Skip to content
Snippets Groups Projects
Commit eab69f67 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Merge branch 'MolarVolume' into 'master'

[CL] Set reactant molality alternatively

See merge request !3372
parents de485c62 8e8a4eff
No related branches found
No related tags found
1 merge request!3372[CL] Set reactant molality alternatively
...@@ -70,17 +70,48 @@ void setAqueousSolution(std::vector<double> const& concentrations, ...@@ -70,17 +70,48 @@ void setAqueousSolution(std::vector<double> const& concentrations,
template <typename Reactant> template <typename Reactant>
void setReactantMolality(Reactant& reactant, void setReactantMolality(Reactant& reactant,
GlobalIndexType const& chemical_system_id, GlobalIndexType const& chemical_system_id,
MaterialPropertyLib::Phase const& solid_phase, MaterialPropertyLib::Medium const* medium,
ParameterLib::SpatialPosition const& pos, ParameterLib::SpatialPosition const& pos,
double const t) double const t)
{ {
auto const& solid_phase = medium->phase("Solid");
auto const& solid_constituent = solid_phase.component(reactant.name); auto const& solid_constituent = solid_phase.component(reactant.name);
auto const molality = auto const& liquid_phase = medium->phase("AqueousLiquid");
solid_constituent.property(MaterialPropertyLib::PropertyType::molality)
.template initialValue<double>(pos, t); if (solid_constituent.hasProperty(
MaterialPropertyLib::PropertyType::molality))
{
auto const molality =
solid_constituent
.property(MaterialPropertyLib::PropertyType::molality)
.template initialValue<double>(pos, t);
(*reactant.molality)[chemical_system_id] = molality; (*reactant.molality)[chemical_system_id] = molality;
}
else
{
auto const volume_fraction =
solid_constituent
.property(MaterialPropertyLib::PropertyType::volume_fraction)
.template initialValue<double>(pos, t);
auto const fluid_density =
liquid_phase.property(MaterialPropertyLib::PropertyType::density)
.template initialValue<double>(pos, t);
auto const porosity =
medium->property(MaterialPropertyLib::PropertyType::porosity)
.template initialValue<double>(pos, t);
auto const molar_volume =
solid_constituent
.property(MaterialPropertyLib::PropertyType::molar_volume)
.template initialValue<double>(pos, t);
(*reactant.molality)[chemical_system_id] =
volume_fraction / fluid_density / porosity / molar_volume;
}
} }
template <typename Reactant> template <typename Reactant>
...@@ -171,17 +202,16 @@ void PhreeqcIO::initializeChemicalSystemConcrete( ...@@ -171,17 +202,16 @@ void PhreeqcIO::initializeChemicalSystemConcrete(
setAqueousSolution(concentrations, chemical_system_id, setAqueousSolution(concentrations, chemical_system_id,
*_chemical_system->aqueous_solution); *_chemical_system->aqueous_solution);
auto const& solid_phase = medium->phase("Solid");
for (auto& kinetic_reactant : _chemical_system->kinetic_reactants) for (auto& kinetic_reactant : _chemical_system->kinetic_reactants)
{ {
setReactantMolality(kinetic_reactant, chemical_system_id, solid_phase, setReactantMolality(kinetic_reactant, chemical_system_id, medium, pos,
pos, t); t);
} }
for (auto& equilibrium_reactant : _chemical_system->equilibrium_reactants) for (auto& equilibrium_reactant : _chemical_system->equilibrium_reactants)
{ {
setReactantMolality(equilibrium_reactant, chemical_system_id, setReactantMolality(equilibrium_reactant, chemical_system_id, medium,
solid_phase, pos, t); pos, t);
} }
} }
......
...@@ -59,6 +59,7 @@ enum PropertyType : int ...@@ -59,6 +59,7 @@ enum PropertyType : int
longitudinal_dispersivity, longitudinal_dispersivity,
molality, molality,
molar_mass, molar_mass,
molar_volume,
mole_fraction, mole_fraction,
/// used to compute the hydrodynamic dispersion tensor. /// used to compute the hydrodynamic dispersion tensor.
molecular_diffusion, molecular_diffusion,
...@@ -88,6 +89,7 @@ enum PropertyType : int ...@@ -88,6 +89,7 @@ enum PropertyType : int
transversal_dispersivity, transversal_dispersivity,
vapor_pressure, vapor_pressure,
viscosity, viscosity,
volume_fraction,
number_of_properties number_of_properties
}; };
...@@ -182,7 +184,6 @@ inline PropertyType convertStringToProperty(std::string const& inString) ...@@ -182,7 +184,6 @@ inline PropertyType convertStringToProperty(std::string const& inString)
{ {
return PropertyType::longitudinal_dispersivity; return PropertyType::longitudinal_dispersivity;
} }
// TODO (renchao): add property "volume fraction"
if (boost::iequals(inString, "molality")) if (boost::iequals(inString, "molality"))
{ {
return PropertyType::molality; return PropertyType::molality;
...@@ -191,6 +192,10 @@ inline PropertyType convertStringToProperty(std::string const& inString) ...@@ -191,6 +192,10 @@ inline PropertyType convertStringToProperty(std::string const& inString)
{ {
return PropertyType::molar_mass; return PropertyType::molar_mass;
} }
if (boost::iequals(inString, "molar_volume"))
{
return PropertyType::molar_volume;
}
if (boost::iequals(inString, "mole_fraction")) if (boost::iequals(inString, "mole_fraction"))
{ {
return PropertyType::mole_fraction; return PropertyType::mole_fraction;
...@@ -295,6 +300,10 @@ inline PropertyType convertStringToProperty(std::string const& inString) ...@@ -295,6 +300,10 @@ inline PropertyType convertStringToProperty(std::string const& inString)
{ {
return PropertyType::viscosity; return PropertyType::viscosity;
} }
if (boost::iequals(inString, "volume_fraction"))
{
return PropertyType::volume_fraction;
}
OGS_FATAL( OGS_FATAL(
"The property name '{:s}' does not correspond to any known property", "The property name '{:s}' does not correspond to any known property",
...@@ -328,6 +337,7 @@ static const std::array<std::string, PropertyType::number_of_properties> ...@@ -328,6 +337,7 @@ static const std::array<std::string, PropertyType::number_of_properties>
"longitudinal_dispersivity", "longitudinal_dispersivity",
"molality", "molality",
"molar_mass", "molar_mass",
"molar_volume",
"mole_fraction", "mole_fraction",
"molecular_diffusion", "molecular_diffusion",
"name", "name",
...@@ -353,7 +363,8 @@ static const std::array<std::string, PropertyType::number_of_properties> ...@@ -353,7 +363,8 @@ static const std::array<std::string, PropertyType::number_of_properties>
"transport_porosity", "transport_porosity",
"transversal_dispersivity", "transversal_dispersivity",
"vapor_pressure", "vapor_pressure",
"viscosity"}}; "viscosity",
"volume_fraction"}};
/// This data type is based on a std::array. It can hold pointers to objects of /// This data type is based on a std::array. It can hold pointers to objects of
/// class Property or its inheritors. The size of this array is determined by /// class Property or its inheritors. The size of this array is determined by
......
...@@ -111,9 +111,14 @@ ...@@ -111,9 +111,14 @@
<name>Productd</name> <name>Productd</name>
<properties> <properties>
<property> <property>
<name>molality</name> <name>volume_fraction</name>
<type>Constant</type> <type>Constant</type>
<value>1e-6</value> <value>0.1</value>
</property>
<property>
<name>molar_volume</name>
<type>Constant</type>
<value>1e2</value>
</property> </property>
</properties> </properties>
</component> </component>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment