Replies: 4 comments
-
Try the following corrections: #include <Reaktoro/Reaktoro.hpp>
#include <ThermoFun/ThermoFun.h>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
#include <iostream>
#include <vector>
int main()
{
Reaktoro::ThermoFunDatabase db;
Reaktoro::EquilibriumResult result;
db = Reaktoro::ThermoFunDatabase("mines19-thermofun.json");
Reaktoro::AqueousPhase aq(speciate("H O Na Cl C")); // Correction 1: Use the speciate command here.
Reaktoro::GaseousPhase gas("CO2");
Reaktoro::MineralPhase sol("Halite");
Reaktoro::ChemicalSystem system(db, aq, gas, sol);
Reaktoro::EquilibriumConditions conds(system);
Reaktoro::ChemicalState state(system);
conds.pressure(100, "bar");
conds.temperature(60, "degC");
// Correction 2: Use EquilibriumConditions::setInitialComponentAmounts
ArrayXd b = ArrayXd::Zero(system.elements().size() + 1);
b[system.elements().index("H")] = 110.0;
b[system.elements().index("O")] = 75.0;
b[system.elements().index("Na")] = 5.0;
b[system.elements().index("Cl")] = 5.0;
b[system.elements().index("C")] = 10.0;
Reaktoro::EquilibriumSolver solver(system);
result = solver.solve(state, conds); // Correction 3: Pass along the specified conditions at equilibrium
std::cout << "===========================Equilibrium State==========================" << std::endl;
state.output(std::cout);
std::cout << std::endl;
return 0;
} I have not tried compiling this though. The following adapted Python script works (had to remove Halite because it's not in the mines16 database and you are using mines19 that Reaktoro still needs to embed (although I could have downloaded it and used a local file): from reaktoro import *
import numpy as np
db = ThermoFunDatabase("mines16")
aq = AqueousPhase(speciate("H O Na Cl C"))
gas = GaseousPhase("CO2")
# sol = MineralPhase("Halite")
# system = ChemicalSystem(db, aq, gas, sol)
system = ChemicalSystem(db, aq, gas)
conds = EquilibriumConditions(system)
state = ChemicalState(system)
b = np.zeros(system.elements().size() + 1)
b[system.elements().index("H")] = 110.0
b[system.elements().index("O")] = 75.0
b[system.elements().index("Na")] = 5.0
b[system.elements().index("Cl")] = 5.0
b[system.elements().index("C")] = 10.0
conds.pressure(100, "bar")
conds.temperature(60, "degC")
conds.setInitialComponentAmounts(b)
solver = EquilibriumSolver(system)
result = solver.solve(state, conds)
print(state) The output is:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply! I fixed the code in accordance with your comments, also fixed the way I create a ChemicalSystem object. Reaktoro::AqueousPhase aq(Reaktoro::speciate("H O Na Cl C")); |
Beta Was this translation helpful? Give feedback.
-
But the problem remains the same. I think the thing is that I may have written the code in cmakelist incorrectly. Could you please take a look at it and point out the mistake? The exe file is created in the "training" folder, and the dll files are also located there. |
Beta Was this translation helpful? Give feedback.
-
Hi @nedam321 , please email me so that I can check this more specific issue with you alone. |
Beta Was this translation helpful? Give feedback.
-
Description
After I installed reaktoro and read the api reference, I started writing a small example. I wanted to dissolve 5 moles of NaCl in 1 kg of water, and pump 10 moles of CO2 there. The choice of the "elementAmount" function is not accidental, I will not go into details, but I need to use this function. The code was even compiled)
However, when the exe file is launched, nothing happens and nothing is output. I can't figure out where I went wrong.
Example
What is your operating system?
Windows
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions