Skip to content

Core arrays and inner-core boundary

Inner-core boundary of a two-layer core and the core arrays result['core'] of a structure solve whose profile reaches the core mass: radius, mass, pressure, density, gravity, temperature and phase per core node, a node at the core mass, and the ICB scalars.

core_profile

Inner-core boundary and core arrays of a structure solve.

A two-layer core has an inner core on the solid iron side and an outer core on the liquid side (layer_eos_config['inner_core'] and ['core']). Its inner-core boundary (ICB) is either a given mass, inner_core_mass_fraction of the core mass, or where the liquid of the outer core reaches the liquidus T_liq(P): the first root, from the centre outward, of the temperature profile on a given profile, and of the liquid branch (the outer-core adiabat continued below the ICB with the liquid side) on an adiabat (icb_from_profile, icb_superheat). The structure equations place a shell in the inner core by its enclosed mass, as they place the core-mantle boundary, so the liquidus rule is applied to the profile of the previous outer pass and the outer loop converges it with the structure.

icb_from_profile(mass, pressure, temperature, cmb_mass, liquidus, icb_mass=None, m23=False, cmb_point_rule=None)

Inner-core boundary on a structure profile by the liquidus rule.

Parameters:

Name Type Description Default
mass array - like

Enclosed mass [kg], pressure [Pa] and temperature [K] at the nodes, centre first.

required
pressure array - like

Enclosed mass [kg], pressure [Pa] and temperature [K] at the nodes, centre first.

required
temperature array - like

Enclosed mass [kg], pressure [Pa] and temperature [K] at the nodes, centre first.

required
cmb_mass float

Core mass [kg].

required
liquidus callable

T_liq(P) [K] of the outer core at pressure [Pa].

required
icb_mass float or None

A given inner-core mass [kg]: the result then reports it, the pressure at it and the core mass above it that lies below the liquidus.

None
m23 bool

Take the mass of a root with m^(2/3) linear in P on its node segment, the inverse of the pressure at a given mass (as in core_arrays); else with m linear in ln P.

False
cmb_point_rule callable or None

T rule (P_cmb, P_last, T_last) -> T [K] of the point at the core mass, from the core side of the temperature source (eos.temperature.cmb_point_temperature on an adiabat); None takes T linear in ln P between the last core node and the next node.

None

Returns:

Type Description
tuple of float

Inner-core mass [kg], ICB pressure [Pa] and the core mass above the ICB that lies below the liquidus [kg], at node resolution. With the centre at or above the liquidus the inner-core mass is 0 and the pressure that of the centre; with the core below it to the core mass the inner core is the core and the pressure that at the core mass. A node past the core mass adds a point at the core mass to the core nodes (_cmb_point). Nodes that a failed stop fills with NaN are left out: the rule reads the finite core nodes.

