CoolProp 7.1.0
An open-source fluid property and humid air property database
emscripten_interface.cxx
Go to the documentation of this file.
1
7
8#ifdef EMSCRIPTEN
9
10# include "CoolProp.h"
11# include "AbstractState.h"
12# include "Configuration.h"
13# include "HumidAirProp.h"
14# include "DataStructures.h"
16# include "CoolPropLib.h"
17
23
24# include <emscripten/bind.h>
25using namespace emscripten;
26
27// Binding code
28EMSCRIPTEN_BINDINGS(coolprop_bindings) {
29 function("F2K", &F2K);
30 function("Props1SI", &CoolProp::Props1SI);
31 function("PropsSI", &CoolProp::PropsSI);
32 function("get_global_param_string", &CoolProp::get_global_param_string);
33 function("get_fluid_param_string", &CoolProp::get_fluid_param_string);
34 function("apply_simple_mixing_rule", &CoolProp::apply_simple_mixing_rule);
35 function("get_mixture_binary_pair_data", &CoolProp::get_mixture_binary_pair_data);
36 function("add_fluids_as_JSON", &CoolProp::add_fluids_as_JSON);
37
38 enum_<CoolProp::input_pairs>("input_pairs").value("PT_INPUTS", CoolProp::PT_INPUTS);
39}
40// Binding code
41EMSCRIPTEN_BINDINGS(humid_air_bindings) {
42 function("HAPropsSI", &HumidAir::HAPropsSI);
43}
44
45CoolProp::AbstractState* factory(const std::string& backend, const std::string& fluid_names) {
46 return CoolProp::AbstractState::factory(backend, strsplit(fluid_names, '&'));
47}
48
49// Binding code
50EMSCRIPTEN_BINDINGS(abstract_state_bindings) {
51
52 register_vector<double>("VectorDouble");
53 register_vector<std::string>("VectorString");
54
55 value_object<CoolProp::PhaseEnvelopeData>("CoolProp::PhaseEnvelopeData")
56// Use X macros to auto-generate the variables;
57// each will look something like: .field("T", &CoolProp::PhaseEnvelopeData::T);
58# define X(name) .field(# name, &CoolProp::PhaseEnvelopeData::name)
60# undef X
61 ;
62
63 function("factory", &factory, allow_raw_pointers());
64
65 class_<CoolProp::AbstractState>("AbstractState")
66 .function("gas_constant", &CoolProp::AbstractState::gas_constant)
67 .function("update", &CoolProp::AbstractState::update)
68 .function("p", &CoolProp::AbstractState::p)
69 .function("rhomass", &CoolProp::AbstractState::rhomass)
70 .function("viscosity", &CoolProp::AbstractState::viscosity)
71 .function("set_mole_fractions", &CoolProp::AbstractState::set_mole_fractions_double)
72 .function("build_phase_envelope", &CoolProp::AbstractState::build_phase_envelope)
73 .function("get_phase_envelope_data", &CoolProp::AbstractState::get_phase_envelope_data);
74}
75
76#endif