From c78dd87daf8f9eb5afca101c080785e684c77199 Mon Sep 17 00:00:00 2001 From: David L Parkhurst Date: Tue, 7 Aug 2007 15:04:13 +0000 Subject: [PATCH] Have version working that formats an input file for Orchestra, runs Orchestra with a system call to a batch file, reads results from Orchestra, stores results in global phreeqc storage, and prints results. Works only for initial solution calculation. Still some problems with the solver. Ex1 fails. Cleaned up organization a little. Ready to start on "reaction" calculation. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@2176 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- ISolution.cxx | 32 +++----------------------------- ISolution.h | 3 +-- Solution.cxx | 30 ++++++++++++++++++++++++++++++ Solution.h | 2 +- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/ISolution.cxx b/ISolution.cxx index dc19c17f..93f9e5f2 100644 --- a/ISolution.cxx +++ b/ISolution.cxx @@ -731,6 +731,8 @@ void cxxISolution::ORCH_write_chemistry_minerals(std::ostream &chemistry_dat) } } } + //chemistry_dat << "@mineral(Quartz)" << std::endl; + //chemistry_dat << "@sreaction(Quartz, 10139.1138573668, -2.0, H2O, 1.0, H4SiO4)" << std::endl; } void cxxISolution::ORCH_write_input(std::ostream &input_dat) { @@ -854,7 +856,7 @@ void cxxISolution::ORCH_write_input(std::ostream &input_dat) return; } -void cxxISolution::ORCH_write_output(std::ostream &outstream) +void cxxISolution::ORCH_write_output_vars(std::ostream &outstream) { outstream << "Var:"; outstream << "\tnr_iter"; @@ -928,31 +930,3 @@ void cxxISolution::ORCH_write_output(std::ostream &outstream) outstream << std::endl; return; } - -void cxxISolution::ORCH_store_global(std::map < std::string, double > output_map) -{ - int i; - tc_x = this->tc; - mass_water_aq_x = this->mass_water; - mu_x = this->mu; - s_h2o->moles = output_map["H2O.con"]; - s_h2o->la = log10(output_map["H2O.act"]); - s_h2o->lm = s_h2o->la; - s_h2o->lg = 0; - for (i = 0; i < count_unknowns; i++) - { - residual[i] = 0; - // MB, ALK, CB, SOLUTION_PHASE_BOUNDARY, MU, AH2O - switch (x[i]->type) - { - case MB: - case CB: - case SOLUTION_PHASE_BOUNDARY: - x[i]->sum = this->totals[x[i]->description]*mass_water_aq_x; - break; - case ALK: - x[i]->f = this->total_alkalinity*mass_water_aq_x; - break; - } - } -} diff --git a/ISolution.h b/ISolution.h index 3574983b..b629f013 100644 --- a/ISolution.h +++ b/ISolution.h @@ -43,8 +43,7 @@ public: void ConvertUnits(); void ORCH_write_chemistry(std::ostream &chemistry_dat); void ORCH_write_input(std::ostream &input_dat); - void ORCH_write_output(std::ostream &input_dat); - void ORCH_store_global(std::map < std::string, double > output_map); + void ORCH_write_output_vars(std::ostream &input_dat); protected: friend class cxxISolutionComp; // for this->pe access diff --git a/Solution.cxx b/Solution.cxx index a090fde9..04cc70e5 100644 --- a/Solution.cxx +++ b/Solution.cxx @@ -964,6 +964,7 @@ double cxxSolution::get_master_activity(char *string)const return(it->second); } } + void cxxSolution::ORCH_read(std::vector > output_vector, std::vector < std::pair < std::string, double > >::iterator &it) { this->tc = it->second; it++; @@ -1038,6 +1039,35 @@ void cxxSolution::ORCH_read(std::vector > outpu s_ptr->lg = s_ptr->la - s_ptr->lm; } } + +void cxxSolution::ORCH_store_global(std::map < std::string, double > output_map) +{ + int i; + tc_x = this->tc; + mass_water_aq_x = this->mass_water; + mu_x = this->mu; + s_h2o->moles = output_map["H2O.con"]; + s_h2o->la = log10(output_map["H2O.act"]); + s_h2o->lm = s_h2o->la; + s_h2o->lg = 0; + for (i = 0; i < count_unknowns; i++) + { + residual[i] = 0; + // MB, ALK, CB, SOLUTION_PHASE_BOUNDARY, MU, AH2O + switch (x[i]->type) + { + case MB: + case CB: + case SOLUTION_PHASE_BOUNDARY: + x[i]->sum = this->totals[x[i]->description]*mass_water_aq_x; + break; + case ALK: + x[i]->f = this->total_alkalinity*mass_water_aq_x; + break; + } + } +} + #ifdef USE_MPI #include /* ---------------------------------------------------------------------- */ diff --git a/Solution.h b/Solution.h index 7c3b44f2..ef519e4d 100644 --- a/Solution.h +++ b/Solution.h @@ -85,7 +85,7 @@ public: void multiply(double extensive); void ORCH_write(std::ostream& headings, std::ostream& input_data)const; void ORCH_read(std::vector > output_vector, std::vector < std::pair < std::string, double > >::iterator &it); - + void ORCH_store_global(std::map < std::string, double > output_map); #ifdef USE_MPI void mpi_pack(std::vector& ints, std::vector& doubles);