Source code in src/zalmoxis/core_profile.py
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
def icb_from_profile(
    mass,
    pressure,
    temperature,
    cmb_mass,
    liquidus,
    icb_mass=None,
    m23=False,
    cmb_point_rule=None,
):
    """Inner-core boundary on a structure profile by the liquidus rule.

    Parameters
    ----------
    mass, pressure, temperature : array-like
        Enclosed mass [kg], pressure [Pa] and temperature [K] at the nodes, centre first.
    cmb_mass : float
        Core mass [kg].
    liquidus : callable
        ``T_liq(P)`` [K] of the outer core at pressure [Pa].
    icb_mass : float or None
        A given inner-core mass [kg]: the result then reports it, the pressure at it and the
        core mass above it that lies below the liquidus.
    m23 : bool
        Take the mass of a root with m^(2/3) linear in P on its node segment, the inverse of the
        pressure at a given mass (as in ``core_arrays``); else with m linear in ln P.
    cmb_point_rule : callable or None
        T rule ``(P_cmb, P_last, T_last) -> T`` [K] of the point at the core mass, from the core
        side of the temperature source (``eos.temperature.cmb_point_temperature`` on an
        adiabat); None takes T linear in ln P between the last core node and the next node.

    Returns
    -------
    tuple of float
        Inner-core mass [kg], ICB pressure [Pa] and the core mass above the ICB that lies below
        the liquidus [kg], at node resolution. With the centre at or above the liquidus the
        inner-core mass is 0 and the pressure that of the centre; with the core below it to the
        core mass the inner core is the core and the pressure that at the core mass. A node past
        the core mass adds a point at the core mass to the core nodes (``_cmb_point``). Nodes
        that a failed stop fills with NaN are left out: the rule reads the finite core nodes.
    """
    m, p, t = _core_nodes(mass, pressure, temperature, cmb_mass, cmb_point_rule)
    f = t - np.array([float(liquidus(x)) for x in p])
    if not np.all(np.isfinite(f)):
        raise ValueError('the temperature or the core liquidus is not finite on the core nodes')
    if icb_mass is not None:
        return float(icb_mass), icb_pressure(m, p, icb_mass), _solid_mass(m, f, icb_mass)
    above = np.flatnonzero(f >= 0.0)
    if above.size and above[0] == 0:
        return 0.0, float(p[0]), _solid_mass(m, f, 0.0)
    if not above.size:
        return float(cmb_mass), float(p[-1]), 0.0
    k = int(above[0])
    lp_up, t_up = np.log(p[::-1]), t[::-1]  # ascending in pressure for np.interp
    p_icb = brentq(
        lambda x: float(np.interp(math.log(x), lp_up, t_up)) - float(liquidus(x)),
        p[k],
        p[k - 1],
        xtol=1e-3,
        rtol=4.0 * np.finfo(float).eps,
    )
    if m23:
        m_icb = float(np.interp(p_icb, p[::-1], m[::-1] ** (2.0 / 3.0))) ** 1.5
    else:
        m_icb = float(np.interp(math.log(p_icb), lp_up, m[::-1]))
    return m_icb, float(p_icb), _solid_mass(m, f, m_icb)

icb_superheat(mass, pressure, liquid_temperature, cmb_mass, liquidus, icb_mass, cmb_point_rule=None)

Superheat [K] of the outer-core liquid at the layer ICB and its miss of the zero-superheat condition of a growing inner core, after Labrosse (2015), Sect. 2, and Nimmo (2015), Fig. 2.

Parameters:

Name Type Description Default
mass array - like

Enclosed mass [kg] and pressure [Pa] at the nodes, centre first.

required
pressure array - like

Enclosed mass [kg] and pressure [Pa] at the nodes, centre first.

required
liquid_temperature array - like

Temperature [K] of the outer-core liquid branch at the nodes: the outer-core adiabat continued below the ICB to the centre with the liquid side.

required
cmb_mass float

Core mass and inner-core mass of the layers [kg].

required
icb_mass float

Core mass and inner-core mass of the layers [kg].

required
liquidus callable

T_liq(P) [K] of the outer core at pressure [Pa].

required
cmb_point_rule callable or None

T rule of the point at the core mass, as in icb_from_profile.

None

Returns:

Type Description
tuple of float

S = T_l(P_icb) - T_liq(P_icb), with T_l linear in ln P on the core nodes and P_icb the pressure at icb_mass with P linear in m^(2/3), as in core_arrays (at the centre for no inner core, at the core mass for a full one); and the miss: |S| for a partial inner core, max(0, -S) for no inner core, max(0, S) for a full one, inf when S is not finite.

