56 Real max_initial_residual,
58 unsigned max_swaps_allowed,
59 const std::vector<std::string> & prevent_precipitation,
60 Real max_ionic_strength,
61 unsigned ramp_max_ionic_strength,
62 bool evaluate_kin_always);
85 std::stringstream & ss,
89 DenseVector<Real> & mole_additions,
162 DenseVector<Real> & residual,
163 const DenseVector<Real> & mole_additions)
const;
175 DenseVector<Real> & new_mol)
const;
190 unsigned & swap_out_of_basis,
191 unsigned & swap_into_basis,
192 std::stringstream & ss)
const;
206 DenseVector<Real> & mole_additions,
const Real _max_ionic_strength
Maximum ionic strength allowed.
const unsigned _num_kin
Number of kinetic species.
const Real _swap_threshold
If a basis molality < swap_threshold, we attempt to swap it out of the basis.
const unsigned _max_swaps_allowed
Maximum number of swaps allowed before the solve aborts.
const Real _rel_tol
If the residual of the algebraic system falls below this value times the initial residual, the Newton process has converged.
Real _res0_times_rel
_res0_times_rel = _rel_tol * initial residual
void solveAndUnderrelax(const GeochemicalSystem &egs, DenseMatrix< Real > &jacobian, DenseVector< Real > &new_mol) const
Solves _jacobian * neg_change_mol = _residual for neg_change_mol, then performs an underrelaxation to...
DenseMatrix< Real > _jacobian
jacobian of the algebraic system
bool swapNeeded(const GeochemicalSystem &egs, unsigned &swap_out_of_basis, unsigned &swap_into_basis, std::stringstream &ss) const
Check if a basis swap is needed.
void setMaxInitialResidual(Real max_initial_residual)
Set value for max_initial_residual.
GeochemistryIonicStrength & _is
The ionic-strength calculator.
DenseVector< Real > _residual
residual of the algebraic system we wish to solve
DenseMatrix< Real > _input_dmole_additions
d(mole_additions)/d(species) as specified in the argument of solveSystem
unsigned _num_in_algebraic_system
Number of unknowns (molalities and surface potentials) in the algebraic system.
const Real _abs_tol
If the residual of the algebraic system falls below this value, the Newton process has converged...
Real getMaxInitialResidual() const
Get value for max_initial_residual.
const std::vector< std::string > _prevent_precipitation
The minerals named in this list can have positive saturation indices and will not precipitate...
DenseVector< Real > _input_mole_additions
the mole_additions for the basis and kinetic species as specified in the argument of solveSystem ...
Calculators to compute ionic strength and stoichiometric ionic strength.
Real _abs_residual
L1 norm of residual.
PetscErrorCode PetscInt const PetscInt IS * is
bool reduceInitialResidual(GeochemicalSystem &egs, Real dt, DenseVector< Real > &mole_additions, DenseMatrix< Real > &dmole_additions)
Progressively alter the initial-guess molalities for the algebraic system to attempt to reduce the re...
unsigned _num_basis_in_algebraic_system
Number of basis molalities (and potentially solvent water mass) in the algebraic system.
void solveSystem(GeochemicalSystem &egs, std::stringstream &ss, unsigned &tot_iter, Real &abs_residual, Real dt, DenseVector< Real > &mole_additions, DenseMatrix< Real > &dmole_additions)
Solve the system.
unsigned getRampMaxIonicStrength() const
Gets the value of _ramp_max_ionic_strength.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
DenseVector< Real > _new_mol
the new molality after finding the solution of _jacobian * neg_change_mol = _residual ...
Real computeResidual(const GeochemicalSystem &egs, DenseVector< Real > &residual, const DenseVector< Real > &mole_additions) const
Builds the residual of the algebraic system.
void setRampMaxIonicStrength(unsigned ramp_max_ionic_strength)
Sets the value of _ramp_max_ionic_strength.
This class holds information about bulk composition, molalities, activities, activity coefficients...
Real _max_initial_residual
maximum desired initial residual
const unsigned _max_iter
maximum number of iterations allowed during an inner solve
const unsigned _num_basis
Number of species in the basis.
unsigned _ramp_max_ionic_strength
Number of iterations over which to increase the maximum ionic strength to _max_ionic_strength.
This class contains methods to solve the algebraic system in GeochemicalSystem.
bool _evaluate_kin_always
When to compute the kinetic rates: if true then evaluate before every residual calculation, otherwise evaluate only at the start of the solve process (using, eg, the old molality values)
GeochemicalSolver(unsigned num_basis, unsigned num_kin, GeochemistryIonicStrength &is, Real abs_tol, Real rel_tol, unsigned max_iter, Real max_initial_residual, Real swap_threshold, unsigned max_swaps_allowed, const std::vector< std::string > &prevent_precipitation, Real max_ionic_strength, unsigned ramp_max_ionic_strength, bool evaluate_kin_always)
Construct and check for sensible arguments.