OGS
ChemistryLib::PhreeqcKernelData Namespace Reference

Classes

class  AqueousSolution
 
class  Component
 
class  EquilibriumReactants
 
class  InitialAqueousSolution
 
class  KineticReactant
 
class  Kinetics
 
class  PhaseComponent
 
class  PhreeqcKernel
 
class  ReactionRate
 

Functions

static bool isHydrogen (std::string_view const element)
 
AqueousSolution createAqueousSolution (BaseLib::ConfigTree const &config, std::vector< std::pair< int, std::string > > const &process_id_to_component_name_map)
 
std::unique_ptr< EquilibriumReactantscreateEquilibriumReactants (std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
 
InitialAqueousSolution createInitialAqueousSolution (BaseLib::ConfigTree const &config, std::vector< std::pair< int, std::string > > const &process_id_to_component_name_map)
 
std::unique_ptr< KineticscreateKineticReactants (std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
 

Function Documentation

◆ createAqueousSolution()

AqueousSolution ChemistryLib::PhreeqcKernelData::createAqueousSolution ( BaseLib::ConfigTree const & config,
std::vector< std::pair< int, std::string > > const & process_id_to_component_name_map )
Input File Parameter
prj__chemical_system__solution__temperature
Input File Parameter
prj__chemical_system__solution__pressure
Input File Parameter
prj__chemical_system__solution__pe

Definition at line 20 of file CreateAqueousSolution.cpp.

24{
26 auto const temperature = config.getConfigParameter<double>("temperature");
27
29 auto const pressure = config.getConfigParameter<double>("pressure");
30
32 auto const pe = config.getConfigParameter<double>("pe");
33
34 auto const initial_aqueous_solution =
35 createInitialAqueousSolution(config, process_id_to_component_name_map);
36
37 return {temperature, pressure, pe, initial_aqueous_solution};
38}
InitialAqueousSolution createInitialAqueousSolution(BaseLib::ConfigTree const &config, std::vector< std::pair< int, std::string > > const &process_id_to_component_name_map)

References createInitialAqueousSolution(), BaseLib::ConfigTree::getConfigParameter(), and ChemistryLib::pe.

◆ createEquilibriumReactants()

std::unique_ptr< EquilibriumReactants > ChemistryLib::PhreeqcKernelData::createEquilibriumReactants ( std::optional< BaseLib::ConfigTree > const & config,
MeshLib::Mesh const & mesh )
Input File Parameter
prj__chemical_system__equilibrium_reactants__phase_component
Input File Parameter
prj__chemical_system__equilibrium_reactants__phase_component__name
Input File Parameter
prj__chemical_system__equilibrium_reactants__phase_component__initial_amount
Input File Parameter
prj__chemical_system__equilibrium_reactants__phase_component__saturation_index

Definition at line 25 of file CreateEquilibriumReactants.cpp.

27{
28 if (!config)
29 {
30 return nullptr;
31 }
32
33 std::vector<PhaseComponent> phase_components;
34 for (
35 auto const& phase_component_config :
37 config->getConfigSubtreeList("phase_component"))
38 {
39 auto name =
41 phase_component_config.getConfigParameter<std::string>("name");
42
43 double const initial_amount =
45 phase_component_config.getConfigParameter<double>("initial_amount");
46
47 double const saturation_index =
49 phase_component_config.getConfigParameter<double>(
50 "saturation_index");
51
52 auto amount = MeshLib::getOrCreateMeshProperty<double>(
53 const_cast<MeshLib::Mesh&>(mesh),
54 name,
56 1);
57 std::fill(amount->begin(), amount->end(), initial_amount);
58
59 phase_components.emplace_back(
60 std::move(name), initial_amount, saturation_index);
61 }
62
63 return std::make_unique<EquilibriumReactants>(phase_components);
64}

References MeshLib::Node.

◆ createInitialAqueousSolution()

InitialAqueousSolution ChemistryLib::PhreeqcKernelData::createInitialAqueousSolution ( BaseLib::ConfigTree const & config,
std::vector< std::pair< int, std::string > > const & process_id_to_component_name_map )
Input File Parameter
prj__chemical_system__solution__components
Input File Parameter
prj__chemical_system__solution__components__component

Definition at line 23 of file CreateInitialAqueousSolution.cpp.

27{
28 std::map<std::string, cxxISolutionComp> components;
30 auto comp_config = config.getConfigSubtree("components");
31 for (
32 auto const& component_config :
34 comp_config.getConfigSubtreeList("component"))
35 {
36 auto const component_name = component_config.getValue<std::string>();
37 Component component(component_name);
38 components.emplace(component_name, component);
39 }
40
41 for (auto const& component : components)
42 {
43 auto process_id_to_component_name_pair =
44 std::find_if(process_id_to_component_name_map.begin(),
45 process_id_to_component_name_map.end(),
46 [&component](auto const& pair)
47 { return pair.second == component.first; });
48
49 if (process_id_to_component_name_pair ==
50 process_id_to_component_name_map.end())
51 {
53 "Component {:s} given in <solution>/<components> is not found "
54 "in specified coupled processes (see "
55 "<process>/<process_variables>/<concentration>).",
56 component.first);
57 }
58 }
59
60 if (components.size() + 1 != process_id_to_component_name_map.size())
61 {
63 "The number of components given in <solution>/<components> is not "
64 "in line with the number of transport processes - 1 which stands "
65 "for the transport process of hydrogen.");
66 }
67
68 auto const charge_balance = createChargeBalance(config);
69 if (charge_balance == ChargeBalance::pH)
70 {
71 Component component("H(1)");
72 component.Set_equation_name("charge");
73 components.emplace("H(1)", component);
74 }
75 if (charge_balance == ChargeBalance::pe)
76 {
78 "Adjusting pe value for charge balance is unsupported yet with the "
79 "chemical solver 'PhreeqcKernel'. Please use the chemical solver "
80 "'Phreeqc' for this functionality.");
81 }
82
83 return InitialAqueousSolution(components);
84}
#define OGS_FATAL(...)
Definition Error.h:26
ChargeBalance createChargeBalance(BaseLib::ConfigTree const &config)

