AGA8 WebAssembly
1.0
bindings for AGA8 gas properties calculations
|
Emscripten bindings for the AGA8 gas calculation library. More...
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "Detail.h"
#include "GERG2008.h"
#include "Gross.h"
Go to the source code of this file.
Data Structures | |
struct | gasMixture |
struct | PressureResult |
struct | DensityResult |
Structure to hold the results of density calculations. More... | |
struct | PropertiesDetailResult |
struct | PropertiesGERGResult |
Structure containing thermodynamic properties for GERG-2008 calculations. More... | |
struct | xGrs |
struct | PressureGrossResult |
struct | GrossHvResult |
struct | GrossInputsResult |
struct | BmixResult |
struct | GrossMethod1Result |
struct | GrossMethod2Result |
Functions | |
std::vector< double > | gasMixture_to_vector (gasMixture js_object) |
Converts a JavaScript gasMixture Object to a C++ struct. | |
std::vector< double > | xGrs_to_vector (xGrs js_object) |
Converts a JavaScript xGrs Object to a C++ struct. | |
xGrs | vector_to_xGrs (const std::vector< double > &vec) |
Converts a C++ vector to a JavaScript xGrs object. | |
std::vector< double > | array_to_vector (const val &js_array) |
Converts a JavaScript array to a C++ vector of doubles. | |
val | vector_to_array (const std::vector< double > &vec) |
Converts a C++ vector of doubles to a JavaScript array. | |
double | MolarMassDetail_wrapper (gasMixture x_array) |
Calculates the molar mass of a gas mixture given mole percentages. | |
PressureResult | PressureDetail_wrapper (double T, double D, gasMixture x_array) |
Wraps the PressureDetail function to calculate pressure and compressibility factor. | |
DensityResult | DensityDetail_wrapper (double T, double P, gasMixture x_array) |
Calculates the density of a gas mixture given temperature, pressure and composition. | |
PropertiesDetailResult | PropertiesDetail_wrapper (double T, double D, gasMixture x_array) |
Wrapper function to calculate detailed thermodynamic properties of a gas mixture. | |
double | MolarMassGERG_wrapper (gasMixture x_array) |
Calculates the molar mass of a gas mixture using GERG-2008 equation of state. | |
PressureResult | PressureGERG_wrapper (double T, double D, gasMixture x_array) |
Calculates pressure and compressibility factor using GERG-2008 equation of state. | |
DensityResult | DensityGERG_wrapper (int iflag, double T, double P, gasMixture x_array) |
Wrapper function to calculate density using GERG-2008 equation of state. | |
PropertiesGERGResult | PropertiesGERG_wrapper (double T, double D, gasMixture x_array) |
Calculates thermodynamic properties using GERG-2008 equation of state. | |
double | MolarMassGross_wrapper (gasMixture x_array) |
Calculates the gross molar mass of a gas mixture. | |
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. | |
GrossHvResult | GrossHv_wrapper (gasMixture x_array) |
Wrapper function to calculate gross heating values for a gas mixture. | |
GrossInputsResult | GrossInputs_wrapper (double T, double P, gasMixture x_array) |
Wrapper function for GrossInputs calculation. | |
BmixResult | Bmix_wrapper (double T, xGrs xGrs_object, double HCH) |
Calculates mixture second and third virial coefficients using the GERG-2008 equation of state. | |
GrossMethod1Result | GrossMethod1_wrapper (double Th, double Td, double Pd, xGrs xGrs_object, double Gr, double Hv) |
Wrapper function for GrossMethod1 calculation method. | |
GrossMethod2Result | GrossMethod2_wrapper (double Th, double Td, double Pd, xGrs xGrs_object, double Gr) |
Wrapper function for the GrossMethod2 calculation method. | |
EMSCRIPTEN_BINDINGS (AGA8_module) | |
Emscripten bindings for the AGA8 gas calculation module. | |
Emscripten bindings for the AGA8 gas calculation library.
This file provides WebAssembly bindings for the AGA8 gas calculation library, enabling its use in JavaScript environments. It implements three main calculation methods:
The gas composition is represented using a 21-component system where:
Example mixture (94% methane, 5% CO2, 1% helium): gasMixtureInMolePercent(1) = 0.94 // Methane gasMixtureInMolePercent(3) = 0.05 // CO2 gasMixtureInMolePercent(20) = 0.01 // Helium
Definition in file bindings.cpp.
std::vector< double > array_to_vector | ( | const val & | js_array | ) |
Converts a JavaScript array to a C++ vector of doubles.
js_array | JavaScript array object passed as an emscripten::val |
This function takes a JavaScript array passed through emscripten's val interface and converts it to a C++ std::vector<double>. Each element in the JavaScript array is converted to a double value.
Definition at line 379 of file bindings.cpp.
BmixResult Bmix_wrapper | ( | double | T, |
xGrs | xGrs_object, | ||
double | HCH ) |
Calculates mixture second and third virial coefficients using the GERG-2008 equation of state.
T | Temperature [K] |
xGrs_object | Array of mole fractions for each component in the mixture |
HCH | Parameter for handling hydrocarbon mixtures |
This function serves as a wrapper for the Bmix calculation, converting array inputs to the required vector format and returning results in a structured format.
Definition at line 790 of file bindings.cpp.
References Bmix(), and xGrs_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
DensityResult DensityDetail_wrapper | ( | double | T, |
double | P, | ||
gasMixture | x_array ) |
Calculates the density of a gas mixture given temperature, pressure and composition.
This function wraps the DensityDetail calculation for easier interface handling.
T | Temperature in K |
P | Pressure in kPa |
x_array | Gas mixture composition in mole percent |
Definition at line 468 of file bindings.cpp.
References DensityDetail(), and gasMixture_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
DensityResult DensityGERG_wrapper | ( | int | iflag, |
double | T, | ||
double | P, | ||
gasMixture | x_array ) |
Wrapper function to calculate density using GERG-2008 equation of state.
iflag | Flag to specify calculation path (1: density from pressure/temperature, 2: pressure from density/temperature) |
T | Temperature [K] |
P | Pressure [kPa] |
x_array | Array containing mole fractions of components in percent |
Definition at line 580 of file bindings.cpp.
References DensityGERG(), and gasMixture_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
DensityResult DensityGross_wrapper | ( | double | T, |
double | P, | ||
xGrs | xGrs_object, | ||
double | HCH ) |
Wrapper function for DensityGross calculation.
This function calculates the density of a natural gas mixture using the GERG-2008 equation of state
T | Temperature [K] |
P | Pressure [kPa] |
xGrs_object | Array containing mole fractions of the mixture components |
HCH | Heating value [MJ/m³] |
Definition at line 703 of file bindings.cpp.
References DensityGross(), and xGrs_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
EMSCRIPTEN_BINDINGS | ( | AGA8_module | ) |
Emscripten bindings for the AGA8 gas calculation module.
These bindings expose the AGA8 gas calculation functionality to JavaScript/WebAssembly. It includes:
Enums:
Types:
Value Objects:
Functions: Detail Methods:
GERG Methods:
Gross Methods:
Definition at line 921 of file bindings.cpp.
References PropertiesGERGResult::A, gasMixture::argon, BmixResult::B, Bmix_wrapper(), BmixResult::C, gasMixture::carbon_dioxide, xGrs::carbon_dioxide, gasMixture::carbon_monoxide, PropertiesDetailResult::Cf, PropertiesGERGResult::Cf, PropertiesDetailResult::Cp, PropertiesGERGResult::Cp, PropertiesDetailResult::Cv, PropertiesGERGResult::Cv, DensityResult::D, PropertiesDetailResult::d2PdD2, PropertiesGERGResult::d2PdD2, PropertiesDetailResult::d2PdTD, PropertiesGERGResult::d2PdTD, DensityDetail_wrapper(), DensityGERG_wrapper(), DensityGross_wrapper(), PropertiesDetailResult::dPdD, PropertiesGERGResult::dPdD, PropertiesDetailResult::dPdT, PropertiesGERGResult::dPdT, gasMixture::ethane, PropertiesDetailResult::G, PropertiesGERGResult::G, GrossInputsResult::Gr, GrossHv_wrapper(), GrossInputs_wrapper(), GrossMethod1_wrapper(), GrossMethod2_wrapper(), PropertiesDetailResult::H, PropertiesGERGResult::H, GrossHvResult::HCH, GrossInputsResult::HCH, GrossMethod1Result::HCH, GrossMethod2Result::HCH, gasMixture::helium, BmixResult::herr, DensityResult::herr, GrossInputsResult::herr, GrossMethod1Result::herr, GrossMethod2Result::herr, PressureGrossResult::herr, GrossHvResult::HN, GrossInputsResult::HN, GrossMethod1Result::HN, GrossMethod2Result::HN, GrossMethod2Result::Hv, xGrs::hydrocarbon, gasMixture::hydrogen, gasMixture::hydrogen_sulfide, BmixResult::ierr, DensityResult::ierr, GrossInputsResult::ierr, GrossMethod1Result::ierr, GrossMethod2Result::ierr, PressureGrossResult::ierr, gasMixture::isobutane, gasMixture::isopentane, PropertiesDetailResult::JT, PropertiesGERGResult::JT, PropertiesDetailResult::Kappa, PropertiesGERGResult::Kappa, gasMixture::methane, GrossMethod1Result::Mm, GrossMethod2Result::Mm, MolarMassDetail_wrapper(), MolarMassGERG_wrapper(), MolarMassGross_wrapper(), gasMixture::n_butane, gasMixture::n_decane, gasMixture::n_heptane, gasMixture::n_hexane, gasMixture::n_nonane, gasMixture::n_octane, gasMixture::n_pentane, gasMixture::nitrogen, xGrs::nitrogen, gasMixture::oxygen, PressureGrossResult::P, PressureResult::P, PropertiesDetailResult::P, PropertiesGERGResult::P, PressureDetail_wrapper(), PressureGERG_wrapper(), PressureGross_wrapper(), gasMixture::propane, PropertiesDetail_wrapper(), PropertiesGERG_wrapper(), PropertiesDetailResult::S, PropertiesGERGResult::S, SetupDetail(), SetupGERG(), SetupGross(), PropertiesDetailResult::U, PropertiesGERGResult::U, PropertiesDetailResult::W, PropertiesGERGResult::W, gasMixture::water, GrossHvResult::xGrs, GrossInputsResult::xGrs, GrossMethod1Result::xGrs, GrossMethod2Result::xGrs, PressureGrossResult::Z, PressureResult::Z, PropertiesDetailResult::Z, and PropertiesGERGResult::Z.
std::vector< double > gasMixture_to_vector | ( | gasMixture | js_object | ) |
Converts a JavaScript gasMixture Object to a C++ struct.
js_object | JavaScript gasMixture object |
Definition at line 311 of file bindings.cpp.
References gasMixture::argon, gasMixture::carbon_dioxide, gasMixture::carbon_monoxide, gasMixture::ethane, gasMixture::helium, gasMixture::hydrogen, gasMixture::hydrogen_sulfide, gasMixture::isobutane, gasMixture::isopentane, gasMixture::methane, gasMixture::n_butane, gasMixture::n_decane, gasMixture::n_heptane, gasMixture::n_hexane, gasMixture::n_nonane, gasMixture::n_octane, gasMixture::n_pentane, gasMixture::nitrogen, gasMixture::oxygen, gasMixture::propane, and gasMixture::water.
Referenced by DensityDetail_wrapper(), DensityGERG_wrapper(), GrossHv_wrapper(), GrossInputs_wrapper(), MolarMassDetail_wrapper(), MolarMassGERG_wrapper(), MolarMassGross_wrapper(), PressureDetail_wrapper(), PressureGERG_wrapper(), PropertiesDetail_wrapper(), and PropertiesGERG_wrapper().
GrossHvResult GrossHv_wrapper | ( | gasMixture | x_array | ) |
Wrapper function to calculate gross heating values for a gas mixture.
x_array | Gas mixture composition in mole fraction |
This function serves as a wrapper around the GrossHv calculation, converting between array and vector data structures while maintaining the computational logic of the original GERG-2008 implementation.
Definition at line 731 of file bindings.cpp.
References gasMixture_to_vector(), GrossHv(), and vector_to_xGrs().
Referenced by EMSCRIPTEN_BINDINGS().
GrossInputsResult GrossInputs_wrapper | ( | double | T, |
double | P, | ||
gasMixture | x_array ) |
Wrapper function for GrossInputs calculation.
This function wraps the GrossInputs calculation to handle array conversions and provide a structured result
T | Temperature value |
P | Pressure value |
x_array | Gas mixture composition in mole percent |
Definition at line 759 of file bindings.cpp.
References gasMixture_to_vector(), GrossInputs(), and vector_to_xGrs().
Referenced by EMSCRIPTEN_BINDINGS().
GrossMethod1Result GrossMethod1_wrapper | ( | double | Th, |
double | Td, | ||
double | Pd, | ||
xGrs | xGrs_object, | ||
double | Gr, | ||
double | Hv ) |
Wrapper function for GrossMethod1 calculation method.
Th | Temperature high (T1) [K] |
Td | Temperature difference (T1-T2) [K] |
Pd | Pressure drop (P1-P2) [Pa] |
xGrs_object | Array of mole fractions for the mixture components |
Gr | Mass flow rate [kg/s] |
Hv | Heating value [J/kg] |
Definition at line 823 of file bindings.cpp.
References GrossMethod1(), vector_to_xGrs(), and xGrs_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
GrossMethod2Result GrossMethod2_wrapper | ( | double | Th, |
double | Td, | ||
double | Pd, | ||
xGrs | xGrs_object, | ||
double | Gr ) |
Wrapper function for the GrossMethod2 calculation method.
Th | Temperature at higher pressure (K) |
Td | Temperature at lower pressure (K) |
Pd | Pressure at lower temperature (kPa) |
xGrs_object | Array containing molar composition of the gas mixture |
Gr | Relative density of the gas mixture |
Definition at line 856 of file bindings.cpp.
References GrossMethod2(), vector_to_xGrs(), and xGrs_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
double MolarMassDetail_wrapper | ( | gasMixture | x_array | ) |
Calculates the molar mass of a gas mixture given mole percentages.
This function wraps the MolarMassDetail calculation for use with external bindings. It converts the input array to a vector before calculating the molar mass.
x_array | Gas mixture composition in mole percentages |
Definition at line 423 of file bindings.cpp.
References gasMixture_to_vector(), and MolarMassDetail().
Referenced by EMSCRIPTEN_BINDINGS().
double MolarMassGERG_wrapper | ( | gasMixture | x_array | ) |
Calculates the molar mass of a gas mixture using GERG-2008 equation of state.
x_array | Gas mixture composition in mole percent |
This function serves as a wrapper for the MolarMassGERG calculation. It converts the input array to a vector format before performing the calculation.
Definition at line 533 of file bindings.cpp.
References gasMixture_to_vector(), and MolarMassGERG().
Referenced by EMSCRIPTEN_BINDINGS().
double MolarMassGross_wrapper | ( | gasMixture | x_array | ) |
Calculates the gross molar mass of a gas mixture.
This function is a wrapper to MolarMassGross that converts a gas mixture composition from array to vector and calculates its gross molar mass.
x_array | Gas mixture composition in mole percent |
Definition at line 646 of file bindings.cpp.
References gasMixture_to_vector(), and MolarMassGross().
Referenced by EMSCRIPTEN_BINDINGS().
PressureResult PressureDetail_wrapper | ( | double | T, |
double | D, | ||
gasMixture | x_array ) |
Wraps the PressureDetail function to calculate pressure and compressibility factor.
T | Temperature in Kelvin |
D | Density in mol/l |
x_array | Gas mixture composition in mole percent |
This wrapper function converts the input array to a vector and handles the pressure calculation using PressureDetail, returning the results in a convenient struct.
Definition at line 445 of file bindings.cpp.
References gasMixture_to_vector(), and PressureDetail().
Referenced by EMSCRIPTEN_BINDINGS().
PressureResult PressureGERG_wrapper | ( | double | T, |
double | D, | ||
gasMixture | x_array ) |
Calculates pressure and compressibility factor using GERG-2008 equation of state.
T | Temperature in K |
D | Density in mol/l (or mol/dm³) |
x_array | Gas mixture composition in mole percent |
This function is a wrapper around the PressureGERG function that handles the conversion between array and vector representations of the gas mixture composition.
Definition at line 556 of file bindings.cpp.
References gasMixture_to_vector(), and PressureGERG().
Referenced by EMSCRIPTEN_BINDINGS().
PressureGrossResult PressureGross_wrapper | ( | double | T, |
double | D, | ||
xGrs | xGrs_object, | ||
double | HCH ) |
Wrapper function for PressureGross calculation.
This function wraps the PressureGross calculation to provide a simplified interface for computing pressure and compressibility factor for natural gas mixtures.
T | Temperature in K |
D | Density in mol/l |
xGrs_object | Array containing mole fractions of components |
HCH | Gross heating value in MJ/m³ |
Definition at line 673 of file bindings.cpp.
References PressureGross(), and xGrs_to_vector().
Referenced by EMSCRIPTEN_BINDINGS().
PropertiesDetailResult PropertiesDetail_wrapper | ( | double | T, |
double | D, | ||
gasMixture | x_array ) |
Wrapper function to calculate detailed thermodynamic properties of a gas mixture.
T | Temperature [K] |
D | Density [mol/l] |
x_array | Gas mixture composition in mole percent |
Definition at line 507 of file bindings.cpp.
References gasMixture_to_vector(), and PropertiesDetail().
Referenced by EMSCRIPTEN_BINDINGS().
PropertiesGERGResult PropertiesGERG_wrapper | ( | double | T, |
double | D, | ||
gasMixture | x_array ) |
Calculates thermodynamic properties using GERG-2008 equation of state.
T | Temperature [K] |
D | Density [kg/m³] |
x_array | Array of mole fractions [%] of the mixture components |
Definition at line 621 of file bindings.cpp.
References gasMixture_to_vector(), and PropertiesGERG().
Referenced by EMSCRIPTEN_BINDINGS().
val vector_to_array | ( | const std::vector< double > & | vec | ) |
Converts a C++ vector of doubles to a JavaScript array.
vec | The input vector containing double values to convert |
This function takes a C++ vector of doubles and creates a new JavaScript array, copying each element from the vector to the corresponding index in the JavaScript array. The function is typically used for interoperability between C++ and JavaScript/WebAssembly.
Definition at line 401 of file bindings.cpp.
xGrs vector_to_xGrs | ( | const std::vector< double > & | vec | ) |
Converts a C++ vector to a JavaScript xGrs object.
vec | C++ vector containing the xGrs values |
Definition at line 359 of file bindings.cpp.
References xGrs::carbon_dioxide, xGrs::hydrocarbon, and xGrs::nitrogen.
Referenced by GrossHv_wrapper(), GrossInputs_wrapper(), GrossMethod1_wrapper(), and GrossMethod2_wrapper().
std::vector< double > xGrs_to_vector | ( | xGrs | js_object | ) |
Converts a JavaScript xGrs Object to a C++ struct.
js_object | JavaScript xGrs object |
Definition at line 344 of file bindings.cpp.
References xGrs::carbon_dioxide, xGrs::hydrocarbon, and xGrs::nitrogen.
Referenced by Bmix_wrapper(), DensityGross_wrapper(), GrossMethod1_wrapper(), GrossMethod2_wrapper(), and PressureGross_wrapper().