Removed skipped code.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@6081 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2012-01-18 17:23:36 +00:00
parent ea54bb8f57
commit 18906cdd2f
27 changed files with 23 additions and 8359 deletions

View File

@ -596,31 +596,6 @@ cxxGasPhase::totalize(PHREEQC_PTR_ARG)
}
return;
}
#ifdef SKIP
void
cxxGasPhase::totalize(PHREEQC_PTR_ARG)
{
this->totals.clear();
// component structures
for (cxxNameDouble::const_iterator it = this->gasPhaseComps.begin();
it != this->gasPhaseComps.end(); it++)
{
struct phase *phase_ptr;
int l;
phase_ptr = P_INSTANCE_POINTER phase_bsearch(it->first.c_str(), &l, FALSE);
if (phase_ptr != NULL)
{
cxxNameDouble phase_formula(phase_ptr->next_elt);
this->totals.add_extensive(phase_formula, it->second);
}
else
{
assert(false);
}
}
return;
}
#endif
LDBLE cxxGasPhase::Calc_total_moles(void)
{
LDBLE tot = 0.0;

View File

@ -26,29 +26,7 @@ cxxPPassemblage::cxxPPassemblage(PHRQ_io * io)
{
eltList.type = cxxNameDouble::ND_ELT_MOLES;
}
#ifdef SKIP
cxxPPassemblage::cxxPPassemblage(struct pp_assemblage *pp_assemblage_ptr, PHRQ_io * io)
//
// constructor for cxxPPassemblage from struct PPassemblage
//
:
cxxNumKeyword(io),
eltList(pp_assemblage_ptr->next_elt)
{
int i;
this->Set_description(pp_assemblage_ptr->description);
n_user = pp_assemblage_ptr->n_user;
n_user_end = pp_assemblage_ptr->n_user_end;
for (i = 0; i < pp_assemblage_ptr->count_comps; i++)
{
cxxPPassemblageComp ppComp(&(pp_assemblage_ptr->pure_phases[i]), this->Get_io());
//ppAssemblageComps.push_back(ppComp);
std::string str(ppComp.Get_name());
this->ppAssemblageComps[str] = ppComp;
}
}
#endif
cxxPPassemblage::cxxPPassemblage(const std::map < int,
cxxPPassemblage > &entities, cxxMix & mix,
int l_n_user, PHRQ_io * io):

View File

@ -33,26 +33,7 @@ PHRQ_base(io)
dissolve_only = false;
precipitate_only = false;
}
#ifdef SKIP
cxxPPassemblageComp::cxxPPassemblageComp(struct pure_phase * pure_phase_ptr, PHRQ_io *io)
:
PHRQ_base(io)
//
// constructor for cxxPPassemblageComp from struct pure_phase
//
{
this->Set_name(pure_phase_ptr->name);
this->Set_add_formula(pure_phase_ptr->add_formula);
si = pure_phase_ptr->si;
si_org = pure_phase_ptr->si_org;
moles = pure_phase_ptr->moles;
delta = pure_phase_ptr->delta;
initial_moles = pure_phase_ptr->initial_moles;
force_equality = (pure_phase_ptr->force_equality == TRUE);
dissolve_only = (pure_phase_ptr->dissolve_only == TRUE);
precipitate_only = (pure_phase_ptr->precipitate_only == TRUE);
}
#endif
cxxPPassemblageComp::~cxxPPassemblageComp()
{
}

View File

@ -22,8 +22,6 @@
CParser::CParser(PHRQ_io *io):
PHRQ_base(io),
m_input_stream(std::cin),
//m_output_stream(std::cout),
//m_error_stream(std::cerr),
m_input_error(0),
m_next_keyword(Keywords::KEY_NONE)
{
@ -47,8 +45,6 @@ m_next_keyword(Keywords::KEY_NONE)
CParser::CParser(std::istream & input, PHRQ_io *io):
PHRQ_base(io),
m_input_stream(input),
//m_output_stream(std::cout),
//m_error_stream(std::cerr),
m_input_error(0),
m_next_keyword(Keywords::KEY_NONE)
{
@ -60,39 +56,6 @@ m_next_keyword(Keywords::KEY_NONE)
phrq_io_only = false;
}
#ifdef SKIP
CParser::CParser(std::istream & input, std::ostream & output, PHRQ_io *io)
:
PHRQ_base(io),
m_input_stream(input),
m_output_stream(output),
m_error_stream(std::cerr),
m_input_error(0),
m_next_keyword(Keywords::KEY_NONE)
{
m_line_save.reserve(80);
m_line.reserve(80);
echo_file = EO_ALL;
echo_stream = EO_NONE;
accumulate = false;
}
CParser::CParser(std::istream & input, std::ostream & output, std::ostream & error, PHRQ_io *io)
:
PHRQ_base(io),
m_input_stream(input),
m_output_stream(output),
m_error_stream(error),
m_input_error(0),
m_next_keyword(Keywords::KEY_NONE)
{
m_line_save.reserve(80);
m_line.reserve(80);
echo_file = EO_ALL;
echo_stream = EO_NONE;
accumulate = false;
}
#endif
CParser::~CParser()
{
}

View File

@ -207,14 +207,6 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
}
#ifdef SKIP
for (i = 0; i < count_pp_assemblage; i++)
{
cxxPPassemblage entity(&pp_assemblage[i], phrq_io);
entity.totalize(this);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
#endif
// exchangers
{
std::map<int, cxxExchange>::const_iterator cit = Rxn_exchange_map.begin();
@ -255,14 +247,6 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
}
#ifdef SKIP
for (i = 0; i < count_ss_assemblage; i++)
{
cxxSSassemblage entity(&ss_assemblage[i]);
entity.totalize(this);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
#endif
// kinetics
for (i = 0; i < count_kinetics; i++)
{

View File

@ -929,33 +929,6 @@ protected:
int phase_delete(int i);
struct phase *phase_store(const char *name);
public:
#ifdef SKIP
struct pp_assemblage *pp_assemblage_alloc(void);
struct pp_assemblage *pp_assemblage_bsearch(int k, int *n);
protected:
static int pp_assemblage_compare(const void *ptr1, const void *ptr2);
public:
int pp_assemblage_copy(struct pp_assemblage *pp_assemblage_old_ptr,
struct pp_assemblage *pp_assemblage_new_ptr,
int n_user_new);
protected:
int pp_assemblage_copy_to_last(int n, int n_user);
int pp_assemblage_delete(int n_user_old);
int pp_assemblage_duplicate(int n_user_old, int n_user_new);
public:
int pp_assemblage_free(struct pp_assemblage *pp_assemblage_ptr);
protected:
int pp_assemblage_init(struct pp_assemblage *pp_assemblage_ptr, int n_user,
int n_user_end, char *description);
int pp_assemblage_ptr_to_user(struct pp_assemblage *pp_assemblage_ptr_old,
int n_user_new);
struct pp_assemblage *pp_assemblage_replicate(struct pp_assemblage
*pp_assemblage_old_ptr,
int n_user_new);
struct pp_assemblage *pp_assemblage_search(int n_user, int *n);
int pp_assemblage_sort(void);
static int pure_phase_compare(const void *ptr1, const void *ptr2);
#endif
struct rate *rate_bsearch(char *ptr, int *j);
int rate_free(struct rate *rate_ptr);
struct rate *rate_search(const char *name, int *n);
@ -969,34 +942,6 @@ protected:
int s_delete(int i);
struct species *s_search(const char *name);
struct species *s_store(const char *name, LDBLE z, int replace_if_found);
public:
#ifdef SKIP
struct ss_assemblage *ss_assemblage_alloc(void);
struct ss_assemblage *ss_assemblage_bsearch(int k, int *n);
protected:
static int ss_assemblage_compare(const void *ptr1, const void *ptr2);
public:
int ss_assemblage_copy(struct ss_assemblage *ss_assemblage_old_ptr,
struct ss_assemblage *ss_assemblage_new_ptr,
int n_user_new);
protected:
int ss_assemblage_copy_to_last(int n, int n_user);
int ss_assemblage_duplicate(int n_user_old, int n_user_new);
int ss_assemblage_delete(int n_user_old);
public:
int ss_assemblage_free(struct ss_assemblage *ss_assemblage_ptr);
int ss_assemblage_init(struct ss_assemblage *ss_assemblage_ptr,
int n_user, int n_user_end, char *description);
int ss_assemblage_ptr_to_user(struct ss_assemblage *ss_assemblage_ptr_old,
int n_user_new);
struct ss_assemblage *ss_assemblage_replicate(struct ss_assemblage
*ss_assemblage_old_ptr,
int n_user_new);
struct ss_assemblage *ss_assemblage_search(int n_user, int *n);
int ss_assemblage_sort(void);
static int s_s_compare(const void *ptr1, const void *ptr2);
#endif
protected:
struct save_values *save_values_bsearch(struct save_values *k, int *n);
static int save_values_compare(const void *ptr1, const void *ptr2);

View File

@ -207,102 +207,6 @@ read_surface_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_equilibrium_phases_raw(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads EQUILIBRIUM_PHASES_RAW data block
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
/*
* Accumulate lines in std string
*/
std::string keywordLines("");
keywordLines.append(line);
keywordLines.append("\n");
/*
* Read additonal lines
*/
int save_echo_input = pr.echo_input;
pr.echo_input = FALSE;
for (;;)
{
return_value =
check_line("equilibrium_phases_raw", TRUE, TRUE, TRUE, FALSE);
/* empty, eof, keyword, print */
if (return_value == EOF || return_value == KEYWORD)
break;
keywordLines.append(line);
keywordLines.append("\n");
}
pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
//For testing, need to read line to get started
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxPPassemblage ex(phrq_io);
ex.read_raw(parser);
//struct pp_assemblage *pp_assemblage_ptr = ex.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
struct pp_assemblage *pp_assemblage_ptr = cxxPPassemblage2pp_assemblage(&ex);
int n;
/*
* This is not quite right, may not produce sort order, forced sort
*/
if (pp_assemblage_bsearch(pp_assemblage_ptr->n_user, &n) != NULL)
{
pp_assemblage_free(&pp_assemblage[n]);
pp_assemblage_copy(pp_assemblage_ptr, &pp_assemblage[n],
pp_assemblage_ptr->n_user);
}
else
{
n = count_pp_assemblage++;
if (count_pp_assemblage >= max_pp_assemblage)
{
space((void **) ((void *) &(pp_assemblage)), count_pp_assemblage,
&max_pp_assemblage, sizeof(struct pp_assemblage));
}
pp_assemblage_copy(pp_assemblage_ptr, &pp_assemblage[n],
pp_assemblage_ptr->n_user);
pp_assemblage_sort();
}
pp_assemblage_free(pp_assemblage_ptr);
free_check_null(pp_assemblage_ptr);
// Need to output the next keyword
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_kinetics_raw(void)
@ -394,103 +298,6 @@ read_kinetics_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_solid_solutions_raw(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads SOLID_SOLUTION_RAW data block
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
/*
* Accumulate lines in std string
*/
std::string keywordLines("");
keywordLines.append(line);
keywordLines.append("\n");
/*
* Read additonal lines
*/
int save_echo_input = pr.echo_input;
pr.echo_input = FALSE;
for (;;)
{
return_value =
check_line("solid_solution_raw", TRUE, TRUE, TRUE, FALSE);
/* empty, eof, keyword, print */
if (return_value == EOF || return_value == KEYWORD)
break;
keywordLines.append(line);
keywordLines.append("\n");
}
pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
//For testing, need to read line to get started
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxSSassemblage ex;
ex.read_raw(parser);
//struct ss_assemblage *ss_assemblage_ptr = ex.cxxSSassemblage2ss_assemblage(PHREEQC_THIS);
struct ss_assemblage *ss_assemblage_ptr = cxxSSassemblage2ss_assemblage(&ex);
int n;
/*
* This is not quite right, may not produce sort order, forced sort
*/
if (ss_assemblage_bsearch(ss_assemblage_ptr->n_user, &n) != NULL)
{
ss_assemblage_free(&ss_assemblage[n]);
ss_assemblage_copy(ss_assemblage_ptr, &ss_assemblage[n],
ss_assemblage_ptr->n_user);
}
else
{
n = count_ss_assemblage++;
if (count_ss_assemblage >= max_ss_assemblage)
{
space((void **) ((void *) &(ss_assemblage)),
count_ss_assemblage, &max_ss_assemblage,
sizeof(struct ss_assemblage));
}
ss_assemblage_copy(ss_assemblage_ptr, &ss_assemblage[n],
ss_assemblage_ptr->n_user);
ss_assemblage_sort();
}
ss_assemblage_free(ss_assemblage_ptr);
free_check_null(ss_assemblage_ptr);
// Need to output the next keyword
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_dump(void)
@ -735,99 +542,6 @@ read_solution_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_equilibrium_phases_modify(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads equilibrium_phases_modify data block
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
// find equilibrium_phases number
char token[MAX_LENGTH];
char *next;
int l, n_user, n;
next = line;
copy_token(token, &next, &l);
if (copy_token(token, &next, &l) != DIGIT)
{
input_error++;
error_string = sformatf( "Expected equilibrium_phases number following EQUILIBRIUM_PHASES_MODIFY.\n%s\n", line_save);
error_msg(error_string, CONTINUE);
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
return (ERROR);
}
else
{
sscanf(token,"%d", &n_user);
}
/*
* Make parser
*/
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
parser.set_echo_file(CParser::EO_NONE);
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
if (pp_assemblage_bsearch(n_user, &n) == NULL)
{
input_error++;
error_string = sformatf( "Equlibrium_phases %d not found for EQUILIBRIUM_PHASES_MODIFY.\n", n_user);
error_msg(error_string, CONTINUE);
return (ERROR);
}
// read entity
cxxPPassemblage entity(&(pp_assemblage[n]), phrq_io);
entity.read_raw(parser, false);
// save entity
//struct pp_assemblage *entity_ptr = entity.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
struct pp_assemblage *entity_ptr = cxxPPassemblage2pp_assemblage(&entity);
pp_assemblage_free(&(pp_assemblage[n]));
pp_assemblage_copy(entity_ptr, &(pp_assemblage[n]), entity_ptr->n_user);
free_check_null(pp_assemblage[n].description);
pp_assemblage[n].description = string_duplicate(entity_ptr->description);
pp_assemblage[n].new_def = TRUE;
pp_assemblage[n].n_user_end = pp_assemblage[n].n_user;
pp_assemblage_free(entity_ptr);
free_check_null(entity_ptr);
// Need to output the next keyword
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_surface_modify(void)
@ -916,96 +630,6 @@ read_surface_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_solid_solutions_modify(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads SOLID_SOLUTIONS_MODIFY data block
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
// find solid_solutions number
char token[MAX_LENGTH];
char *next;
int l, n_user, n;
next = line;
copy_token(token, &next, &l);
if (copy_token(token, &next, &l) != DIGIT)
{
input_error++;
error_string = sformatf( "Expected solid_solutions number following SOLID_SOLUTIONS_MODIFY.\n%s\n", line_save);
error_msg(error_string, CONTINUE);
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
return (ERROR);
}
else
{
sscanf(token,"%d", &n_user);
}
/*
* Make parser
*/
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
parser.set_echo_file(CParser::EO_NONE);
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
if (ss_assemblage_bsearch(n_user, &n) == NULL)
{
input_error++;
error_string = sformatf( "Solid_solutions %d not found for SOLID_SOLUTIONS_MODIFY.\n", n_user);
error_msg(error_string, CONTINUE);
return (ERROR);
}
// read entity
cxxSSassemblage entity(&(ss_assemblage[n]));
entity.read_raw(parser, false);
// save entity
//struct ss_assemblage *entity_ptr = entity.cxxSSassemblage2ss_assemblage(PHREEQC_THIS);
struct ss_assemblage *entity_ptr = cxxSSassemblage2ss_assemblage(&entity);
ss_assemblage_free(&(ss_assemblage[n]));
ss_assemblage_copy(entity_ptr, &(ss_assemblage[n]), entity_ptr->n_user);
free_check_null(ss_assemblage[n].description);
ss_assemblage[n].description = string_duplicate(entity_ptr->description);
ss_assemblage_free(entity_ptr);
free_check_null(entity_ptr);
// Need to output the next keyword
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_kinetics_modify(void)
@ -1237,30 +861,6 @@ delete_entities(void)
}
}
}
#ifdef SKIP
if (delete_info.Get_pp_assemblage().Get_defined())
{
if (delete_info.Get_pp_assemblage().Get_numbers().size() == 0)
{
for (i = 0; i < count_pp_assemblage; i++)
{
pp_assemblage_delete(pp_assemblage[i].n_user);
}
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_pp_assemblage().Get_numbers().begin(); it != delete_info.Get_pp_assemblage().Get_numbers().end(); it++)
{
if (pp_assemblage_bsearch(*it, &n) != NULL)
{
pp_assemblage_delete(*it);
}
}
}
}
#endif
// exchangers
if (delete_info.Get_exchange().Get_defined())
{
@ -1316,29 +916,6 @@ delete_entities(void)
}
}
}
#ifdef SKIP
if (delete_info.Get_ss_assemblage().Get_defined())
{
if (delete_info.Get_ss_assemblage().Get_numbers().size() == 0)
{
for (i = 0; i < count_ss_assemblage; i++)
{
ss_assemblage_delete(ss_assemblage[i].n_user);
}
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_ss_assemblage().Get_numbers().begin(); it != delete_info.Get_ss_assemblage().Get_numbers().end(); it++)
{
if (ss_assemblage_bsearch(*it, &n) != NULL)
{
ss_assemblage_delete(*it);
}
}
}
}
#endif
// gas_phases
if (delete_info.Get_gas_phase().Get_defined())
{
@ -1718,32 +1295,6 @@ dump_ostream(std::ostream& os)
}
}
}
#ifdef SKIP
if (dump_info.Get_bool_pp_assemblage())
{
if (dump_info.Get_pp_assemblage().size() == 0)
{
for (i = 0; i < count_pp_assemblage; i++)
{
cxxPPassemblage cxxentity(&pp_assemblage[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_pp_assemblage().begin(); it != dump_info.Get_pp_assemblage().end(); it++)
{
if (pp_assemblage_bsearch(*it, &n) != NULL)
{
cxxPPassemblage cxxentity(&pp_assemblage[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
}
}
#endif
// exchanges
if (dump_info.Get_bool_exchange())
{
@ -1813,32 +1364,6 @@ dump_ostream(std::ostream& os)
}
}
}
#ifdef SKIP
if (dump_info.Get_bool_ss_assemblage())
{
if (dump_info.Get_ss_assemblage().size() == 0)
{
for (i = 0; i < count_ss_assemblage; i++)
{
cxxSSassemblage cxxentity(&ss_assemblage[i]);
cxxentity.dump_raw(os,0);
}
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_ss_assemblage().begin(); it != dump_info.Get_ss_assemblage().end(); it++)
{
if (ss_assemblage_bsearch(*it, &n) != NULL)
{
cxxSSassemblage cxxentity(&ss_assemblage[n]);
cxxentity.dump_raw(os,0);
}
}
}
}
#endif
// gas_phases
if (dump_info.Get_bool_gas_phase())
{

89
SS.cxx
View File

@ -44,37 +44,6 @@ PHRQ_base(io)
p.push_back(0);
}
}
#ifdef SKIP
cxxSS::cxxSS(struct s_s *s_s_ptr, PHRQ_io *io)
:
PHRQ_base(io) //
// constructor for cxxSS from struct s_s
//
{
this->Set_name(s_s_ptr->name);
//total_moles = s_s_ptr->total_moles;
a0 = s_s_ptr->a0;
a1 = s_s_ptr->a1;
ag0 = s_s_ptr->ag0;
ag1 = s_s_ptr->ag1;
miscibility = (s_s_ptr->miscibility == TRUE);
//spinodal = (s_s_ptr->spinodal == TRUE);
//tk = s_s_ptr->tk;
xb1 = s_s_ptr->xb1;
xb2 = s_s_ptr->xb2;
//type = s_s_ptr->input_case;
/*
for (i = 0; i < 4; i++) {
p[i] = s_s_ptr->p[i];
}
*/
int i;
for (i = 0; i < s_s_ptr->count_comps; i++)
{
comps[s_s_ptr->comps[i].name] = s_s_ptr->comps[i].moles;
}
}
#endif
cxxSS::~cxxSS()
{
}
@ -543,31 +512,6 @@ cxxSS::totalize(PHREEQC_PTR_ARG)
}
return;
}
#ifdef SKIP
void
cxxSS::totalize(PHREEQC_PTR_ARG)
{
this->totals.clear();
// component structures
for (cxxNameDouble::const_iterator it = this->comps.begin();
it != this->comps.end(); it++)
{
struct phase *phase_ptr;
int l;
phase_ptr = P_INSTANCE_POINTER phase_bsearch(it->first.c_str(), &l, FALSE);
if (phase_ptr != NULL)
{
cxxNameDouble phase_formula(phase_ptr->next_elt);
this->totals.add_extensive(phase_formula, it->second);
}
else
{
assert(false);
}
}
return;
}
#endif
void
cxxSS::add(const cxxSS & addee_in, LDBLE extensive)
{
@ -608,26 +552,6 @@ cxxSS::add(const cxxSS & addee_in, LDBLE extensive)
}
}
}
#ifdef SKIP
void
cxxSS::add(const cxxSS & addee, LDBLE extensive)
{
if (extensive == 0.0)
return;
if (addee.name.size() == 0)
return;
// this and addee must have same name
// otherwise generate a new PPassemblagComp with multiply
//char *name;
//cxxNameDouble comps;
this->comps.add_extensive(addee.comps, extensive);
//LDBLE a0, a1;
//LDBLE ag0, ag1;
//bool miscibility;
//LDBLE xb1, xb2;
}
#endif
void
cxxSS::multiply(LDBLE extensive)
{
@ -644,19 +568,6 @@ cxxSS::multiply(LDBLE extensive)
this->ss_comps[i].Set_delta(d);
}
}
#ifdef SKIP
void
cxxSS::multiply(LDBLE extensive)
{
//char *name;
//cxxNameDouble comps;
this->comps.multiply(extensive);
//LDBLE a0, a1;
//LDBLE ag0, ag1;
//bool miscibility;
//LDBLE xb1, xb2;
}
#endif
cxxSScomp *
cxxSS::Find(const char * comp_name)
{

7
SS.h
View File

@ -59,12 +59,7 @@ class cxxSS: public PHRQ_base
{
return (this->totals);
};
#ifdef SKIP
const cxxNameDouble & Get_comps() const
{
return (this->comps);
};
#endif
#ifdef USE_MPI
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);