References ChemistryLib::createChargeBalance(), BaseLib::ConfigTree::getConfigSubtree(), BaseLib::ConfigTree::getValue(), OGS_FATAL, ChemistryLib::pe, and ChemistryLib::pH.

Referenced by createAqueousSolution().

◆ createKineticReactants()

std::unique_ptr< Kinetics > ChemistryLib::PhreeqcKernelData::createKineticReactants ( std::optional< BaseLib::ConfigTree > const & config,
MeshLib::Mesh const & mesh )
Input File Parameter
prj__chemical_system__kinetic_reactants__kinetic_reactant
Input File Parameter
prj__chemical_system__kinetic_reactants__kinetic_reactant__name
Input File Parameter
prj__chemical_system__kinetic_reactants__kinetic_reactant__initial_amount

Definition at line 25 of file CreateKineticReactant.cpp.

27{
28 if (!config)
29 {
30 return nullptr;
31 }
32
33 std::vector<KineticReactant> kinetic_reactants;
34 for (
35 auto const& reactant_config :
37 config->getConfigSubtreeList("kinetic_reactant"))
38 {
40 auto name = reactant_config.getConfigParameter<std::string>("name");
41
42 double const initial_amount =
44 reactant_config.getConfigParameter<double>("initial_amount");
45
46 auto* const amount = MeshLib::getOrCreateMeshProperty<double>(
47 const_cast<MeshLib::Mesh&>(mesh),
48 name,
50 1);
51 std::fill(std::begin(*amount), std::end(*amount), initial_amount);
52
53 kinetic_reactants.emplace_back(std::move(name), initial_amount);
54 }
55
56 return std::make_unique<Kinetics>(kinetic_reactants);
57}

References MeshLib::Node.

◆ isHydrogen()

static bool ChemistryLib::PhreeqcKernelData::isHydrogen ( std::string_view const element)
static