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:
Ian Bell
2014-08-05 12:58:47 +02:00
parent 2a45e87ed0
commit e8dbfded3e
7 changed files with 71 additions and 4 deletions

View File

@@ -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

View File

@@ -1,3 +1,12 @@
*************
Low Level API
*************
*************
Code
----
.. literalinclude:: snippets/AbstractState1.cxx
:language: c++
Output
------
.. literalinclude:: snippets/AbstractState1.cxx.output

View 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;
}

View 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

View 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;
}

View File

@@ -0,0 +1,6 @@
40.8269
40.8269
40.8269
40.8269
40.8269
40.8269