Skip to content

Commit

Permalink
Add new scaling parameters for the Cahn-Hilliard model (chaos-polymtl…
Browse files Browse the repository at this point in the history
…#1274)

Description

With new models come new parameters that need to be dimensionalised adequately when changing the units in the "Dimensionality" section of the parameter file. With the Cahn-Hilliard model, it was the mobility coefficient, the interface thickness and the surface tension. Three new scalings were added at first, for those three parameters. Since surface tension is also used in VOF model, a fourth scaling parameter was added for the surface tension gradient for completion.

There was a mistake in the scaling of thermal expansion which was corrected.

Testing

No testing because it would imply coding an output for the physical properties which is unnecessary. It works fine.
  • Loading branch information
PierreLaurentinCS authored Sep 20, 2024
1 parent 220ecee commit 46511be
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to the Lethe project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master] - 2024-09-20

### Added

- MINOR Added dimensionality for the mobility and interface thickness in the CHNS solver, and surface tension related parameters in the VOF solver. [#1274](https://github.com/chaos-polymtl/lethe/pull/1274)

## [Master] - 2024-09-12

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions include/core/dimensionality.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ namespace Parameters
double enthalpy_scaling;
double diffusivity_scaling;
double thermal_expansion_scaling;
double surface_tension_scaling;
double surface_tension_gradient_scaling;
double cahn_hilliard_mobility_scaling;
double cahn_hilliard_epsilon_scaling;
};
} // namespace Parameters

Expand Down
54 changes: 51 additions & 3 deletions include/core/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,24 @@ namespace Parameters
// Liquidus temperature - Units in K
double T_liquidus;

/**
* @brief Declare the parameters.
*
* @param[in,out] prm The ParameterHandler.
*/
void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
/**
* @brief Parse the parameters.
*
* @param[in,out] prm The ParameterHandler.
*
* @param[in] dimensions The Dimensionality object controling the
* fundamental dimensions (length, time, mass, temperature) of the problem.
*/
parse_parameters(ParameterHandler &prm,
const Parameters::Dimensionality dimensions);
};

/**
Expand All @@ -365,10 +379,25 @@ namespace Parameters
// Mobility constant (M) in m^2/s
double mobility_cahn_hilliard_constant;

/**
* @brief Declare the parameters.
*
* @param[in,out] prm The ParameterHandler.
*/
void
declare_parameters(ParameterHandler &prm);

/**
* @brief Parse the parameters.
*
* @param[in,out] prm The ParameterHandler.
*
* @param[in] dimensions The Dimensionality object controling the
* fundamental dimensions (length, time, mass, temperature) of the problem.
*/
void
parse_parameters(ParameterHandler &prm);
parse_parameters(ParameterHandler &prm,
const Parameters::Dimensionality dimensions);
};


Expand Down Expand Up @@ -498,11 +527,30 @@ namespace Parameters
std::pair<std::pair<unsigned int, unsigned int>, unsigned int>
fluid_solid_interaction_with_material_interaction_id;

/**
* @brief Declare the parameters.
*
* @param[in,out] prm The ParameterHandler.
*
* @param[in] id The material id.
*/
void
declare_parameters(ParameterHandler &prm, unsigned int id);

/**
* @brief Parse the parameters.
*
* @param[in,out] prm The ParameterHandler.
*
* @param[in] id The material id.
*
* @param[in] dimensions The Dimensionality object controling the
* fundamental dimensions (length, time, mass, temperature) of the problem.
*/
void
parse_parameters(ParameterHandler &prm, const unsigned int id);
parse_parameters(ParameterHandler &prm,
const unsigned int id,
const Parameters::Dimensionality dimensions);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions include/core/parameters_multiphysics.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace Parameters
void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
parse_parameters(ParameterHandler &prm, const Dimensionality dimensions);
};

