50#include <emscripten/bind.h>
51#include <emscripten/val.h>
56using namespace emscripten;
313 std::vector<double> result(22);
318 result[4] = js_object.
ethane;
330 result[16] = js_object.
oxygen;
332 result[18] = js_object.
water;
334 result[20] = js_object.
helium;
335 result[21] = js_object.
argon;
346 std::vector<double> result(3);
381 auto length = js_array[
"length"].as<
unsigned>();
382 std::vector<double> result(length);
383 for (
unsigned i = 0; i < length; ++i)
385 result[i] = js_array[i].as<
double>();
403 val result = val::array();
404 for (
size_t i = 0; i < vec.size(); ++i)
406 result.set(i, vec[i]);
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;
514 U, H, S, Cv, Cp, W, G, JT, Kappa, Cf);
516 PropertiesDetailResult result = {P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, Kappa, Cf};
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;
628 U, H, S, Cv, Cp, W, G, JT, Kappa, A, Cf);
630 PropertiesGERGResult result = {P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, Kappa, A, Cf};
734 std::vector<double>
xGrs(x.size());
735 double HN = 0, HCH = 0;
762 std::vector<double>
xGrs(x.size());
763 double Gr = 0, HN = 0, HCH = 0;
797 Bmix(T,
xGrs, HCH, B, C, ierr, herr);
826 double Mm = 0, HCH = 0, HN = 0;
830 GrossMethod1(Th, Td, Pd,
xGrs, Gr, Hv, Mm, HCH, HN, ierr, herr);
859 double Hv = 0, Mm = 0, HCH = 0, HN = 0;
863 GrossMethod2(Th, Td, Pd,
xGrs, Gr, Hv, Mm, HCH, HN, ierr, herr);
923 register_vector<double>(
"VectorDouble");
925 value_object<gasMixture>(
"GasMixture")
948 value_object<xGrs>(
"xGrs")
953 value_object<PressureResult>(
"PressureResult")
957 value_object<DensityResult>(
"DensityResult")
962 value_object<PropertiesDetailResult>(
"PropertiesDetailResult")
980 value_object<PropertiesGERGResult>(
"PropertiesGERGResult")
999 value_object<PressureGrossResult>(
"PressureGrossResult")
1005 value_object<GrossHvResult>(
"GrossHvResult")
1010 value_object<GrossInputsResult>(
"GrossInputsResult")
1018 value_object<BmixResult>(
"BmixResult")
1024 value_object<GrossMethod1Result>(
"GrossMethod1Result")
1032 value_object<GrossMethod2Result>(
"GrossMethod2Result")
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.
void MolarMassDetail(const std::vector< double > &x, double &Mm)
Calculate molar mass of a mixture based on composition.
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.
void SetupDetail()
The following routine must be called once before any other routine.
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.
void MolarMassGERG(const std::vector< double > &x, double &Mm)
Calculate molar mass of a gas mixture.
void SetupGERG()
Initializes all the constants and parameters in the GERG-2008 model.
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.
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.
void PressureGERG(const double T, const double D, const std::vector< double > &x, double &P, double &Z)
Calculate pressure and compressibility factor.
void GrossHv(const std::vector< double > &x, std::vector< double > &xGrs, double &HN, double &HCH)
Calculate ideal heating values based on composition.
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.
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.
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.
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.
void SetupGross()
Initialize all the constants and parameters in the GROSS model.
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.
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.
void MolarMassGross(const std::vector< double > &x, double &Mm)
Calculate molar mass of the mixture with the compositions contained in the x() input array.
BmixResult Bmix_wrapper(double T, xGrs xGrs_object, double HCH)
Calculates mixture second and third virial coefficients using the GERG-2008 equation of state.
GrossMethod2Result GrossMethod2_wrapper(double Th, double Td, double Pd, xGrs xGrs_object, double Gr)
Wrapper function for the GrossMethod2 calculation method.
GrossHvResult GrossHv_wrapper(gasMixture x_array)
Wrapper function to calculate gross heating values for a gas mixture.
PressureResult PressureDetail_wrapper(double T, double D, gasMixture x_array)
Wraps the PressureDetail function to calculate pressure and compressibility factor.
std::vector< double > gasMixture_to_vector(gasMixture js_object)
Converts a JavaScript gasMixture Object to a C++ struct.
double MolarMassGERG_wrapper(gasMixture x_array)
Calculates the molar mass of a gas mixture using GERG-2008 equation of state.
PropertiesDetailResult PropertiesDetail_wrapper(double T, double D, gasMixture x_array)
Wrapper function to calculate detailed thermodynamic properties of a gas mixture.
EMSCRIPTEN_BINDINGS(AGA8_module)
Emscripten bindings for the AGA8 gas calculation module.
val vector_to_array(const std::vector< double > &vec)
Converts a C++ vector of doubles to a JavaScript array.
double MolarMassGross_wrapper(gasMixture x_array)
Calculates the gross molar mass of a gas mixture.
PressureResult PressureGERG_wrapper(double T, double D, gasMixture x_array)
Calculates pressure and compressibility factor using GERG-2008 equation of state.
PressureGrossResult PressureGross_wrapper(double T, double D, xGrs xGrs_object, double HCH)
Wrapper function for PressureGross calculation.
DensityResult DensityGross_wrapper(double T, double P, xGrs xGrs_object, double HCH)
Wrapper function for DensityGross calculation.
GrossInputsResult GrossInputs_wrapper(double T, double P, gasMixture x_array)
Wrapper function for GrossInputs calculation.
GrossMethod1Result GrossMethod1_wrapper(double Th, double Td, double Pd, xGrs xGrs_object, double Gr, double Hv)
Wrapper function for GrossMethod1 calculation method.
xGrs vector_to_xGrs(const std::vector< double > &vec)
Converts a C++ vector to a JavaScript xGrs object.
double MolarMassDetail_wrapper(gasMixture x_array)
Calculates the molar mass of a gas mixture given mole percentages.
DensityResult DensityGERG_wrapper(int iflag, double T, double P, gasMixture x_array)
Wrapper function to calculate density using GERG-2008 equation of state.
std::vector< double > xGrs_to_vector(xGrs js_object)
Converts a JavaScript xGrs Object to a C++ struct.
std::vector< double > array_to_vector(const val &js_array)
Converts a JavaScript array to a C++ vector of doubles.
PropertiesGERGResult PropertiesGERG_wrapper(double T, double D, gasMixture x_array)
Calculates thermodynamic properties using GERG-2008 equation of state.
DensityResult DensityDetail_wrapper(double T, double P, gasMixture x_array)
Calculates the density of a gas mixture given temperature, pressure and composition.
Structure to hold the results of density calculations.
Structure containing thermodynamic properties for GERG-2008 calculations.