From f8b4047ddfc1da2a2bf631690ce7ec95286daec1 Mon Sep 17 00:00:00 2001 From: renchao_lu <renchao.lu@gmail.com> Date: Sat, 4 Jul 2020 12:06:51 +0200 Subject: [PATCH] [CL] Unit conversion for pH. --- ChemistryLib/PhreeqcIO.cpp | 5 +++-- ChemistryLib/PhreeqcIOData/AqueousSolution.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index b3e7bc22361..3cda89519f8 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -462,8 +462,9 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io) case ItemType::pH: { // Update pH value - aqueous_solution->pH->set(chemical_system_id, - accepted_items[item_id]); + aqueous_solution->pH->set( + chemical_system_id, + std::pow(10, -accepted_items[item_id])); break; } case ItemType::pe: diff --git a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp index 5d80ad50234..8a2d213c4e2 100644 --- a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp +++ b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp @@ -8,6 +8,7 @@ * */ +#include <cmath> #include <ostream> #include "AqueousSolution.h" @@ -28,17 +29,17 @@ void AqueousSolution::print(std::ostream& os, switch (charge_balance) { case ChargeBalance::pH: - os << "pH " << (*pH)[chemical_system_id] << " charge" + os << "pH " << -std::log10((*pH)[chemical_system_id]) << " charge" << "\n"; os << "pe " << (*pe)[chemical_system_id] << "\n"; break; case ChargeBalance::pe: - os << "pH " << (*pH)[chemical_system_id] << "\n"; + os << "pH " << -std::log10((*pH)[chemical_system_id]) << "\n"; os << "pe " << (*pe)[chemical_system_id] << " charge" << "\n"; break; case ChargeBalance::Unspecified: - os << "pH " << (*pH)[chemical_system_id] << "\n"; + os << "pH " << -std::log10((*pH)[chemical_system_id]) << "\n"; os << "pe " << (*pe)[chemical_system_id] << "\n"; break; } -- GitLab