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

Merge branch 'TH2M_PTM_generalized_ptm_initialisation' into 'master'

TH2M PTM generalized initialisation for phase transition models

See merge request ogs/ogs!3770
parents 6eded9bf bce5b83d
No related branches found
No related tags found
No related merge requests found
......@@ -11,63 +11,6 @@
#include "MaterialLib/PhysicalConstant.h"
namespace
{
int numberOfGasComponents(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
// It is always the first (begin) medium that holds fluid phases.
auto const medium = media.begin()->second;
auto const& gas_phase = medium->phase("Gas");
int const n_components_gas = gas_phase.numberOfComponents();
if (n_components_gas > 2)
{
OGS_FATAL(
"More than two gas phase components are defined. Gaseous mixtures "
"of more than two components are currently not provided.");
}
if (n_components_gas < 2)
{
OGS_FATAL(
"MPL::PhaseTransitionEvaporation() requires at least two "
"components in the gas phase.");
}
return n_components_gas;
}
int findVapourComponentIndex(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
// It is always the first (begin) medium that holds fluid phases.
auto const medium = media.begin()->second;
auto const& gas_phase = medium->phase("Gas");
int const n_components_gas = gas_phase.numberOfComponents();
// find the component for which the property 'vapour pressure' is defined,
// using it as the evaporating component.
for (int c = 0; c < n_components_gas; c++)
{
if (gas_phase.component(c).hasProperty(
MaterialPropertyLib::PropertyType::vapour_pressure))
{
return c;
}
}
// A lot of checks can (and should) be done to make sure that the right
// components with the right properties are used. For example, the names of
// the components can be compared to check that the name of the evaporable
// component does not also correspond to the name of the solvate.
OGS_FATAL(
"MPL::PhaseTransitionEvaporation(); none of the gas phase components "
"has a required property vapour_pressure.");
}
} // namespace
namespace ProcessLib
{
namespace TH2M
......@@ -75,13 +18,22 @@ namespace TH2M
PhaseTransitionEvaporation::PhaseTransitionEvaporation(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
: PhaseTransitionModel(media),
n_components_gas_{numberOfGasComponents(media)},
gas_phase_vapour_component_index_{findVapourComponentIndex(media)},
n_components_gas_{numberOfComponents(media, "Gas")},
gas_phase_vapour_component_index_{findComponentIndex(
media, "Gas", MaterialPropertyLib::PropertyType::vapour_pressure)},
// dry air component is complement of vapour component index
gas_phase_dry_air_component_index_{gas_phase_vapour_component_index_ ^ 1}
{
DBUG("Create PhaseTransitionEvaporation constitutive model.");
if (n_components_gas_ != 2)
{
OGS_FATAL(
"The current implementation of PhaseTransitionModelEvaporation "
"requires the specification of exactly two components in the gas "
"phase.");
}
// It is always the first (begin) medium that holds fluid phases.
auto const medium = media.begin()->second;
auto const& gas_phase = medium->phase("Gas");
......
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#include "PhaseTransitionModel.h"
namespace ProcessLib
{
namespace TH2M
{
int numberOfComponents(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
std::string phase_name)
{
// Always the first (begin) medium that holds fluid phases.
auto const medium = media.begin()->second;
return medium->phase(phase_name).numberOfComponents();
}
int findComponentIndex(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
std::string phase_name, MaterialPropertyLib::PropertyType property_type)
{
// It is always the first (begin) medium that holds fluid phases.
auto const medium = media.begin()->second;
auto const& phase = medium->phase(phase_name);
// find the component for which the property 'property_type' is defined
for (std::size_t c = 0; c < phase.numberOfComponents(); c++)
{
if (phase.component(c).hasProperty(property_type))
{
return c;
}
}
// A lot of checks can (and should) be done to make sure that the right
// components with the right properties are used. For example, the names
// of the components can be compared to check that the name of the
// evaporable component does not also correspond to the name of the
// solvate.
OGS_FATAL(
"PhaseTransitionModel::findComponentIndex could not find the "
"specified property type in the phase.");
}
} // namespace TH2M
} // namespace ProcessLib
\ No newline at end of file
......@@ -122,5 +122,13 @@ struct PhaseTransitionModel
PhaseTransitionModelVariables cv;
};
int numberOfComponents(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
std::string phase_name);
int findComponentIndex(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
std::string phase_name, MaterialPropertyLib::PropertyType property_type);
} // namespace TH2M
} // namespace ProcessLib
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