Combining phase change with passive tracers in a simulation?

Hello,

I am using version 2.6.0 of ASPECT and am trying to include passive tracers in the christensen_yuen_phase_function cookbook. I tried to copy and paste the additional block of definitions from the passive case example to the christensen_yuen_phase_function.prm file but could not run the code. Looking at the log file, it gives the following message:

An error occurred in line <365> of file </home/lim-kangwei/aspect/source/material_model/latent_heat.cc> in function
void aspect::MaterialModel::LatentHeat::parse_parameters(dealii::ParameterHandler&) [with int dim = 2]
Additional information:
Error: At least one list that provides input parameters for phase
transitions has the wrong size. The phase function object reports that
there are 3 transitions, therefore the material model expects 3
density jumps and corresponding phases, and 4 viscosity prefactors.

Stacktrace:

#0 …/…/build/aspect: aspect::MaterialModel::LatentHeat<2>::parse_parameters(dealii::ParameterHandler&)
#1 …/…/build/aspect: aspect::Simulator<2>::Simulator(ompi_communicator_t*, dealii::ParameterHandler&)
#2 …/…/build/aspect: void run_simulator<2>(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool, bool, bool, bool)
#3 …/…/build/aspect: main

Aborting!

Has anyone encountered this issue before and found ways to solve it (or understood what is happening)?

Thanks!

The error message is “the material model expects 3
density jumps and corresponding phases, and 4 viscosity prefactors.”

How many density jumps, phases, and prefactors are you providing?

There is only one phase transition in the model as I have not modified anything from the christensen_yuen_phase_function cookbook. I only added the “Compositional fields” and “Initial composition model” in the prm file to create some passive tracers just like in the manual

Can you post your prm file?

This is a setup for convection in a 2D box with a phase transition

in the center, and corresponds to the setup of the Boussinesq cases

in Christensen & Yuen 1985.

set Dimension = 2
set End time = 2e8
set Output directory = christensen_yuen

We use a nonlinear solver to make sure any nonlinearity that may be

associated with the phase transition is resolved, and we use a large

value for the Maximum nonlinear iterations to make it obvious if the

nonlinear solver does not converge. Usually, the nonlinear solver

should converge within 1-5 iterations.

set Nonlinear solver scheme = iterated Advection and Stokes
set Max nonlinear iterations = 500
set Maximum time step = 1e5
set Adiabatic surface temperature = 500

subsection Solver parameters
subsection Stokes solver parameters
set Stokes solver type = block GMG
end
end

This model assumes the Boussinesq approximation, so it is

incompressible and has a constant reference density.

subsection Formulation
set Formulation = Boussinesq approximation
end

For the Boussinesq approximation, all heating terms are switched off.

subsection Heating model
set List of model names =
end

The model domain is a quadratic box.

subsection Geometry model
set Model name = box

subsection Box
set X extent = 1350000
set Y extent = 1350000
end
end

Set the reference profile.

The temperature on the reference profile is 500 K, halfway between the

top temperature of 0 K and the bottom temperature of 1000 K.

subsection Adiabatic conditions model
set Model name = function

subsection Function
set Function constants = density=1000
set Function expression = 500; density10depth; density
set Variable names = depth
end
end

This is the new part: We declare that there will

be two compositional fields that will be

advected along. Their initial conditions are given by

a function that is one for the lowermost 0.2 height

units of the domain and zero otherwise in the first case,

and one in the top most 0.2 height units in the latter.

subsection Compositional fields

set Number of fields = 1

end

subsection Initial composition model

set Model name = function

subsection Function

set Variable names = x,y

set Function expression = if(y<270000, 1, 0)

end

end

This temperature initial condition resembles the one on Christensen & Yuen, 1985.

It has conductive boundary layers at the top and bottom, and sinusoidal

temperature perturbations.

subsection Initial temperature model
set Model name = function

subsection Function
set Function constants = delta=0.1, A=10, h=1350000, pi=3.1416
set Variable names = x,z
set Function expression = 500 + 500*(erfc(z/(hdelta)) - erfc((1-z/h)/delta)) + Acos(pix/h)sin(piz/h) + Acos(2pix/h)sin(piz/h) + Acos(pix/h)sin(2piz/h) + Acos(2pix/h)sin(2pi*z/h)
end
end

subsection Boundary temperature model
set Fixed temperature boundary indicators = top, bottom
set List of model names = box

subsection Box
set Top temperature = 0
set Bottom temperature = 1000
end
end

subsection Boundary velocity model
set Tangential velocity boundary indicators = top, bottom, left, right
end

subsection Gravity model
set Model name = vertical

subsection Vertical
set Magnitude = 10
end
end

This material model uses phase functions.

The model in Christensen & Yuen is nondimensional, but we want to keep

Earth-like parameters. To achieve this, we set all material

