diff --git a/ChemistryLib/CreateOutput.cpp b/ChemistryLib/CreateOutput.cpp index e0678dd1c48f5823dbc84c6860b4ebc3cf37d0ef..310a2037b74c3fa60b55521e3156ae17c85fd95e 100644 --- a/ChemistryLib/CreateOutput.cpp +++ b/ChemistryLib/CreateOutput.cpp @@ -22,13 +22,19 @@ std::unique_ptr<Output> createOutput( std::vector<OutputItem> accepted_items{{"pH", ItemType::pH}, {"pe", ItemType::pe}}; for (auto const& component : components) + { accepted_items.emplace_back(component.name, ItemType::Component); + } for (auto const& equilibrium_phase : equilibrium_phases) + { accepted_items.emplace_back(equilibrium_phase.name, ItemType::EquilibriumPhase); + } for (auto const& kinetic_reactant : kinetic_reactants) + { accepted_items.emplace_back(kinetic_reactant.name, ItemType::KineticReactant); + } // Record ids of which phreeqc output items will be dropped. BasicOutputSetups basic_output_setups(project_file_name); diff --git a/ChemistryLib/CreatePhreeqcIO.cpp b/ChemistryLib/CreatePhreeqcIO.cpp index dd5ed3a468a88748d848fc05e77f068a4f8b7530..95a0ecd7c5d51877dceeef49ee5623a461606d1e 100644 --- a/ChemistryLib/CreatePhreeqcIO.cpp +++ b/ChemistryLib/CreatePhreeqcIO.cpp @@ -65,18 +65,22 @@ std::unique_ptr<PhreeqcIO> createPhreeqcIO( if (process_id_to_component_name_map_element == process_id_to_component_name_map.end()) + { OGS_FATAL( "Component %s given in <solution>/<components> is not found in " "specified coupled processes (see " "<process>/<process_variables>/<concentration>).", component.name.c_str()); + } } if (components_per_chem_sys.size() + 1 != process_id_to_component_name_map.size()) + { OGS_FATAL( "The number of components given in <solution>/<components> is not " "in line with the number of transport processes - 1 which stands " "for the transport process of hydrogen."); + } std::vector<AqueousSolution> aqueous_solutions( num_chemical_systems, aqueous_solution_per_chem_sys); diff --git a/ChemistryLib/Output.cpp b/ChemistryLib/Output.cpp index 6eed8b29076c27dbad6113f8aad2535a783ed449..64593e54754665ea5c905a0806d55a370e4eba08 100644 --- a/ChemistryLib/Output.cpp +++ b/ChemistryLib/Output.cpp @@ -41,7 +41,9 @@ std::ofstream& operator<<(std::ofstream& out, Output const& output) output.getOutputItemsByItemType(ItemType::Component); out << "-totals"; for (auto const& component_item : component_items) + { out << " " << component_item.name; + } out << "\n"; auto const equilibrium_phase_items = @@ -50,7 +52,9 @@ std::ofstream& operator<<(std::ofstream& out, Output const& output) { out << "-equilibrium_phases"; for (auto const& equilibrium_phase_item : equilibrium_phase_items) + { out << " " << equilibrium_phase_item.name; + } out << "\n"; } @@ -60,7 +64,9 @@ std::ofstream& operator<<(std::ofstream& out, Output const& output) { out << "-kinetic_reactants"; for (auto const& kinetic_reactant_item : kinetic_reactant_items) + { out << " " << kinetic_reactant_item.name; + } out << "\n"; } diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index 6a3580b6de1d8ce1a7dfc890c3ddad1d2174384e..faa62265ad133f4b8da8aa64c24c6b1cddb255bf 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -118,14 +118,18 @@ void PhreeqcIO::writeInputsToFile() std::ofstream out(_phreeqc_input_file, std::ofstream::out); if (!out) + { OGS_FATAL("Could not open file '%s' for writing phreeqc inputs.", _phreeqc_input_file.c_str()); + } out << *this; if (!out) + { OGS_FATAL("Failed in generating phreeqc input file '%s'.", _phreeqc_input_file.c_str()); + } out.close(); } @@ -188,9 +192,11 @@ void PhreeqcIO::execute() // load a specific database in the working directory if (!database_loaded(instance_id)) + { OGS_FATAL( "Failed in loading the specified thermodynamic database file: %s.", _database.c_str()); + } SetSelectedOutputFileOn(instance_id, 1); @@ -213,14 +219,18 @@ void PhreeqcIO::readOutputsFromFile() std::ifstream in(phreeqc_result_file); if (!in) + { OGS_FATAL("Could not open phreeqc result file '%s'.", phreeqc_result_file.c_str()); + } in >> *this; if (!in) + { OGS_FATAL("Error when reading phreeqc result file '%s'", phreeqc_result_file.c_str()); + } in.close(); } @@ -244,10 +254,12 @@ std::ifstream& operator>>(std::ifstream& in, PhreeqcIO& phreeqc_io) // Get calculation result of the solution after the reaction if (!std::getline(in, line)) + { OGS_FATAL( "Error when reading calculation result of Solution %u after " "the reaction.", chemical_system_id); + } std::vector<double> accepted_items; std::vector<std::string> items; @@ -259,7 +271,9 @@ std::ifstream& operator>>(std::ifstream& in, PhreeqcIO& phreeqc_io) { if (std::find(dropped_item_ids.begin(), dropped_item_ids.end(), item_id) == dropped_item_ids.end()) + { accepted_items.push_back(std::stod(items[item_id])); + } } assert(accepted_items.size() == output.accepted_items.size()); diff --git a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp index 6680a4d45362733834e12373930aae53c9617046..8867e80dd97f30618d8d33a1b243e750f9a02654 100644 --- a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp +++ b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp @@ -48,14 +48,20 @@ AqueousSolution createAqueousSolution(BaseLib::ConfigTree const& config) if (means_of_adjusting_charge_in_str) { if (*means_of_adjusting_charge_in_str == "pH") + { means_of_adjusting_charge = MeansOfAdjustingCharge::pH; + } else if (*means_of_adjusting_charge_in_str == "pe") + { means_of_adjusting_charge = MeansOfAdjustingCharge::pe; + } else + { OGS_FATAL( "Error in specifying means of adjusting charge. Achieving " "charge balance is currently supported with the way of " "adjusting pH value or pe value."); + } } else { @@ -99,7 +105,9 @@ std::ofstream& operator<<(std::ofstream& out, out << "units mol/kgw\n"; for (auto const& component : aqueous_solution.components) + { out << component.name << " " << component.amount << "\n"; + } return out; } diff --git a/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp b/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp index 05888627e5c31889eeffd6f4354318488b63b344..e92d7b06641f0aa324344167422677da626e0602 100644 --- a/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp +++ b/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp @@ -18,7 +18,9 @@ std::vector<EquilibriumPhase> createEquilibriumPhases( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return {}; + } std::vector<EquilibriumPhase> equilibrium_phases; for ( diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp index 6f6c76b5d201da80f271af86f9d4ff1e27fad59a..e4e39a22a9e32a2fa516a6e1aec873124a72d317 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp @@ -18,7 +18,9 @@ std::vector<KineticReactant> createKineticReactants( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return {}; + } std::vector<KineticReactant> kinetic_reactants; for ( @@ -58,7 +60,9 @@ std::ofstream& operator<<(std::ofstream& out, { out << "-parms"; for (auto const& parameter : kinetic_reactant.parameters) + { out << " " << parameter; + } out << "\n"; } } diff --git a/ChemistryLib/PhreeqcIOData/ReactionRate.cpp b/ChemistryLib/PhreeqcIOData/ReactionRate.cpp index ee967a4037131410677b9980fa75b41839690387..00331c51f0e172ef32f1668a5ef749af7299f8aa 100644 --- a/ChemistryLib/PhreeqcIOData/ReactionRate.cpp +++ b/ChemistryLib/PhreeqcIOData/ReactionRate.cpp @@ -18,7 +18,9 @@ std::vector<ReactionRate> createReactionRates( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return {}; + } std::vector<ReactionRate> reaction_rates; for (auto const& rate_config : @@ -37,7 +39,9 @@ std::vector<ReactionRate> createReactionRates( auto const& expression_statement : //! \ogs_file_param{prj__chemical_system__rates__rate__expression__statement} expression_config.getConfigParameterList<std::string>("statement")) + { expression_statements.push_back(expression_statement); + } reaction_rates.emplace_back(std::move(kinetic_reactant), std::move(expression_statements));