mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Added C++ snippets to docs for API - more work needed here
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -2,4 +2,13 @@
|
||||
High-Level API
|
||||
**************
|
||||
|
||||
For many users, all that is needed is a simple call to the ``PropsSI`` function.
|
||||
For many users, all that is needed is a simple call to the ``PropsSI`` function.
|
||||
|
||||
Code
|
||||
----
|
||||
.. literalinclude:: snippets/propssi.cxx
|
||||
:language: c++
|
||||
|
||||
Output
|
||||
------
|
||||
.. literalinclude:: snippets/propssi.cxx.output
|
||||
@@ -1,3 +1,12 @@
|
||||
*************
|
||||
Low Level API
|
||||
*************
|
||||
*************
|
||||
|
||||
Code
|
||||
----
|
||||
.. literalinclude:: snippets/AbstractState1.cxx
|
||||
:language: c++
|
||||
|
||||
Output
|
||||
------
|
||||
.. literalinclude:: snippets/AbstractState1.cxx.output
|
||||
18
Web/coolprop/snippets/AbstractState1.cxx
Normal file
18
Web/coolprop/snippets/AbstractState1.cxx
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "CoolProp.h"
|
||||
#include "AbstractState.h"
|
||||
#include <iostream>
|
||||
#include "crossplatform_shared_ptr.h"
|
||||
using namespace CoolProp;
|
||||
int main()
|
||||
{
|
||||
shared_ptr<AbstractState> Water(AbstractState::factory("HEOS","Water"));
|
||||
Water->update(PQ_INPUTS, 101325, 0); // SI units
|
||||
std::cout << "T: " << Water->T() << " K" << std::endl;
|
||||
std::cout << "rho': " << Water->rhomass() << " kg/m^3" << std::endl;
|
||||
std::cout << "rho': " << Water->rhomolar() << " mol/m^3" << std::endl;
|
||||
std::cout << "h': " << Water->hmass() << " J/kg" << std::endl;
|
||||
std::cout << "h': " << Water->hmolar() << " J/mol" << std::endl;
|
||||
std::cout << "s': " << Water->smass() << " J/kg/K" << std::endl;
|
||||
std::cout << "s': " << Water->smolar() << " J/mol/K" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
7
Web/coolprop/snippets/AbstractState1.cxx.output
Normal file
7
Web/coolprop/snippets/AbstractState1.cxx.output
Normal file
@@ -0,0 +1,7 @@
|
||||
T: 373.124 K
|
||||
rho': 958.367 kg/m^3
|
||||
rho': 53197.5 mol/m^3
|
||||
h': 419058 J/kg
|
||||
h': 7549.44 J/mol
|
||||
s': 1306.92 J/kg/K
|
||||
s': 23.5445 J/mol/K
|
||||
18
Web/coolprop/snippets/propssi.cxx
Normal file
18
Web/coolprop/snippets/propssi.cxx
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "CoolProp.h"
|
||||
#include <iostream>
|
||||
using namespace CoolProp;
|
||||
int main()
|
||||
{
|
||||
// First type (slowest, due to most string processing, exposed in DLL)
|
||||
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
|
||||
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
|
||||
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;
|
||||
|
||||
std::vector<double> z(2,0.5);
|
||||
// Second type (C++ only, a bit faster)
|
||||
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane&Ethane", z) << std::endl;
|
||||
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane&Ethane", z) << std::endl;
|
||||
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane&Ethane", z) << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
6
Web/coolprop/snippets/propssi.cxx.output
Normal file
6
Web/coolprop/snippets/propssi.cxx.output
Normal file
@@ -0,0 +1,6 @@
|
||||
40.8269
|
||||
40.8269
|
||||
40.8269
|
||||
40.8269
|
||||
40.8269
|
||||
40.8269
|
||||
Reference in New Issue
Block a user