Giter VIP home page Giter VIP logo

thermohub / thermofun Goto Github PK

View Code? Open in Web Editor NEW
22.0 5.0 9.0 19.55 MB

A code for calculating the standard state thermodynamic properties at a given temperature and pressure.

Home Page: https://thermohub.org/thermofun/thermofun/

License: GNU Lesser General Public License v2.1

CMake 1.27% QMake 1.64% C++ 69.76% Shell 0.56% Python 2.50% Batchfile 0.20% C 0.02% Jupyter Notebook 21.81% TeX 2.23%
chemical-reactions enthalpy entropy equation-of-state geochemical-data geochemical-modeling geochemistry gibbs-energy heat-capacity reaction

thermofun's Introduction

ThermoFun

Linux, OSX, Windows

Build Status

A code for calculating the standard state thermodynamic properties of substances and reactions at a given temperature and pressure.

If you use it in your work please cite the JOSS publication DOI

Try ThermoFun in your browser click launch binder

Binder

Wait until the Jupyter Lab Notebook server starts (~1 min) then double click on any how-to-... tutorial notebook. Binder is a free service and not using the browser tab for more than a few miuntes will turn off the virutal server. To restart the Jupyter Lab Notebook server click again on the launch binder icon above. Refreshing the webpage will not help restarting the server.

More information on Jupyter Notebooks: Jupyter Documentation

Simple C++ API example

  • Using a json database file
#!c++
int main()
{
    // Create the batch object using a database file in JSON
    ThermoFun::ThermoBatch batch("Resources/Databases/aq17-thermofun.json");

    // Optional: set units, default units are in SI
    batch.setPropertiesUnits({"temperature", "pressure"},{"degC","bar"});

    // Optional: change default significant digits
    batch.setPropertiesDigits({"gibbs_energy","entropy", "volume", "enthalpy", "temperature", "pressure"}, {0, 1, 2, 0, 0, 0});

    // Retrieve the entropy of H2O
    double H2Oentropy = batch.thermoPropertiesSubstance( 300, 2000, "H2O@", "entropy").toDouble();

    // Retrieve the derivative of G with respect to T
    double H2OdGdT = batch.thermoPropertiesSubstance( 300, 2000, "H2O", "entropy").toThermoScalar().ddt;

    // Write results to a comma separate files for a list of T-P pairs, substances, and properties
    batch.thermoPropertiesSubstance({{25, 1},{40, 1},{70, 100},{90, 100},{100, 100}}, // list of T-P pairs
                                    {"Al+3", "OH-", "SiO2@"},                         // list of substance symbols
                                    {"gibbs_energy","entropy", "volume", "enthalpy"}  // list of properties
                                   ).toCSV("results.csv");                            // output
    return 0;
}
  • Using the database client and retrieving a ThermoDataSet from the remote database. This example uses the thermohubclient
#!c++
int main()
{
    // Initialize a database client object
    ThermoFun::DatabaseClient dbc;

    // Create a ThermoFun database using the records list
    ThermoFun::Database db(dbc.getDatabase('aq17'));

    // Initialize an batch object using the database
    ThermoFun::ThermoBatch batch (db);

    // Optional set calculation and output preferences
    ThermoFun::OutputSettings op;
    op.isFixed = true;
    op.outputSolventProperties       = true;
    op.reactionPropertiesFromReactants   = false;
    op.substancePropertiesFromReaction   = false;
    batch.setOutputSettings(op);

    // Optional set units and significant digits
    batch.setPropertiesUnits({"temperature", "pressure"},{"degC","bar"});
    batch.setPropertiesDigits({ "reaction_gibbs_energy","reaction_entropy", "reaction_volume",
                                "reaction_enthalpy","logKr", "temperature", "pressure"}, {0, 4, 4, 4, 4, 0, 0});

    batch.thermoPropertiesReaction({{25,1}}, {"AmSO4+", "MgSiO3@"}, {"reaction_gibbs_energy", "reaction_entropy",
                                    "reaction_volume", "reaction_enthalpy", "logKr"}).toCSV("results.csv");

    batch.thermoPropertiesReaction({0,20,50,75},{0,0,0,0},{"AmSO4+", "MgSiO3@"}, {"reaction_gibbs_energy", "reaction_entropy",
                                    "reaction_volume", "reaction_enthalpy", "logKr"}).toCSV("results.csv");
}

Simple Python API example

  • Using a json database file
#!Python
import thermofun as fun
import thermohubclient as hubclient

properties = fun.ThermoPropertiesSubstance

engine = fun.ThermoEngine("Resources/databases/aq17-thermofun.json")

prop = engine.thermoPropertiesSubstance(373.15, 100000000, "H2O@")