Source code in src/zalmoxis/core_profile.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
def icb_superheat(
    mass, pressure, liquid_temperature, cmb_mass, liquidus, icb_mass, cmb_point_rule=None
):
    """Superheat [K] of the outer-core liquid at the layer ICB and its miss of the
    zero-superheat condition of a growing inner core, after Labrosse (2015), Sect. 2, and
    Nimmo (2015), Fig. 2.

    Parameters
    ----------
    mass, pressure : array-like
        Enclosed mass [kg] and pressure [Pa] at the nodes, centre first.
    liquid_temperature : array-like
        Temperature [K] of the outer-core liquid branch at the nodes: the outer-core adiabat
        continued below the ICB to the centre with the liquid side.
    cmb_mass, icb_mass : float
        Core mass and inner-core mass of the layers [kg].
    liquidus : callable
        ``T_liq(P)`` [K] of the outer core at pressure [Pa].
    cmb_point_rule : callable or None
        T rule of the point at the core mass, as in ``icb_from_profile``.

    Returns
    -------
    tuple of float
        S = T_l(P_icb) - T_liq(P_icb), with T_l linear in ln P on the core nodes and P_icb the
        pressure at ``icb_mass`` with P linear in m^(2/3), as in ``core_arrays`` (at the centre
        for no inner core, at the core mass for a full one); and the miss: |S| for a partial
        inner core, max(0, -S) for no inner core, max(0, S) for a full one, inf when S is not
        finite.
    """
    m, p, t = _core_nodes(mass, pressure, liquid_temperature, cmb_mass, cmb_point_rule)
    full = icb_mass >= cmb_mass * (1.0 - _RTOL_LAYER)
    p_icb = p[0] if icb_mass <= 0.0 else icb_pressure(m, p, icb_mass)
    s = float(np.interp(math.log(p_icb), np.log(p[::-1]), t[::-1])) - float(liquidus(p_icb))
    miss = max(0.0, -s) if icb_mass <= 0.0 else max(0.0, s) if full else abs(s)
    return s, miss if math.isfinite(s) else math.inf

icb_misses(mass, pressure, temperature, cmb_mass, liquidus, icb_mass, icb_adiabat, cmb_point_rule=None)

Distances [kg] of the layer inner-core mass icb_mass from the liquidus root of the profile (CMB point from the rule cmb_point_rule, as in icb_from_profile) and from icb_adiabat, the inner-core mass that its adiabat took (0 if None).

Source code in src/zalmoxis/core_profile.py
177
178
179
180
181
182
183
184
185
186
def icb_misses(
    mass, pressure, temperature, cmb_mass, liquidus, icb_mass, icb_adiabat, cmb_point_rule=None
):
    """Distances [kg] of the layer inner-core mass ``icb_mass`` from the liquidus root of the
    profile (CMB point from the rule ``cmb_point_rule``, as in ``icb_from_profile``) and from
    ``icb_adiabat``, the inner-core mass that its adiabat took (0 if None)."""
    root = icb_from_profile(
        mass, pressure, temperature, cmb_mass, liquidus, cmb_point_rule=cmb_point_rule
    )[0]
    return abs(root - icb_mass), 0.0 if icb_adiabat is None else abs(icb_adiabat - icb_mass)

core_arrays(result, layer_mixtures, rhs, temperature_at, icb_mass, solid_above)

Arrays of the core from the centre to a node at the core mass, and its ICB scalars.

Parameters:

Name Type Description Default
result dict

Structure result with radii, mass_enclosed, gravity, pressure, density, temperature and cmb_mass.

required
layer_mixtures dict

Per-layer mixtures; inner_core present for a two-layer core.

required
rhs callable

rhs(r, y) of the structure equations with the core mixture, y = (m, g, P).

required
temperature_at callable

T(r, P) [K] of the solve.

required
icb_mass float

Inner-core mass [kg] and the core mass below the liquidus above the ICB [kg].

required
solid_above float

Inner-core mass [kg] and the core mass below the liquidus above the ICB [kg].

required

Returns:

Type Description
dict

