mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Added f = EQ_FRAC("AlX3", eq, x$)
Also added synonyms PHASE_FORMULA$ and SPECIES_FORMULA$. git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@7829 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
4b643b866b
commit
a03d2ae87e
68
PBasic.cpp
68
PBasic.cpp
@ -1495,10 +1495,12 @@ listtokens(FILE * f, tokenrec * l_buf)
|
||||
output_msg("ISO_UNIT");
|
||||
break;
|
||||
case tokphase_formula:
|
||||
output_msg("PHASE_FORMULA");
|
||||
case tokphase_formula_:
|
||||
output_msg("PHASE_FORMULA$");
|
||||
break;
|
||||
case tokspecies_formula:
|
||||
output_msg("SPECIES_FORMULA");
|
||||
case tokspecies_formula_:
|
||||
output_msg("SPECIES_FORMULA$");
|
||||
break;
|
||||
case toklist_s_s:
|
||||
output_msg("LIST_S_S");
|
||||
@ -1551,6 +1553,9 @@ listtokens(FILE * f, tokenrec * l_buf)
|
||||
case tokstr_e_:
|
||||
output_msg("STR_E$");
|
||||
break;
|
||||
case tokeq_frac:
|
||||
output_msg("EQ_FRAC");
|
||||
break;
|
||||
}
|
||||
l_buf = l_buf->next;
|
||||
}
|
||||
@ -2695,6 +2700,7 @@ factor(struct LOC_exec * LINK)
|
||||
}
|
||||
|
||||
case tokphase_formula:
|
||||
case tokphase_formula_:
|
||||
{
|
||||
require(toklp, LINK);
|
||||
std::string phase_name(stringfactor(STR1, LINK));
|
||||
@ -2800,6 +2806,7 @@ factor(struct LOC_exec * LINK)
|
||||
break;
|
||||
}
|
||||
case tokspecies_formula:
|
||||
case tokspecies_formula_:
|
||||
{
|
||||
require(toklp, LINK);
|
||||
std::string species_name(stringfactor(STR1, LINK));
|
||||
@ -3394,6 +3401,58 @@ factor(struct LOC_exec * LINK)
|
||||
PhreeqcPtr->free_check_null(token);
|
||||
}
|
||||
break;
|
||||
case tokeq_frac:
|
||||
{
|
||||
// left parenthesis
|
||||
require(toklp, LINK);
|
||||
|
||||
// species name
|
||||
std::string species_name(stringfactor(STR1, LINK));
|
||||
|
||||
require(tokcomma, LINK);
|
||||
|
||||
// equivalents
|
||||
count_varrec = LINK->t->UU.vp;
|
||||
if (LINK->t->kind != tokvar || count_varrec->stringvar != 0)
|
||||
snerr(": Cannot find equivalents variable");
|
||||
|
||||
LINK->t = LINK->t->next;
|
||||
require(tokcomma, LINK);
|
||||
|
||||
// exchange or surface element
|
||||
varrec *elt_varrec = NULL;
|
||||
elt_varrec = LINK->t->UU.vp;
|
||||
if (LINK->t->kind != tokvar || elt_varrec->stringvar != 1)
|
||||
snerr(": Cannot find element string variable");
|
||||
free_dim_stringvar(elt_varrec);
|
||||
|
||||
// right parenthesis
|
||||
LINK->t = LINK->t->next;
|
||||
require(tokrp, LINK);
|
||||
|
||||
// Make work space
|
||||
//int max_length = length < 256 ? 256 : length;
|
||||
//char *token = (char *) PhreeqcPtr->PHRQ_calloc(size_t (max_length + 1), sizeof(char));
|
||||
//if (token == NULL) PhreeqcPtr->malloc_error();
|
||||
|
||||
// set function value
|
||||
LDBLE eq;
|
||||
std::string elt_name;
|
||||
|
||||
// return equivalent fraction
|
||||
n.UU.val = PhreeqcPtr->equivalent_fraction(species_name.c_str(), &eq, elt_name);
|
||||
|
||||
// set equivalents
|
||||
*count_varrec->UU.U0.val = eq;
|
||||
|
||||
// set element name
|
||||
size_t l = elt_name.size();
|
||||
l = l < 256 ? 256 : l + 1;
|
||||
char * token = (char *) PhreeqcPtr->PHRQ_malloc( l, sizeof(char));
|
||||
strcpy(token, elt_name.c_str());
|
||||
*elt_varrec->UU.U1.sval = token;
|
||||
}
|
||||
break;
|
||||
case tokval:
|
||||
l_s = strfactor(LINK);
|
||||
tok1 = LINK->t;
|
||||
@ -6638,6 +6697,7 @@ const std::map<const std::string, PBasic::BASIC_TOKEN>::value_type temp_tokens[]
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("iso", PBasic::tokiso),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("iso_unit", PBasic::tokiso_unit),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("phase_formula", PBasic::tokphase_formula),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("phase_formula$", PBasic::tokphase_formula_),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("list_s_s", PBasic::toklist_s_s),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("pr_p", PBasic::tokpr_p),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("pr_phi", PBasic::tokpr_phi),
|
||||
@ -6658,7 +6718,9 @@ const std::map<const std::string, PBasic::BASIC_TOKEN>::value_type temp_tokens[]
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("kin_time", PBasic::tokkin_time),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("str_f$", PBasic::tokstr_f_),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("str_e$", PBasic::tokstr_e_),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("species_formula", PBasic::tokspecies_formula)
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("species_formula", PBasic::tokspecies_formula),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("species_formula$", PBasic::tokspecies_formula_),
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("eq_frac", PBasic::tokeq_frac)
|
||||
|
||||
};
|
||||
std::map<const std::string, PBasic::BASIC_TOKEN> PBasic::command_tokens(temp_tokens, temp_tokens + sizeof temp_tokens / sizeof temp_tokens[0]);
|
||||
|
||||
5
PBasic.h
5
PBasic.h
@ -295,7 +295,9 @@ public:
|
||||
tokceil,
|
||||
tokfloor,
|
||||
tokphase_formula,
|
||||
tokphase_formula_,
|
||||
tokspecies_formula,
|
||||
tokspecies_formula_,
|
||||
toklist_s_s,
|
||||
tokpr_p,
|
||||
tokpr_phi,
|
||||
@ -316,7 +318,8 @@ public:
|
||||
tokkin_delta,
|
||||
tokkin_time,
|
||||
tokstr_f_,
|
||||
tokstr_e_
|
||||
tokstr_e_,
|
||||
tokeq_frac
|
||||
};
|
||||
|
||||
#if !defined(PHREEQCI_GUI)
|
||||
|
||||
@ -98,6 +98,7 @@ public:
|
||||
LDBLE diff_layer_total(const char *total_name, const char *surface_name);
|
||||
LDBLE equi_phase(const char *phase_name);
|
||||
LDBLE equi_phase_delta(const char *phase_name);
|
||||
LDBLE equivalent_fraction(const char *name, LDBLE *eq, std::string &elt_name);
|
||||
LDBLE find_gas_comp(const char *gas_comp_name);
|
||||
LDBLE find_gas_p(void);
|
||||
LDBLE find_gas_vm(void);
|
||||
|
||||
@ -841,6 +841,37 @@ equi_phase_delta(const char *phase_name)
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
LDBLE Phreeqc::
|
||||
equivalent_fraction(const char *name, LDBLE *eq, std::string &elt_name)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
struct species *s_ptr = s_search(name);
|
||||
*eq = 0;
|
||||
elt_name.clear();
|
||||
LDBLE f = 0;
|
||||
if (s_ptr != NULL && (s_ptr->type == EX || s_ptr->type == SURF))
|
||||
{
|
||||
*eq = s_ptr->equiv;
|
||||
struct elt_list *next_elt;
|
||||
LDBLE tot=0.0;
|
||||
for (next_elt = s_ptr->next_elt; next_elt->elt != NULL; next_elt++)
|
||||
{
|
||||
if (next_elt->elt->master->s->type == SURF ||
|
||||
next_elt->elt->master->s->type == EX)
|
||||
{
|
||||
tot = total_mole(next_elt->elt->name);
|
||||
elt_name = next_elt->elt->name;
|
||||
}
|
||||
}
|
||||
if (s_ptr->in == TRUE && tot > 0.0)
|
||||
{
|
||||
f = s_ptr->moles * s_ptr->equiv / tot;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
LDBLE Phreeqc::
|
||||
find_gas_comp(const char *gas_comp_name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user