Modelling phase changes between a solid and liquid phase is possible with code_saturne. Historically, this module has been developped for modelling the solidification process, hence the name "solidification" module. Nevertheless, the melting of a solid is also possible.
The solidification module described in this page relies on CDO schemes and especially, CDO face-based schemes.
To set-up a computation taking into account the solidification process, one has to update the cs_user_parameters.c user source file and edit at least the user-defined functions cs_user_model and cs_user_finalize_setup in simple cases. In more complex cases, editing the function cs_user_parameters and defining functions to describe the boundary conditions or the material properties should be necessary.
Several models are available according to the type of phenomena at stake. Here are listed the available solidification models (first parameter of the function cs_solidification_activate):
Besides the main solidification model, one can specify several modelling options. Be aware that some options are only relevant when a given model is set. Here are listed the available options (second parameter of the function cs_solidification_activate):
Here are listed the available quantities which can be automatically post-processed (third parameter of the function cs_solidification_activate):
The following options make sense only when the CS_SOLIDIFICATION_MODEL_BINARY_ALLOY is activated
The first step when settings a solidification model relying on CDO schemes is to set the CDO mode to CS_PARAM_CDO_MODE_ONLY
This is done at the begining of the function cs_user_model.
Then, the second step is to add a call to the function cs_solidification_activate in order to activate the CDO solidification module. There are eight parameters to set :
Here are several examples of activation of the CDO solidification module according to the model and its related options.
Ex. 1 The first example describes how to set a "binary alloy" model with several related options.
Ex. 2 The second example describes how to set a "Voller" model with several related options.
Ex. 3 The third example describes how to set a "Voller" model without a velocity field in the "liquid" area.
Excepted for the Stefan model, it is possible to change the strategy to update quantities such as the way to compute the new thermal source term. There are three strategies available (cs_solidification_strategy_t for more details). The default strategy is CS_SOLIDIFICATION_STRATEGY_LEGACY
Here is an example to set the strategy:
The Stefan model handles the solidification process with the approximation that the liquidus and solidus temperature are the same. Thus, the transition from the solid to liquid or from the liquid to solid is rough.
The main function to set a Voller and Prakash model is cs_solidification_set_voller_model (follow the link to get a description of the parameters). This function is mandatory and has to be located in cs_user_model after calling cs_solidification_activate
Please notice that a simplified version of the function exists in case of purely thermal model (activated when the flag CS_SOLIDIFICATION_NO_VELOCITY_FIELD has been set).
The setting of the non-linear variant of the Voller and Prakash model relies on the main function as the linear one (i.e. cs_solidification_set_voller_model or cs_solidification_set_voller_model_no_velocity in a more specific situation).
To access more settings, it is possible to retrieve the structure managing the voller model and to specify advanced parameter settings in order to set the non-linear iterative algorithm for instance.
The main function to set a binary alloy model is cs_solidification_set_binary_alloy_model (follow the link to get a description of the parameters). This function is mandatory and has to be located inside cs_user_model after calling cs_solidification_activate
To access more settings, it is possible to retrieve the structure managing the binary alloy model and to specify advanced parameter settings.
The creation of all properties used the solidification model is made automatically. The definition is then performed in the function cs_user_finalize_setup
In simple cases, the main properties are constant (uniform and steady-state) and the definition is thus simply done in the example below. Please notice that predefined properties have a macro to store their name. Here are used:
CS_PROPERTY_MASS_DENSITY for the (volumetric) mass density which corresponds to the property named "mass_density" (this is different from the legacy Finite Volume where "density" is used);
CS_NAVSTO_LAM_VISCOSITY for the laminar (dynamic) viscosity which corresponds to the property named "laminar_viscosity";
CS_THERMAL_CP_NAME for the thermal capacity which corresponds to the property named "thermal_capacity";
CS_THERMAL_LAMBDA_NAME for the thermal conductivity which corresponds to the property named "thermal_conductivity".
snippet cs_user_parameters-cdo-solidification.cpp param_cdo_solidification_properties
The last step is to set the initial condition and the boundary conditions. By default, all variable fields are initially set to zero. For the boundary conditions, if nothing is set, then the default boundary condition is applied. For the thermal equation, the default boundary condition is a no flux (i.e. a homogeneous Neumann boundary condition).
When a solute transport equation is added (this done automatically when calling the function cs_solidification_set_binary_alloy_model), the default boundary condition for this equation is a no flux condition as well.
Here is an example how to set the initial solute concentration in the domain.
For the Navier-Stokes equation, the default boundary condition is defined when the domain boundaries are defined in the function cs_user_model using the function cs_boundary_set_default There are two possibilities:
A more detailed description of the model and a comparison between the Finite Volume and CDO approaches is available here