r, m, P, rho, g, T (m, kg, Pa, kg/m^3, m/s^2, K) and phase (int8: 1 inner core, 0 outer core) per node, w_<el> (mass fraction) per light element of either layer, and M_ic [kg], R_icb [m], P_icb [Pa], solid_above_icb_mass_fraction and the flag solid_above_icb. The node at the core mass takes the core side of the layer rule for its phase and density. R_icb takes r^3 linear in m on the node segment of M_ic, exact for uniform density. P_icb takes P linear in m^(2/3) on the core nodes and the CMB point of icb_from_profile (ln P linear in m), exact while the density is uniform from the centre, and in the node segment of the CMB as accurate as that point, which depends on the CMB position (docs/Explanations/mixing.md). It is never below the pressure of the CMB node, and a full inner core takes that pressure; the ICB readers then miss P_icb by that move, and a move above 1e-3 relative logs a warning. w_layers maps each core layer to its light-element fractions.

Raises:

Type Description
ValueError

When the profile has no node at or past the core mass, or the core mass is not reached within 2 node segments.

Source code in src/zalmoxis/core_profile.py
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
def core_arrays(result, layer_mixtures, rhs, temperature_at, icb_mass, solid_above):
    """Arrays of the core from the centre to a node at the core mass, and its ICB scalars.

    Parameters
    ----------
    result : dict
        Structure result with ``radii``, ``mass_enclosed``, ``gravity``, ``pressure``,
        ``density``, ``temperature`` and ``cmb_mass``.
    layer_mixtures : dict
        Per-layer mixtures; ``inner_core`` present for a two-layer core.
    rhs : callable
        ``rhs(r, y)`` of the structure equations with the core mixture, y = (m, g, P).
    temperature_at : callable
        ``T(r, P)`` [K] of the solve.
    icb_mass, solid_above : float
        Inner-core mass [kg] and the core mass below the liquidus above the ICB [kg].

    Returns
    -------
    dict
        ``r, m, P, rho, g, T`` (m, kg, Pa, kg/m^3, m/s^2, K) and ``phase`` (int8: 1 inner core,
        0 outer core) per node, ``w_<el>`` (mass fraction) per light element of either layer,
        and ``M_ic`` [kg], ``R_icb`` [m], ``P_icb`` [Pa], ``solid_above_icb_mass_fraction`` and
        the flag ``solid_above_icb``.
        The node at the core mass takes the core side of the layer rule for its phase and
        density. ``R_icb`` takes r^3 linear in m on the node segment of M_ic, exact for
        uniform density. ``P_icb`` takes P linear in m^(2/3) on the core nodes and the CMB
        point of ``icb_from_profile`` (ln P linear in m), exact while the density is uniform
        from the centre, and in the node segment of the CMB as accurate as that point, which
        depends on the CMB position (docs/Explanations/mixing.md). It is never below the
        pressure of the CMB node, and a full inner core takes that pressure; the ICB readers
        then miss ``P_icb`` by that move, and a move above 1e-3 relative logs a warning.
        ``w_layers`` maps each core layer to its light-element fractions.

    Raises
    ------
    ValueError
        When the profile has no node at or past the core mass, or the core mass is not reached
        within 2 node segments.
    """
    r, m, g, p, rho, t = (
        np.asarray(result[k], dtype=float)
        for k in ('radii', 'mass_enclosed', 'gravity', 'pressure', 'density', 'temperature')
    )
    cmb_mass = float(result['cmb_mass'])
    n = int(np.count_nonzero(m < cmb_mass * (1.0 - _RTOL_LAYER)))
    if n == len(m):
        raise ValueError('the profile has no node at or past the core mass')

    def hit(r_, y):
        return y[0] - cmb_mass

    hit.terminal, hit.direction = True, 1
    sol = solve_ivp(
        rhs,
        (r[n - 1], 2.0 * r[n] - r[n - 1]),  # one more segment: node n can lie 1e-12 short
        [m[n - 1], g[n - 1], p[n - 1]],
        events=hit,
        rtol=1e-12,
        atol=[1e-12 * cmb_mass, 1e-12, 1e-6],
    )
    if not sol.t_events[0].size:
        raise ValueError(f'the core mass is not reached within 2 segments of node {n - 1}')
    r_c, (m_c, g_c, p_c) = float(sol.t_events[0][0]), sol.y_events[0][0]
    t_c = float(temperature_at(r_c, p_c))
    m_in = min(m_c, cmb_mass * (1.0 - 4.0 * _RTOL_LAYER))  # the core side of the layer rule
    rho_c = float(rhs(r_c, [m_in, g_c, p_c])[0]) / (4.0 * np.pi * r_c**2)
    out = {
        'r': np.r_[r[:n], r_c],
        'm': np.r_[m[:n], m_c],
        'P': np.r_[p[:n], p_c],
        'rho': np.r_[rho[:n], rho_c],
        'g': np.r_[g[:n], g_c],
        'T': np.r_[t[:n], t_c],
    }
    inner = 'inner_core' in layer_mixtures
    side_m = np.r_[m[:n], m_in]
    out['phase'] = (inner & (side_m < icb_mass * (1.0 - _RTOL_LAYER))).astype(np.int8)
    comps = {
        layer: split_alloy(mix)[1] if is_alloy_mixture(mix) else {}
        for layer, mix in layer_mixtures.items()
        if layer in ('core', 'inner_core')
    }
    out['w_layers'] = comps
    for el in sorted(set().union(*comps.values())):
        w = [comps.get(layer, {}).get(el, 0.0) for layer in ('core', 'inner_core')]
        out[f'w_{el}'] = np.where(out['phase'] == 1, w[1], w[0])
    out['M_ic'] = float(icb_mass)
    out['R_icb'] = float(np.interp(icb_mass, out['m'], out['r'] ** 3)) ** (1.0 / 3.0)
    m_core, p_core, _ = _core_nodes(m, p, t, cmb_mass)  # the CMB point of the other ICB readers
    reader = icb_pressure(m_core, p_core, icb_mass)
    full = icb_mass >= cmb_mass * (1.0 - _RTOL_LAYER)
    out['P_icb'] = float(p_c) if full else max(reader, float(p_c))
    if abs(out['P_icb'] / reader - 1.0) > 1e-3:
        logger.warning(
            'P_icb takes the CMB node pressure %.6g Pa, %.2g off the %.6g Pa of the ICB '
            'readers: the CMB point of the readers is coarse on this grid.',
            out['P_icb'],
            out['P_icb'] / reader - 1.0,
            reader,
        )
    out['solid_above_icb_mass_fraction'] = float(solid_above) / cmb_mass
    out['solid_above_icb'] = bool(solid_above > 0.0)
    return out

