mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
base, sit arrays
This commit is contained in:
parent
90e8412074
commit
6907bb06c4
@ -1092,7 +1092,6 @@ void Phreeqc::init(void)
|
|||||||
OPRESS = -100.;
|
OPRESS = -100.;
|
||||||
A0 = 0;
|
A0 = 0;
|
||||||
aphi = NULL;
|
aphi = NULL;
|
||||||
spec = NULL;
|
|
||||||
cations = NULL;
|
cations = NULL;
|
||||||
anions = NULL;
|
anions = NULL;
|
||||||
neutrals = NULL;
|
neutrals = NULL;
|
||||||
@ -1137,9 +1136,6 @@ void Phreeqc::init(void)
|
|||||||
sit_MAXCATIONS = 0;
|
sit_MAXCATIONS = 0;
|
||||||
sit_FIRSTANION = 0;
|
sit_FIRSTANION = 0;
|
||||||
sit_MAXNEUTRAL = 0;
|
sit_MAXNEUTRAL = 0;
|
||||||
sit_IPRSNT = NULL;
|
|
||||||
sit_M = NULL;
|
|
||||||
sit_LGAMMA = NULL;
|
|
||||||
/* tidy.cpp ------------------------------- */
|
/* tidy.cpp ------------------------------- */
|
||||||
a0 = 0;
|
a0 = 0;
|
||||||
a1 = 0;
|
a1 = 0;
|
||||||
|
|||||||
@ -1802,7 +1802,8 @@ protected:
|
|||||||
LDBLE OTEMP, OPRESS;
|
LDBLE OTEMP, OPRESS;
|
||||||
LDBLE A0;
|
LDBLE A0;
|
||||||
struct pitz_param* aphi;
|
struct pitz_param* aphi;
|
||||||
struct species **spec, **cations, **anions, **neutrals;
|
std::vector<struct species*> spec;
|
||||||
|
struct species ** cations, ** anions, ** neutrals; // pointers to spec
|
||||||
int count_cations, count_anions, count_neutrals;
|
int count_cations, count_anions, count_neutrals;
|
||||||
int MAXCATIONS, FIRSTANION, MAXNEUTRAL;
|
int MAXCATIONS, FIRSTANION, MAXNEUTRAL;
|
||||||
struct pitz_param *mcb0, *mcb1, *mcc0;
|
struct pitz_param *mcb0, *mcb1, *mcc0;
|
||||||
@ -1836,8 +1837,8 @@ protected:
|
|||||||
LDBLE sit_A0;
|
LDBLE sit_A0;
|
||||||
int sit_count_cations, sit_count_anions, sit_count_neutrals;
|
int sit_count_cations, sit_count_anions, sit_count_neutrals;
|
||||||
int sit_MAXCATIONS, sit_FIRSTANION, sit_MAXNEUTRAL;
|
int sit_MAXCATIONS, sit_FIRSTANION, sit_MAXNEUTRAL;
|
||||||
int *sit_IPRSNT;
|
std::vector<int> sit_IPRSNT;
|
||||||
LDBLE *sit_M, *sit_LGAMMA;
|
std::vector<double> sit_M, sit_LGAMMA;
|
||||||
std::vector<int> s_list, cation_list, neutral_list, anion_list, ion_list, param_list;
|
std::vector<int> s_list, cation_list, neutral_list, anion_list, ion_list, param_list;
|
||||||
|
|
||||||
/* tidy.cpp ------------------------------- */
|
/* tidy.cpp ------------------------------- */
|
||||||
|
|||||||
14
pitzer.cpp
14
pitzer.cpp
@ -56,15 +56,9 @@ pitzer_tidy(void)
|
|||||||
/*
|
/*
|
||||||
* allocate pointers to species structures
|
* allocate pointers to species structures
|
||||||
*/
|
*/
|
||||||
if (spec != NULL)
|
spec.clear();
|
||||||
spec = (struct species **) free_check_null(spec);
|
spec.resize(3 * s.size(), NULL);
|
||||||
spec = (struct species **)
|
cations = &spec[0];
|
||||||
PHRQ_malloc((size_t) (3 * s.size() * sizeof(struct species *)));
|
|
||||||
if (spec == NULL)
|
|
||||||
malloc_error();
|
|
||||||
for (i = 0; i < 3 * (int)s.size(); i++)
|
|
||||||
spec[i] = NULL;
|
|
||||||
cations = spec;
|
|
||||||
neutrals = &(spec[s.size()]);
|
neutrals = &(spec[s.size()]);
|
||||||
anions = &(spec[2 * s.size()]);
|
anions = &(spec[2 * s.size()]);
|
||||||
MAXCATIONS = (int)s.size();
|
MAXCATIONS = (int)s.size();
|
||||||
@ -1649,7 +1643,7 @@ pitzer_clean_up(void)
|
|||||||
theta_params.clear();
|
theta_params.clear();
|
||||||
LGAMMA.clear();
|
LGAMMA.clear();
|
||||||
IPRSNT.clear();
|
IPRSNT.clear();
|
||||||
spec = (struct species **) free_check_null(spec);
|
spec.clear();
|
||||||
aphi = (struct pitz_param *) free_check_null(aphi);
|
aphi = (struct pitz_param *) free_check_null(aphi);
|
||||||
M.clear();
|
M.clear();
|
||||||
|
|
||||||
|
|||||||
5
prep.cpp
5
prep.cpp
@ -5814,9 +5814,8 @@ save_model(void)
|
|||||||
}
|
}
|
||||||
/* charge */
|
/* charge */
|
||||||
last_model.count_surface_charge = (int) use.Get_surface_ptr()->Get_surface_charges().size();
|
last_model.count_surface_charge = (int) use.Get_surface_ptr()->Get_surface_charges().size();
|
||||||
last_model.surface_charge =
|
last_model.surface_charge =(const char **) PHRQ_malloc( use.Get_surface_ptr()->Get_surface_charges().size() *
|
||||||
(const char **) PHRQ_malloc( use.Get_surface_ptr()->Get_surface_charges().size() *
|
sizeof(char *));
|
||||||
sizeof(char *));
|
|
||||||
if (last_model.surface_charge == NULL)
|
if (last_model.surface_charge == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
for (i = 0; i < (int) use.Get_surface_ptr()->Get_surface_charges().size(); i++)
|
for (i = 0; i < (int) use.Get_surface_ptr()->Get_surface_charges().size(); i++)
|
||||||
|
|||||||
44
sit.cpp
44
sit.cpp
@ -35,12 +35,10 @@ sit_tidy(void)
|
|||||||
/*
|
/*
|
||||||
* allocate pointers to species structures
|
* allocate pointers to species structures
|
||||||
*/
|
*/
|
||||||
if (spec != NULL) spec = (struct species **) free_check_null(spec);
|
spec.clear();
|
||||||
spec = (struct species **) PHRQ_malloc((size_t) (3 * s.size() * sizeof(struct species *)));
|
spec.resize(3 * s.size(), NULL);
|
||||||
if (spec == NULL) malloc_error();
|
|
||||||
for (i = 0; i < 3 * (int)s.size(); i++) spec[i] = NULL;
|
|
||||||
|
|
||||||
cations = spec;
|
cations = &spec[0];
|
||||||
neutrals = &(spec[s.size()]);
|
neutrals = &(spec[s.size()]);
|
||||||
anions = &(spec[2 * s.size()]);
|
anions = &(spec[2 * s.size()]);
|
||||||
sit_MAXCATIONS = (int)s.size();
|
sit_MAXCATIONS = (int)s.size();
|
||||||
@ -53,16 +51,9 @@ sit_tidy(void)
|
|||||||
/*
|
/*
|
||||||
* allocate other arrays for SIT
|
* allocate other arrays for SIT
|
||||||
*/
|
*/
|
||||||
if (sit_IPRSNT != NULL) sit_IPRSNT = (int *) free_check_null(sit_IPRSNT);
|
sit_IPRSNT.resize(3 * s.size());
|
||||||
sit_IPRSNT = (int *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(int)));
|
sit_M.resize(3 * s.size());
|
||||||
if (sit_IPRSNT == NULL) malloc_error();
|
sit_LGAMMA.resize(3 * s.size());
|
||||||
if (sit_M != NULL) sit_M = (LDBLE *) free_check_null(sit_M);
|
|
||||||
sit_M = (LDBLE *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(LDBLE)));
|
|
||||||
if (sit_M == NULL) malloc_error();
|
|
||||||
if (sit_LGAMMA != NULL) sit_LGAMMA = (LDBLE *) free_check_null(sit_LGAMMA);
|
|
||||||
sit_LGAMMA = (LDBLE *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(LDBLE)));
|
|
||||||
if (sit_LGAMMA == NULL) malloc_error();
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (int)s.size(); i++)
|
for (i = 0; i < (int)s.size(); i++)
|
||||||
{
|
{
|
||||||
@ -509,11 +500,11 @@ sit_clean_up(void)
|
|||||||
}
|
}
|
||||||
sit_params.clear();
|
sit_params.clear();
|
||||||
sit_param_map.clear();
|
sit_param_map.clear();
|
||||||
sit_LGAMMA = (LDBLE *) free_check_null(sit_LGAMMA);
|
sit_LGAMMA.clear();
|
||||||
sit_IPRSNT = (int *) free_check_null(sit_IPRSNT);
|
sit_IPRSNT.clear();
|
||||||
spec = (struct species **) free_check_null(spec);
|
spec.clear();
|
||||||
aphi = (struct pitz_param *) free_check_null(aphi);
|
aphi = (struct pitz_param *) free_check_null(aphi);
|
||||||
sit_M = (LDBLE *) free_check_null(sit_M);
|
sit_M.clear();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -805,7 +796,7 @@ int Phreeqc::
|
|||||||
jacobian_sit(void)
|
jacobian_sit(void)
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
LDBLE *base;
|
std::vector<double> base;
|
||||||
LDBLE d, d1, d2;
|
LDBLE d, d1, d2;
|
||||||
int i, j;
|
int i, j;
|
||||||
Restart:
|
Restart:
|
||||||
@ -817,16 +808,7 @@ Restart:
|
|||||||
sit();
|
sit();
|
||||||
residuals();
|
residuals();
|
||||||
}
|
}
|
||||||
base = (LDBLE *) PHRQ_malloc((size_t) count_unknowns * sizeof(LDBLE));
|
base = residual; // std::vectors
|
||||||
if (base == NULL)
|
|
||||||
{
|
|
||||||
malloc_error();
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
for (i = 0; i < count_unknowns; i++)
|
|
||||||
{
|
|
||||||
base[i] = residual[i];
|
|
||||||
}
|
|
||||||
d = 0.0001;
|
d = 0.0001;
|
||||||
d1 = d * LOG_10;
|
d1 = d * LOG_10;
|
||||||
d2 = 0;
|
d2 = 0;
|
||||||
@ -900,7 +882,6 @@ Restart:
|
|||||||
molalities(TRUE);
|
molalities(TRUE);
|
||||||
if (max_unknowns > pz_max_unknowns)
|
if (max_unknowns > pz_max_unknowns)
|
||||||
{
|
{
|
||||||
base = (LDBLE *) free_check_null(base);
|
|
||||||
gammas_sit();
|
gammas_sit();
|
||||||
jacobian_sums();
|
jacobian_sums();
|
||||||
goto Restart;
|
goto Restart;
|
||||||
@ -960,7 +941,6 @@ Restart:
|
|||||||
sit();
|
sit();
|
||||||
mb_sums();
|
mb_sums();
|
||||||
residuals();
|
residuals();
|
||||||
free_check_null(base);
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user