print(prop.gibbs_energy.val)
print(prop.gibbs_energy.ddt)
print(prop.entropy.val)
print(prop.gibbs_energy.ddp)
print(prop.gibbs_energy.err)
print(prop.gibbs_energy.sta)

# Create the engine object using a database file in JSON
batch = fun.ThermoBatch("Resources/databases/aq17-thermofun.json")

# Optional: change default units
batch.setPropertiesUnits(["temperature", "pressure"],["degC","bar"])

# Optional: change default significant digits
batch.setPropertiesDigits(["gibbs_energy","entropy", "volume", "enthalpy", "temperature", "pressure"], [0, 1, 2, 0, 0, 0])

H2Oentropy = batch.thermoPropertiesSubstance( 300, 2000, "H2O@", "entropy").toDouble()
print(H2Oentropy)

V = batch.thermoPropertiesSubstance( 250, 1000, "H2O@", "volume").toThermoScalar()

# Write results to a comma separate files for a list of T-P pairs, substances, and properties
batch.thermoPropertiesSubstance( [[25, 1],[40, 1],[70, 100],[90, 100],[100, 100]],  # // list of T-P pairs
                                 ["Al+3", "OH-", "SiO2@"],                          # // list of substance symbols
                                 ["gibbs_energy","entropy", "volume", "enthalpy"]   # // list of properties
                               ).toCSV("results.csv")    
  • Using the database client and retrieving a ThermoDataSet from the remote database. This example uses the thermohubclient, that can be installed from conda-forge executing conda install -c conda-forge thermohubclient
#!Python
import thermofun as fun
import thermohubclient as hubclient

print("\n# Initialize a database client object\n")
dbc = hubclient.DatabaseClient()

print("ThermoDataSets")
for t in dbc.availableThermoDataSets():
    print(f'{t}')
print('\n')

aq17 = fun.Database(dbc.getDatabase('aq17'))

print("\n# Initialize an interface object using the database\n")
batch2 = fun.ThermoBatch(aq17)

print("\n# Optional: set the solvent symbol used for calculating properties of aqueous species\n")
batch2.setSolventSymbol("H2O@")

print("\n# Optional set calculation and output preferences\n")
op = fun.BatchPreferences()
op.isFixed = True
op.outputSolventProperties       = True
op.reactionPropertiesFromReactants   = False
op.substancePropertiesFromReaction   = False
batch2.setBatchPreferences(op)

print("\n# Optional set units and significant digits\n")
batch2.setPropertiesUnits(["temperature", "pressure"],["degC","bar"])

batch2.setPropertiesDigits(["gibbs_energy","entropy", "volume",
                            "enthalpy","logKr", "temperature", "pressure"], [0, 4, 4, 4, 4, 0, 0])

print("\n# Do calculations and write output\n")
batch2.thermoPropertiesSubstance([[25,1]], ["NaCO3-", "Mg+2"], ["gibbs_energy", "entropy",
                                "volume", "enthalpy"]).toCSV("results_dbc.csv")

Installation using Conda

ThermoFun can be easily installed using Conda package manager. If you have Conda installed, first add the conda-forge channel by executing

#!bash
conda config --add channels conda-forge

install ThermoFun by executing the following command:

#!bash
conda install thermofun

Conda can be installed from Miniconda.

Install ThermoFun using CMake

  • Make sure you have g++, cmake and git installed. If not, install them (on Ubuntu Linux):
#!bash
sudo apt-get install g++ cmake git
  • Download ThermoFun source code using git clone

  • In a terminal, at the home directory level e.g. <user>@ubuntu:~$ copy-paste and run the following code:

#!bash
git clone https://github.com/thermohub/thermofun.git && cd thermofun 
  • In the terminal you should be in ~/thermofun$.

(A) Build and install ThermoFun library (working with json database files)

This option allows the user to build thermofun library that works with a user provided thermodynamic database file in json format and has only one thirdpary library dependency. To build thermofun with access to the thermohub thermodynamic database cloud and local server see bellow.

Install Dependencies (if not using Conda environment)

The thermofun library uses nlohmann/json.hpp as thirdparty dependency to parse database files in json format. To install the header only json library in a terminal ~/thermofun$ execute the following:

#!bash
sudo ./install-dependencies.sh

Compiling the C++ library

In the terminal ~/thermofun$, execute the following commands:

#!bash
mkdir build && \
cd build && \
cmake .. && \
make

To take advantage of parallel compilation use make -j3. 3 representing the number of threads.

For a global installation of the compiled libraries in your system, execute:

#!bash
sudo make install 

This will install Thermofun library and header files in the default installation directory of your system (e.g, /usr/local/ or if conda is active, in the instalation directory of the conda environment).

For a local installation, you can specify a directory path for the installed files as follows:

#!bash
cmake .. -DCMAKE_INSTALL_PREFIX=/home/username/local/

then execute:

sudo make install 

