OGS
ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp} Namespace Reference

Classes

struct  overloaded
 

Functions

template<class... Ts>
 overloaded (Ts...) -> overloaded< Ts... >
 
template<typename DataBlock >
std::ostream & operator<< (std::ostream &os, std::vector< DataBlock > const &data_blocks)
 
void setAqueousSolution (std::vector< double > const &concentrations, GlobalIndexType const &chemical_system_id, AqueousSolution &aqueous_solution)
 
template<typename Reactant >
void initializeReactantMolality (Reactant &reactant, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Phase const &solid_phase, MaterialPropertyLib::Phase const &liquid_phase, MaterialPropertyLib::Medium const &medium, ParameterLib::SpatialPosition const &pos, double const t)
 
template<typename Reactant >
void setReactantMolality (Reactant &reactant, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Phase const &solid_phase, MaterialPropertyLib::Phase const &liquid_phase, MaterialPropertyLib::VariableArray const &vars, ParameterLib::SpatialPosition const &pos, double const t, double const dt)
 
template<typename Site >
void initializeSiteMolality (Site &site, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Phase const &solid_phase, ParameterLib::SpatialPosition const &pos, double const t)
 
template<typename Reactant >
void updateReactantVolumeFraction (Reactant &reactant, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Medium const &medium, ParameterLib::SpatialPosition const &pos, double const porosity, double const t, double const dt)
 
template<typename Reactant >
void setPorosityPostReaction (Reactant &reactant, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Medium const &medium, double &porosity)
 
template<typename Reactant >
static double averageReactantMolality (Reactant const &reactant, std::vector< GlobalIndexType > const &chemical_system_indices)
 

Function Documentation

◆ averageReactantMolality()

template<typename Reactant >
static double ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::averageReactantMolality ( Reactant const & reactant,
std::vector< GlobalIndexType > const & chemical_system_indices )
static

Definition at line 250 of file PhreeqcIO.cpp.

253{
254 double const sum = std::accumulate(
255 chemical_system_indices.begin(), chemical_system_indices.end(), 0.0,
256 [&](double const s, GlobalIndexType const id)
257 { return s + (*reactant.molality)[id]; });
258 return sum / chemical_system_indices.size();
259}
GlobalMatrix::IndexType GlobalIndexType

References averageReactantMolality().

Referenced by averageReactantMolality().

◆ initializeReactantMolality()

template<typename Reactant >
void ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::initializeReactantMolality ( Reactant & reactant,
GlobalIndexType const & chemical_system_id,
MaterialPropertyLib::Phase const & solid_phase,
MaterialPropertyLib::Phase const & liquid_phase,
MaterialPropertyLib::Medium const & medium,
ParameterLib::SpatialPosition const & pos,
double const t )

Definition at line 86 of file PhreeqcIO.cpp.

