AGA8 WebAssembly  1.0
bindings for AGA8 gas properties calculations
Loading...
Searching...
No Matches
bindings.cpp
Go to the documentation of this file.
1
34/*
35 * Copyright (C) 2025 Ronan LE MEILLAT
36 *
37 * This program is free software: you can redistribute it and/or modify
38 * it under the terms of the GNU Affero General Public License as published by
39 * the Free Software Foundation, either version 3 of the License, or
40 * (at your option) any later version.
41 *
42 * This program is distributed in the hope that it will be useful,
43 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 * GNU Affero General Public License for more details.
46 *
47 * You should have received a copy of the GNU Affero General Public License
48 * along with this program. If not, see <https://www.gnu.org/licenses/>.
49 */
50#include <emscripten/bind.h>
51#include <emscripten/val.h>
52#include "Detail.h"
53#include "GERG2008.h"
54#include "Gross.h"
55
56using namespace emscripten;
57
84{
85 double methane;
86 double nitrogen;
88 double ethane;
89 double propane;
90 double isobutane;
91 double n_butane;
92 double isopentane;
93 double n_pentane;
94 double n_hexane;
95 double n_heptane;
96 double n_octane;
97 double n_nonane;
98 double n_decane;
99 double hydrogen;
100 double oxygen;
102 double water;
104 double helium;
105 double argon;
106};
107
115{
116 double P;
117 double Z;
118};
119
129{
130 double D;
131 int ierr;
132 std::string herr;
133};
134
158{
159 double P;
160 double Z;
161 double dPdD;
162 double d2PdD2;
163 double d2PdTD;
164 double dPdT;
165 double U;
166 double H;
167 double S;
168 double Cv;
169 double Cp;
170 double W;
171 double G;
172 double JT;
173 double Kappa;
174 double Cf;
175};
176
201{
202 double P;
203 double Z;
204 double dPdD;
205 double d2PdD2;
206 double d2PdTD;
207 double dPdT;
208 double U;
209 double H;
210 double S;
211 double Cv;
212 double Cp;
213 double W;
214 double G;
215 double JT;
216 double Kappa;
217 double A;
218 double Cf;
219};
220
228struct xGrs
229{
230 double hydrocarbon;
231 double nitrogen;
233};
234
244{
245 double P;
246 double Z;
247 int ierr;
248 std::string herr;
249};
250
261{
263 double HN;
264 double HCH;
265};
266
268{
270 double Gr;
271 double HN;
272 double HCH;
273 int ierr;
274 std::string herr;
275};
276
278{
279 double B;
280 double C;
281 int ierr;
282 std::string herr;
283};
284
286{
288 double Mm;
289 double HCH;
290 double HN;
291 int ierr;
292 std::string herr;
293};
294
296{
298 double Hv;
299 double Mm;
300 double HCH;
301 double HN;
302 int ierr;
303 std::string herr;
304};
305
306// Helper function to convert a JavaScript object to a C++ struct
311std::vector<double> gasMixture_to_vector(gasMixture js_object)
312{
313 std::vector<double> result(22);
314 result[0] = 0;
315 result[1] = js_object.methane;
316 result[2] = js_object.nitrogen;
317 result[3] = js_object.carbon_dioxide;
318 result[4] = js_object.ethane;
319 result[5] = js_object.propane;
320 result[6] = js_object.isobutane;
321 result[7] = js_object.n_butane;
322 result[8] = js_object.isopentane;
323 result[9] = js_object.n_pentane;
324 result[10] = js_object.n_hexane;
325 result[11] = js_object.n_heptane;
326 result[12] = js_object.n_octane;
327 result[13] = js_object.n_nonane;
328 result[14] = js_object.n_decane;
329 result[15] = js_object.hydrogen;
330 result[16] = js_object.oxygen;
331 result[17] = js_object.carbon_monoxide;
332 result[18] = js_object.water;
333 result[19] = js_object.hydrogen_sulfide;
334 result[20] = js_object.helium;
335 result[21] = js_object.argon;
336 return result;
337}
338
339// Helper function to convert a JavaScript xGr object to a C++ struct
344std::vector<double> xGrs_to_vector(xGrs js_object)
345{
346 std::vector<double> result(3);
347 result[0] = 0;
348 result[1] = js_object.hydrocarbon;
349 result[2] = js_object.nitrogen;
350 result[3] = js_object.carbon_dioxide;
351 return result;
352}
353
354// Helper function to convert a vector to a xGrs JavaScript object
359xGrs vector_to_xGrs(const std::vector<double> &vec)
360{
361 xGrs result;
362 result.hydrocarbon = vec[1];
363 result.nitrogen = vec[2];
364 result.carbon_dioxide = vec[3];
365 return result;
366}
367
368// Helper function to convert a JavaScript array to a C++ vector
379std::vector<double> array_to_vector(const val &js_array)
380{
381 auto length = js_array["length"].as<unsigned>();
382 std::vector<double> result(length);
383 for (unsigned i = 0; i < length; ++i)
384 {
385 result[i] = js_array[i].as<double>();
386 }
387 return result;
388}
389
390// Helper function to convert a C++ vector to a JavaScript array
401val vector_to_array(const std::vector<double> &vec)
402{
403 val result = val::array();
404 for (size_t i = 0; i < vec.size(); ++i)
405 {
406 result.set(i, vec[i]);
407 }
408 return result;
409}
410
411// Detail wrappers
424{
425 std::vector<double> x = gasMixture_to_vector(x_array);
426 double Mm = 0;
427 MolarMassDetail(x, Mm);
428 return Mm;
429}
430
446{
447 std::vector<double> x = gasMixture_to_vector(x_array);
448 double P = 0, Z = 0;
449 PressureDetail(T, D, x, P, Z);
450 PressureResult result = {P, Z};
451 return result;
452}
453
469{
470 std::vector<double> x = gasMixture_to_vector(x_array);
471 double D = 0;
472 int ierr = 0;
473 std::string herr;
474
475 DensityDetail(T, P, x, D, ierr, herr);
476
477 DensityResult result = {D, ierr, herr};
478 return result;
479}
480
508{
509 std::vector<double> x = gasMixture_to_vector(x_array);
510 double P = 0, Z = 0, dPdD = 0, d2PdD2 = 0, d2PdTD = 0, dPdT = 0;
511 double U = 0, H = 0, S = 0, Cv = 0, Cp = 0, W = 0, G = 0, JT = 0, Kappa = 0, Cf = 0;
512
513 PropertiesDetail(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT,
514 U, H, S, Cv, Cp, W, G, JT, Kappa, Cf);
515
516 PropertiesDetailResult result = {P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, Kappa, Cf};
517
518 return result;
519}
520
521// GERG wrappers
534{
535 std::vector<double> x = gasMixture_to_vector(x_array);
536 double Mm = 0;
537 MolarMassGERG(x, Mm);
538 return Mm;
539}
540
557{
558 std::vector<double> x = gasMixture_to_vector(x_array);
559 double P = 0, Z = 0;
560 PressureGERG(T, D, x, P, Z);
561
562 PressureResult result = {P, Z};
563 return result;
564}
565
580DensityResult DensityGERG_wrapper(int iflag, double T, double P, gasMixture x_array)
581{
582 std::vector<double> x = gasMixture_to_vector(x_array);
583 double D = 0;
584 int ierr = 0;
585 std::string herr;
586
587 DensityGERG(iflag, T, P, x, D, ierr, herr);
588
589 DensityResult result = {D, ierr, herr};
590 return result;
591}
592
622{
623 std::vector<double> x = gasMixture_to_vector(x_array);
624 double P = 0, Z = 0, dPdD = 0, d2PdD2 = 0, d2PdTD = 0, dPdT = 0;
625 double U = 0, H = 0, S = 0, Cv = 0, Cp = 0, W = 0, G = 0, JT = 0, Kappa = 0, A = 0, Cf = 0;
626
627 PropertiesGERG(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT,
628 U, H, S, Cv, Cp, W, G, JT, Kappa, A, Cf);
629
630 PropertiesGERGResult result = {P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, Kappa, A, Cf};
631 return result;
632}
633
634// Gross wrappers
647{
648 std::vector<double> x = gasMixture_to_vector(x_array);
649 double Mm = 0;
650 MolarMassGross(x, Mm);
651 return Mm;
652}
653
673PressureGrossResult PressureGross_wrapper(double T, double D, xGrs xGrs_object, double HCH)
674{
675 std::vector<double> xGrs = xGrs_to_vector(xGrs_object);
676 double P = 0, Z = 0;
677 int ierr = 0;
678 std::string herr;
679
680 PressureGross(T, D, xGrs, HCH, P, Z, ierr, herr);
681
682 PressureGrossResult result = {P, Z, ierr, herr};
683 return result;
684}
685
703DensityResult DensityGross_wrapper(double T, double P, xGrs xGrs_object, double HCH)
704{
705 std::vector<double> xGrs = xGrs_to_vector(xGrs_object);
706 double D = 0;
707 int ierr = 0;
708 std::string herr;
709
710 DensityGross(T, P, xGrs, HCH, D, ierr, herr);
711
712 DensityResult result = {D, ierr, herr};
713 return result;
714}
715
732{
733 std::vector<double> x = gasMixture_to_vector(x_array);
734 std::vector<double> xGrs(x.size());
735 double HN = 0, HCH = 0;
736
737 GrossHv(x, xGrs, HN, HCH);
738 GrossHvResult result = {vector_to_xGrs(xGrs), HN, HCH};
739 return result;
740}
741
760{
761 std::vector<double> x = gasMixture_to_vector(x_array);
762 std::vector<double> xGrs(x.size());
763 double Gr = 0, HN = 0, HCH = 0;
764 int ierr = 0;
765 std::string herr;
766
767 GrossInputs(T, P, x, xGrs, Gr, HN, HCH, ierr, herr);
768
769 GrossInputsResult result = {vector_to_xGrs(xGrs), Gr, HN, HCH, ierr, herr};
770 return result;
771}
772
790BmixResult Bmix_wrapper(double T, xGrs xGrs_object, double HCH)
791{
792 std::vector<double> xGrs = xGrs_to_vector(xGrs_object);
793 double B = 0, C = 0;
794 int ierr = 0;
795 std::string herr;
796
797 Bmix(T, xGrs, HCH, B, C, ierr, herr);
798
799 BmixResult result = {B, C, ierr, herr};
800 return result;
801}
802
823GrossMethod1Result GrossMethod1_wrapper(double Th, double Td, double Pd, xGrs xGrs_object, double Gr, double Hv)
824{
825 std::vector<double> xGrs = xGrs_to_vector(xGrs_object);
826 double Mm = 0, HCH = 0, HN = 0;
827 int ierr = 0;
828 std::string herr;
829
830 GrossMethod1(Th, Td, Pd, xGrs, Gr, Hv, Mm, HCH, HN, ierr, herr);
831
832 GrossMethod1Result result = {vector_to_xGrs(xGrs), Mm, HCH, HN, ierr, herr};
833 return result;
834}
835
856GrossMethod2Result GrossMethod2_wrapper(double Th, double Td, double Pd, xGrs xGrs_object, double Gr)
857{
858 std::vector<double> xGrs = xGrs_to_vector(xGrs_object);
859 double Hv = 0, Mm = 0, HCH = 0, HN = 0;
860 int ierr = 0;
861 std::string herr;
862
863 GrossMethod2(Th, Td, Pd, xGrs, Gr, Hv, Mm, HCH, HN, ierr, herr);
864
865 GrossMethod2Result result = {vector_to_xGrs(xGrs), Hv, Mm, HCH, HN, ierr, herr};
866 return result;
867}
868
922{
923 register_vector<double>("VectorDouble");
924
925 value_object<gasMixture>("GasMixture")
926 .field("methane", &gasMixture::methane)
927 .field("nitrogen", &gasMixture::nitrogen)
928 .field("carbon_dioxide", &gasMixture::carbon_dioxide)
929 .field("ethane", &gasMixture::ethane)
930 .field("propane", &gasMixture::propane)
931 .field("isobutane", &gasMixture::isobutane)
932 .field("n_butane", &gasMixture::n_butane)
933 .field("isopentane", &gasMixture::isopentane)
934 .field("n_pentane", &gasMixture::n_pentane)
935 .field("n_hexane", &gasMixture::n_hexane)
936 .field("n_heptane", &gasMixture::n_heptane)
937 .field("n_octane", &gasMixture::n_octane)
938 .field("n_nonane", &gasMixture::n_nonane)
939 .field("n_decane", &gasMixture::n_decane)
940 .field("hydrogen", &gasMixture::hydrogen)
941 .field("oxygen", &gasMixture::oxygen)
942 .field("carbon_monoxide", &gasMixture::carbon_monoxide)
943 .field("water", &gasMixture::water)
944 .field("hydrogen_sulfide", &gasMixture::hydrogen_sulfide)
945 .field("helium", &gasMixture::helium)
946 .field("argon", &gasMixture::argon);
947
948 value_object<xGrs>("xGrs")
949 .field("hydrocarbon", &xGrs::hydrocarbon)
950 .field("nitrogen", &xGrs::nitrogen)
951 .field("carbon_dioxide", &xGrs::carbon_dioxide);
952
953 value_object<PressureResult>("PressureResult")
954 .field("P", &PressureResult::P)
955 .field("Z", &PressureResult::Z);
956
957 value_object<DensityResult>("DensityResult")
958 .field("D", &DensityResult::D)
959 .field("ierr", &DensityResult::ierr)
960 .field("herr", &DensityResult::herr);
961
962 value_object<PropertiesDetailResult>("PropertiesDetailResult")
963 .field("P", &PropertiesDetailResult::P)
964 .field("Z", &PropertiesDetailResult::Z)
965 .field("dPdD", &PropertiesDetailResult::dPdD)
966 .field("d2PdD2", &PropertiesDetailResult::d2PdD2)
967 .field("d2PdTD", &PropertiesDetailResult::d2PdTD)
968 .field("dPdT", &PropertiesDetailResult::dPdT)
969 .field("U", &PropertiesDetailResult::U)
970 .field("H", &PropertiesDetailResult::H)
971 .field("S", &PropertiesDetailResult::S)
972 .field("Cv", &PropertiesDetailResult::Cv)
973 .field("Cp", &PropertiesDetailResult::Cp)
974 .field("W", &PropertiesDetailResult::W)
975 .field("G", &PropertiesDetailResult::G)
976 .field("JT", &PropertiesDetailResult::JT)
977 .field("Kappa", &PropertiesDetailResult::Kappa)
978 .field("Cf", &PropertiesDetailResult::Cf);
979
980 value_object<PropertiesGERGResult>("PropertiesGERGResult")
981 .field("P", &PropertiesGERGResult::P)
982 .field("Z", &PropertiesGERGResult::Z)
983 .field("dPdD", &PropertiesGERGResult::dPdD)
984 .field("d2PdD2", &PropertiesGERGResult::d2PdD2)
985 .field("d2PdTD", &PropertiesGERGResult::d2PdTD)
986 .field("dPdT", &PropertiesGERGResult::dPdT)
987 .field("U", &PropertiesGERGResult::U)
988 .field("H", &PropertiesGERGResult::H)
989 .field("S", &PropertiesGERGResult::S)
990 .field("Cv", &PropertiesGERGResult::Cv)
991 .field("Cp", &PropertiesGERGResult::Cp)
992 .field("W", &PropertiesGERGResult::W)
993 .field("G", &PropertiesGERGResult::G)
994 .field("JT", &PropertiesGERGResult::JT)
995 .field("Kappa", &PropertiesGERGResult::Kappa)
996 .field("A", &PropertiesGERGResult::A)
997 .field("Cf", &PropertiesGERGResult::Cf);
998
999 value_object<PressureGrossResult>("PressureGrossResult")
1000 .field("P", &PressureGrossResult::P)
1001 .field("Z", &PressureGrossResult::Z)
1002 .field("ierr", &PressureGrossResult::ierr)
1003 .field("herr", &PressureGrossResult::herr);
1004
1005 value_object<GrossHvResult>("GrossHvResult")
1006 .field("xGrs", &GrossHvResult::xGrs)
1007 .field("HN", &GrossHvResult::HN)
1008 .field("HCH", &GrossHvResult::HCH);
1009
1010 value_object<GrossInputsResult>("GrossInputsResult")
1011 .field("xGrs", &GrossInputsResult::xGrs)
1012 .field("Gr", &GrossInputsResult::Gr)
1013 .field("HN", &GrossInputsResult::HN)
1014 .field("HCH", &GrossInputsResult::HCH)
1015 .field("ierr", &GrossInputsResult::ierr)
1016 .field("herr", &GrossInputsResult::herr);
1017
1018 value_object<BmixResult>("BmixResult")
1019 .field("B", &BmixResult::B)
1020 .field("C", &BmixResult::C)
1021 .field("ierr", &BmixResult::ierr)
1022 .field("herr", &BmixResult::herr);
1023
1024 value_object<GrossMethod1Result>("GrossMethod1Result")
1025 .field("xGrs", &GrossMethod1Result::xGrs)
1026 .field("Mm", &GrossMethod1Result::Mm)
1027 .field("HCH", &GrossMethod1Result::HCH)
1028 .field("HN", &GrossMethod1Result::HN)
1029 .field("ierr", &GrossMethod1Result::ierr)
1030 .field("herr", &GrossMethod1Result::herr);
1031
1032 value_object<GrossMethod2Result>("GrossMethod2Result")
1033 .field("xGrs", &GrossMethod2Result::xGrs)
1034 .field("Hv", &GrossMethod2Result::Hv)
1035 .field("Mm", &GrossMethod2Result::Mm)
1036 .field("HCH", &GrossMethod2Result::HCH)
1037 .field("HN", &GrossMethod2Result::HN)
1038 .field("ierr", &GrossMethod2Result::ierr)
1039 .field("herr", &GrossMethod2Result::herr);
1040
1041 // Detail bindings
1042 function("SetupDetail", &SetupDetail);
1043 function("MolarMassDetail", &MolarMassDetail_wrapper);
1044 function("PressureDetail", &PressureDetail_wrapper);
1045 function("DensityDetail", &DensityDetail_wrapper);
1046 function("PropertiesDetail", &PropertiesDetail_wrapper);
1047
1048 // GERG bindings
1049 function("SetupGERG", &SetupGERG);
1050 function("MolarMassGERG", &MolarMassGERG_wrapper);
1051 function("PressureGERG", &PressureGERG_wrapper);
1052 function("DensityGERG", &DensityGERG_wrapper);
1053 function("PropertiesGERG", &PropertiesGERG_wrapper);
1054
1055 // Gross bindings
1056 function("SetupGross", &SetupGross);
1057 function("MolarMassGross", &MolarMassGross_wrapper);
1058 function("PressureGross", &PressureGross_wrapper);
1059 function("DensityGross", &DensityGross_wrapper);
1060 function("GrossHv", &GrossHv_wrapper);
1061 function("GrossInputs", &GrossInputs_wrapper);
1062 function("Bmix", &Bmix_wrapper);
1063 function("GrossMethod1", &GrossMethod1_wrapper);
1064 function("GrossMethod2", &GrossMethod2_wrapper);
1065}
void PressureDetail(const double T, const double D, const std::vector< double > &x, double &P, double &Z)
Calculates pressure and compressibility factor as a function of temperature and density.
Definition Detail.cpp:196
void MolarMassDetail(const std::vector< double > &x, double &Mm)
Calculate molar mass of a mixture based on composition.
Definition Detail.cpp:158
void PropertiesDetail(const double T, const double D, const std::vector< double > &x, double &P, double &Z, double &dPdD, double &d2PdD2, double &d2PdTD, double &dPdT, double &U, double &H, double &S, double &Cv, double &Cp, double &W, double &G, double &JT, double &Kappa, double &Cf)
Calculates thermodynamic properties as a function of temperature and density.
Definition Detail.cpp:350
void SetupDetail()
The following routine must be called once before any other routine.
Definition Detail.cpp:806
void DensityDetail(const double T, const double P, const std::vector< double > &x, double &D, int &ierr, std::string &herr)
Calculates density as a function of temperature and pressure using an iterative method.
Definition Detail.cpp:246
void MolarMassGERG(const std::vector< double > &x, double &Mm)
Calculate molar mass of a gas mixture.
Definition GERG2008.cpp:191
void SetupGERG()
Initializes all the constants and parameters in the GERG-2008 model.
Definition GERG2008.cpp:775
void PropertiesGERG(const double T, const double D, const std::vector< double > &x, double &P, double &Z, double &dPdD, double &d2PdD2, double &d2PdTD, double &dPdT, double &U, double &H, double &S, double &Cv, double &Cp, double &W, double &G, double &JT, double &Kappa, double &A, double &Cf)
Calculate thermodynamic properties as a function of temperature and density.
Definition GERG2008.cpp:371
void DensityGERG(const int iFlag, const double T, const double P, const std::vector< double > &x, double &D, int &ierr, std::string &herr)
Calculate density from temperature and pressure.
Definition GERG2008.cpp:247
void PressureGERG(const double T, const double D, const std::vector< double > &x, double &P, double &Z)
Calculate pressure and compressibility factor.
Definition GERG2008.cpp:216
void GrossHv(const std::vector< double > &x, std::vector< double > &xGrs, double &HN, double &HCH)
Calculate ideal heating values based on composition.
Definition Gross.cpp:317
void GrossMethod2(const double Th, const double Td, const double Pd, std::vector< double > &xGrs, const double Gr, double &Hv, double &Mm, double &HCH, double &HN, int &ierr, std::string &herr)
Initialize variables required in the GROSS equation with Method 2 of the AGA 8 Part 1 publication.
Definition Gross.cpp:594
void DensityGross(const double T, const double P, const std::vector< double > &xGrs, const double HCH, double &D, int &ierr, std::string &herr)
Calculate density as a function of temperature and pressure.
Definition Gross.cpp:236
void PressureGross(const double T, const double D, const std::vector< double > &xGrs, const double HCH, double &P, double &Z, int &ierr, std::string &herr)
Calculate pressure as a function of temperature and density.
Definition Gross.cpp:183
void GrossMethod1(const double Th, const double Td, const double Pd, std::vector< double > &xGrs, const double Gr, const double Hv, double &Mm, double &HCH, double &HN, int &ierr, std::string &herr)
Initialize variables required in the GROSS equation with Method 1 of the AGA 8 Part 1 publication.
Definition Gross.cpp:517
void SetupGross()
Initialize all the constants and parameters in the GROSS model.
Definition Gross.cpp:651
void Bmix(const double T, const std::vector< double > &xGrs, const double HCH, double &B, double &C, int &ierr, std::string &herr)
Calculate 2nd and 3rd virial coefficients for the mixture at T.
Definition Gross.cpp:412
void GrossInputs(const double T, const double P, const std::vector< double > &x, std::vector< double > &xGrs, double &Gr, double &HN, double &HCH, int &ierr, std::string &herr)
Calculate relative density and heating values based on composition.
Definition Gross.cpp:364
void MolarMassGross(const std::vector< double > &x, double &Mm)
Calculate molar mass of the mixture with the compositions contained in the x() input array.
Definition Gross.cpp:143
BmixResult Bmix_wrapper(double T, xGrs xGrs_object, double HCH)
Calculates mixture second and third virial coefficients using the GERG-2008 equation of state.
Definition bindings.cpp:790
GrossMethod2Result GrossMethod2_wrapper(double Th, double Td, double Pd, xGrs xGrs_object, double Gr)
Wrapper function for the GrossMethod2 calculation method.
Definition bindings.cpp:856
GrossHvResult GrossHv_wrapper(gasMixture x_array)
Wrapper function to calculate gross heating values for a gas mixture.
Definition bindings.cpp:731
PressureResult PressureDetail_wrapper(double T, double D, gasMixture x_array)
Wraps the PressureDetail function to calculate pressure and compressibility factor.
Definition bindings.cpp:445
std::vector< double > gasMixture_to_vector(gasMixture js_object)
Converts a JavaScript gasMixture Object to a C++ struct.
Definition bindings.cpp:311
double MolarMassGERG_wrapper(gasMixture x_array)
Calculates the molar mass of a gas mixture using GERG-2008 equation of state.
Definition bindings.cpp:533
PropertiesDetailResult PropertiesDetail_wrapper(double T, double D, gasMixture x_array)
Wrapper function to calculate detailed thermodynamic properties of a gas mixture.
Definition bindings.cpp:507
EMSCRIPTEN_BINDINGS(AGA8_module)
Emscripten bindings for the AGA8 gas calculation module.
Definition bindings.cpp:921
val vector_to_array(const std::vector< double > &vec)
Converts a C++ vector of doubles to a JavaScript array.
Definition bindings.cpp:401
double MolarMassGross_wrapper(gasMixture x_array)
Calculates the gross molar mass of a gas mixture.
Definition bindings.cpp:646
PressureResult PressureGERG_wrapper(double T, double D, gasMixture x_array)
Calculates pressure and compressibility factor using GERG-2008 equation of state.
Definition bindings.cpp:556
PressureGrossResult PressureGross_wrapper(double T, double D, xGrs xGrs_object, double HCH)
Wrapper function for PressureGross calculation.
Definition bindings.cpp:673
DensityResult DensityGross_wrapper(double T, double P, xGrs xGrs_object, double HCH)
Wrapper function for DensityGross calculation.
Definition bindings.cpp:703
GrossInputsResult GrossInputs_wrapper(double T, double P, gasMixture x_array)
Wrapper function for GrossInputs calculation.
Definition bindings.cpp:759
GrossMethod1Result GrossMethod1_wrapper(double Th, double Td, double Pd, xGrs xGrs_object, double Gr, double Hv)
Wrapper function for GrossMethod1 calculation method.
Definition bindings.cpp:823
xGrs vector_to_xGrs(const std::vector< double > &vec)
Converts a C++ vector to a JavaScript xGrs object.
Definition bindings.cpp:359
double MolarMassDetail_wrapper(gasMixture x_array)
Calculates the molar mass of a gas mixture given mole percentages.
Definition bindings.cpp:423
DensityResult DensityGERG_wrapper(int iflag, double T, double P, gasMixture x_array)
Wrapper function to calculate density using GERG-2008 equation of state.
Definition bindings.cpp:580
std::vector< double > xGrs_to_vector(xGrs js_object)
Converts a JavaScript xGrs Object to a C++ struct.
Definition bindings.cpp:344
std::vector< double > array_to_vector(const val &js_array)
Converts a JavaScript array to a C++ vector of doubles.
Definition bindings.cpp:379
PropertiesGERGResult PropertiesGERG_wrapper(double T, double D, gasMixture x_array)
Calculates thermodynamic properties using GERG-2008 equation of state.
Definition bindings.cpp:621
DensityResult DensityDetail_wrapper(double T, double P, gasMixture x_array)
Calculates the density of a gas mixture given temperature, pressure and composition.
Definition bindings.cpp:468
std::string herr
Definition bindings.cpp:282
Structure to hold the results of density calculations.
Definition bindings.cpp:129
std::string herr
Definition bindings.cpp:132
std::string herr
Definition bindings.cpp:274
std::string herr
Definition bindings.cpp:292
std::string herr
Definition bindings.cpp:303
Structure containing thermodynamic properties for GERG-2008 calculations.
Definition bindings.cpp:201
double n_pentane
Definition bindings.cpp:93
double n_nonane
Definition bindings.cpp:97
double carbon_dioxide
Definition bindings.cpp:87
double oxygen
Definition bindings.cpp:100
double water
Definition bindings.cpp:102
double methane
Definition bindings.cpp:85
double hydrogen
Definition bindings.cpp:99
double isobutane
Definition bindings.cpp:90
double argon
Definition bindings.cpp:105
double nitrogen
Definition bindings.cpp:86
double n_octane
Definition bindings.cpp:96
double n_hexane
Definition bindings.cpp:94
double carbon_monoxide
Definition bindings.cpp:101
double hydrogen_sulfide
Definition bindings.cpp:103
double helium
Definition bindings.cpp:104
double isopentane
Definition bindings.cpp:92
double n_decane
Definition bindings.cpp:98
double n_heptane
Definition bindings.cpp:95
double ethane
Definition bindings.cpp:88
double propane
Definition bindings.cpp:89
double n_butane
Definition bindings.cpp:91
double hydrocarbon
Definition bindings.cpp:230
double nitrogen
Definition bindings.cpp:231
double carbon_dioxide
Definition bindings.cpp:232