To compile ThermoFun library in debug mode:

#!bash
cmake .. -DCMAKE_BUILD_TYPE=Debug

then execute:

sudo make install 

(B) Build and install ThermoFun library (working with access to the local and cloud ThemroHub database)

This option builds thermofun library together with the dbclient, which provides access to the local and cloud thermohub databases, allowing specific a ThermoDataSet to be used or a selection on elements of the thermodynamic data.

Install ThermoHubClient

Clone and install ThermoHubClient library

#!bash
git clone https://bitbucket.org/gems4/thermohubclient.git
cd thermohubclient
sudo ./install-dependencies.sh
mkdir build
cd build
cmake ..
make

For a global installation of the compiled library in your system, execute:

#!bash
sudo make install 

Compile and install ThermoFun using CMake and Conda

This procedure uses Conda for handling all the dependencies of ThermoFun and builds ThermoFun for Windows, Mac OS X, and Linux.

Once you have conda installed execute:

#!bash
conda install -n base conda-devenv

This installs conda-devenv, a conda tool used to define and initialize conda environments.

Download ThermoFun from github

#!bash
git clone https://github.com/thermohub/thermofun.git && cd thermofun 

In the next step we create a clean environment with all dependencies necessary to build ThermoFun, executing:

#!bash
conda devenv 

In the next step we need to activate the thermofun environment

#!bash
conda activate thermofun

Remember to always activate thermofun environment whenever you use ThermoFun from C++ or Python. This is because conda will adjust some environment variables in your system.

Now we can proceed and build ThermoFun using CMake.

Reporting bugs

To report a bug, please go to ThermoFun's Issues and enter a descriptive title and write your issue with enough details. Please provide a minimum reproducible example to be more efficient in identifying the bug and fixing it.

For questions and issues don't hesitate to chat with us on Gitter.

Contributing with development

The Fork & Pull Request Workflow is used. Below is a summary of the necessary steps you need to take:

  1. Fork this repository
  2. Clone the repository at your machine
  3. Add your changes in a branch named after what's being done (lower-case-with-hyphens)
  4. Make a pull request to thermohub/thermofun, targeting the main branch

thermofun's People

Contributors

allanleal avatar apgysi avatar cardinalgeo avatar dimitrikulik avatar gdmiron avatar svetadmitr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

thermofun's Issues

[JOSS] - state of the field

The manuscript submitted to JOSS reads well and nicely summarises the functionality of Thermofun.
However, no reference to other software packages with similar scope is made in the draft. A quick search brought up packages like Thermo and PYroMat - do these or other packages provide similar functionalities as Thermofun?

Memory leak in `thermoPropertiesGasCORK`

In method thermoPropertiesGasCORK, file GasCORK.cpp, memory is allocated using new:

double * CPg = new double[7];

but it is never freed.

This was determined using valgrind, when running it over all Reaktoro's C++ tests. This is what it produced:

==1134== 
==1134== HEAP SUMMARY:
==1134==     in use at exit: 56 bytes in 1 blocks
==1134==   total heap usage: 144,625,352 allocs, 144,625,351 frees, 25,275,031,795 bytes allocated
==1134== 
==1134== 56 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1134==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==1134==    by 0x7C9D4F8: ThermoFun::thermoPropertiesGasCORK(Reaktoro_::Temperature, Reaktoro_::Pressure, ThermoFun::Substance, ThermoFun::ThermoPropertiesSubstance) (in /home/allan/miniconda3/envs/reaktoro/lib/libThermoFun.so)
==1134==    by 0x7D9167F: ThermoFun::GasCORK::thermoProperties(double, double, ThermoFun::ThermoPropertiesSubstance) (in /home/allan/miniconda3/envs/reaktoro/lib/libThermoFun.so)
==1134==    by 0x7D7F541: ThermoFun::ThermoEngine::Impl::thermoPropertiesSubstance(double, double&, ThermoFun::Substance const&) (in /home/allan/miniconda3/envs/reaktoro/lib/libThermoFun.so)
==1134==    by 0x7D7FE20: ThermoFun::ThermoEngine::thermoPropertiesSubstance(double, double&, ThermoFun::Substance const&) const (in /home/allan/miniconda3/envs/reaktoro/lib/libThermoFun.so)
==1134==    by 0x7857830: Reaktoro::ThermoFunEngine::Impl::props(autodiff::detail::Real<1ul, double> const&, autodiff::detail::Real<1ul, double> const&, ThermoFun::Substance const&) const (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/libReaktoro.so)
==1134==    by 0x784EB17: Reaktoro::ThermoFunEngine::props(autodiff::detail::Real<1ul, double> const&, autodiff::detail::Real<1ul, double> const&, ThermoFun::Substance const&) const (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/libReaktoro.so)
==1134==    by 0x7834CF9: Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}::operator()(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>) const (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/libReaktoro.so)
==1134==    by 0x78363FF: Reaktoro::StandardThermoProps std::__invoke_impl<Reaktoro::StandardThermoProps, Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}&, autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double> >(std::__invoke_other, Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}&, autodiff::detail::Real<1ul, double>&&, autodiff::detail::Real<1ul, double>&&) (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/libReaktoro.so)
==1134==    by 0x783629A: std::enable_if<is_invocable_r_v<Reaktoro::StandardThermoProps, Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}&, autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double> >, std::enable_if>::type std::__invoke_r<Reaktoro::StandardThermoProps, Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}&, autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double> >(Reaktoro::StandardThermoProps&&, (Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}&)...) (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/libReaktoro.so)
==1134==    by 0x78360BD: std::_Function_handler<Reaktoro::StandardThermoProps (autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>), Reaktoro::(anonymous namespace)::createStandardThermoModel(Reaktoro::ThermoFunEngine const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)#1}>::_M_invoke(std::_Any_data const&, autodiff::detail::Real<1ul, double>&&, std::_Any_data const&) (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/libReaktoro.so)
==1134==    by 0x7994E4: std::function<Reaktoro::StandardThermoProps (autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>)>::operator()(autodiff::detail::Real<1ul, double>, autodiff::detail::Real<1ul, double>) const (in /home/allan/codes/reaktoro/build/debug/gcc/Reaktoro/reaktoro-cpptests)
==1134== 
==1134== LEAK SUMMARY:
==1134==    definitely lost: 56 bytes in 1 blocks
==1134==    indirectly lost: 0 bytes in 0 blocks
==1134==      possibly lost: 0 bytes in 0 blocks
==1134==    still reachable: 0 bytes in 0 blocks
==1134==         suppressed: 0 bytes in 0 blocks
==1134== 
==1134== For lists of detected and suppressed errors, rerun with: -s
==1134== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

[JOSS] Doc strings for python api

The documentation on thrrmofun.org is good and also has examples. But it would be more accessible if you had doc strings for different methods available. Right now it's hard to tell what methods are available besides those in the example.

[JOSS] Install from source fails

  • For conda install, the command should be conda install -c conda-forge thermofun instead of conda install thermofun in README.

  • Installation from source fails with this message:

>>> ./install-dependencies.sh
Cloning into 'json'...
remote: Enumerating objects: 35355, done.
remote: Counting objects: 100% (1004/1004), done.
remote: Compressing objects: 100% (385/385), done.
remote: Total 35355 (delta 461), reused 874 (delta 375), pack-reused 34351
Receiving objects: 100% (35355/35355), 178.64 MiB | 8.38 MiB/s, done.
Resolving deltas: 100% (21772/21772), done.
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using the multi-header code from /Users/hetagandhi/code/json/include/
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/hetagandhi/code/json/build
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include
-- Installing: /usr/local/include/nlohmann
-- Installing: /usr/local/include/nlohmann/ordered_map.hpp
-- Installing: /usr/local/include/nlohmann/json.hpp
-- Installing: /usr/local/include/nlohmann/adl_serializer.hpp
-- Installing: /usr/local/include/nlohmann/byte_container_with_subtype.hpp
-- Installing: /usr/local/include/nlohmann/detail
-- Installing: /usr/local/include/nlohmann/detail/hash.hpp
-- Installing: /usr/local/include/nlohmann/detail/string_escape.hpp
-- Installing: /usr/local/include/nlohmann/detail/json_custom_base_class.hpp
-- Installing: /usr/local/include/nlohmann/detail/json_ref.hpp
-- Installing: /usr/local/include/nlohmann/detail/conversions
-- Installing: /usr/local/include/nlohmann/detail/conversions/to_chars.hpp
-- Installing: /usr/local/include/nlohmann/detail/conversions/from_json.hpp
-- Installing: /usr/local/include/nlohmann/detail/conversions/to_json.hpp
-- Installing: /usr/local/include/nlohmann/detail/value_t.hpp
-- Installing: /usr/local/include/nlohmann/detail/input
-- Installing: /usr/local/include/nlohmann/detail/input/position_t.hpp
-- Installing: /usr/local/include/nlohmann/detail/input/parser.hpp
-- Installing: /usr/local/include/nlohmann/detail/input/json_sax.hpp
-- Installing: /usr/local/include/nlohmann/detail/input/binary_reader.hpp
-- Installing: /usr/local/include/nlohmann/detail/input/input_adapters.hpp
-- Installing: /usr/local/include/nlohmann/detail/input/lexer.hpp
-- Installing: /usr/local/include/nlohmann/detail/string_concat.hpp
-- Installing: /usr/local/include/nlohmann/detail/macro_scope.hpp
-- Installing: /usr/local/include/nlohmann/detail/output
-- Installing: /usr/local/include/nlohmann/detail/output/output_adapters.hpp
-- Installing: /usr/local/include/nlohmann/detail/output/serializer.hpp
-- Installing: /usr/local/include/nlohmann/detail/output/binary_writer.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta
-- Installing: /usr/local/include/nlohmann/detail/meta/is_sax.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/call_std
-- Installing: /usr/local/include/nlohmann/detail/meta/call_std/end.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/call_std/begin.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/identity_tag.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/type_traits.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/cpp_future.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/detected.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/void_t.hpp
-- Installing: /usr/local/include/nlohmann/detail/meta/std_fs.hpp
-- Installing: /usr/local/include/nlohmann/detail/json_pointer.hpp
-- Installing: /usr/local/include/nlohmann/detail/exceptions.hpp
-- Installing: /usr/local/include/nlohmann/detail/abi_macros.hpp
-- Installing: /usr/local/include/nlohmann/detail/macro_unscope.hpp
-- Installing: /usr/local/include/nlohmann/detail/iterators
-- Installing: /usr/local/include/nlohmann/detail/iterators/iter_impl.hpp
-- Installing: /usr/local/include/nlohmann/detail/iterators/json_reverse_iterator.hpp
-- Installing: /usr/local/include/nlohmann/detail/iterators/iteration_proxy.hpp
-- Installing: /usr/local/include/nlohmann/detail/iterators/iterator_traits.hpp
-- Installing: /usr/local/include/nlohmann/detail/iterators/internal_iterator.hpp
-- Installing: /usr/local/include/nlohmann/detail/iterators/primitive_iterator.hpp
-- Installing: /usr/local/include/nlohmann/thirdparty
-- Installing: /usr/local/include/nlohmann/thirdparty/hedley
-- Installing: /usr/local/include/nlohmann/thirdparty/hedley/hedley.hpp
-- Installing: /usr/local/include/nlohmann/thirdparty/hedley/hedley_undef.hpp
-- Installing: /usr/local/include/nlohmann/json_fwd.hpp
-- Installing: /usr/local/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake
-- Installing: /usr/local/share/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake
-- Installing: /usr/local/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake
-- Installing: /usr/local/share/pkgconfig/nlohmann_json.pc
./install-dependencies.sh: line 41: wget: command not found
tar: Error opening archive: Failed to open 'default.tar.bz2'
CMake Warning:
  Ignoring extra path from command line:

   ".."