View File

@ -27,26 +27,7 @@ cxxSSassemblage::cxxSSassemblage(PHRQ_io * io)
: cxxNumKeyword(io)
{
}
#ifdef SKIP
cxxSSassemblage::cxxSSassemblage(struct ss_assemblage * ss_assemblage_ptr, PHRQ_io * io)
//
// constructor for cxxSSassemblage from struct SSassemblage
//
:
cxxNumKeyword(io)
{
int i;
this->Set_description(ss_assemblage_ptr->description);
n_user = ss_assemblage_ptr->n_user;
n_user_end = ss_assemblage_ptr->n_user_end;
for (i = 0; i < ss_assemblage_ptr->count_s_s; i++)
{
cxxSS ssSS(&(ss_assemblage_ptr->s_s[i]), this->Get_io());
std::string str(ssSS.Get_name());
SSs[str] = ssSS;
}
}
#endif
cxxSSassemblage::cxxSSassemblage(const std::map < int,
cxxSSassemblage > &entities, cxxMix & mix,
int l_n_user, PHRQ_io * io):
@ -213,92 +194,6 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
break;
}
}
#ifdef SKIP
void
cxxSSassemblage::read_raw(CParser & parser, bool check)
{
static std::vector < std::string > vopts;
if (vopts.empty())
{
vopts.reserve(10);
vopts.push_back("solid_solution"); // 0
}
std::istream::pos_type ptr;
std::istream::pos_type next_char;
std::string token;
int opt_save;
bool useLastLine(false);
// Read SSassemblage number and description
this->read_number_description(parser);
opt_save = CParser::OPT_ERROR;
for (;;)
{
int opt;
if (useLastLine == false)
{
opt = parser.get_option(vopts, next_char);
}
else
{
opt = parser.getOptionFromLastLine(vopts, next_char);
}
if (opt == CParser::OPT_DEFAULT)
{
opt = opt_save;
}
switch (opt)
{
case CParser::OPT_EOF:
break;
case CParser::OPT_KEYWORD:
break;
case CParser::OPT_DEFAULT:
case CParser::OPT_ERROR:
opt = CParser::OPT_EOF;
parser.
error_msg("Unknown input in SOLID_SOLUTIONS_RAW or SOLID_SOLUTIONS_MODIFY keyword.",
PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false;
break;
case 0: // solid_solution
{
cxxSS ec(this->Get_io());
// preliminary read
parser.set_accumulate(true);
ec.read_raw(parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is, this->Get_io());
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->SSs.find(ec.Get_name()) != this->SSs.end())
{
cxxSS & ec1 = this->SSs.find(ec.Get_name())->second;
ec1.read_raw(reread, false);
}
else
{
cxxSS ec1(this->Get_io());
ec1.read_raw(reread, false);
std::string str(ec1.Get_name());
this->SSs[str] = ec1;
}
}
useLastLine = true;
break;
}
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
break;
}
}
#endif
#ifdef USE_MPI
/* ---------------------------------------------------------------------- */
void

View File

@ -36,26 +36,6 @@ PHRQ_base(io)
dnc = 0;
dnb = 0;
}
#ifdef SKIP
cxxSScomp::cxxSScomp(struct pure_phase * pure_phase_ptr, PHRQ_io *io)
:
PHRQ_base(io)
//
// constructor for cxxSScomp from struct pure_phase
//
{
this->Set_name(pure_phase_ptr->name);
this->Set_add_formula(pure_phase_ptr->add_formula);
si = pure_phase_ptr->si;
si_org = pure_phase_ptr->si_org;
moles = pure_phase_ptr->moles;
delta = pure_phase_ptr->delta;
initial_moles = pure_phase_ptr->initial_moles;
force_equality = (pure_phase_ptr->force_equality == TRUE);
dissolve_only = (pure_phase_ptr->dissolve_only == TRUE);
precipitate_only = (pure_phase_ptr->precipitate_only == TRUE);
}
#endif
cxxSScomp::~cxxSScomp()
{
}

View File

@ -174,7 +174,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
vopts.push_back("formula"); // 0
vopts.push_back("moles"); // 1
vopts.push_back("la"); // 2
vopts.push_back("charge_number"); // 3
vopts.push_back("charge_number_not_used"); // 3
vopts.push_back("charge_balance"); // 4
vopts.push_back("phase_name"); // 5
vopts.push_back("rate_name"); // 6
@ -257,18 +257,17 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
}
la_defined = true;
break;
#ifdef SKIP
case 3: // charge_number
if (!(parser.get_iss() >> this->charge_number))
{
this->charge_number = 0;
parser.incr_input_error();
parser.error_msg("Expected integer value for charge_number.",
PHRQ_io::OT_CONTINUE);
}
charge_number_defined = true;
case 3: // charge_number not used
//if (!(parser.get_iss() >> this->charge_number))
//{
// this->charge_number = 0;
// parser.incr_input_error();
// parser.error_msg("Expected integer value for charge_number.",
// PHRQ_io::OT_CONTINUE);
//}
//charge_number_defined = true;
break;
#endif
case 4: // charge_balance
if (!(parser.get_iss() >> this->charge_balance))
{
@ -397,14 +396,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
parser.error_msg("La not defined for SurfaceComp input.",
PHRQ_io::OT_CONTINUE);
}
#ifdef SKIP
if (charge_number_defined == false)
{
parser.incr_input_error();
parser.error_msg("Charge_number not defined for SurfaceComp input.",
PHRQ_io::OT_CONTINUE);
}
#endif
if (charge_balance_defined == false)
{
parser.incr_input_error();

View File

@ -12,14 +12,6 @@ namespace Utilities
{
const char INDENT[] = " ";
#ifdef SKIP
enum STATUS_TYPE
{
ST_OK = 0,
ST_ERROR = 1
};
#endif
//STATUS_TYPE parse_couple(std::string & token);
int strcmp_nocase(const char *str1, const char *str2);

View File

@ -727,20 +727,6 @@ equi_phase(const char *phase_name)
/*
* Print pure phase assemblage data
*/
#ifdef SKIP
if (j == count_unknowns)
{
/* if not an unknown */
for (i = 0; i < use.Get_pp_assemblage_ptr()->count_comps; i++)
{
if (strcmp_nocase
(use.Get_pp_assemblage_ptr()->pure_phases[i].name, phase_name) == 0)
{
return (use.Get_pp_assemblage_ptr()->pure_phases[i].moles);
}
}
}
#endif
cxxPPassemblage * pp_assemblage_ptr = (cxxPPassemblage *) use.Get_pp_assemblage_ptr();
if (j == count_unknowns)
{
@ -911,90 +897,6 @@ find_ss_comp(const char *ss_comp_name)
}
return (0);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
find_misc1(const char *s_s_name)
/* ---------------------------------------------------------------------- */
{
int j;
if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
return (0.0);
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
if (strcmp_nocase(use.Get_ss_assemblage_ptr()->s_s[j].name, s_s_name) == 0)
{
if (use.Get_ss_assemblage_ptr()->s_s[j].miscibility == TRUE)
{
return (use.Get_ss_assemblage_ptr()->s_s[j].xb1);
}
else
{
return (1.0);
}
}
}
return (0);
}
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
find_misc2(const char *s_s_name)
/* ---------------------------------------------------------------------- */
{
int j;
if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
return (0.0);
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
if (strcmp_nocase(use.Get_ss_assemblage_ptr()->s_s[j].name, s_s_name) == 0)
{
if (use.Get_ss_assemblage_ptr()->s_s[j].miscibility == TRUE)
{
return (use.Get_ss_assemblage_ptr()->s_s[j].xb2);
}
else
{
return (1.0);
}
}
}
return (0);
}
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
find_s_s_comp(const char *s_s_comp_name)
/* ---------------------------------------------------------------------- */
{
int i, j;
if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
return (0);
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; i++)
{
if (strcmp_nocase
(use.Get_ss_assemblage_ptr()->s_s[j].comps[i].name,
s_s_comp_name) == 0)
{
if (use.Get_ss_assemblage_ptr()->s_s[j].ss_in == TRUE)
{
return (use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles);
}
else
{
return (0.0);
}
}
}
}
return (0);
}
#endif
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
get_calculate_value(const char *name)
@ -1444,84 +1346,6 @@ list_ss(std::string ss_name, cxxNameDouble &composition)
}
return (tot);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
sum_match_s_s(const char *mytemplate, const char *name)
/* ---------------------------------------------------------------------- */
{
int i, j;
LDBLE tot;
struct elt_list *next_elt;
if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
return (0);
tot = 0;
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
if (strcmp_nocase(use.Get_ss_assemblage_ptr()->s_s[j].name, mytemplate) ==
0)
{
if (use.Get_ss_assemblage_ptr()->s_s[j].ss_in == FALSE)
{
tot = 0;
break;
}
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; i++)
{
if (name == NULL)
{
tot += use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles;
}
else
{
for (next_elt =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].phase->
next_elt; next_elt->elt != NULL; next_elt++)
{
if (strcmp(next_elt->elt->name, name) == 0)
{
tot +=
next_elt->coef *
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles;
break;
}
}
}
}
break;
}
}
return (tot);
}
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
list_s_s(std::string s_s_name, cxxNameDouble &composition)
/* ---------------------------------------------------------------------- */
{
int i, j;
LDBLE tot = 0;
composition.clear();
if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
return (0);
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
if (strcmp_nocase(use.Get_ss_assemblage_ptr()->s_s[j].name, s_s_name.c_str()) == 0)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; i++)
{
composition.add(use.Get_ss_assemblage_ptr()->s_s[j].comps[i].name, use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles);
tot += use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles;
}
break;
}
}
return (tot);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
match_elts_in_species(const char *name, const char *mytemplate)
@ -2440,41 +2264,6 @@ system_total_ss(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
system_total_s_s(void)
/* ---------------------------------------------------------------------- */
{
/*
* Provides total moles in system and lists of species/phases in sort order
*/
int i, k;
/*
* Solid solutions
*/
if (use.Get_ss_assemblage_ptr() == NULL)
return (OK);
for (k = 0; k < use.Get_ss_assemblage_ptr()->count_s_s; k++)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[k].count_comps; i++)
{
sys[count_sys].name =
string_duplicate(use.Get_ss_assemblage_ptr()->s_s[k].comps[i].
phase->name);
sys[count_sys].moles =
use.Get_ss_assemblage_ptr()->s_s[k].comps[i].moles;
sys_tot += sys[count_sys].moles;
sys[count_sys].type = string_duplicate("s_s");
count_sys++;
space((void **) ((void *) &sys), count_sys, &max_sys,
sizeof(struct system_species));
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
system_total_elt(const char *total_name)
@ -2700,50 +2489,6 @@ system_total_elt(const char *total_name)
}
}
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
for (k = 0; k < use.Get_ss_assemblage_ptr()->count_s_s; k++)
{
if (use.Get_ss_assemblage_ptr()->s_s[k].ss_in == TRUE)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[k].count_comps;
i++)
{
count_elts = 0;
paren_count = 0;
add_elt_list(use.Get_ss_assemblage_ptr()->s_s[k].comps[i].
phase->next_elt,
use.Get_ss_assemblage_ptr()->s_s[k].comps[i].
moles);
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list),
elt_list_compare);
elt_list_combine();
}
for (j = 0; j < count_elts; j++)
{
if (strcmp(elt_list[j].elt->name, total_name) == 0)
{
sys[count_sys].name =
string_duplicate(use.Get_ss_assemblage_ptr()->
s_s[k].comps[i].phase->name);
sys[count_sys].moles = elt_list[j].coef;
sys_tot += sys[count_sys].moles;
sys[count_sys].type = string_duplicate("s_s");
count_sys++;
space((void **) ((void *) &sys), count_sys,
&max_sys, sizeof(struct system_species));
break;
}
}
}
}
}
}
#endif
/*
* find total in gas phase
*/
@ -3017,50 +2762,6 @@ system_total_elt_secondary(const char *total_name)
}
}
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
for (k = 0; k < use.Get_ss_assemblage_ptr()->count_s_s; k++)
{
if (use.Get_ss_assemblage_ptr()->s_s[k].ss_in == TRUE)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[k].count_comps;
i++)
{
count_elts = 0;
paren_count = 0;
add_elt_list(use.Get_ss_assemblage_ptr()->s_s[k].comps[i].
phase->next_sys_total,
use.Get_ss_assemblage_ptr()->s_s[k].comps[i].
moles);
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list),
elt_list_compare);
elt_list_combine();
}
for (j = 0; j < count_elts; j++)
{
if (strcmp(elt_list[j].elt->name, total_name) == 0)
{
sys[count_sys].name =
string_duplicate(use.Get_ss_assemblage_ptr()->
s_s[k].comps[i].phase->name);
sys[count_sys].moles = elt_list[j].coef;
sys_tot += sys[count_sys].moles;
sys[count_sys].type = string_duplicate("s_s");
count_sys++;
space((void **) ((void *) &sys), count_sys,
&max_sys, sizeof(struct system_species));
break;
}
}
}
}
}
}
#endif
/*
* find total in gas phase
*/
@ -3224,20 +2925,6 @@ system_total_solids(cxxExchange *exchange_ptr,
}
}
}
#ifdef SKIP
if (ss_assemblage_ptr != NULL)
{
for (i = 0; i < ss_assemblage_ptr->count_s_s; i++)
{
for (j = 0; j < ss_assemblage_ptr->s_s[i].count_comps; j++)
{
add_elt_list(ss_assemblage_ptr->s_s[i].comps[j].phase->
next_elt,
ss_assemblage_ptr->s_s[i].comps[j].moles);
}
}
}
#endif
if (gas_phase_ptr != NULL)
{
for (size_t j = 0; j < gas_phase_ptr->Get_gas_comps().size(); j++)

View File

@ -487,80 +487,7 @@ struct save
int n_ss_assemblage_user;
int n_ss_assemblage_user_end;
};
#ifdef SKIP
/*----------------------------------------------------------------------
* Use
*---------------------------------------------------------------------- */
struct Use
{
int solution_in;
int n_solution_user;
int n_solution;
struct solution *solution_ptr;
int pp_assemblage_in;
int n_pp_assemblage_user;
//int n_pp_assemblage;
//struct pp_assemblage *pp_assemblage_ptr;
void *pp_assemblage_ptr;
int mix_in;
int n_mix_user;
int n_mix;
//struct mix *mix_ptr;
void * mix_ptr;
int n_mix_user_orig;
int reaction_in;
int n_reaction_user;
//int n_irrev;
//struct irrev *irrev_ptr;
void * reaction_ptr;
int exchange_in;
int n_exchange_user;
//int n_exchange;
//struct exchange *exchange_ptr;
void * exchange_ptr;
int kinetics_in;
int n_kinetics_user;
int n_kinetics;
struct kinetics *kinetics_ptr;
int surface_in;
int n_surface_user;
int n_surface;
struct surface *surface_ptr;
int pressure_in;
int n_pressure_user;
void *pressure_ptr;
int temperature_in;
int n_temperature_user;
void *temperature_ptr;
int inverse_in;
int n_inverse_user;
int n_inverse;
struct inverse *inverse_ptr;
int gas_phase_in;
int n_gas_phase_user;
//int n_gas_phase;
//struct gas_phase *gas_phase_ptr;
void * gas_phase_ptr;
int ss_assemblage_in;
int n_ss_assemblage_user;
int n_ss_assemblage;
struct ss_assemblage *ss_assemblage_ptr;
int trans_in;
int advect_in;
};
#endif
/*----------------------------------------------------------------------
* Copy
*---------------------------------------------------------------------- */
@ -648,81 +575,6 @@ struct name_coef
const char *name;
LDBLE coef;
};
#ifdef SKIP
/*----------------------------------------------------------------------
* Solid solution
*---------------------------------------------------------------------- */
struct ss_assemblage
{
int n_user;
int n_user_end;
char *description;
int new_def;
/* int type; */
/* int solution_equilibria; */
/* int n_solution; */
int count_s_s;
struct s_s *s_s;
};
struct s_s
{
const char *name;
struct s_s_comp *comps;
int count_comps;
LDBLE total_moles;
LDBLE dn;
LDBLE a0, a1;
LDBLE ag0, ag1;
int ss_in;
int miscibility;
int spinodal;
LDBLE tk, xb1, xb2;
int input_case;
LDBLE p[4];
};
struct s_s_comp
{
const char *name;
struct phase *phase;
LDBLE initial_moles;
LDBLE moles;
LDBLE init_moles;
LDBLE delta;
LDBLE fraction_x;
LDBLE log10_lambda;
LDBLE log10_fraction_x;
LDBLE dn, dnc, dnb;
};
#endif
#ifdef SKIP
/*----------------------------------------------------------------------
* Pure-phase assemblage
*---------------------------------------------------------------------- */
struct pp_assemblage
{
int n_user;
int n_user_end;
char *description;
int new_def;
struct elt_list *next_elt;
int count_comps;
struct pure_phase *pure_phases;
};
struct pure_phase
{
struct phase *phase;
const char *name;
const char *add_formula;
LDBLE si;
LDBLE si_org;
LDBLE moles;
LDBLE delta;
LDBLE initial_moles;
int force_equality;
int dissolve_only;
int precipitate_only;
};
#endif
/*----------------------------------------------------------------------
* Species_list
*---------------------------------------------------------------------- */

