Gems3k  3.1
GEMS3K standalone solver for geochemical equilibria
 All Classes Files Functions Variables Enumerations Enumerator
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
TMulti Class Reference

List of all members.

Public Member Functions

void set_def (long int i=0)
 Set default information.
 TMulti (TNode *na_)
 This allocation is used only in standalone GEMS3K.
void multi_realloc (char PAalp, char PSigm)
 Realloc dynamic memory.
void multi_free ()
 Reallocation of dynamic memory.
void CheckMtparam ()
 Test and load thermodynamic data from GEMS project database.
MULTIGetPM ()
void setPa (TProfil *prof)
long int testMulti ()
 Output to "ipmlog.txt" file Warnings.
const char * GetName () const
void to_file (GemDataStream &ff)
 Writing MULTI to binary file.
void to_text_file (const char *path, bool append=false)
 Writing structure MULTI ( free format file )
void from_file (GemDataStream &ff)
 Reading MULTI from binary file.
void to_text_file_gemipm (const char *path, bool addMui, bool with_comments=true, bool brief_mode=false)
 Writing structure MULTI (GEM IPM work structure)
void from_text_file_gemipm (const char *path, DATACH *dCH)
 Reading structure MULTI (GEM IPM work structure)
void Alloc_internal ()
 Internal memory allocation for IPM performance optimization.
double CalculateEquilibriumState (long int typeMin, long int &NumIterFIA, long int &NumIterIPM)
 Main call to GEM IPM calculation of equilibrium state in MULTI (with internal re-scaling of the system).
void InitalizeGEM_IPM_Data ()
 Calculation by IPM (preparing for calculation, unpacking data) In IPM.
void DC_LoadThermodynamicData (TNode *aNa=0)
 Load Thermodynamic Data from DATACH to MULTI using Lagrangian Interpolator.
long int CheckMassBalanceResiduals (double *Y)
 Diagnostics for a severe break of mass balance (abs.moles) after GEM IPM PhaseSelect().
double ConvertGj_toUniformStandardState (double g0, long int j, long int k)
 Conversion of g(T,P) value for DCs into the uniform cj scale.
double PhaseSpecificGamma (long int j, long int jb, long int je, long int k, long int DirFlag=0L)
 Function for converting internal lnGam[j] value into an external (phase-scale-specific) Gamma[j] if DirFlag = 0 or external into internal value if DirFlag = 1.
double HelmholtzEnergy (double x)
 Calls to minimization of other system potentials - HelmholtzEnergy.
double InternalEnergy (double TC, double P)
 Calls to minimization of other system potentials - InternalEnergy.

Public Attributes

TNodenode

Protected Member Functions

void Alloc_TSolMod (long int newFIs)
 Internal memory allocation for TSolMod performance optimization (since version 2.3.0)
void Free_TSolMod ()
void Alloc_uDD (long int newN)
 Added for implementation of divergence detection in dual solution 06.05.2011 DK.
void Free_uDD ()
void Reset_uDD (long int cr, bool trace=false)
 initializing data for u divergence detection
void Increment_uDD (long int r, bool trace=false)
 Incrementing mean u values for r-th (current) IPM iteration.
long int Check_uDD (long int mode, double DivTol, bool trace=false)
 Checking for divergence in coef.variation of dual solution approximation.
void getLsModsum (long int &LsModSum, long int &LsIPxSum)
void getLsMdcsum (long int &LsMdcSum, long int &LsMsnSum, long int &LsSitSum)
void setErrorMessage (long int num, const char *code, const char *msg)
void addErrorMessage (const char *msg)
void XmaxSAT_IPM2 ()
 Calculation of max.moles of surface species for SACT stabilization to improve IPM-2 convergence at high SACT values.
double DC_DualChemicalPotential (double U[], double AL[], long int N, long int j)
 Calculating value of dual chemical potential of j-th dependent component performance optimized version (February 2007)
void Set_DC_limits (long int Mode)
 This procedure sets kinetic constraints according to a given concentration units.
void TotalPhasesAmounts (double X[], double XF[], double XFA[])
 Calculating total amounts of phases.
double DC_PrimalChemicalPotentialUpdate (long int j, long int k)
 Corrections to primal chemical potentials F0[j] of j-th species in k-th phase among IPM main iterations.
