mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Merge branch 'master' of https://github.com/CoolProp/CoolProp
This commit is contained in:
52
Web/coolprop/wrappers/Javascript/index.rst
Normal file
52
Web/coolprop/wrappers/Javascript/index.rst
Normal file
@@ -0,0 +1,52 @@
|
||||
.. _Javascript:
|
||||
|
||||
******************
|
||||
Javascript Wrapper
|
||||
******************
|
||||
|
||||
|
||||
Users
|
||||
=====
|
||||
|
||||
Precompiled binaries
|
||||
--------------------
|
||||
|
||||
* Download the precompiled binaries from :sfdownloads:`Javascript`
|
||||
|
||||
* Load your js file into your website, following the structure of `the example here <https://github.com/CoolProp/CoolProp/blob/master/wrappers/Javascript/index.html>`_
|
||||
|
||||
Developers
|
||||
==========
|
||||
|
||||
On linux, but binaries generated are cross-platform. We are following the instructions from `emscripten.org <http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html>`_ - download the portable emscripten SDK `emsdk` for linux.
|
||||
|
||||
1. First download node.js, clang++ and llvm using
|
||||
|
||||
sudo apt-get install nodejs clang++ llvm
|
||||
|
||||
2. Expand the SDK zip file linked above
|
||||
|
||||
3. At the console in the folder that contains the file emsdk run the commands
|
||||
|
||||
emsdk update # This will fetch the list of things to download
|
||||
|
||||
emsdk install latest # This will download and install the full toolchain
|
||||
|
||||
4. Go enjoy a nice walk or a cup of coffee - it will be a while
|
||||
|
||||
5. Activate the SDK just compiled
|
||||
|
||||
emsdk activate latest # This will make the file ~/.emscripten with the paths to most of the binaries compiled in SDK
|
||||
|
||||
6. Modify the file ``~/.emscripten`` to make NODE_JS path equal to `which nodejs`
|
||||
|
||||
7. Check out coolprop
|
||||
|
||||
git clone https://github.com/CoolProp/CoolProp
|
||||
|
||||
8. Folder creating
|
||||
|
||||
mkdir -p build/JS && cd build/JS
|
||||
|
||||
9. cmake ../..
|
||||
|
||||
@@ -32,7 +32,7 @@ enum parameters{
|
||||
// General parameters
|
||||
imolar_mass, irhomolar_reducing, irhomolar_critical, iT_reducing, iT_critical,
|
||||
irhomass_reducing, irhomass_critical, iP_critical, iT_triple, iP_triple, iT_min,
|
||||
iT_max,
|
||||
iT_max,iP_max,
|
||||
|
||||
// Bulk properties
|
||||
iT, iP, iQ, iTau, iDelta,
|
||||
|
||||
@@ -169,6 +169,8 @@ double AbstractState::trivial_keyed_output(int key)
|
||||
return Ttriple();
|
||||
case iT_max:
|
||||
return Tmax();
|
||||
case iP_max:
|
||||
return pmax();
|
||||
case iT_reducing:
|
||||
return get_reducing().T;
|
||||
case irhomolar_reducing:
|
||||
|
||||
@@ -24,6 +24,13 @@ void FlashRoutines::QT_flash(HelmholtzEOSMixtureBackend &HEOS)
|
||||
{
|
||||
if (HEOS.is_pure_or_pseudopure)
|
||||
{
|
||||
// \todo: fix the min and max saturation temperatures
|
||||
double Tmax_sat = HEOS.T_critical();
|
||||
double Tmin_sat = HEOS.Tmin();
|
||||
// Check limits
|
||||
if (!is_in_closed_range(Tmin_sat, Tmax_sat, HEOS._T)){
|
||||
throw ValueError(format("Temperature to QT_flash [%6g K] must be in range [%8g K, %8g K]",HEOS._T, Tmin_sat, Tmax_sat));
|
||||
}
|
||||
if (!(HEOS.components[0]->pEOS->pseudo_pure))
|
||||
{
|
||||
// Set some imput options
|
||||
|
||||
@@ -585,6 +585,49 @@ void REFPROPMixtureBackend::check_status(void)
|
||||
{
|
||||
if (!_mole_fractions_set){ throw ValueError("Mole fractions not yet set");}
|
||||
}
|
||||
|
||||
void REFPROPMixtureBackend::limits(double &Tmin, double &Tmax, double &rhomolarmax, double &pmax)
|
||||
{
|
||||
/*
|
||||
*
|
||||
subroutine LIMITS (htyp,x,tmin,tmax,Dmax,pmax)
|
||||
c
|
||||
c returns limits of a property model as a function of composition
|
||||
c
|
||||
c Pure fluid limits are read in from the .fld files; for mixtures, a
|
||||
c simple mole fraction weighting in reduced variables is used.
|
||||
c
|
||||
c inputs:
|
||||
c htyp--flag indicating which models are to be checked [character*3]
|
||||
c 'EOS': equation of state for thermodynamic properties
|
||||
c 'ETA': viscosity
|
||||
c 'TCX': thermal conductivity
|
||||
c 'STN': surface tension
|
||||
c x--composition array [mol frac]
|
||||
c outputs:
|
||||
c tmin--minimum temperature for model specified by htyp [K]
|
||||
c tmax--maximum temperature [K]
|
||||
c Dmax--maximum density [mol/L]
|
||||
c pmax--maximum pressure [kPa]
|
||||
*
|
||||
*/
|
||||
double Dmax_mol_L,pmax_kPa;
|
||||
char htyp[] = "EOS";
|
||||
LIMITSdll(htyp, &(mole_fractions[0]), &Tmin, &Tmax, &Dmax_mol_L, &pmax_kPa, 3);
|
||||
pmax = pmax_kPa*1000;
|
||||
rhomolarmax = Dmax_mol_L*1000;
|
||||
}
|
||||
long double REFPROPMixtureBackend::calc_pmax(void){
|
||||
double Tmin, Tmax, rhomolarmax, pmax;
|
||||
limits(Tmin, Tmax, rhomolarmax, pmax);
|
||||
return static_cast<long double>(pmax);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_Tmax(void){
|
||||
double Tmin, Tmax, rhomolarmax, pmax;
|
||||
limits(Tmin, Tmax, rhomolarmax, pmax);
|
||||
return static_cast<long double>(Tmax);
|
||||
};
|
||||
|
||||
double REFPROPMixtureBackend::calc_melt_Tmax()
|
||||
{
|
||||
long ierr;
|
||||
|
||||
@@ -97,6 +97,13 @@ public:
|
||||
long double calc_melt_T_p(long double p);
|
||||
long double calc_melt_rho_T(long double T);
|
||||
double calc_melt_Tmax();
|
||||
|
||||
/// A wrapper function to calculate the limits for the EOS
|
||||
void limits(double &Tmin, double &Tmax, double &rhomolarmax, double &pmax);
|
||||
/// Calculate the maximum pressure
|
||||
long double calc_pmax(void);
|
||||
/// Calculate the maximum temperature
|
||||
long double calc_Tmax(void);
|
||||
};
|
||||
|
||||
} /* namespace CoolProp */
|
||||
|
||||
@@ -411,13 +411,21 @@ double PropsSI(const char *Output, const char *Name1, double Prop1, const char *
|
||||
double PropsSI(const std::string &Output, const std::string &Name1, double Prop1, const std::string &Name2, double Prop2, const std::string &Ref)
|
||||
{
|
||||
std::string backend, fluid;
|
||||
#if !defined(PROPSI_NO_ERROR_CATCH)
|
||||
// In this function the error catching happens;
|
||||
try{
|
||||
#else
|
||||
std::cout << "macro is on; error checking disabled in PropsSI" << std::endl;
|
||||
#endif
|
||||
|
||||
// Here is the real code
|
||||
extract_backend(Ref, backend, fluid);
|
||||
return _PropsSI(Output, Name1, Prop1, Name2, Prop2, backend, fluid, std::vector<double>());
|
||||
#if !defined(PROPSI_NO_ERROR_CATCH)
|
||||
}
|
||||
catch(const std::exception& e){ set_error_string(e.what()); return _HUGE; }
|
||||
catch(...){ return _HUGE; }
|
||||
#endif
|
||||
}
|
||||
std::vector<double> PropsSI(const std::string &Output, const std::string &Name1, const std::vector<double> &Prop1, const std::string &Name2, const std::vector<double> Prop2, const std::string &Ref, const std::vector<double> &z)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,7 @@ parameter_info parameter_info_list[] = {
|
||||
parameter_info(iT_triple, "T_triple","O","K","Temperature at the triple point",true),
|
||||
parameter_info(iT_max, "T_max","O","K","Maximum temperature limit",true),
|
||||
parameter_info(iT_min, "T_min","O","K","Minimum temperature limit",true),
|
||||
parameter_info(iP_max, "P_max","O","Pa","Maximum pressure limit",true),
|
||||
parameter_info(iP_critical, "p_critical","O","Pa","Pressure at the critical point",true),
|
||||
parameter_info(iisothermal_compressibility, "isothermal_compressibility","O","1/Pa","Isothermal compressibility",false),
|
||||
parameter_info(ispeed_sound, "speed_of_sound","O","m/s","Speed of sound",false),
|
||||
@@ -94,6 +95,9 @@ public:
|
||||
index_map.insert(std::pair<std::string, int>("Tcrit", iT_critical));
|
||||
index_map.insert(std::pair<std::string, int>("Ttriple", iT_triple));
|
||||
index_map.insert(std::pair<std::string, int>("rhocrit", irhomass_critical));
|
||||
index_map.insert(std::pair<std::string, int>("Tmin", iT_min));
|
||||
index_map.insert(std::pair<std::string, int>("Tmax", iT_max));
|
||||
index_map.insert(std::pair<std::string, int>("pmax", iP_max));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ int main()
|
||||
{
|
||||
#if 1
|
||||
std::cout << get_global_param_string("parameter_list") << std::endl;
|
||||
double pm = CoolProp::PropsSI("pmax","T",-100,"Q",0.0000000000000000e+00,"REFPROP::Water");
|
||||
double Tm = PropsSI("Tmax","T",-100,"Q",0.0000000000000000e+00,"REFPROP::Water");
|
||||
double Tt = PropsSI("P","T",-100,"Q",0.0000000000000000e+00,"AceticAcid");
|
||||
double T = PropsSI("P","T",5.9020000000000005e+02,"Q",0.0000000000000000e+00,"AceticAcid");
|
||||
std::cout << get_global_param_string("errstring");
|
||||
double Tc = Props1SI("Water","T_triple");
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include "CoolProp.h"
|
||||
#include "CoolPropLib.h"
|
||||
#include "CoolPropTools.h"
|
||||
|
||||
static bool EES_DEBUG = false;
|
||||
@@ -144,7 +145,7 @@ extern "C"
|
||||
{
|
||||
// This redirects standard output to log_stdout.txt
|
||||
freopen("log_stdout.txt", "w", stdout);
|
||||
set_debug_level(100000); // Maximum debugging
|
||||
::set_debug_level(100000); // Maximum debugging
|
||||
}
|
||||
|
||||
try
|
||||
@@ -161,7 +162,7 @@ extern "C"
|
||||
}
|
||||
else{
|
||||
// Mole fractions are not given
|
||||
out = PropsSI(Outstr, In1str, In1, In2str, In2, Fluidstr);
|
||||
out = Props(Outstr.c_str(), In1str[0], In1, In2str[0], In2, Fluidstr.c_str());
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
|
||||
@@ -15,7 +15,7 @@ __gitrevision__ = CoolProp.get_global_param_string(b'gitrevision')
|
||||
def get(s):
|
||||
"""
|
||||
This is just a shorthand function for getting a parameter from
|
||||
CoolProp.get_global_param_string
|
||||
``CoolProp.get_global_param_string``
|
||||
"""
|
||||
return CoolProp.get_global_param_string(s)
|
||||
def test():
|
||||
|
||||
Reference in New Issue
Block a user