From 19f6c8eb7b746afced1b6f57fcc28cdbd0a2efbc Mon Sep 17 00:00:00 2001 From: renchao_lu <renchao.lu@gmail.com> Date: Sun, 9 Jun 2019 22:08:00 +0200 Subject: [PATCH] [CL] Chemical formula of a phase. --- ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp | 11 +++++++++-- ChemistryLib/PhreeqcIOData/KineticReactant.cpp | 5 +++++ ChemistryLib/PhreeqcIOData/KineticReactant.h | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp index 2a95c1f2a8e..c740c6c3e8d 100644 --- a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp +++ b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp @@ -29,6 +29,11 @@ std::vector<KineticReactant> createKineticReactants( //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__name} auto name = reactant_config.getConfigParameter<std::string>("name"); + auto chemical_formula = + //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__chemical_formula} + reactant_config.getConfigParameter<std::string>("chemical_formula", + ""); + double const initial_amount = //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__initial_amount} reactant_config.getConfigParameter<double>("initial_amount"); @@ -38,8 +43,10 @@ std::vector<KineticReactant> createKineticReactants( reactant_config.getConfigParameterOptional<std::vector<double>>( "parameters"); - kinetic_reactants.emplace_back( - std::move(name), initial_amount, std::move(parameters)); + kinetic_reactants.emplace_back(std::move(name), + std::move(chemical_formula), + initial_amount, + std::move(parameters)); } return kinetic_reactants; diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp index 7d014bb98cd..58ca69348eb 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp @@ -20,6 +20,11 @@ std::ofstream& operator<<(std::ofstream& out, { out << kinetic_reactant.name << "\n"; + if (!kinetic_reactant.chemical_formula.empty()) + { + out << "-formula " << kinetic_reactant.chemical_formula << "\n"; + } + out << "-m " << kinetic_reactant.amount << "\n"; if (!kinetic_reactant.parameters.empty()) diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.h b/ChemistryLib/PhreeqcIOData/KineticReactant.h index 5fd9418d8e7..4cfd0325cd3 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.h +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.h @@ -21,10 +21,12 @@ namespace ChemistryLib struct KineticReactant { KineticReactant(std::string name_, + std::string&& chemical_formula_, double amount_, boost::optional<std::vector<double>> parameters_) : name(std::move(name_)), + chemical_formula(std::move(chemical_formula_)), amount(amount_), parameters(parameters_ ? std::move(*parameters_) : std::vector<double>{}) @@ -36,6 +38,7 @@ struct KineticReactant std::vector<KineticReactant> const& kinetic_reactants); std::string const name; + std::string const chemical_formula; double amount; std::vector<double> const parameters; static const ItemType item_type = ItemType::KineticReactant; -- GitLab