double DC_PrimalChemicalPotential (double G, double logY, double logYF, double asTail, double logYw, char DCCW)
 Calculation of DC primal chemical potential F.
void PrimalChemicalPotentials (double F[], double Y[], double YF[], double YFA[])
 VJ - Update of primal chemical potentials.
double KarpovCriterionDC (double *dNuG, double logYF, double asTail, double logYw, double Wx, char DCCW)
 Calculation of Karpov stability criteria for a DC.
void KarpovsPhaseStabilityCriteria ()
 Calculation of Karpov stability criteria for all phases.
void StabilityIndexes ()
 Calculation of (logarithmic) stability indexes logSI for all phases.
double DC_GibbsEnergyContribution (double G, double x, double logXF, double logXw, char DCCW)
 Calculation of a species contribution to the total Gibbs energy G(X) of the system.
double GX (double LM)
 Calculation of the total Gibbs energy of the system G(X) and copying of Y, YF vectors into X,XF, respectively.
void ConvertDCC ()
 Converting DC class codes into generic internal codes of IPM.
long int getXvolume ()
 Get the index of volume IC ("Vv") for the volume balance constraint.
void GasParcP ()
 Calculating demo partial pressures of gases (works only in GEMS-PSI)
void phase_bcs (long int N, long int M, long int jb, double *A, double X[], double BF[])
 Calculating bulk stoichiometry of a multicomponent phase.
void phase_bfc (long int k, long int jj)
 Adds phase to total bulk stoichiometry of all solid phases in the system.
double bfc_mass (void)
 Returns mass of all solid phases in grams (from the BFC vector)
void CalculateConcentrationsInPhase (double X[], double XF[], double XFA[], double Factor, double MMC, double Dsur, long int jb, long int je, long int k)
 Calculation of dual chemical potentials, activities, and primal concentrations for DCs (indexed jb to je) in a k-th phase.
void CalculateConcentrations (double X[], double XF[], double XFA[])
 Calculation of derived values (concentrations etc.) on IPM iteration from X,XF, and XFA vectors.
long int GouyChapman (long int jb, long int je, long int k)
 Calculation of the surface potential pm[q].XpsiD[k] on diffuse.
long int SurfaceActivityCoeff (long int jb, long int je, long int jpb, long int jdb, long int k)
 Calculation of new surface activity coefficient terms SACT (Kulik, 2004)
void IS_EtaCalc ()
 Calculation of surface charge densities on multi-surface sorption phase.
void pm_GC_ods_link (long int k, long int jb, long int jpb, long int jdb, long int ipb)
 Linking DOD for executing Phase mixing model scripts.
double SmoothingFactor ()
 Returns current value of smoothing factor for chemical potentials of highly non-ideal DCs.
void SetSmoothingFactor (long int mode)
 New correction of smoothing factor for highly non-ideal systems.
long int CalculateActivityCoefficients (long int LinkMode)
 Main call point for calculation of DC activity coefficients (lnGam vector) formerly GammaCalc().
void SolModCreate (long int jb, long int jmb, long int jsb, long int jpb, long int jdb, long int k, long int ipb, char ModCode, char MixCode)
 Wrapper calls for creating multi-component mixing models for phases using TSolMod class.
void SolModParPT (long int k, char ModCode)
 Wrapper call for calculation of temperature and pressure correction uses TSolMod class.
void SolModActCoeff (long int k, char ModCode)
 Wrapper call for calculation of activity coefficients uses TSolMod class.
void SolModExcessProp (long int k, char ModCode)
 Wrapper call for calculation of bulk phase excess properties uses TSolMod class.
void SolModIdealProp (long int jb, long int k, char ModCode)
 Wrapper call for calculation of bulk phase ideal mixing properties.
void SolModStandProp (long int jb, long int k, char ModCode)
 Wrapper call for retrieving bulk phase standard state terms.
void SolModDarkenProp (long int jb, long int k, char ModCode)
 Wrapper call for retrieving bulk phase Darken quadratic terms.
void GEM_IPM (long int rLoop)
 Main sequence of GEM IPM algorithm implementation.
long int MassBalanceRefinement (long int WhereCalledFrom)
 Calculation of a feasible IPM approximation, refinement of the mass balance.
