Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
cmake_minimum_required(VERSION 3.16...4.2)

# Set the name of the project
project(xGEMS VERSION 2.0.2 LANGUAGES CXX)
project(xGEMS VERSION 2.1.0 LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MACOSX_RPATH ON)

Expand All @@ -23,8 +23,8 @@ include(CondaAware)

# Set the version of the project
set(XGEMS_VERSION_MAJOR "2")
set(XGEMS_VERSION_MINOR "0")
set(XGEMS_VERSION_MICRO "2")
set(XGEMS_VERSION_MINOR "1")
set(XGEMS_VERSION_MICRO "0")
set(XGEMS_VERSION "${XGEMS_VERSION_MAJOR}.${XGEMS_VERSION_MINOR}.${XGEMS_VERSION_MICRO}")

# Set the output directories of the built libraries and binaries
Expand Down
2 changes: 1 addition & 1 deletion demos/demo.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DEFINES += USE_THERMOFUN
DEFINES += USE_THERMO_LOG
#DEFINES += OVERFLOW_EXCEPT #compile with nan inf exceptions

#GEMS3K_CPP = ../../standalone/GEMS3K
#GEMS3K_CPP = ../../GEMS3K/GEMS3K
#GEMS3K_H = $$GEMS3K_CPP
#DEPENDPATH += $$GEMS3K_H
#INCLUDEPATH += $$GEMS3K_H
Expand Down
76 changes: 74 additions & 2 deletions demos/demo1-dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,92 @@
#include <fstream>
#include <sstream>
#include <string>
using namespace std;

// xGEMS includes
#include "xGEMS/ChemicalEngineMaps.hpp"
#include <xGEMS/ChemicalEngine.hpp>

void print_map(const std::string title, const xGEMS::ValuesMap& data)
template <class T>
void print_map(const std::string title, const std::map<std::string, T>& data)
{
std::cout << "\n" << title << std::endl;
for(const auto& sp: data) {
std::cout<< sp.first << ":" << sp.second << std::endl;
}
}
static void demo_dict();
static void demo_warnings_map();
static void demo_warnings();


int main(int argc, char **argv)
{
//demo_dict();
//demo_warnings_map();
demo_warnings();
return 0;
}

void demo_warnings_map()
{

auto engine = xGEMS::ChemicalEngineMaps("resources/solvus2/series1-dat.lst");
std::cout << engine.equilibrate() << std::endl;

print_map("engine.species_molar_mass()", engine.species_molar_mass());

print_map("engine.element_molar_masses()", engine.element_molar_masses());

print_map("engine.phases_moles()", engine.phases_moles());

}

void demo_warnings()
{

xGEMS::ChemicalEngine engine("resources/solvus2/series1-dat.lst");

auto T = engine.temperature();
auto P = engine.pressure();
auto b = engine.elementAmounts();
engine.equilibrate(T, P, b);

// Test setPT
bool no_error = engine.setPT(101325, 298.15);
std::cout << (no_error ? "PT set correctly" : "PT error") << std::endl;
no_error = engine.setPT(50000000, 673.15);
std::cout << (no_error ? "PT set correctly" : "PT error") << std::endl;

//Test long names
auto ispecies1 = engine.indexSpecies("Anorthite_long_substance_name");
auto ispecies2 = engine.indexSpecies("Anorthite_long_substance_name", "Plagioclase");
auto ispecies3 = engine.indexSpecies("Anorthite");
std::cout << ispecies1 << " " << ispecies2 << " " <<ispecies3 << std::endl;
std::cout << engine.speciesName(ispecies1) << " " << engine.speciesName(ispecies2) << " " <<engine.speciesName(ispecies3) << std::endl;

auto iphase1= engine.indexPhase("Kaolinite_long_phase_name");
std::cout << iphase1 << " " << engine.phaseName(iphase1) << std::endl;
auto iphase2= engine.indexPhase("Kaolinite");
std::cout << iphase2 << " " << engine.phaseName(iphase2) << std::endl;

//indexSpecies dependen on phase optional
std::cout << engine.speciesAmount(ispecies1) << " " << engine.speciesAmount(ispecies2) << std::endl;
engine.setSpeciesAmount("Anorthite_long_substance_name", 10);
engine.setSpeciesAmount("Anorthite_long_substance_name", 20, "Plagioclase");
std::cout << engine.speciesAmount(ispecies1) << " " << engine.speciesAmount(ispecies2) << std::endl;

print_map("Albite indexes", engine.indexSpeciesMap("Albite"));
print_map("Quartz indexes", engine.indexSpeciesMap("Quartz"));

// warning messages required
std::cout << engine.phaseSpecificVolume(2) << std::endl;
std::cout << engine.phaseSpecificVolume(30) << std::endl;
std::cout << engine.phaseSpecificVolume(-1) << std::endl;

}


void demo_dict()
{
auto engine = xGEMS::ChemicalEngineMaps("resources/CalciteBC/CalciteBC-dat.lst");

Expand Down
61 changes: 61 additions & 0 deletions demos/demo2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# xGEMS is a C++ and Python library for thermodynamic modeling by Gibbs energy minimization
#
# Copyright (C) 2018 Allan Leal, Dmitrii Kulik
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from xgems import *
from numpy import *
Comment thread
gdmiron marked this conversation as resolved.

#connect all loggers
update_loggers(True, "test_demo1.log", 3)

engine = ChemicalEngine("resources/solvus2/series1-dat.lst")
Comment thread
gdmiron marked this conversation as resolved.

T = engine.temperature()
P = engine.pressure()
b = engine.elementAmounts()

engine.equilibrate(T, P, b)

# SetPT test
print("setPT(101325, 298.15)", engine.setPT(101325, 298.15) )
print("setPT(50000000, 673.15)", engine.setPT(50000000, 673.15) )

# long names
ispecies1 = engine.indexSpecies("Anorthite_long_substance_name")
ispecies2 = engine.indexSpecies("Anorthite_long_substance_name", "Plagioclase")
ispecies3 = engine.indexSpecies("Anorthite")
print(ispecies1, " ",ispecies2, " ",ispecies3, " ")

print(engine.speciesName(ispecies1), " ", engine.speciesName(ispecies2), " ",engine.speciesName(ispecies3))

iphase1= engine.indexPhase("Kaolinite_long_phase_name");
print(iphase1, " ", engine.phaseName(iphase1))
iphase2= engine.indexPhase("Kaolinite");
print(iphase2, " ", engine.phaseName(iphase2))

#indexSpecies dependen on phase optional
print(engine.speciesAmount(ispecies1), " ", engine.speciesAmount(ispecies2))
engine.setSpeciesAmount("Anorthite_long_substance_name", 10)
engine.setSpeciesAmount("Anorthite_long_substance_name", 20, "Plagioclase")
print(engine.speciesAmount(ispecies1), " ", engine.speciesAmount(ispecies2))

print("Albite indexes\n", engine.indexSpeciesMap("Albite"))
print("Quartz indexes\n", engine.indexSpeciesMap("Quartz"))

# warning messages required
print(engine.phaseSpecificVolume(2))
print(engine.phaseSpecificVolume(30))
print(engine.phaseSpecificVolume(-1))
1 change: 1 addition & 0 deletions demos/resources/solvus2/series1-dat.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-j "series1-dch.json" "series1-ipm.json" "series1-dbr-0-0000.json"
Loading
Loading