CoolProp  6.6.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>
25 using namespace emscripten;
26 
27 // Binding code
28 EMSCRIPTEN_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 
34  enum_<CoolProp::input_pairs>("input_pairs").value("PT_INPUTS", CoolProp::PT_INPUTS);
35 }
36 // Binding code
37 EMSCRIPTEN_BINDINGS(humid_air_bindings) {
38  function("HAPropsSI", &HumidAir::HAPropsSI);
39 }
40 
41 CoolProp::AbstractState* factory(const std::string& backend, const std::string& fluid_names) {
42  return CoolProp::AbstractState::factory(backend, strsplit(fluid_names, '&'));
43 }
44 
45 // Binding code
46 EMSCRIPTEN_BINDINGS(abstract_state_bindings) {
47 
48  register_vector<double>("VectorDouble");
49  register_vector<std::string>("VectorString");
50 
51  value_object<CoolProp::PhaseEnvelopeData>("CoolProp::PhaseEnvelopeData")
52 // Use X macros to auto-generate the variables;
53 // each will look something like: .field("T", &CoolProp::PhaseEnvelopeData::T);
54 # define X(name) .field(# name, &CoolProp::PhaseEnvelopeData::name)
56 # undef X
57  ;
58 
59  function("factory", &factory, allow_raw_pointers());
60 
61  class_<CoolProp::AbstractState>("AbstractState")
62  .function("gas_constant", &CoolProp::AbstractState::gas_constant)
63  .function("update", &CoolProp::AbstractState::update)
64  .function("p", &CoolProp::AbstractState::p)
65  .function("rhomass", &CoolProp::AbstractState::rhomass)
66  .function("viscosity", &CoolProp::AbstractState::viscosity)
67  .function("set_mole_fractions", &CoolProp::AbstractState::set_mole_fractions_double)
68  .function("build_phase_envelope", &CoolProp::AbstractState::build_phase_envelope)
69  .function("get_phase_envelope_data", &CoolProp::AbstractState::get_phase_envelope_data);
70 }
71 
72 #endif