CMake Error: The source directory "/Users/hetagandhi/code/eigen-code" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
Cloning into 'pybind11'...
remote: Enumerating objects: 24615, done.
remote: Counting objects: 100% (170/170), done.
remote: Compressing objects: 100% (101/101), done.
remote: Total 24615 (delta 78), reused 126 (delta 59), pack-reused 24445
Receiving objects: 100% (24615/24615), 9.21 MiB | 6.78 MiB/s, done.
Resolving deltas: 100% (17232/17232), done.
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- pybind11 v2.11.0 dev1
-- CMake 3.24.1
-- Found PythonInterp: /Users/hetagandhi/opt/anaconda3/envs/thermofun/bin/python (found suitable version "3.7.13", minimum required is "3.6") 
-- Found PythonLibs: /Users/hetagandhi/opt/anaconda3/envs/thermofun/lib/libpython3.7m.dylib
-- PYTHON 3.7.13
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- pybind11::lto enabled
-- Performing Test HAS_FLTO_THIN
-- Performing Test HAS_FLTO_THIN - Success
-- pybind11::thin_lto enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/hetagandhi/code/pybind11/build
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/pybind11
-- Installing: /usr/local/include/pybind11/attr.h
-- Installing: /usr/local/include/pybind11/embed.h
-- Installing: /usr/local/include/pybind11/numpy.h
-- Installing: /usr/local/include/pybind11/pybind11.h
-- Installing: /usr/local/include/pybind11/operators.h
-- Installing: /usr/local/include/pybind11/iostream.h
-- Installing: /usr/local/include/pybind11/gil.h
-- Installing: /usr/local/include/pybind11/chrono.h
-- Installing: /usr/local/include/pybind11/stl_bind.h
-- Installing: /usr/local/include/pybind11/buffer_info.h
-- Installing: /usr/local/include/pybind11/options.h
-- Installing: /usr/local/include/pybind11/stl
-- Installing: /usr/local/include/pybind11/stl/filesystem.h
-- Installing: /usr/local/include/pybind11/functional.h
-- Installing: /usr/local/include/pybind11/stl.h
-- Installing: /usr/local/include/pybind11/detail
-- Installing: /usr/local/include/pybind11/detail/type_caster_base.h
-- Installing: /usr/local/include/pybind11/detail/typeid.h
-- Installing: /usr/local/include/pybind11/detail/descr.h
-- Installing: /usr/local/include/pybind11/detail/internals.h
-- Installing: /usr/local/include/pybind11/detail/common.h
-- Installing: /usr/local/include/pybind11/detail/class.h
-- Installing: /usr/local/include/pybind11/detail/init.h
-- Installing: /usr/local/include/pybind11/common.h
-- Installing: /usr/local/include/pybind11/eval.h
-- Installing: /usr/local/include/pybind11/cast.h
-- Installing: /usr/local/include/pybind11/eigen.h
-- Installing: /usr/local/include/pybind11/pytypes.h
-- Installing: /usr/local/include/pybind11/complex.h
-- Installing: /usr/local/share/cmake/pybind11/pybind11Config.cmake
-- Installing: /usr/local/share/cmake/pybind11/pybind11ConfigVersion.cmake
-- Installing: /usr/local/share/cmake/pybind11/FindPythonLibsNew.cmake
-- Installing: /usr/local/share/cmake/pybind11/pybind11Common.cmake
-- Installing: /usr/local/share/cmake/pybind11/pybind11Tools.cmake
-- Installing: /usr/local/share/cmake/pybind11/pybind11NewTools.cmake
-- Installing: /usr/local/share/cmake/pybind11/pybind11Targets.cmake
-- Installing: /usr/local/share/pkgconfig/pybind11.pc
Cloning into 'chemicalfun'...
remote: Enumerating objects: 1172, done.
remote: Counting objects: 100% (1172/1172), done.
remote: Compressing objects: 100% (946/946), done.
remote: Total 1172 (delta 639), reused 406 (delta 169), pack-reused 0
Receiving objects: 100% (1172/1172), 1.13 MiB | 3.49 MiB/s, done.
Resolving deltas: 100% (639/639), done.
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CondaAware: conda environment recognized!
-- CondaAware: CONDA_PREFIX=/Users/hetagandhi/opt/anaconda3/envs/thermofun
-- CondaAware: CONDA_AWARE_PREFIX=CONDA_PREFIX (/Users/hetagandhi/opt/anaconda3/envs/thermofun)
-- CondaAware: CMAKE_INSTALL_PREFIX set to CONDA_AWARE_PREFIX
-- CondaAware: appended CONDA_AWARE_PREFIX to CMAKE_PREFIX_PATH
-- CondaAware: appended CONDA_AWARE_PREFIX/include to include directories
-- CondaAware: appended CONDA_AWARE_PREFIX/lib to link directories
-- Found PythonInterp: /Users/hetagandhi/opt/anaconda3/envs/thermofun/bin/python (found suitable version "3.7.13", minimum required is "3.6") 
-- Found PythonLibs: /Users/hetagandhi/opt/anaconda3/envs/thermofun/lib/libpython3.7m.dylib
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Performing Test HAS_FLTO_THIN
-- Performing Test HAS_FLTO_THIN - Success
-- Found pybind11: /usr/local/include (found version "2.11.0dev1")
-- Found pybind11 v2.11.0: /usr/local/include;/Users/hetagandhi/opt/anaconda3/envs/thermofun/include/python3.7m
-- Found pybind11 v2.11.0: /usr/local/include;/Users/hetagandhi/opt/anaconda3/envs/thermofun/include/python3.7m
CMake Error at cmake/modules/ChemicalFunFindDeps.cmake:14 (find_package):
  By not providing "Findspdlog.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "spdlog", but
  CMake did not find one.

  Could not find a package configuration file provided by "spdlog" with any
  of the following names:

    spdlogConfig.cmake
    spdlog-config.cmake

  Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set
  "spdlog_DIR" to a directory containing one of the above files.  If "spdlog"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:115 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/hetagandhi/code/chemicalfun/build/CMakeFiles/CMakeOutput.log".
