diff --git a/.hdoc.toml b/.hdoc.toml new file mode 100644 index 0000000..1188a25 --- /dev/null +++ b/.hdoc.toml @@ -0,0 +1,32 @@ +[project] +name = "thermofun" +version = "0.4.2" + +# Optional, adding this will enable direct links from the documentation +# to your source code. +git_repo_url = "https://github.com/thermohub/thermofun/" +git_default_branch = "master" + +[paths] +compile_commands = "build/compile_commands.json" +# output_dir = "docs/hdoc-output" + +[pages] +homepage = "docs/index.md" + +[ignore] +# Symbols from any of the following path fragments will be ignored +ignore_private_members = true +paths = [ + "/python/", + "/pytests/", + "/tests/", + "/Common/", + "OptimizationUtils.h", + "/Substances/Solvent/Reaktoro/", + "/Substances/Gases/s_solmod_.cpp", + "/Substances/Gases/s_solmod_.h", + "/Substances/Gases/s_solmod2_.cpp", + "/Substances/Gases/verror.h" + # more paths can be added as needed +] diff --git a/CMakeLists.txt b/CMakeLists.txt index b72f014..9113346 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") include(CCache) # Set the name of the project -project(ThermoFun VERSION 0.4.1 LANGUAGES CXX) +project(ThermoFun VERSION 0.4.2 LANGUAGES CXX) # Define variables with the GNU standard installation directories include(GNUInstallDirs) diff --git a/README.md b/README.md index 4b5c175..246dccb 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Linux, OSX, Windows A code for calculating the standard state thermodynamic properties of substances and reactions at a given temperature and pressure. +- [Code documentation](https://docs.hdoc.io/dmiron/thermofun/?target=_blank) - [Simple C++ API example](#simple-c-api-example) - [Try ThermoFun](#try-thermofun-in-your-browser-click-launch-binder) - [Python example](#simple-python-api-example) diff --git a/ThermoFun/Batch/OutputBatch.h b/ThermoFun/Batch/OutputBatch.h index 660ac3c..16044de 100644 --- a/ThermoFun/Batch/OutputBatch.h +++ b/ThermoFun/Batch/OutputBatch.h @@ -23,14 +23,14 @@ class Output /** * @brief toCSV write results to CSV file - * with substances/reactions on rows and proeprties on columns + * with substances/reactions on rows and properties on columns * @param filename */ auto toCSV (std::string filename) -> void; /** * @brief toCSVTransposed write results to CSV file in a special transposed format. - * with substances/reactions on columns and proeprties on rows + * with substances/reactions on columns and properties on rows * @param filename */ auto toCSVTransposed (std::string filename) -> void; diff --git a/ThermoFun/Batch/ThermoBatch.cpp b/ThermoFun/Batch/ThermoBatch.cpp index 9ae2038..55384e8 100644 --- a/ThermoFun/Batch/ThermoBatch.cpp +++ b/ThermoFun/Batch/ThermoBatch.cpp @@ -615,5 +615,24 @@ auto ThermoBatch::results() -> const vvThScalar return pimpl->results; } +auto ThermoBatch::temperatureIncrement() -> const std::map& +{ + return pimpl->Tincrement; +} + +auto ThermoBatch::pressureIncrement() -> const std::map& +{ + return pimpl->Pincrement; +} + +auto ThermoBatch::propertyUnits () -> const std::map& +{ + return pimpl->givenPropertyUnits; +} +auto ThermoBatch::propertyDigits() -> const std::map& +{ + return pimpl->givenPropertyDigits; +} + } diff --git a/ThermoFun/Batch/ThermoBatch.h b/ThermoFun/Batch/ThermoBatch.h index 89b1ac4..22b7efe 100644 --- a/ThermoFun/Batch/ThermoBatch.h +++ b/ThermoFun/Batch/ThermoBatch.h @@ -28,7 +28,7 @@ typedef std::vector vtps; typedef std::vector vtpr; /** - * @brief The OutputOptions struct holds the options for outputing results + * @brief The OutputOptions struct holds the options for outputting results */ struct BatchPreferences { @@ -68,17 +68,17 @@ struct BatchPreferences /// /// \brief The Interface class provides an interface to C++ codes coupled to ThermoFunk library for performing /// calculations related to the standard state properties of substances and reactions at different temperatures -/// and pressures, and retriveve the results as CSV output file, 2D vector (of double or ThrmoScalar types), or +/// and pressures, and retrieve the results as CSV output file, 2D vector (of double or ThrmoScalar types), or /// single value (of double or ThermoScalar types) for one property-substance-T-P calculation. /// -/// The class provides several functions for adding the symbol of the substance or reaction (or lists of symblos) +/// The class provides several functions for adding the symbol of the substance or reaction (or lists of symbols) /// for which the calculations will be performed. /// /// The class provides several functions for adding the temperature and pressure points at which the calculations /// will be performed. /// -/// The class provides several functions for setting the unist in which the results are dysplayed and the -/// siginifincat digits (or precision) in which the values will be written in the output CSV file. +/// The class provides several functions for setting the units in which the results are displayed and the +/// siginificant digits (or precision) in which the values will be written in the output CSV file. /// /// The input temperature and pressure should be in celsius and bar /// @@ -114,7 +114,7 @@ class ThermoBatch auto setTemperatureIncrement (const double& Tmin, const double& Tmax, const double& Tstep) -> void; auto setPressureIncrement (const double& Pmin, const double& Pmax, const double& Pstep) -> void; - // claculate functions substances + // calculate functions substances auto thermoPropertiesSubstance (double T, double P, std::string symbol, std::string property) -> Output; auto thermoPropertiesSubstance (double T, double P, vstr symbols, vstr properties) -> Output; auto thermoPropertiesSubstance (vstr symbols, vstr properties) -> Output; @@ -123,7 +123,7 @@ class ThermoBatch auto thermoPropertiesSubstance (std::vector temperatures, std::vector pressures, vstr symbols, vstr properties) -> Output; auto thermoPropertiesSubstance (std::vector temperatures, std::vector pressures, vstr symbols, vstr properties, vtps vTps) -> Output; - // claculate functions reactions + // calculate functions reactions auto thermoPropertiesReaction (double T, double P, std::string symbol, std::string property) -> Output; auto thermoPropertiesReaction (double T, double P, vstr symbols, vstr properties) -> Output; auto thermoPropertiesReaction (vstr symbols, vstr properties) -> Output; @@ -135,6 +135,12 @@ class ThermoBatch auto setBatchPreferences (const BatchPreferences &value) -> void; auto setSolventSymbol (const std::string solventSymbol) ->void; + auto temperatureIncrement () -> const std::map&; + auto pressureIncrement () -> const std::map&; + + auto propertyUnits () -> const std::map&; + auto propertyDigits () -> const std::map&; + private: struct Impl; std::shared_ptr pimpl; @@ -154,7 +160,7 @@ class ThermoBatch const std::map defaultPropertyNames = { - // Substance propeties + // Substance properties {"gibbs_energy", "substance" }, {"enthalpy", "substance" }, {"entropy", "substance" }, @@ -163,7 +169,7 @@ const std::map defaultPropertyNames = {"volume", "substance" }, {"helmholtz_energy", "substance" }, {"internal_energy", "substance" }, - // Reaction propeties + // Reaction properties {"reaction_gibbs_energy", "reaction" }, {"reaction_helmholtz_energy", "reaction" }, {"reaction_internal_energy", "reaction" }, @@ -174,7 +180,7 @@ const std::map defaultPropertyNames = {"reaction_heat_capacity_cv", "reaction" }, {"logKr", "reaction" }, {"lnKr", "reaction" }, - // Solvent propeties + // Solvent properties {"density", "solvent" }, {"densityT", "solvent" }, {"densityP", "solvent" }, diff --git a/ThermoFun/Database.h b/ThermoFun/Database.h index 2f7034b..7720527 100644 --- a/ThermoFun/Database.h +++ b/ThermoFun/Database.h @@ -43,7 +43,7 @@ class Database explicit Database(std::string filename); /** - * @brief Database constructs a database instace from a vector of records in json format + * @brief Database constructs a database instance from a vector of records in json format * Records with the same symbol will be overwritten! * @param jsonRecords vector of records in JSON string format * @param _label, optional, (element, substance, reactions), @@ -68,7 +68,7 @@ class Database * @brief appendData append records to the database from a vector of JSON strings * Records with the same symbol will be overwritten! * @param jsonRecords vector of records in JSON string format - * @param _label, oprional, (element, substance, reactions), + * @param _label, optional, (element, substance, reactions), * used when the vector of records are of one type and do not contain themselves the key "_label" */ auto appendData(std::vector jsonRecords, std::string _label) -> void; diff --git a/ThermoFun/Substance.h b/ThermoFun/Substance.h index 9dac85f..00c1c9c 100644 --- a/ThermoFun/Substance.h +++ b/ThermoFun/Substance.h @@ -17,10 +17,10 @@ struct ThermoParametersSubstance; class Substance { public: - /// Constrcut a default Substance instance + /// Construct a default Substance instance Substance(); - /// Constrcut a Substance instance from a JSON string + /// Construct a Substance instance from a JSON string Substance(std::string jsonSubstance); /// Construct a copy of an Substance instance diff --git a/ThermoFun/ThermoEngine.h b/ThermoFun/ThermoEngine.h index 3841045..6f644df 100644 --- a/ThermoFun/ThermoEngine.h +++ b/ThermoFun/ThermoEngine.h @@ -22,7 +22,7 @@ struct ElectroPropertiesSolvent; struct PropertiesSolvent; /** - * @brief The Thermo class mainly calculates the thermodynamic properties of the substances + * @brief The ThermoEngine class calculates the thermodynamic properties of the substances * from the internal database. It also calculates the electro-chemical and other physico-chemical * properties of the solvent */ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..27f5e03 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,68 @@ + + +# [ThermoFun](https://thermohub.org/thermofun/thermofun/) + +#### Details on the API functionality can be found by [searching](https://docs.hdoc.io/dmiron/thermofun/search.html) the documentation. The naming is the same in C++ and Python. + +Using ThermoFun is as simple as loading a [database](https://github.com/thermohub/thermofun-jupyter/blob/master/how-to-use-a-database.ipynb) initializing a [ThermoEngine](https://github.com/thermohub/thermofun-jupyter/blob/master/how-to-calculate-properties-thermoengine.ipynb)/[ThermoBatch](https://github.com/thermohub/thermofun-jupyter/blob/master/how-to-do-batch-calculations.ipynb) and calling the function to [calculate the properties](https://github.com/thermohub/thermofun-jupyter/blob/master/how-to-calculate-properties-substance-reaction.ipynb) for given substance(s)/reaction(s) at given T-P condition(s). + +```python + import thermofun as fun + database = fun.Database('aq17-thermofun.json') + engine = fun.ThermoEngine(database) + # T(K) P(Pa) symbol + Ca_ion = engine.thermoPropertiesSubstance(473, 2000e5, 'Ca+2') + print(f'G0 {Ca_ion.gibbs_energy.val} J/mol') + # T(K) P(Pa) reaction equation + calcite_dissolution = engine.thermoPropertiesReaction(348.15, 1e5, 'Calcite = Ca+2 + CO3-2') + print(f'drS0 of (Cal = Ca+2 + CO3-2) is {calcite_dissolution.reaction_entropy.val}') + print(f'drG0 of (Cal = Ca+2 + CO3-2) is {calcite_dissolution.reaction_gibbs_energy.val}') + print(f'logK0 of (Cal = Ca+2 + CO3-2) is {calcite_dissolution.log_equilibrium_constant.val}') +``` + +In Python using the `help` function can provide hints on the usability. + +```python +help(fun.ThermoEngine) + +Help on class ThermoEngine in module thermofun.PyThermoFun: + +class ThermoEngine(pybind11_builtins.pybind11_object) + | Contains methods for calculating the thermodynamic properties of the substances and reactions + ... +``` + +Try the ThermoFun examples in your browser: + +[![Launch ThermoFun tutorials](https://img.shields.io/badge/launch-ThermoFun%20tutorials-brightgreen?style=for-the-badge&logo=jupyter)](https://mybinder.org/v2/gh/thermohub/thermofun-jupyter/master?urlpath=lab/) + +## The main ThermoFun classes + +* [Database](https://docs.hdoc.io/dmiron/thermofun/r820E4166D6856B34.html): The Database class stores maps of elements, substances and reactions. A database instance can be used to create a ThermoEngine instance which can be further used to calculate the standard thermodynamic properties of substances and reactions at T and P + +[![Launch example on initializing a database from file](https://img.shields.io/badge/launch-Database%20example-brightgreen?style=for-the-badge&logo=jupyter)](https://mybinder.org/v2/gh/thermohub/thermofun-jupyter/master?urlpath=lab/tree/how-to-use-a-database.ipynb) + +* [ThermoEngine](https://docs.hdoc.io/dmiron/thermofun/r15CBE4920E8D3EF1.html): The main ThermoFun class for doing calculations. It calculates the thermodynamic properties of the substances from the database. It also calculates the electro-chemical and other physico-chemical properties of the solvent. + +[![Launch example on using ThermoEngine to calculate thermodynamic properties](https://img.shields.io/badge/launch-ThermoEngine%20example-brightgreen?style=for-the-badge&logo=jupyter)](https://mybinder.org/v2/gh/thermohub/thermofun-jupyter/master?urlpath=lab/tree/how-to-calculate-properties-thermoengine.ipynb) + +* [ThermoBatch](https://docs.hdoc.io/dmiron/thermofun/r88DCC0D87A971DFF.html): The Batch class is useful for doing batch calculations for a given list of substances, reactions, properties, and temperature and pressure grid. Options to set the input and output properties units are available. + +[![Launch example on doing batch calculations, for a list of substances, T-P intervals](https://img.shields.io/badge/launch-ThermoBatch%20example-brightgreen?style=for-the-badge&logo=jupyter)](https://mybinder.org/v2/gh/thermohub/thermofun-jupyter/master?urlpath=lab/tree/how-to-do-batch-calculations.ipynb) diff --git a/python/pyThermoFun/Batch/pyOutputBatch.cpp b/python/pyThermoFun/Batch/pyOutputBatch.cpp index 0f9ff71..f7d1beb 100644 --- a/python/pyThermoFun/Batch/pyOutputBatch.cpp +++ b/python/pyThermoFun/Batch/pyOutputBatch.cpp @@ -35,14 +35,14 @@ namespace ThermoFun { void exportOutput(py::module& m) { - py::class_(m, "Output") + py::class_(m, "Output", "Type for outputting results to different formats") .def(py::init()) - .def("toCSV", &Output::toCSV) - .def("toCSVTransposed", &Output::toCSVTransposed) - .def("toCSVPropertyGrid", &Output::toCSVPropertyGrid) + .def("toCSV", &Output::toCSV, "write results to CSV file with substances/reactions on rows and properties on columns") + .def("toCSVTransposed", &Output::toCSVTransposed, "write results to CSV file in a special transposed format with substances/reactions on columns and properties on rows") + .def("toCSVPropertyGrid", &Output::toCSVPropertyGrid, "write results to CSV file in a property grid format") .def("toDouble", &Output::toDouble) .def("toThermoScalar", &Output::toThermoScalar) - .def("to2DVectorDouble", &Output::to2DVectorDouble) + .def("to2DVectorDouble", &Output::to2DVectorDouble, "returns a list of results") ; } } diff --git a/python/pyThermoFun/Batch/pyThermoBatch.cpp b/python/pyThermoFun/Batch/pyThermoBatch.cpp index bf48722..03dac32 100644 --- a/python/pyThermoFun/Batch/pyThermoBatch.cpp +++ b/python/pyThermoFun/Batch/pyThermoBatch.cpp @@ -35,88 +35,90 @@ namespace py = pybind11; #include #include -namespace ThermoFun { - -void exportThermoBatch(py::module& m) +namespace ThermoFun { - auto thermoPropertiesSubstance1 = static_cast - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesSubstance2 = static_cast, std::vector)> - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesSubstance3 = static_cast, std::vector)> - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesSubstance4 = static_cast>, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesSubstance5 = static_cast>, std::vector, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesSubstance6 = static_cast, std::vector, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesSubstance7 = static_cast, std::vector, std::vector, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesSubstance); - auto thermoPropertiesReaction1 = static_cast - (&ThermoBatch::thermoPropertiesReaction); - auto thermoPropertiesReaction2 = static_cast, std::vector)> - (&ThermoBatch::thermoPropertiesReaction); - auto thermoPropertiesReaction3 = static_cast, std::vector)> - (&ThermoBatch::thermoPropertiesReaction); - auto thermoPropertiesReaction4 = static_cast>, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesReaction); - auto thermoPropertiesReaction5 = static_cast>, std::vector, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesReaction); - auto thermoPropertiesReaction6 = static_cast, std::vector, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesReaction); - auto thermoPropertiesReaction7 = static_cast, std::vector, std::vector, std::vector, std::vector)> - (&ThermoBatch::thermoPropertiesReaction); + void exportThermoBatch(py::module &m) + { + auto thermoPropertiesSubstance1 = static_cast(&ThermoBatch::thermoPropertiesSubstance); + auto thermoPropertiesSubstance2 = static_cast, std::vector)>(&ThermoBatch::thermoPropertiesSubstance); + auto thermoPropertiesSubstance3 = static_cast, std::vector)>(&ThermoBatch::thermoPropertiesSubstance); + auto thermoPropertiesSubstance4 = static_cast>, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesSubstance); + auto thermoPropertiesSubstance5 = static_cast>, std::vector, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesSubstance); + auto thermoPropertiesSubstance6 = static_cast, std::vector, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesSubstance); + auto thermoPropertiesSubstance7 = static_cast, std::vector, std::vector, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesSubstance); - py::class_(m, "ThermoBatch") - .def(py::init()) - .def(py::init()) - .def(py::init()) - .def("setUnits", &ThermoBatch::setUnits) - .def("setDigits", &ThermoBatch::setDigits) - .def("setPropertiesUnits", &ThermoBatch::setPropertiesUnits) - .def("setPropertiesDigits", &ThermoBatch::setPropertiesDigits) - .def("setPropertyUnit", &ThermoBatch::setPropertyUnit) - .def("setPropertyDigit", &ThermoBatch::setPropertyDigit) - .def("setPropertyUnitDigit", &ThermoBatch::setPropertyUnitDigit) - .def("setTemperatureIncrement", &ThermoBatch::setTemperatureIncrement) - .def("setPressureIncrement", &ThermoBatch::setPressureIncrement) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance1) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance2) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance3) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance4) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance5) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance6) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance7) - .def("thermoPropertiesReaction", thermoPropertiesReaction1) - .def("thermoPropertiesReaction", thermoPropertiesReaction2) - .def("thermoPropertiesReaction", thermoPropertiesReaction3) - .def("thermoPropertiesReaction", thermoPropertiesReaction4) - .def("thermoPropertiesReaction", thermoPropertiesReaction5) - .def("thermoPropertiesReaction", thermoPropertiesReaction6) - .def("thermoPropertiesReaction", thermoPropertiesReaction7) - .def("setBatchPreferences", &ThermoBatch::setBatchPreferences) - .def("setSolventSymbol", &ThermoBatch::setSolventSymbol) - ; -} + auto thermoPropertiesReaction1 = static_cast(&ThermoBatch::thermoPropertiesReaction); + auto thermoPropertiesReaction2 = static_cast, std::vector)>(&ThermoBatch::thermoPropertiesReaction); + auto thermoPropertiesReaction3 = static_cast, std::vector)>(&ThermoBatch::thermoPropertiesReaction); + auto thermoPropertiesReaction4 = static_cast>, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesReaction); + auto thermoPropertiesReaction5 = static_cast>, std::vector, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesReaction); + auto thermoPropertiesReaction6 = static_cast, std::vector, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesReaction); + auto thermoPropertiesReaction7 = static_cast, std::vector, std::vector, std::vector, std::vector)>(&ThermoBatch::thermoPropertiesReaction); -void exportBatchPreferences(py::module& m) -{ - py::class_(m, "BatchPreferences") - .def(py::init<>()) - .def_readwrite("isFixed", &BatchPreferences::isFixed) - .def_readwrite("isFloating", &BatchPreferences::isFloating) - .def_readwrite("isScientific", &BatchPreferences::isScientific) - .def_readwrite("separator", &BatchPreferences::separator) - .def_readwrite("fileName", &BatchPreferences::fileName) - .def_readwrite("solventFileName", &BatchPreferences::solventFileName) - .def_readwrite("outputSolventProperties", &BatchPreferences::outputSolventProperties) - .def_readwrite("substancePropertiesFromReaction", &BatchPreferences::substancePropertiesFromReaction) - .def_readwrite("reactionPropertiesFromReactants", &BatchPreferences::reactionPropertiesFromReactants) - .def_readwrite("loopOverTPpairsFirst", &BatchPreferences::loopOverTPpairsFirst) - .def_readwrite("loopTemperatureThenPressure", &BatchPreferences::loopTemperatureThenPressure) - ; -} + py::class_(m, "ThermoBatch", "Useful for performing batch calculations for multiple substance/reaction records for multiple T-P") + .def(py::init()) + .def(py::init()) + .def(py::init()) + // .def("setUnits", &ThermoBatch::setUnits) + // .def("setDigits", &ThermoBatch::setDigits) + .def("setPropertiesUnits", &ThermoBatch::setPropertiesUnits) + .def("setPropertiesDigits", &ThermoBatch::setPropertiesDigits) + .def("setPropertyUnit", &ThermoBatch::setPropertyUnit) + .def("setPropertyDigit", &ThermoBatch::setPropertyDigit) + .def("setPropertyUnitDigit", &ThermoBatch::setPropertyUnitDigit) + .def("setTemperatureIncrement", &ThermoBatch::setTemperatureIncrement) + .def("setPressureIncrement", &ThermoBatch::setPressureIncrement) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance1, "calculate for given property, substance symbol, temperature and pressure", py::arg("temperature"), py::arg("pressure"), py::arg("symbol"), py::arg("property")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance2, "calculate for given properties, substance symbols, temperature and pressure", py::arg("temperature"), py::arg("pressure"), py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance3, "calculate for given properties, substance symbols, temperatures and pressures are set with increment functions", py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance4, "calculate for given properties, substance symbols, and temperature and pressure pairs", py::arg("TP_pairs"), py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance5, "calculate for given properties, substance symbols, and temperature and pressure pairs", py::arg("TP_pairs"), py::arg("symbols"), py::arg("properties"), py::arg("provided_results")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance6, "calculate for given properties, substance symbols, temperatures and pressures", py::arg("temperatures"), py::arg("pressures"), py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance7, "calculate for given properties, substance symbols, temperatures and pressures", py::arg("temperatures"), py::arg("pressures"), py::arg("symbols"), py::arg("properties"), py::arg("provided_results")) + .def("thermoPropertiesReaction", thermoPropertiesReaction1, "calculate for given property, reaction symbol, temperature and pressure", py::arg("temperature"), py::arg("pressure"), py::arg("symbol"), py::arg("property")) + .def("thermoPropertiesReaction", thermoPropertiesReaction2, "calculate for given properties, reaction symbols, temperature and pressure", py::arg("temperature"), py::arg("pressure"), py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesReaction", thermoPropertiesReaction3, "calculate for given properties, reaction symbols, temperatures and pressures are set with increment functions", py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesReaction", thermoPropertiesReaction4, "calculate for given properties, reaction symbols, and temperature and pressure pairs", py::arg("TP_pairs"), py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesReaction", thermoPropertiesReaction5, "calculate for given properties, reaction symbols, and temperature and pressure pairs", py::arg("TP_pairs"), py::arg("symbols"), py::arg("properties"), py::arg("provided_results")) + .def("thermoPropertiesReaction", thermoPropertiesReaction6, "calculate for given properties, reaction symbols, temperatures and pressures", py::arg("temperatures"), py::arg("pressures"), py::arg("symbols"), py::arg("properties")) + .def("thermoPropertiesReaction", thermoPropertiesReaction7, "calculate for given properties, reaction symbols, temperatures and pressures", py::arg("temperatures"), py::arg("pressures"), py::arg("symbols"), py::arg("properties"), py::arg("provided_results")) + .def("setBatchPreferences", &ThermoBatch::setBatchPreferences) + .def("setSolventSymbol", &ThermoBatch::setSolventSymbol) + .def("temperatureIncrement", &ThermoBatch::temperatureIncrement, "returns the default temperature increment") + .def("pressureIncrement", &ThermoBatch::pressureIncrement, "returns the default pressure increment") + .def("propertyUnits", &ThermoBatch::propertyUnits, "returns the default properties units") + .def("propertyDigits", &ThermoBatch::propertyDigits, "returns the default properties number of round digits"); + } + + // void exportDefault(py::module& m) + //{ + // py::class_(m, "defs", "fdefs") + // .def_property_readonly("defaultPropertyNames", defaultPropertyNames) + // .def_property_readonly("defaultSolventPropertyUnits", defaultSolventPropertyUnits) + // .def_property_readonly("defaultSolventPropertyDigits", defaultSolventPropertyDigits) + // .def_property_readonly("defaultPropertyUnits", defaultPropertyUnits) + // .def_property_readonly("defaultPropertyDigits", defaultPropertyDigits) + // .def_property_readonly("defaultTemperatureIncrement", defaultTemperatureIncrement) + // .def_property_readonly("defaultPressureIncrement", defaultPressureIncrement) + // ; + // } + + void exportBatchPreferences(py::module &m) + { + py::class_(m, "BatchPreferences", "holds the options for outputting results") + .def(py::init<>()) + .def_readwrite("isFixed", &BatchPreferences::isFixed, "default=True, using fixed-point notation: the value is represented with exactly as many digits in the decimal part as specified by the precision field") + .def_readwrite("isFloating", &BatchPreferences::isFloating, "default=False, using floating point notation") + .def_readwrite("isScientific", &BatchPreferences::isScientific, "default=False, if True write values in scientific notation") + .def_readwrite("separator", &BatchPreferences::separator, "default=, separator used in output csv file") + .def_readwrite("fileName", &BatchPreferences::fileName, "output file name") + .def_readwrite("solventFileName", &BatchPreferences::solventFileName, "output file for solvent properties") + .def_readwrite("outputSolventProperties", &BatchPreferences::outputSolventProperties, "default=False, output calculated solvent properties to file") + .def_readwrite("substancePropertiesFromReaction", &BatchPreferences::substancePropertiesFromReaction, "default=False, calculate substance properties from reaction, if provided in the substance record with kez \"reaction\"") + .def_readwrite("reactionPropertiesFromReactants", &BatchPreferences::reactionPropertiesFromReactants, "default=False, calculate reaction properties from reactants") + .def_readwrite("loopOverTPpairsFirst", &BatchPreferences::loopOverTPpairsFirst, "default=True, when calculating properties the loop is going for T-P points first and then for substances/reactions list") + .def_readwrite("loopTemperatureThenPressure", &BatchPreferences::loopTemperatureThenPressure, "default=True, when calculating properties the loop is going for T and the P"); + } } diff --git a/python/pyThermoFun/PyThermoFun.cpp b/python/pyThermoFun/PyThermoFun.cpp index 8bd9624..b4373c8 100644 --- a/python/pyThermoFun/PyThermoFun.cpp +++ b/python/pyThermoFun/PyThermoFun.cpp @@ -45,10 +45,10 @@ PYBIND11_MODULE(PyThermoFun, m) exportReaction(m); exportElement(m); - m.def("availableSubstanceTPMethods", availableSubstanceTPMethods, "list of JSONs templates of avialable substance methods."); - m.def("availableReactionTPMethods", availableReactionTPMethods, "list of JSONs templates of avialable reaction methods."); + m.def("availableSubstanceTPMethods", availableSubstanceTPMethods, "list of JSONs templates of available substance methods."); + m.def("availableReactionTPMethods", availableReactionTPMethods, "list of JSONs templates of available reaction methods."); m.def("availablePropertiesSubstance", availablePropertiesSubstance, "list of available properties to calculate for a substance record."); m.def("availablePropertiesReaction", availablePropertiesReaction, "list of available properties to calculate for a reaction record."); - m.def("update_loggers", &update_loggers, "update log, default parameters (False, \"thermofun.log\", 2) "); - m.def("clear_loggers", &clear_loggers,"clear log, default parameters (False, \"thermofun.log\", 2) "); + m.def("update_loggers", &update_loggers, "update log, default parameters (False, \"thermofun.log\", 2), logging levels: trace = 0, debug = 1, info = 2, warn = 3, err = 4, critical = 5, off = 6 "); + m.def("clear_loggers", &clear_loggers,"clear log, default parameters (False, \"thermofun.log\", 2), trace = 0, debug = 1, info = 2, warn = 3, err = 4, critical = 5, off = 6 "); } diff --git a/python/pyThermoFun/pyDatabase.cpp b/python/pyThermoFun/pyDatabase.cpp index 21a34bf..6c03138 100644 --- a/python/pyThermoFun/pyDatabase.cpp +++ b/python/pyThermoFun/pyDatabase.cpp @@ -54,9 +54,9 @@ void exportDatabase(py::module& m) auto setReaction2 = static_cast(&Database::setReaction); - py::class_(m, "Database") + py::class_(m, "Database", "Stores maps of elements, substances and reactions. A database instance can be used to create a ThermoEngine instance which can be further used to calculate the standard thermodynamic properties of substances and reactions at T and P") .def(py::init<>()) - .def(py::init()) + .def(py::init(), "constructor using a JSON string with the thermofun database format") .def(py::init()) .def("appendData", appendData1, "Append records to the database from a file.") .def("appendData", appendData2, "Append records of given type (elements, substances, reactions) to the database from a list of JSON strings.") diff --git a/python/pyThermoFun/pyElement.cpp b/python/pyThermoFun/pyElement.cpp index 00676b5..aaf0a00 100644 --- a/python/pyThermoFun/pyElement.cpp +++ b/python/pyThermoFun/pyElement.cpp @@ -31,7 +31,7 @@ namespace ThermoFun { void exportElement(py::module& m) { - py::class_(m, "Element") + py::class_(m, "Element", "A type used to describe an element") .def(py::init<>()) .def(py::init()) .def(py::init()) diff --git a/python/pyThermoFun/pyReaction.cpp b/python/pyThermoFun/pyReaction.cpp index 058542b..5e834b1 100644 --- a/python/pyThermoFun/pyReaction.cpp +++ b/python/pyThermoFun/pyReaction.cpp @@ -34,10 +34,10 @@ namespace ThermoFun { void exportReaction(py::module& m) { - py::class_(m, "Reaction") + py::class_(m, "Reaction", "A type used to describe a reaction") .def(py::init<>()) .def(py::init()) - .def(py::init()) + .def(py::init(), "Constructor using a reaction record as a JSON string") .def("setName", &Reaction::setName,"Set the name of the Reaction.") .def("setSymbol", &Reaction::setSymbol,"Set the symbol of the Reaction.") .def("setEquation", &Reaction::setEquation,"Set the equation of the Reaction") @@ -45,7 +45,7 @@ void exportReaction(py::module& m) .def("setReferenceT", &Reaction::setReferenceT,"Set reference temperature fo the standard properties of reaction (K)") .def("setReferenceP", &Reaction::setReferenceP,"Set references pressure for the standard properties of reaction (Pa)") .def("setLowerT", &Reaction::setLowerT,"Set upper temperature limit of the correction method (K)") - .def("setLowerP", &Reaction::setLowerP,"Set upper presure limit of the correction method (Pa)") + .def("setLowerP", &Reaction::setLowerP,"Set upper pressure limit of the correction method (Pa)") .def("setUpperT", &Reaction::setUpperT,"Set lower temperature limit of the correction method (K)") .def("setUpperP", &Reaction::setUpperP,"Set lower pressure limit for the correction method (Pa)") .def("setMethodGenEoS", &Reaction::setMethodGenEoS,"Set the code for general EOS calculation method") @@ -64,7 +64,7 @@ void exportReaction(py::module& m) .def("referenceT", &Reaction::referenceT,"Returns the references temperature (K)") .def("referenceP", &Reaction::referenceP,"Returns the references pressure (Pa)") .def("lowerT", &Reaction::lowerT,"Return upper temperature limit of the correction method (K)") - .def("lowerP", &Reaction::lowerP,"Return upper presure limit of the correction method (Pa)") + .def("lowerP", &Reaction::lowerP,"Return upper pressure limit of the correction method (Pa)") .def("upperT", &Reaction::upperT,"Return lower temperature limit of the correction method (K)") .def("upperP", &Reaction::upperP,"Return lower pressure limit for the correction method (Pa)") .def("methodGenEOS", &Reaction::methodGenEOS,"Return the general EOS method code") diff --git a/python/pyThermoFun/pySubstance.cpp b/python/pyThermoFun/pySubstance.cpp index 3298104..84c7c2e 100644 --- a/python/pyThermoFun/pySubstance.cpp +++ b/python/pyThermoFun/pySubstance.cpp @@ -33,10 +33,10 @@ namespace ThermoFun { void exportSubstance(py::module& m) { - py::class_(m, "Substance") + py::class_(m, "Substance", "A type used to describe a chemical substance (species, dependent components)") .def(py::init<>()) .def(py::init()) - .def(py::init()) + .def(py::init(), "Constructor using a substance record as a JSON string") .def("setName", &Substance::setName, "Set the name of the Substance.") .def("setSymbol", &Substance::setSymbol, "Set the symbol of the Substance.") .def("setFormula", &Substance::setFormula, "Set the formula of the Substance.") @@ -48,7 +48,7 @@ void exportSubstance(py::module& m) .def("setMethod_T", &Substance::setMethod_T, "Set the code for the temperature correction method") .def("setMethod_P", &Substance::setMethod_P, "Set the code for the pressure correction method") .def("setLowerT", &Substance::setLowerT, "Set upper temperature limit of the correction method (K)") - .def("setLowerP", &Substance::setLowerP, "Set upper presure limit of the correction method (Pa)") + .def("setLowerP", &Substance::setLowerP, "Set upper pressure limit of the correction method (Pa)") .def("setUpperT", &Substance::setUpperT, "Set lower temperature limit of the correction method (K)") .def("setUpperP", &Substance::setUpperP, "Set lower pressure limit for the correction method (Pa)") .def("setSubstanceClass", &Substance::setSubstanceClass, "Set the code for the substance class") @@ -66,7 +66,7 @@ void exportSubstance(py::module& m) .def("referenceT", &Substance::referenceT, "Return the reference temperature (K)") .def("referenceP", &Substance::referenceP, "Return the reference pressure (Pa)") .def("lowerT", &Substance::lowerT, "Return upper temperature limit of the correction method (K)") - .def("lowerP", &Substance::lowerP, "Return upper presure limit of the correction method (Pa)") + .def("lowerP", &Substance::lowerP, "Return upper pressure limit of the correction method (Pa)") .def("upperT", &Substance::upperT, "Return lower temperature limit of the correction method (K)") .def("upperP", &Substance::upperP, "Return lower pressure limit for the correction method (Pa)") .def("thermoProperties", &Substance::thermoProperties, "Return the thermodynamic data of the substance.") @@ -76,7 +76,7 @@ void exportSubstance(py::module& m) .def("method_T", &Substance::method_T, "Return the temperature correction method code") .def("method_P", &Substance::method_P, "Return the pressure correction method code") .def("substanceClass", &Substance::substanceClass, "Return the class type of the substance") - .def("thermoCalculationType", &Substance::thermoCalculationType, "Return the code of the substance proeprties calculation type") + .def("thermoCalculationType", &Substance::thermoCalculationType, "Return the code of the substance properties calculation type") .def("aggregateState", &Substance::aggregateState, "Return the aggregate state of a substance") .def("charge", &Substance::charge, "Return the charge of a substance") .def("jsonString", &Substance::jsonString, "Return the record as a json string") diff --git a/python/pyThermoFun/pyThermoEngine.cpp b/python/pyThermoFun/pyThermoEngine.cpp index 137deb1..ddd21b3 100644 --- a/python/pyThermoFun/pyThermoEngine.cpp +++ b/python/pyThermoFun/pyThermoEngine.cpp @@ -51,25 +51,25 @@ void exportThermoEngine(py::module& m) auto thermoPropertiesReaction2 = static_cast(&ThermoEngine::thermoPropertiesReaction); auto thermoPropertiesReactionFromReactants2 = static_cast(&ThermoEngine::thermoPropertiesReactionFromReactants); - py::class_(m, "ThermoEngine") + py::class_(m, "ThermoEngine", "Contains methods for calculating the thermodynamic properties of the substances and reactions") // .def(py::init<>()) - .def(py::init()) - .def(py::init()) + .def(py::init(), "Constructor using a thermofun database as a JSON string") + .def(py::init(), "Constructor using a thermofun database") .def(py::init()) - .def("appendData", appendData1, "Append records to the database from a file.") - .def("appendData", appendData2, "Append records of given type (elements, substances, reactions) to the database from a list of JSON strings.") - .def("setSolventSymbol", &ThermoEngine::setSolventSymbol) - .def("solventSymbol", &ThermoEngine::solventSymbol) - .def("thermoPropertiesSubstance", thermoPropertiesSubstance1, "Calculate the thermodynamic properties of a substance with a given symbol.") - .def("electroPropertiesSolvent", electroPropertiesSolvent1, "Calculate the electro-chemical properties of a substance solvent with a given symbol.") - .def("propertiesSolvent", propertiesSolvent1, "Calculate the properties of a substance solvent with a given symbol.") - .def("thermoPropertiesReaction", thermoPropertiesReaction1, "Calculate the thermodynamic properties of a reaction with a given symbol, or for a given reaction equation.") - .def("thermoPropertiesReactionFromReactants", thermoPropertiesReactionFromReactants1, "Calculate the thermodynamic properties of a reaction from reactants with a given symbol.") - .def("thermoPropertiesSubstance", thermoPropertiesSubstance2, "Calculate the thermodynamic properties of a given substance object.") - .def("electroPropertiesSolvent", electroPropertiesSolvent2, "Calculate the electro-chemical properties of a given substance solvent object.") - .def("propertiesSolvent", propertiesSolvent2, "Calculate the properties of a given substance solvent object.") - .def("thermoPropertiesReaction", thermoPropertiesReaction2, "Calculate the thermodynamic properties of a given reaction object.") - .def("thermoPropertiesReactionFromReactants", thermoPropertiesReactionFromReactants2, "Calculate the thermodynamic properties from the reactants of a given reaction object.") + .def("appendData", appendData1, "Append a json string record to the database from a file", py::arg("record_json_string")) + .def("appendData", appendData2, "Append records of given label (element, substance, reaction) to the database from a list of JSON strings", py::arg("records_json"), py::arg("label")) + .def("setSolventSymbol", &ThermoEngine::setSolventSymbol, "Sets the symbol of the solvent record present in the thermodynamic dataset. Will be used to calculate the solvent properties ", py::arg("symbol")) + .def("solventSymbol", &ThermoEngine::solventSymbol, "Returns the symbol of the solvent record used to calculate the solvent properties") + .def("thermoPropertiesSubstance", thermoPropertiesSubstance1, "Calculate the thermodynamic properties of a substance with a given symbol.", py::arg("temperature"), py::arg("pressure"), py::arg("symbol")) + .def("electroPropertiesSolvent", electroPropertiesSolvent1, "Calculate the electro-chemical properties of a substance solvent with a given symbol.", py::arg("temperature"), py::arg("pressure"), py::arg("symbol")) + .def("propertiesSolvent", propertiesSolvent1, "Calculate the properties of a substance solvent with a given symbol.", py::arg("temperature"), py::arg("pressure"), py::arg("symbol")) + .def("thermoPropertiesReaction", thermoPropertiesReaction1, "Calculate the thermodynamic properties of a reaction with a given symbol, or for a given reaction equation.", py::arg("temperature"), py::arg("pressure"), py::arg("symbol")) + .def("thermoPropertiesReactionFromReactants", thermoPropertiesReactionFromReactants1, "Calculate the thermodynamic properties of a reaction from reactants with a given symbol.", py::arg("temperature"), py::arg("pressure"), py::arg("symbol")) + .def("thermoPropertiesSubstance", thermoPropertiesSubstance2, "Calculate the thermodynamic properties of a given substance object.", py::arg("temperature"), py::arg("pressure"), py::arg("substance")) + .def("electroPropertiesSolvent", electroPropertiesSolvent2, "Calculate the electro-chemical properties of a given substance solvent object.", py::arg("temperature"), py::arg("pressure"), py::arg("solvent")) + .def("propertiesSolvent", propertiesSolvent2, "Calculate the properties of a given substance solvent object.", py::arg("temperature"), py::arg("pressure"), py::arg("solvent")) + .def("thermoPropertiesReaction", thermoPropertiesReaction2, "Calculate the thermodynamic properties of a given reaction object.", py::arg("temperature"), py::arg("pressure"), py::arg("reaction")) + .def("thermoPropertiesReactionFromReactants", thermoPropertiesReactionFromReactants2, "Calculate the thermodynamic properties from the reactants of a given reaction object.", py::arg("temperature"), py::arg("pressure"), py::arg("reaction")) ; } diff --git a/python/pyThermoFun/pyThermoParameters.cpp b/python/pyThermoFun/pyThermoParameters.cpp index 1091cec..a782178 100644 --- a/python/pyThermoFun/pyThermoParameters.cpp +++ b/python/pyThermoFun/pyThermoParameters.cpp @@ -31,7 +31,7 @@ namespace ThermoFun { void exportThermoParametersSubstance(py::module& m) { - py::class_(m, "ThermoParametersSubstance") + py::class_(m, "ThermoParametersSubstance", "Parameters of a substance record") .def(py::init<>()) .def_readwrite("isothermal_compresibility", &ThermoParametersSubstance::isothermal_compresibility) .def_readwrite("isobaric_expansivity", &ThermoParametersSubstance::isobaric_expansivity) @@ -53,7 +53,7 @@ void exportThermoParametersSubstance(py::module& m) void exportThermoParametersReaction(py::module& m) { - py::class_(m, "ThermoParametersReaction") + py::class_(m, "ThermoParametersReaction", "Parameters of a reaction record") .def(py::init<>()) .def_readwrite("temperature_intervals", &ThermoParametersReaction::temperature_intervals) .def_readwrite("pressure_intervals", &ThermoParametersReaction::pressure_intervals) diff --git a/python/pyThermoFun/pyThermoProperties.cpp b/python/pyThermoFun/pyThermoProperties.cpp index 0db0206..52de81d 100644 --- a/python/pyThermoFun/pyThermoProperties.cpp +++ b/python/pyThermoFun/pyThermoProperties.cpp @@ -31,7 +31,7 @@ namespace ThermoFun { void exportThermoPropertiesSubstance(py::module& m) { - py::class_(m, "ThermoPropertiesSubstance") + py::class_(m, "ThermoPropertiesSubstance", "Standard molar properties of a substance") .def(py::init<>()) .def_readwrite("gibbs_energy", &ThermoPropertiesSubstance::gibbs_energy) .def_readwrite("helmholtz_energy", &ThermoPropertiesSubstance::helmholtz_energy) @@ -46,7 +46,7 @@ void exportThermoPropertiesSubstance(py::module& m) void exportThermoPropertiesReaction(py::module& m) { - py::class_(m, "ThermoPropertiesReaction") + py::class_(m, "ThermoPropertiesReaction", "Standard molar properties of a reaction") .def(py::init<>()) .def_readwrite("ln_equilibrium_constant", &ThermoPropertiesReaction::ln_equilibrium_constant) .def_readwrite("log_equilibrium_constant", &ThermoPropertiesReaction::log_equilibrium_constant) @@ -63,7 +63,7 @@ void exportThermoPropertiesReaction(py::module& m) void exportElectroPropertiesSolvent(py::module& m) { - py::class_(m, "ElectroPropertiesSolvent") + py::class_(m, "ElectroPropertiesSolvent", "Dielectric constant, its derivatives with T and P, and Born functions") .def(py::init<>()) .def_readwrite("epsilon", &ElectroPropertiesSolvent::epsilon) .def_readwrite("epsilonT", &ElectroPropertiesSolvent::epsilonT) @@ -82,7 +82,7 @@ void exportElectroPropertiesSolvent(py::module& m) void exportPropertiesSolvent(py::module& m) { - py::class_(m, "PropertiesSolvent") + py::class_(m, "PropertiesSolvent", "Physical properties of water solvent") .def(py::init<>()) .def_readwrite("speed_of_sound", &PropertiesSolvent::speed_of_sound) .def_readwrite("dynamic_viscosity", &PropertiesSolvent::dynamic_viscosity)