diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d067cce..a915d88f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ include(GNUInstallDirs) if(TFUN_BUILD_ALL MATCHES ON) set(TFUN_BUILD_SHARED_LIBS ON) set(TFUN_BUILD_STATIC_LIBS ON) -# set(TFUN_BUILD_TESTS ON) + set(TFUN_BUILD_TESTS OFF) set(TFUN_BUILD_PYTHON ON) endif() @@ -100,11 +100,11 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Resources DESTINATION ${CMAKE_BINARY_DIR}) # Build the tests -#if(BUILD_TESTS) -# add_subdirectory(tests) +if(BUILD_TESTS) + add_subdirectory(tests) #else() # add_subdirectory(tests EXCLUDE_FROM_ALL) -#endif() +endif() # Build python wraper if(TFUN_BUILD_PYTHON) diff --git a/README.md b/README.md index 71011a89..a629c2bd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ More information on Jupyter Notebooks: [Jupyter Documentation](https://jupyter.r int main() { // Create the batch object using a database file in JSON - ThermoFun::Batch batch("Resources/Databases/aq17-thermofun.json"); + ThermoFun::ThermoBatch batch("Resources/Databases/aq17-thermofun.json"); // Optional: set units, default units are in SI batch.setPropertiesUnits({"temperature", "pressure"},{"degC","bar"}); @@ -71,7 +71,7 @@ int main() ThermoFun::Database db(dbc.getDatabase('aq17')); // Initialize an batch object using the database - ThermoFun::Batch batch (db); + ThermoFun::ThermoBatch batch (db); // Optional set calculation and output preferences ThermoFun::OutputSettings op; diff --git a/ThermoFun/ThermoModelsSubstance.h b/ThermoFun/ThermoModelsSubstance.h index b34e2661..35d268e0 100644 --- a/ThermoFun/ThermoModelsSubstance.h +++ b/ThermoFun/ThermoModelsSubstance.h @@ -47,10 +47,13 @@ class SoluteAkinfievDiamondEOS /// Returns the thermodynamic properties of the substance. /// @param T The temperature value (in units of K) /// @param P The pressure value (in units of Pa) - /// @param tps thermodynamic properties of the substance previosuly corrected with the AD EOS + /// @param tps thermodynamic properties of the substance previously corrected with the AD EOS /// @param wtp thermodynamic properties of liquid H2O - /// @param wigp themrodynamic properties of water in ideal gas state - /// @param wp water solvent proeoprties (e.g. density, alpha, beta, etc.) + /// @param wigp thermodynamic properties of water in ideal gas state + /// @param wp water solvent properties (e.g. density, alpha, beta, etc.) + /// @param wtpr thermodynamic properties of liquid H2O at ref T and P + /// @param wigpr thermodynamic properties of water in ideal gas state at ref T and P + /// @param wpr water solvent properties at ref T and P auto thermoProperties (double T, double P, ThermoPropertiesSubstance tps, const ThermoPropertiesSubstance &wtp, const ThermoPropertiesSubstance &wigp, const PropertiesSolvent& wp, const ThermoPropertiesSubstance &wtpr, const ThermoPropertiesSubstance &wigpr, const PropertiesSolvent &wpr) -> ThermoPropertiesSubstance; private: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 42973660..941922e3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,4 +4,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # Add ReaktoroInterpreter tests to the build system include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_subdirectory(dbclientTest) +add_subdirectory(unit01) +add_subdirectory(unit02) +add_subdirectory(unit03) +add_subdirectory(unit04) +add_subdirectory(reactionsTest) diff --git a/tests/reactionsTest/CMakeLists.txt b/tests/reactionsTest/CMakeLists.txt new file mode 100644 index 00000000..acf25be4 --- /dev/null +++ b/tests/reactionsTest/CMakeLists.txt @@ -0,0 +1,14 @@ +# Specify the minimum cmake version +cmake_minimum_required(VERSION 3.9) + +# Specify the name of your project +project(reactions) + +# Find the ThermoFun dependency. +find_package(ThermoFun REQUIRED) + +# Create an executable named app with source code main.cpp +add_executable(reactions src/main.cpp) + +# Link your application against ThermoFun C++ library. +target_link_libraries(reactions ThermoFun::ThermoFun) diff --git a/tests/reactionsTest/src/main.cpp b/tests/reactionsTest/src/main.cpp index 6c4fe6ba..49368d4d 100644 --- a/tests/reactionsTest/src/main.cpp +++ b/tests/reactionsTest/src/main.cpp @@ -1,4 +1,5 @@ -#include "Interfaces/Interface.h" +#include +#include "ThermoFun/ThermoFun.h" using namespace std; using namespace ThermoFun; @@ -11,16 +12,16 @@ int main(int argc, char *argv[]) Database thermoDB(databaseFile); - Thermo thermo(thermoDB); + ThermoEngine thermo(thermoDB); ThermoPropertiesReaction tpr; - double T = 25; - double P = 1; + double T = 298.15; + double P = 1e5; tpr = thermo.thermoPropertiesReaction(T, P, "CaSiO3@"); - cout << tpr.log_equilibrium_constant << endl << tpr.reaction_gibbs_energy << endl; + std::cout << tpr.log_equilibrium_constant << endl << tpr.reaction_gibbs_energy << endl; return 0; } diff --git a/tests/unit01/CMakeLists.txt b/tests/unit01/CMakeLists.txt new file mode 100644 index 00000000..6f7267bd --- /dev/null +++ b/tests/unit01/CMakeLists.txt @@ -0,0 +1,14 @@ +# Specify the minimum cmake version +cmake_minimum_required(VERSION 3.9) + +# Specify the name of your project +project(test01) + +# Find the ThermoFun dependency. +find_package(ThermoFun REQUIRED) + +# Create an executable named app with source code main.cpp +add_executable(test01 src/main.cpp) + +# Link your application against ThermoFun C++ library. +target_link_libraries(test01 ThermoFun::ThermoFun) diff --git a/tests/unit01/src/main.cpp b/tests/unit01/src/main.cpp index f14a6c94..4c1644c8 100644 --- a/tests/unit01/src/main.cpp +++ b/tests/unit01/src/main.cpp @@ -1,11 +1,13 @@ #include #include -//#include "tcorrpt.h" -#include "Database.h" -#include "Substance.h" -#include "ThermoModelsSubstance.h" -#include "ThermoFun_global.h" -#include "Thermo.h" +#include "ThermoFun/Database.h" +#include "ThermoFun/Substance.h" +#include "ThermoFun/ThermoEngine.h" +#include "ThermoFun/ThermoModelsSubstance.h" +#include "ThermoFun/ThermoProperties.h" +#include "ThermoFun/ThermoParameters.h" +#include "ThermoFun/ThermoModelsSolvent.h" +#include "ThermoFun/GlobalVariables.h" using namespace std; using namespace ThermoFun; @@ -26,8 +28,8 @@ int main(int argc, char *argv[]) double Tr = 298.15, ///< Reference temperature for standard state (usually 298.15 K) Pr = 1e05; ///< Reference pressure (usually 1 bar or 10^5 Pa, sometimes 1.013 bar = 1 atm) - double currentP = 2000, ///< - currentT = 400; ///< + double currentP = 2000e5, ///< + currentT = 473.15; ///< /// END thermo properties /// @@ -88,7 +90,7 @@ int main(int argc, char *argv[]) dtb.addSubstance(corundum); - Thermo thermo (dtb); + ThermoEngine thermo (dtb); // Test error out of the interval // currentT = 2005; @@ -101,7 +103,7 @@ int main(int argc, char *argv[]) // +++ END test CP +++ // +++ Test H2O_HGK +++ -// #define TEST_H2O_HGK + //#define TEST_H2O_HGK #ifdef TEST_H2O_HGK Substance water; @@ -129,22 +131,23 @@ int main(int argc, char *argv[]) dtb.addSubstance(water); - Thermo thermo (dtb); - result2 = thermo.thermoPropertiesSubstance(25, 1, "water"); + ThermoEngine thermo (dtb); + currentP = 1e5; + result2 = thermo.thermoPropertiesSubstance(298.15, currentP, "water"); water.setThermoReferenceProperties(result2); WaterHGK waterHGK(water); - result1 = waterHGK.propertiesSolvent(25, 1); + result1 = waterHGK.propertiesSolvent(298.15, currentP, 0); - result3 = thermo.propertiesSolvent(25, 1, "water"); + result3 = thermo.propertiesSolvent(298.15, currentP, 0); #endif // +++ END test H2O_HGK +++ // +++ Test H2O_HGKreaktoro +++ -// #define TEST_H2O_HGKreaktoro + //#define TEST_H2O_HGKreaktoro #ifdef TEST_H2O_HGKreaktoro Substance water; @@ -172,8 +175,9 @@ int main(int argc, char *argv[]) dtb.addSubstance(water); - Thermo thermo (dtb); - result2 = thermo.thermoPropertiesSubstance(25, 1, "water"); + ThermoEngine thermo (dtb); + currentP = 1e5; + result2 = thermo.thermoPropertiesSubstance(298.15, currentP, "water"); water.setThermoReferenceProperties(result2); @@ -181,7 +185,7 @@ int main(int argc, char *argv[]) // +++ END test H2O_HGKreaktoro +++ // +++ Test H2O_HGKgems Vs H2O_HGKreaktoro +++ - #define TEST_H2O_VS + //#define TEST_H2O_VS #ifdef TEST_H2O_VS Substance water; @@ -199,8 +203,8 @@ int main(int argc, char *argv[]) WaterHGKreaktoro H2OHGKreaktoro ( water ); double T, P; - T = 100; - P = 5000; + T = 100+273.15; + P = 5000e5; ThermoPropertiesSubstance resSubstG, resSubstR; ElectroPropertiesSolvent resSolvG, resSolvR; @@ -239,7 +243,7 @@ int main(int argc, char *argv[]) // +++ END Test H2O_HGKgems Vs H2O_HGKreaktoro +++ // +++ Test H2O_WP95reaktoro Vs H2O_HGKreaktoro +++ -// #define TEST_H2O_HGK_VS_H2O_WP95 + //#define TEST_H2O_HGK_VS_H2O_WP95 #ifdef TEST_H2O_HGK_VS_H2O_WP95 Substance water; @@ -257,8 +261,8 @@ int main(int argc, char *argv[]) WaterHGKreaktoro H2OHGKreaktoro ( water ); double T, P; - T = 100; - P = 5000; + T = 100+273.15; + P = 5000e5; ThermoPropertiesSubstance resWP95, resHGKreak; // ElectroPropertiesSolvent resSolvG, resSolvR; diff --git a/tests/unit02/CMakeLists.txt b/tests/unit02/CMakeLists.txt new file mode 100644 index 00000000..2b983a2a --- /dev/null +++ b/tests/unit02/CMakeLists.txt @@ -0,0 +1,14 @@ +# Specify the minimum cmake version +cmake_minimum_required(VERSION 3.9) + +# Specify the name of your project +project(test02) + +# Find the ThermoFun dependency. +find_package(ThermoFun REQUIRED) + +# Create an executable named app with source code main.cpp +add_executable(test02 src/main.cpp) + +# Link your application against ThermoFun C++ library. +target_link_libraries(test02 ThermoFun::ThermoFun) diff --git a/tests/unit02/src/main.cpp b/tests/unit02/src/main.cpp index b1c4c7b0..d9416601 100644 --- a/tests/unit02/src/main.cpp +++ b/tests/unit02/src/main.cpp @@ -1,11 +1,17 @@ #include #include -//#include "tcorrpt.h" -#include "Database.h" -#include "Substance.h" -#include "ThermoModelsSubstance.h" -#include "ThermoFun_global.h" -#include "Thermo.h" + +#include "ThermoFun/Database.h" +#include "ThermoFun/Substance.h" +#include "ThermoFun/ThermoEngine.h" +#include "ThermoFun/ThermoModelsSubstance.h" +#include "ThermoFun/ThermoProperties.h" +#include "ThermoFun/ThermoParameters.h" +#include "ThermoFun/ThermoModelsSolvent.h" +#include "ThermoFun/ElectroModelsSolvent.h" +#include "ThermoFun/GlobalVariables.h" +#include "ThermoFun/Substances/Solute/SoluteHKFreaktoro.h" +#include "ThermoFun/Substances/Solute/SoluteHKFgems.h" using namespace std; using namespace ThermoFun; @@ -38,7 +44,6 @@ int main(int argc, char *argv[]) al3.setName("Al+3"); al3.setFormula("Al+3"); al3.setCharge(3); - al3.setSolventSymbol("H2O@"); al3.setSubstanceClass(SubstanceClass::type::AQSOLUTE); al3.setAggregateState(AggregateState::type::AQUEOUS); @@ -67,6 +72,8 @@ int main(int argc, char *argv[]) PropertiesSolvent wp = H2OHGKgems.propertiesSolvent(T, P, 0); + FunctionG g = functionG(T, P, wp); + water.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WJNG); WaterJNgems H2OJNgems ( water ); @@ -82,7 +89,7 @@ int main(int argc, char *argv[]) #endif // +++ Test HKFgems +++ -// #define TEST_HKFreaktoro + // #define TEST_HKFreaktoro #ifdef TEST_HKFreaktoro // water.setMethod_T(MethodCorrT_Thrift::type::CTM_WAT); @@ -99,7 +106,6 @@ int main(int argc, char *argv[]) al3.setName("Al+3"); al3.setFormula("Al+3"); al3.setCharge(3); - al3.setSolventSymbol("H2O@"); al3.setSubstanceClass(SubstanceClass::type::AQSOLUTE); al3.setAggregateState(AggregateState::type::AQUEOUS); @@ -128,7 +134,7 @@ int main(int argc, char *argv[]) PropertiesSolvent wp = H2OHGKreaktoro.propertiesSolvent(T, P, 0); - water.setMethodGenEoS(MethodGenEoS_Thrift::type::CEM_WJNG); + water.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WJNR); WaterJNreaktoro H2OJNreaktoro ( water ); @@ -155,7 +161,7 @@ int main(int argc, char *argv[]) al3.setName("Al+3"); al3.setFormula("Al+3"); al3.setCharge(3); - al3.setSymbol("H2O@"); + al3.setSymbol("Al+3"); al3.setSubstanceClass(SubstanceClass::type::AQSOLUTE); al3.setAggregateState(AggregateState::type::AQUEOUS); @@ -228,7 +234,6 @@ int main(int argc, char *argv[]) aloh3.setName("Al(OH)3"); aloh3.setFormula("Al(OH)3@"); aloh3.setCharge(0); - aloh3.setSolventSymbol("H2O@"); aloh3.setSubstanceClass(SubstanceClass::type::AQSOLUTE); aloh3.setAggregateState(AggregateState::type::AQUEOUS); diff --git a/tests/unit03/CMakeLists.txt b/tests/unit03/CMakeLists.txt new file mode 100644 index 00000000..f8a1709d --- /dev/null +++ b/tests/unit03/CMakeLists.txt @@ -0,0 +1,14 @@ +# Specify the minimum cmake version +cmake_minimum_required(VERSION 3.9) + +# Specify the name of your project +project(test03) + +# Find the ThermoFun dependency. +find_package(ThermoFun REQUIRED) + +# Create an executable named app with source code main.cpp +add_executable(test03 src/main.cpp) + +# Link your application against ThermoFun C++ library. +target_link_libraries(test03 ThermoFun::ThermoFun) diff --git a/tests/unit03/src/main.cpp b/tests/unit03/src/main.cpp index 196a516f..2d5dfced 100644 --- a/tests/unit03/src/main.cpp +++ b/tests/unit03/src/main.cpp @@ -1,10 +1,15 @@ #include #include -#include "Database.h" -#include "Substance.h" -#include "ThermoModelsSubstance.h" -#include "ThermoFun_global.h" -#include "Thermo.h" + +#include "ThermoFun/Database.h" +#include "ThermoFun/Substance.h" +#include "ThermoFun/ThermoEngine.h" +#include "ThermoFun/ThermoModelsSubstance.h" +#include "ThermoFun/ThermoProperties.h" +#include "ThermoFun/ThermoParameters.h" +#include "ThermoFun/ThermoModelsSolvent.h" +#include "ThermoFun/ElectroModelsSolvent.h" +#include "ThermoFun/GlobalVariables.h" using namespace std; using namespace ThermoFun; @@ -33,7 +38,6 @@ int main(int argc, char *argv[]) co2.setName("CO2"); co2.setFormula("CO2@"); co2.setCharge(0); - co2.setSolventSymbol("CO2@"); co2.setSubstanceClass(SubstanceClass::type::AQSOLUTE); co2.setAggregateState(AggregateState::type::AQUEOUS); @@ -60,8 +64,9 @@ int main(int argc, char *argv[]) co2.setThermoParameters(prs); double T, P; - T = 25; - P = 1; + T = 50+298.15; + P = 100*1e5; + double Pr = 1e5; ThermoPropertiesSubstance rCO2, TrPrCO2; @@ -72,8 +77,8 @@ int main(int argc, char *argv[]) TrPrCO2.heat_capacity_cp = 209.749; co2.setThermoReferenceProperties(TrPrCO2); - co2.setReferenceT(25); - co2.setReferenceP(1); + co2.setReferenceT(298.15); + co2.setReferenceP(1e5); EmpiricalCpIntegration CpCO2 (co2); rCO2 = CpCO2.thermoProperties(T, P); @@ -81,18 +86,22 @@ int main(int argc, char *argv[]) WaterIdealGasWoolley wig ( water ); ThermoPropertiesSubstance wigp = wig.thermoProperties(T, P); + ThermoPropertiesSubstance wigpr = wig.thermoProperties(298.15, Pr); PropertiesSolvent wp0 = H2OHGKgems.propertiesSolvent(T, P, 0); + PropertiesSolvent wp0r = H2OHGKgems.propertiesSolvent(298.15, Pr, 0); PropertiesSolvent wp1 = H2OHGKreaktoro.propertiesSolvent(T, P, 0); PropertiesSolvent wp2 = H2OWP95reaktoro.propertiesSolvent(T, P, 0); ThermoPropertiesSubstance wtp = H2OHGKgems.thermoPropertiesSubstance(T, P, 0); + + ThermoPropertiesSubstance wtpr = H2OHGKgems.thermoPropertiesSubstance(298.15, Pr, 0); SoluteAkinfievDiamondEOS CO2_AD (co2); ThermoPropertiesSubstance result; - result = CO2_AD.thermoProperties(T, P, rCO2, wtp, wigp, wp0); + result = CO2_AD.thermoProperties(T, P, rCO2, wtp, wigp, wp0, wtpr, wigpr, wp0r ); // ThermoPropertiesSubstance wp3 = H2OWP95reaktoro.thermoPropertiesSubstance(T, P, 1); diff --git a/tests/unit04/CMakeLists.txt b/tests/unit04/CMakeLists.txt new file mode 100644 index 00000000..92a9d254 --- /dev/null +++ b/tests/unit04/CMakeLists.txt @@ -0,0 +1,14 @@ +# Specify the minimum cmake version +cmake_minimum_required(VERSION 3.9) + +# Specify the name of your project +project(test04) + +# Find the ThermoFun dependency. +find_package(ThermoFun REQUIRED) + +# Create an executable named app with source code main.cpp +add_executable(test04 src/main.cpp) + +# Link your application against ThermoFun C++ library. +target_link_libraries(test04 ThermoFun::ThermoFun) diff --git a/tests/unit06/H2OZD2005-test.pro b/tests/unit04/H2OZD2005-test.pro similarity index 100% rename from tests/unit06/H2OZD2005-test.pro rename to tests/unit04/H2OZD2005-test.pro diff --git a/tests/unit04/IO-test.pro b/tests/unit04/IO-test.pro deleted file mode 100644 index a87d47ca..00000000 --- a/tests/unit04/IO-test.pro +++ /dev/null @@ -1,55 +0,0 @@ -TEMPLATE = app -CONFIG += console -CONFIG -= app_bundle -CONFIG -= qt - -#QMAKE_CXXFLAGS += -std=c++1y -QMAKE_CXXFLAGS += -std=c++11 - -#CONFIG += -std=c++11 - -TARGET = IO-test - -ThermoFun_TEST_CPP = ./src -ThermoFun_CPP = ../../../thermofun/src - -ThermoFun_TEST_H = $$ThermoFun_TEST_CPP -ThermoFun_H = $$ThermoFun_CPP - -DEPENDPATH += $$ThermoFun_TEST_H -DEPENDPATH += $$ThermoFun_H - -INCLUDEPATH += $$ThermoFun_TEST_H -INCLUDEPATH += $$ThermoFun_H - -QMAKE_LFLAGS += -OBJECTS_DIR = obj - -# Define the directory where the gui, third-party libs, resources are located -BUILD_DIR = $$OUT_PWD/.. -THRIFT_DIR = ./thrift - -# Define the directory where the third-party libraries have been installed -#THIRDPARTY_DIR = $$BUILD_DIR/thirdparty/debug -CONFIG(release, debug|release): THIRDPARTY_DIR = $$BUILD_DIR/release/thirdparty -CONFIG(debug, debug|release): THIRDPARTY_DIR = $$BUILD_DIR/debug/thirdparty -# Define the directories where the headers of the third-party libraries have been installed -THIRDPARTY_INCLUDE_DIR = $$THIRDPARTY_DIR/include - -# Define the directories where the THIRDPARTY libraries have been installed -THIRDPARTY_LIBRARY_DIR1 = $$THIRDPARTY_DIR/lib -THIRDPARTY_LIBRARY_DIR2 = $$THIRDPARTY_DIR/lib/x86_64-linux-gnu - -DEPENDPATH += $$THIRDPARTY_INCLUDE_DIR -INCLUDEPATH += $$THIRDPARTY_INCLUDE_DIR - -LIBS += -L$$THIRDPARTY_LIBRARY_DIR1 -LIBS += -L$$THIRDPARTY_LIBRARY_DIR2 -LIBS += -lbsonio -lyaml-cpp -lejdb -lpugixml -LIBS += -lthrift -LIBS += -llua5.2 - -include($$ThermoFun_TEST_CPP/ThermoFun-test.pri) -include($$ThermoFun_CPP/ThermoFun.pri) - - diff --git a/tests/unit04/src/README.txt b/tests/unit04/src/README.txt index 956c6658..138235a8 100644 --- a/tests/unit04/src/README.txt +++ b/tests/unit04/src/README.txt @@ -1 +1 @@ -Tests for implementation of the Akinfiev Diamond (2003) EOS - GEMS version +Tests for implementation of the Zhang and Duan (2005) H2O VdP EOS diff --git a/tests/unit04/src/main.cpp b/tests/unit04/src/main.cpp index dfb39efe..ab438b18 100644 --- a/tests/unit04/src/main.cpp +++ b/tests/unit04/src/main.cpp @@ -1,12 +1,15 @@ #include #include -//#include "tcorrpt.h" -#include "Database.h" -#include "Substance.h" -#include "ThermoModelsSubstance.h" -#include "ThermoFun_global.h" -#include "Thermo.h" -#include "Common/OutputToCSV.h" + +#include "ThermoFun/Database.h" +#include "ThermoFun/Substance.h" +#include "ThermoFun/ThermoEngine.h" +#include "ThermoFun/ThermoModelsSubstance.h" +#include "ThermoFun/ThermoProperties.h" +#include "ThermoFun/ThermoParameters.h" +#include "ThermoFun/ThermoModelsSolvent.h" +#include "ThermoFun/ElectroModelsSolvent.h" +#include "ThermoFun/GlobalVariables.h" using namespace std; using namespace ThermoFun; @@ -16,104 +19,85 @@ int main(int argc, char *argv[]) cout << "Hello World!" << endl; - string file = argv[1]; - - Database tdb(file); - Database tdb2; + Database tdb; - double T = 25; - double P = 0; + double T = 1000+273.15; + double P = 60000e5; - Substance water; + Substance water, water2; water.setName("water"); water.setSymbol("H2O@"); water.setFormula("H2O"); water.setSubstanceClass(SubstanceClass::type::AQSOLVENT); water.setAggregateState(AggregateState::type::AQUEOUS); - water.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WJNG); + water.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WSV14); // dielectric propertie Svernjensy et al. (2014) - water.setMethod_T(MethodCorrT_Thrift::type::CTM_WAT); + water.setMethod_T(MethodCorrT_Thrift::type::CTM_WZD); // water PVT properties Zhang and Duan (2003) + // Water as in Sverjensky et al. (2014) tdb.addSubstance(water); - vector vSubst = tdb.getSubstances(); + water2.setName("water2"); + water2.setSymbol("H2O@2"); + water2.setFormula("H2O2"); + water2.setSubstanceClass(SubstanceClass::type::AQSOLVENT); + water2.setAggregateState(AggregateState::type::AQUEOUS); - for (int i = 0; i < vSubst.size(); i++) - { - if (vSubst[i].substanceClass() == SubstanceClass::type::AQSOLUTE) - vSubst[i].setSolventSymbol(water.symbol()); + water2.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WJNR); // Johnson and Norton (1991) - tdb2.addSubstance(vSubst[i]); - } + water2.setMethod_T(MethodCorrT_Thrift::type::CTM_WWP); // Wagner and Pruss (1995) - ThermoPropertiesSubstance result; + // Water Wagner and Puss IAPWS95, dielectrip properties Johnson and Norton (1991) + tdb.addSubstance(water2); - Thermo thermo (tdb2); + ThermoPropertiesSubstance result, result2, result3; + PropertiesSolvent ps, ps2; + ElectroPropertiesSolvent eps, eps2; - result = thermo.thermoPropertiesSubstance(T, P, "Al+3"); + ThermoEngine thermo (tdb); - cout << "\n Al+3 " << "T:" << T << " C, P:"<< P << " bar"<< endl; - cout << "G0: " << result.gibbs_energy << endl; - cout << "H0: " << result.enthalpy << endl; - cout << "S0: " << result.entropy << endl; - cout << "Cp0: " << result.heat_capacity_cp << endl; - cout << "Cv0: " << result.heat_capacity_cv << endl; - cout << "V0: " << result.volume << endl; - cout << "A0: " << result.helmholtz_energy << endl; - cout << "U0: " << result.internal_energy << endl; + result = thermo.thermoPropertiesSubstance(T, P, "H2O@"); + result2 = thermo.thermoPropertiesSubstance(T, P, "H2O@2"); - OutputToCSV out (argv[0]); - out.openThermoPropertiesSubstanceFile("ThermoPropSubst.csv"); - out.writeThermoPropertiesSubstance("Al+3", T, P, result); + ps = thermo.propertiesSolvent(T, P, "H2O@"); + ps2 = thermo.propertiesSolvent(T, P, "H2O@2"); - result = thermo.thermoPropertiesSubstance(T, P, "CO2@AD"); + eps = thermo.electroPropertiesSolvent(T, P, "H2O@"); + eps2 = thermo.electroPropertiesSolvent(T, P, "H2O@2"); - cout << "\n CO2@AD " << "T:" << T << " C, P:"<< P << " bar"<< endl; - cout << "G0: " << result.gibbs_energy << endl; - cout << "H0: " << result.enthalpy << endl; - cout << "S0: " << result.entropy << endl; - cout << "Cp0: " << result.heat_capacity_cp << endl; - cout << "Cv0: " << result.heat_capacity_cv << endl; - cout << "V0: " << result.volume << endl; - cout << "A0: " << result.helmholtz_energy << endl; - cout << "U0: " << result.internal_energy << endl; + Substance al3; + al3.setName("Al+3"); + al3.setFormula("Al+3"); + al3.setSymbol("Al+3"); + al3.setCharge(3); - result = thermo.thermoPropertiesSubstance(T, P, "Gibbsite"); + al3.setSubstanceClass(SubstanceClass::type::AQSOLUTE); + al3.setAggregateState(AggregateState::type::AQUEOUS); - cout << "\n Gibbsite " << "T:" << T << " C, P:"<< P << " bar"<< endl; - cout << "G0: " << result.gibbs_energy << endl; - cout << "H0: " << result.enthalpy << endl; - cout << "S0: " << result.entropy << endl; - cout << "Cp0: " << result.heat_capacity_cp << endl; - cout << "Cv0: " << result.heat_capacity_cv << endl; - cout << "V0: " << result.volume << endl; - cout << "A0: " << result.helmholtz_energy << endl; - cout << "U0: " << result.internal_energy << endl; + al3.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_HKFR); + al3.setMethod_P(MethodCorrP_Thrift::type::CPM_HKF); + al3.setMethod_T(MethodCorrT_Thrift::type::CTM_HKF); - result = thermo.thermoPropertiesSubstance(T, P, "H2O@"); + vector hkf = {-0.33802, -1700.71, 14.5185, -20758, 10.7, -80600, 275300 }; + + ThermoPropertiesSubstance ref; + + ref.gibbs_energy = -115609*cal_to_J; + ref.enthalpy = -126834*cal_to_J; + ref.entropy = -77.7*cal_to_J; + + ThermoParametersSubstance prs; + prs.HKF_parameters = hkf; + al3.setThermoParameters(prs); + al3.setThermoReferenceProperties(ref); + + tdb.addSubstance(al3); + + result3 = thermo.thermoPropertiesSubstance(T, P, "Al+3"); - cout << "\n H2O@ " << "T:" << T << " C, P:"<< P << " bar"<< endl; - cout << "G0: " << result.gibbs_energy << endl; - cout << "H0: " << result.enthalpy << endl; - cout << "S0: " << result.entropy << endl; - cout << "Cp0: " << result.heat_capacity_cp << endl; - cout << "Cv0: " << result.heat_capacity_cv << endl; - cout << "V0: " << result.volume << endl; - cout << "A0: " << result.helmholtz_energy << endl; - cout << "U0: " << result.internal_energy << endl; - - result = thermo.thermoPropertiesSubstance(T, P, "K+"); - - cout << "\n K+ " << "T:" << T << " C, P:"<< P << " bar"<< endl; - cout << "G0: " << result.gibbs_energy << endl; - cout << "H0: " << result.enthalpy << endl; - cout << "S0: " << result.entropy << endl; - cout << "Cp0: " << result.heat_capacity_cp << endl; - cout << "Cv0: " << result.heat_capacity_cv << endl; - cout << "V0: " << result.volume << endl; - cout << "A0: " << result.helmholtz_energy << endl; - cout << "U0: " << result.internal_energy << endl; + const double al3_sv14_T1000_P6000 = (-75494) * 4.184; + const double al3_sv14_T1000_P6000_fernandez = (-81043) * 4.184; cout << "Bye World!" << endl; diff --git a/tests/unit05/IO-autoOutput-test.pro b/tests/unit05/IO-autoOutput-test.pro deleted file mode 100644 index 79d70311..00000000 --- a/tests/unit05/IO-autoOutput-test.pro +++ /dev/null @@ -1,55 +0,0 @@ -TEMPLATE = app -CONFIG += console -CONFIG -= app_bundle -CONFIG -= qt - -#QMAKE_CXXFLAGS += -std=c++1y -QMAKE_CXXFLAGS += -std=c++11 - -#CONFIG += -std=c++11 - -TARGET = IO-autoOutput-test - -ThermoFun_TEST_CPP = ./src -ThermoFun_CPP = ../../../thermofun/src - -ThermoFun_TEST_H = $$ThermoFun_TEST_CPP -ThermoFun_H = $$ThermoFun_CPP - -DEPENDPATH += $$ThermoFun_TEST_H -DEPENDPATH += $$ThermoFun_H - -INCLUDEPATH += $$ThermoFun_TEST_H -INCLUDEPATH += $$ThermoFun_H - -QMAKE_LFLAGS += -OBJECTS_DIR = obj - -# Define the directory where the gui, third-party libs, resources are located -BUILD_DIR = $$OUT_PWD/.. -THRIFT_DIR = ./thrift - -# Define the directory where the third-party libraries have been installed -#THIRDPARTY_DIR = $$BUILD_DIR/thirdparty/debug -CONFIG(release, debug|release): THIRDPARTY_DIR = $$BUILD_DIR/release/thirdparty -CONFIG(debug, debug|release): THIRDPARTY_DIR = $$BUILD_DIR/debug/thirdparty -# Define the directories where the headers of the third-party libraries have been installed -THIRDPARTY_INCLUDE_DIR = $$THIRDPARTY_DIR/include - -# Define the directories where the THIRDPARTY libraries have been installed -THIRDPARTY_LIBRARY_DIR1 = $$THIRDPARTY_DIR/lib -THIRDPARTY_LIBRARY_DIR2 = $$THIRDPARTY_DIR/lib/x86_64-linux-gnu - -DEPENDPATH += $$THIRDPARTY_INCLUDE_DIR -INCLUDEPATH += $$THIRDPARTY_INCLUDE_DIR - -LIBS += -L$$THIRDPARTY_LIBRARY_DIR1 -LIBS += -L$$THIRDPARTY_LIBRARY_DIR2 -LIBS += -lbsonio -lyaml-cpp -lejdb -lpugixml -LIBS += -lthrift -LIBS += -llua5.2 - -include($$ThermoFun_TEST_CPP/ThermoFun-test.pri) -include($$ThermoFun_CPP/ThermoFun.pri) - - diff --git a/tests/unit05/src/README.txt b/tests/unit05/src/README.txt deleted file mode 100644 index 956c6658..00000000 --- a/tests/unit05/src/README.txt +++ /dev/null @@ -1 +0,0 @@ -Tests for implementation of the Akinfiev Diamond (2003) EOS - GEMS version diff --git a/tests/unit05/src/ThermoFun-test.pri b/tests/unit05/src/ThermoFun-test.pri deleted file mode 100644 index e71cd15e..00000000 --- a/tests/unit05/src/ThermoFun-test.pri +++ /dev/null @@ -1,3 +0,0 @@ -HEADERS += - -SOURCES += $$ThermoFun_TEST_CPP/main.cpp \ diff --git a/tests/unit05/src/main.cpp b/tests/unit05/src/main.cpp deleted file mode 100644 index 8c35241a..00000000 --- a/tests/unit05/src/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include -//#include "tcorrpt.h" -#include "Database.h" -#include "Substance.h" -#include "ThermoModelsSubstance.h" -#include "ThermoFun_global.h" -#include "Thermo.h" -#include "Common/OutputToCSV.h" - -using namespace std; -using namespace ThermoFun; - -int main(int argc, char *argv[]) -{ - - cout << "Hello World!" << endl; - - string file = argv[1]; - - Database tdb(file); - Database tdb2; - - double T = 100; - double P = 5000; - - Substance water; - water.setName("water"); - water.setSymbol("H2O@"); - water.setFormula("H2O"); - water.setSubstanceClass(SubstanceClass::type::AQSOLVENT); - water.setAggregateState(AggregateState::type::AQUEOUS); - - water.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WJNG); - - water.setMethod_T(MethodCorrT_Thrift::type::CTM_WAT); - - tdb.addSubstance(water); - - vector vSubst = tdb.getSubstances(); - - for (int i = 0; i < vSubst.size(); i++) - { - if (vSubst[i].substanceClass() == SubstanceClass::type::AQSOLUTE) - vSubst[i].setSolventSymbol(water.symbol()); - - tdb2.addSubstance(vSubst[i]); - } - - ThermoPropertiesSubstance result; - - Thermo thermo (tdb2); - - OutputToCSV out (argv[0]); - out.openThermoPropertiesSubstanceFile("ThermoPropSubstSUBCRT_JNG_WAT.csv"); - - P = 5000; - result = thermo.thermoPropertiesSubstance(577, P, "Al+3"); - - do { - - for (int i = 0; i < vSubst.size(); i++) - { - result = thermo.thermoPropertiesSubstance(T,P,vSubst[i].symbol()); - out.writeThermoPropertiesSubstance( vSubst[i].symbol(), T, P, result); - } - - T +=5; - } while (T <= 800); - - out.closeThermoPropertiesSubstanceFile(); - -// OutputToCSV out2 (argv[0]); -// out2.openThermoPropertiesSubstanceFile("ThermoPropSubstSUPCRT.csv"); - - -// for (int i = 0; i < vSubst.size(); i++) -// { -// P= 500; -// do -// { -// T= 5; -// do { -// out2.writeThermoPropertiesSubstance( vSubst[i].symbol(), T, P, thermo.thermoPropertiesSubstance(T,P,vSubst[i].symbol()) ); -// T +=5; -// } while (T <= 350); -// P +=500; -// } while (P <=5000); -// } - -// out2.closeThermoPropertiesSubstanceFile(); - cout << "Bye World!" << endl; - - return 0; -} - diff --git a/tests/unit06/src/README.txt b/tests/unit06/src/README.txt deleted file mode 100644 index 138235a8..00000000 --- a/tests/unit06/src/README.txt +++ /dev/null @@ -1 +0,0 @@ -Tests for implementation of the Zhang and Duan (2005) H2O VdP EOS diff --git a/tests/unit06/src/ThermoFun-test.pri b/tests/unit06/src/ThermoFun-test.pri deleted file mode 100644 index e71cd15e..00000000 --- a/tests/unit06/src/ThermoFun-test.pri +++ /dev/null @@ -1,3 +0,0 @@ -HEADERS += - -SOURCES += $$ThermoFun_TEST_CPP/main.cpp \ diff --git a/tests/unit06/src/main.cpp b/tests/unit06/src/main.cpp deleted file mode 100644 index 3e800d10..00000000 --- a/tests/unit06/src/main.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -//#include "tcorrpt.h" -#include "Database.h" -#include "Substance.h" -#include "ThermoModelsSubstance.h" -#include "ThermoFun_global.h" -#include "Thermo.h" -#include "Common/OutputToCSV.h" - -using namespace std; -using namespace ThermoFun; - -int main(int argc, char *argv[]) -{ - - cout << "Hello World!" << endl; - - Database tdb; - - double T = 1000; - double P = 60000; - - Substance water, water2; - water.setName("water"); - water.setSymbol("H2O@"); - water.setFormula("H2O"); - water.setSubstanceClass(SubstanceClass::type::AQSOLVENT); - water.setAggregateState(AggregateState::type::AQUEOUS); - - water.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WSV14); // dielectric propertie Svernjensy et al. (2014) - - water.setMethod_T(MethodCorrT_Thrift::type::CTM_WZD); // water PVT properties Zhang and Duan (2003) - - // Water as in Sverjensky et al. (2014) - tdb.addSubstance(water); - - water2.setName("water2"); - water2.setSymbol("H2O@2"); - water2.setFormula("H2O2"); - water2.setSubstanceClass(SubstanceClass::type::AQSOLVENT); - water2.setAggregateState(AggregateState::type::AQUEOUS); - - water2.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_WJNR); // Johnson and Norton (1991) - - water2.setMethod_T(MethodCorrT_Thrift::type::CTM_WWP); // Wagner and Pruss (1995) - - // Water Wagner and Puss IAPWS95, dielectrip properties Johnson and Norton (1991) - tdb.addSubstance(water2); - - ThermoPropertiesSubstance result, result2, result3; - PropertiesSolvent ps, ps2; - ElectroPropertiesSolvent eps, eps2; - - Thermo thermo (tdb); - - result = thermo.thermoPropertiesSubstance(T, P, "H2O@"); - result2 = thermo.thermoPropertiesSubstance(T, P, "H2O@2"); - - ps = thermo.propertiesSolvent(T, P, "H2O@"); - ps2 = thermo.propertiesSolvent(T, P, "H2O@2"); - - eps = thermo.electroPropertiesSolvent(T, P, "H2O@"); - eps2 = thermo.electroPropertiesSolvent(T, P, "H2O@2"); - - Substance al3; - al3.setName("Al+3"); - al3.setFormula("Al+3"); - al3.setSymbol("Al+3"); - al3.setCharge(3); - al3.setSolventSymbol("H2O@"); - - al3.setSubstanceClass(SubstanceClass::type::AQSOLUTE); - al3.setAggregateState(AggregateState::type::AQUEOUS); - - al3.setMethodGenEoS(MethodGenEoS_Thrift::type::CTPM_HKFR); - al3.setMethod_P(MethodCorrP_Thrift::type::CPM_HKF); - al3.setMethod_T(MethodCorrT_Thrift::type::CTM_HKF); - - vector hkf = {-0.33802, -1700.71, 14.5185, -20758, 10.7, -80600, 275300 }; - - ThermoPropertiesSubstance ref; - - ref.gibbs_energy = -115609*cal_to_J; - ref.enthalpy = -126834*cal_to_J; - ref.entropy = -77.7*cal_to_J; - - ThermoParametersSubstance prs; - prs.HKF_parameters = hkf; - al3.setThermoParameters(prs); - al3.setThermoReferenceProperties(ref); - - tdb.addSubstance(al3); - - result3 = thermo.thermoPropertiesSubstance(T, P, "Al+3"); - - const double al3_sv14_T1000_P6000 = (-75494) * 4.184; - const double al3_sv14_T1000_P6000_fernandez = (-81043) * 4.184; - - cout << "Bye World!" << endl; - - return 0; -} -