See also "/Users/hetagandhi/code/chemicalfun/build/CMakeFiles/CMakeError.log".
expr: syntax error

Database file not found

Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import thermofun.PyThermoFun as PyThermoFun
engine = PyThermoFun.ThermoEngine("Resources/aq17new-format.json")
Traceback (most recent call last):
File "", line 1, in
RuntimeError:


*** Error: File reading error
*** Reason: Database file Resources/aq17new-format.json not found!
*** Location: ...me/eddya7med/thermofun/ThermoFun/Database.cpp:246


Using autodiff::real instead of ThermoScalar

Let's use autodiff::real in ThermoFun (to enable automatic differentiation) instead of Reaktoro::ThermoScalar. This change will enable computation of derivatives with respect to virtually anything, and not just with respect to temperature and pressure (a limitation of ThermoScalar). For example, we'll be able to compute the derivative of a computed standard thermodynamic property (e.g., G0) with respect to model parameters (e.g., HKF coefficients).

This will also bring ThermoFun in sync with v2.0 of Reaktoro, which uses autodiff::real.

I'll be happy to help with the transition.

Missing find_package for json dependency

Hi,

I'm building Thermofun 0.3.8 from sources on windows (as part of building reaktoro).
The build is failing as the source files reference nlohmann/json.hpp which they can't find.

