From 8169db2e6d26eb084fe436262bf17b469bd9e6a9 Mon Sep 17 00:00:00 2001
From: Renchao Lu <renchao.lu@ufz.de>
Date: Sun, 20 Sep 2020 14:56:52 +0200
Subject: [PATCH] [CL] Output chemical formula of a component.

---
 ChemistryLib/PhreeqcIOData/AqueousSolution.cpp         | 6 ++++--
 ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp | 7 ++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp
index 8a2d213c4e2..7ea3250f458 100644
--- a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp
+++ b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp
@@ -48,8 +48,10 @@ void AqueousSolution::print(std::ostream& os,
 
     for (auto const& component : components)
     {
-        os << component.name << " " << (*component.amount)[chemical_system_id]
-           << "\n";
+        os << component.name << " " << (*component.amount)[chemical_system_id];
+        component.chemical_formula.empty()
+            ? os << "\n"
+            : os << " as " << component.chemical_formula << "\n";
     }
 
     os << "\n\n";
diff --git a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp
index b417c69166b..5c223863556 100644
--- a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp
+++ b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp
@@ -24,14 +24,15 @@ std::vector<Component> createSolutionComponents(
     auto components_config = config.getConfigSubtree("components");
 
     for (
-        auto const& comp_config :
+        auto const& component_config :
         //! \ogs_file_param{prj__chemical_system__solution__components__component}
         components_config.getConfigSubtreeList("component"))
     {
-        auto const component_name = comp_config.getValue<std::string>();
+        auto const component_name = component_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", "");
+            component_config.getConfigAttribute<std::string>("chemical_formula",
+                                                             "");
         components.emplace_back(component_name, chemical_formula);
     }
 
-- 
GitLab