outside_side_tables(P, T, mixture, material_dictionaries, cache)

Nodes whose (P, T) an iron side table of mixture clamps or cannot read.

A node is outside where its pressure is outside the table, its temperature outside the valid band of its pressure row (where the read clamps it) or the bilinear density there is not finite (where the read takes the nearest neighbour). Mixtures without a side table give no node.

Source code in src/zalmoxis/core_profile.py
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
def outside_side_tables(P, T, mixture, material_dictionaries, cache):
    """Nodes whose (P, T) an iron side table of ``mixture`` clamps or cannot read.

    A node is outside where its pressure is outside the table, its temperature outside the
    valid band of its pressure row (where the read clamps it) or the bilinear density there is
    not finite (where the read takes the nearest neighbour). Mixtures without a side table give
    no node.
    """
    from .eos.interpolation import (
        _ensure_unified_cache,
        _fast_bilinear,
        _paleos_clamp_temperature,
    )

    out = np.zeros(len(P), dtype=bool)
    for comp in mixture.components:
        if comp not in IRON_SIDES:
            continue
        c = _ensure_unified_cache(material_dictionaries[comp]['eos_file'], cache)
        for i, (p, t) in enumerate(zip(P, T)):
            if not c['p_min'] <= p <= c['p_max'] or not t > 0:
                out[i] = True
                continue
            lp, lt = math.log10(p), math.log10(t)
            clamped = _paleos_clamp_temperature(lp, lt, c)[1]
            out[i] |= clamped or not math.isfinite(_fast_bilinear(lp, lt, c['density_grid'], c))
    return out