long int InteriorPointsMethod (long int &status, long int rLoop)
 Calculation of chemical equilibrium using the Interior Points Method algorithm (see Karpov et al., 1997, p.
void AutoInitialApproximation ()
 Calculation of LPP-based automatic initial approximation of the primal vector x.
void MassBalanceResiduals (long int N, long int L, double *A, double *Y, double *B, double *C)
 Calculation of mass-balance residuals in GEM IPM CSD.
double OptimizeStepSize (double LM)
 Interior Points Method subroutine for unconditional optimization of the descent step length on the interval 0 to LM.
void DC_ZeroOff (long int jStart, long int jEnd, long int k=-1L)
 Cleaning the unstable phase with index k >= 0 (if k < 0 only DC will be cleaned)
void DC_RaiseZeroedOff (long int jStart, long int jEnd, long int k=-1L)
 Inserting minor quantities of DC which were zeroed off by SolveSimplex().
double RaiseDC_Value (const long int j)
 New function to improve on raising zero values in PhaseSelect() and after SolveSimplex()
long int MetastabilityLagrangeMultiplier ()
 Adjustment of primal approximation according to kinetic constraints.
void WeightMultipliers (bool square)
 Calculation of weight multipliers for DCs.
long int MakeAndSolveSystemOfLinearEquations (long int N, bool initAppr)
 Make and Solve a system of linear equations to find the dual vector approximation using a method of Cholesky Decomposition.
double DikinsCriterion (long int N, bool initAppr)
 Calculation of MU values (in the vector of direction of descent) and Dikin criterion.
double StepSizeEstimate (bool initAppr)
 Estimation of the descent step length LM.
void Restore_Y_YF_Vectors ()
 Restoring primal vectors Y and YF.
double RescaleToSize (bool standard_size)
 Calculation of the system size scaling factor and modified thresholds/cutoffs/insertion values Replaces calcSfactor()
long int SpeciationCleanup (double AmountThreshold, double ChemPotDiffCutoff)
 Speciation cleanup subroutine if CleanupStatus is not zero.
long int PhaseSelectionSpeciationCleanup (long int &k_miss, long int &k_unst, long int rLoop)
 New simplified PSSC() algorithm DK 01.05.2010.
long int PhaseSelect (long int &k_miss, long int &k_unst, long int rLoop)
 Checking Karpov phase stability criteria Fa for phases and DCs.
bool GEM_IPM_InitialApproximation ()
 Finding out whether the automatic initial approximation is necessary for launching the IPM algorithm.
void SolveSimplex (long int M, long int N, long int T, double GZ, double EPS, double *UND, double *UP, double *B, double *U, double *AA, long int *STR, long int *NMB)
 Generic simplex method with two sided constraints (c) K.Chudnenko 1992.
void SPOS (double *P, long int STR[], long int NMB[], long int J, long int M, double AA[])
 Generic simplex method with two sided constraints (c) K.Chudnenko 1992 SPOS function.
void START (long int T, long int *ITER, long int M, long int N, long int NMB[], double GZ, double EPS, long int STR[], long int *BASE, double B[], double UND[], double UP[], double AA[], double *A, double *Q)
 Generic simplex method with two sided constraints (c) K.Chudnenko 1992 START function.
void NEW (long int *OPT, long int N, long int M, double EPS, double *LEVEL, long int *J0, long int *Z, long int STR[], long int NMB[], double UP[], double AA[], double *A)
 Generic simplex method with two sided constraints (c) K.Chudnenko 1992 NEW function.
void WORK (double GZ, double EPS, long int *I0, long int *J0, long int *Z, long int *ITER, long int M, long int STR[], long int NMB[], double AA[], long int BASE[], long int *UNO, double UP[], double *A, double Q[])
 Generic simplex method with two sided constraints (c) K.Chudnenko 1992 WORK function.
void FIN (double EPS, long int M, long int N, long int STR[], long int NMB[], long int BASE[], double UND[], double UP[], double U[], double AA[], double *A, double Q[], long int *ITER)
 Generic simplex method with two sided constraints (c) K.Chudnenko 1992 FIN function.
void GibbsEnergyMinimization ()
 Call to GEM IPM calculation of equilibrium state in MULTI (with already scaled GEM problem)
double SystemTotalMolesIC ()
 Calculate total IC mole amounts in b vector and return the scaling factor.
void ScaleSystemToInternal (double ScFact)
 Resizes MULTI (GEM IPM work structure) data into internally scaled constant mass.
void RescaleSystemFromInternal (double ScFact)
 Re-scaling the internal constant-mass MULTI system definition back to real size.
void MultiConstInit ()
 Setup/copy flags and thresholds for numeric modules to TMulti structure.
void GEM_IPM_Init ()
 Calculation by IPM (internal step initialization)

Protected Attributes

long int sizeFIs
 current size of phSolMod
TSolMod ** phSolMod
 size current FIs - number of multicomponent phases
long int nNu
 number of ICs in the system
long int cnr
 current IPM iteration
long int nCNud
 number of IC names for divergent dual chemical potentials
double * U_mean
 Cumulative mean dual solution approximation [nNu].
double * U_M2
 Cumulative sum of squares [nNu].
double * U_CVo
 Cumulative Coefficient of Variation for dual solution approximation r-1 [nNu].
double * U_CV
 Cumulative Coefficient of Variation for r-th dual solution approximation [nNu].
long int * ICNud
 List of IC indexes for divergent dual chemical potentials [nNu].
char PAalp_
 Flag for using (+) or ignoring (-) specific surface areas of phases.
char PSigm_
 Flag for using (+) or ignoring (-) specific surface free energies.

Member Function Documentation

void TMulti::AutoInitialApproximation ( ) [protected]

Calculation of LPP-based automatic initial approximation of the primal vector x.

Use the modified simplex method with two-side constraints on x

long int TMulti::CalculateActivityCoefficients ( long int  LinkMode) [protected]

Main call point for calculation of DC activity coefficients (lnGam vector) formerly GammaCalc().

Controls various built-in models, as well as generic Phase script calculation LinkMode is a parameter indicating the status of Gamma calculations: LINK_TP_MODE - calculation of equations depending on TP only; LINK_UX_MODE - calculation of equations depending on current IPM approximation of the equilibrium state; LINK_PP_MODE - calculation of integral phase properties after GEMIPM has converged needs to be implemented

Returns:
status code (0 if o.k., non-zero values if there were problems with surface complexation models)
void TMulti::CalculateConcentrations ( double  X[],
double  XF[],
double  XFA[] 
) [protected]

Calculation of derived values (concentrations etc.) on IPM iteration from X,XF, and XFA vectors.

Also calculates pH, pe, Eh

!!!!

void TMulti::CalculateConcentrationsInPhase ( double  X[],
double  XF[],
double  XFA[],
double  Factor,
double  MMC,
double  Dsur,
long int  jb,
long int  je,
long int  k 
) [protected]

Calculation of dual chemical potentials, activities, and primal concentrations for DCs (indexed jb to je) in a k-th phase.

double TMulti::CalculateEquilibriumState ( long int  typeMin,
long int &  NumIterFIA,
long int &  NumIterIPM 
)

Main call to GEM IPM calculation of equilibrium state in MULTI (with internal re-scaling of the system).

long int TMulti::Check_uDD ( long int  mode,
double  DivTol,
bool  trace = false 
) [protected]

Checking for divergence in coef.variation of dual solution approximation.

Compares with CV value tolerance (mode = 0) or with CV increase tolerance (mode = 1)

Returns:
0 if no divergence has been detected >0 - number of diverging dual chemical potentials (their IC names are collected in the ICNud list)
long int TMulti::CheckMassBalanceResiduals ( double *  Y)

Diagnostics for a severe break of mass balance (abs.moles) after GEM IPM PhaseSelect().

When pm.X is passed as parameter

Returns:
-1 (Ok) or index of the first IC for which the balance is broken
double TMulti::ConvertGj_toUniformStandardState ( double  g0,
long int  j,
long int  k 
)

Conversion of g(T,P) value for DCs into the uniform cj scale.

Parameters:
k- index of phase,
j- index DC in phase
Returns:
if error code, returns 777777777.
double TMulti::DC_GibbsEnergyContribution ( double  G,
double  x,
double  logXF,
double  logXw,
char  DCCW 
) [protected]

Calculation of a species contribution to the total Gibbs energy G(X) of the system.

On error returns +7777777.

Parameters:
GgT0+gEx
xx - mole amount of species
logXFln Xa - mole amount of phase
logXwln Xv - mole amount of the solvent/sorbent
DCCWgeneralized species class code
double TMulti::DC_PrimalChemicalPotential ( double  G,
double  logY,
double  logYF,
double  asTail,
double  logYw,
char  DCCW 
) [protected]

Calculation of DC primal chemical potential F.

From moles of DC Y[], total moles of phase YF[] and DC partial molar Gibbs energy gT (obtained from pm.G[]) which includes activity coefficient terms. On error returns F = +7777777.

Parameters:
GgT0+gEx
logYln x
logYFln Xa
asTailasymmetry non-log term or 0 for symmetric phases
logYwln Xv
DCCWgeneralized species class code
double TMulti::DC_PrimalChemicalPotentialUpdate ( long int  j,
long int  k 
) [protected]

Corrections to primal chemical potentials F0[j] of j-th species in k-th phase among IPM main iterations.

Returns double value of corrected chem. potential. If error, returns +7777777 J/mole.

!!!!

!!!!

void TMulti::DC_RaiseZeroedOff ( long int  jStart,
long int  jEnd,
long int  k = -1L 
) [protected]

Inserting minor quantities of DC which were zeroed off by SolveSimplex().

Important for the automatic initial approximation with solution phases (k = -1) or inserting a solution phase after PhaseSelect() (k >= 0)

double TMulti::DikinsCriterion ( long int  N,
bool  initAppr 
) [protected]

Calculation of MU values (in the vector of direction of descent) and Dikin criterion.

Parameters:
initAppr- use in MassBalanceRefinement() (true) or main iteration of IPM (false)
N- dimension of the matrix R (number of equations)
void TMulti::GEM_IPM ( long int  rLoop) [protected]

Main sequence of GEM IPM algorithm implementation.

Main place for implementation of diagnostics and setup of IPM precision and convergence rLoop is the index of the primal solution refinement loop (for tracing) or -1 if this is main GEM_IPM call

void TMulti::GEM_IPM_Init ( ) [protected]

Calculation by IPM (internal step initialization)

line must be tested !pm.FIs

Finding out whether the automatic initial approximation is necessary for launching the IPM algorithm.

Uses a modified simplex method with two-side constraints (Karpov ea 1997)

Returns:
false - OK for IPM true - OK solved (pure phases only in the system)
long int TMulti::GouyChapman ( long int  jb,
long int  je,
long int  k 
) [protected]

Calculation of the surface potential pm[q].XpsiD[k] on diffuse.

layer plane on k-th sorption phase. From total charge pm.Xeta[k] ( in moles ) using Gouy-Chapman equation. Strictly valid at PSI < 30 mV. Modified by DAK 5 Jan 2000 to add a Basic Stern EDL model. Added 13.03.2008 by DK: returns int value showing (if not 0) that some extreme values were reached for charge densities or electric potentials (for detecting bad PIA), 0 otherwise

double TMulti::GX ( double  LM) [protected]

Calculation of the total Gibbs energy of the system G(X) and copying of Y, YF vectors into X,XF, respectively.

Parameter LM is the IPM step size for calculation of new quantities of all species (vector X[]) using the direction of descent (MU[] vector). If LM == 0, this function just copies vector Y[] into X[].

Returns:
of G(X) in moles.
double TMulti::HelmholtzEnergy ( double  x)

Calls to minimization of other system potentials - HelmholtzEnergy.

Calc function for Method of golden section (only in GEMS ).

long int TMulti::InteriorPointsMethod ( long int &  status,
long int  rLoop 
) [protected]

Calculation of chemical equilibrium using the Interior Points Method algorithm (see Karpov et al., 1997, p.

785-786) GEM IPM

Returns:
0, if converged; 1, in the case of R matrix degeneration 2, (more than max iteration) - no convergence or user's interruption 3, CalculateActivityCoefficients() returns bad (non-zero) status 4, Mass balance broken in DualTH (Mol_u) 5, Divergence in dual solution u vector has been detected
double TMulti::InternalEnergy ( double  TC,
double  P 
)

Calls to minimization of other system potentials - InternalEnergy.

Calc function for Method of golden section (only in GEMS ).

long int TMulti::MakeAndSolveSystemOfLinearEquations ( long int  N,
bool  initAppr 
) [protected]

Make and Solve a system of linear equations to find the dual vector approximation using a method of Cholesky Decomposition.

Good if a square matrix R happens to be symmetric and positive defined. If Cholesky Decomposition does not solve the problem, an attempt is done to solve the SLE using method of LU Decomposition (A = L*U , L is lower triangular ( has elements only on the diagonal and below ) U is is upper triangular ( has elements only on the diagonal and above))

Parameters:
initAppr- Inital approximation point(true) or iteration of IPM (false) N - dimension of the matrix R (number of equations)
Returns:
0 - solved OK; 1 - no solution, degenerated or inconsistent system
long int TMulti::MassBalanceRefinement ( long int  WhereCalledFrom) [protected]

Calculation of a feasible IPM approximation, refinement of the mass balance.

Algorithm: see Karpov, Chudnenko, Kulik 1997 Amer.J.Sci. vol 297 p. 798-799 (Appendix B) Control: MaxResidualRatio, 0 (deactivated), > DHBM and < 1 - accuracy for "trace" independent components (max residual for i should not exceed B[i]*MaxResidualRatio)

Parameters:
WhereCalledFrom,0- at entry after automatic LPP-based IA; 1 - at entry in SIA (start without SolveSimplex() 2 - after post-IPM cleanup 3 - additional (after PhaseSelection)
Returns:
0 - OK, 1 - no SLE colution at the specified precision pa.p.DHB 2 - used up more than pa.p.DP iterations 3 - too small step length (< 1e-6), no descent possible 4 - error in Initial mass balance residuals (debugging) 5 - error in MetastabilityLagrangeMultiplier() (debugging)
void TMulti::MassBalanceResiduals ( long int  N,
long int  L,
double *  A,
double *  Y,
double *  B,
double *  C 
) [protected]

Calculation of mass-balance residuals in GEM IPM CSD.

Parameters:
N- number of IC in IPM problem
L- number of DC in IPM problem
A- DC stoichiometry matrix (LxN)
Y- moles DC quantities in IPM solution (L)
B- Input bulk chem. compos. (N)
C- mass balance residuals (N)
void TMulti::MultiConstInit ( ) [protected]

Setup/copy flags and thresholds for numeric modules to TMulti structure.

Do it before calculations

double TMulti::OptimizeStepSize ( double  LM) [protected]

Interior Points Method subroutine for unconditional optimization of the descent step length on the interval 0 to LM.

uses the "Golden Section" algorithm Formerly called LMD()

Returns:
optimal value of LM which provides the largest possible monotonous decrease in G(X)
long int TMulti::PhaseSelect ( long int &  kfr,
long int &  kur,
long int  RaiseStatus 
) [protected]

Checking Karpov phase stability criteria Fa for phases and DCs.

Using Selekt2() algorithm by Karpov & Chudnenko (1989) modified by DK in 1995 and in 2007, 2012 RaiseStatus: if 1 then zeroed-off DCs are raised to constant in solution phases present in eq state, otherwise (0) this is skipped assuming that SpeciationCleanup will be done.

Returns:
0, if some phases were inserted and a new IPM loop is needed (up to 3 loops possible); 1, if the IPM solution is final and consistent, no phases were inserted -1, if the IPM solution is inconsistent after 3 Selekt2() loops In this case, the index of most problematic phase is passed through kfr or kur parameter (parameter value -1 means that no problematic phases were found)
long int TMulti::PhaseSelectionSpeciationCleanup ( long int &  kfr,
long int &  kur,
long int  CleanupStatus 
) [protected]

New simplified PSSC() algorithm DK 01.05.2010.

PhaseSelection() part only looks for phases to be inserted, also checks if some solution phases are unstable. Removal of unstable phases is done afterwards in SpeciationCleanup subroutine if CleanupStatus is not zero. As phase stability criterion, uses (log) phase stability (saturation) index computed from DualTh activities of components and activity coefficients

Returns:
1L if Ok; 0 if one more IPM loop should be done; -1L if 3 loops did not fix the problem
double TMulti::PhaseSpecificGamma ( long int  j,
long int  jb,
long int  je,
long int  k,
long int  DirFlag = 0L 
)

Function for converting internal lnGam[j] value into an external (phase-scale-specific) Gamma[j] if DirFlag = 0 or external into internal value if DirFlag = 1.

Returns the respectively corrected external gamma activity coefficient or internal lnGam Returns trivial values (lnGam = 0 or Gamma = 1) when the respective component amount is zero (X[j] == 0) (is this a correct policy for zeroed-off components?)

void TMulti::Set_DC_limits ( long int  Mode) [protected]

This procedure sets kinetic constraints according to a given concentration units.

void TMulti::SetSmoothingFactor ( long int  mode) [protected]

New correction of smoothing factor for highly non-ideal systems.

Smoothing function choice: AG >= 0.0001 and DGC > -0.0001: old f(IT) AG >= 0.0001 and DGC <= -0.0001: new f(1/IT) AG <= -0.0001 and DGC <= -0.0001: new f(1/CD)

Parameters:
mode0 - taking single log(CD) value for calculation of smoothing factor SF; 1, 2, ... taking log(CD) average from the moving window of length mode (up to 5 consecutive values)
void TMulti::SolModCreate ( long int  jb,
long int  jmb,
long int  jsb,
long int  jpb,
long int  jdb,
long int  k,
long int  ipb,
char  ModCode,
char  MixCode 
) [protected]

Wrapper calls for creating multi-component mixing models for phases using TSolMod class.

Now including multi-site ideal and scripted models

void TMulti::SolveSimplex ( long int  M,
long int  N,
long int  T,
double  GZ,
double  EPS,
double *  UND,
double *  UP,
double *  B,
double *  U,
double *  AA,
long int *  STR,
long int *  NMB 
) [protected]

Generic simplex method with two sided constraints (c) K.Chudnenko 1992.

Main function

Parameters:
M- number of independent components
N- number of unknowns
T- dimension of a work vector AA[] containing all non-zero values of vector GT[] and A[][] matrix (over lines)
GZ- Limiting value of the unknown
EPS- precision (convergence) criterion (default 1e-9)
UND- vector of lower constraints to unknowns
UP- input vector of upper constraints to unknowns; output vector of unknowns (simplex solution) (N+M)
B- M input values of independent components (bulk composition)
U- output vector of the dual solution (M)
AA- work array (T)
STR- markup vector of values in AA array (T)
NMB- indices of values in AA
Returns:
0 if OK; 1 if inconsistent input constraints; -1 if memory allocation error;
long int TMulti::SpeciationCleanup ( double  AmountCorrectionThreshold,
double  MjuDiffCutoff 
) [protected]

Speciation cleanup subroutine if CleanupStatus is not zero.

Parameters:
AmountCorrectionThreshold- the maximum DC amount correction that can be cleaned ( 1e-5 )
MjuDiffCutoff- normalized chem.pot. difference threshold (dMu = ln a - ln a,dual)
Returns:
0 if no subsequent refinement of mass balance is needed; 1 if species amounts were cleaned up to more than requested overall mass balance accuracy -1 if cleanup has been done and the degeneration of the chemical system occurred 2 solution is seriously distorted and full PhaseSelect3() loop is necessary
double TMulti::StepSizeEstimate ( bool  initAppr) [protected]

Estimation of the descent step length LM.

Parameters:
initAppr- MBR() (true) or iteration of IPM (false)
long int TMulti::SurfaceActivityCoeff ( long int  jb,
long int  je,
long int  jpb,
long int  jdb,
long int  k 
) [protected]

Calculation of new surface activity coefficient terms SACT (Kulik, 2004)

Revised by KD in April 2004 (PSI) to introduce new activity coefficient terms SACT rigorously derived from Langmuir and QCA isotherms (Kulik 2006, Radiochimica Acta). SACT are placed into pm.lnGam[j], as other activity coefficients except relative surface potentials (Coulombic terms) kept separately. Old (obsolete) SAT calculations (Kulik 2000, 2002) are retained. pm.lnSAC[*][3] vector is now used to keep original DUL[j] to restore them after IPM-2 refinements for surface complexes. Added 13.03.2008 by DK: returns int value showing (if true) that some extreme values were obtained for some SACTs, 0 otherwise (for detecting bad PIA)

void TMulti::XmaxSAT_IPM2 ( ) [protected]

Calculation of max.moles of surface species for SACT stabilization to improve IPM-2 convergence at high SACT values.

xj0 values are placed as upper kinetic constraints

!!!!!

!!!!!

!!!!!


The documentation for this class was generated from the following files: