diff --git a/ChemistryLib/CreateChemicalSolverInterface.cpp b/ChemistryLib/CreateChemicalSolverInterface.cpp index bd080a099725ebbb3fe135fdab51d898deca3636..da0bb97b329a06d4eabedfe6ba733266f7414453 100644 --- a/ChemistryLib/CreateChemicalSolverInterface.cpp +++ b/ChemistryLib/CreateChemicalSolverInterface.cpp @@ -67,8 +67,6 @@ template <> std::unique_ptr<ChemicalSolverInterface> createChemicalSolverInterface<ChemicalSolver::Phreeqc>( std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map, BaseLib::ConfigTree const& config, std::string const& output_directory) { auto mesh_name = @@ -92,8 +90,7 @@ createChemicalSolverInterface<ChemicalSolver::Phreeqc>( // solution auto aqueous_solution = PhreeqcIOData::createAqueousSolution( //! \ogs_file_param{prj__chemical_system__solution} - config.getConfigSubtree("solution"), - process_id_to_component_name_map); + config.getConfigSubtree("solution")); // kinetic reactants auto chemical_system_map = @@ -158,16 +155,13 @@ createChemicalSolverInterface<ChemicalSolver::Phreeqc>( std::move(path_to_database), std::move(aqueous_solutions), std::move(equilibrium_reactants), std::move(kinetic_reactants), std::move(reaction_rates), std::move(surface), std::move(user_punch), - std::move(output), std::move(dump), std::move(knobs), - process_id_to_component_name_map); + std::move(output), std::move(dump), std::move(knobs)); } template <> std::unique_ptr<ChemicalSolverInterface> createChemicalSolverInterface<ChemicalSolver::PhreeqcKernel>( std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map, BaseLib::ConfigTree const& config, std::string const& /*output_directory*/) { auto mesh = *meshes[0]; diff --git a/ChemistryLib/CreateChemicalSolverInterface.h b/ChemistryLib/CreateChemicalSolverInterface.h index 39615caae60ad081f0a419148ac9dbe6ca607f4e..16af2b92eb996e8a55ca271b25fdf85e13126b0e 100644 --- a/ChemistryLib/CreateChemicalSolverInterface.h +++ b/ChemistryLib/CreateChemicalSolverInterface.h @@ -33,7 +33,5 @@ class ChemicalSolverInterface; template <ChemicalSolver chemical_solver> std::unique_ptr<ChemicalSolverInterface> createChemicalSolverInterface( std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map, BaseLib::ConfigTree const& config, std::string const& output_directory); } // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index 1735c5f6104d2e184a425189429292daebaaad3c..8f6999744f24106d0e6464f8beb62ffb804feb24 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -56,9 +56,7 @@ PhreeqcIO::PhreeqcIO(std::string const project_file_name, std::unique_ptr<UserPunch>&& user_punch, std::unique_ptr<Output>&& output, std::unique_ptr<Dump>&& dump, - Knobs&& knobs, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map) + Knobs&& knobs) : _phreeqc_input_file(project_file_name + "_phreeqc.inp"), _mesh(mesh), _database(std::move(database)), @@ -70,8 +68,7 @@ PhreeqcIO::PhreeqcIO(std::string const project_file_name, _user_punch(std::move(user_punch)), _output(std::move(output)), _dump(std::move(dump)), - _knobs(std::move(knobs)), - _process_id_to_component_name_map(process_id_to_component_name_map) + _knobs(std::move(knobs)) { // initialize phreeqc instance if (CreateIPhreeqc() != phreeqc_instance_id) @@ -159,61 +156,45 @@ void PhreeqcIO::setAqueousSolutionsOrUpdateProcessSolutions( // Loop over transport process id map to retrieve component // concentrations from process solutions or to update process solutions // after chemical calculation by Phreeqc - for (auto const& process_id_to_component_name_map_element : - _process_id_to_component_name_map) - { - auto const& transport_process_id = - process_id_to_component_name_map_element.first; - auto const& transport_process_variable = - process_id_to_component_name_map_element.second; + for (unsigned component_id = 0; component_id < components.size(); + ++component_id) + { + auto& component = components[component_id]; auto& transport_process_solution = - process_solutions[transport_process_id]; - - auto component = - std::find_if(components.begin(), components.end(), - [&transport_process_variable](Component const& c) { - return c.name == transport_process_variable; - }); - - if (component != components.end()) + process_solutions[component_id + 1]; + switch (status) { - switch (status) - { - case Status::SettingAqueousSolutions: - // Set component concentrations. - component->amount = - transport_process_solution->get(global_id); - break; - case Status::UpdatingProcessSolutions: - // Update solutions of component transport processes. - transport_process_solution->set(global_id, - component->amount); - break; - } + case Status::SettingAqueousSolutions: + // Set component concentrations. + component.amount = + transport_process_solution->get(global_id); + break; + case Status::UpdatingProcessSolutions: + // Update solutions of component transport processes. + transport_process_solution->set(global_id, + component.amount); + break; } + } - if (transport_process_variable == "H") + switch (status) + { + case Status::SettingAqueousSolutions: { - switch (status) - { - case Status::SettingAqueousSolutions: - { - // Set pH value by hydrogen concentration. - aqueous_solution.pH = -std::log10( - transport_process_solution->get(global_id)); - break; - } - case Status::UpdatingProcessSolutions: - { - // Update hydrogen concentration by pH value. - auto hydrogen_concentration = - std::pow(10, -aqueous_solution.pH); - transport_process_solution->set(global_id, - hydrogen_concentration); - break; - } - } + // Set pH value by hydrogen concentration. + aqueous_solution.pH = + -std::log10(process_solutions.back()->get(global_id)); + break; + } + case Status::UpdatingProcessSolutions: + { + // Update hydrogen concentration by pH value. + auto hydrogen_concentration = + std::pow(10, -aqueous_solution.pH); + process_solutions.back()->set(global_id, + hydrogen_concentration); + break; } } } diff --git a/ChemistryLib/PhreeqcIO.h b/ChemistryLib/PhreeqcIO.h index 7bf70f58f5c55d86e9f0392066b04949c8cb7105..2db34efab46b8e40b31e582e38692164d79741f1 100644 --- a/ChemistryLib/PhreeqcIO.h +++ b/ChemistryLib/PhreeqcIO.h @@ -53,9 +53,7 @@ public: std::unique_ptr<UserPunch>&& user_punch, std::unique_ptr<Output>&& output, std::unique_ptr<Dump>&& dump, - Knobs&& knobs, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map); + Knobs&& knobs); void executeInitialCalculation( std::vector<GlobalVector*>& process_solutions) override; @@ -101,8 +99,6 @@ private: std::unique_ptr<Output> const _output; std::unique_ptr<Dump> const _dump; Knobs const _knobs; - std::vector<std::pair<int, std::string>> const& - _process_id_to_component_name_map; double _dt = std::numeric_limits<double>::quiet_NaN(); const int phreeqc_instance_id = 0; }; diff --git a/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.cpp b/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.cpp index 907eea1885e199e67d732fb03a7525075dd4ba51..70a7e2c6157b7689adb68b372e72d35912731303 100644 --- a/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.cpp +++ b/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.cpp @@ -18,10 +18,7 @@ namespace ChemistryLib { namespace PhreeqcIOData { -AqueousSolution createAqueousSolution( - BaseLib::ConfigTree const& config, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map) +AqueousSolution createAqueousSolution(BaseLib::ConfigTree const& config) { //! \ogs_file_param{prj__chemical_system__solution__temperature} auto const temperature = config.getConfigParameter<double>("temperature"); @@ -32,8 +29,7 @@ AqueousSolution createAqueousSolution( //! \ogs_file_param{prj__chemical_system__solution__pe} auto const pe = config.getConfigParameter<double>("pe"); - auto components = - createSolutionComponents(config, process_id_to_component_name_map); + auto components = createSolutionComponents(config); auto charge_balance = createChargeBalance(config); diff --git a/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.h b/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.h index 787d4196fb6055ed9b067d24189d4c002e09c870..8e0d680f276eca3a44bf227a0a6c7c9576db7a21 100644 --- a/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.h +++ b/ChemistryLib/PhreeqcIOData/CreateAqueousSolution.h @@ -10,9 +10,6 @@ #pragma once -#include <string> -#include <vector> - namespace BaseLib { class ConfigTree; @@ -24,9 +21,6 @@ namespace PhreeqcIOData { struct AqueousSolution; -AqueousSolution createAqueousSolution( - BaseLib::ConfigTree const& config, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map); +AqueousSolution createAqueousSolution(BaseLib::ConfigTree const& config); } // namespace PhreeqcIOData } // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp index 66430c61ddb53168b54df85db3b10b331d9747e2..44c0fce8422b462bcd12a88f9489c4d39f877ce5 100644 --- a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp +++ b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp @@ -11,16 +11,13 @@ #include "CreateSolutionComponent.h" #include "AqueousSolution.h" #include "BaseLib/ConfigTree.h" -#include "BaseLib/Error.h" namespace ChemistryLib { namespace PhreeqcIOData { std::vector<Component> createSolutionComponents( - BaseLib::ConfigTree const& config, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map) + BaseLib::ConfigTree const& config) { std::vector<Component> components; //! \ogs_file_param{prj__chemical_system__solution__components} @@ -33,34 +30,6 @@ std::vector<Component> createSolutionComponents( components.emplace_back(component_name); } - for (auto const& component : components) - { - auto process_id_to_component_name_map_element = std::find_if( - process_id_to_component_name_map.begin(), - process_id_to_component_name_map.end(), - [&component](std::pair<int, std::string> const& map_element) { - return map_element.second == component.name; - }); - - 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); - } - } - if (components.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."); - } - return components; } } // namespace PhreeqcIOData diff --git a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h index 66151c5d67103eb5d178bc31c735785389cfbbf4..417450e9dac2319acd7b65572483082a49ecefb1 100644 --- a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h +++ b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h @@ -10,7 +10,6 @@ #pragma once -#include <string> #include <vector> namespace BaseLib @@ -25,8 +24,6 @@ namespace PhreeqcIOData struct Component; std::vector<Component> createSolutionComponents( - BaseLib::ConfigTree const& config, - std::vector<std::pair<int, std::string>> const& - process_id_to_component_name_map); + BaseLib::ConfigTree const& config); } // namespace PhreeqcIOData } // namespace ChemistryLib