/**
Expand All @@ -242,7 +242,7 @@ namespace Parameters
void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
parse_parameters(ParameterHandler &prm, const Dimensionality dimensions);
};
} // namespace Parameters
#endif
3 changes: 1 addition & 2 deletions include/solvers/simulation_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class SimulationParameters
mesh_box_refinement->parse_parameters(prm);
nitsche->parse_parameters(prm);
physical_properties.parse_parameters(prm, dimensionality);
multiphysics.parse_parameters(prm);
multiphysics.parse_parameters(prm, dimensionality);
timer.parse_parameters(prm);
fem_parameters.parse_parameters(prm);
laser_parameters->parse_parameters(prm);
Expand All @@ -182,7 +182,6 @@ class SimulationParameters
simulation_control.parse_parameters(prm);
velocity_sources.parse_parameters(prm);
particlesParameters->parse_parameters(prm);
multiphysics.parse_parameters(prm);
constrain_solid_domain.parse_parameters(prm);
stabilization.parse_parameters(prm);
ale.parse_parameters(prm);
Expand Down
20 changes: 12 additions & 8 deletions source/core/dimensionality.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ namespace Parameters
const double theta = temperature;
const double T = time;

density_scaling = 1. * L * L * L / M;
specific_gas_constant_scaling = 1. / L / L * T * T * theta;
viscosity_scaling = 1. / L / L * T;
specific_heat_scaling = 1. / L / L * T * T * theta;
thermal_conductivity_scaling = 1. / M / L * T * T * T * theta;
enthalpy_scaling = 1. / M / L / L * T * T;
diffusivity_scaling = 1. / L / L * T;
thermal_expansion_scaling = T;
density_scaling = 1. * L * L * L / M;
specific_gas_constant_scaling = 1. / L / L * T * T * theta;
viscosity_scaling = 1. / L / L * T;
specific_heat_scaling = 1. / L / L * T * T * theta;
thermal_conductivity_scaling = 1. / M / L * T * T * T * theta;
enthalpy_scaling = 1. / M / L / L * T * T;
diffusivity_scaling = 1. / L / L * T;
thermal_expansion_scaling = 1. * theta;
surface_tension_scaling = 1. * T * T / M;
surface_tension_gradient_scaling = 1. * theta * T * T / M;
cahn_hilliard_mobility_scaling = 1. * M / L / L / L / T;
cahn_hilliard_epsilon_scaling = 1. / L;
}

void
Expand Down
42 changes: 26 additions & 16 deletions source/core/parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,21 @@ namespace Parameters
}

void
SurfaceTensionParameters::parse_parameters(ParameterHandler &prm)
SurfaceTensionParameters::parse_parameters(
ParameterHandler &prm,
const Parameters::Dimensionality dimensions)
{
surface_tension_coefficient = prm.get_double("surface tension coefficient");
T_0 = prm.get_double("reference state temperature");
surface_tension_coefficient *= dimensions.surface_tension_scaling;
T_0 = prm.get_double("reference state temperature");
T_0 *= 1. / dimensions.temperature;
surface_tension_gradient =
prm.get_double("temperature-driven surface tension gradient");
T_solidus = prm.get_double("solidus temperature");
surface_tension_gradient *= dimensions.surface_tension_gradient_scaling;
T_solidus = prm.get_double("solidus temperature");
T_solidus *= 1. / dimensions.temperature;
T_liquidus = prm.get_double("liquidus temperature");

T_liquidus *= 1. / dimensions.temperature;
Assert(T_liquidus > T_solidus,
PhaseChangeIntervalError(T_liquidus, T_solidus));
}
Expand All @@ -539,10 +545,14 @@ namespace Parameters
}

void
MobilityCahnHilliardParameters::parse_parameters(ParameterHandler &prm)
MobilityCahnHilliardParameters::parse_parameters(
ParameterHandler &prm,
const Parameters::Dimensionality dimensions)
{
mobility_cahn_hilliard_constant =
prm.get_double("cahn hilliard mobility constant");
mobility_cahn_hilliard_constant *=
dimensions.cahn_hilliard_mobility_scaling;
}

template <int dim>
Expand Down Expand Up @@ -962,7 +972,7 @@ namespace Parameters
++i_material_interaction)
{
material_interactions[i_material_interaction].parse_parameters(
prm, i_material_interaction);
prm, i_material_interaction, dimensions);
if (material_interactions[i_material_interaction]
.material_interaction_type ==
MaterialInteractions::MaterialInteractionsType::fluid_fluid)
Expand Down Expand Up @@ -1304,7 +1314,10 @@ namespace Parameters
}

void
MaterialInteractions::parse_parameters(ParameterHandler &prm, unsigned int id)
MaterialInteractions::parse_parameters(
ParameterHandler &prm,
unsigned int id,
const Parameters::Dimensionality dimensions)
{
prm.enter_subsection("material interaction " +
Utilities::int_to_string(id, 1));
Expand Down Expand Up @@ -1339,39 +1352,36 @@ namespace Parameters
if (op == "constant")
{
surface_tension_model = SurfaceTensionModel::constant;
surface_tension_parameters.parse_parameters(prm);
}
else if (op == "linear")
{
surface_tension_model = SurfaceTensionModel::linear;
surface_tension_parameters.parse_parameters(prm);
}
else if (op == "phase change")
{
surface_tension_model = SurfaceTensionModel::phase_change;
surface_tension_parameters.parse_parameters(prm);
}
else
throw(std::runtime_error(
"Invalid surface tension model. The choices are <constant|linear|phase change>."));

surface_tension_parameters.parse_parameters(prm, dimensions);
// Cahn-Hilliard mobility
op = prm.get("cahn hilliard mobility model");
if (op == "constant")
{
mobility_cahn_hilliard_model =
MobilityCahnHilliardModel::constant;
mobility_cahn_hilliard_parameters.parse_parameters(prm);
}
else if (op == "quartic")
{
mobility_cahn_hilliard_model =
MobilityCahnHilliardModel::quartic;
mobility_cahn_hilliard_parameters.parse_parameters(prm);
}
else
throw(std::runtime_error(
"Invalid mobility model. The choices are <constant|quartic>."));

mobility_cahn_hilliard_parameters.parse_parameters(prm, dimensions);
}
prm.leave_subsection();
}
Expand All @@ -1390,17 +1400,17 @@ namespace Parameters
if (op == "constant")
{
surface_tension_model = SurfaceTensionModel::constant;
surface_tension_parameters.parse_parameters(prm);
surface_tension_parameters.parse_parameters(prm, dimensions);
}
else if (op == "linear")
{
surface_tension_model = SurfaceTensionModel::linear;
surface_tension_parameters.parse_parameters(prm);
surface_tension_parameters.parse_parameters(prm, dimensions);
}
else if (op == "phase change")
{
surface_tension_model = SurfaceTensionModel::phase_change;
surface_tension_parameters.parse_parameters(prm);
surface_tension_parameters.parse_parameters(prm, dimensions);
}
else
throw(std::runtime_error(
Expand Down
9 changes: 6 additions & 3 deletions source/core/parameters_multiphysics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Parameters::Multiphysics::declare_parameters(ParameterHandler &prm)
}

void
Parameters::Multiphysics::parse_parameters(ParameterHandler &prm)
Parameters::Multiphysics::parse_parameters(ParameterHandler &prm,
const Dimensionality dimensions)
{
prm.enter_subsection("multiphysics");
{
Expand All @@ -89,7 +90,7 @@ Parameters::Multiphysics::parse_parameters(ParameterHandler &prm)
}
prm.leave_subsection();
vof_parameters.parse_parameters(prm);
cahn_hilliard_parameters.parse_parameters(prm);
cahn_hilliard_parameters.parse_parameters(prm, dimensions);
}

void
Expand Down Expand Up @@ -525,7 +526,8 @@ Parameters::CahnHilliard::declare_parameters(ParameterHandler &prm)
}

void
Parameters::CahnHilliard::parse_parameters(ParameterHandler &prm)
Parameters::CahnHilliard::parse_parameters(ParameterHandler &prm,
const Dimensionality dimensions)
{
prm.enter_subsection("cahn hilliard");
{
Expand All @@ -552,6 +554,7 @@ Parameters::CahnHilliard::parse_parameters(ParameterHandler &prm)
"Options are 'automatic' or 'manual'."));

epsilon = prm.get_double("value");
epsilon *= dimensions.cahn_hilliard_epsilon_scaling;
}
prm.leave_subsection();
}
Expand Down

0 comments on commit 46511be

Please sign in to comment.