properties to multiples of 10, and then control the three important

model parameters by setting:

k = 2.460375e7 / Ra, to control the Rayleigh number,

deltarho = 2 alpha rho DeltaT = 200 kg/m3, to achieve Rb = 2Ra, as in Christensen & Yuen,

gamma = P * Ra/Rb * rho g h / DeltaT = P/2 * 1.35e7 Pa/K, to set the phase buoyancy parameter.

(for a more detailed explanation, see the corresponding cookbook description in the manual).

subsection Material model
set Model name = latent heat
set Material averaging = harmonic average only viscosity

subsection Latent heat
# All parameters in the equation of state are constant, and the mode is incompressible.
set Reference temperature = 500
set Reference density = 1000
set Reference specific heat = 1000
set Thermal expansion coefficient = 1e-4
set Compressibility = 0
set Thermal conductivity = 246.03750 # k = 2.460375e7/Ra, corresponds to Ra = 1e5

# There is one phase transition in the center of the box (at a depth of 675 km),
# with a width of 67.5 km (5% of the box height).
# It occurs at that depth if the temperature corresponds to the reference temperature (500 K);
# for different temperatures the depth changes according to the Clapeyron slope (-2.7 MPa/K).
# At the phase transition, the density increases from its reference value of 1000 kg/m^3 to
# 1200 kg/m^3.
set Define transition by depth instead of pressure = true
set Phase transition depths                        = 675000
set Phase transition widths                        = 67500
set Phase transition temperatures                  = 500
set Phase transition Clapeyron slopes              = -2700000        # gamma = P * Ra/Rb, corresponds to P = -0.4
set Phase transition density jumps                 = 200             # deltarho = 2 alpha rho DeltaT (Rb = 2Ra)
set Corresponding phase for density jump           = 0

# The viscosity is constant
set Viscosity                                      = 1e20
set Minimum viscosity                              = 1e20
set Maximum viscosity                              = 1e20
set Viscosity prefactors                           = 1,1
set Thermal viscosity exponent                     = 0.0

end
end

subsection Mesh refinement
set Initial global refinement = 6
set Initial adaptive refinement = 0
set Time steps between mesh refinement = 0
end

Stop the model run when a steady state heat flux is reached.

Some of the models do not reach steady state and will continue

until the end time is reached.

subsection Termination criteria
set Termination criteria = end time, steady state heat flux

subsection Steady state heat flux
set Maximum relative deviation = 0.005
set Time in steady state = 1e7
set Boundary indicators = top
end
end

subsection Postprocess
set List of postprocessors = velocity statistics, temperature statistics, heat flux statistics, heating statistics, composition statistics, visualization

subsection Visualization
set Time between graphical output = 1e5
set List of output variables = material properties, adiabat, strain rate

subsection Material properties
  set List of material properties = viscosity, density
end

end
end

This is the new part: We declare that there will

be two compositional fields that will be

advected along. Their initial conditions are given by

a function that is one for the lowermost 0.2 height

units of the domain and zero otherwise in the first case,

and one in the top most 0.2 height units in the latter.

subsection Compositional fields
set Number of fields = 2
end

subsection Initial composition model
set Model name = function

subsection Function
set Variable names = x,y
set Function expression = if(y<270000, 1, 0) ; if(y>1080000, 1, 0)
end
end

subsection Material model
subsection Latent heat
set Thermal conductivity = 246.03750
set Phase transition Clapeyron slopes = -2700000.00000
end
end
set Output directory = Ra100000_P-0.4_tracers

Unfortunately, the Latent Heat material model is not currently implemented to deal with compositional fields that don’t correspond to different materials. From the manual description of the material model:

A material model that includes phase transitions and the possibility that latent heat is released or absorbed when material crosses one of the phase transitions of up to two different materials (compositional fields).

Your prm instantiates three compositional fields (the background field and two more explicit fields), and these are treated by the material model as distinct materials, rather than passive tracers. We should add an Assert in the code that provides a better exception message - the one you report is correct but misleading in your case.

There are at least a couple of things that would need to change in the code to get your prm to work.

  1. This line would have to be changed to use this->introspection().chemical_composition_field_names():
  2. The latent heat material model would have to be modified to remove the hard-coded assumption that if in.composition[i][0] exists, it corresponds to the volume fraction of a chemical composition. (e.g. this line). The most efficient to do this would be to get the indices for the chemical compositional fields in parse_parameters (perhaps using this->introspection().composition_indices_for_type()), assert that there are either 0 or 1 of those fields, store the index if there is 1 field, and then use that index in evaluate.

You would also have to modify your prm file, adding the line set Types of fields = generic, generic, so that ASPECT doesn’t assume that these compositional fields are chemical compositions.

Would you be willing to make a PR with these changes? We’re happy to help. If not, you’ll have to give us a bit of time to modify the code.

Bob