View File

@ -319,26 +319,6 @@ rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
{
set_reaction(i, NOMIX, TRUE);
}
#ifdef SKIP
if (use.Get_pp_assemblage_ptr() != NULL)
{
pp_assemblage_save =
(struct pp_assemblage *)
PHRQ_malloc(sizeof(struct pp_assemblage));
if (pp_assemblage_save == NULL)
malloc_error();
}
#endif
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
ss_assemblage_save =
(struct ss_assemblage *)
PHRQ_malloc(sizeof(struct ss_assemblage));
if (ss_assemblage_save == NULL)
malloc_error();
}
#endif
kinetics_ptr = kinetics_bsearch(i, &m);
step_bad = step_ok = 0;
@ -1161,18 +1141,6 @@ set_and_run_wrapper(int i, int use_mix, int use_kinetics, int nsaver,
}
ss_assemblage_save = new cxxSSassemblage(*ss_assemblage_ptr);
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
ss_assemblage_save =
(struct ss_assemblage *)
PHRQ_malloc(sizeof(struct ss_assemblage));
if (ss_assemblage_save == NULL)
malloc_error();
ss_assemblage_copy(use.Get_ss_assemblage_ptr(), ss_assemblage_save,
use.Get_ss_assemblage_ptr()->n_user);
}
#endif
if (use.Get_kinetics_ptr() != NULL)
{
kinetics_save =
@ -2081,16 +2049,6 @@ run_reactions(int i, LDBLE kin_time, int use_mix, LDBLE step_fraction)
if (ss_assemblage_ptr != NULL)
{
cvode_ss_assemblage_save = new cxxSSassemblage(*ss_assemblage_ptr);
#ifdef SKIP
cvode_ss_assemblage_save =
(struct ss_assemblage *)
PHRQ_malloc(sizeof(struct ss_assemblage));
if (cvode_ss_assemblage_save == NULL)
malloc_error();
ss_assemblage_copy(ss_assemblage_ptr,
cvode_ss_assemblage_save,
ss_assemblage_ptr->n_user);
#endif
}
/* allocate space for CVODE */
@ -2600,19 +2558,6 @@ store_get_equi_reactants(int l, int kin_end)
count_ss += (int) ss_ptr->Get_ss_comps().size();
}
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps;
i++)
{
count_s_s++;
}
}
}
#endif
k = count_pp + count_ss + count_pg;
x0_moles = NULL;
if (k == 0)
@ -2634,12 +2579,7 @@ store_get_equi_reactants(int l, int kin_end)
x0_moles[++k] = it->second.Get_moles();
}
}
#ifdef SKIP
for (j = 0; j < count_pp; j++)
{
x0_moles[++k] = use.Get_pp_assemblage_ptr()->pure_phases[j].moles;
}
#endif
{
cxxGasPhase *gas_phase_ptr = (cxxGasPhase *) use.Get_gas_phase_ptr();
if (gas_phase_ptr)
@ -2679,13 +2619,7 @@ store_get_equi_reactants(int l, int kin_end)
it->second.Set_delta(0.0);
}
}
#ifdef SKIP
for (j = 0; j < count_pp; j++)
{
use.Get_pp_assemblage_ptr()->pure_phases[j].moles = x0_moles[++k];
use.Get_pp_assemblage_ptr()->pure_phases[j].delta = 0.0;
}
#endif
{
cxxGasPhase *gas_phase_ptr = (cxxGasPhase *) use.Get_gas_phase_ptr();
if (gas_phase_ptr && count_pg)

View File

@ -1827,10 +1827,7 @@ xss_assemblage_save(int n_user)
* Save ss_assemblage composition into structure ss_assemblage with user
* number n_user.
*/
//int i, j, n;
//int count_comps, count_s_s;
cxxSSassemblage temp_ss_assemblage;
//char token[MAX_LENGTH];
if (use.Get_ss_assemblage_ptr() == NULL)
return (OK);
@ -1864,97 +1861,6 @@ xss_assemblage_save(int n_user)
use.Set_ss_assemblage_ptr(NULL);
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
xss_assemblage_save(int n_user)
/* ---------------------------------------------------------------------- */
{
/*
* Save ss_assemblage composition into structure ss_assemblage with user
* number n_user.
*/
int i, j, n;
int count_comps, count_s_s;
struct ss_assemblage temp_ss_assemblage, *ss_assemblage_ptr;
char token[MAX_LENGTH];
if (use.Get_ss_assemblage_ptr() == NULL)
return (OK);
/*
* Set ss_assemblage
*/
temp_ss_assemblage.n_user = n_user;
temp_ss_assemblage.n_user_end = n_user;
sprintf(token, "Solid solution assemblage after simulation %d.",
simulation);
temp_ss_assemblage.description = string_duplicate(token);
temp_ss_assemblage.new_def = FALSE;
count_s_s = use.Get_ss_assemblage_ptr()->count_s_s;
temp_ss_assemblage.count_s_s = count_s_s;
/*
* Malloc space for solid solutions
*/
/* ss_assemblage->s_s */
temp_ss_assemblage.s_s =
(struct s_s *) PHRQ_malloc((size_t) count_s_s * sizeof(struct s_s));
if (temp_ss_assemblage.s_s == NULL)
malloc_error();
for (i = 0; i < count_s_s; i++)
{
memcpy(&(temp_ss_assemblage.s_s[i]),
&(use.Get_ss_assemblage_ptr()->s_s[i]), sizeof(struct s_s));
/*
* Malloc space for solid soution components
*/
count_comps = use.Get_ss_assemblage_ptr()->s_s[i].count_comps;
temp_ss_assemblage.s_s[i].comps =
(struct s_s_comp *) PHRQ_malloc((size_t) count_comps *
sizeof(struct s_s_comp));
if (temp_ss_assemblage.s_s[i].comps == NULL)
malloc_error();
memcpy((void *) temp_ss_assemblage.s_s[i].comps,
(void *) use.Get_ss_assemblage_ptr()->s_s[i].comps,
(size_t) count_comps * sizeof(struct s_s_comp));
/* set initial moles for quick setup */
for (j = 0; j < count_comps; j++)
{
temp_ss_assemblage.s_s[i].comps[j].initial_moles =
temp_ss_assemblage.s_s[i].comps[j].moles;
}
}
/*
* Finish up
*/
ss_assemblage_ptr = ss_assemblage_bsearch(n_user, &n);
if (ss_assemblage_ptr == NULL)
{
space((void **) ((void *) &ss_assemblage), count_ss_assemblage,
&max_ss_assemblage, sizeof(struct ss_assemblage));
n = count_ss_assemblage++;
}
else
{
ss_assemblage_free(&ss_assemblage[n]);
}
memcpy(&ss_assemblage[n], &temp_ss_assemblage,
sizeof(struct ss_assemblage));
/* sort only if necessary */
if (n == count_ss_assemblage - 1 && count_ss_assemblage > 1)
{
if (ss_assemblage[n].n_user < ss_assemblage[n - 1].n_user)
{
qsort(ss_assemblage,
(size_t) count_ss_assemblage,
(size_t) sizeof(struct ss_assemblage),
ss_assemblage_compare);
}
}
use.Set_ss_assemblage_ptr(NULL);
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
xpp_assemblage_save(int n_user)
@ -1996,92 +1902,6 @@ xpp_assemblage_save(int n_user)
use.Set_pp_assemblage_ptr(NULL);
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
xpp_assemblage_save(int n_user)
/* ---------------------------------------------------------------------- */
{
/*
* Save pure_phase assemblage into structure pp_assemblage with user
* number n_user.
*/
int count_comps, n, j, i;
struct pp_assemblage temp_pp_assemblage, *pp_assemblage_ptr;
char token[MAX_LENGTH];
if (use.Get_pp_assemblage_ptr() == NULL)
return (OK);
/*
* Count pure phases
*/
count_comps = use.Get_pp_assemblage_ptr()->count_comps;
temp_pp_assemblage.n_user = n_user;
temp_pp_assemblage.n_user_end = n_user;
sprintf(token, "Pure-phase assemblage after simulation %d.", simulation);
temp_pp_assemblage.description = string_duplicate(token);
temp_pp_assemblage.new_def = FALSE;
temp_pp_assemblage.count_comps = count_comps;
temp_pp_assemblage.next_elt =
elt_list_dup(use.Get_pp_assemblage_ptr()->next_elt);
/*
* Malloc space and copy pure phase data
*/
temp_pp_assemblage.pure_phases =
(struct pure_phase *) PHRQ_malloc((size_t) count_comps *
sizeof(struct pure_phase));
if (temp_pp_assemblage.pure_phases == NULL)
malloc_error();
memcpy((void *) temp_pp_assemblage.pure_phases,
(void *) use.Get_pp_assemblage_ptr()->pure_phases,
(size_t) count_comps * sizeof(struct pure_phase));
/*
* Update amounts
*/
i = 0;
for (j = 0; j < count_unknowns; j++)
{
if (x[j]->type != PP)
continue;
temp_pp_assemblage.pure_phases[i].moles = x[j]->moles;
temp_pp_assemblage.pure_phases[i].delta = 0.0;
/* update unknown ptr, old may be freed later */
x[j]->pure_phase = &(temp_pp_assemblage.pure_phases[i]);
i++;
}
/*
* Finish up
*/
pp_assemblage_ptr = pp_assemblage_bsearch(n_user, &n);
if (pp_assemblage_ptr == NULL)
{
space((void **) ((void *) &pp_assemblage), count_pp_assemblage,
&max_pp_assemblage, sizeof(struct pp_assemblage));
n = count_pp_assemblage++;
}
else
{
pp_assemblage_free(&pp_assemblage[n]);
}
memcpy(&pp_assemblage[n], &temp_pp_assemblage,
sizeof(struct pp_assemblage));
/* sort only if necessary */
if (n == count_pp_assemblage - 1 && count_pp_assemblage > 1)
{
if (pp_assemblage[n].n_user < pp_assemblage[n - 1].n_user)
{
qsort(pp_assemblage,
(size_t) count_pp_assemblage,
(size_t) sizeof(struct pp_assemblage),
pp_assemblage_compare);
}
}
use.Get_pp_assemblage_ptr() = NULL;
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
xsolution_save(int n_user)
@ -2851,62 +2671,6 @@ step_save_exch(int n_user)
Rxn_exchange_map[n_user] = temp_exchange;
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
step_save_exch(int n_user)
/* ---------------------------------------------------------------------- */
{
/*
* Save exchange composition
*
* input: n_user is user exchange number of target
*/
//int i;
bool found;
if (use.Get_exchange_ptr() == NULL)
return (OK);
//exchange_duplicate(use.Get_exchange_ptr()->n_user, n_user);
//exchange_ptr = exchange_bsearch(n_user, &n);
cxxExchange *temp_ptr = Utilities::Rxn_find(Rxn_exchange_map, use.Get_n_exchange_user());
assert(temp_ptr);
cxxExchange temp_exchange = *temp_ptr;
for (int i = 0; i < count_master; i++)
{
if (master[i]->s->type != EX)
continue;
found = false;
std::string e(master[i]->elt->name);
std::map<std::string, cxxExchComp>::iterator it = temp_exchange.Get_exchComps().begin();
for ( ; it != temp_exchange.Get_exchComps().end(); it++)
{
cxxNameDouble nd = it->second.Get_totals();
nd.multiply(0.0);
cxxNameDouble::iterator nd_it =nd.find(e);
if ((!found) && nd_it != nd.end())
{
found = true;
LDBLE coef;
if (master[i]->total <= MIN_TOTAL)
{
coef = MIN_TOTAL;
}
else
{
coef = master[i]->total;
}
nd[nd_it->first.c_str()] = coef;
}
it->second.Set_totals(nd);
}
}
Rxn_exchange_map[n_user] = temp_exchange;
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
step_save_surf(int n_user)
@ -3503,70 +3267,3 @@ save_init(int i)
save.n_ss_assemblage_user = i;
save.n_ss_assemblage_user_end = i;
}
#ifdef SKIP
void Phreeqc::
use_init(void)
{
use.Get_solution_in() = FALSE;
use.Get_n_solution_user()= -1;
use.Get_n_solution()= -1;
use.Get_solution_ptr() = NULL;
use.Get_pp_assemblage_in() = FALSE;
use.Get_n_pp_assemblage_user()= -1;
//use.n_pp_assemblage= -1;
use.Get_pp_assemblage_ptr() = NULL;
use.Get_mix_in() = FALSE;
use.Get_n_mix_user()= -1;
//use.n_mix= -1;
use.Get_mix_ptr() = NULL;
use.Get_n_mix_user_orig()= -1;
use.Get_reaction_in() = FALSE;
use.Get_n_reaction_user()= -1;
//use.n_irrev= -1;
use.Get_reaction_ptr() = NULL;
use.Get_exchange_in() = FALSE;
use.Get_n_exchange_user()= -1;
//use.n_exchange= -1;
use.Get_exchange_ptr() = NULL;
use.Get_kinetics_in() = FALSE;
use.Get_n_kinetics_user()= -1;
use.n_kinetics= -1;
use.Get_kinetics_ptr() = NULL;
use.Get_surface_in() = FALSE;
use.Get_n_surface_user()= -1;
use.n_surface= -1;
use.Get_surface_ptr() = NULL;
use.Get_temperature_in() = FALSE;
use.Get_n_temperature_user()= -1;
use.Get_temperature_ptr() = NULL;
use.Get_pressure_in() = FALSE;
use.Get_n_pressure_user()= -1;
use.Get_pressure_ptr() = NULL;
use.Get_inverse_in() = FALSE;
use.Get_n_inverse_user()= -1;
use.n_inverse= -1;
use.Get_inverse_ptr() = NULL;
use.Get_gas_phase_in() = FALSE;
use.Get_n_gas_phase_user()= -1;
//use.n_gas_phase= -1;
use.Get_gas_phase_ptr() = NULL;
use.Get_ss_assemblage_in() = FALSE;
use.Get_n_ss_assemblage_user()= -1;
use.n_ss_assemblage= -1;
use.Get_ss_assemblage_ptr() = NULL;
use.trans_in = FALSE;
use.advect_in = FALSE;
}
#endif

View File

@ -457,61 +457,6 @@ check_residuals(void)
}
}
}
#ifdef SKIP
else if (x[i]->type == PP)
{
if (x[i]->pure_phase->add_formula == NULL)
{
if (x[i]->dissolve_only == TRUE)
{
if ((residual[i] > epsilon && x[i]->moles > 0.0)
||
((residual[i] < -epsilon
&& (x[i]->pure_phase->initial_moles - x[i]->moles) >
0)))
{
log_msg(sformatf(
"%20s Dissolve_only pure phase has not converged. \tResidual: %e\n",
x[i]->description, (double) residual[i]));
}
}
else
{
if ((residual[i] >= epsilon
&& x[i]->moles > 0.0) /* || stop_program == TRUE */ )
{
remove_unstable_phases = TRUE;
log_msg(sformatf(
"%20s Pure phase has not converged. \tResidual: %e\n",
x[i]->description, (double) residual[i]));
}
else if (residual[i] <= -epsilon)
{
error_string = sformatf(
"%20s Pure phase has not converged. "
"\tResidual: %e\n", x[i]->description,
(double) residual[i]);
error_msg(error_string, CONTINUE);
}
}
}
else
{
if ((fabs(residual[i]) >= epsilon
&& x[i]->moles > 0.0) /* || stop_program == TRUE */ )
{
log_msg(sformatf(
"%s, Pure phase has not converged. \tResidual: %e\n",
x[i]->description, (double) residual[i]));
error_string = sformatf(
"%s, Pure phase with add formula has not converged.\n\t SI may be a local minimum."
"\tResidual: %e\n", x[i]->description,
(double) residual[i]);
warning_msg(error_string);
}
}
}
#endif
else if (x[i]->type == EXCH)
{
if ( /* stop_program == TRUE || */
@ -1028,30 +973,6 @@ ineq(int in_kode)
}
}
}
#ifdef SKIP
for (i = 0; i < count_unknowns; i++)
{
if (x[i]->type == PP && residual[i] > 0e-8 && x[i]->moles > 0 &&
x[i]->pure_phase->add_formula == NULL
&& x[i]->dissolve_only == FALSE)
{
/*
* Set mass transfer to all of phase
*/
delta[i] = x[i]->moles;
}
else
{
delta[i] = 0.0;
}
if (debug_model == TRUE)
{
output_msg(sformatf( "%6d %-12.12s %10.2e\n", i,
x[i]->description, (double) delta[i]));
}
}
#endif
remove_unstable_phases = FALSE;
return (OK);
}
@ -1307,57 +1228,6 @@ ineq(int in_kode)
l_count_rows++;
}
}
#ifdef SKIP
if (x[i]->type == PP)
{
/* not in model, ignore */
if (x[i]->pure_phase->phase->in == FALSE)
continue;
if (x[i]->pure_phase->force_equality == TRUE)
continue;
/* Undersaturated and no mass, ignore */
if (x[i]->f > 0e-8 && x[i]->moles <= 0
&& x[i]->pure_phase->add_formula == NULL)
{
continue;
}
else if (x[i]->f < 0e-8 && x[i]->dissolve_only == TRUE
&& (x[i]->moles - x[i]->pure_phase->initial_moles >= 0))
{
continue;
}
else
{
/* Copy in saturation index equation (has mass or supersaturated) */
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
(void *) &(array[i * (count_unknowns + 1)]),
(size_t) (count_unknowns + 1) * sizeof(LDBLE));
back_eq[l_count_rows] = i;
if (x[i]->pure_phase->add_formula == NULL
&& x[i]->dissolve_only == FALSE)
{
res[l_count_rows] = 1.0;
}
/*
* If infeasible solution on first attempt, remove constraints on IAP
*/
if (pp_scale != 1)
{
for (j = 0; j < count_unknowns + 1; j++)
{
ineq_array[l_count_rows * max_column_count + j] *=
pp_scale;
}
}
if (in_kode != 1)
{
res[l_count_rows] = 0.0;
}
l_count_rows++;
}
}
#endif
else if (x[i]->type == ALK || x[i]->type == SOLUTION_PHASE_BOUNDARY)
{
/*
@ -1680,35 +1550,6 @@ ineq(int in_kode)
}
}
}
#ifdef SKIP
/*
* No moles of surface
*/
if (use.Get_surface_ptr() != NULL
&& (use.Get_surface_ptr()->related_phases == TRUE
|| use.Get_surface_ptr()->related_rate == TRUE))
{
for (i = 0; i < count_unknowns; i++)
{
if ((x[i]->type == SURFACE && x[i]->phase_unknown != NULL &&
/* x[i]->phase_unknown->f > 0e-8 && */
x[i]->phase_unknown->moles <= MIN_RELATED_SURFACE &&
x[i]->phase_unknown->pure_phase->add_formula == NULL) ||
((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|| x[i]->type == SURFACE_CB2)
&& x[i - 1]->phase_unknown != NULL &&
/* x[i-1]->phase_unknown->f > 0e-8 && */
x[i]->surface_charge->grams <= MIN_RELATED_SURFACE &&
x[i - 1]->phase_unknown->pure_phase->add_formula == NULL))
{
for (j = 0; j < l_count_rows; j++)
{
ineq_array[j * max_column_count + i] = 0.0;
}
}
}
}
#endif
/*
* No moles of surface
*/
@ -2431,129 +2272,6 @@ mb_ss(void)
//x[i]->ss_in = x[i]->s_s->ss_in;
x[i]->ss_in = ss_ptr->Get_ss_in() ? TRUE : FALSE;
}
#ifdef SKIP
for (i = 0; i < use.Get_ss_assemblage_ptr()->count_s_s; i++)
{
s_s_ptr = &(use.Get_ss_assemblage_ptr()->s_s[i]);
total_moles = 0;
for (j = 0; j < s_s_ptr->count_comps; j++)
{
total_moles += s_s_ptr->comps[j].moles;
}
if (total_moles > 1e-13)
{
s_s_ptr->ss_in = TRUE;
}
else if (s_s_ptr->a0 != 0.0 || s_s_ptr->a1 != 0.0)
{
/*
* Calculate IAPc and IAPb
*/
if (s_s_ptr->comps[0].phase->rxn_x != NULL)
{
log10_iap = 0;
for (rxn_ptr = s_s_ptr->comps[0].phase->rxn_x->token + 1;
rxn_ptr->s != NULL; rxn_ptr++)
{
log10_iap += rxn_ptr->s->la * rxn_ptr->coef;
}
iapc = exp(log10_iap * LOG_10);
}
else
{
iapc = 1e-99;
}
if (s_s_ptr->comps[1].phase->rxn_x != NULL)
{
log10_iap = 0;
for (rxn_ptr = s_s_ptr->comps[1].phase->rxn_x->token + 1;
rxn_ptr->s != NULL; rxn_ptr++)
{
log10_iap += rxn_ptr->s->la * rxn_ptr->coef;
}
iapb = exp(log10_iap * LOG_10);
}
else
{
iapb = 1e-99;
}
/*
* Calculate sigma pi, aq
*/
sigmapi_aq = iapc + iapb;
/*
* Calculate xc,aq and xb, aq
*/
xcaq = iapc / (iapb + iapc);
xbaq = iapb / (iapb + iapc);
/*
* Get Kc and Kb
*/
l_kc = exp(s_s_ptr->comps[0].phase->lk * LOG_10);
l_kb = exp(s_s_ptr->comps[1].phase->lk * LOG_10);
/*
* Solve for xb
*/
xb = s_s_root(s_s_ptr->a0, s_s_ptr->a1, l_kc, l_kb, xcaq, xbaq);
/*
* Calculate lambdac and lambdab
*/
xc = 1 - xb;
lc = exp((s_s_ptr->a0 - s_s_ptr->a1 * (-4 * xb + 3)) * xb * xb);
lb = exp((s_s_ptr->a0 + s_s_ptr->a1 * (4 * xb - 1)) * xc * xc);
/*
* Calculate sigma pi, solid
*/
sigmapi_solid = xb * lb * l_kb + xc * lc * l_kc;
/*
* If Sigma pi, solid < sigma pi, aq, then use eqns
*/
if (sigmapi_solid < sigmapi_aq)
{
s_s_ptr->ss_in = TRUE;
}
else
{
s_s_ptr->ss_in = FALSE;
}
}
else
{
/*
* Calculate total mole fraction from solution activities
*/
total_p = 0;
for (j = 0; j < s_s_ptr->count_comps; j++)
{
phase_ptr = s_s_ptr->comps[j].phase;
if (phase_ptr->in == TRUE)
{
lp = -phase_ptr->lk;
for (rxn_ptr = s_s_ptr->comps[j].phase->rxn_x->token + 1;
rxn_ptr->s != NULL; rxn_ptr++)
{
lp += rxn_ptr->s->la * rxn_ptr->coef;
}
total_p += exp(lp * LOG_10);
}
}
if (total_p > 1.0)
{
s_s_ptr->ss_in = TRUE;
}
else
{
s_s_ptr->ss_in = FALSE;
}
}
}
for (i = ss_unknown->number; i < count_unknowns; i++)
{
if (x[i]->type != SS_MOLES)
break;
x[i]->ss_in = x[i]->s_s->ss_in;
}
#endif
return (OK);
}
@ -3043,67 +2761,6 @@ calc_ss_fractions(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
calc_s_s_fractions(void)
/* ---------------------------------------------------------------------- */
{
int i, k;
LDBLE moles, n_tot;
struct s_s *s_s_ptr;
/*
* moles and lambdas for solid solutions
*/
if (ss_unknown == NULL)
return (OK);
/*
* Calculate mole fractions and log lambda and derivative factors
*/
if (use.Get_ss_assemblage_ptr() == NULL)
return (OK);
for (i = 0; i < use.Get_ss_assemblage_ptr()->count_s_s; i++)
{
s_s_ptr = &(use.Get_ss_assemblage_ptr()->s_s[i]);
n_tot = 0;
for (k = 0; k < s_s_ptr->count_comps; k++)
{
moles = s_s_ptr->comps[k].moles;
if (s_s_ptr->comps[k].moles < 0)
{
moles = MIN_TOTAL_SS;
s_s_ptr->comps[k].initial_moles = moles;
}
n_tot += moles;
}
s_s_ptr->total_moles = n_tot;
for (k = 0; k < s_s_ptr->count_comps; k++)
{
moles = s_s_ptr->comps[k].moles;
if (s_s_ptr->comps[k].moles < 0)
{
moles = MIN_TOTAL_SS;
}
s_s_ptr->comps[k].fraction_x = moles / n_tot;
s_s_ptr->comps[k].log10_fraction_x = log10(moles / n_tot);
/* all mb and jacobian items must be in x or phase to be static between models */
s_s_ptr->comps[k].phase->log10_fraction_x =
s_s_ptr->comps[k].log10_fraction_x;
}
if (s_s_ptr->a0 != 0.0 || s_s_ptr->a1 != 0)
{
s_s_binary(s_s_ptr);
}
else
{
s_s_ideal(s_s_ptr);
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
ss_binary(cxxSS *ss_ptr)
@ -3228,127 +2885,6 @@ ss_binary(cxxSS *ss_ptr)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
s_s_binary(struct s_s *s_s_ptr)
/* ---------------------------------------------------------------------- */
{
LDBLE nb, nc, n_tot, xb, xc, dnb, dnc, l_a0, l_a1;
LDBLE xb2, xb3, xb4, xc2, xc3;
LDBLE xb1, xc1;
/*
* component 0 is major component
* component 1 is minor component
* xb is the mole fraction of second component (formerly trace)
* xc is the mole fraction of first component (formerly major)
*/
/*
* Calculate mole fractions and log lambda and derivative factors
*/
n_tot = s_s_ptr->total_moles;
nc = s_s_ptr->comps[0].moles;
xc = nc / n_tot;
nb = s_s_ptr->comps[1].moles;
xb = nb / n_tot;
/*
* In miscibility gap
*/
l_a0 = s_s_ptr->a0;
l_a1 = s_s_ptr->a1;
if (s_s_ptr->miscibility == TRUE && xb > s_s_ptr->xb1
&& xb < s_s_ptr->xb2)
{
xb1 = s_s_ptr->xb1;
xc1 = 1.0 - xb1;
s_s_ptr->comps[0].fraction_x = xc1;
s_s_ptr->comps[0].log10_fraction_x = log10(xc1);
s_s_ptr->comps[0].phase->log10_fraction_x =
s_s_ptr->comps[0].log10_fraction_x;
s_s_ptr->comps[1].fraction_x = xb1;
s_s_ptr->comps[1].log10_fraction_x = log10(xb1);
s_s_ptr->comps[1].phase->log10_fraction_x =
s_s_ptr->comps[1].log10_fraction_x;
s_s_ptr->comps[0].log10_lambda =
xb1 * xb1 * (l_a0 - l_a1 * (3 - 4 * xb1)) / LOG_10;
s_s_ptr->comps[0].phase->log10_lambda =
s_s_ptr->comps[0].log10_lambda;
s_s_ptr->comps[1].log10_lambda =
xc1 * xc1 * (l_a0 + l_a1 * (4 * xb1 - 1)) / LOG_10;
s_s_ptr->comps[1].phase->log10_lambda =
s_s_ptr->comps[1].log10_lambda;
s_s_ptr->comps[0].dnb = 0;
s_s_ptr->comps[0].dnc = 0;
s_s_ptr->comps[1].dnb = 0;
s_s_ptr->comps[1].dnc = 0;
s_s_ptr->comps[0].phase->dnb = 0;
s_s_ptr->comps[0].phase->dnc = 0;
s_s_ptr->comps[1].phase->dnb = 0;
s_s_ptr->comps[1].phase->dnc = 0;
}
else
{
/*
* Not in miscibility gap
*/
s_s_ptr->comps[0].fraction_x = xc;
s_s_ptr->comps[0].log10_fraction_x = log10(xc);
s_s_ptr->comps[0].phase->log10_fraction_x =
s_s_ptr->comps[0].log10_fraction_x;
s_s_ptr->comps[1].fraction_x = xb;
s_s_ptr->comps[1].log10_fraction_x = log10(xb);
s_s_ptr->comps[1].phase->log10_fraction_x =
s_s_ptr->comps[1].log10_fraction_x;
s_s_ptr->comps[0].log10_lambda =
xb * xb * (l_a0 - l_a1 * (3 - 4 * xb)) / LOG_10;
s_s_ptr->comps[0].phase->log10_lambda =
s_s_ptr->comps[0].log10_lambda;
s_s_ptr->comps[1].log10_lambda =
xc * xc * (l_a0 + l_a1 * (4 * xb - 1)) / LOG_10;
s_s_ptr->comps[1].phase->log10_lambda =
s_s_ptr->comps[1].log10_lambda;
xc2 = xc * xc;
xc3 = xc2 * xc;
xb2 = xb * xb;
xb3 = xb2 * xb;
xb4 = xb3 * xb;
/* used derivation that did not substitute x2 = 1-x1 */
/* first component, df1/dn1 */
dnc = 2 * l_a0 * xb2 + 12 * l_a1 * xc * xb2 + 6 * l_a1 * xb2;
s_s_ptr->comps[0].phase->dnc = -xb / nc + dnc / n_tot;
/* first component, df1/dn2 */
dnb =
1 - 2 * l_a0 * xb + 2 * l_a0 * xb2 + 8 * l_a1 * xc * xb -
12 * l_a1 * xc * xb2 - 2 * l_a1 * xb + 2 * l_a1 * xb2;
s_s_ptr->comps[0].phase->dnb = dnb / n_tot;
/* second component, df2/dn1 */
dnc =
1 - 2 * l_a0 * xc + 2 * l_a0 * xc2 - 8 * l_a1 * xb * xc +
12 * l_a1 * xb * xc2 + 2 * l_a1 * xc - 2 * l_a1 * xc2;
s_s_ptr->comps[1].phase->dnc = dnc / n_tot;
/* second component, df2/dn2 */
dnb = 2 * l_a0 * xc2 + 12 * l_a1 * xb * xc2 - 6 * l_a1 * xc2;
s_s_ptr->comps[1].phase->dnb = -xc / nb + dnb / n_tot;
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
ss_ideal(cxxSS *ss_ptr)
@ -3397,52 +2933,6 @@ ss_ideal(cxxSS *ss_ptr)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
s_s_ideal(struct s_s *s_s_ptr)
/* ---------------------------------------------------------------------- */
{
int k, j;
LDBLE n_tot, n_tot1;
/*
* component 0 is major component
* component 1 is minor component
* xb is the mole fraction of second component (formerly trace)
* xc is the mole fraction of first component (formerly major)
*/
/*
* Calculate mole fractions and log lambda and derivative factors
*/
n_tot = s_s_ptr->total_moles;
/*
* Ideal solid solution
*/
s_s_ptr->dn = 1.0 / n_tot;
for (k = 0; k < s_s_ptr->count_comps; k++)
{
n_tot1 = 0;
for (j = 0; j < s_s_ptr->count_comps; j++)
{
if (j != k)
{
n_tot1 += s_s_ptr->comps[j].moles;
}
}
s_s_ptr->comps[k].log10_lambda = 0;
s_s_ptr->comps[k].phase->log10_lambda = 0;
s_s_ptr->comps[k].dnb = -(n_tot1) / (s_s_ptr->comps[k].moles * n_tot);
s_s_ptr->comps[k].phase->dnb = s_s_ptr->comps[k].dnb;
s_s_ptr->comps[k].dn = s_s_ptr->dn;
s_s_ptr->comps[k].phase->dn = s_s_ptr->dn;
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
reset(void)
@ -3578,25 +3068,6 @@ reset(void)
factor = f0;
}
}
#ifdef SKIP
else if (x[i]->s_s_comp != NULL && delta[i] < -x[i]->s_s_comp->phase->delta_max)
// Uses delta_max computed in step
// delta_max is the maximum amount of the mineral that could form based
// on the limiting element in the system
{
f0 = -delta[i] / x[i]->s_s_comp->phase->delta_max;
if (f0 > factor)
{
if (debug_model == TRUE)
{
output_msg(sformatf(
"%-10.10s, Precipitating too much mineral.\t%f\n",
x[i]->description, (double) f0));
}
factor = f0;
}
}
#endif
}
}
}

View File

@ -290,41 +290,6 @@ quick_setup(void)
}
}
}
#ifdef SKIP
if (ss_unknown != NULL)
{
for (i = 0; i < count_unknowns; i++)
{
if (x[i]->type == SS_MOLES)
break;
}
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
for (k = 0; k < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; k++)
{
x[i]->s_s = &(use.Get_ss_assemblage_ptr()->s_s[j]);
x[i]->s_s_comp = &(use.Get_ss_assemblage_ptr()->s_s[j].comps[k]);
x[i]->s_s_comp_number = j;
x[i]->moles = x[i]->s_s_comp->moles;
if (x[i]->moles <= 0)
{
x[i]->moles = MIN_TOTAL_SS;
x[i]->s_s_comp->moles = MIN_TOTAL_SS;
}
x[i]->s_s_comp->initial_moles = x[i]->moles;
x[i]->ln_moles = log(x[i]->moles);
x[i]->phase->dn = x[i]->s_s_comp->dn;
x[i]->phase->dnb = x[i]->s_s_comp->dnb;
x[i]->phase->dnc = x[i]->s_s_comp->dnc;
x[i]->phase->log10_fraction_x =
x[i]->s_s_comp->log10_fraction_x;
x[i]->phase->log10_lambda = x[i]->s_s_comp->log10_lambda;
i++;
}
}
}
#endif
/*
* exchange
*/
@ -913,221 +878,6 @@ build_ss_assemblage(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
build_ss_assemblage(void)
/* ---------------------------------------------------------------------- */
{
/*
* Put coefficients into lists to sum iaps to test for equilibrium
* Put coefficients into lists to build jacobian for
* mass action equation for component
* mass balance equations for elements contained in solid solutions
*/
int i, j, k, l, stop;
int row, col;
struct master *master_ptr;
struct rxn_token *rxn_ptr;
struct s_s *s_s_ptr, *s_s_ptr_old;
char token[MAX_LENGTH];
char *ptr;
if (ss_unknown == NULL)
return (OK);
s_s_ptr_old = NULL;
col = 0;
for (i = 0; i < count_unknowns; i++)
{
if (x[i]->type != SS_MOLES)
continue;
s_s_ptr = x[i]->s_s;
if (s_s_ptr != s_s_ptr_old)
{
col = x[i]->number;
s_s_ptr_old = s_s_ptr;
}
/*
* Calculate function value (inverse saturation index)
*/
if (x[i]->phase->rxn_x == NULL)
continue;
store_mb(&(x[i]->phase->lk), &(x[i]->f), 1.0);
for (rxn_ptr = x[i]->phase->rxn_x->token + 1; rxn_ptr->s != NULL;
rxn_ptr++)
{
store_mb(&(rxn_ptr->s->la), &(x[i]->f), -rxn_ptr->coef);
}
/* include mole fraction */
store_mb(&(x[i]->phase->log10_fraction_x), &(x[i]->f), 1.0);
/* include activity coeficient */
store_mb(&(x[i]->phase->log10_lambda), &(x[i]->f), 1.0);
/*
* Put coefficients into mass action equations
*/
/* first IAP terms */
for (rxn_ptr = x[i]->phase->rxn_x->token + 1; rxn_ptr->s != NULL;
rxn_ptr++)
{
if (rxn_ptr->s->secondary != NULL
&& rxn_ptr->s->secondary->in == TRUE)
{
master_ptr = rxn_ptr->s->secondary;
}
else
{
master_ptr = rxn_ptr->s->primary;
}
if (master_ptr == NULL || master_ptr->unknown == NULL)
continue;
store_jacob0(x[i]->number, master_ptr->unknown->number,
rxn_ptr->coef);
}
if (s_s_ptr->a0 != 0.0 || s_s_ptr->a1 != 0.0)
{
/*
* For binary solid solution
*/
/* next dnc terms */
row = x[i]->number * (count_unknowns + 1);
if (x[i]->s_s_comp_number == 0)
{
col = x[i]->number;
}
else
{
col = x[i]->number - 1;
}
store_jacob(&(x[i]->phase->dnc), &(array[row + col]), -1);
/* next dnb terms */
col++;
store_jacob(&(x[i]->phase->dnb), &(array[row + col]), -1);
}
else
{
/*
* For ideal solid solution
*/
row = x[i]->number * (count_unknowns + 1);
for (j = 0; j < s_s_ptr->count_comps; j++)
{
if (j != x[i]->s_s_comp_number)
{
/* store_jacob (&(s_s_ptr->dn), &(array[row + col + j]), -1.0); */
store_jacob(&(x[i]->phase->dn), &(array[row + col + j]),
-1.0);
}
else
{
store_jacob(&(x[i]->phase->dnb), &(array[row + col + j]),
-1.0);
}
}
}
/*
* Put coefficients into mass balance equations
*/
count_elts = 0;
paren_count = 0;
strcpy(token, x[i]->phase->formula);
ptr = token;
get_elts_in_species(&ptr, 1.0);
/*
* Go through elements in phase
*/
#ifdef COMBINE
change_hydrogen_in_elt_list(0);
#endif
for (j = 0; j < count_elts; j++)
{
if (strcmp(elt_list[j].elt->name, "H") == 0
&& mass_hydrogen_unknown != NULL)
{
store_jacob0(mass_hydrogen_unknown->number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&(delta[i]), &mass_hydrogen_unknown->delta,
elt_list[j].coef);
}
else if (strcmp(elt_list[j].elt->name, "O") == 0
&& mass_oxygen_unknown != NULL)
{
store_jacob0(mass_oxygen_unknown->number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&(delta[i]), &mass_oxygen_unknown->delta,
elt_list[j].coef);
}
else
{
master_ptr = elt_list[j].elt->primary;
if (master_ptr->in == FALSE)
{
master_ptr = master_ptr->s->secondary;
}
if (master_ptr == NULL || master_ptr->in == FALSE)
{
if (state != ADVECTION && state != TRANSPORT
&& state != PHAST)
{
error_string = sformatf(
"Element in phase, %s, is not in model.",
x[i]->phase->name);
warning_msg(error_string);
}
if (master_ptr != NULL)
{
master_ptr->s->la = -999.9;
}
/*
* Master species is in model
*/
}
else if (master_ptr->in == TRUE)
{
store_jacob0(master_ptr->unknown->number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&delta[i], &master_ptr->unknown->delta,
elt_list[j].coef);
/*
* Master species in equation needs to be rewritten
*/
}
else if (master_ptr->in == REWRITE)
{
stop = FALSE;
for (k = 0; k < count_unknowns; k++)
{
if (x[k]->type != MB)
continue;
for (l = 0; x[k]->master[l] != NULL; l++)
{
if (x[k]->master[l] == master_ptr)
{
store_jacob0(x[k]->master[0]->unknown->
number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&delta[i],
&x[k]->master[0]->unknown->
delta, elt_list[j].coef);
stop = TRUE;
break;
}
}
if (stop == TRUE)
break;
}
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
build_jacobian_sums(int k)
@ -1863,185 +1613,6 @@ build_pure_phases(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
build_pure_phases(void)
/* ---------------------------------------------------------------------- */
{
/*
* Includes calculation of inverse saturation index in sum_mb.
* Puts coefficients in iap and mass balance equations for each phase.
*/
int i;
int stop, j, k, l;
char token[MAX_LENGTH];
char *ptr;
struct master *master_ptr;
struct rxn_token *rxn_ptr;
/*
* Build into sums the logic to calculate inverse saturation indices for
* pure phases
*/
if (pure_phase_unknown == NULL)
return (OK);
/*
* Calculate inverse saturation index
*/
for (i = 0; i < count_unknowns; i++)
{
if (x[i]->type != PP || x[i]->phase->rxn_x == NULL)
continue;
if (pure_phase_unknown == NULL)
pure_phase_unknown = x[i];
store_mb(&(x[i]->phase->lk), &(x[i]->f), 1.0);
store_mb(&(x[i]->si), &(x[i]->f), 1.0);
for (rxn_ptr = x[i]->phase->rxn_x->token + 1; rxn_ptr->s != NULL;
rxn_ptr++)
{
store_mb(&(rxn_ptr->s->la), &(x[i]->f), -rxn_ptr->coef);
}
}
for (i = 0; i < count_unknowns; i++)
{
/*
* rxn_x is null if an element in phase is not in solution
*/
if (x[i]->type != PP || x[i]->phase->rxn_x == NULL)
continue;
/*
* Put coefficients into IAP equations
*/
for (rxn_ptr = x[i]->phase->rxn_x->token + 1; rxn_ptr->s != NULL;
rxn_ptr++)
{
if (rxn_ptr->s->secondary != NULL
&& rxn_ptr->s->secondary->in == TRUE)
{
master_ptr = rxn_ptr->s->secondary;
}
else
{
master_ptr = rxn_ptr->s->primary;
}
if (master_ptr == NULL || master_ptr->unknown == NULL)
continue;
store_jacob0(x[i]->number, master_ptr->unknown->number,
rxn_ptr->coef);
}
/*
* Put coefficients into mass balance equations
*/
count_elts = 0;
paren_count = 0;
if (x[i]->pure_phase->add_formula != NULL)
{
strcpy(token, x[i]->pure_phase->add_formula);
ptr = token;
get_elts_in_species(&ptr, 1.0);
}
else
{
strcpy(token, x[i]->phase->formula);
ptr = token;
get_elts_in_species(&ptr, 1.0);
}
/*
* Go through elements in phase
*/
#ifdef COMBINE
change_hydrogen_in_elt_list(0);
#endif
for (j = 0; j < count_elts; j++)
{
if (strcmp(elt_list[j].elt->name, "H") == 0
&& mass_hydrogen_unknown != NULL)
{
store_jacob0(mass_hydrogen_unknown->number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&(delta[i]), &mass_hydrogen_unknown->delta,
elt_list[j].coef);
}
else if (strcmp(elt_list[j].elt->name, "O") == 0
&& mass_oxygen_unknown != NULL)
{
store_jacob0(mass_oxygen_unknown->number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&(delta[i]), &mass_oxygen_unknown->delta,
elt_list[j].coef);
}
else
{
master_ptr = elt_list[j].elt->primary;
if (master_ptr->in == FALSE)
{
master_ptr = master_ptr->s->secondary;
}
if (master_ptr == NULL || master_ptr->in == FALSE)
{
if (state != ADVECTION && state != TRANSPORT
&& state != PHAST)
{
error_string = sformatf(
"Element in phase, %s, is not in model.",
x[i]->phase->name);
warning_msg(error_string);
}
if (master_ptr != NULL)
{
master_ptr->s->la = -999.9;
}
/*
* Master species is in model
*/
}
else if (master_ptr->in == TRUE)
{
store_jacob0(master_ptr->unknown->number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&delta[i], &master_ptr->unknown->delta,
elt_list[j].coef);
/*
* Master species in equation needs to be rewritten
*/
}
else if (master_ptr->in == REWRITE)
{
stop = FALSE;
for (k = 0; k < count_unknowns; k++)
{
if (x[k]->type != MB)
continue;
for (l = 0; x[k]->master[l] != NULL; l++)
{
if (x[k]->master[l] == master_ptr)
{
store_jacob0(x[k]->master[0]->unknown->
number, x[i]->number,
-elt_list[j].coef);
store_sum_deltas(&delta[i],
&x[k]->master[0]->unknown->
delta, elt_list[j].coef);
stop = TRUE;
break;
}
}
if (stop == TRUE)
break;
}
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
build_solution_phase_boundaries(void)
@ -3787,65 +3358,6 @@ setup_ss_assemblage(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
setup_ss_assemblage(void)
/* ---------------------------------------------------------------------- */
{
/*
* Fill in data for solid solution unknowns (sum of partial pressures)
* in unknown structure
*/
int i, j;
if (use.Get_ss_assemblage_ptr() == NULL)
return (OK);
/*
* One for each component in each solid solution
*/
ss_unknown = NULL;
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; i++)
{
x[count_unknowns]->type = SS_MOLES;
x[count_unknowns]->description =
string_hsave(use.Get_ss_assemblage_ptr()->s_s[j].comps[i].name);
x[count_unknowns]->moles = 0.0;
if (use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles <= 0)
{
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles = MIN_TOTAL_SS;
}
x[count_unknowns]->moles =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles;
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].initial_moles =
x[count_unknowns]->moles;
x[count_unknowns]->ln_moles = log(x[count_unknowns]->moles);
x[count_unknowns]->s_s = &(use.Get_ss_assemblage_ptr()->s_s[j]);
x[count_unknowns]->s_s_comp =
&(use.Get_ss_assemblage_ptr()->s_s[j].comps[i]);
x[count_unknowns]->s_s_comp_number = i;
x[count_unknowns]->phase =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].phase;
x[count_unknowns]->number = count_unknowns;
x[count_unknowns]->phase->dn =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].dn;
x[count_unknowns]->phase->dnb =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].dnb;
x[count_unknowns]->phase->dnc =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].dnc;
x[count_unknowns]->phase->log10_fraction_x =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].log10_fraction_x;
x[count_unknowns]->phase->log10_lambda =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].log10_lambda;
if (ss_unknown == NULL)
ss_unknown = x[count_unknowns];
count_unknowns++;
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
setup_surface(void)
@ -4613,51 +4125,6 @@ setup_pure_phases(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
setup_pure_phases(void)
/* ---------------------------------------------------------------------- */
{
int i;
struct phase *phase_ptr;
LDBLE si_org;
/*
* Fills in data for pure_phase assemglage in unknown structure
*/
if (use.Get_pp_assemblage_ptr() == NULL)
return (OK);
/*
* Setup unknowns
*/
for (i = 0; i < use.Get_pp_assemblage_ptr()->count_comps; i++)
{
x[count_unknowns]->type = PP;
x[count_unknowns]->description =
use.Get_pp_assemblage_ptr()->pure_phases[i].name;
x[count_unknowns]->moles =
use.Get_pp_assemblage_ptr()->pure_phases[i].moles;
x[count_unknowns]->phase = phase_ptr =
use.Get_pp_assemblage_ptr()->pure_phases[i].phase;
x[count_unknowns]->si = use.Get_pp_assemblage_ptr()->pure_phases[i].si;
si_org = use.Get_pp_assemblage_ptr()->pure_phases[i].si_org;
/* si_org is used for Peng-Robinson gas, with the fugacity
coefficient added later in adjust_pure_phases,
when rxn_x has been defined for each phase in the model */
x[count_unknowns]->delta =
use.Get_pp_assemblage_ptr()->pure_phases[i].delta;
x[count_unknowns]->pure_phase =
&(use.Get_pp_assemblage_ptr()->pure_phases[i]);
x[count_unknowns]->dissolve_only =
use.Get_pp_assemblage_ptr()->pure_phases[i].dissolve_only;
if (pure_phase_unknown == NULL)
pure_phase_unknown = x[count_unknowns];
count_unknowns++;
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
adjust_setup_pure_phases(void)
@ -5239,17 +4706,6 @@ setup_unknowns(void)
max_unknowns += ss_ptrs[i]->Get_ss_comps().size();
}
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
/* max_unknowns += 2 * use.Get_ss_assemblage_ptr()->count_s_s; */
for (i = 0; i < use.Get_ss_assemblage_ptr()->count_s_s; i++)
{
max_unknowns += use.Get_ss_assemblage_ptr()->s_s[i].count_comps;
}
}
#endif
/*
* Pitzer/Sit
*/
@ -6077,18 +5533,6 @@ k_temp(LDBLE tc, LDBLE pa) /* pa - pressure in atm */
}
}
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->count_s_s; i++)
{
if (fabs(tempk - use.Get_ss_assemblage_ptr()->s_s[i].tk) > 0.01)
{
s_s_prep(tempk, &(use.Get_ss_assemblage_ptr()->s_s[i]), FALSE);
}
}
}
#endif
return (OK);
}
@ -6211,27 +5655,6 @@ save_model(void)
last_model.count_ss_assemblage = 0;
last_model.ss_assemblage = NULL;
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
last_model.count_ss_assemblage = use.Get_ss_assemblage_ptr()->count_s_s;
last_model.ss_assemblage =
(const char **) PHRQ_malloc((size_t) use.Get_ss_assemblage_ptr()->
count_s_s * sizeof(char *));
if (last_model.ss_assemblage == NULL)
malloc_error();
for (i = 0; i < use.Get_ss_assemblage_ptr()->count_s_s; i++)
{
last_model.ss_assemblage[i] =
use.Get_ss_assemblage_ptr()->s_s[i].name;
}
}
else
{
last_model.count_ss_assemblage = 0;
last_model.ss_assemblage = NULL;
}
#endif
/*
* save list of phase pointers for pp_assemblage
*/
@ -6278,43 +5701,6 @@ save_model(void)
last_model.add_formula = NULL;
last_model.si = NULL;
}
#ifdef SKIP
if (use.Get_pp_assemblage_ptr() != NULL)
{
last_model.count_pp_assemblage = use.Get_pp_assemblage_ptr()->count_comps;
last_model.pp_assemblage =
(struct phase **) PHRQ_malloc((size_t) use.Get_pp_assemblage_ptr()->
count_comps *
sizeof(struct phase *));
if (last_model.pp_assemblage == NULL)
malloc_error();
last_model.add_formula =
(const char **) PHRQ_malloc((size_t) use.Get_pp_assemblage_ptr()->
count_comps * sizeof(char *));
if (last_model.add_formula == NULL)
malloc_error();
last_model.si =
(LDBLE *) PHRQ_malloc((size_t) use.Get_pp_assemblage_ptr()->
count_comps * sizeof(LDBLE));
if (last_model.si == NULL)
malloc_error();
for (i = 0; i < use.Get_pp_assemblage_ptr()->count_comps; i++)
{
last_model.pp_assemblage[i] =
use.Get_pp_assemblage_ptr()->pure_phases[i].phase;
last_model.add_formula[i] =
use.Get_pp_assemblage_ptr()->pure_phases[i].add_formula;
last_model.si[i] = use.Get_pp_assemblage_ptr()->pure_phases[i].si;
}
}
else
{
last_model.count_pp_assemblage = 0;
last_model.pp_assemblage = NULL;
last_model.add_formula = NULL;
last_model.si = NULL;
}
#endif
/*
* save data for surface
*/
@ -6477,27 +5863,6 @@ check_same_model(void)
if (last_model.ss_assemblage != NULL)
return (FALSE);
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
if (last_model.count_ss_assemblage !=
use.Get_ss_assemblage_ptr()->count_s_s)
return (FALSE);
for (i = 0; i < use.Get_ss_assemblage_ptr()->count_s_s; i++)
{
if (last_model.ss_assemblage[i] !=
use.Get_ss_assemblage_ptr()->s_s[i].name)
{
return (FALSE);
}
}
}
else
{
if (last_model.ss_assemblage != NULL)
return (FALSE);
}
#endif
/*
* Check pure_phases
*/
@ -6538,38 +5903,6 @@ check_same_model(void)
if (last_model.pp_assemblage != NULL)
return (FALSE);
}
#ifdef SKIP
if (use.Get_pp_assemblage_ptr() != NULL)
{
if (last_model.count_pp_assemblage !=
use.Get_pp_assemblage_ptr()->count_comps)
return (FALSE);
for (i = 0; i < use.Get_pp_assemblage_ptr()->count_comps; i++)
{
if (last_model.pp_assemblage[i] !=
use.Get_pp_assemblage_ptr()->pure_phases[i].phase)
{
return (FALSE);
}
if (last_model.add_formula[i] !=
use.Get_pp_assemblage_ptr()->pure_phases[i].add_formula)
{
return (FALSE);
}
/* A. Crapsi
if (last_model.si[i] != use.Get_pp_assemblage_ptr()->pure_phases[i].si)
{
return (FALSE);
}
*/
}
}
else
{
if (last_model.pp_assemblage != NULL)
return (FALSE);
}
#endif
/*
* Check surface
*/