93{
94 auto const& solid_constituent = solid_phase.component(reactant.name);
95
96 if (solid_constituent.hasProperty(
98 {
99 auto const molality =
101 .template initialValue<double>(pos, t);
102
103 (*reactant.molality)[chemical_system_id] = molality;
104 (*reactant.molality_prev)[chemical_system_id] = molality;
105 }
106 else
107 {
108 auto const volume_fraction =
109 solid_constituent
111 .template initialValue<double>(pos, t);
112
113 (*reactant.volume_fraction)[chemical_system_id] = volume_fraction;
114
115 (*reactant.volume_fraction_prev)[chemical_system_id] = volume_fraction;
116
117 auto const fluid_density =
119 .template initialValue<double>(pos, t);
120
121 auto const porosity =
123 .template initialValue<double>(pos, t);
124
125 auto const molar_volume =
127 .template initialValue<double>(pos, t);
128
129 (*reactant.molality)[chemical_system_id] =
130 volume_fraction / fluid_density / porosity / molar_volume;
131
132 (*reactant.molality_prev)[chemical_system_id] =
133 (*reactant.molality)[chemical_system_id];
134 }
135}

References MaterialPropertyLib::Phase::component(), MaterialPropertyLib::density, initializeReactantMolality(), MaterialPropertyLib::molality, MaterialPropertyLib::molar_volume, MaterialPropertyLib::porosity, and MaterialPropertyLib::volume_fraction.

Referenced by initializeReactantMolality().

◆ initializeSiteMolality()

template<typename Site >
void ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::initializeSiteMolality ( Site & site,
GlobalIndexType const & chemical_system_id,
MaterialPropertyLib::Phase const & solid_phase,
ParameterLib::SpatialPosition const & pos,
double const t )

Definition at line 179 of file PhreeqcIO.cpp.

184{
185 auto const& solid_constituent = solid_phase.component(site.name);
186
187 auto const molality =
189 .template initialValue<double>(pos, t);
190
191 (*site.molality)[chemical_system_id] = molality;
192}

References MaterialPropertyLib::Phase::component(), initializeSiteMolality(), and MaterialPropertyLib::molality.

Referenced by initializeSiteMolality().

◆ operator<<()

template<typename DataBlock >
std::ostream & ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::operator<< ( std::ostream & os,
std::vector< DataBlock > const & data_blocks )

Definition at line 54 of file PhreeqcIO.cpp.

56{
57 std::copy(data_blocks.begin(), data_blocks.end(),
58 std::ostream_iterator<DataBlock>(os));
59 return os;
60}

◆ overloaded()

template<class... Ts>
ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::overloaded ( Ts... ) -> overloaded< Ts... >

◆ setAqueousSolution()

void ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::setAqueousSolution ( std::vector< double > const & concentrations,
GlobalIndexType const & chemical_system_id,
AqueousSolution & aqueous_solution )

Definition at line 62 of file PhreeqcIO.cpp.

65{
66 GlobalIndexType const offset = aqueous_solution.pH->getRangeBegin();
67 GlobalIndexType const global_index = offset + chemical_system_id;
68
69 // components
70 auto& components = aqueous_solution.components;
71 for (unsigned component_id = 0; component_id < components.size();
72 ++component_id)
73 {
75 *components[component_id].amount);
76 components[component_id].amount->set(global_index,
77 concentrations[component_id]);
78 }
79
80 // pH
82 aqueous_solution.pH->set(global_index, concentrations.back());
83}
void setLocalAccessibleVector(PETScVector const &x)
Definition LinAlg.cpp:27

References ChemistryLib::PhreeqcIOData::AqueousSolution::components, ChemistryLib::PhreeqcIOData::AqueousSolution::pH, setAqueousSolution(), and MathLib::LinAlg::setLocalAccessibleVector().

Referenced by setAqueousSolution().

◆ setPorosityPostReaction()

template<typename Reactant >
void ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::setPorosityPostReaction ( Reactant & reactant,
GlobalIndexType const & chemical_system_id,
MaterialPropertyLib::Medium const & medium,
double & porosity )

Definition at line 230 of file PhreeqcIO.cpp.

234{
235 auto const& solid_phase = medium.phase("Solid");
236
237 auto const& solid_constituent = solid_phase.component(reactant.name);
238
239 if (solid_constituent.hasProperty(
241 {
242 return;
243 }
244
245 porosity -= ((*reactant.volume_fraction)[chemical_system_id] -
246 (*reactant.volume_fraction_prev)[chemical_system_id]);
247}

References MaterialPropertyLib::Phase::component(), MaterialPropertyLib::molality, MaterialPropertyLib::Medium::phase(), and setPorosityPostReaction().

Referenced by setPorosityPostReaction().

◆ setReactantMolality()

template<typename Reactant >
void ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::setReactantMolality ( Reactant & reactant,
GlobalIndexType const & chemical_system_id,
MaterialPropertyLib::Phase const & solid_phase,
MaterialPropertyLib::Phase const & liquid_phase,
MaterialPropertyLib::VariableArray const & vars,
ParameterLib::SpatialPosition const & pos,
double const t,
double const dt )

Definition at line 138 of file PhreeqcIO.cpp.

145{
146 auto const& solid_constituent = solid_phase.component(reactant.name);
147
148 if (solid_constituent.hasProperty(
150 {
151 (*reactant.molality_prev)[chemical_system_id] =
152 (*reactant.molality)[chemical_system_id];
153
154 return;
155 }
156
157 auto const volume_fraction =
158 (*reactant.volume_fraction)[chemical_system_id];
159
160 (*reactant.volume_fraction_prev)[chemical_system_id] =
161 (*reactant.volume_fraction)[chemical_system_id];
162
163 auto const fluid_density =
165 .template value<double>(vars, pos, t, dt);
166
167 auto const molar_volume =
169 .template value<double>(vars, pos, t, dt);
170
171 (*reactant.molality)[chemical_system_id] =
172 volume_fraction / fluid_density / vars.porosity / molar_volume;
173
174 (*reactant.molality_prev)[chemical_system_id] =
175 (*reactant.molality)[chemical_system_id];
176}

References MaterialPropertyLib::Phase::component(), MaterialPropertyLib::density, MaterialPropertyLib::molality, MaterialPropertyLib::molar_volume, MaterialPropertyLib::VariableArray::porosity, and setReactantMolality().

Referenced by setReactantMolality().

◆ updateReactantVolumeFraction()

template<typename Reactant >
void ChemistryLib::PhreeqcIOData::anonymous_namespace{PhreeqcIO.cpp}::updateReactantVolumeFraction ( Reactant & reactant,
GlobalIndexType const & chemical_system_id,
MaterialPropertyLib::Medium const & medium,
ParameterLib::SpatialPosition const & pos,
double const porosity,
double const t,
double const dt )

Definition at line 195 of file PhreeqcIO.cpp.

201{
202 auto const& solid_phase = medium.phase("Solid");
203 auto const& liquid_phase = medium.phase("AqueousLiquid");
204
206
207 auto const liquid_density =
209 .template value<double>(vars, pos, t, dt);
210
211 auto const& solid_constituent = solid_phase.component(reactant.name);
212
213 if (solid_constituent.hasProperty(
215 {
216 return;
217 }
218
219 auto const molar_volume =
221 .template value<double>(vars, pos, t, dt);
222
223 (*reactant.volume_fraction)[chemical_system_id] +=
224 ((*reactant.molality)[chemical_system_id] -
225 (*reactant.molality_prev)[chemical_system_id]) *
226 liquid_density * porosity * molar_volume;
227}

References MaterialPropertyLib::density, MaterialPropertyLib::molality, MaterialPropertyLib::molar_volume, MaterialPropertyLib::Medium::phase(), and updateReactantVolumeFraction().

Referenced by updateReactantVolumeFraction().