mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
last_model
This commit is contained in:
parent
7a6b8b6d92
commit
2b14f8090e
27
Phreeqc.cpp
27
Phreeqc.cpp
@ -445,30 +445,15 @@ void Phreeqc::init(void)
|
||||
/*
|
||||
* last model
|
||||
*/
|
||||
last_model.force_prep = TRUE;
|
||||
last_model.temperature = -100;
|
||||
last_model.pressure = 0;
|
||||
last_model.count_exchange = -1;
|
||||
last_model.exchange = NULL;
|
||||
last_model.count_kinetics = -1;
|
||||
last_model.kinetics = NULL;
|
||||
last_model.count_gas_phase = -1;
|
||||
last_model.force_prep = true;
|
||||
last_model.gas_phase_type = cxxGasPhase::GP_UNKNOWN;
|
||||
last_model.gas_phase = NULL;
|
||||
last_model.count_ss_assemblage = -1;
|
||||
last_model.ss_assemblage = NULL;
|
||||
last_model.count_pp_assemblage = -1;
|
||||
last_model.pp_assemblage = NULL;
|
||||
last_model.add_formula = NULL;
|
||||
last_model.si = NULL;
|
||||
last_model.gas_phase.clear();
|
||||
last_model.ss_assemblage.clear();
|
||||
last_model.pp_assemblage.clear();
|
||||
last_model.add_formula.clear();
|
||||
last_model.si.clear();
|
||||
last_model.dl_type = cxxSurface::NO_DL;
|
||||
last_model.surface_type = cxxSurface::UNKNOWN_DL;
|
||||
last_model.only_counter_ions = FALSE;
|
||||
last_model.thickness = 1e-8;
|
||||
last_model.count_surface_comp = -1;
|
||||
last_model.surface_comp = NULL;
|
||||
last_model.count_surface_charge = -1;
|
||||
last_model.surface_charge = NULL;
|
||||
|
||||
current_selected_output = NULL;
|
||||
current_user_punch = NULL;
|
||||
|
||||
@ -60,7 +60,7 @@ advection(void)
|
||||
/*
|
||||
* Equilibrate solutions with phases, exchangers, surfaces
|
||||
*/
|
||||
last_model.force_prep = TRUE;
|
||||
last_model.force_prep = true;
|
||||
rate_sim_time_start = 0;
|
||||
for (advection_step = 1; advection_step <= count_ad_shifts;
|
||||
advection_step++)
|
||||
|
||||
@ -193,37 +193,33 @@ typedef struct PHRQMemHeader
|
||||
|
||||
struct model
|
||||
{
|
||||
int force_prep;
|
||||
LDBLE temperature;
|
||||
int count_exchange;
|
||||
struct master **exchange;
|
||||
bool force_prep;
|
||||
//LDBLE temperaturex; // not used
|
||||
//LDBLE pressure; // not used
|
||||
|
||||
int count_kinetics;
|
||||
struct kinetics *kinetics;
|
||||
//int count_exchange;
|
||||
//struct master **exchange; // not used
|
||||
|
||||
int count_gas_phase;
|
||||
//int count_kinetics;
|
||||
//struct kinetics *kinetics; // not used
|
||||
|
||||
bool numerical_fixed_volume;
|
||||
cxxGasPhase::GP_TYPE gas_phase_type;
|
||||
struct phase **gas_phase;
|
||||
std::vector<struct phase*> gas_phase;
|
||||
|
||||
int count_ss_assemblage;
|
||||
const char **ss_assemblage;
|
||||
std::vector<const char*> ss_assemblage;
|
||||
|
||||
int count_pp_assemblage;
|
||||
struct phase **pp_assemblage;
|
||||
const char **add_formula;
|
||||
LDBLE *si;
|
||||
std::vector<struct phase*> pp_assemblage;
|
||||
std::vector<double> si;
|
||||
std::vector<const char*> add_formula;
|
||||
|
||||
cxxSurface::DIFFUSE_LAYER_TYPE dl_type;
|
||||
cxxSurface::SURFACE_TYPE surface_type;
|
||||
int only_counter_ions;
|
||||
//bool only_counter_ions; // not used
|
||||
|
||||
LDBLE thickness;
|
||||
int count_surface_comp;
|
||||
const char **surface_comp;
|
||||
int count_surface_charge;
|
||||
const char **surface_charge;
|
||||
LDBLE pressure;
|
||||
bool numerical_fixed_volume;
|
||||
//LDBLE thickness; // not used
|
||||
std::vector<const char*> surface_comp;
|
||||
std::vector<const char*> surface_charge;
|
||||
};
|
||||
|
||||
struct name_master
|
||||
|
||||
@ -5001,7 +5001,7 @@ surface_model(void)
|
||||
*/
|
||||
debug_diffuse_layer_save = debug_diffuse_layer;
|
||||
debug_model_save = debug_model;
|
||||
if (last_model.force_prep == TRUE)
|
||||
if (last_model.force_prep)
|
||||
{
|
||||
same_model = FALSE;
|
||||
}
|
||||
|
||||
110
prep.cpp
110
prep.cpp
@ -34,7 +34,7 @@ prep(void)
|
||||
else
|
||||
{
|
||||
same_model = FALSE;
|
||||
last_model.force_prep = TRUE;
|
||||
last_model.force_prep = true;
|
||||
}
|
||||
/*same_model = FALSE; */
|
||||
/*
|
||||
@ -5665,14 +5665,6 @@ save_model(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
int i;
|
||||
/*
|
||||
* save temperature
|
||||
*/
|
||||
last_model.temperature = tc_x;
|
||||
/*
|
||||
* save pressure
|
||||
*/
|
||||
last_model.pressure = patm_x;
|
||||
/*
|
||||
* mark master species
|
||||
*/
|
||||
@ -5695,18 +5687,11 @@ save_model(void)
|
||||
/*
|
||||
* save list of phase pointers for gas phase
|
||||
*/
|
||||
last_model.gas_phase =
|
||||
(struct phase **) free_check_null(last_model.gas_phase);
|
||||
if (use.Get_gas_phase_ptr() != NULL)
|
||||
{
|
||||
cxxGasPhase * gas_phase_ptr = use.Get_gas_phase_ptr();
|
||||
last_model.count_gas_phase = (int) gas_phase_ptr->Get_gas_comps().size();
|
||||
last_model.gas_phase_type = gas_phase_ptr->Get_type();
|
||||
last_model.gas_phase =
|
||||
(struct phase **) PHRQ_malloc((size_t) last_model.count_gas_phase *
|
||||
sizeof(struct phase *));
|
||||
if (last_model.gas_phase == NULL)
|
||||
malloc_error();
|
||||
last_model.gas_phase.resize(gas_phase_ptr->Get_gas_comps().size());
|
||||
for (size_t i = 0; i < gas_phase_ptr->Get_gas_comps().size(); i++)
|
||||
{
|
||||
cxxGasComp *gc_ptr = &(gas_phase_ptr->Get_gas_comps()[i]);
|
||||
@ -5718,23 +5703,15 @@ save_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
last_model.count_gas_phase = 0;
|
||||
last_model.gas_phase_type = cxxGasPhase::GP_UNKNOWN;
|
||||
last_model.gas_phase = NULL;
|
||||
last_model.gas_phase.clear();
|
||||
}
|
||||
/*
|
||||
* save list of names of solid solutions
|
||||
*/
|
||||
last_model.ss_assemblage =
|
||||
(const char **) free_check_null(last_model.ss_assemblage);
|
||||
if (use.Get_ss_assemblage_ptr() != NULL)
|
||||
{
|
||||
size_t count_ss = use.Get_ss_assemblage_ptr()->Get_SSs().size();
|
||||
last_model.count_ss_assemblage = (int) count_ss;
|
||||
last_model.ss_assemblage =
|
||||
(const char **) PHRQ_malloc(count_ss * sizeof(char *));
|
||||
if (last_model.ss_assemblage == NULL)
|
||||
malloc_error();
|
||||
last_model.ss_assemblage.resize(use.Get_ss_assemblage_ptr()->Get_SSs().size());
|
||||
std::vector<cxxSS *> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
|
||||
for (size_t j = 0; j < ss_ptrs.size(); j++)
|
||||
{
|
||||
@ -5743,34 +5720,17 @@ save_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
last_model.count_ss_assemblage = 0;
|
||||
last_model.ss_assemblage = NULL;
|
||||
last_model.ss_assemblage.clear();
|
||||
}
|
||||
/*
|
||||
* save list of phase pointers for pp_assemblage
|
||||
*/
|
||||
last_model.pp_assemblage =
|
||||
(struct phase **) free_check_null(last_model.pp_assemblage);
|
||||
last_model.add_formula =
|
||||
(const char **) free_check_null(last_model.add_formula);
|
||||
last_model.si = (LDBLE *) free_check_null(last_model.si);
|
||||
if (use.Get_pp_assemblage_ptr() != NULL)
|
||||
{
|
||||
cxxPPassemblage * pp_assemblage_ptr = use.Get_pp_assemblage_ptr();
|
||||
last_model.count_pp_assemblage = (int) pp_assemblage_ptr->Get_pp_assemblage_comps().size();
|
||||
last_model.pp_assemblage =
|
||||
(struct phase **) PHRQ_malloc((size_t) last_model.count_pp_assemblage *
|
||||
sizeof(struct phase *));
|
||||
if (last_model.pp_assemblage == NULL)
|
||||
malloc_error();
|
||||
last_model.add_formula =
|
||||
(const char **) PHRQ_malloc((size_t)last_model.count_pp_assemblage * sizeof(char *));
|
||||
if (last_model.add_formula == NULL)
|
||||
malloc_error();
|
||||
last_model.si =
|
||||
(LDBLE *) PHRQ_malloc((size_t) last_model.count_pp_assemblage * sizeof(LDBLE));
|
||||
if (last_model.si == NULL)
|
||||
malloc_error();
|
||||
last_model.pp_assemblage.resize(pp_assemblage_ptr->Get_pp_assemblage_comps().size());
|
||||
last_model.add_formula.resize(pp_assemblage_ptr->Get_pp_assemblage_comps().size());
|
||||
last_model.si.resize(pp_assemblage_ptr->Get_pp_assemblage_comps().size());
|
||||
std::map<std::string, cxxPPassemblageComp>::iterator it;
|
||||
it = pp_assemblage_ptr->Get_pp_assemblage_comps().begin();
|
||||
i = 0;
|
||||
@ -5787,37 +5747,23 @@ save_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
last_model.count_pp_assemblage = 0;
|
||||
last_model.pp_assemblage = NULL;
|
||||
last_model.add_formula = NULL;
|
||||
last_model.si = NULL;
|
||||
last_model.pp_assemblage.clear();
|
||||
last_model.add_formula.clear();
|
||||
last_model.si.clear();
|
||||
}
|
||||
/*
|
||||
* save data for surface
|
||||
*/
|
||||
last_model.surface_comp =
|
||||
(const char **) free_check_null(last_model.surface_comp);
|
||||
last_model.surface_charge =
|
||||
(const char **) free_check_null(last_model.surface_charge);
|
||||
if (use.Get_surface_ptr() != NULL)
|
||||
{
|
||||
/* comps */
|
||||
last_model.count_surface_comp = (int) use.Get_surface_ptr()->Get_surface_comps().size();
|
||||
last_model.surface_comp =
|
||||
(const char **) PHRQ_malloc(use.Get_surface_ptr()->Get_surface_comps().size() *
|
||||
sizeof(char *));
|
||||
if (last_model.surface_comp == NULL)
|
||||
malloc_error();
|
||||
last_model.surface_comp.resize(use.Get_surface_ptr()->Get_surface_comps().size());
|
||||
for (i = 0; i < (int) use.Get_surface_ptr()->Get_surface_comps().size(); i++)
|
||||
{
|
||||
last_model.surface_comp[i] = string_hsave(use.Get_surface_ptr()->Get_surface_comps()[i].Get_formula().c_str());
|
||||
}
|
||||
/* charge */
|
||||
last_model.count_surface_charge = (int) use.Get_surface_ptr()->Get_surface_charges().size();
|
||||
last_model.surface_charge =(const char **) PHRQ_malloc( use.Get_surface_ptr()->Get_surface_charges().size() *
|
||||
sizeof(char *));
|
||||
if (last_model.surface_charge == NULL)
|
||||
malloc_error();
|
||||
last_model.surface_charge.resize(use.Get_surface_ptr()->Get_surface_charges().size());
|
||||
for (i = 0; i < (int) use.Get_surface_ptr()->Get_surface_charges().size(); i++)
|
||||
{
|
||||
last_model.surface_charge[i] = string_hsave(use.Get_surface_ptr()->Get_surface_charges()[i].Get_name().c_str());
|
||||
@ -5831,10 +5777,8 @@ save_model(void)
|
||||
last_model.dl_type = cxxSurface::NO_DL;
|
||||
/*last_model.edl = -1; */
|
||||
last_model.surface_type = cxxSurface::UNKNOWN_DL;
|
||||
last_model.count_surface_comp = 0;
|
||||
last_model.surface_comp = NULL;
|
||||
last_model.count_surface_charge = 0;
|
||||
last_model.surface_charge = NULL;
|
||||
last_model.surface_comp.clear();
|
||||
last_model.surface_charge.clear();
|
||||
}
|
||||
|
||||
current_tc = NAN;
|
||||
@ -5856,9 +5800,9 @@ check_same_model(void)
|
||||
/*
|
||||
* Force new model to be built in prep
|
||||
*/
|
||||
if (last_model.force_prep == TRUE)
|
||||
if (last_model.force_prep)
|
||||
{
|
||||
last_model.force_prep = FALSE;
|
||||
last_model.force_prep = false;
|
||||
return (FALSE);
|
||||
}
|
||||
if (state == TRANSPORT && cell_data[cell_no].same_model)
|
||||
@ -5897,12 +5841,10 @@ check_same_model(void)
|
||||
if (use.Get_gas_phase_ptr() != NULL)
|
||||
{
|
||||
cxxGasPhase * gas_phase_ptr = use.Get_gas_phase_ptr();
|
||||
if (last_model.gas_phase == NULL)
|
||||
if (last_model.gas_phase.size() != (int)gas_phase_ptr->Get_gas_comps().size())
|
||||
return (FALSE);
|
||||
if (last_model.numerical_fixed_volume != numerical_fixed_volume)
|
||||
return (FALSE);
|
||||
if (last_model.count_gas_phase != (int) gas_phase_ptr->Get_gas_comps().size())
|
||||
return (FALSE);
|
||||
if (last_model.gas_phase_type != gas_phase_ptr->Get_type())
|
||||
return (FALSE);
|
||||
for (i = 0; i < (int) gas_phase_ptr->Get_gas_comps().size(); i++)
|
||||
@ -5919,7 +5861,7 @@ check_same_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_model.gas_phase != NULL)
|
||||
if (last_model.gas_phase.size() > 0)
|
||||
return (FALSE);
|
||||
}
|
||||
/*
|
||||
@ -5927,7 +5869,7 @@ check_same_model(void)
|
||||
*/
|
||||
if (use.Get_ss_assemblage_ptr() != NULL)
|
||||
{
|
||||
if (last_model.count_ss_assemblage != (int) use.Get_ss_assemblage_ptr()->Get_SSs().size())
|
||||
if (last_model.ss_assemblage.size() != (int) use.Get_ss_assemblage_ptr()->Get_SSs().size())
|
||||
return (FALSE);
|
||||
std::vector<cxxSS *> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
|
||||
for (size_t i = 0; i < ss_ptrs.size(); i++)
|
||||
@ -5940,7 +5882,7 @@ check_same_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_model.ss_assemblage != NULL)
|
||||
if (last_model.ss_assemblage.size() > 0)
|
||||
return (FALSE);
|
||||
}
|
||||
/*
|
||||
@ -5949,7 +5891,7 @@ check_same_model(void)
|
||||
if (use.Get_pp_assemblage_ptr() != NULL)
|
||||
{
|
||||
cxxPPassemblage * pp_assemblage_ptr = use.Get_pp_assemblage_ptr();
|
||||
if (last_model.count_pp_assemblage != (int) pp_assemblage_ptr->Get_pp_assemblage_comps().size())
|
||||
if (last_model.pp_assemblage.size() != (int) pp_assemblage_ptr->Get_pp_assemblage_comps().size())
|
||||
return (FALSE);
|
||||
|
||||
std::map<std::string, cxxPPassemblageComp>::iterator it;
|
||||
@ -5980,7 +5922,7 @@ check_same_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_model.pp_assemblage != NULL)
|
||||
if (last_model.pp_assemblage.size() > 0)
|
||||
return (FALSE);
|
||||
}
|
||||
/*
|
||||
@ -5988,9 +5930,9 @@ check_same_model(void)
|
||||
*/
|
||||
if (use.Get_surface_ptr() != NULL)
|
||||
{
|
||||
if (last_model.count_surface_comp != (int) use.Get_surface_ptr()->Get_surface_comps().size())
|
||||
if (last_model.surface_comp.size() != (int) use.Get_surface_ptr()->Get_surface_comps().size())
|
||||
return (FALSE);
|
||||
if (last_model.count_surface_charge != (int) use.Get_surface_ptr()->Get_surface_charges().size())
|
||||
if (last_model.surface_charge.size() != (int) use.Get_surface_ptr()->Get_surface_charges().size())
|
||||
return (FALSE);
|
||||
if (last_model.dl_type != use.Get_surface_ptr()->Get_dl_type())
|
||||
return (FALSE);
|
||||
@ -6041,7 +5983,7 @@ check_same_model(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_model.surface_comp != NULL)
|
||||
if (last_model.surface_comp.size() > 0)
|
||||
return (FALSE);
|
||||
}
|
||||
/*
|
||||
|
||||
@ -43,22 +43,13 @@ clean_up(void)
|
||||
(char*)free_check_null(moles_per_kilogram_string);
|
||||
pe_string = (char*)free_check_null(pe_string);
|
||||
/* model */
|
||||
last_model.exchange =
|
||||
(struct master**)free_check_null(last_model.exchange);
|
||||
last_model.gas_phase =
|
||||
(struct phase**)free_check_null(last_model.gas_phase);
|
||||
last_model.pp_assemblage =
|
||||
(struct phase**)free_check_null(last_model.pp_assemblage);
|
||||
last_model.ss_assemblage =
|
||||
(const char**)free_check_null(last_model.ss_assemblage);
|
||||
last_model.add_formula =
|
||||
(const char**)free_check_null(last_model.add_formula);
|
||||
last_model.si = (LDBLE*)free_check_null(last_model.si);
|
||||
last_model.surface_comp =
|
||||
(const char**)free_check_null(last_model.surface_comp);
|
||||
last_model.surface_charge =
|
||||
(const char**)free_check_null(last_model.surface_charge);
|
||||
|
||||
last_model.gas_phase.clear();
|
||||
last_model.pp_assemblage.clear();
|
||||
last_model.add_formula.clear();
|
||||
last_model.si.clear();
|
||||
last_model.ss_assemblage.clear();
|
||||
last_model.surface_comp.clear();
|
||||
last_model.surface_charge.clear();
|
||||
/* model */
|
||||
free_model_allocs();
|
||||
|
||||
|
||||
31
tidy.cpp
31
tidy.cpp
@ -5613,30 +5613,15 @@ reset_last_model(void)
|
||||
/*
|
||||
* Initialize model
|
||||
*/
|
||||
last_model.force_prep = TRUE;
|
||||
last_model.count_exchange = 0;
|
||||
last_model.exchange =
|
||||
(struct master **) free_check_null(last_model.exchange);
|
||||
last_model.count_gas_phase = 0;
|
||||
last_model.gas_phase_type = cxxGasPhase::GP_UNKNOWN;
|
||||
last_model.gas_phase =
|
||||
(struct phase **) free_check_null(last_model.gas_phase);
|
||||
last_model.count_ss_assemblage = 0;
|
||||
last_model.ss_assemblage =
|
||||
(const char **) free_check_null(last_model.ss_assemblage);
|
||||
last_model.count_pp_assemblage = 0;
|
||||
last_model.pp_assemblage =
|
||||
(struct phase **) free_check_null(last_model.pp_assemblage);
|
||||
last_model.add_formula =
|
||||
(const char **) free_check_null(last_model.add_formula);
|
||||
last_model.si = (LDBLE *) free_check_null(last_model.si);
|
||||
last_model.force_prep = true;
|
||||
last_model.gas_phase.clear();
|
||||
last_model.ss_assemblage.clear();
|
||||
last_model.pp_assemblage.clear();
|
||||
last_model.add_formula.clear();
|
||||
last_model.si.clear();
|
||||
last_model.dl_type = cxxSurface::NO_DL;
|
||||
last_model.count_surface_comp = 0;
|
||||
last_model.surface_comp =
|
||||
(const char **) free_check_null(last_model.surface_comp);
|
||||
last_model.count_surface_charge = 0;
|
||||
last_model.surface_charge =
|
||||
(const char **) free_check_null(last_model.surface_charge);
|
||||
last_model.surface_comp.clear();
|
||||
last_model.surface_charge.clear();
|
||||
return (OK);
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -397,7 +397,7 @@ transport(void)
|
||||
/*
|
||||
* Set boundary conditions, transport direction
|
||||
*/
|
||||
last_model.force_prep = TRUE;
|
||||
last_model.force_prep = true;
|
||||
if ((ishift == 0) || (bcon_first == 1) || (bcon_last == 1))
|
||||
b_c = 1;
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user