Mixing flux
What this page checks
This page checks the chemical mixing flux: the latent heat that convection moves when it mixes parcels with different melt fractions in a mush (Chemical mixing of melt fraction). Validation here means that we run the code on a state where we know the right answer and check that the code gives that answer. If this part were wrong, the flux could switch on and off at the top of a freezing mush, or heat could flow between cells of pure melt or of pure solid. The magma ocean would then freeze at the wrong rate, and the surface temperature of a PROTEUS run could change in steps. Each case below says why the check exists, what it tests, how we know the right answer and why it matters; then it shows a plot and the test details.
Symbols and terms
- \(g = (S - S_\mathrm{sol})/(S_\mathrm{liq} - S_\mathrm{sol})\) is the position of the entropy \(S\) of a cell between the solidus entropy \(S_\mathrm{sol}\) and the liquidus entropy \(S_\mathrm{liq}\) at its pressure. \(g < 0\) is solid, \(0 \le g \le 1\) is mush, \(g > 1\) is melt.
- \(\phi\) is the cell melt fraction that the mixing flux uses: \(g\) smoothly clipped to \([0, 1]\), exactly 0 for \(g \le -0.02\) and exactly 1 for \(g \ge 1.02\).
- \(J_\mathrm{mix}\) is the mixing heat flux at a face between 2 cells, in W m\(^{-2}\); negative is downward.
- The bracket form is the SPIDER form of the same flux (
GetMixingHeatFluxin SPIDER; SPIDER comparison gives the file and lines), which takes \(\phi\) at the face and multiplies the flux by a tanh weight of the face value of \(g\). Each test computes it on the same state with a Python transcription of that form (_bracket_jmixintests/test_mixing_production_front.py), as the case to compare with; SPIDER itself does not run. - All cases use the SPIDER test tables. The first 3 cases use a fixed chemical eddy diffusivity \(\kappa_c = 1\) m\(^2\) s\(^{-1}\); the flux then depends on the state through \(\rho\), \(T_\mathrm{fus}\,\Delta S_\mathrm{fus}\) and the cell melt fractions. The last case uses the mixing-length \(\kappa_c\) of a run (
eddy_diffusivity_chemical= 1), which also depends on the entropy gradient.
No step in the flux while the cell above a mush melts out
Why this check exists. If the flux at the top face of a mush depended on a switch at the face, it would jump while the cell above is still melt. A run could then freeze the mush one cell at a time, with a step in the heat flow at each cell.
What it tests. The lower half of a 19-cell column is mush at \(g = 0.5\) and the cells above the middle are melt at \(g = 2\). The cell just above the mush cools from \(g = 2\) to \(g = 0.8\) in 600 steps. At each step the test takes \(J_\mathrm{mix}\) at the face below that cell. Eq. 9 gives \(J_\mathrm{mix} = -U\,(\phi_\mathrm{above} - \phi_\mathrm{below})\) there, with \(U = \kappa_c\,\rho\,L\,(\mathrm{d}\xi/\mathrm{d}r)/\Delta\xi\), \(L\) the latent heat, \(\xi\) the mass coordinate of the mesh and \(\Delta\xi\) the spacing of the 2 cell centres in \(\xi\). The test checks 3 things:
- \(J_\mathrm{mix}/U\) stays between \(-0.501\) and \(-0.299\): the melt fraction difference of the 2 cells goes from 0.5 to 0.3.
- Each step of the flux stays below \(U\,\Delta g + |J_\mathrm{mix}|\,|\Delta\rho|/\rho\), with \(\Delta g\) and \(\Delta\rho\) the changes of \(g\) and of the face density in one step. The first term is \(U\) times \(\Delta g\), because the cell melt fraction never changes faster than \(g\) (its slope is at most 1, which
tests/test_mixing_melt_fraction.pyasserts). The second is the density term. - While the cell is still melt (\(g \ge 1.02\)) its melt fraction is exactly 1, so only the density term may change the flux.
How we know the right answer. Eq. 9 of Bower et al. (2018)1 gives a flux that follows the melt fraction of the cells, and that fraction changes smoothly with \(g\). So the face flux must change smoothly too. At the start the 2 cells differ in melt fraction by 0.5. At the face, at 76 GPa, \(\rho = 3401\) kg m\(^{-3}\) and \(L = 3.727 \times 10^7\) J kg\(^{-1}\), with \(\kappa_c = 1\) m\(^2\) s\(^{-1}\); the cell centres are 152 km apart in \(\xi\) and 151 km in radius (\(\mathrm{d}\xi/\mathrm{d}r = 1.006\)). So Eq. 9 gives \(J_\mathrm{mix} = -0.5\,U = -4.19 \times 10^5\) W m\(^{-2}\), as the code does; when the cell above reaches \(g = 0.8\) the difference is 0.3. The bracket form on the same states shows what a weight at the face does.
Why it matters. The face between the top mush cell and the melt above it sets how fast the top of a freezing magma ocean loses latent heat.
How to read the plot. The x axis is \(g\) of the cell above the mush; it falls to the right, as the cell cools. The y axis is \(J_\mathrm{mix}\) at the face below that cell, in units of \(10^5\) W m\(^{-2}\). The solid line is the code; the dashed line is the bracket form. The vertical line marks \(g = 1\). The dashed line is 0 at first and falls to \(-8.9 \times 10^5\) W m\(^{-2}\) between \(g = 1.64\) and \(1.46\), while the cell above is still melt: the tanh weight at the face turns the flux on before the melt fraction of that cell changes. Its largest change in one step is 24 times the bound of the test. A pass is a solid line that changes only as the cell melt fractions and the density do.
Test details
- Reference: continuity of Bower et al. (2018) Eq. 9 with the cell melt fractions; the bracket form on the same states for comparison.
- Tolerance: every step below \(U\,\Delta g + |J_\mathrm{mix}|\,|\Delta\rho|/\rho\) plus \(10^{-9}\,|J_\mathrm{mix}|\) for rounding (largest ratio of a step to the bound 0.937, at \(g = 0.8\); largest step 1938 W m⁻²; \(U\) from 8.38 × 10⁵ to 1.00 × 10⁶ W m⁻²); while the cell is melt, every step below the density term alone (largest step 197 W m⁻², equal to the density term to 2 × 10⁻¹⁰ W m⁻²); \(J_\mathrm{mix}/U\) between −0.501 and −0.299, the melt-fraction differences of the 2 end states (measured −0.500 to −0.300).
- Discrimination: the bracket form is 0 at \(g = 2\) and reaches −8.86 × 10⁵ W m⁻²; its largest step while the cell is melt is 4.56 × 10⁴ W m⁻², 24 times the bound; the test asserts more than 10 times.
- Test id:
tests/test_mixing_face_flux_validation.py::test_the_front_face_flux_has_no_step_while_the_cell_above_melts_out - Command:
pytest tests/test_mixing_face_flux_validation.py -k front_face(add--validation-plotsto write the plot pair)
Second-order accuracy inside a mush
Why this check exists. A wrong stencil for \(\partial\phi/\partial r\), for example a gradient taken one cell off the face, still gives a flux of the right size. It only shows as a slower fall of the error when the cells get smaller.
What it tests. A mush column with \(g = 0.5 + 0.25 \sin(\pi x)\), with \(x\) the fraction of the way from the core-mantle boundary to the surface, on meshes of 20, 40, 80 and 160 nodes (19, 39, 79 and 159 cells). The test takes the largest error of \(J_\mathrm{mix}\) over the interior faces, divided by the largest exact flux. The error must fall by 3.8 to 4.5 times each time the number of nodes doubles.
How we know the right answer. For a known \(g(r)\) the exact flux is \(-\kappa_c\,\rho\,T_\mathrm{fus}\,\Delta S_\mathrm{fus}\,\phi'(g)\,\mathrm{d}g/\mathrm{d}r\) at each face, with \(\mathrm{d}g/\mathrm{d}r\) from the sine and \(\phi'(g)\) the derivative of the smooth clip, derived by hand. The mesh is uniform in mass coordinate and each face lies midway between the 2 cell centres in that coordinate, so a central difference has an error that falls 4 times each time the cell size halves (second order). Doubling the nodes shrinks the cells by a little more than 2 (39/19 = 2.05). So second order predicts ratios of 4.21, 4.10 and 4.05, and the measured ratios are close to these. The same flux from a gradient shifted by one cell falls 2 times (first order), so the test tells the 2 apart.
Why it matters. Inside a mush, the mixing flux moves latent heat at every depth. A first-order error would change the freezing rate with the number of cells.
How to read the plot. Both axes are logarithmic. The x axis is the number of nodes; the y axis is the largest error of \(J_\mathrm{mix}\), divided by the largest exact flux. Circles are the code, squares the gradient shifted by one cell (shifted gradient), triangles the bracket form. The thin lines show slopes of 2 and 1. A pass is circles on the slope-2 line.
Known limit. Beyond the plotted 160 nodes, the error falls 4.02 times from 160 to 320 nodes, as second order predicts (4.03). From 320 to 640 nodes it falls only 3.09 times, against 4.01 predicted, which is outside the 3.8 to 4.5 band of the test. The relative error at 640 nodes is \(1.05 \times 10^{-6}\). So a second error shows only on the finest mesh; its cause is not checked, and no test runs these meshes.
Test details
- Reference: the exact flux \(-\kappa_c\,\rho\,T_\mathrm{fus}\,\Delta S_\mathrm{fus}\,\phi'(g)\,\mathrm{d}g/\mathrm{d}r\) of the prescribed profile.
- Tolerance: error ratio between 3.8 and 4.5 per doubling (measured 4.30, 4.15, 4.07; error 9.55 × 10⁻⁴ at 20 nodes and 1.31 × 10⁻⁵ at 160).
- Discrimination: the shifted gradient has ratios between 1.8 and 2.3 (measured 2.14, 2.07, 2.03); the bracket form has an error more than 10 times that of the code at each mesh (measured 0.18 at 20 nodes to 0.057 at 160, at least 189 times).
- Test id:
tests/test_mixing_face_flux_validation.py::test_the_mush_flux_converges_at_second_order_to_the_exact_gradient - Command:
pytest tests/test_mixing_face_flux_validation.py -k second_order(add--validation-plotsto write the plot pair)
No mixing flux between cells of pure melt
Why this check exists. A clip that stays slightly below 1 in the melt gives a small \(\partial\phi/\partial r\) between melt cells. That flux has no physical cause: pure melt has no crystals to mix.
What it tests. A melt column of 39 cells with \(g\) from 1.5 at the base to 1.005 at the top. Every face between 2 cells with \(g \ge 1.02\) must have \(J_\mathrm{mix}\) exactly 0. Only the 2 top faces, which touch a cell below \(g = 1.02\) (the top 2 cells have \(g = 1.018\) and \(1.005\)), can have a flux.
How we know the right answer. The cell melt fraction is exactly 1 for \(g \ge 1.02\), so the difference between 2 such cells is exactly 0.
Why it matters. A deep magma ocean is pure melt for most of its early life. A flux there would move heat that the energy equation does not have.
How to read the plot. The x axis is \(g\) at the face, the mean of the 2 cells. The y axis is \(|J_\mathrm{mix}| + 10^{-3}\) W m\(^{-2}\), on a logarithmic scale; the added \(10^{-3}\) lets an exact 0 show on the plot. The dots are the code; the dashed line is the bracket form. The vertical line marks \(g = 1.02\). The face just right of it still touches the cell at \(g = 1.018\), so it carries a flux. A pass is dots on the bottom line at every other face right of the line.
Test details
- Reference: \(\phi = 1\) exactly for \(g \ge 1.02\) (exact identity of the code).
- Tolerance: exactly 0 on all 36 faces between cells with \(g \ge 1.02\) (measured 0).
- Discrimination: the bracket form gives more than 1 W m⁻² on one of these faces (measured 15.1 W m⁻²); the test asserts that at least one face carries more than 1 W m⁻².
- Test id:
tests/test_mixing_face_flux_validation.py::test_pure_melt_faces_carry_no_mixing_flux_down_to_the_cut - Command:
pytest tests/test_mixing_face_flux_validation.py -k pure_melt(add--validation-plotsto write the plot pair) - Related smoke test (no plot): the cell melt fraction is exactly 0 for \(g \le -0.02\), and
tests/test_mixing_face_flux_smoke.py::test_pure_solid_cells_exchange_no_mixing_fluxchecks that a column of pure solid has \(J_\mathrm{mix}\) exactly 0 at every face, with a fixed and with the mixing-length \(\kappa_c\).
A moving front under the mixing-length eddy diffusivity
Why this check exists. The cases above use a fixed \(\kappa_c\). In a run, \(\kappa_c\) is the mixing-length eddy diffusivity, which vanishes where the entropy grows upward and is large in a convecting column. A switch at the face that returns under that \(\kappa_c\) would make the flux jump each time the front passes a cell.
What it tests. A column of 19 cells with \(\mathrm{d}S/\mathrm{d}r = -10^{-6}\) J kg\(^{-1}\) K\(^{-1}\) m\(^{-1}\), close to an adiabat, so that \(\kappa_c\) is positive at every face (from \(6.1 \times 10^4\) to \(1.07 \times 10^7\) m\(^2\) s\(^{-1}\)). The test shifts the entropy of the whole column so that the middle cell goes from \(g = 1.05\) to \(0.95\), in 20, 200 and 2000 equal steps. In every state, each face between 2 cells with \(g \ge 1.02\) must carry exactly 0. The largest step of the flux over all faces must fall by 8 to 12 times each time the sweep step falls 10 times.
How we know the right answer. The cell melt fraction is exactly 1 for \(g \ge 1.02\), so Eq. 9 of Bower et al. (2018)1 gives 0 between 2 such cells, for any \(\kappa_c\). The melt fraction and \(\kappa_c\) change continuously with the entropy, so the largest step must fall in proportion to the sweep step. A flux with a switch at the face keeps a step of the same size however small the sweep step is; the test builds that case from the bracket form with a hard switch at face \(g = 1\).
Why it matters. In a run the front moves through the cells under the mixing-length \(\kappa_c\). In this test column, where \(\kappa_c\) reaches \(1.07 \times 10^7\) m\(^2\) s\(^{-1}\), the flux at the front reaches \(7.2 \times 10^{10}\) W m\(^{-2}\); that value belongs to the column, not to a run. A step there would show as a step in the heat flow of the run.
How to read the plot. The plot shows the state of the 200-step sweep in which the middle cell is closest to \(g = 1\). The x axis is \(g\) at the face, the mean of the 2 cells. The y axis is \(|J_\mathrm{mix}| + 1\) W m\(^{-2}\), on a logarithmic scale; the added 1 lets an exact 0 show on the plot. The dots are the code; the dashed line is the bracket form. The vertical line marks \(g = 1.02\). A pass is dots on the bottom line at the faces between 2 melt cells, where the bracket form still carries its tanh tail.
How to read the plot. Both axes are logarithmic. The x axis is the sweep step, in \(g\) of the middle cell; the y axis is the largest change of \(J_\mathrm{mix}\) at any face between 2 states next to each other. Circles are the code, triangles the bracket form, squares the bracket form with a hard switch at the face. A pass is circles on a line of slope 1; the squares stay flat. The triangles also fall with slope 1, because the tanh weight of the bracket form is continuous: the bracket form fails this case at the faces between 2 melt cells (first plot), not here.
Known limit. The column above has the default convective threshold \(D = 0\) (convective_threshold in [energy], J kg\(^{-1}\) K\(^{-1}\) m\(^{-1}\)). For a positive eddy_diffusivity_chemical and \(D > 0\) the flux of a mush jumps where \(\partial S/\partial r\) changes sign. On the unstable side the code drives convection with a gradient of at least \(D\) (the minimum drive), so \(\kappa_c\) keeps its value for \(D\) as \(\partial S/\partial r\) goes to 0. On the stable side \(\kappa_c\) is 0. On a 30-cell mush, at the faces at least 3 cells from a boundary, the flux goes from a median of \(-6.2 \times 10^7\) W m\(^{-2}\) (largest size \(2.4 \times 10^{10}\) W m\(^{-2}\)) to 0 when the gradient changes from \(-10^{-9}\) to \(+10^{-9}\) J kg\(^{-1}\) K\(^{-1}\) m\(^{-1}\). No test checks these numbers; the Test details give the state.
Test details
- Reference: \(\phi = 1\) exactly for \(g \ge 1.02\) in Eq. 9 of Bower et al. (2018); continuity of \(\phi\) and \(\kappa_c\) in the entropy.
- Tolerance: exactly 0 on every face between cells with \(g \ge 1.02\), in all 2001 states of the finest sweep (15154 faces in all, measured 0); step ratio between 8 and 12 per 10 times smaller sweep step (measured 9.35 and 10.00; largest step \(3.48 \times 10^{10}\), \(3.72 \times 10^9\) and \(3.72 \times 10^8\) W m\(^{-2}\)).
- Discrimination: on the same faces the bracket form carries up to \(5.98 \times 10^8\) W m\(^{-2}\); the test asserts more than \(10^6\). The bracket form with a hard switch keeps a step of \(7.4\) to \(7.5 \times 10^{10}\) W m\(^{-2}\) at every sweep step; the test asserts that the step does not fall below half from one sweep to the next, and that at the finest sweep it is more than 100 times the step of the code. On the solver of the bracket form the test fails at the check of exactly 0 between melt cells.
- Test id:
tests/test_mixing_production_front.py::test_production_kappa_c_front_has_no_flux_in_pure_melt_and_no_step - Command:
pytest tests/test_mixing_production_front.py(add--validation-plotsto write the 2 plot pairs) - State of the Known limit (not checked by a test): the 30 cells that
_solver(n_nodes=31)intests/test_mixing_face_flux_smoke.pybuilds on the SPIDER test tables, \(D = 10^{-6}\),eddy_diffusivity_chemical= 1, entropy \(S_0 + (\partial S/\partial r)(r - \bar r)\) with \(S_0\) the mean over the cells of the entropy at \(g = 0.4\) (\(S_0\) alone gives \(g\) = 0.36 to 0.99) and \(\bar r\) the mean cell radius; the numbers are for the faces at least 3 cells from a boundary, where the flux is downward at every face at \(-10^{-9}\).
Known limit: speed under a falling liquidus
The cases above do not check how fast the solver runs. In some EOS tables the liquidus entropy falls as the pressure grows. The PALEOS MgSiO\(_3\) tables, the default tables of Aragog, have such a liquidus above 164.8 GPa. In one run with these tables the solve slowed down when the cells of a molten column came within 0.02 of the liquidus in \(g\): the slow call started with 14 cells at \(g\) between 1.015 and 1.02, all above the liquidus. These cells are inside the join below \(g = 1.02\), where the cell melt fraction is below 1 (\(1 - 8.3 \times 10^{-6}\) at \(g = 1.015\)), so the mixing flux at their faces is not 0 (up to \(7.78 \times 10^6\) W m\(^{-2}\), at face 42). Whether the fall of the liquidus causes this is open.
The numbers come from one PROTEUS run of a planet of 3 Earth masses from a molten start (core-mantle boundary at 296 GPa, 80 nodes). PROTEUS calls Aragog once per coupling step, and each call integrates the mantle over that step.
- With the cell melt fractions of this page and the PALEOS liquidus, the call from 3134 to 3269 yr takes 3 432 429 internal steps of CVODE, the time integrator, in 1 solve.
- In a second run from the same molten start, with a liquidus that does not fall, the call at the same model time (3134 to 3270 yr) takes 44 steps. That call starts from the state of its own run, not from the state of the slow call. This liquidus is constant at 9923.5 J kg\(^{-1}\) K\(^{-1}\) above 124.7 GPa, and it also differs from the PALEOS liquidus at lower pressures (by \(-30\) to \(+125\) J kg\(^{-1}\) K\(^{-1}\)), so the comparison does not isolate the fall.
- With the bracket form and the PALEOS liquidus, CVODE reaches its step limit earlier, at 2497 yr. The retry ladder of PROTEUS then repeats the call with more steps and a looser tolerance; the first repeat reaches the limit too, and the second had not ended when the run was stopped. So the bracket form also stalls in this run, at a time when the state differs from that of the other 2 calls.
The step limit max_steps (100 000 by default) counts the CVODE steps between 2 output times of a call, not the steps of the whole call; a call has 64 output intervals (cvode_output_points = 65). The slow call ended without the error, so none of its intervals reached 100 000 steps (3 432 429 steps over 64 intervals is about 53 600 per interval on average). In the bracket-form run one interval reached the limit.
No test checks these numbers; the cause is open (aragog#133).
Run details
- Config:
planet.mass_tot= 3,interior_struct.zalmoxis.mantle_eos="PALEOS-2phase:MgSiO3",interior_energetics.num_levels= 80,interior_energetics.rtol= \(10^{-8}\),interior_energetics.aragog.atol_temperature_equivalent= \(10^{-8}\),interior_energetics.eddy_diffusivity_thermal= 1,interior_energetics.eddy_diffusivity_chemical= 1,interior_energetics.trans_mixing= true (mixing flux on),interior_energetics.trans_grav_sep= true (gravitational separation on). - Steps: the sum of
nstover the CVODE solves of the call in the PROTEUS log. A step limit is the CVODE errorCV_TOO_MUCH_WORK; the first repeat of the PROTEUS ladder usesmax_steps200 000 andrtol\(2 \times 10^{-8}\).
-
D. J. Bower, P. Sanan, A. S. Wolf, Numerical solution of a non-linear conservation law applicable to the interior dynamics of partially molten planets, Physics of the Earth and Planetary Interiors, 274, 49-62, 2018. SciX. ↩↩