In ThermoFun\CmakeLists.txt around line 40 there is some conditional code and on windows with visual studio nothing is done while on linux there is a dependency explicitly defined.

I added this to the MSVC section and that worked:

   find_package(nlohmann_json REQUIRED)
		 target_link_libraries(ThermoFun
         PRIVATE nlohmann_json::nlohmann_json)

Successful ChemicalFun build ARM64 Android Termux

I have successfully build & installed chemicalfun git version but there is a weird issue

cmake .. -DPYTHON_EXECUTABLE=/data/data/com.termux/files/usr/bin/python3.9 -DCMAKE_INSTALL_PREFIX=/data/data/com.termux/files/usr

The final output

Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /data/data/com.termux/files/usr/lib/cmake/ChemicalFun/ChemicalFunTargets.cmake
-- Installing: /data/data/com.termux/files/usr/lib/cmake/ChemicalFun/ChemicalFunTargets-relwithdebinfo.cmake
-- Installing: /data/data/com.termux/files/usr/lib/cmake/ChemicalFun/ChemicalFunConfig.cmake
-- Installing: /data/data/com.termux/files/usr/lib/cmake/ChemicalFun/ChemicalFunConfigVersion.cmake
-- Installing: /data/data/com.termux/files/usr/lib/[libChemicalFun.so](http://libchemicalfun.so/)
-- Set runtime path of "/data/data/com.termux/files/usr/lib/[libChemicalFun.so](http://libchemicalfun.so/)" to ""
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/FormulaParser.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/FormulaParser
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/FormulaParser/ChemicalData.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/FormulaParser/ChemicalFormulaParser.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/FormulaParser/MoietyParser.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator/ChemicalReactions.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator/Combiner.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator/Generator.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator/MatrixUtils.h
-- Installing: /data/data/com.termux/files/usr/include/ChemicalFun/ReactionsGenerator/Reaction.h
running install
running build
running build_py
running install_lib
creating /data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun
copying build/lib/chemicalfun/__init__.py -> /data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun
copying build/lib/chemicalfun/[PyChemicalFun.cpython-39.so](http://pychemicalfun.cpython-39.so/) -> /data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun
byte-compiling /data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun/__init__.py to __init__.cpython-39.pyc
running install_egg_info
Writing /data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun-0.1.4-py3.9.egg-info

Running under python throws error, but shows installed

~ $ pip list | grep chemical
chemicalfun          0.1.4
~ $ python -c "import chemicalfun; print(chemicalfun.__version__)"                                 Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun/__init__.py", line 1, in <module>
    from chemicalfun.PyChemicalFun import *
ImportError: dlopen failed: cannot locate symbol "_Py_FalseStruct" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/chemicalfun/PyChemicalFun.cpython-39.so"...

[JOSS] - contributing guidelines

Thanks for providing indications on how to get support (via gitter) - however I could not find guidelines on how to file issues and submit contributions - maybe you could add a CONTRIBUTING file to the repository (e.g. see here) and link it within the README file?

[JOSS] - Python snippet in README

When running the second Python snippet from the README file, I get the following error:
AttributeError: module 'thermohubclient' has no attribute 'setDatabaseConnectionFilePath'.

If I comment out the first line, I still get the following:
AttributeError: 'thermohubclient.PyThermoHubClient.DatabaseClient' object has no attribute 'recordsFromThermoDataSet'.

Minor point: it would also be nice to inform that thermohubclient needs to be installed as a separate dependency to run these examples.

[JOSS] Tests failing

Two tests in test_thermoengine.py are failing. You can see the log from running pytest pytests/ here

Fails to install into a stage dir

This line needs --root=${TFUN_STAGING_PREFIX} before --prefix=....

TFUN_STAGING_PREFIX should be settable by users and should otherwise default to empty string.

And the same should be done in chemicalfun.

2 tests fail on FreeBSD

==================================================================================== test session starts =====================================================================================
platform freebsd13 -- Python 3.9.13, pytest-7.1.2, pluggy-1.0.0 -- /usr/local/bin/python3.9
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/disk-samsung/freebsd-ports/science/thermofun/work/thermofun-0.4.0/.hypothesis/examples')
rootdir: /disk-samsung/freebsd-ports/science/thermofun/work/thermofun-0.4.0, configfile: pytest.ini, testpaths: ThermoFun, pytests
plugins: forked-1.4.0, rerunfailures-10.1, hypothesis-6.50.1, xdist-2.5.0, cov-2.9.0, typeguard-2.13.3, subtests-0.8.0
collected 19 items                                                                                                                                                                           

pytests/test_database.py::TestDatabase::test_add_json_reaction_substance PASSED                                                                                                        [  5%]
pytests/test_database.py::TestDatabase::test_append_data PASSED                                                                                                                        [ 10%]
pytests/test_database.py::TestDatabase::test_append_element PASSED                                                                                                                     [ 15%]
pytests/test_database.py::TestDatabase::test_formula_parser PASSED                                                                                                                     [ 21%]
pytests/test_database.py::TestDatabase::test_parsing_database PASSED                                                                                                                   [ 26%]
pytests/test_database.py::TestDatabase::test_parsing_reaction PASSED                                                                                                                   [ 31%]
pytests/test_database.py::TestDatabase::test_parsing_substance PASSED                                                                                                                  [ 36%]
pytests/test_thermoengine.py::TestThermoEngine::test_properties_reaction FAILED                                                                                                        [ 42%]
pytests/test_thermoengine.py::TestThermoEngine::test_properties_reaction_from_equation FAILED                                                                                          [ 47%]
pytests/test_thermoengine.py::TestThermoEngine::test_properties_substance PASSED                                                                                                       [ 52%]
pytests/test_thermoengine.py::TestThermoEngine::test_properties_substance_from_reaction PASSED                                                                                         [ 57%]
pytests/Reactions/test_logKfT.py::TestThermoEngine::test_properties_logKfT_reaction PASSED                                                                                             [ 63%]
pytests/Reactions/test_rbm.py::TestThermoEngine::test_properties_Ryzhenko_Bryzgalin_reaction PASSED                                                                                    [ 68%]
pytests/Substances/Gases/test_gas_PRSV.py::TestCpfT::test_properties_substance PASSED                                                                                                  [ 73%]
pytests/Substances/Solids/test_CpfT_phase_transition.py::TestCpfT::test_properties_substance PASSED                                                                                    [ 78%]
pytests/Substances/Solute/test_hkf_gems.py::TestHKFGems::test_3kbar_al_ion PASSED                                                                                                      [ 84%]
pytests/Substances/Solute/test_hkf_gems.py::TestHKFGems::test_3kbar_sio2 PASSED                                                                                                        [ 89%]
pytests/Substances/Solute/test_hkf_gems.py::TestHKFGems::test_psat_al_ion PASSED                                                                                                       [ 94%]
pytests/Substances/Solute/test_hkf_gems.py::TestHKFGems::test_psat_sio2 PASSED                                                                                                         [100%]

========================================================================================== FAILURES ==========================================================================================
_________________________________________________________________________ TestThermoEngine.test_properties_reaction __________________________________________________________________________

self = <test_thermoengine.TestThermoEngine testMethod=test_properties_reaction>

    def test_properties_reaction(self):
        assert self.engine2.thermoPropertiesReaction(298.15, 1e5, "Meionite-Ca").log_equilibrium_constant.val == pytest.approx(80.873916, 1e-5, 1e-14)
>       assert self.engine2.thermoPropertiesReaction(423.15, 0, "Meionite-Ca").log_equilibrium_constant.val == pytest.approx(28.243799, 1e-5, 1e-14)
E       assert 28.2299676214565 == 28.243799 ± 2.8e-04
E         comparison failed
E         Obtained: 28.2299676214565
E         Expected: 28.243799 ± 2.8e-04

pytests/test_thermoengine.py:32: AssertionError
__________________________________________________________________ TestThermoEngine.test_properties_reaction_from_equation ___________________________________________________________________

self = <test_thermoengine.TestThermoEngine testMethod=test_properties_reaction_from_equation>

    def test_properties_reaction_from_equation(self):
        assert self.engine.thermoPropertiesReaction(298.15, 1e5, "Cal = Ca+2 + CO3-2").log_equilibrium_constant.val == pytest.approx(-8.48014, 1e-5, 1e-14)
        assert self.engine.thermoPropertiesReaction(298.15, 1e5, "Al+3 + 4 H2O@ + 0Ca+2= 1Al(OH)4- + 4 \n H+").log_equilibrium_constant.val == pytest.approx(-22.3085, 1e-5, 1e-14)
>       assert self.engine.thermoPropertiesReaction(423.15, 0, "Cal = Ca+2 + CO3-2").log_equilibrium_constant.val == pytest.approx(-10.10169, 1e-5, 1e-14)
E       assert -10.10141561200007 == -10.10169 ± 1.0e-04
E         comparison failed
E         Obtained: -10.10141561200007
E         Expected: -10.10169 ± 1.0e-04

pytests/test_thermoengine.py:25: AssertionError
================================================================================ 2 failed, 17 passed in 2.69s ================================================================================
*** Error code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.