https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
GeochemistryConsoleOutput Class Reference

Outputs information (to the console) from a GeochemistryReactorBase at a point. More...

#include <GeochemistryConsoleOutput.h>

Inheritance diagram for GeochemistryConsoleOutput:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 GeochemistryConsoleOutput (const InputParameters &parameters)
 
virtual Real time ()
 
virtual Real timeOld ()
 
virtual Real dt ()
 
virtual Real dtOld ()
 
virtual int timeStep ()
 
const unsigned intinterval () const
 
const MultiMooseEnumexecuteOn () const
 
bool isAdvanced ()
 
virtual const OutputOnWarehouseadvancedExecuteOn () const
 
void allowOutput (bool state)
 
virtual void outputStep (const ExecFlagType &type)
 
const std::set< Real > & getSyncTimes ()
 
virtual bool supportsMaterialPropertyOutput () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void meshChanged ()
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
const FunctiongetFunction (const std::string &name) const
 
const FunctiongetFunctionByName (const FunctionName &name) const
 
bool hasFunction (const std::string &param_name) const
 
bool hasFunctionByName (const FunctionName &name) const
 
Moose::Kokkos::Function getKokkosFunction (const std::string &name) const
 
const TgetKokkosFunction (const std::string &name) const
 
Moose::Kokkos::Function getKokkosFunctionByName (const FunctionName &name) const
 
const TgetKokkosFunctionByName (const FunctionName &name) const
 
bool hasKokkosFunction (const std::string &param_name) const
 
bool hasKokkosFunctionByName (const FunctionName &name) const
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
PerfGraphperfGraph ()
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const TgetUserObject (const std::string &param_name, bool is_dependency=true) const
 
const TgetUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectBasegetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectBasegetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 

Static Public Member Functions

static InputParameters sharedParams ()
 contains params that are shared with Actions that use this object
 
static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static ExecFlagEnum getDefaultExecFlagEnum ()
 
static void addDeprecatedInputParameters (InputParameters &params)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

virtual void output () override
 
virtual void solveSetup ()
 
virtual bool shouldOutput ()
 
virtual bool onInterval ()
 
void setWallTimeIntervalFromCommandLineParam ()
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
TdeclareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< TdeclareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const TgetRestartableData (const std::string &data_name) const
 
TdeclareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
TdeclareRecoverableData (const std::string &data_name, Args &&... args)
 
TdeclareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
TdeclareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) const
 
const ReporterContextBasegetReporterContextBaseByName (const ReporterName &reporter_name) const
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
virtual void addUserObjectDependencyHelper (const UserObjectBase &) const
 

Protected Attributes

const GeochemistryReactorBase_reactor
 the Reactor from which to extract info
 
const NearestNodeNumberUO_nnn
 UserObject defining the node of interest.
 
const unsigned _precision
 precision of output
 
const Real _stoi_tol
 Tolerance on stoichiometric coefficients before they are deemed to be zero.
 
const bool _solver_info
 Whether to print solver info.
 
const Real _mol_cutoff
 Species with molalities less than mol_cutoff will not be outputted.
 
FEProblemBase_problem_ptr
 
bool _transient
 
bool _use_displaced
 
libMesh::EquationSystems_es_ptr
 
MooseMesh_mesh_ptr
 
bool _sequence
 
ExecFlagEnum _execute_on
 
ExecFlagType _current_execute_flag
 
Real & _time
 
Real & _time_old
 
int_t_step
 
Real & _dt
 
Real & _dt_old
 
unsigned int _num
 
const bool _time_step_interval_set_by_addparam
 
unsigned int _time_step_interval
 
const Real _min_simulation_time_interval
 
Real _wall_time_interval
 
std::set< Real > _sync_times
 
const Times *const _sync_times_object
 
Real _start_time
 
Real _end_time
 
int _start_step
 
int _end_step
 
Real _t_tol
 
bool _sync_only
 
bool _allow_output
 
bool _is_advanced
 
OutputOnWarehouse _advanced_execute_on
 
