From 04941a0a0a782cc8c38c0b47c7dc6738f8a17a86 Mon Sep 17 00:00:00 2001 From: Renchao Lu <renchao.lu@ufz.de> Date: Sun, 20 Sep 2020 14:56:26 +0200 Subject: [PATCH] [CL] Get chemical formula of a component if given --- ChemistryLib/PhreeqcIOData/AqueousSolution.h | 6 +++++- .../PhreeqcIOData/CreateSolutionComponent.cpp | 13 +++++++++---- .../components/component/a_chemical_formula.md | 1 + .../solution/components/component/i_component.md | 1 + .../solution/components/i_components.md | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 Documentation/ProjectFile/prj/chemical_system/solution/components/component/a_chemical_formula.md create mode 100644 Documentation/ProjectFile/prj/chemical_system/solution/components/component/i_component.md diff --git a/ChemistryLib/PhreeqcIOData/AqueousSolution.h b/ChemistryLib/PhreeqcIOData/AqueousSolution.h index b802479b1c0..0bca4401782 100644 --- a/ChemistryLib/PhreeqcIOData/AqueousSolution.h +++ b/ChemistryLib/PhreeqcIOData/AqueousSolution.h @@ -32,9 +32,13 @@ namespace PhreeqcIOData { struct Component { - explicit Component(std::string name_) : name(std::move(name_)) {} + explicit Component(std::string name_, std::string chemical_formula_) + : name(std::move(name_)), chemical_formula(std::move(chemical_formula_)) + { + } std::string const name; + std::string const chemical_formula; std::unique_ptr<GlobalVector> amount; static const ItemType item_type = ItemType::Component; }; diff --git a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp index 44c0fce8422..b417c69166b 100644 --- a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp +++ b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp @@ -21,13 +21,18 @@ std::vector<Component> createSolutionComponents( { std::vector<Component> components; //! \ogs_file_param{prj__chemical_system__solution__components} - auto comp_config = config.getConfigSubtree("components"); + auto components_config = config.getConfigSubtree("components"); + for ( - auto const& component_name : + auto const& comp_config : //! \ogs_file_param{prj__chemical_system__solution__components__component} - comp_config.getConfigParameterList<std::string>("component")) + components_config.getConfigSubtreeList("component")) { - components.emplace_back(component_name); + auto const component_name = comp_config.getValue<std::string>(); + auto const chemical_formula = + //! \ogs_file_attr{prj__chemical_system__solution__components__component__chemical_formula} + comp_config.getConfigAttribute<std::string>("chemical_formula", ""); + components.emplace_back(component_name, chemical_formula); } return components; diff --git a/Documentation/ProjectFile/prj/chemical_system/solution/components/component/a_chemical_formula.md b/Documentation/ProjectFile/prj/chemical_system/solution/components/component/a_chemical_formula.md new file mode 100644 index 00000000000..f22938a71a3 --- /dev/null +++ b/Documentation/ProjectFile/prj/chemical_system/solution/components/component/a_chemical_formula.md @@ -0,0 +1 @@ +chemical formula alternative to a component when defining water composition. diff --git a/Documentation/ProjectFile/prj/chemical_system/solution/components/component/i_component.md b/Documentation/ProjectFile/prj/chemical_system/solution/components/component/i_component.md new file mode 100644 index 00000000000..4475bbb6ead --- /dev/null +++ b/Documentation/ProjectFile/prj/chemical_system/solution/components/component/i_component.md @@ -0,0 +1 @@ +define the element in the aqueous solution. diff --git a/Documentation/ProjectFile/prj/chemical_system/solution/components/i_components.md b/Documentation/ProjectFile/prj/chemical_system/solution/components/i_components.md index 0064008382b..2399ff634d2 100644 --- a/Documentation/ProjectFile/prj/chemical_system/solution/components/i_components.md +++ b/Documentation/ProjectFile/prj/chemical_system/solution/components/i_components.md @@ -1 +1 @@ -define a list of elements in the initial solution. +define a list of elements in the aqueous solution. -- GitLab