Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database records can be changed by reference (C++, Python) #70

Merged
merged 279 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
279 commits
Select commit Hold shift + click to select a range
0005c76
fix test script execution
gdmiron Nov 25, 2019
473609c
fix test script execution
gdmiron Nov 25, 2019
f47d5ec
tests only excuted in linux ci
gdmiron Nov 25, 2019
6c76a65
Merge branch 'master' into development
gdmiron Nov 25, 2019
2667fc3
Merged in development (pull request #25)
gdmiron Nov 25, 2019
b8365a4
Merge branch 'master' into development
gdmiron Nov 25, 2019
381b69b
Merge branch 'master' of github.com:gdmiron/thermofun
gdmiron Nov 25, 2019
184cee1
Merge branch 'master' into development
gdmiron Nov 25, 2019
2dd39d5
Update test.sh
gdmiron Nov 25, 2019
8c647c3
Update install.sh
gdmiron Nov 25, 2019
8d51e8f
Update test.sh
gdmiron Nov 25, 2019
0eda2ec
1e-13 accepted differences for tests
gdmiron Nov 25, 2019
4078893
Merge branch 'master' of github.com:gdmiron/thermofun into development
gdmiron Nov 26, 2019
cde4b6d
Introduced function appendData to existing database.
gdmiron Dec 5, 2019
a78fa68
Merged in development (pull request #26)
gdmiron Dec 5, 2019
43a69fc
Merged in development (pull request #27)
gdmiron Dec 6, 2019
abb8292
fix for json parse crash in release mode, yet unknown reason
gdmiron Dec 6, 2019
6a4eed8
temporarily disabled tests in travis ci
gdmiron Dec 6, 2019
141eb84
Merged in development (pull request #28)
gdmiron Dec 6, 2019
9aa8f17
changed binder link to jupyter lab, fixes to readme
gdmiron Dec 6, 2019
872795e
Merged in development (pull request #29)
gdmiron Dec 6, 2019
13f64a3
Update README.md
gdmiron Dec 6, 2019
b029706
Update README.md
gdmiron Dec 6, 2019
f5ad769
using pytest approx function with abs and rel tolerances. Re-activate…
gdmiron Dec 8, 2019
e6fd905
changes to accomodate new database structure containing lists of 'sub…
gdmiron Dec 9, 2019
93a4811
Merge branch 'dev-database' into pytests
gdmiron Dec 9, 2019
2f1ceb2
added test for database parsing
gdmiron Dec 9, 2019
8376b86
test for appending data to database
gdmiron Dec 10, 2019
1476430
Merged in dev-database (pull request #30)
gdmiron Dec 10, 2019
91a24e2
Merged in pytests (pull request #31)
gdmiron Dec 10, 2019
a7a52ea
fixed merge conflicts
gdmiron Dec 10, 2019
feee298
removed check if record exists from set functions
gdmiron Dec 10, 2019
3c7628a
removed duplicate database file
gdmiron Dec 10, 2019
17392d3
Merged in github (pull request #33)
gdmiron Dec 10, 2019
f809fb5
removed version pinning for pybind11 and nlohmann_json
gdmiron Dec 11, 2019
e2103a4
Merge branch 'master' into github
gdmiron Dec 11, 2019
7b9cbff
Merged in github (pull request #34)
gdmiron Dec 11, 2019
1266832
Merged in github (pull request #35)
gdmiron Dec 11, 2019
01ccc5d
converted databases to new structure
gdmiron Dec 11, 2019
4cca715
Merge branch 'master' of github.com:gdmiron/thermofun into github
gdmiron Dec 11, 2019
3649958
fix overloaded functions
gdmiron Dec 11, 2019
e4ed92c
Merge branch 'master' of github.com:gdmiron/thermofun into github
gdmiron Dec 11, 2019
e1f9009
temporarily disabling python bindings
gdmiron Dec 11, 2019
3585521
re-activated python bindings
gdmiron Dec 11, 2019
6f69137
removed overloaded appendData
gdmiron Dec 11, 2019
7ffe014
added back overloaded appendData
gdmiron Dec 11, 2019
aa104e6
set reaction using reaction equation, calculate properties given a re…
gdmiron Dec 11, 2019
eb9cb70
Merge branch 'master' of github.com:thermomod/thermofun into dev-reac…
gdmiron Dec 11, 2019
ba471bc
Merge branch 'master' of github.com:gdmiron/thermofun into dev-reactions
gdmiron Dec 11, 2019
22c7dcc
fix for correct removal of space, tab, newline in reaction parser
gdmiron Dec 12, 2019
fe08b4d
Merged in dev-reactions (pull request #36)
gdmiron Dec 12, 2019
1fc692a
Database object can now be constructed using a file or a string conta…
gdmiron Dec 18, 2019
47b19d1
fixed division by zero problem in the propagation of derivatives
gdmiron Dec 20, 2019
01946b5
fix calculation of derivatives in Cp f(T) method at reference T-P
gdmiron Dec 20, 2019
ca50af9
example properties reaction
gdmiron Feb 6, 2020
f4c1163
bugfix entropy of reaction
gdmiron Feb 17, 2020
360cd59
Merged in development (pull request #37)
gdmiron Feb 17, 2020
1d2710f
fixed conflicts
gdmiron Feb 17, 2020
789eebd
std T and P default values, bugfix
gdmiron Mar 10, 2020
15d462e
extended with derived units for powers of K^ and bar^
gdmiron Mar 11, 2020
3ef288a
converting read units to default upon parsing of data, added ThermoPa…
gdmiron Mar 11, 2020
677e8b2
added test for cp of reaction at high T and P
gdmiron Mar 11, 2020
d8b1e9a
fix for units conversion, extended tests with landau, BM, AD models
gdmiron Mar 12, 2020
a2a3b4b
fix for HKF units
gdmiron Mar 27, 2020
6a1923a
extended aggregateState options compatible with Cox, J. D. (1982)
gdmiron Mar 29, 2020
4833b70
Overloaded thermoProperties functions
gdmiron Mar 30, 2020
0ace5fd
tests for reactions, now calculate proeprties functions can be called…
gdmiron Mar 30, 2020
16abb1d
Merged in bugfix (pull request #39)
gdmiron Mar 31, 2020
8784a12
Merge branch 'master' into development
gdmiron Mar 31, 2020
e1f8c91
Merged in bugfix (pull request #40)
gdmiron Apr 7, 2020
2e492d0
Merge branch 'master' into origin-bucket
gdmiron Apr 7, 2020
cedfe1d
fixed merge conflicts
gdmiron Apr 7, 2020
2bb61e8
version 0.3.2
gdmiron Apr 7, 2020
72c0c3f
Merged in origin-hub (pull request #41)
gdmiron Apr 7, 2020
5d2a789
Merge branch 'master' into origin-bucket
gdmiron Apr 7, 2020
8fdfb48
removed schemas folder, used only by ThermoFunGui
gdmiron Apr 8, 2020
034dda1
changed enum indexes
gdmiron Apr 8, 2020
e7e1bb6
sync with master, bumped to 0.3.3
gdmiron Apr 8, 2020
3f70b49
kept thermo_ref_prop() for reaction properties as is used in ThermoMatch
gdmiron Apr 9, 2020
45134c0
Merged in development (pull request #38)
gdmiron Apr 9, 2020
d7d2d26
fixed conflict
gdmiron Apr 9, 2020
efe1b9b
fixed conflicts
gdmiron Apr 9, 2020
7e548c5
Merged in origin-hub (pull request #42)
gdmiron Apr 9, 2020
240a4b7
Merge remote-tracking branch 'gdmiron-hub/origin-bucket' into origin-hub
gdmiron Apr 9, 2020
acc76a2
Merged in origin-hub (pull request #43)
gdmiron Apr 9, 2020
3993d80
Merge branch 'master' into origin-bucket
gdmiron Apr 9, 2020
6c53a0f
Merge branch 'origin-hub' into origin-bucket
gdmiron Apr 9, 2020
a37a002
removed tests on macos
gdmiron Apr 9, 2020
f0ddd17
Update README.md
gdmiron Apr 9, 2020
9bf5b53
Merge branch 'origin-hub' into calc_const_reference_props
gdmiron May 3, 2020
834137a
added option for constant properties
gdmiron Jun 3, 2020
c2d8245
install.bat edited online with Bitbucket
gdmiron Jun 3, 2020
5c137e5
install.bat edited online with Bitbucket
gdmiron Jun 3, 2020
5bea848
Merged in calc_const_reference_props (pull request #44)
gdmiron Jun 4, 2020
0a9090b
changes for wasm build
gdmiron Aug 3, 2020
33e69d3
json Dump function results in cheerp clang crash
gdmiron Aug 3, 2020
6070e1d
uncommented json dump
gdmiron Aug 3, 2020
d502a3b
build static lib
gdmiron Sep 3, 2020
1e97fd0
build static lib
gdmiron Sep 3, 2020
806350a
fixed reaction volume unit in RB model
gdmiron Nov 17, 2020
9b2fa33
fix to allow appending elements to the database
gdmiron Nov 30, 2020
9508b9d
added automatic tests for RB model, thermofun v0.3.5
gdmiron Nov 30, 2020
188d1e1
test for appending elements
gdmiron Nov 30, 2020
aafc509
Merged in RB-fix (pull request #45)
gdmiron Nov 30, 2020
9ec23a3
Merge branch 'master' into origin-bucket
gdmiron Nov 30, 2020
5b32d43
fixed merge conflicts
gdmiron Nov 30, 2020
e34699b
removed old functions
gdmiron Nov 30, 2020
8c30a84
Merged in origin-hub (pull request #46)
gdmiron Nov 30, 2020
2f60e25
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Jan 6, 2021
0b7919b
Merged master into origin-hub
gdmiron Jan 6, 2021
86fe73f
fix for Cp=f(T) phase transition, problems with the derivatives
gdmiron Jan 6, 2021
5452e32
Merged in origin-hub (pull request #47)
gdmiron Jan 6, 2021
76fd2ea
added default valences anf fixed formula parser bug
gdmiron Jan 6, 2021
eb4ec07
tests for formula parser and CpfT with phase transition
gdmiron Jan 6, 2021
f582925
Merged in fix-formula-parser (pull request #48)
gdmiron Jan 6, 2021
e0ee1f6
fixed unit of Pc to bar, added test for PRSV gas
gdmiron Mar 6, 2021
c78454d
Merged in fix_unit (pull request #49)
gdmiron Mar 6, 2021
5d9d1dd
fixed conflicts
gdmiron Mar 6, 2021
85cf2b5
Merged in origin-hub (pull request #50)
gdmiron Mar 6, 2021
9306a0f
v0.3.7
gdmiron Mar 6, 2021
ff3ad80
Aded path to c:/usr/local
sdmytrievs Mar 29, 2021
5b8eeda
ThermoEngine.cpp edited online with Bitbucket
gdmiron Jun 9, 2021
a14e521
ThermoEngine.cpp edited online with Bitbucket
gdmiron Jun 9, 2021
90f59ac
extended error output
gdmiron Jun 10, 2021
8f43435
EmpiricalCpIntegration.cpp edited online with Bitbucket
gdmiron Jun 10, 2021
b92d519
Merged in jsonio17-move (pull request #51)
gdmiron Jun 10, 2021
897c013
Merge branch 'master' of bitbucket.org:gems4/thermofun
gdmiron Jun 24, 2021
4979339
Merged in merge-fix (pull request #52)
gdmiron Jun 25, 2021
38dd3d5
add records as json strings, literals, functions to list available TP…
gdmiron Jun 25, 2021
2d21030
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Jun 25, 2021
d6db893
Merge branch 'master' into origin-hub
gdmiron Jun 25, 2021
3d1a482
Merged in origin-hub (pull request #53)
gdmiron Jun 25, 2021
447a9b2
Merge branch 'master' into enhancements
Jun 26, 2021
75ebd03
functions to list available properties to calculate
gdmiron Jun 26, 2021
a9b6599
functions to list available properties to calculate
gdmiron Jun 26, 2021
051cecd
reaction with equation gets split in reactants
gdmiron Jun 26, 2021
f6257c6
test for calc reacdc props
gdmiron Jun 26, 2021
62431a4
Merged in enhancements (pull request #54)
gdmiron Jun 27, 2021
4762e12
Moved implementation to ChemicalFun
sdmytrievs Oct 1, 2021
a71a3c9
Changed API FormulaToken
sdmytrievs Oct 5, 2021
a5bd5b1
Remove link to ninternal DBElements data
sdmytrievs Oct 8, 2021
40bb111
fix logK coeff calculation
gdmiron Oct 18, 2021
05a5b1d
Merge branch 'fix_logK' into chemicalfun
gdmiron Oct 18, 2021
4cbaf12
fix test
gdmiron Oct 18, 2021
d4937c3
Use new config
sdmytrievs Oct 25, 2021
03b2735
Fixed after rename functions
sdmytrievs Jan 4, 2022
b224f22
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Jan 12, 2022
97e9d5b
Merge branch 'master' into origin-hub
gdmiron Jan 12, 2022
492e26b
Merge branch 'origin-hub' into chemicalfun
gdmiron Jan 12, 2022
bc2e3d7
chemicalfun to environment file
gdmiron Jan 12, 2022
6500bca
fix link to chemicalfun
gdmiron Jan 12, 2022
d2329ad
fix forward declaration
gdmiron Jan 12, 2022
35a654c
fix for MSVC build
gdmiron Jan 12, 2022
1473ef4
disabled build on mingw, issue with linking to chemicalfun which is c…
gdmiron Jan 12, 2022
e3e8d6d
Merged in chemicalfun (pull request #55)
sdmytrievs Jan 12, 2022
cf8dd56
v0.3.9
gdmiron Jan 13, 2022
73ff40a
Merge branch 'master' into origin-hub
gdmiron Jan 13, 2022
a9ab781
Merged in origin-hub (pull request #56)
gdmiron Jan 13, 2022
d8b6bd7
Changed install-dependencies.sh to use ChimicalFun
sdmytrievs Feb 11, 2022
0c5867c
Fixed install-dependencies.sh to use ChimicalFun
sdmytrievs Feb 11, 2022
903bf7b
Merged in change-install-dependencies (pull request #57)
sdmytrievs Feb 15, 2022
8426f2a
GEMS-203: Replace cout output with logging (spdlog) into ThermoFun
sdmytrievs May 27, 2022
9a0c547
Changed CI appveyor to C:\Miniconda3-x64
sdmytrievs Jun 22, 2022
f285bda
Try fix build CI
sdmytrievs Jun 27, 2022
154663a
Try fix build CI
sdmytrievs Jun 27, 2022
36e30c9
Try fix build CI
sdmytrievs Jun 27, 2022
ba73b20
installVS.bat edited online with Bitbucket
gdmiron Jun 28, 2022
4a0f493
removed namespace std
gdmiron Jun 30, 2022
fc6c128
trying to fix CI for win
gdmiron Jun 30, 2022
cea0f77
trying to fix CI for win
gdmiron Jun 30, 2022
f9cd9b4
pybind11 msvc compiler bug https://github.com/microsoft/onnxruntime/i…
gdmiron Jun 30, 2022
4d7719c
Removed test fix CI
sdmytrievs Jun 30, 2022
2de44c3
changes to use of logger
gdmiron Jun 30, 2022
86db0fb
GEMS-210 Added function for set up logging level and log to file
sdmytrievs Jul 6, 2022
c0eba1d
GEMS-210 Added function for set up logging level and log to file for …
sdmytrievs Jul 6, 2022
003dfd0
adjustments to logger
gdmiron Jul 15, 2022
7ca369f
updated pipelines CI to macos12
gdmiron Jul 15, 2022
3de7ddc
Merged in add-logger (pull request #58)
sdmytrievs Jul 15, 2022
53e4fd3
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Jul 15, 2022
cda412e
Merge branch 'master' into origin-hub
gdmiron Jul 15, 2022
725f4fe
Merged in origin-hub (pull request #59)
gdmiron Jul 15, 2022
8526b9b
set C++ standard to 17
gdmiron Jul 16, 2022
479584c
link to spdlog
gdmiron Jul 16, 2022
9597fa1
fix versions for spdlog and fmt libs$
gdmiron Jul 16, 2022
e4c4641
Merged master into test-17
gdmiron Jul 16, 2022
cb52350
linking to fmt, psdlog
gdmiron Jul 16, 2022
3a0f4a2
Merge branch 'test-17' of bitbucket.org:gems4/thermofun into test-17
gdmiron Jul 16, 2022
56c96ef
link to spdlog in win and macos
gdmiron Jul 16, 2022
09fe03c
added fmt link in macos
gdmiron Jul 16, 2022
b05d064
import test macos
gdmiron Jul 16, 2022
ab43818
import test macos
gdmiron Jul 16, 2022
1134f95
define the CMake variable SPDLOG_FMT_EXTERNAL to use external fmt
gdmiron Jul 16, 2022
2d054d8
Add python path to build
sdmytrievs Jul 18, 2022
05e6211
Hide fmt
sdmytrievs Jul 18, 2022
10ed389
sinhronize with chemicalfun
sdmytrievs Jul 18, 2022
24f0da4
changed macos
sdmytrievs Jul 18, 2022
b6ea48b
azure-pipelines.yml edited online with Bitbucket
gdmiron Jul 19, 2022
f01936f
test with new chfun, link to spdlog for all os
gdmiron Jul 21, 2022
ba43cda
removed eigen
gdmiron Jul 21, 2022
f351881
fix conflict
gdmiron Jul 21, 2022
1578aa8
fixes
gdmiron Jul 21, 2022
ffcee06
Merged in test-17 (pull request #60)
gdmiron Jul 21, 2022
64464b9
Merge remote-tracking branch 'origin-hub/master' into origin-bucket
gdmiron Jul 21, 2022
1697bc9
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Nov 24, 2022
3cb430c
fixed merge
gdmiron Nov 24, 2022
ad95567
fixing spdlog link
gdmiron Nov 24, 2022
99642f7
activate tests in osx
gdmiron Nov 25, 2022
3a49012
fix build
gdmiron Nov 25, 2022
b185bfa
fix test
gdmiron Nov 25, 2022
ddb2ff7
fix test
gdmiron Nov 25, 2022
dbfc28d
fix for tests at Psat
gdmiron Nov 25, 2022
546c7ea
fix psat
gdmiron Nov 25, 2022
0f9302d
fixed tests
gdmiron Nov 25, 2022
7279a7c
fix macos ci
gdmiron Nov 25, 2022
caf6ad4
Merged in origin-hub (pull request #61)
gdmiron Nov 25, 2022
4852213
Merge branch 'master' into origin-bucket
gdmiron Nov 25, 2022
385bd75
Update environment.devenv.yml
gdmiron Nov 25, 2022
ecd7b51
revert
gdmiron Nov 25, 2022
aa9275e
Increment CACHE_NUMBER to reset cached conda packages
allanleal Nov 25, 2022
6d4ec1f
Removed option `use-only-tar-bz2: true` in GitHub workflows.
allanleal Nov 26, 2022
3d7c3f0
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Dec 6, 2022
26a0c90
Merge branch 'master' into origin-hub
gdmiron Dec 6, 2022
da2f852
GEMS-221: Fixed build spdlog in header-only mode or as lib for therm…
sdmytrievs Feb 8, 2023
6fb3782
GEMS-221: Set spdlog in header-only mode for thermofun project, check…
sdmytrievs Feb 9, 2023
e37645f
Restore fixed
sdmytrievs Feb 9, 2023
4368b3b
Fixed local install python code
sdmytrievs Feb 10, 2023
2addfd4
GEMS-217: Fixed memory leaks which were definitely lost t in ThermoFu…
sdmytrievs Feb 16, 2023
1244b54
Fixed python install for win64
sdmytrievs Mar 1, 2023
39e0f22
Fixed version in install dependent
sdmytrievs Mar 1, 2023
3bb2660
Fixed
sdmytrievs Mar 1, 2023
f6a8751
Merge remote-tracking branch 'origin-hub/master' into origin-hub
gdmiron Mar 2, 2023
4d7caa0
Merged in spdlog-221 (pull request #62)
sdmytrievs Mar 2, 2023
a1471ee
fixed merge conflicts
gdmiron Mar 2, 2023
eb826f8
v0.4.3
gdmiron Mar 2, 2023
edf86d7
Merge remote-tracking branch 'origin/origin-hub' into origin-bucket
gdmiron Mar 2, 2023
7a50ad4
removed setuptools and version of chemicalfun
gdmiron Mar 2, 2023
d6026d3
Merged in origin-hub (pull request #63)
gdmiron Mar 2, 2023
c669c98
GEMS-232: Fixed refresh all_elements data after setElement, addElement
sdmytrievs Apr 24, 2024
ac4af1d
GEMS-232: Added reference functions to C API
sdmytrievs Apr 24, 2024
1b8d663
GEMS-232: Added trace output functionality for the database API
sdmytrievs Apr 26, 2024
8cb8de7
GEMS-232: Added new functionality to the python API
sdmytrievs Apr 27, 2024
f676894
GEMS-232: Implemented test script of new functions into the Python API
sdmytrievs Apr 29, 2024
22d50fc
install.sh edited online with Bitbucket
gdmiron Apr 30, 2024
a91c6d5
install.sh edited online with Bitbucket
gdmiron Apr 30, 2024
bf7aa97
install.sh edited online with Bitbucket
gdmiron Apr 30, 2024
244193a
Merged in ref_api_232 (pull request #64)
sdmytrievs Apr 30, 2024
4f07752
fixed conflicts
gdmiron Jul 23, 2024
3442538
Merged master into origin-hub
gdmiron Jul 23, 2024
a458cda
Merged in origin-hub (pull request #65)
gdmiron Jul 23, 2024
6a0aa37
Merge branch 'master' into origin-bucket
gdmiron Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 118 additions & 24 deletions ThermoFun/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ struct Database::Impl
{
//jsonio::FJson file (filename);
//type_ = file.Type();
fromFile( filename );
if (elements_map.size()>0)
setDBElements( elements_map );
fromFile(filename);
setDBElements(elements_map);
}

Impl(std::vector<std::string> jsons, std::string _label)
{
fromJSONs(jsons, _label);
if (elements_map.size()>0)
setDBElements( elements_map );
setDBElements(elements_map);
}

template<typename Key, typename Value>
Expand All @@ -68,15 +66,18 @@ struct Database::Impl
return collection;
}

auto setDBElements(ElementsMap elements ) -> void
auto setDBElement(Element& element) -> void
{
thfun_logger->debug("Database::setDBElements() elements {}", elements.size());

ChemicalFun::ElementValues eldata;
for (auto& e : elements)
{
auto elkey = e.second.toElementKey(eldata);
all_elements.addElement(elkey, eldata);
auto elkey = element.toElementKey(eldata);
all_elements.addElement(elkey, eldata);
}

auto setDBElements(ElementsMap elements) -> void
{
thfun_logger->debug("Database::setDBElements() elements {}", elements.size());
for (auto& e : elements) {
setDBElement(e.second);
}
}

Expand All @@ -91,12 +92,14 @@ struct Database::Impl
auto addElement(const Element& element) -> void
{
elements_map.insert({element.symbol(), element});
setDBElement(elements_map[element.symbol()]);
}

auto setElement(const Element& element) -> void
{
checkIfSymbolExists(elements_map, "element", element.symbol());
elements_map[element.symbol()] = element;
setDBElement(elements_map[element.symbol()]);
}

auto addSubstance(const Substance& substance) -> void
Expand All @@ -113,6 +116,7 @@ struct Database::Impl
auto addMapElements(const ElementsMap& elements) -> void
{
elements_map = elements;
setDBElements(elements_map);
}

auto addMapSubstances(const SubstancesMap& substances) -> void
Expand Down Expand Up @@ -166,28 +170,70 @@ struct Database::Impl
return reactions_map.size();
}

auto getElement(std::string symbol) -> Element&
auto getElement(std::string symbol) -> const Element&
{
if(elements_map.count(symbol) == 0)
if(!containsElement(symbol)) {
errorNonExistent("element", symbol, __LINE__);

return elements_map.find(symbol)->second;
}
return elements_map[symbol];
}

auto getSubstance(std::string symbol) -> Substance&
auto getSubstance(std::string symbol) -> const Substance&
{
if(substances_map.count(symbol) == 0)
if(!containsSubstance(symbol)) {
errorNonExistent("substance", symbol, __LINE__);

return substances_map.find(symbol)->second;
}
return substances_map[symbol];
}

auto getReaction(std::string symbol) -> Reaction&
auto getReaction(std::string symbol) -> const Reaction&
{
if(reactions_map.count(symbol) == 0)
if(!containsReaction(symbol)) {
errorNonExistent("reaction", symbol, __LINE__);
}
return reactions_map[symbol];
}

auto element(std::string symbol) -> Element&
{
if(!containsElement(symbol)) { // try restore data from defaults
auto el_key =ChemicalFun::ElementKey(symbol,0);
Element empty_element;
if( all_elements.elements().find(el_key) != all_elements.elements().end()) {
empty_element = elementKeyToElement(el_key);
}
else {
empty_element.setSymbol(symbol);
empty_element.setName(symbol);
}
elements_map[symbol] = empty_element;
}
return elements_map[symbol];
}

return reactions_map.at(symbol);
auto substance(std::string symbol) -> Substance&
{
if(!containsSubstance(symbol)) {
Substance empty_subst;
empty_subst.setSymbol(symbol);
empty_subst.setName(symbol);
// ... set other default data
substances_map[symbol]=empty_subst;
}
return substances_map[symbol];
}

auto reaction(std::string symbol) -> Reaction&
{
if(!containsReaction(symbol))
{
Reaction empty_react;
empty_react.setSymbol(symbol);
empty_react.setName(symbol);
// ... set other default data
reactions_map[symbol]=empty_react;
}
return reactions_map[symbol];
}

auto mapElements() -> ElementsMap&
Expand Down Expand Up @@ -466,6 +512,22 @@ auto Database::getReaction(std::string symbol) const -> const Reaction&
return pimpl->getReaction(symbol);
}

auto Database::element(std::string symbol) -> Element&
{
return pimpl->element(symbol);
}

auto Database::substance(std::string symbol) -> Substance&
{
return pimpl->substance(symbol);
}

auto Database::reaction(std::string symbol) -> Reaction&
{
return pimpl->reaction(symbol);
}


auto Database::mapElements() const -> const ElementsMap&
{
return pimpl->mapElements();
Expand Down Expand Up @@ -496,6 +558,38 @@ auto Database::getReactions() const -> std::vector<Reaction>
return pimpl->getReactions();
}

// Return all elements in the database
auto Database::getElementsList() const -> std::vector<std::string>
{
std::vector<std::string> list;
for(const auto& item: pimpl->elements_map) {
list.push_back(item.first);
}
return list;
}

// Return all substances in the database
auto Database::getSubstancesList() const -> std::vector<std::string>
{
std::vector<std::string> list;
for(const auto& item: pimpl->substances_map) {
list.push_back(item.first);
}
return list;
}

// Return all reactions in the database
auto Database::getReactionsList() const -> std::vector<std::string>
{
std::vector<std::string> list;
for(const auto& item: pimpl->reactions_map) {
list.push_back(item.first);
}
return list;
}



auto Database::numberOfElements() const -> size_t
{
return pimpl->numberOfElements();
Expand Down Expand Up @@ -531,7 +625,7 @@ auto Database::parseSubstanceFormula(std::string formula_) const -> std::map<Ele
std::map<Element, double> map;
ChemicalFun::FormulaToken formula(formula_);
// ??? Do we need props, do not save
auto props = formula.properties(pimpl->all_elements.elements());
//auto props = formula.properties(pimpl->all_elements.elements());

for (const auto& element : formula.getStoichCoefficients())
{
Expand Down
18 changes: 18 additions & 0 deletions ThermoFun/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ class Database
/// Return all reactions in the database
auto getReactions() const -> std::vector<Reaction>;

/// Return list of all elements in the database
auto getElementsList() const -> std::vector<std::string>;

/// Return list of all substances in the database
auto getSubstancesList() const -> std::vector<std::string>;

/// Return list og all reactions in the database
auto getReactionsList() const -> std::vector<std::string>;

/// Returns the map of elements in the database
auto mapElements() const -> const ElementsMap&;

Expand Down Expand Up @@ -166,6 +175,15 @@ class Database
/// Return a reactions in the database
auto getReaction(std::string symbol) const -> const Reaction&;

/// Reference to the element in the database
auto element(std::string symbol) -> Element&;

/// Reference to the substance in the database
auto substance(std::string symbol) -> Substance&;

/// Reference to the reaction in the database
auto reaction(std::string symbol) -> Reaction&;

/// Check if the database contains a given element
/// @param symbol The name of the element
auto containsElement(std::string symbol) const -> bool;
Expand Down
21 changes: 20 additions & 1 deletion ThermoFun/Element.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iostream>
#include "Element.h"
#include "ChemicalFun/FormulaParser/ChemicalData.h"
#include "Common/ParseJsonToData.h"
Expand Down Expand Up @@ -206,7 +207,7 @@ ChemicalFun::ElementKey Element::toElementKey(ChemicalFun::ElementValues &eldata
eldata.number = number();
eldata.name = symbol(); // was e.name();

return ChemicalFun::ElementKey(symbol(), class_(), isotopeMass() );
return ChemicalFun::ElementKey(symbol(), class_(), isotopeMass());
}

auto operator<(const Element& lhs, const Element& rhs) -> bool
Expand Down Expand Up @@ -265,4 +266,22 @@ auto operator==(const Element& lhs, const Element& rhs) -> bool
(lhs.isotopeMass() == rhs.isotopeMass());
}


auto operator<<(std::ostream& stream, const Element& element) -> std::ostream&
{
stream << "Element(\n";
stream << " name: " << element.name() << "\n";
stream << " symbol: " << element.symbol() << "\n";
stream << " molarMass: " << element.molarMass() << "\n";
stream << " entropy: " << element.entropy() << "\n";
stream << " heatCapacity: " << element.heatCapacity() << "\n";
stream << " volume: " << element.volume() << "\n";
stream << " valence: " << element.valence() << "\n";
stream << " class: " << element.class_() << "\n";
stream << " isotopeMass: " << element.isotopeMass() << "\n";
stream << " number: " << element.number() << "\n)" << std::endl;
return stream;
}


} // namespace ThermoFun
2 changes: 2 additions & 0 deletions ThermoFun/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ auto operator<(const Element& lhs, const Element& rhs) -> bool;
/// Compare two Element instances for equality
auto operator==(const Element& lhs, const Element& rhs) -> bool;

auto operator<<(std::ostream& stream, const Element& element) -> std::ostream&;

} // namespace ThermoFun

#endif // ELEMENT_H
12 changes: 12 additions & 0 deletions ThermoFun/GlobalVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,18 @@ static const char * reacFMcoeff = "dr_marshall_franck_coeffs.values";

//typedef std::vector<struct ReactionData> Reactions;

/// Output a array instance
template<typename V>
auto operator<<(std::ostream& out, const std::vector<V>& array) -> std::ostream&
{
out << std::string("[ ");
for(const auto& val: array) {
out << val << " ";
}
out << std::string("]");
return out;
}

}
///@endcond

Expand Down
66 changes: 66 additions & 0 deletions ThermoFun/Reaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,73 @@ auto Reaction::calc_logK_fT_coefficients() -> vd
// setThermoParameters(th_param);
}

auto operator<<(std::ostream& stream, const ThermoPropertiesReaction& data) -> std::ostream&
{
stream << "( " << data.ln_equilibrium_constant << ", " << data.log_equilibrium_constant << ", "
<< data.reaction_gibbs_energy << ", "<< data.reaction_helmholtz_energy << ", "
<< data.reaction_internal_energy << ", "<< data.reaction_enthalpy << ", "
<< data.reaction_entropy << ", "<< data.reaction_volume << ", "
<< data.reaction_heat_capacity_cp << ", "<< data.reaction_heat_capacity_cv << " )";
return stream;
}

auto operator<<(std::ostream& stream, const ThermoParametersReaction& data) -> std::ostream&
{
if( !data.temperature_intervals.empty() ) {
stream << " temperature_intervals: " << data.temperature_intervals << "\n";
}
if( !data.pressure_intervals.empty() ) {
stream << " pressure_intervals: " << data.pressure_intervals << "\n";
}
if( !data.reaction_logK_fT_coeff.empty() ) {
stream << " reaction_logK_fT_coeff: " << data.reaction_logK_fT_coeff << "\n";
}
if( !data.logK_TP_array.empty() ) {
stream << " logK_TP_array: " << data.logK_TP_array << "\n";
}
if( !data.reaction_Cp_fT_coeff.empty() ) {
stream << " reaction_Cp_fT_coeff: " << data.reaction_Cp_fT_coeff << "\n";
}
if( !data.reaction_V_fT_coeff.empty() ) {
stream << " reaction_V_fT_coeff: " << data.reaction_V_fT_coeff << "\n";
}
if( !data.reaction_RB_coeff.empty() ) {
stream << " reaction_RB_coeff: " << data.reaction_RB_coeff << "\n";
}
if( !data.reaction_RB_coeff.empty() ) {
stream << " reaction_RB_coeff: " << data.reaction_RB_coeff << "\n";
}
if( !data.reaction_FM_coeff.empty() ) {
stream << " reaction_FM_coeff: " << data.reaction_FM_coeff << "\n";
}
if( !data.reaction_DM10_coeff.empty() ) {
stream << " reaction_DM10_coeff: " << data.reaction_DM10_coeff << "\n";
}
return stream;
}

auto operator<<(std::ostream& stream, const Reaction& react) -> std::ostream&
{
stream << "Reaction(\n";
stream << " name: " << react.name() << "\n";
stream << " symbol: " << react.symbol() << "\n";
stream << " equation: " << react.equation() << "\n";
stream << " reactants: ";
stream << std::string("[ ");
for(const auto& val: react.reactants()) {
stream << "( " << val.first << " : " << val.second << " ) ";
}
stream << std::string("]\n");
stream << " thermoReferenceProperties: " << react.thermoReferenceProperties() << "\n";
stream << " thermo_ref_prop: " << react.thermo_ref_prop() << "\n";
stream << " thermoParameters: \n" << react.thermoParameters();
stream << " T: ( " << react.referenceT() << ", " << react.lowerT() << ", " << react.upperT() << " )\n";
stream << " P: ( " << react.referenceP() << ", " << react.lowerP() << ", " << react.upperP() << " )\n";
stream << " methodGenEOS: " << react.methodGenEOS() << "\n";
stream << " method_T: " << react.method_T() << "\n";
stream << " method_P: " << react.method_P() << "\n)" << std::endl;
return stream;
}

} // namespace ThermoFun

Loading
Loading