View File

@ -765,133 +765,6 @@ print_ss_assemblage(void)
output_msg(sformatf("\n"));
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
print_ss_assemblage(void)
/* ---------------------------------------------------------------------- */
{
/*
* Prints solid solution composition if present
*/
int i, j;
LDBLE delta_moles;
LDBLE nb, nc, xb, xb1, xb2, xb1moles, xb2moles;
struct s_s *s_s_ptr;
if (pr.ss_assemblage == FALSE || pr.all == FALSE)
return (OK);
if (use.Get_ss_assemblage_ptr() == NULL)
return (OK);
/*
* Print heading
*/
print_centered("Solid solutions");
output_msg(sformatf("\n"));
output_msg(sformatf("%-15s %22s %11s %11s %11s\n\n",
"Solid solution", "Component", "Moles", "Delta moles",
"Mole fract"));
/*
* Print solid solutions
*/
std::vector<cxxSS *> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
for (j = 0; j < ss_ptrs.size(); j++)
{
cxxSS * ss_ptr = ss_ptrs[j];
if (use.Get_ss_assemblage_ptr()->s_s[j].ss_in == TRUE)
{
/* solid solution name, moles */
output_msg(sformatf("%-15s %22s %11.2e\n",
use.Get_ss_assemblage_ptr()->s_s[j].name, " ",
(double) use.Get_ss_assemblage_ptr()->s_s[j].total_moles));
/* component name, moles, delta moles, mole fraction */
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; i++)
{
if (state != TRANSPORT && state != PHAST)
{
delta_moles =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles -
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].
initial_moles -
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].delta;
}
else
{
delta_moles =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles -
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].init_moles;
}
output_msg(sformatf(
"%15s %22s %11.2e %11.2e %11.2e\n", " ",
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].name,
(double) use.Get_ss_assemblage_ptr()->s_s[j].comps[i].
moles, (double) delta_moles,
(double) (use.Get_ss_assemblage_ptr()->s_s[j].comps[i].
moles /
use.Get_ss_assemblage_ptr()->s_s[j].
total_moles)));
}
s_s_ptr = &(use.Get_ss_assemblage_ptr()->s_s[j]);
if (s_s_ptr->miscibility == TRUE)
{
nc = s_s_ptr->comps[0].moles;
nb = s_s_ptr->comps[1].moles;
xb = nb / (nb + nc);
xb1 = s_s_ptr->xb1;
xb2 = s_s_ptr->xb2;
if (xb > xb1 && xb < xb2)
{
xb2moles = (xb1 - 1) / xb1 * nb + nc;
xb2moles = xb2moles / ((xb1 - 1) / xb1 * xb2 + (1 - xb2));
xb1moles = (nb - xb2moles * xb2) / xb1;
output_msg(sformatf(
"\n%14s Solid solution is in miscibility gap\n",
" "));
output_msg(sformatf(
"%14s End members in pct of %s\n\n", " ",
s_s_ptr->comps[1].name));
output_msg(sformatf("%22s %11g pct %11.2e\n",
" ", (double) xb1, (double) xb1moles));
output_msg(sformatf("%22s %11g pct %11.2e\n",
" ", (double) xb2, (double) xb2moles));
}
}
}
else
{
/* solid solution name, moles */
output_msg(sformatf("%-15s %22s %11.2e\n",
use.Get_ss_assemblage_ptr()->s_s[j].name, " ",
(double) 0.0));
/* component name, moles, delta moles, mole fraction */
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps; i++)
{
if (state != TRANSPORT && state != PHAST)
{
delta_moles =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles -
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].
initial_moles -
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].delta;
}
else
{
delta_moles =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles -
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].init_moles;
}
output_msg(sformatf(
"%15s %22s %11.2e %11.2e %11.2e\n", " ",
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].name,
(double) 0, (double) delta_moles, (double) 0));
}
}
}
output_msg(sformatf("\n"));
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
print_reaction(void)
@ -2476,17 +2349,6 @@ print_using(void)
use.Get_n_ss_assemblage_user(),
ss_assemblage_ptr->Get_description().c_str()));
}
#ifdef SKIP
if (use.Get_ss_assemblage_in() == TRUE)
{
ss_assemblage_ptr =
ss_assemblage_bsearch(use.Get_n_ss_assemblage_user(), &n);
output_msg(sformatf(
"Using solid solution assemblage %d.\t%s\n",
use.Get_n_ss_assemblage_user(),
ss_assemblage_ptr->description));
}
#endif
if (use.Get_gas_phase_in() == TRUE)
{
//gas_phase_ptr = gas_phase_bsearch(use.Get_n_gas_phase_user(), &n);
@ -2679,62 +2541,6 @@ punch_ss_assemblage(void)
}
}
}
#ifdef SKIP
for (k = 0; k < punch.count_s_s; k++)
{
found = FALSE;
if (use.Get_ss_assemblage_ptr() != NULL)
{
for (j = 0; j < use.Get_ss_assemblage_ptr()->count_s_s; j++)
{
for (i = 0; i < use.Get_ss_assemblage_ptr()->s_s[j].count_comps;
i++)
{
if (strcmp_nocase
(punch.s_s[k].name,
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].name) == 0)
{
if (use.Get_ss_assemblage_ptr()->s_s[j].ss_in == TRUE)
{
moles =
use.Get_ss_assemblage_ptr()->s_s[j].comps[i].moles;
}
else
{
moles = 0;
}
if (punch.high_precision == FALSE)
{
fpunchf(sformatf("s_%s", punch.s_s[k].name),
"%12.4e\t", (double) moles);
}
else
{
fpunchf(sformatf("s_%s", punch.s_s[k].name),
"%20.12e\t", (double) moles);
}
found = TRUE;
break;
}
}
if (found == TRUE)
break;
}
}
if (found == FALSE)
{
if (punch.high_precision == FALSE)
{
fpunchf(sformatf("s_%s", punch.s_s[k].name), "%12.4e\t", (double) 0.0);
}
else
{
fpunchf(sformatf("s_%s", punch.s_s[k].name), "%20.12e\t",
(double) 0.0);
}
}
}
#endif
return (OK);
}