Real & _last_output_simulation_time
 
std::chrono::time_point< std::chrono::steady_clock > _last_output_wall_time
 
Real _wall_time_since_last_output
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
FEProblemBase_mci_feproblem
 
const ExecFlagEnum_execute_enum
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Private Member Functions

void outputNernstInfo (const GeochemicalSystem &egs_ref) const
 
RestartableDataValueregisterRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const
 
const Moose::FunctionBasegetKokkosFunctionByNameHelper (const FunctionName &name) const
 
const PostprocessorName & getPostprocessorNameInternal (const std::string &param_name, const unsigned int index, const bool allow_default_value=true) const
 
bool isDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
PostprocessorValue getDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
void checkParam (const std::string &param_name, const unsigned int index=std::numeric_limits< unsigned int >::max()) const
 
bool postprocessorsAdded () const
 
const VectorPostprocessorValuegetVectorPostprocessorByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name, bool broadcast, std::size_t t_index) const
 
const VectorPostprocessorContext< VectorPostprocessorValue > & getVectorPostprocessorContextByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool vectorPostprocessorsAdded () const
 
bool reportersAdded () const
 
void possiblyCheckHasReporter (const ReporterName &reporter_name, const std::string &param_name="") const
 
const PostprocessorValuegetPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValuegetPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValuegetPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
const PostprocessorValuegetPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const UserObjectBasegetUserObjectFromFEProblem (const UserObjectName &object_name, const THREAD_ID tid=0) const
 
const TcastUserObject (const UserObjectBase &uo_base, const std::string &param_name="") const
 
void mooseObjectError (const std::string &param_name, std::stringstream &oss) const
 
const std::string & userObjectType (const UserObjectBase &uo) const
 
const std::string & userObjectName (const UserObjectBase &uo) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 
ExecFlagEnum _empty_execute_enum
 
const MooseObject_fni_object
 
const InputParameters_fni_params
 
FEProblemBase_fni_feproblem
 
const THREAD_ID _fni_tid
 
const MooseObject_ppi_moose_object
 
const InputParameters_ppi_params
 
const FEProblemBase_ppi_feproblem
 
std::map< PostprocessorName, std::unique_ptr< PostprocessorValue > > _default_values
 
const bool _broadcast_by_default
 
const MooseObject_vpi_moose_object
 
const FEProblemBase_vpi_feproblem
 
const THREAD_ID _vpi_tid
 
const InputParameters_ri_params
 
FEProblemBase_ri_fe_problem_base
 
const ReporterData_ri_reporter_data
 
const MooseObject_ri_moose_object
 
const MooseObject_uoi_moose_object
 
const FEProblemBase_uoi_feproblem
 
const THREAD_ID _uoi_tid
 

Detailed Description

Outputs information (to the console) from a GeochemistryReactorBase at a point.

Definition at line 20 of file GeochemistryConsoleOutput.h.

Constructor & Destructor Documentation

◆ GeochemistryConsoleOutput()

GeochemistryConsoleOutput::GeochemistryConsoleOutput ( const InputParameters parameters)

Definition at line 53 of file GeochemistryConsoleOutput.C.

56 _reactor(getUserObject<GeochemistryReactorBase>("geochemistry_reactor")),
57 _nnn(getUserObject<NearestNodeNumberUO>("nearest_node_number_UO")),
58 _precision(getParam<unsigned int>("precision")),
59 _stoi_tol(getParam<Real>("stoichiometry_tolerance")),
60 _solver_info(getParam<bool>("solver_info")),
61 _mol_cutoff(getParam<Real>("mol_cutoff"))
62{
63}
const Real _stoi_tol
Tolerance on stoichiometric coefficients before they are deemed to be zero.
const GeochemistryReactorBase & _reactor
the Reactor from which to extract info
const bool _solver_info
Whether to print solver info.
const unsigned _precision
precision of output
const Real _mol_cutoff
Species with molalities less than mol_cutoff will not be outputted.
const NearestNodeNumberUO & _nnn
UserObject defining the node of interest.
const InputParameters & parameters() const

