The mixing flux at a melting front
In this tutorial you compute the chemical mixing flux at the top of a mush, while the cell above it cools from pure melt into the mush. You see that the melt fraction that the flux uses is exactly 1 in pure melt and exactly 0 in pure solid, and that the flux at the top face of the mush changes smoothly.
What you will learn
- How the cell melt fraction
mixing_melt_fractionbehaves near the solidus and the liquidus. - How to set the entropy of each cell from its position between the solidus and the liquidus.
- How to read the mixing flux at each face from the solver state.
What you need
- Aragog installed (see Installation).
- The SPIDER P-S test tables, with
ARAGOG_TEST_EOS_DIRset to their folder (see Build tests): thespider_eosfolder of the release assetspider_eos_test_data.tar.gz(releasetest-data-v1), which the CI uses too. The printed numbers below come from these tables.
1. The cell melt fraction near the phase boundaries
The mixing flux uses the melt fraction of each cell as a function of \(g = (S - S_\mathrm{sol})/(S_\mathrm{liq} - S_\mathrm{sol})\): 0 at the solidus, 1 at the liquidus. We print the fraction and how far it is below 1.
import numpy as np
from aragog.utilities import mixing_melt_fraction
g = np.array([-0.03, -0.015, -0.005, 0.5, 1.005, 1.015, 1.03])
for gi, phi in zip(g, mixing_melt_fraction(g)):
print(f'g = {gi:6.3f}: phi = {phi:.2e}, 1 - phi = {1.0 - phi:.2e}')
The output is
g = -0.030: phi = 0.00e+00, 1 - phi = 1.00e+00
g = -0.015: phi = 8.20e-06, 1 - phi = 1.00e+00
g = -0.005: phi = 4.93e-05, 1 - phi = 1.00e+00
g = 0.500: phi = 5.00e-01, 1 - phi = 5.00e-01
g = 1.005: phi = 1.00e+00, 1 - phi = 4.95e-05
g = 1.015: phi = 1.00e+00, 1 - phi = 8.32e-06
g = 1.030: phi = 1.00e+00, 1 - phi = 0.00e+00
Just above the liquidus the smooth clip keeps the fraction a little below 1, and just below the solidus a little above 0. Between \(g = 1.01\) and \(1.02\) a cubic join takes it to exactly 1, and between \(g = -0.01\) and \(-0.02\) to exactly 0. So 2 cells of pure melt, or 2 cells of pure solid, have the same fraction, and no mixing heat flows between them.
2. Write a configuration with mixing on
The configuration has 20 nodes, so 19 cells, mixing on, and a fixed chemical eddy diffusivity of 1 m\(^2\) s\(^{-1}\) (a negative eddy_diffusivity_chemical sets its magnitude on every node). So \(\kappa_c\) is the same at every face. The flux then changes with the density, the latent heat \(L = T_\mathrm{fus}\,\Delta S_\mathrm{fus}\) and the cell melt fractions, and not with the entropy gradient.
from pathlib import Path
config = """
[solver]
start_time = 0
end_time = 2
atol = 1e-10
rtol = 1e-10
[boundary_conditions]
outer_boundary_condition = 1 # grey-body surface
outer_boundary_value = 1500
inner_boundary_condition = 1 # the core cools through the CMB
inner_boundary_value = 0
emissivity = 1
equilibrium_temperature = 255
core_heat_capacity = 880
core_bc = "quasi_steady"
[mesh]
outer_radius = 6371000
inner_radius = 3480000
number_of_nodes = 20
mixing_length_profile = "nearest_boundary"
core_density = 10500
eos_method = 1
[energy]
conduction = true
convection = true
gravitational_separation = false
mixing = true
eddy_diffusivity_chemical = -1.0 # a fixed kappa_c of 1 m^2/s
radionuclides = false
tidal = false
solver_method = "radau"
use_jax_jacobian = false
[initial_condition]
initial_condition = 1
surface_temperature = 3500
basal_temperature = 3500
[phase_liquid]
density = 4000
viscosity = 10
heat_capacity = 1000
melt_fraction = 1
thermal_conductivity = 4
thermal_expansivity = 3e-5
[phase_solid]
density = 4200
viscosity = 1e21
heat_capacity = 1000
melt_fraction = 0
thermal_conductivity = 4
thermal_expansivity = 3e-5
[phase_mixed]
latent_heat_of_fusion = 4e5
rheological_transition_melt_fraction = 0.4
rheological_transition_width = 0.15
solidus = "solidus.dat"
liquidus = "liquidus.dat"
phase = "mixed"
phase_transition_width = 0.01
grain_size = 1.0e-3
"""
Path('mixing.toml').write_text(config)
3. Cool the cell above a mush
The lower half of the cells is a mush at \(g = 0.5\), the upper half is melt at \(g = 2\). We set \(g\) of the first cell above the mush to 4 values and print the flux at the face below it, and the largest flux at the faces above it. dSdt evaluates the right-hand side at the given entropies and keeps the fluxes in solver.state.
import os
import numpy as np
from aragog.solver import EntropySolver
solver = EntropySolver.from_file(filename='mixing.toml', eos_dir=os.environ['ARAGOG_TEST_EOS_DIR'])
solver.initialize()
eos = solver.entropy_eos
P = np.ravel(solver.state.phase_staggered.pressure) # Pa, at the cells
S_sol, S_liq = np.ravel(eos.solidus_entropy(P)), np.ravel(eos.liquidus_entropy(P))
n = P.size
k = n // 2 # the first cell above the mush; face k lies below it
for g_top in (2.0, 1.5, 1.02, 0.9):
g = np.where(np.arange(n) < k, 0.5, 2.0) # mush below, melt above
g[k] = g_top
solver.dSdt(0.0, S_sol + g * (S_liq - S_sol))
jmix = np.ravel(solver.state.jmix_heat)
print(f'g of cell {k} = {g_top:4.2f}: J_mix at face {k} = {jmix[k]:.3e} W/m^2, '
f'largest |J_mix| above it = {np.abs(jmix[k + 1:]).max():.1e} W/m^2')
The output is
g of cell 9 = 2.00: J_mix at face 9 = -8.161e+05 W/m^2, largest |J_mix| above it = 0.0e+00 W/m^2
g of cell 9 = 1.50: J_mix at face 9 = -8.682e+05 W/m^2, largest |J_mix| above it = 0.0e+00 W/m^2
g of cell 9 = 1.02: J_mix at face 9 = -9.020e+05 W/m^2, largest |J_mix| above it = 0.0e+00 W/m^2
g of cell 9 = 0.90: J_mix at face 9 = -7.287e+05 W/m^2, largest |J_mix| above it = 9.9e+04 W/m^2
The flux at face 9 is downward. From \(g = 2\) to \(g = 1.02\) the difference of the 2 cell melt fractions stays 0.5; the flux grows by 10.5 % because the density at the face rises from 4061 to 4489 kg m\(^{-3}\) as cell 9 cools. The faces above carry no flux while cell 9 is melt. At \(g = 0.9\) cell 9 is mush, and the face above it now has a flux too. These values are about twice those of the first case of the Validation page. This configuration keeps the default refined cell at the core-mantle boundary, cmb_cell_thickness = 3000 m. The mesh then refines toward the core-mantle boundary with the same number of nodes, so the cells near the core are thinner and face 9 lies deeper. It is at 130 GPa, and the centres of its 2 cells are 108 km apart. The mesh of the Validation test has no refined cell (its cells are equal in mass coordinate), with face 9 at 76 GPa and the cell centres 151 km apart.
Where next
- Chemical mixing of melt fraction explains the flux and why it uses the cell melt fractions.
- Mixing flux shows the checks of the flux against the exact answer.