diff --git a/Solution.cxx b/Solution.cxx index f5310e28..bad764ba 100644 --- a/Solution.cxx +++ b/Solution.cxx @@ -907,6 +907,20 @@ void cxxSolution::add(const cxxSolution &addee, double extensive) this->species_gamma.add_intensive(addee.species_gamma, f1, f2); this->isotopes.add(addee.isotopes, f2, extensive); } +void cxxSolution::multiply(double extensive) + // + // Multiply existing solution by extensive + // +{ + if (extensive == 0.0 || extensive == 1.0) return; + this->total_h *= extensive; + this->total_o *= extensive; + this->cb *= extensive; + this->mass_water *= extensive; + this->total_alkalinity *= extensive; + this->totals.multiply(extensive); + this->isotopes.multiply(extensive); +} double cxxSolution::get_total(char *string)const { cxxNameDouble::const_iterator it = this->totals.find(string); diff --git a/Solution.h b/Solution.h index 89c7f377..edadce15 100644 --- a/Solution.h +++ b/Solution.h @@ -83,6 +83,7 @@ public: void write_orchestra(std::ostream& headings, std::ostream& input_data)const; void read_raw(CParser& parser); + void multiply(double extensive); #ifdef USE_MPI diff --git a/SolutionIsotope.cxx b/SolutionIsotope.cxx index 25be4d72..771645c2 100644 --- a/SolutionIsotope.cxx +++ b/SolutionIsotope.cxx @@ -197,6 +197,10 @@ void cxxSolutionIsotope::add(const cxxSolutionIsotope &isotope_ptr, double inten this->ratio_uncertainty_defined = (this->ratio_uncertainty_defined || isotope_ptr.ratio_uncertainty_defined); } } +void cxxSolutionIsotope::multiply(double extensive) +{ + this->total *= extensive; +} #ifdef SKIP cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser& parser) diff --git a/SolutionIsotope.h b/SolutionIsotope.h index 7efdfbdc..50c40eaf 100644 --- a/SolutionIsotope.h +++ b/SolutionIsotope.h @@ -48,6 +48,7 @@ public: struct master *primary(void); void add(const cxxSolutionIsotope &isotope_ptr, double intensive, double extensive); + void multiply(double extensive); protected: friend class cxxSolutionIsotopeList; diff --git a/SolutionIsotopeList.cxx b/SolutionIsotopeList.cxx index 0bc81085..97ddda62 100644 --- a/SolutionIsotopeList.cxx +++ b/SolutionIsotopeList.cxx @@ -61,6 +61,13 @@ void cxxSolutionIsotopeList::add(cxxSolutionIsotopeList old, double intensive, d } } } +void cxxSolutionIsotopeList::multiply(double extensive) +{ + for (cxxSolutionIsotopeList::iterator it = this->begin(); it != this->end(); ++it) + { + it->total *= extensive; + } +} struct isotope * cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope() { struct isotope *iso; diff --git a/SolutionIsotopeList.h b/SolutionIsotopeList.h index 6867e14c..21a40d8a 100644 --- a/SolutionIsotopeList.h +++ b/SolutionIsotopeList.h @@ -24,6 +24,7 @@ public: struct isotope *cxxSolutionIsotopeList2isotope(); void add(cxxSolutionIsotopeList oldlist, double intensive, double extensive); + void multiply(double extensive); protected: