phastpp works on linear_ic in debug mode.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@862 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2006-04-13 21:16:33 +00:00
parent 574da9a1ac
commit c41fb4e5ec
8 changed files with 81 additions and 214 deletions

View File

@ -36,7 +36,7 @@ cxxKineticsComp::cxxKineticsComp(struct kinetics_comp *kinetics_comp_ptr)
// constructor for cxxKineticsComp from struct kinetics_comp
//
:
namecoef(kinetics_comp_ptr->list, kinetics_comp_ptr->count_list, cxxNameDouble::ND_NAME_COEF)
namecoef(kinetics_comp_ptr->list, kinetics_comp_ptr->count_list)
{
rate_name = kinetics_comp_ptr->rate_name;
tol = kinetics_comp_ptr->tol;

3
Mix.h
View File

@ -28,9 +28,10 @@ public:
void read_raw(CParser& parser);
std::map<int, double> comps() {return mixComps;}
std::map<int, double> *comps() {return &mixComps;}
protected:
friend class cxxStorageBin;
std::map<int, double> mixComps;
public:

View File

@ -66,7 +66,7 @@ cxxNameDouble::cxxNameDouble(struct conc *tots)
}
this->type = ND_ELT_MOLES;
}
cxxNameDouble::cxxNameDouble(struct master_activity *ma, int count, cxxNameDouble::ND_TYPE)
cxxNameDouble::cxxNameDouble(struct master_activity *ma, int count, cxxNameDouble::ND_TYPE type)
//
// constructor for cxxNameDouble from list of elt_list
//
@ -76,9 +76,9 @@ cxxNameDouble::cxxNameDouble(struct master_activity *ma, int count, cxxNameDoubl
if (ma[i].description == NULL) continue;
(*this)[ma[i].description] = ma[i].la;
}
this->type = ND_SPECIES_LA;
this->type = type;
}
cxxNameDouble::cxxNameDouble(struct name_coef *nc, int count, cxxNameDouble::ND_TYPE)
cxxNameDouble::cxxNameDouble(struct name_coef *nc, int count)
//
// constructor for cxxNameDouble from list of elt_list
//

View File

@ -26,7 +26,7 @@ public:
cxxNameDouble(struct elt_list *);
cxxNameDouble(struct conc *);
cxxNameDouble(struct master_activity *ma, int count, ND_TYPE);
cxxNameDouble(struct name_coef *nc, int count, ND_TYPE);
cxxNameDouble(struct name_coef *nc, int count);
cxxNameDouble(const cxxNameDouble &old, double factor);
~cxxNameDouble();

View File

@ -37,7 +37,7 @@ cxxReaction::cxxReaction(struct irrev *irrev_ptr)
//
:
cxxNumKeyword(),
reactantList(irrev_ptr->list, irrev_ptr->count_list, cxxNameDouble::ND_NAME_COEF),
reactantList(irrev_ptr->list, irrev_ptr->count_list),
elementList(irrev_ptr->elts)
{
int i;

View File

@ -752,199 +752,6 @@ void cxxSolution::set_master_activity(char *string, double d)
this->master_activity[string] = d;
}
#ifdef SKIP
cxxSolution& cxxSolution::read(CParser& parser)
{
static std::vector<std::string> vopts;
if (vopts.empty()) {
vopts.reserve(11);
vopts.push_back("temp"); // 0
vopts.push_back("temperature"); // 1
vopts.push_back("dens"); // 2
vopts.push_back("density"); // 3
vopts.push_back("units"); // 4
vopts.push_back("redox"); // 5
vopts.push_back("ph"); // 6
vopts.push_back("pe"); // 7
vopts.push_back("unit"); // 8
vopts.push_back("isotope"); // 9
vopts.push_back("water"); // 10
}
// const int count_opt_list = vopts.size();
cxxSolution numkey;
// Read solution number and description
numkey.read_number_description(parser);
std::istream::pos_type ptr;
std::istream::pos_type next_char;
std::string token;
CParser::TOKEN_TYPE j;
//cxxSolution& sol = s_map[numkey.n_user()];
int default_pe = 0;
for (;;)
{
int opt = parser.get_option(vopts, next_char);
if (opt == CParser::OPTION_DEFAULT)
{
ptr = next_char;
if (parser.copy_token(token, ptr) == CParser::TT_DIGIT) {
opt = 9;
}
}
switch (opt)
{
case CParser::OPTION_EOF:
break;
case CParser::OPTION_KEYWORD:
break;
case CParser::OPTION_ERROR:
opt = CParser::OPTION_EOF;
parser.error_msg("Unknown input in SOLUTION keyword.", CParser::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
break;
case 0: // temp
case 1: // temperature
if (!(parser.get_iss() >> sol.tc))
{
sol.tc = 25;
}
break;
case 2: // dens
case 3: // density
parser.get_iss() >> sol.density;
break;
case 4: // units
case 8: // unit
if (parser.copy_token(token, next_char) == CParser::TT_EMPTY) break;
if (parser.check_units(token, false, false, sol.units, true) == CParser::OK) {
sol.units = token;
} else {
parser.incr_input_error();
}
break;
case 5: // redox
if (parser.copy_token(token, next_char) == CParser::TT_EMPTY) break;
if (parser.parse_couple(token) == CParser::OK) {
default_pe = cxxPe_Data::store(sol.pe, token);
} else {
parser.incr_input_error();
}
break;
case 6: // ph
{
cxxConc conc;
if (conc.read(parser, sol) == cxxConc::ERROR) {
parser.incr_input_error();
break;
}
sol.ph = conc.get_input_conc();
if (conc.get_equation_name().empty()) {
break;
}
conc.set_description("H(1)");
sol.add(conc);
}
break;
case 7: // pe
{
cxxConc conc;
if (conc.read(parser, sol) == cxxConc::ERROR) {
parser.incr_input_error();
break;
}
sol.solution_pe = conc.get_input_conc();
if (conc.get_equation_name().empty()) {
break;
}
conc.set_description("E");
sol.add(conc);
}
break;
case 9: // isotope
{
cxxIsotope isotope;
if (isotope.read(parser) == cxxIsotope::OK) {
sol.add(isotope);
}
}
break;
case 10: // water
j = parser.copy_token(token, next_char);
if (j == CParser::TT_EMPTY) {
sol.mass_water = 1.0;
} else if (j != CParser::TT_DIGIT) {
parser.incr_input_error();
parser.error_msg("Expected numeric value for mass of water in solution.", CParser::OT_CONTINUE);
} else {
std::istringstream(token) >> sol.mass_water;
}
break;
case CParser::OPTION_DEFAULT:
{
// Read concentration
cxxConc conc;
if (conc.read(parser, sol) == cxxConc::ERROR) {
parser.incr_input_error();
} else {
sol.add(conc);
}
}
break;
}
if (opt == CParser::OPTION_EOF || opt == CParser::OPTION_KEYWORD) break;
}
#ifdef SKIP
//
// Sort totals by description
//
std::sort(sol.totals.begin(), sol.totals.end());
#endif
//
// fix up default units and default pe
//
std::string token1;
std::vector<cxxConc>::iterator iter = sol.totals.begin();
for (; iter != sol.totals.end(); ++iter)
{
token = (*iter).get_description();
Utilities::str_tolower(token);
if ((*iter).get_units().empty()) {
(*iter).set_units(sol.units);
} else {
bool alk = false;
if (token.find("alk") == 0) alk = true;
token1 = (*iter).get_units();
if (parser.check_units(token1, alk, true, sol.get_units(), true) == CParser::ERROR) {
parser.incr_input_error();
} else {
(*iter).set_units(token1);
}
}
if ((*iter).get_n_pe() < 0) {
(*iter).set_n_pe(default_pe);
}
}
sol.default_pe = default_pe;
return sol;
}
#endif
#include "ISolution.h"
#include "Exchange.h"
#include "Surface.h"
@ -1291,4 +1098,3 @@ void test_classes(void)
// read it back
}
}

View File

@ -302,6 +302,8 @@ void cxxStorageBin::cxxStorageBin2phreeqc(int n)
struct exchange *exchange_ptr = (it->second).cxxExchange2exchange();
exchange_copy(exchange_ptr, &exchange[0], n);
count_exchange++;
exchange_free(exchange_ptr);
exchange_ptr = (struct exchange *) free_check_null(exchange_ptr);
}
}
@ -312,6 +314,8 @@ void cxxStorageBin::cxxStorageBin2phreeqc(int n)
struct gas_phase *gas_phase_ptr = (it->second).cxxGasPhase2gas_phase();
gas_phase_copy(gas_phase_ptr, &gas_phase[0], n);
count_gas_phase++;
gas_phase_free(gas_phase_ptr);
gas_phase_ptr = (struct gas_phase *) free_check_null(gas_phase_ptr);
}
}
@ -322,6 +326,8 @@ void cxxStorageBin::cxxStorageBin2phreeqc(int n)
struct kinetics *kinetics_ptr = (it->second).cxxKinetics2kinetics();
kinetics_copy(kinetics_ptr, &kinetics[0], n);
count_kinetics++;
kinetics_free(kinetics_ptr);
kinetics_ptr = (struct kinetics *) free_check_null(kinetics_ptr);
}
}
@ -332,6 +338,8 @@ void cxxStorageBin::cxxStorageBin2phreeqc(int n)
struct pp_assemblage *pp_assemblage_ptr = (it->second).cxxPPassemblage2pp_assemblage();
pp_assemblage_copy(pp_assemblage_ptr, &pp_assemblage[0], n);
count_pp_assemblage++;
pp_assemblage_free(pp_assemblage_ptr);
pp_assemblage_ptr = (struct pp_assemblage *) free_check_null(pp_assemblage_ptr);
}
}
@ -342,6 +350,8 @@ void cxxStorageBin::cxxStorageBin2phreeqc(int n)
struct s_s_assemblage *s_s_assemblage_ptr = (it->second).cxxSSassemblage2s_s_assemblage();
s_s_assemblage_copy(s_s_assemblage_ptr, &s_s_assemblage[0], n);
count_s_s_assemblage++;
s_s_assemblage_free(s_s_assemblage_ptr);
s_s_assemblage_ptr = (struct s_s_assemblage *) free_check_null(s_s_assemblage_ptr);
}
}
@ -352,6 +362,8 @@ void cxxStorageBin::cxxStorageBin2phreeqc(int n)
struct surface *surface_ptr = (it->second).cxxSurface2surface();
surface_copy(surface_ptr, &surface[0], n);
count_surface++;
surface_free(surface_ptr);
surface_ptr = (struct surface *) free_check_null(surface_ptr);
}
}
@ -371,38 +383,84 @@ void cxxStorageBin::phreeqc2cxxStorageBin(int n)
// Exchangers
{
exchange_bsearch(n, &pos);
this->Exchangers[n] = cxxExchange(&(exchange[pos]));
if (exchange_bsearch(n, &pos) != NULL) {
this->Exchangers[n] = cxxExchange(&(exchange[pos]));
}
}
// GasPhases
{
gas_phase_bsearch(n, &pos);
this->GasPhases[n] = cxxGasPhase(&(gas_phase[pos]));
if (gas_phase_bsearch(n, &pos) != NULL) {
this->GasPhases[n] = cxxGasPhase(&(gas_phase[pos]));
}
}
// Kinetics
{
kinetics_bsearch(n, &pos);
this->Kinetics[n] = cxxKinetics(&(kinetics[pos]));
if (kinetics_bsearch(n, &pos) != NULL) {
this->Kinetics[n] = cxxKinetics(&(kinetics[pos]));
}
}
// PPassemblages
{
pp_assemblage_bsearch(n, &pos);
this->PPassemblages[n] = cxxPPassemblage(&(pp_assemblage[pos]));
if (pp_assemblage_bsearch(n, &pos) != NULL) {
this->PPassemblages[n] = cxxPPassemblage(&(pp_assemblage[pos]));
}
}
// SSassemblages
{
s_s_assemblage_bsearch(n, &pos);
this->SSassemblages[n] = cxxSSassemblage(&(s_s_assemblage[pos]));
if (s_s_assemblage_bsearch(n, &pos) != NULL) {
this->SSassemblages[n] = cxxSSassemblage(&(s_s_assemblage[pos]));
}
}
// Surfaces
{
surface_bsearch(n, &pos);
this->Surfaces[n] = cxxSurface(&(surface[pos]));
if (surface_bsearch(n, &pos) != NULL) {
this->Surfaces[n] = cxxSurface(&(surface[pos]));
}
}
}
cxxSolution *cxxStorageBin::mix_cxxSolutions(cxxMix &mixmap)
{
/*
* mixes solutions based on cxxMix structure, returns new solution
* return solution must be freed by calling method
*/
double intensive, extensive;
cxxSolution *cxxsoln_ptr, *cxxsoln_ptr1;
/*
* Zero out global solution data
*/
cxxsoln_ptr = new cxxSolution(0.0);
/*
* Determine sum of mixing fractions
*/
extensive = 0.0;
std::map<int, double> *mixcomps = mixmap.comps();
std::map<int, double>::const_iterator it;
for (it = mixcomps->begin(); it != mixcomps->end(); it++) {
extensive += it->second;
}
/*
* Add solutions
*/
for (it = mixcomps->begin(); it != mixcomps->end(); it++) {
cxxsoln_ptr1 = &((this->Solutions.find(it->first))->second);
if (cxxsoln_ptr1 == NULL) {
sprintf(error_string, "Solution %d not found in mix_cxxSolutions.", it->first);
error_msg(error_string, CONTINUE);
input_error++;
return(NULL);
}
intensive = it->second/extensive;
cxxsoln_ptr->add(*cxxsoln_ptr1, intensive, it->second);
}
return(cxxsoln_ptr);
}

View File

@ -50,6 +50,8 @@ public:
void add(struct system *sys_ptr);
cxxSolution *mix_cxxSolutions(cxxMix &mixmap);
protected:
// Tidied classes
std::map<int, cxxSolution> Solutions;