View File

@ -262,37 +262,30 @@ read_input(void)
read_solution_raw();
break;
case Keywords::KEY_EXCHANGE_RAW:
//read_exchange_raw();
Utilities::Rxn_read_raw(Rxn_exchange_map, this);
break;
case Keywords::KEY_SURFACE_RAW:
read_surface_raw();
break;
case Keywords::KEY_EQUILIBRIUM_PHASES_RAW:
//read_equilibrium_phases_raw();
Utilities::Rxn_read_raw(Rxn_pp_assemblage_map, this);
break;
case Keywords::KEY_KINETICS_RAW:
read_kinetics_raw();
break;
case Keywords::KEY_SOLID_SOLUTIONS_RAW:
//read_solid_solutions_raw();
Utilities::Rxn_read_raw(Rxn_ss_assemblage_map, this);
break;
case Keywords::KEY_GAS_PHASE_RAW:
//read_gas_phase_raw();
Utilities::Rxn_read_raw(Rxn_gas_phase_map, this);
break;
case Keywords::KEY_REACTION_RAW:
//read_reaction_raw();
Utilities::Rxn_read_raw(Rxn_reaction_map, this);
break;
case Keywords::KEY_MIX_RAW:
//read_mix_raw();
Utilities::Rxn_read_raw(Rxn_mix_map, this);
break;
case Keywords::KEY_REACTION_TEMPERATURE_RAW:
//read_temperature_raw();
Utilities::Rxn_read_raw(Rxn_temperature_map, this);
break;
case Keywords::KEY_DUMP:
@ -302,11 +295,9 @@ read_input(void)
read_solution_modify();
break;
case Keywords::KEY_EQUILIBRIUM_PHASES_MODIFY:
//read_equilibrium_phases_modify();
Utilities::Rxn_read_modify(Rxn_pp_assemblage_map, this);
break;
case Keywords::KEY_EXCHANGE_MODIFY:
//read_exchange_modify();
Utilities::Rxn_read_modify(Rxn_exchange_map, this);
break;
case Keywords::KEY_SURFACE_MODIFY:
@ -316,7 +307,6 @@ read_input(void)
Utilities::Rxn_read_modify(Rxn_ss_assemblage_map, this);
break;
case Keywords::KEY_GAS_PHASE_MODIFY:
//read_gas_phase_modify();
Utilities::Rxn_read_modify(Rxn_gas_phase_map, this);
break;
case Keywords::KEY_KINETICS_MODIFY:
@ -329,7 +319,6 @@ read_input(void)
read_run_cells();
break;
case Keywords::KEY_REACTION_MODIFY:
//read_reaction_modify();
Utilities::Rxn_read_modify(Rxn_reaction_map, this);
break;
//case LAST_C_KEYWORD + 22: //reaction_temperature_modify
@ -340,14 +329,8 @@ read_input(void)
read_reaction_pressure();
break;
case Keywords::KEY_REACTION_PRESSURE_RAW:
//read_reaction_pressure_raw();
Utilities::Rxn_read_raw(Rxn_pressure_map, this);
break;
#ifdef SKIP
//case Keywords::KEY_REACTION_PRESSURE_MODIFY:
// read_reaction_pressure_modify();
// break;
#endif
default:
error_msg("Error in keyword switch", STOP);
break;
@ -4122,228 +4105,6 @@ read_pp_assemblage(void)
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_pure_phases(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads pure phase data
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int j, n, l, return_value;
int count_pure_phases;
int n_user, n_user_end;
char *ptr;
char *description;
char token[MAX_LENGTH];
int opt, opt_save;
char *next_char;
const char *opt_list[] = {
"force_equality" /* 0 */
};
int count_opt_list = 1;
ptr = line;
/*
* Read pp_assemblage number
*/
read_number_description(ptr, &n_user, &n_user_end, &description);
/*
* Find pp_assemblage or realloc space for pp_assemblage
*/
if (pp_assemblage_search(n_user, &n) != NULL)
{
pp_assemblage_free(&pp_assemblage[n]);
}
else
{
n = count_pp_assemblage++;
space((void **) ((void *) &pp_assemblage), count_pp_assemblage,
&max_pp_assemblage, sizeof(struct pp_assemblage));
}
/*
* Set use data to first read
*/
if (use.Get_pp_assemblage_in() == FALSE)
{
use.Get_pp_assemblage_in() = TRUE;
use.Get_n_pp_assemblage_user() = n_user;
}
pp_assemblage_init(&(pp_assemblage[n]), n_user, n_user_end, description);
free_check_null(description);
count_pure_phases = 0;
/*
* Read equilibrium phase data
*/
opt_save = OPTION_DEFAULT;
return_value = UNKNOWN;
for (;;)
{
opt = get_option(opt_list, count_opt_list, &next_char);
if (opt == OPTION_DEFAULT)
{
opt = opt_save;
}
switch (opt)
{
case OPTION_EOF: /* end of file */
return_value = EOF;
break;
case OPTION_KEYWORD: /* keyword */
return_value = KEYWORD;
break;
case OPTION_ERROR:
input_error++;
error_msg("Unknown input in EQUILIBRIUM_PHASES keyword.", CONTINUE);
error_msg(line_save, CONTINUE);
break;
case 0: /* force_equality */
if (count_pure_phases == 0)
{
error_msg
("Force_equality defined before equilibrium phase has been defined.",
CONTINUE);
error_msg(line_save, CONTINUE);
input_error++;
}
else
{
pp_assemblage[n].pure_phases[count_pure_phases -
1].force_equality =
get_true_false(next_char, TRUE);
}
break;
case OPTION_DEFAULT:
/*
* Make space, set default
*/
count_pure_phases++;
pp_assemblage[n].pure_phases =
(struct pure_phase *) PHRQ_realloc(pp_assemblage[n].
pure_phases,
(size_t)
(count_pure_phases) *
sizeof(struct pure_phase));
if (pp_assemblage[n].pure_phases == NULL)
malloc_error();
pp_assemblage[n].pure_phases[count_pure_phases - 1].si = 0.0;
pp_assemblage[n].pure_phases[count_pure_phases - 1].si_org = 0.0;
pp_assemblage[n].pure_phases[count_pure_phases - 1].add_formula =
NULL;
pp_assemblage[n].pure_phases[count_pure_phases - 1].moles = 10.0;
pp_assemblage[n].pure_phases[count_pure_phases - 1].delta = 0.0;
pp_assemblage[n].pure_phases[count_pure_phases -
1].initial_moles = 0.0;
pp_assemblage[n].pure_phases[count_pure_phases -
1].force_equality = FALSE;
pp_assemblage[n].pure_phases[count_pure_phases -
1].dissolve_only = FALSE;
pp_assemblage[n].pure_phases[count_pure_phases -
1].precipitate_only = FALSE;
/*
* Read name
*/
ptr = line;
copy_token(token, &ptr, &l);
pp_assemblage[n].pure_phases[count_pure_phases - 1].name =
string_hsave(token);
if ((j = copy_token(token, &ptr, &l)) == EMPTY)
continue;
/*
* Read saturation index
*/
j = sscanf(token, SCANFORMAT, &dummy);
pp_assemblage[n].pure_phases[count_pure_phases - 1].si =
(LDBLE) dummy;
pp_assemblage[n].pure_phases[count_pure_phases - 1].si_org =
(LDBLE) dummy;
if (j != 1)
{
error_msg("Expected saturation index.", CONTINUE);
error_msg(line_save, CONTINUE);
input_error++;
continue;
}
/*
* Adding a reaction to the phase boundary
*/
if ((j = copy_token(token, &ptr, &l)) == EMPTY)
continue;
if (j == UPPER || j == LOWER)
{
pp_assemblage[n].pure_phases[count_pure_phases -
1].add_formula =
string_hsave(token);
j = copy_token(token, &ptr, &l);
}
/*
* Read amount
*/
if (j == EMPTY)
continue;
j = sscanf(token, SCANFORMAT, &dummy);
pp_assemblage[n].pure_phases[count_pure_phases - 1].moles =
(LDBLE) dummy;
if (j != 1)
{
error_msg("Expected amount of mineral.", CONTINUE);
error_msg(line_save, CONTINUE);
input_error++;
continue;
}
if ((j = copy_token(token, &ptr, &l)) == EMPTY)
continue;
str_tolower(token);
if (strstr(token, "d") == token)
{
pp_assemblage[n].pure_phases[count_pure_phases -
1].dissolve_only = TRUE;
pp_assemblage[n].pure_phases[count_pure_phases -
1].precipitate_only = FALSE;
} else if (strstr(token, "p") == token)
{
pp_assemblage[n].pure_phases[count_pure_phases -
1].precipitate_only = TRUE;
pp_assemblage[n].pure_phases[count_pure_phases -
1].dissolve_only = FALSE;
}
else
{
error_msg
("Unexpected data at end of equilibrium-phase definition.",
CONTINUE);
input_error++;
continue;
}
break;
}
if (return_value == EOF || return_value == KEYWORD)
break;
}
pp_assemblage[n].count_comps = count_pure_phases;
/*
* Sort phases by name (lowercase)
*/
qsort(pp_assemblage[n].pure_phases,
(size_t) count_pure_phases,
(size_t) sizeof(struct pure_phase), pure_phase_compare);
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_reaction(void)
@ -9772,566 +9533,6 @@ read_solid_solutions(void)
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_solid_solutions(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads solid solution data
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int i, j, n, l;
int count_s_s, number_s_s, count_comps;
int n_user, n_user_end;
char *ptr;
char *description;
char token[MAX_LENGTH];
int return_value, opt;
char *next_char;
const char *opt_list[] = {
"component", /* 0 */
"comp", /* 1 */
"parms", /* 2 */
"gugg_nondimensional", /* 3 */
"gugg_kj", /* 4 */
"activity_coefficients", /* 5 */
"distribution_coefficients", /* 6 */
"miscibility_gap", /* 7 */
"spinodal_gap", /* 8 */
"critical_point", /* 9 */
"alyotropic_point", /* 10 */
"temp", /* 11 */
"tempk", /* 12 */
"tempc", /* 13 */
"thompson", /* 14 */
"margules", /* 15 */
"comp1", /* 16 */
"comp2" /* 17 */
};
int count_opt_list = 18;
/*
* Read ss_assemblage number
*/
number_s_s = 0;
ptr = line;
read_number_description(ptr, &n_user, &n_user_end, &description);
/*
* Find old ss_assemblage or alloc space for new ss_assemblage
*/
if (ss_assemblage_search(n_user, &n) != NULL)
{
ss_assemblage_free(&ss_assemblage[n]);
}
else
{
n = count_ss_assemblage;
space((void **) ((void *) &ss_assemblage), count_ss_assemblage,
&max_ss_assemblage, sizeof(struct ss_assemblage));
count_ss_assemblage++;
}
/*
* Initialize
*/
ss_assemblage_init(&(ss_assemblage[n]), n_user, n_user_end,
description);
free_check_null(description);
/*
* Set use data to first read
*/
if (!use.Get_ss_assemblage_in())
{
use.Set_ss_assemblage_in(true);
use.Set_n_ss_assemblage_user(n_user);
}
/*
* Read solid solutions
*/
count_s_s = 0;
count_comps = 0;
return_value = UNKNOWN;
for (;;)
{
opt = get_option(opt_list, count_opt_list, &next_char);
switch (opt)
{
case OPTION_EOF: /* end of file */
return_value = EOF;
break;
case OPTION_KEYWORD: /* keyword */
return_value = KEYWORD;
break;
case OPTION_ERROR:
input_error++;
error_msg("Unknown input in SOLID_SOLUTIONS keyword.", CONTINUE);
error_msg(line_save, CONTINUE);
break;
/*
* New component
*/
case 0: /* component */
case 1: /* comp */
count_comps = ss_assemblage[n].s_s[number_s_s].count_comps++;
ss_assemblage[n].s_s[number_s_s].comps =
(struct s_s_comp *) PHRQ_realloc(ss_assemblage[n].
s_s[number_s_s].comps,
(size_t) (count_comps +
1) *
sizeof(struct s_s_comp));
if (ss_assemblage[n].s_s[number_s_s].comps == NULL)
malloc_error();
ss_assemblage[n].s_s[number_s_s].comps[count_comps].initial_moles = 0;
ss_assemblage[n].s_s[number_s_s].comps[count_comps].delta = 0;
/*
* Read phase name of component
*/
ptr = next_char;
copy_token(token, &ptr, &l);
ss_assemblage[n].s_s[number_s_s].comps[count_comps].name =
string_hsave(token);
/*
* Read moles of component
*/
if ((j = copy_token(token, &ptr, &l)) == EMPTY)
{
ss_assemblage[n].s_s[number_s_s].comps[count_comps].moles =
NAN;
}
else
{
j = sscanf(token, SCANFORMAT, &dummy);
ss_assemblage[n].s_s[number_s_s].comps[count_comps].moles =
(LDBLE) dummy;
if (j != 1)
{
error_msg("Expected moles of solid solution.", CONTINUE);
error_msg(line_save, CONTINUE);
input_error++;
}
}
break;
case 2: /* parms */
case 3: /* gugg_nondimensional */
/*
* Read parameters
*/
ptr = next_char;
if (copy_token(token, &ptr, &l) != EMPTY)
{
sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[0]));
}
if (copy_token(token, &ptr, &l) != EMPTY)
{
sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[1]));
}
ss_assemblage[n].s_s[number_s_s].input_case = 0;
break;
case 4: /* gugg_kj */
ptr = next_char;
if (copy_token(token, &ptr, &l) != EMPTY)
{
sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[0]));
}
if (copy_token(token, &ptr, &l) != EMPTY)
{
sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[1]));
}
ss_assemblage[n].s_s[number_s_s].input_case = 7;
break;
case 5: /* activity coefficients */
ptr = next_char;
j = 0;
for (i = 0; i < 4; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 4)
{
error_string = sformatf(
"Expected 4 parameters to calculate a0 and a1 from two activity coefficients, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 1;
break;
case 6: /* distribution coefficients */
ptr = next_char;
j = 0;
for (i = 0; i < 4; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 4)
{
error_string = sformatf(
"Expected 4 parameters to calculate a0 and a1 from two distribution coefficients, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 2;
break;
case 7: /* miscibility_gap */
ptr = next_char;
j = 0;
for (i = 0; i < 2; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 2)
{
error_string = sformatf(
"Expected 2 miscibility gap fractions of component 2 to calculate a0 and a1, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 3;
break;
case 8: /* spinodal_gap */
ptr = next_char;
j = 0;
for (i = 0; i < 2; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 2)
{
error_string = sformatf(
"Expected 2 spinodal gap fractions of component 2 to calculate a0 and a1, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 4;
break;
case 9: /* critical point */
ptr = next_char;
j = 0;
for (i = 0; i < 2; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 2)
{
error_string = sformatf(
"Expected fraction of component 2 and critical temperature to calculate a0 and a1, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 5;
break;
case 10: /* alyotropic point */
ptr = next_char;
j = 0;
for (i = 0; i < 2; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 2)
{
error_string = sformatf(
"Expected fraction of component 2 and sigma pi at alyotropic point to calculate a0 and a1, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 6;
break;
case 12: /* tempk */
ptr = next_char;
j = 0;
if (copy_token(token, &ptr, &l) != EMPTY)
{
j = sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].tk));
}
if (j != 1)
{
error_string = sformatf(
"Expected temperature (Kelvin) for parameters, assemblage %d, solid solution %s, using 298.15 K",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
warning_msg(error_string);
ss_assemblage[n].s_s[number_s_s].tk = 298.15;
}
break;
case 11: /* temp */
case 13: /* tempc */
ptr = next_char;
j = 0;
if (copy_token(token, &ptr, &l) != EMPTY)
{
j = sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].tk));
}
if (j != 1)
{
error_string = sformatf(
"Expected temperature (Celcius) for parameters, assemblage %d, solid solution %s, using 25 C",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
warning_msg(error_string);
ss_assemblage[n].s_s[number_s_s].tk = 25.;
}
ss_assemblage[n].s_s[number_s_s].tk += 273.15;
break;
case 14: /* Thompson and Waldbaum */
ptr = next_char;
j = 0;
for (i = 0; i < 2; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 2)
{
error_string = sformatf(
"Expected Wg2 and Wg1 Thompson-Waldbaum parameters to calculate a0 and a1, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 8;
break;
case 15: /* Margules */
ptr = next_char;
j = 0;
for (i = 0; i < 2; i++)
{
if (copy_token(token, &ptr, &l) != EMPTY)
{
j += sscanf(token, SCANFORMAT,
&(ss_assemblage[n].s_s[number_s_s].p[i]));
}
}
if (j != 2)
{
error_string = sformatf(
"Expected alpha2 and alpha3 Margules parameters to calculate a0 and a1, assemblage %d, solid solution %s",
ss_assemblage[n].n_user,
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
ss_assemblage[n].s_s[number_s_s].input_case = 9;
break;
case 16: /* comp1 */
if (count_comps < 2)
{
ss_assemblage[n].s_s[number_s_s].count_comps = 2;
count_comps = 2;
ss_assemblage[n].s_s[number_s_s].comps =
(struct s_s_comp *) PHRQ_realloc(ss_assemblage[n].
s_s[number_s_s].comps,
(size_t) (count_comps) *
sizeof(struct s_s_comp));
if (ss_assemblage[n].s_s[number_s_s].comps == NULL)
malloc_error();
}
/*
* Read phase name of component
*/
ptr = next_char;
copy_token(token, &ptr, &l);
ss_assemblage[n].s_s[number_s_s].comps[0].name =
string_hsave(token);
/*
* Read moles of component
*/
if ((j = copy_token(token, &ptr, &l)) == EMPTY)
{
ss_assemblage[n].s_s[number_s_s].comps[0].moles = NAN;
}
else
{
j = sscanf(token, SCANFORMAT, &dummy);
ss_assemblage[n].s_s[number_s_s].comps[0].moles =
(LDBLE) dummy;
if (j != 1)
{
error_msg("Expected moles of solid solution.", CONTINUE);
error_msg(line_save, CONTINUE);
input_error++;
}
}
break;
case 17: /* comp2 */
if (count_comps < 2)
{
ss_assemblage[n].s_s[number_s_s].count_comps = 2;
count_comps = 2;
ss_assemblage[n].s_s[number_s_s].comps =
(struct s_s_comp *) PHRQ_realloc(ss_assemblage[n].
s_s[number_s_s].comps,
(size_t) (count_comps) *
sizeof(struct s_s_comp));
if (ss_assemblage[n].s_s[number_s_s].comps == NULL)
malloc_error();
}
/*
* Read phase name of component
*/
ptr = next_char;
copy_token(token, &ptr, &l);
ss_assemblage[n].s_s[number_s_s].comps[1].name =
string_hsave(token);
/*
* Read moles of component
*/
if ((j = copy_token(token, &ptr, &l)) == EMPTY)
{
ss_assemblage[n].s_s[number_s_s].comps[1].moles = NAN;
}
else
{
j = sscanf(token, SCANFORMAT, &dummy);
ss_assemblage[n].s_s[number_s_s].comps[1].moles =
(LDBLE) dummy;
if (j != 1)
{
error_msg("Expected moles of solid solution.", CONTINUE);
error_msg(line_save, CONTINUE);
input_error++;
}
}
break;
/*
* New solid solution
*/
case OPTION_DEFAULT:
number_s_s = count_s_s++;
/*
* Make space, set default
*/
/* realloc space for one s_s */
ss_assemblage[n].s_s =
(struct s_s *) PHRQ_realloc(ss_assemblage[n].s_s,
(size_t) (count_s_s +
1) *
sizeof(struct s_s));
if (ss_assemblage[n].s_s == NULL)
malloc_error();
/* malloc space for one component */
ss_assemblage[n].s_s[number_s_s].comps =
(struct s_s_comp *) PHRQ_malloc((size_t)
sizeof(struct s_s_comp));
if (ss_assemblage[n].s_s[number_s_s].comps == NULL)
malloc_error();
count_comps = 0;
ss_assemblage[n].s_s[number_s_s].count_comps = 0;
ss_assemblage[n].s_s[number_s_s].total_moles = 0;
ss_assemblage[n].s_s[number_s_s].dn = 0;
ss_assemblage[n].s_s[number_s_s].a0 = 0.0;
ss_assemblage[n].s_s[number_s_s].a1 = 0.0;
ss_assemblage[n].s_s[number_s_s].ag0 = 0.0;
ss_assemblage[n].s_s[number_s_s].ag1 = 0.0;
ss_assemblage[n].s_s[number_s_s].ss_in = FALSE;
ss_assemblage[n].s_s[number_s_s].miscibility = FALSE;
ss_assemblage[n].s_s[number_s_s].spinodal = FALSE;
ss_assemblage[n].s_s[number_s_s].tk = 298.15;
ss_assemblage[n].s_s[number_s_s].xb1 = 0;
ss_assemblage[n].s_s[number_s_s].xb2 = 0;
ss_assemblage[n].s_s[number_s_s].input_case = 0;
ss_assemblage[n].s_s[number_s_s].p[0] = 0.0;
ss_assemblage[n].s_s[number_s_s].p[1] = 0.0;
ss_assemblage[n].s_s[number_s_s].p[2] = 0.0;
ss_assemblage[n].s_s[number_s_s].p[3] = 0.0;
ss_assemblage[n].s_s[number_s_s].comps->name = NULL;
ss_assemblage[n].s_s[number_s_s].comps->phase = NULL;
/*
* Read solid solution name
*/
ptr = line;
copy_token(token, &ptr, &l);
ss_assemblage[n].s_s[number_s_s].name = string_hsave(token);
ss_assemblage[n].s_s[number_s_s].total_moles = NAN;
break;
}
if (return_value == EOF || return_value == KEYWORD)
break;
}
for (i = 0; i < ss_assemblage[n].count_s_s; i++)
{
if (ss_assemblage[n].s_s[i].p[0] != 0.0 ||
ss_assemblage[n].s_s[i].p[1] != 0.0)
{
if (ss_assemblage[n].s_s[number_s_s].count_comps != 2)
{
error_string = sformatf(
"Solid solution, %s, is nonideal. Must define exactly two components (-comp1 and -comp2).",
ss_assemblage[n].s_s[number_s_s].name);
error_msg(error_string, CONTINUE);
input_error++;
}
}
}
/*
* Sort components by name (lowercase)
*/
ss_assemblage[n].count_s_s = count_s_s;
qsort(ss_assemblage[n].s_s,
(size_t) count_s_s, (size_t) sizeof(struct s_s), s_s_compare);
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_llnl_aqueous_model_parameters(void)

View File

@ -133,19 +133,6 @@ step(LDBLE step_fraction)
pp_assemblage_save = new cxxPPassemblage(*pp_assemblage_ptr);
add_pp_assemblage(pp_assemblage_ptr);
}
#ifdef SKIP
if (use.Get_pp_assemblage_ptr() != NULL)
{
pp_assemblage_save =
(struct pp_assemblage *)
PHRQ_malloc(sizeof(struct pp_assemblage));
if (pp_assemblage_save == NULL)
malloc_error();
pp_assemblage_copy(use.Get_pp_assemblage_ptr(), pp_assemblage_save,
use.Get_pp_assemblage_ptr()->n_user);
add_pp_assemblage(use.Get_pp_assemblage_ptr());
}
#endif
/*
* Solid solutions
*/
@ -154,19 +141,6 @@ step(LDBLE step_fraction)
ss_assemblage_save = new cxxSSassemblage(*use.Get_ss_assemblage_ptr());
add_ss_assemblage(use.Get_ss_assemblage_ptr());
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
ss_assemblage_save =
(struct ss_assemblage *)
PHRQ_malloc(sizeof(struct ss_assemblage));
if (ss_assemblage_save == NULL)
malloc_error();
ss_assemblage_copy(use.Get_ss_assemblage_ptr(), ss_assemblage_save,
use.Get_ss_assemblage_ptr()->n_user);
add_ss_assemblage(use.Get_ss_assemblage_ptr());
}
#endif
/*
* Check that elements are available for gas components,
* pure phases, and solid solutions
@ -201,18 +175,6 @@ step(LDBLE step_fraction)
Rxn_ss_assemblage_map[ss_assemblage_save->Get_n_user()] = *ss_assemblage_save;
use.Set_ss_assemblage_ptr(Utilities::Rxn_find(Rxn_ss_assemblage_map, ss_assemblage_save->Get_n_user()));
}
#ifdef SKIP
if (use.Get_ss_assemblage_ptr() != NULL)
{
ss_assemblage_free(use.Get_ss_assemblage_ptr());
ss_assemblage_copy(ss_assemblage_save, use.Get_ss_assemblage_ptr(),
use.Get_ss_assemblage_ptr()->n_user);
ss_assemblage_free(ss_assemblage_save);
ss_assemblage_save =
(struct ss_assemblage *)
free_check_null(ss_assemblage_save);
}
#endif
return (MASS_BALANCE);
}
/*
@ -822,132 +784,6 @@ add_pp_assemblage(cxxPPassemblage *pp_assemblage_ptr)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
add_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Add a small amount of each phase if necessary to insure
* all elements exist in solution.
*/
int i, j;
LDBLE amount_to_add, total;
char token[MAX_LENGTH];
char *ptr;
struct pure_phase *pure_phase_ptr;
struct master *master_ptr;
//struct phase *phase_ptr;
//LDBLE p, t;
pure_phase_ptr = pp_assemblage_ptr->pure_phases;
// Should be be done when it gets to prep (modified quick_setup in case same_model).
//for (j = 0; j < pp_assemblage_ptr->count_comps; j++)
//{
// phase_ptr = pure_phase_ptr[j].phase;
// if (/*pure_phase_ptr[j].si_org > 0 && */phase_ptr->p_c > 0 && phase_ptr->t_c > 0)
// {
// p = exp(pure_phase_ptr[j].si_org * LOG_10);
// t = tc_x + 273.15;
// if (!phase_ptr->pr_in || p != phase_ptr->pr_p || t != phase_ptr->pr_tk)
// {
// calc_PR(&phase_ptr, 1, p, t, 0);
// }
// pure_phase_ptr[j].si = pure_phase_ptr[j].si_org + phase_ptr->pr_si_f;
// }
//}
if (check_pp_assemblage(pp_assemblage_ptr) == OK)
return (OK);
/*
* Go through list and generate list of elements and
* coefficient of elements in reaction
*/
count_elts = 0;
paren_count = 0;
/*
* Check that all elements are in solution for phases with greater than zero mass
*/
pure_phase_ptr = pp_assemblage_ptr->pure_phases;
for (j = 0; j < pp_assemblage_ptr->count_comps; j++)
{
if (pure_phase_ptr[j].precipitate_only) continue;
count_elts = 0;
paren_count = 0;
amount_to_add = 0.0;
pure_phase_ptr[j].delta = 0.0;
if (pure_phase_ptr[j].add_formula != NULL)
{
strcpy(token, pure_phase_ptr[j].add_formula);
ptr = &(token[0]);
get_elts_in_species(&ptr, 1.0);
}
else
{
strcpy(token, pure_phase_ptr[j].phase->formula);
add_elt_list(pure_phase_ptr[j].phase->next_elt, 1.0);
}
if (pure_phase_ptr[j].moles > 0.0)
{
for (i = 0; i < count_elts; i++)
{
master_ptr = elt_list[i].elt->primary;
if (master_ptr->s == s_hplus)
{
continue;
}
else if (master_ptr->s == s_h2o)
{
continue;
}
else if (master_ptr->total > MIN_TOTAL)
{
continue;
}
else
{
total = (-master_ptr->total + 1e-10) / elt_list[i].coef;
if (amount_to_add < total)
{
amount_to_add = total;
}
}
}
if (pure_phase_ptr[j].moles < amount_to_add)
{
amount_to_add = pure_phase_ptr[j].moles;
}
}
if (amount_to_add > 0.0)
{
pure_phase_ptr[j].moles -= amount_to_add;
pure_phase_ptr[j].delta = amount_to_add;
/*
* Add reaction to totals
*/
for (i = 0; i < count_elts; i++)
{
master_ptr = elt_list[i].elt->primary;
if (master_ptr->s == s_hplus)
{
total_h_x += elt_list[i].coef * amount_to_add;
}
else if (master_ptr->s == s_h2o)
{
total_o_x += elt_list[i].coef * amount_to_add;
}
else
{
master_ptr->total += elt_list[i].coef * amount_to_add;
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
check_pp_assemblage(cxxPPassemblage *pp_assemblage_ptr)
@ -979,31 +815,6 @@ check_pp_assemblage(cxxPPassemblage *pp_assemblage_ptr)
}
return (TRUE);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
check_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Check list of all elements in pure_phase assemblage to see
* if all are in model. Return true if all are present,
* Return false if one or more is missing.
*/
int j;
struct master *master_ptr;
for (j = 0; pp_assemblage_ptr->next_elt[j].elt != NULL; j++)
{
master_ptr = pp_assemblage_ptr->next_elt[j].elt->primary;
if (master_ptr->s == s_h2o || master_ptr->s == s_hplus)
continue;
if (master_ptr->total > MIN_TOTAL)
continue;
return (FALSE);
}
return (TRUE);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
add_reaction(cxxReaction *reaction_ptr, int step_number, LDBLE step_fraction)
@ -1375,102 +1186,6 @@ add_ss_assemblage(cxxSSassemblage *ss_assemblage_ptr)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
add_ss_assemblage(cxxSSassemblage *ss_assemblage_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Accumulate solid_solution data in master->totals and _x variables.
*/
int i, j, k;
LDBLE amount_to_add, total;
struct s_s *s_s_ptr;
struct master *master_ptr;
char token[MAX_LENGTH];
char *ptr;
if (ss_assemblage_ptr == NULL)
return (OK);
count_elts = 0;
paren_count = 0;
/*
* Check that all elements are in solution for phases with greater than zero mass
*/
for (i = 0; i < ss_assemblage_ptr->count_s_s; i++)
{
count_elts = 0;
paren_count = 0;
s_s_ptr = &(ss_assemblage_ptr->s_s[i]);
for (j = 0; j < s_s_ptr->count_comps; j++)
{
amount_to_add = 0.0;
s_s_ptr->comps[j].delta = 0.0;
if (s_s_ptr->comps[j].moles > 0.0)
{
strcpy(token, s_s_ptr->comps[j].phase->formula);
ptr = &(token[0]);
get_elts_in_species(&ptr, 1.0);
for (k = 0; k < count_elts; k++)
{
master_ptr = elt_list[k].elt->primary;
if (master_ptr->s == s_hplus)
{
continue;
}
else if (master_ptr->s == s_h2o)
{
continue;
}
else if (master_ptr->total > MIN_TOTAL_SS)
{
continue;
}
else
{
total =
(-master_ptr->total + 1e-10) / elt_list[k].coef;
if (amount_to_add < total)
{
amount_to_add = total;
}
}
}
}
if (s_s_ptr->comps[j].moles < amount_to_add)
{
amount_to_add = s_s_ptr->comps[j].moles;
}
if (amount_to_add > 0.0)
{
s_s_ptr->comps[j].moles -= amount_to_add;
s_s_ptr->comps[j].delta = amount_to_add;
/*
* Add reaction to totals
*/
for (k = 0; k < count_elts; k++)
{
master_ptr = elt_list[k].elt->primary;
if (master_ptr->s == s_hplus)
{
total_h_x += elt_list[k].coef * amount_to_add;
}
else if (master_ptr->s == s_h2o)
{
total_o_x += elt_list[k].coef * amount_to_add;
}
else
{
master_ptr->total += elt_list[k].coef * amount_to_add;
}
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
add_kinetics(struct kinetics *kinetics_ptr)
@ -1662,91 +1377,6 @@ pp_assemblage_check(cxxPPassemblage *pp_assemblage_ptr)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
pp_assemblage_check(struct pp_assemblage *pp_assemblage_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Check for missing elements
*/
int i, j, k;
char token[MAX_LENGTH];
char *ptr;
struct pure_phase *pure_phase_ptr;
struct master *master_ptr;
if (check_pp_assemblage(pp_assemblage_ptr) == OK)
return (OK);
/*
* Check that all elements are in solution for phases with zero mass
*/
pure_phase_ptr = pp_assemblage_ptr->pure_phases;
for (j = 0; j < pp_assemblage_ptr->count_comps; j++)
{
count_elts = 0;
paren_count = 0;
if (pure_phase_ptr[j].moles <= 0.0)
{
pure_phase_ptr[j].delta = 0.0;
if (pure_phase_ptr[j].add_formula != NULL)
{
strcpy(token, pure_phase_ptr[j].add_formula);
ptr = &(token[0]);
get_elts_in_species(&ptr, 1.0);
}
else
{
strcpy(token, pure_phase_ptr[j].phase->formula);
add_elt_list(pure_phase_ptr[j].phase->next_elt, 1.0);
}
for (i = 0; i < count_elts; i++)
{
master_ptr = elt_list[i].elt->primary;
if (master_ptr->s == s_hplus)
{
continue;
}
else if (master_ptr->s == s_h2o)
{
continue;
}
else if (master_ptr->total > MIN_TOTAL)
{
continue;
}
else
{
if (state != ADVECTION && state != TRANSPORT
&& state != PHAST)
{
error_string = sformatf(
"Element %s is contained in %s (which has 0.0 mass),"
"\t\nbut is not in solution or other phases.",
elt_list[i].elt->name,
pure_phase_ptr[j].phase->name);
warning_msg(error_string);
}
/*
* Make la's of all master species for the element small, so SI will be small
* and no mass transfer will be calculated
*/
for (k = 0; k < count_master; k++)
{
if (master[k]->elt->primary == master_ptr)
{
master[k]->s->la = -9999.999;
}
}
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
ss_assemblage_check(cxxSSassemblage *ss_assemblage_ptr)
@ -1822,80 +1452,6 @@ ss_assemblage_check(cxxSSassemblage *ss_assemblage_ptr)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
ss_assemblage_check(struct ss_assemblage *ss_assemblage_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Check for missing elements
*/
int i, j, k, l;
struct master *master_ptr;
if (ss_assemblage_ptr == NULL)
return (OK);
/*
* Check that all elements are in solution for phases with zero mass
*/
for (i = 0; i < ss_assemblage_ptr->count_s_s; i++)
{
for (j = 0; j < ss_assemblage_ptr->s_s[i].count_comps; j++)
{
count_elts = 0;
paren_count = 0;
if (ss_assemblage_ptr->s_s[i].comps[j].moles <= 0.0)
{
add_elt_list(ss_assemblage_ptr->s_s[i].comps[j].phase->
next_elt, 1.0);
for (l = 0; l < count_elts; l++)
{
master_ptr = elt_list[l].elt->primary;
if (master_ptr->s == s_hplus)
{
continue;
}
else if (master_ptr->s == s_h2o)
{
continue;
}
else if (master_ptr->total > MIN_TOTAL_SS)
{
continue;
}
else
{
if (state != ADVECTION && state != TRANSPORT
&& state != PHAST)
{
error_string = sformatf(
"Element %s is contained in solid solution %s (which has 0.0 mass),\nbut is not in solution or other phases.",
elt_list[l].elt->name,
ss_assemblage_ptr->s_s[i].comps[j].
phase->name);
warning_msg(error_string);
}
}
/*
* Make la's of all master species for the element small,
* so SI will be small
* and no mass transfer will be calculated
*/
for (k = 0; k < count_master; k++)
{
if (master[k]->elt->primary == master_ptr)
{
master[k]->s->la = -9999.999;
}
}
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
solution_check(void)

File diff suppressed because it is too large Load Diff

View File

@ -464,23 +464,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
add_elt_list(reaction_ptr->Get_elementList(), moles);
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
}
#ifdef SKIP
irrev_ptr = irrev_bsearch(n_user[Reaction], &n);
if (irrev_ptr == NULL)
break;
count_elts = 0;
paren_count = 0;
if (n_buffer == 1)
{
moles = irrev_ptr->steps[0];
}
else
{
moles = 0.0;
}
add_elt_list(irrev_ptr->elts, moles);
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
#endif
break;
case Pure_phase:
/*
@ -533,12 +516,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
{
add_elt_list(comps[j]->Get_totals(), 1.0);
}
#ifdef SKIP
for (j = 0; j < exchange_ptr->count_comps; j++)
{
add_elt_list(exchange_ptr->comps[j].totals, 1.0);
}
#endif
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
@ -609,44 +586,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
}
break;
#ifdef SKIP
/*
* fill an solid solution phase
*/
if (n_user[Ss_phase] < 0)
break;
ss_assemblage_ptr = ss_assemblage_bsearch(n_user[Ss_phase], &n);
if (ss_assemblage_ptr == NULL)
break;
found = FALSE;
moles = 0.0;
for (j = 0; j < ss_assemblage_ptr->count_s_s; j++)
{
for (k = 0; k < ss_assemblage_ptr->s_s[j].count_comps; k++)
{
if (ss_assemblage_ptr->s_s[j].comps[k].phase->name ==
tally_table[i].name)
break;
if (strcmp_nocase
(ss_assemblage_ptr->s_s[j].comps[k].phase->name,
tally_table[i].name) == 0)
break;
}
if (k < ss_assemblage_ptr->s_s[j].count_comps)
{
moles = ss_assemblage_ptr->s_s[j].comps[k].moles;
found = TRUE;
break;
}
}
if (found == FALSE)
break;
count_elts = 0;
paren_count = 0;
add_elt_list(tally_table[i].formula, moles);
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
break;
#endif
case Gas_phase:
/*
* fill in gas phase
@ -674,29 +613,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
break;
}
#ifdef SKIP
/*
* fill in gas phase
*/
if (n_user[Gas_phase] < 0)
break;
//gas_phase_ptr = gas_phase_bsearch(n_user[Gas_phase], &n);
if (gas_phase_ptr == NULL)
break;
count_elts = 0;
paren_count = 0;
for (j = 0; j < gas_phase_ptr->count_comps; j++)
{
add_elt_list(gas_phase_ptr->comps[j].phase->next_elt,
gas_phase_ptr->comps[j].moles);
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
break;
#endif
case Kinetics:
/*
* fill in kinetics
@ -732,16 +648,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
case UnKnown:
break;
}
#ifdef SKIP
output_msg(sformatf( "Column %d\t%s\tType: %d\n", i,
tally_table[i].name, tally_table[i].type));
for (j = 0; j < count_tally_table_rows; j++)
{
output_msg(sformatf( "\t%d\t%s\t%e\n", j,
tally_table[i].total[n_buffer][j].name,
(double) tally_table[i].total[n_buffer][j].moles));
}
#endif
}
return (OK);
@ -874,20 +780,6 @@ build_tally_table(void)
{
count_tt_exchange = 0;
}
#ifdef SKIP
if (count_exchange > 0)
{
count_tt_exchange = 1;
n = count_tally_table_columns;
extend_tally_table();
tally_table[n].name = string_hsave("Exchange");
tally_table[n].type = Exchange;
}
else
{
count_tt_exchange = 0;
}
#endif
/*
* add one for surface
*/
@ -984,62 +876,6 @@ build_tally_table(void)
}
}
}
#ifdef SKIP
count_tt_pure_phase = 0;
if (count_pp_assemblage > 0)
{
/*
* Go through all pure phases in pure phase assemblages
*/
for (i = 0; i < count_pp_assemblage; i++)
{
pp_assemblage_ptr = &pp_assemblage[i];
for (j = 0; j < pp_assemblage_ptr->count_comps; j++)
{
pure_phase_ptr = &pp_assemblage_ptr->pure_phases[j];
/*
* check if already in tally_table
*/
for (k = 1; k < count_tally_table_columns; k++)
{
if (tally_table[k].type == Pure_phase &&
tally_table[k].name == pure_phase_ptr->phase->name &&
tally_table[k].add_formula ==
pure_phase_ptr->add_formula)
break;
}
if (k < count_tally_table_columns)
continue;
/*
* Add to table
*/
count_tt_pure_phase++;
n = count_tally_table_columns;
extend_tally_table();
tally_table[n].name = pure_phase_ptr->phase->name;
tally_table[n].type = Pure_phase;
tally_table[n].add_formula = pure_phase_ptr->add_formula;
count_elts = 0;
paren_count = 0;
if (pure_phase_ptr->add_formula != NULL)
{
strcpy(token, pure_phase_ptr->add_formula);
ptr = &(token[0]);
get_elts_in_species(&ptr, 1.0);
}
else
{
strcpy(token, pure_phase_ptr->phase->formula);
add_elt_list(pure_phase_ptr->phase->next_elt, 1.0);
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
tally_table[n].formula = elt_list_save();
}
}
}
#endif
/*
* Add solid-solution pure phases
*/
@ -1096,53 +932,6 @@ build_tally_table(void)
}
}
}
#ifdef SKIP
if (count_ss_assemblage > 0)
{
/*
* Go through all components of all solid solutions in solid-solution assemblages
*/
for (i = 0; i < count_ss_assemblage; i++)
{
ss_assemblage_ptr = &ss_assemblage[i];
for (j = 0; j < ss_assemblage_ptr->count_s_s; j++)
{
s_s_ptr = &ss_assemblage_ptr->s_s[j];
for (k = 0; k < s_s_ptr->count_comps; k++)
{
s_s_comp_ptr = &s_s_ptr->comps[k];
/*
* check if already in tally_table
*/
for (l = 1; l < count_tally_table_columns; l++)
{
if (tally_table[l].type == Ss_phase &&
tally_table[l].name == s_s_comp_ptr->phase->name)
break;
}
if (l < count_tally_table_columns)
continue;
/*
* Add to table
*/
count_tt_ss_phase++;
n = count_tally_table_columns;
extend_tally_table();
tally_table[n].name = s_s_comp_ptr->phase->name;
tally_table[n].type = Ss_phase;
count_elts = 0;
paren_count = 0;
strcpy(token, s_s_comp_ptr->phase->formula);
add_elt_list(s_s_comp_ptr->phase->next_elt, 1.0);
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
tally_table[n].formula = elt_list_save();
}
}
}
}
#endif
/*
* Add kinetic reactants
*/
@ -1280,12 +1069,6 @@ add_all_components_tally(void)
add_reaction(&it->second, 1, 1.0);
}
}
#ifdef SKIP
for (i = 0; i < count_irrev; i++)
{
add_reaction(&irrev[i], 1, 1.0);
}
#endif
/*
* Add pure phases
*/
@ -1296,12 +1079,6 @@ add_all_components_tally(void)
add_pp_assemblage(&(it->second));
}
}
#ifdef SKIP
for (i = 0; i < count_pp_assemblage; i++)
{
add_pp_assemblage(&pp_assemblage[i]);
}
#endif
/*
* Exchangers
*/
@ -1312,12 +1089,6 @@ add_all_components_tally(void)
add_exchange(&it->second);
}
}
#ifdef SKIP
for (i = 0; i < count_exchange; i++)
{
add_exchange(&exchange[i]);
}
#endif
/*
* Surfaces
*/
@ -1335,12 +1106,6 @@ add_all_components_tally(void)
add_gas_phase(&it->second);
}
}
#ifdef SKIP
for (i = 0; i < count_gas_phase; i++)
{
add_gas_phase(&gas_phase[i]);
}
#endif
/*
* Add solid-solution pure phases
*/
@ -1349,12 +1114,6 @@ add_all_components_tally(void)
{
add_ss_assemblage(&(it->second));
}
#ifdef SKIP
for (i = 0; i < count_ss_assemblage; i++)
{
add_ss_assemblage(&ss_assemblage[i]);
}
#endif
/*
* Add elements in kinetic reactions
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -45,20 +45,6 @@ add_elt_list(const cxxNameDouble & nd, LDBLE coef)
elt_list[count_elts].coef = cit->second * coef;
count_elts++;
}
#ifdef SKIP
for (elt_list_ptr1 = elt_list_ptr; elt_list_ptr1->elt != NULL;
elt_list_ptr1++)
{
if (count_elts >= max_elts)
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
}
elt_list[count_elts].elt = elt_list_ptr1->elt;
elt_list[count_elts].coef = elt_list_ptr1->coef * coef;
count_elts++;
}
#endif
return (OK);
}