Member Function Documentation

◆ output()

void GeochemistryConsoleOutput::output ( )
overrideprotectedvirtual

Implements Output.

Definition at line 66 of file GeochemistryConsoleOutput.C.

67{
68 const Node * closest_node = _nnn.getClosestNode();
69 if (!closest_node)
70 return;
71 const dof_id_type closest_id = closest_node->id();
72
73 if (_solver_info)
74 _console << _reactor.getSolverOutput(closest_id).str();
75
76 // retrieve information
77 const GeochemicalSystem & egs = _reactor.getGeochemicalSystem(closest_id);
78 const unsigned num_basis = egs.getNumInBasis();
79 const unsigned num_eqm = egs.getNumInEquilibrium();
80 const unsigned num_kin = egs.getNumKinetic();
81 const std::vector<Real> & basis_molality = egs.getSolventMassAndFreeMolalityAndMineralMoles();
82 const std::vector<Real> & basis_activity = egs.getBasisActivity();
83 const std::vector<Real> & basis_act_coef = egs.getBasisActivityCoefficient();
84 const std::vector<Real> & bulk_moles = egs.getBulkMolesOld();
85 const std::vector<Real> & eqm_molality = egs.getEquilibriumMolality();
86 const std::vector<Real> & eqm_act_coef = egs.getEquilibriumActivityCoefficient();
87 const std::vector<Real> & eqm_SI = egs.getSaturationIndices();
88 const std::vector<Real> & kin_moles = egs.getKineticMoles();
90
91 _console << std::setprecision(_precision);
92
93 _console << "\nSummary:\n";
94
95 _console << "Total number of iterations required = " << _reactor.getSolverIterations(closest_id)
96 << "\n";
97 _console << "Error in calculation = " << _reactor.getSolverResidual(closest_id) << "mol\n";
98 _console << "Charge of solution = " << egs.getTotalChargeOld() << "mol";
99 _console << " (charge-balance species = "
101
102 _console << "Mass of solvent water = " << basis_molality[0] << "kg\n";
103
104 Real mass = bulk_moles[0] / GeochemistryConstants::MOLES_PER_KG_WATER;
105 for (unsigned i = 1; i < num_basis; ++i) // do not loop over water
106 mass += bulk_moles[i] * mgd.basis_species_molecular_weight[i] / 1000.0;
107 _console << "Total mass = " << mass << "kg";
108 if (num_kin == 0)
109 _console << "\n";
110 else
111 {
112 _console << " (including kinetic species and free minerals)\n";
113 for (unsigned k = 0; k < num_kin; ++k)
114 mass -= kin_moles[k] * mgd.kin_species_molecular_weight[k] / 1000.0;
115 _console << "Mass without kinetic species but including free minerals = " << mass << "kg\n";
116 }
117 // remove the free minerals
118 for (unsigned i = 1; i < num_basis; ++i) // do not loop over water
120 mass -= basis_molality[i] * mgd.basis_species_molecular_weight[i] / 1000.0;
121 // remove surface complexes
122 for (const auto & name_info :
123 mgd.surface_complexation_info) // all minerals involved in surface complexation
124 for (const auto & name_frac :
125 name_info.second.sorption_sites) // all sorption sites on the given mineral
126 {
127 const unsigned i =
128 mgd.basis_species_index.at(name_frac.first); // i = basis_index_of_sorption_site
129 mass -= basis_molality[i] * mgd.basis_species_molecular_weight[i] / 1000.0;
130 }
131 _console << "Mass of aqueous solution = " << mass << "kg";
132 if (num_kin == 0)
133 _console << " (without free minerals)\n";
134 else
135 _console << " (without kinetic species and without free minerals)\n";
136
137 // Output the aqueous solution pH, if relevant
138 if (mgd.basis_species_index.count("H+"))
139 _console << "pH = " << -std::log10(basis_activity[mgd.basis_species_index.at("H+")]) << "\n";
140 if (mgd.eqm_species_index.count("H+"))
141 _console << "pH = "
142 << -std::log10(eqm_molality[mgd.eqm_species_index.at("H+")] *
143 eqm_act_coef[mgd.eqm_species_index.at("H+")])
144 << "\n";
145
146 // Output the aqueous solution pe, if relevant
147 if (mgd.redox_stoichiometry.m() > 0)
148 _console << "pe = " << egs.getRedoxLog10K(0) - egs.log10RedoxActivityProduct(0) << "\n";
149
150 // Output ionic strengths
151 _console << "Ionic strength = " << egs.getIonicStrength() << "mol/kg(solvent water)\n";
152 _console << "Stoichiometric ionic strength = " << egs.getStoichiometricIonicStrength()
153 << "mol/kg(solvent water)\n";
154
155 // Output activity of water
156 _console << "Activity of water = " << basis_activity[0] << "\n";
157
158 // Output temperature
159 _console << "Temperature = " << egs.getTemperature() << "\n";
160
161 // Output the basis species information, sorted by molality
162 std::vector<unsigned> basis_order =
163 GeochemistrySortedIndices::sortedIndices(basis_molality, false);
164 _console << "\nBasis Species:\n";
165 for (const auto & i : basis_order)
166 if (i == 0 || mgd.basis_species_gas[i])
167 continue;
168 else
169 {
170 _console << mgd.basis_species_name[i] << "; bulk_moles = " << bulk_moles[i]
171 << "mol; bulk_conc = "
172 << bulk_moles[i] * mgd.basis_species_molecular_weight[i] * 1000.0 / mass
173 << "mg/kg(soln);";
175 _console << " molality = " << basis_molality[i] << "mol/kg(solvent water); free_conc = "
176 << basis_molality[i] * basis_molality[0] / mass *
178 << "mg/kg(soln); act_coeff = " << basis_act_coef[i]
179 << "; log10(a) = " << std::log10(basis_activity[i]) << "\n";
180 else if (mgd.basis_species_mineral[i])
181 _console << " free_moles = " << basis_molality[i] << "mol; free_mass = "
182 << basis_molality[i] * mgd.basis_species_molecular_weight[i] * 1000.0 << "mg\n";
183 }
184 for (unsigned i = 0; i < num_basis; ++i)
185 if (mgd.basis_species_gas[i])
186 _console << mgd.basis_species_name[i] << "; fugacity = " << basis_activity[i] << "\n";
187
188 // Output the equilibrium species info, sorted by molality
189 std::vector<unsigned> eqm_order = GeochemistrySortedIndices::sortedIndices(eqm_molality, false);
190 _console << "\nEquilibrium Species:\n";
191 for (const auto & i : eqm_order)
192 if (eqm_molality[i] <= _mol_cutoff)
193 break;
194 else if (mgd.eqm_species_gas[i])
195 continue;
196 else
197 _console << mgd.eqm_species_name[i] << "; molality = " << eqm_molality[i]
198 << "mol/kg(solvent water); free_conc = "
199 << eqm_molality[i] * basis_molality[0] / mass * mgd.eqm_species_molecular_weight[i] *
200 1000.0
201 << "mg/kg(soln); act_coeff = " << eqm_act_coef[i]
202 << "; log10(a) = " << std::log10(eqm_molality[i] * eqm_act_coef[i]) << "; "
203 << mgd.eqm_species_name[i] << " = "
206 << "; log10K = " << egs.getLog10K(i) << "\n";
207 for (unsigned i = 0; i < num_eqm; ++i)
208 if (mgd.eqm_species_gas[i])
209 {
210 Real log10f = 0;
211 for (unsigned basis_i = 0; basis_i < num_basis; ++basis_i)
212 log10f += mgd.eqm_stoichiometry(i, basis_i) * std::log10(basis_activity[basis_i]);
213 log10f -= egs.getLog10K(i);
215 << "; act_coeff = " << egs.getEquilibriumActivityCoefficient(i)
216 << "; fugacity = " << std::pow(10.0, log10f) << "; " << mgd.eqm_species_name[i]
217 << " = "
220 << "; log10K = " << egs.getLog10K(i) << "\n";
221 }
222
223 // Output the kinetic species information, sorted by mole number
224 std::vector<unsigned> kin_order = GeochemistrySortedIndices::sortedIndices(kin_moles, false);
225 _console << "\nKinetic Species:\n";
226 for (const auto & k : kin_order)
227 {
228 _console << mgd.kin_species_name[k] << "; moles = " << kin_moles[k]
229 << "; mass = " << kin_moles[k] * mgd.kin_species_molecular_weight[k] * 1000.0
230 << "mg; ";
232 _console << "volume = " << kin_moles[k] * mgd.kin_species_molecular_volume[k] << "cm^3; ";
233 _console << mgd.kin_species_name[k] << " = "
236 << "; log10(Q) = " << egs.log10KineticActivityProduct(k)
237 << "; log10K = " << egs.getKineticLog10K(k)
238 << "; dissolution_rate*dt = " << -_reactor.getMoleAdditions(closest_id)(num_basis + k)
239 << "\n";
240 }
241
242 // Output the mineral info, sorted by saturation indices
243 std::vector<unsigned> mineral_order = GeochemistrySortedIndices::sortedIndices(eqm_SI, false);
244 _console << "\nMinerals:\n";
245 for (const auto & i : mineral_order)
246 if (mgd.eqm_species_mineral[i])
247 _console << mgd.eqm_species_name[i] << " = "
249 mgd.eqm_stoichiometry, i, mgd.basis_species_name, _stoi_tol, _precision)
250 << "; log10K = " << egs.getLog10K(i) << "; SI = " << eqm_SI[i] << "\n";
251
252 // Output the Nernst potentials, if relevant
253 _console << "\nNernst potentials:\n";
254 if (mgd.redox_stoichiometry.m() > 0)
255 outputNernstInfo(egs);
256
257 const unsigned num_pot = egs.getNumSurfacePotentials();
258 if (num_pot > 0)
259 {
260 _console << "\nSorbing surfaces:\n";
261 const std::vector<Real> area = egs.getSorbingSurfaceArea();
262 for (unsigned sp = 0; sp < num_pot; ++sp)
263 _console << mgd.surface_sorption_name[sp] << "; area = " << area[sp]
264 << "m^2; specific charge = " << egs.getSurfaceCharge(sp)
265 << "C/m^2; surface potential = " << egs.getSurfacePotential(sp) << "V\n";
266 }
267
268 DenseVector<Real> bulk_in_original_basis = egs.getBulkOldInOriginalBasis();
269 DenseVector<Real> transported_bulk_in_original_basis = egs.getTransportedBulkInOriginalBasis();
270 std::vector<std::string> original_basis_names =
272 _console << "\nIn original basis:\n";
273 for (unsigned i = 0; i < num_basis; ++i)
274 _console << original_basis_names[i] << "; total_bulk_moles = " << bulk_in_original_basis(i)
275 << "; transported_bulk_moles = " << transported_bulk_in_original_basis(i) << "\n";
276
277 _console << std::flush;
278}
const ModelGeochemicalDatabase mgd
for(PetscInt i=0;i< nvars;++i)
const ConsoleStream _console
This class holds information about bulk composition, molalities, activities, activity coefficients,...
Real log10KineticActivityProduct(unsigned kin) const
std::vector< Real > getSaturationIndices() const
unsigned getNumKinetic() const
returns the number of kinetic species
Real getLog10K(unsigned j) const
Real getEquilibriumActivityCoefficient(unsigned j) const
const std::vector< Real > & getSorbingSurfaceArea() const
Real log10RedoxActivityProduct(unsigned red) const
Real getKineticLog10K(unsigned kin) const
Real getRedoxLog10K(unsigned red) const
Real getSurfacePotential(unsigned sp) const
unsigned getNumSurfacePotentials() const
return the number of surface potentials
unsigned getNumInBasis() const
returns the number of species in the basis
Real getKineticMoles(unsigned kin) const
unsigned getNumInEquilibrium() const
returns the number of species in equilibrium with the basis components
unsigned getChargeBalanceBasisIndex() const
return the index of the charge-balance species in the basis list
Real getTotalChargeOld() const
DenseVector< Real > getTransportedBulkInOriginalBasis() const
Real getStoichiometricIonicStrength() const
Get the stoichiometric ionic strength.
Real getBasisActivityCoefficient(unsigned i) const
const std::vector< Real > & getBulkMolesOld() const
const ModelGeochemicalDatabase & getModelGeochemicalDatabase() const
Real getIonicStrength() const
Get the ionic strength.
const std::vector< Real > & getSolventMassAndFreeMolalityAndMineralMoles() const
DenseVector< Real > getBulkOldInOriginalBasis() const
Real getSurfaceCharge(unsigned sp) const
Real getBasisActivity(unsigned i) const
Real getEquilibriumMolality(unsigned j) const
Real getTemperature() const
void outputNernstInfo(const GeochemicalSystem &egs_ref) const
virtual const GeochemicalSystem & getGeochemicalSystem(dof_id_type node_id) const =0
virtual Real getSolverResidual(dof_id_type node_id) const =0
virtual const DenseVector< Real > & getMoleAdditions(dof_id_type node_id) const =0
const PertinentGeochemicalSystem & getPertinentGeochemicalSystem() const
returns a reference to the PertinentGeochemicalSystem used to creat the ModelGeochemicalDatabase
virtual const std::stringstream & getSolverOutput(dof_id_type node_id) const =0
virtual unsigned getSolverIterations(dof_id_type node_id) const =0
const Node * getClosestNode() const
std::vector< std::string > originalBasisNames() const
unsigned int m() const
std::string reaction(const DenseMatrix< Real > &stoi, unsigned row, const std::vector< std::string > &names, Real stoi_tol=1.0E-6, int precision=4)
Returns a nicely formatted string corresponding to the reaction defined by the given row of the stoic...
std::vector< unsigned > sortedIndices(const std::vector< Real > &to_sort, bool ascending)
Produces a vector of indices corresponding to the smallest-to-biggest entries in to_sort (or biggest-...
if(subdm)
uint8_t dof_id_type
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Data structure to hold all relevant information from the database file.
DenseMatrix< Real > eqm_stoichiometry
eqm_stoichiometry(i, j) = stoichiometric coefficient for equilibrium species "i" in terms of the basi...
std::vector< Real > basis_species_molecular_weight
all quantities have a molecular weight (g)
DenseMatrix< Real > kin_stoichiometry
kin_stoichiometry(i, j) = stoichiometric coefficient for kinetic species "i" in terms of the basis sp...
std::vector< bool > kin_species_mineral
kin_species_mineral[j] = true iff the j^th kinetic species is a mineral
std::vector< Real > eqm_species_molecular_weight
all quantities have a molecular weight (g)
std::vector< std::string > kin_species_name
kin_species_name[j] = name of the j^th kinetic species
DenseMatrix< Real > redox_stoichiometry
redox_stoichiometry(i, j) = stoichiometric coefficients for i^th redox species that is in disequilibr...
std::vector< bool > basis_species_mineral
basis_species_mineral[j] = true iff the j^th basis species is a mineral
std::vector< Real > kin_species_molecular_volume
all quantities have a molecular volume (cm^3/mol) (only nonzero for minerals, however)
std::unordered_map< std::string, unsigned > eqm_species_index
eqm_species_index[name] = index of the equilibrium species (secondary aqueous species,...
std::vector< std::string > basis_species_name
basis_species_name[j] = name of the j^th basis species
std::unordered_map< std::string, unsigned > basis_species_index
basis_species_index[name] = index of the basis species, within all ModelGeochemicalDatabase internal ...
std::vector< std::string > surface_sorption_name
surface_sorption_name[k] = name of the mineral involved in surface sorption.
std::vector< bool > basis_species_gas
basis_species_gas[j] = true iff the j^th basis species is a gas
std::vector< std::string > eqm_species_name
eqm_species_name[i] = name of the i^th eqm species
std::vector< bool > eqm_species_gas
eqm_species_gas[i] = true iff the i^th equilibrium species is a gas
std::vector< Real > kin_species_molecular_weight
all quantities have a molecular weight (g/mol)

◆ outputNernstInfo()

void GeochemistryConsoleOutput::outputNernstInfo ( const GeochemicalSystem egs_ref) const
private

Definition at line 281 of file GeochemistryConsoleOutput.C.

282{
283 // Copy egs_ref so we can call non-const methods (viz, swaps). This does not copy the data in
284 // egs.getModelGeochemicalDatabase(), only the reference (both references refer to the same
285 // block of memory) and unfortunately the swaps below manipulate that memory
286 GeochemicalSystem egs = egs_ref;
287 // Since we only want to do the swaps to print out some Nernst info, but don't want to impact
288 // the rest of the simulation, copy the mgd, so that we can copy it back into the aforementioned
289 // block of memory at the end of this method
290 ModelGeochemicalDatabase mgd_without_nernst_swaps = egs.getModelGeochemicalDatabase();
291
293 // attempt to undo the swaps that have been done to mgd_ref.
294 // NOTE FOR FUTURE: In the current code (2020, June 1) swapping the redox stuff in mgd seems
295 // redundant. While the current code does these swaps, here we just undo all the swaps again to
296 // write the redox stuff in the original basis. Since this is the only place that the redox
297 // stuff is used, doing any swaps on the redox stuff is currently just a waste of time! take a
298 // copy of the following because they get modified during the swaps
299 const std::vector<unsigned> have_swapped_out_of_basis = mgd_ref.have_swapped_out_of_basis;
300 const std::vector<unsigned> have_swapped_into_basis = mgd_ref.have_swapped_into_basis;
301 for (int sw = have_swapped_out_of_basis.size() - 1; sw >= 0; --sw)
302 {
303 // Don't check for gases being swapped in or out of the basis (which usually can't happen in
304 // the middle of a Newton process) because we're going to trash all the swaps at the end of
305 // this method, and we don't have to worry about bulk moles, etc: we just want the
306 // stoichiometries and the activities
307 try
308 {
309 egs.performSwapNoCheck(have_swapped_out_of_basis[sw], have_swapped_into_basis[sw]);
310 }
311 catch (const MooseException & e)
312 {
313 const std::string to_swap_in = mgd_ref.eqm_species_name[have_swapped_into_basis[sw]];
314 const std::string to_swap_out = mgd_ref.basis_species_name[have_swapped_out_of_basis[sw]];
315 // Don't crash the entire simulation, just because Nernst-related swapping does not work
316 mooseWarning("Swapping ", to_swap_out, " and ", to_swap_in, ": ", e.what());
317 }
318 }
319
323
324 if (mgd_ref.redox_lhs == egs_ref.getOriginalRedoxLHS())
325 {
326 std::vector<Real> eh(mgd_ref.redox_stoichiometry.m());
327 for (unsigned red = 0; red < mgd_ref.redox_stoichiometry.m(); ++red)
328 eh[red] = prefactor * (egs.log10RedoxActivityProduct(red) - egs.getRedoxLog10K(red));
329 const std::vector<unsigned> eh_order = GeochemistrySortedIndices::sortedIndices(eh, false);
330 for (const auto & red : eh_order)
331 _console << mgd_ref.redox_lhs << " = "
332 << GeochemistryFormattedOutput::reaction(mgd_ref.redox_stoichiometry,
333 red,
334 mgd_ref.basis_species_name,
335 _stoi_tol,
337 << "; Eh = " << eh[red] << "V\n";
338 }
339
340 _console << std::flush;
341
342 // restore the original mgd by copying the data in copy_of_mgd into the memory referenced by
343 // egs.getModelGeochemicalDatabase()
344 egs.setModelGeochemicalDatabase(mgd_without_nernst_swaps);
345}
const std::string & getOriginalRedoxLHS() const
void performSwapNoCheck(unsigned swap_out_of_basis, unsigned swap_into_basis)
Perform the basis swap, and ensure that the resulting system is consistent.
void setModelGeochemicalDatabase(const ModelGeochemicalDatabase &mgd)
Copies a ModelGeochemicalDatabase into our _mgd structure.
void mooseWarning(Args &&... args) const
virtual const char * what() const
std::string redox_lhs
the name of the species on the left-hand side of the redox equations.
std::vector< unsigned > have_swapped_into_basis
Species that have been swapped into the basis.
std::vector< unsigned > have_swapped_out_of_basis
Species that have been swapped out of the basis.

Referenced by output().

◆ sharedParams()

InputParameters GeochemistryConsoleOutput::sharedParams ( )
static

contains params that are shared with Actions that use this object

Definition at line 18 of file GeochemistryConsoleOutput.C.

19{
21 params.addParam<unsigned int>("precision", 4, "Precision for printing values");
22 params.addParam<Real>(
23 "mol_cutoff",
24 1E-40,
25 "Information regarding species with molalities less than this amount will not be outputted");
26 params.addParam<bool>(
27 "solver_info",
28 false,
29 "Print information (to the console) from the solver including residuals, swaps, etc");
30 return params;
31}
InputParameters emptyInputParameters()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)

Referenced by AddGeochemistrySolverAction::validParams(), and validParams().

◆ validParams()

InputParameters GeochemistryConsoleOutput::validParams ( )
static

Definition at line 34 of file GeochemistryConsoleOutput.C.

35{
38 params.addRequiredParam<UserObjectName>("geochemistry_reactor",
39 "The name of the GeochemistryReactor UserObject");
40 params.addRangeCheckedParam<Real>("stoichiometry_tolerance",
41 1E-6,
42 "stoichiometry_tolerance >= 0.0",
43 "if abs(any stoichiometric coefficient) < stoi_tol then it is "
44 "set to zero, and so will not appear in the output");
45 params.addRequiredParam<UserObjectName>(
46 "nearest_node_number_UO",
47 "The NearestNodeNumber UserObject that defines the physical point at which to query the "
48 "GeochemistryReactor");
49 params.addClassDescription("Outputs results from a GeochemistryReactor at a particular point");
50 return params;
51}
static InputParameters sharedParams()
contains params that are shared with Actions that use this object
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
static InputParameters validParams()

Member Data Documentation

◆ _mol_cutoff

const Real GeochemistryConsoleOutput::_mol_cutoff
protected

Species with molalities less than mol_cutoff will not be outputted.

Definition at line 44 of file GeochemistryConsoleOutput.h.

Referenced by output().

◆ _nnn

const NearestNodeNumberUO& GeochemistryConsoleOutput::_nnn
protected

UserObject defining the node of interest.

Definition at line 36 of file GeochemistryConsoleOutput.h.

Referenced by output().

◆ _precision

const unsigned GeochemistryConsoleOutput::_precision
protected

precision of output

Definition at line 38 of file GeochemistryConsoleOutput.h.

Referenced by output(), and outputNernstInfo().

◆ _reactor

const GeochemistryReactorBase& GeochemistryConsoleOutput::_reactor
protected

the Reactor from which to extract info

Definition at line 34 of file GeochemistryConsoleOutput.h.

Referenced by output().

◆ _solver_info

const bool GeochemistryConsoleOutput::_solver_info
protected

Whether to print solver info.

Definition at line 42 of file GeochemistryConsoleOutput.h.

Referenced by output().

◆ _stoi_tol

const Real GeochemistryConsoleOutput::_stoi_tol
protected

Tolerance on stoichiometric coefficients before they are deemed to be zero.

Definition at line 40 of file GeochemistryConsoleOutput.h.

Referenced by output(), and outputNernstInfo().


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