Skip to content

aragog.rheology

The aragog.rheology module provides the homologous-temperature Arrhenius diffusion-creep viscosity kernel, the Byerlee plastic yield-stress criterion, the viscosity-contrast-dependent mixing-length factor, and the SolidRheologyParams configuration dataclass. All kernels accept an xp array namespace (numpy or jax.numpy) and run at 64-bit precision.

Name Role
SolidRheologyParams Validated configuration dataclass for solid-state Arrhenius creep, Byerlee yielding, stagnant-lid diagnostics, and mixing-length calibration.
merge_rheology Return a SolidRheologyParams instance with keyword field overrides applied.
delegate_rheology Class decorator exposing SolidRheologyParams fields as read-only properties reading self.rheology.
compute_arrhenius_enthalpy Pressure-dependent homologous activation enthalpy \(H(P) = g_\mathrm{hom} R T_\mathrm{sol}(P)\) (J/mol).
compute_arrhenius_viscosity Homologous-temperature Arrhenius diffusion-creep viscosity \(\eta_\mathrm{diff}(T, P)\) (Pa s), clipped in \(\log_{10}\) space after applying water_prefactor.
compute_yield_stress Byerlee frictional yield stress \(\tau_y(P) = \max(0, \min(c + \mu P, \tau_\mathrm{max}))\) (Pa).
compute_strain_rate_local Second invariant of the local convective strain-rate tensor $\dot{\epsilon}_\mathrm{local} =
compute_mlt_top_slope Viscosity-contrast-dependent upper mixing-length slope \(s_\mathrm{top}(\theta) = s_{\mathrm{top},\infty} + (1 - s_{\mathrm{top},\infty}) \exp(-c_\theta \max(\theta, 0))\).
viscous_mixing_length_factor Fourth-power mixing-length scaling factor \((l_v / l)^4\) for the viscous branch of mixing-length theory.

For the physical derivations and asymptotic regimes, see Solid-state convection and lithospheric rheology.

rheology

Solid-state mantle rheology formulations.

Provides temperature- and pressure-dependent Arrhenius diffusion creep viscosity, Byerlee yield stress, boundary-layer stress closure, effective viscosity capping, and viscosity-contrast-dependent mixing-length scaling for solid-state convection.

SolidRheologyParams(enabled=False, g_homologous=25.0, t_sol_0=1400.0, dt_sol_dp=2.4e-08, arrhenius_t_ref=1600.0, viscosity_max_log10=40.0, water_prefactor=1.0, yield_stress_c=50000000.0, yield_stress_mu=0.6, yield_stress_max=500000000.0, stress_closure_mode='lid', interior_flux_fraction=0.05, lid_base_mode='rheological', lid_base_temperature=1400.0, lid_contrast_coeff=2.2, lid_mask_width_cells=1.0, phi_visc_single=0.5, mlt_bottom_slope=1.0, s_top_inf=0.22, c_theta=0.15, activation_energy=None, activation_volume=0.0, activation_volume_decay_pressure=float('inf')) dataclass

Parameters for solid-state mantle rheology and stagnant lid scaling.

This class is the single source of truth for rheology parameter defaults and bounds validation across Aragog and PROTEUS.

Notes

Coupled and tabulated PALEOS runs evaluate the phase-boundary solidus :math:T_\mathrm{sol}(P) = 0.8\,T_\mathrm{liq}(P) from the PALEOS :math:\mathrm{MgSiO_3} melting curve. In both table-solidus and linear-fallback modes, t_sol_0 sets the zero-pressure reference activation enthalpy h_0 = g_homologous * R * t_sol_0, so viscosity_solid is the viscosity at (arrhenius_t_ref, P=0) on the linear solidus t_sol_0; with a table solidus, eta(T_ref, 0) = viscosity_solid * exp(g_homologous * (T_sol,table(0) - t_sol_0) / T_ref) (1.8459 * viscosity_solid for the CI test table with T_sol,table(0) = 1439.230032 K and t_sol_0 = 1400 K). When no solidus table reaches a call, the linear fallback defaults t_sol_0 = 1400.0 K and dt_sol_dp = 2.4e-8 K/Pa (24 K/GPa) provide a table-free benchmark form whose largest deviation from the PALEOS solidus over 0 to 135 GPa is 1108.1 K (see docs/Explanations/solid_state_convection.md Section 1). When activation_energy is set, activation enthalpy follows the saturating integral law :math:H(P) = E_a + V_0 P_\mathrm{decay} (1 - \exp(-P / P_\mathrm{decay})) (reducing to :math:E_a + V_0 P when :math:P_\mathrm{decay} = \infty); the published secant-form parameter sets of Tackley et al. (2013, Table 2) for :math:E_0 + P V_0 \exp(-P / P_\mathrm{decay}) are not parameter sets of the integral law. See docs/Explanations/solid_state_convection.md for model formulation and derivations.

check_viscosity_ceiling(viscosity, rheology)

Raise ValueError when a numeric viscosity is not below 10**viscosity_max_log10.

The ceiling applies only when rheology.enabled is True; with the rheology off any viscosity passes.

Parameters:

Name Type Description Default
viscosity Any

Reference solid dynamic viscosity [Pa s]; finite positive scalar values in (0, 10**viscosity_max_log10) are accepted, while non-scalar or boolean values are ignored by this scalar ceiling check.

required
rheology SolidRheologyParams

Rheology parameter set providing enabled and viscosity_max_log10 (dimensionless, valid range (20, 300]).

required

Returns:

Type Description
None

Returns None when viscosity satisfies the ceiling or the rheology is disabled.

Raises:

Type Description
ValueError

If the rheology is enabled and viscosity overflows float, or viscosity > 0 is finite and rheology.viscosity_max_log10 <= log10(viscosity).

Source code in src/aragog/rheology.py
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
def check_viscosity_ceiling(viscosity: Any, rheology: SolidRheologyParams) -> None:
    """Raise ValueError when a numeric ``viscosity`` is not below ``10**viscosity_max_log10``.

    The ceiling applies only when ``rheology.enabled`` is True; with the rheology
    off any ``viscosity`` passes.

    Parameters
    ----------
    viscosity : Any
        Reference solid dynamic viscosity [Pa s]; finite positive scalar values
        in ``(0, 10**viscosity_max_log10)`` are accepted, while non-scalar or
        boolean values are ignored by this scalar ceiling check.
    rheology : SolidRheologyParams
        Rheology parameter set providing ``enabled`` and ``viscosity_max_log10``
        (dimensionless, valid range ``(20, 300]``).

    Returns
    -------
    None
        Returns ``None`` when ``viscosity`` satisfies the ceiling or the rheology
        is disabled.

    Raises
    ------
    ValueError
        If the rheology is enabled and ``viscosity`` overflows ``float``, or
        ``viscosity > 0`` is finite and ``rheology.viscosity_max_log10 <= log10(viscosity)``.
    """
    if not rheology.enabled or isinstance(viscosity, (bool, np.bool_)):
        return
    is_num_scalar = isinstance(viscosity, (int, float, np.number)) or (
        getattr(viscosity, 'ndim', None) == 0
        and getattr(getattr(viscosity, 'dtype', None), 'kind', '') in 'iuf'
    )
    if is_num_scalar:
        try:
            v = float(viscosity)
        except OverflowError as exc:
            raise ValueError('viscosity must be finite') from exc
        if math.isfinite(v) and v > 0.0 and rheology.viscosity_max_log10 <= math.log10(v):
            raise ValueError(
                f'viscosity_max_log10 ({rheology.viscosity_max_log10}) must be > '
                f'log10(viscosity) ({math.log10(v)})'
            )

compute_arrhenius_enthalpy(pressure, g_homologous=None, solidus_temperature=None, t_sol_0=None, dt_sol_dp=None, r_gas=R_GAS, xp=np, *, activation_energy=None, activation_volume=None, activation_volume_decay_pressure=None)

Compute homologous-temperature or saturating-integral activation enthalpy H(P) [J/mol].

When activation_energy is None (the default), evaluates the homologous law:

.. math:: H(P) = g_\mathrm{hom} R T_\mathrm{sol}(P)

When activation_energy is provided, evaluates the saturating integral law:

.. math:: H(P) = E_a + \int_0^P V_0 \exp(-p' / P_\mathrm{decay}) \, dp' = E_a + V_0 P_\mathrm{decay} \left(1 - \exp(-P / P_\mathrm{decay})\right)

which reduces to :math:H(P) = E_a + V_0 P when :math:P_\mathrm{decay} = \infty and to :math:H(P) = E_a when :math:V_0 = 0. Note that the published secant-form parameter sets of Tackley et al. (2013, Table 2) for :math:E_0 + P V_0 \exp(-P / P_\mathrm{decay}) are not parameter sets of the integral law.

Parameters:

Name Type Description Default
pressure float or array - like

Pressure P [Pa] (non-negative; negative round-off excursions down to -PRESSURE_ROUNDOFF_TOLERANCE = -1.0 Pa are clamped to 0.0 Pa).

required
g_homologous float

Dimensionless homologous activation parameter g_hom [-]. Defaults to SolidRheologyParams.g_homologous when None. Not used when activation_energy is set.

None
solidus_temperature float or array - like

Local solidus temperature T_sol(P) [K]. Not used when activation_energy is set.

None
t_sol_0 float

Zero-pressure solidus T_sol(0) [K] for the linear fallback (SolidRheologyParams.t_sol_0 when None). Not used when activation_energy is set.

None
dt_sol_dp float

Linear solidus slope dT_sol/dP [K/Pa] for the linear fallback. Defaults to SolidRheologyParams.dt_sol_dp when None. Not used when activation_energy is set.

None
r_gas float

Universal gas constant R [J/(mol K)].

8.314462618
xp array module

Array namespace module (numpy or jax.numpy).

np
activation_energy float

Zero-pressure activation energy E_a [J/mol] for the saturating integral law. When None (default), uses the homologous law.

None
activation_volume float

Zero-pressure activation volume V_0 [m^3/mol] for the saturating integral law. Requires activation_energy to be set when non-zero.

None
activation_volume_decay_pressure float

Characteristic decay pressure P_decay [Pa] (> 0, finite or +inf) for the saturating integral law. Requires activation_energy to be set when finite.

None

Returns:

Type Description
float or array - like

Activation enthalpy H(P) [J/mol].

Raises:

Type Description
ValueError

If scalar arguments are non-scalar; if any input is non-real; if activation_volume or finite activation_volume_decay_pressure is given when activation_energy is None; or, on the eager NumPy path, if any parameter lies outside its valid domain. On the JAX path, out-of-range numeric values return NaN.

Source code in src/aragog/rheology.py
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
def compute_arrhenius_enthalpy(
    pressure: FloatOrArray,
    g_homologous: float | None = None,
    solidus_temperature: FloatOrArray | None = None,
    t_sol_0: float | None = None,
    dt_sol_dp: float | None = None,
    r_gas: float = R_GAS,
    xp: Any = np,
    *,
    activation_energy: float | None = None,
    activation_volume: float | None = None,
    activation_volume_decay_pressure: float | None = None,
) -> FloatOrArray:
    r"""Compute homologous-temperature or saturating-integral activation enthalpy H(P) [J/mol].

    When ``activation_energy`` is ``None`` (the default), evaluates the homologous law:

    .. math::
        H(P) = g_\mathrm{hom} R T_\mathrm{sol}(P)

    When ``activation_energy`` is provided, evaluates the saturating integral law:

    .. math::
        H(P) = E_a + \int_0^P V_0 \exp(-p' / P_\mathrm{decay}) \, dp'
             = E_a + V_0 P_\mathrm{decay} \left(1 - \exp(-P / P_\mathrm{decay})\right)

    which reduces to :math:`H(P) = E_a + V_0 P` when :math:`P_\mathrm{decay} = \infty`
    and to :math:`H(P) = E_a` when :math:`V_0 = 0`. Note that the published secant-form
    parameter sets of Tackley et al. (2013, Table 2) for
    :math:`E_0 + P V_0 \exp(-P / P_\mathrm{decay})` are not parameter sets of the
    integral law.

    Parameters
    ----------
    pressure : float or array-like
        Pressure P [Pa] (non-negative; negative round-off excursions down to
        ``-PRESSURE_ROUNDOFF_TOLERANCE`` = -1.0 Pa are clamped to 0.0 Pa).
    g_homologous : float, optional
        Dimensionless homologous activation parameter g_hom [-]. Defaults to
        ``SolidRheologyParams.g_homologous`` when None. Not used when
        ``activation_energy`` is set.
    solidus_temperature : float or array-like, optional
        Local solidus temperature T_sol(P) [K]. Not used when
        ``activation_energy`` is set.
    t_sol_0 : float, optional
        Zero-pressure solidus T_sol(0) [K] for the linear fallback
        (``SolidRheologyParams.t_sol_0`` when None). Not used when
        ``activation_energy`` is set.
    dt_sol_dp : float, optional
        Linear solidus slope dT_sol/dP [K/Pa] for the linear fallback. Defaults to
        ``SolidRheologyParams.dt_sol_dp`` when None. Not used when
        ``activation_energy`` is set.
    r_gas : float, default 8.314462618
        Universal gas constant R [J/(mol K)].
    xp : array module, default np
        Array namespace module (numpy or jax.numpy).
    activation_energy : float, optional
        Zero-pressure activation energy E_a [J/mol] for the saturating integral
        law. When None (default), uses the homologous law.
    activation_volume : float, optional
        Zero-pressure activation volume V_0 [m^3/mol] for the saturating integral
        law. Requires ``activation_energy`` to be set when non-zero.
    activation_volume_decay_pressure : float, optional
        Characteristic decay pressure P_decay [Pa] (> 0, finite or +inf) for the
        saturating integral law. Requires ``activation_energy`` to be set when finite.

    Returns
    -------
    float or array-like
        Activation enthalpy H(P) [J/mol].

    Raises
    ------
    ValueError
        If scalar arguments are non-scalar; if any input is non-real; if
        ``activation_volume`` or finite ``activation_volume_decay_pressure`` is
        given when ``activation_energy`` is None; or, on the eager NumPy path,
        if any parameter lies outside its valid domain. On the JAX path,
        out-of-range numeric values return ``NaN``.
    """
    _require_x64_if_jax(xp)
    if pressure is None:
        raise ValueError('pressure must be a real number or array, got None')
    if activation_energy is None:
        if activation_volume is not None and activation_volume != 0.0:
            raise ValueError('activation_volume requires activation_energy to be set')
        if activation_volume_decay_pressure is not None:
            if (
                _is_non_real(activation_volume_decay_pressure)
                or np.ndim(activation_volume_decay_pressure) > 0
                or not (
                    math.isinf(float(activation_volume_decay_pressure))
                    and float(activation_volume_decay_pressure) > 0.0
                )
            ):
                raise ValueError(
                    'activation_volume_decay_pressure requires activation_energy to be set'
                )
        g_hom_eff = SolidRheologyParams.g_homologous if g_homologous is None else g_homologous
        dt_sol_dp_eff = SolidRheologyParams.dt_sol_dp if dt_sol_dp is None else dt_sol_dp
        t_sol_0_eff = SolidRheologyParams.t_sol_0 if t_sol_0 is None else t_sol_0
        invalid = _validate_inputs(
            (
                ('pressure', pressure, 'pressure', False),
                ('g_homologous', g_hom_eff, 'nonneg', True),
                ('solidus_temperature', solidus_temperature, 'pos', False),
                ('t_sol_0', t_sol_0_eff, 'pos', True),
                ('dt_sol_dp', dt_sol_dp_eff, 'nonneg', True),
                ('r_gas', r_gas, 'pos', True),
            ),
            xp,
        )
        h = _compute_arrhenius_enthalpy_core(
            pressure=pressure,
            g_homologous=g_hom_eff,
            solidus_temperature=solidus_temperature,
            t_sol_0=t_sol_0_eff,
            dt_sol_dp=dt_sol_dp_eff,
            r_gas=r_gas,
            xp=xp,
        )
        return _unwrap_scalar(xp.where(invalid, xp.nan, h), xp, pressure, solidus_temperature)

    v_eff = (
        SolidRheologyParams.activation_volume
        if activation_volume is None
        else activation_volume
    )
    p_dec_eff = (
        SolidRheologyParams.activation_volume_decay_pressure
        if activation_volume_decay_pressure is None
        else activation_volume_decay_pressure
    )
    invalid = _validate_inputs(
        (
            ('pressure', pressure, 'pressure', False),
            ('activation_energy', activation_energy, 'nonneg', True),
            ('activation_volume', v_eff, 'nonneg', True),
            ('activation_volume_decay_pressure', p_dec_eff, 'pos_or_inf', True),
            ('solidus_temperature', solidus_temperature, 'pos', False),
            ('r_gas', r_gas, 'pos', True),
        ),
        xp,
    )
    h = _compute_arrhenius_enthalpy_core(
        pressure=pressure,
        r_gas=r_gas,
        xp=xp,
        activation_energy=activation_energy,
        activation_volume=v_eff,
        activation_volume_decay_pressure=p_dec_eff,
    )
    return _unwrap_scalar(xp.where(invalid, xp.nan, h), xp, pressure, solidus_temperature)

compute_arrhenius_viscosity(temperature, pressure, viscosity_solid=None, g_homologous=None, solidus_temperature=None, t_sol_0=None, dt_sol_dp=None, arrhenius_t_ref=None, r_gas=R_GAS, viscosity_max_log10=None, water_prefactor=None, xp=np, *, activation_energy=None, activation_volume=None, activation_volume_decay_pressure=None)

Compute temperature- and pressure-dependent Arrhenius diffusion-creep viscosity.

.. math:: \eta_\mathrm{diff}(T, P) = \eta_0 f_\mathrm{water} \exp\left( \frac{H(P)}{R T} - \frac{H(0)}{R T_\mathrm{ref}} \right)

where :math:H(P) = g_\mathrm{hom} R T_\mathrm{sol}(P) when activation_energy is None (default) and :math:H(P) = E_a + V_0 P_\mathrm{decay} (1 - \exp(-P / P_\mathrm{decay})) when activation_energy is set. Note that the published secant-form parameter sets of Tackley et al. (2013, Table 2) for :math:E_0 + P V_0 \exp(-P / P_\mathrm{decay}) are not parameter sets of the integral law.

Parameters:

Name Type Description Default
temperature float or array - like

Temperature T [K].

required
pressure float or array - like

Pressure P [Pa] (non-negative; negative round-off excursions down to -PRESSURE_ROUNDOFF_TOLERANCE = -1.0 Pa are clamped to 0.0 Pa).

required
viscosity_solid float

Reference solid-state dynamic viscosity eta_0 [Pa s] at (T_ref, P=0) on the linear solidus t_sol_0 (since h_0 = g_hom * R * t_sol_0; with a table solidus T_sol,table(P), eta_diff(T_ref, 0) = viscosity_solid * f_water * exp(g_hom * (T_sol,table(0) - t_sol_0) / T_ref), which is 1.8459 * viscosity_solid for the CI test table with T_sol,table(0) = 1439.230032 K and t_sol_0 = 1400 K). Defaults to DEFAULT_VISCOSITY_SOLID (1.0e21) when None.

None
g_homologous float

Dimensionless homologous activation parameter g_hom [-]. Defaults to SolidRheologyParams.g_homologous when None. Not used when activation_energy is set.

None
solidus_temperature float or array - like

Local solidus temperature T_sol(P) [K]. When None, uses the linear fallback t_sol_0 + dt_sol_dp * P. Not used when activation_energy is set.

None
t_sol_0 float

Zero-pressure reference solidus temperature T_sol,0 [K] setting the reference activation enthalpy h_0 = g_hom * R * t_sol_0 in both table-solidus and linear-fallback modes (and the zero-pressure intercept of the linear fallback when solidus_temperature is None). Required when solidus_temperature is provided and activation_energy is None; defaults to SolidRheologyParams.t_sol_0 for the linear fallback. Not used when activation_energy is set.

None
dt_sol_dp float

Linear solidus slope dT_sol/dP [K/Pa] for the linear fallback. Defaults to SolidRheologyParams.dt_sol_dp when None. Not used when activation_energy is set.

None
arrhenius_t_ref float

Reference temperature T_ref [K]. Defaults to SolidRheologyParams.arrhenius_t_ref when None.

None
r_gas float

Universal gas constant R [J/(mol K)].

8.314462618
viscosity_max_log10 float

Smooth log10 softplus ceiling on dynamic viscosity [log10(Pa s)] with width VISCOSITY_CEILING_LOG10_WIDTH (0.05). Defaults to SolidRheologyParams.viscosity_max_log10 when None.

None
water_prefactor float or array - like

Multiplicative prefactor for hydration weakening. Defaults to SolidRheologyParams.water_prefactor when None. Must be positive; values <= 0 raise ValueError when xp is np and return NaN on the JAX path for JIT compatibility.

None
xp array module

Array namespace module (numpy or jax.numpy).

np
activation_energy float

Zero-pressure activation energy E_a [J/mol] for the saturating integral law.

None
activation_volume float

Zero-pressure activation volume V_0 [m^3/mol] for the saturating integral law.

None
activation_volume_decay_pressure float

Characteristic decay pressure P_decay [Pa] (> 0, finite or +inf) for the saturating integral law.

None

Returns:

Type Description
float or array - like

Dynamic diffusion creep viscosity eta_diff [Pa s].

Raises:

Type Description
ValueError

If solidus_temperature is provided without t_sol_0 when activation_energy is None; if scalar parameters are non-scalar; if any input is non-real; or, on the eager NumPy path (xp is np), if any parameter lies outside its valid domain. On the JAX path, out-of-range numeric values return NaN.

Source code in src/aragog/rheology.py
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
def compute_arrhenius_viscosity(
    temperature: FloatOrArray,
    pressure: FloatOrArray,
    viscosity_solid: float | None = None,
    g_homologous: float | None = None,
    solidus_temperature: FloatOrArray | None = None,
    t_sol_0: float | None = None,
    dt_sol_dp: float | None = None,
    arrhenius_t_ref: float | None = None,
    r_gas: float = R_GAS,
    viscosity_max_log10: float | None = None,
    water_prefactor: FloatOrArray | None = None,
    xp: Any = np,
    *,
    activation_energy: float | None = None,
    activation_volume: float | None = None,
    activation_volume_decay_pressure: float | None = None,
) -> FloatOrArray:
    r"""Compute temperature- and pressure-dependent Arrhenius diffusion-creep viscosity.

    .. math::
        \eta_\mathrm{diff}(T, P) = \eta_0 f_\mathrm{water} \exp\left(
            \frac{H(P)}{R T} - \frac{H(0)}{R T_\mathrm{ref}}
        \right)

    where :math:`H(P) = g_\mathrm{hom} R T_\mathrm{sol}(P)` when
    ``activation_energy`` is ``None`` (default) and
    :math:`H(P) = E_a + V_0 P_\mathrm{decay} (1 - \exp(-P / P_\mathrm{decay}))`
    when ``activation_energy`` is set. Note that the published secant-form
    parameter sets of Tackley et al. (2013, Table 2) for
    :math:`E_0 + P V_0 \exp(-P / P_\mathrm{decay})` are not parameter sets of
    the integral law.

    Parameters
    ----------
    temperature : float or array-like
        Temperature T [K].
    pressure : float or array-like
        Pressure P [Pa] (non-negative; negative round-off excursions down to
        ``-PRESSURE_ROUNDOFF_TOLERANCE`` = -1.0 Pa are clamped to 0.0 Pa).
    viscosity_solid : float, optional
        Reference solid-state dynamic viscosity eta_0 [Pa s] at ``(T_ref, P=0)``
        on the linear solidus ``t_sol_0`` (since ``h_0 = g_hom * R * t_sol_0``;
        with a table solidus ``T_sol,table(P)``,
        ``eta_diff(T_ref, 0) = viscosity_solid * f_water * exp(g_hom * (T_sol,table(0) - t_sol_0) / T_ref)``,
        which is ``1.8459 * viscosity_solid`` for the CI test table with
        ``T_sol,table(0) = 1439.230032 K`` and ``t_sol_0 = 1400 K``).
        Defaults to ``DEFAULT_VISCOSITY_SOLID`` (1.0e21) when None.
    g_homologous : float, optional
        Dimensionless homologous activation parameter g_hom [-]. Defaults to
        ``SolidRheologyParams.g_homologous`` when None. Not used when
        ``activation_energy`` is set.
    solidus_temperature : float or array-like, optional
        Local solidus temperature T_sol(P) [K]. When None, uses the linear fallback
        ``t_sol_0 + dt_sol_dp * P``. Not used when ``activation_energy`` is set.
    t_sol_0 : float, optional
        Zero-pressure reference solidus temperature ``T_sol,0`` [K] setting the
        reference activation enthalpy ``h_0 = g_hom * R * t_sol_0`` in both
        table-solidus and linear-fallback modes (and the zero-pressure intercept
        of the linear fallback when ``solidus_temperature`` is None). Required
        when ``solidus_temperature`` is provided and ``activation_energy`` is None;
        defaults to ``SolidRheologyParams.t_sol_0`` for the linear fallback. Not
        used when ``activation_energy`` is set.
    dt_sol_dp : float, optional
        Linear solidus slope dT_sol/dP [K/Pa] for the linear fallback. Defaults to
        ``SolidRheologyParams.dt_sol_dp`` when None. Not used when
        ``activation_energy`` is set.
    arrhenius_t_ref : float, optional
        Reference temperature T_ref [K]. Defaults to
        ``SolidRheologyParams.arrhenius_t_ref`` when None.
    r_gas : float, default 8.314462618
        Universal gas constant R [J/(mol K)].
    viscosity_max_log10 : float, optional
        Smooth log10 softplus ceiling on dynamic viscosity [log10(Pa s)] with
        width ``VISCOSITY_CEILING_LOG10_WIDTH`` (0.05). Defaults to
        ``SolidRheologyParams.viscosity_max_log10`` when None.
    water_prefactor : float or array-like, optional
        Multiplicative prefactor for hydration weakening. Defaults to
        ``SolidRheologyParams.water_prefactor`` when None. Must be positive;
        values ``<= 0`` raise ``ValueError`` when ``xp is np`` and return ``NaN``
        on the JAX path for JIT compatibility.
    xp : array module, default np
        Array namespace module (numpy or jax.numpy).
    activation_energy : float, optional
        Zero-pressure activation energy E_a [J/mol] for the saturating integral law.
    activation_volume : float, optional
        Zero-pressure activation volume V_0 [m^3/mol] for the saturating integral law.
    activation_volume_decay_pressure : float, optional
        Characteristic decay pressure P_decay [Pa] (> 0, finite or +inf) for the
        saturating integral law.

    Returns
    -------
    float or array-like
        Dynamic diffusion creep viscosity eta_diff [Pa s].

    Raises
    ------
    ValueError
        If ``solidus_temperature`` is provided without ``t_sol_0`` when
        ``activation_energy`` is None; if scalar parameters are non-scalar; if
        any input is non-real; or, on the eager NumPy path (``xp is np``), if
        any parameter lies outside its valid domain. On the JAX path,
        out-of-range numeric values return ``NaN``.
    """
    _require_x64_if_jax(xp)
    if temperature is None:
        raise ValueError('temperature must be a real number or array, got None')
    if pressure is None:
        raise ValueError('pressure must be a real number or array, got None')
    vs_eff = DEFAULT_VISCOSITY_SOLID if viscosity_solid is None else viscosity_solid
    g_hom_eff = SolidRheologyParams.g_homologous if g_homologous is None else g_homologous
    dt_sol_dp_eff = SolidRheologyParams.dt_sol_dp if dt_sol_dp is None else dt_sol_dp
    t_ref_eff = (
        SolidRheologyParams.arrhenius_t_ref if arrhenius_t_ref is None else arrhenius_t_ref
    )
    vmax_eff = (
        SolidRheologyParams.viscosity_max_log10
        if viscosity_max_log10 is None
        else viscosity_max_log10
    )
    wp_eff = SolidRheologyParams.water_prefactor if water_prefactor is None else water_prefactor
    if activation_energy is None and solidus_temperature is not None and t_sol_0 is None:
        raise ValueError('t_sol_0 must be provided when solidus_temperature is given')

    t_sol_ref_0 = SolidRheologyParams.t_sol_0 if t_sol_0 is None else t_sol_0
    invalid = _validate_inputs(
        (
            ('temperature', temperature, 'pos', False),
            ('viscosity_solid', vs_eff, 'pos', True),
            ('arrhenius_t_ref', t_ref_eff, 'pos', True),
            ('viscosity_max_log10', vmax_eff, 'vmax_scalar', True),
            ('water_prefactor', wp_eff, 'pos', False),
        ),
        xp,
    )
    invalid = invalid | _vmax_not_above_log10_viscosity(vs_eff, vmax_eff, xp)
    h_p = compute_arrhenius_enthalpy(
        pressure=pressure,
        g_homologous=g_hom_eff,
        solidus_temperature=solidus_temperature,
        t_sol_0=t_sol_ref_0,
        dt_sol_dp=dt_sol_dp_eff,
        r_gas=r_gas,
        xp=xp,
        activation_energy=activation_energy,
        activation_volume=activation_volume,
        activation_volume_decay_pressure=activation_volume_decay_pressure,
    )
    result = _compute_arrhenius_viscosity_core(
        temperature=temperature,
        pressure=pressure,
        viscosity_solid=vs_eff,
        g_homologous=g_hom_eff,
        solidus_temperature=solidus_temperature,
        t_sol_0=t_sol_ref_0,
        dt_sol_dp=dt_sol_dp_eff,
        arrhenius_t_ref=t_ref_eff,
        r_gas=r_gas,
        viscosity_max_log10=vmax_eff,
        water_prefactor=wp_eff,
        xp=xp,
        activation_energy=activation_energy,
        activation_volume=activation_volume,
        activation_volume_decay_pressure=activation_volume_decay_pressure,
        _precomputed_enthalpy=h_p,
    )
    result = xp.where(invalid | xp.isnan(h_p), xp.nan, result)
    return _unwrap_scalar(
        result, xp, temperature, pressure, water_prefactor, solidus_temperature
    )

compute_mlt_top_slope(theta, s_top_inf=None, c_theta=None, xp=np)

Evaluate viscosity-contrast-dependent upper mixing-length slope.

.. math:: s_\mathrm{top}(\theta) = s_{\mathrm{top},\infty} + (1 - s_{\mathrm{top},\infty}) \exp(-c_\theta \max(\theta, 0))

Parameters:

Name Type Description Default
theta float or array - like

Frank-Kamenetskii viscosity contrast parameter [-].

required
s_top_inf float

Asymptotic upper mixing-length slope in the stagnant-lid limit [-]. Defaults to SolidRheologyParams.s_top_inf.

None
c_theta float

Exponential decay rate with respect to theta [-]. Defaults to SolidRheologyParams.c_theta.

None
xp module

Array namespace (numpy or jax.numpy).

np

Returns:

Type Description
float or array - like

Upper mixing-length slope s_top(theta) [-].

Raises:

Type Description
ValueError

If theta is None. If s_top_inf is not in (0, 1] or c_theta is negative on NumPy.

Source code in src/aragog/rheology.py
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
def compute_mlt_top_slope(
    theta: FloatOrArray,
    s_top_inf: float | None = None,
    c_theta: float | None = None,
    xp: Any = np,
) -> FloatOrArray:
    r"""Evaluate viscosity-contrast-dependent upper mixing-length slope.

    .. math::
        s_\mathrm{top}(\theta) = s_{\mathrm{top},\infty}
            + (1 - s_{\mathrm{top},\infty}) \exp(-c_\theta \max(\theta, 0))

    Parameters
    ----------
    theta : float or array-like
        Frank-Kamenetskii viscosity contrast parameter [-].
    s_top_inf : float, optional
        Asymptotic upper mixing-length slope in the stagnant-lid limit [-].
        Defaults to ``SolidRheologyParams.s_top_inf``.
    c_theta : float, optional
        Exponential decay rate with respect to theta [-].
        Defaults to ``SolidRheologyParams.c_theta``.
    xp : module, default np
        Array namespace (numpy or jax.numpy).

    Returns
    -------
    float or array-like
        Upper mixing-length slope s_top(theta) [-].

    Raises
    ------
    ValueError
        If ``theta`` is None.
        If ``s_top_inf`` is not in ``(0, 1]`` or ``c_theta`` is negative on NumPy.
    """
    _require_x64_if_jax(xp)
    if theta is None:
        raise ValueError('theta must be a real number or array, got None')
    s_top_inf_eff = SolidRheologyParams.s_top_inf if s_top_inf is None else s_top_inf
    c_theta_eff = SolidRheologyParams.c_theta if c_theta is None else c_theta
    invalid = _validate_inputs(
        (
            ('theta', theta, 'finite', False),
            ('s_top_inf', s_top_inf_eff, 'half_open_unit', True),
            ('c_theta', c_theta_eff, 'nonneg', True),
        ),
        xp,
    )
    s_top = _compute_mlt_top_slope_core(
        theta, s_top_inf=s_top_inf_eff, c_theta=c_theta_eff, xp=xp
    )
    s_top = xp.where(invalid, xp.nan, s_top)
    return _unwrap_scalar(s_top, xp, theta)

compute_strain_rate_local(viscous_velocity, mixing_length, eps=1e-15, xp=np)

Compute local convective strain rate from MLT state variables.

.. math:: \dot{\epsilon}\mathrm{local} = \frac{|v|}{2 \max(l\mathrm{mix}, \epsilon)}

Parameters:

Name Type Description Default
viscous_velocity float or array - like

Convective / viscous velocity v [m/s].

required
mixing_length float or array - like

Mixing length l_mix [m].

required
eps float

Denominator floor to prevent division by zero.

1.0e-15
xp array module

Array namespace module (numpy or jax.numpy).

np

Returns:

Type Description
float or array - like

Local strain rate [1/s].

Raises:

Type Description
ValueError

If viscous_velocity or mixing_length is None. If mixing_length is negative or infinite on NumPy.

Source code in src/aragog/rheology.py
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
def compute_strain_rate_local(
    viscous_velocity: FloatOrArray,
    mixing_length: FloatOrArray,
    eps: float = 1.0e-15,
    xp: Any = np,
) -> FloatOrArray:
    r"""Compute local convective strain rate from MLT state variables.

    .. math::
        \dot{\epsilon}_\mathrm{local} = \frac{|v|}{2 \max(l_\mathrm{mix}, \epsilon)}

    Parameters
    ----------
    viscous_velocity : float or array-like
        Convective / viscous velocity v [m/s].
    mixing_length : float or array-like
        Mixing length l_mix [m].
    eps : float, default 1.0e-15
        Denominator floor to prevent division by zero.
    xp : array module, default np
        Array namespace module (numpy or jax.numpy).

    Returns
    -------
    float or array-like
        Local strain rate [1/s].

    Raises
    ------
    ValueError
        If ``viscous_velocity`` or ``mixing_length`` is None.
        If ``mixing_length`` is negative or infinite on NumPy.
    """
    _require_x64_if_jax(xp)
    if viscous_velocity is None:
        raise ValueError('viscous_velocity must be a real number or array, got None')
    if mixing_length is None:
        raise ValueError('mixing_length must be a real number or array, got None')
    invalid = _validate_inputs(
        (
            ('viscous_velocity', viscous_velocity, 'finite', False),
            ('mixing_length', mixing_length, 'nonneg', False),
            ('eps', eps, 'pos', True),
        ),
        xp,
    )
    res = _compute_strain_rate_local_core(viscous_velocity, mixing_length, eps=eps, xp=xp)
    res = xp.where(invalid, xp.nan, res)
    return _unwrap_scalar(res, xp, viscous_velocity, mixing_length)

compute_yield_stress(pressure, yield_stress_c=None, yield_stress_mu=None, yield_stress_max=None, xp=np)

Compute Byerlee frictional yield stress.

.. math:: \tau_y(P) = \max(0, \min(c + \mu P, \tau_\mathrm{max}))

Parameters:

Name Type Description Default
pressure float or array - like

Pressure P [Pa] (non-negative; negative round-off excursions down to -PRESSURE_ROUNDOFF_TOLERANCE = -1.0 Pa are clamped to 0.0 Pa).

required
yield_stress_c float

Cohesion c [Pa]. Defaults to SolidRheologyParams.yield_stress_c when None.

None
yield_stress_mu float

Friction coefficient mu [-]. Defaults to SolidRheologyParams.yield_stress_mu when None.

None
yield_stress_max float

Maximum yield stress ceiling [Pa]. Defaults to SolidRheologyParams.yield_stress_max when None.

None
xp array module

Array namespace module (numpy or jax.numpy).

np

Returns:

Type Description
float or array - like

Yield stress tau_y [Pa].

Raises:

Type Description
ValueError

If yield_stress_c, yield_stress_mu, or yield_stress_max is not a scalar; if any input is non-real; or, on the eager NumPy path (xp is np), if pressure is below -PRESSURE_ROUNDOFF_TOLERANCE (-1.0 Pa) or infinite, if yield_stress_c or yield_stress_mu is negative or infinite, or if yield_stress_max is non-positive or infinite. On the JAX path, out-of-range numeric values return NaN.

Source code in src/aragog/rheology.py
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
def compute_yield_stress(
    pressure: FloatOrArray,
    yield_stress_c: float | None = None,
    yield_stress_mu: float | None = None,
    yield_stress_max: float | None = None,
    xp: Any = np,
) -> FloatOrArray:
    r"""Compute Byerlee frictional yield stress.

    .. math::
        \tau_y(P) = \max(0, \min(c + \mu P, \tau_\mathrm{max}))

    Parameters
    ----------
    pressure : float or array-like
        Pressure P [Pa] (non-negative; negative round-off excursions down to
        ``-PRESSURE_ROUNDOFF_TOLERANCE`` = -1.0 Pa are clamped to 0.0 Pa).
    yield_stress_c : float, optional
        Cohesion c [Pa]. Defaults to ``SolidRheologyParams.yield_stress_c`` when None.
    yield_stress_mu : float, optional
        Friction coefficient mu [-]. Defaults to
        ``SolidRheologyParams.yield_stress_mu`` when None.
    yield_stress_max : float, optional
        Maximum yield stress ceiling [Pa]. Defaults to
        ``SolidRheologyParams.yield_stress_max`` when None.
    xp : array module, default np
        Array namespace module (numpy or jax.numpy).

    Returns
    -------
    float or array-like
        Yield stress tau_y [Pa].

    Raises
    ------
    ValueError
        If ``yield_stress_c``, ``yield_stress_mu``, or ``yield_stress_max`` is
        not a scalar; if any input is non-real; or, on the eager NumPy path
        (``xp is np``), if ``pressure`` is below ``-PRESSURE_ROUNDOFF_TOLERANCE``
        (-1.0 Pa) or infinite, if ``yield_stress_c`` or ``yield_stress_mu`` is
        negative or infinite, or if ``yield_stress_max`` is non-positive or
        infinite. On the JAX path, out-of-range numeric values return ``NaN``.
    """
    _require_x64_if_jax(xp)
    if pressure is None:
        raise ValueError('pressure must be a real number or array, got None')
    c_eff = SolidRheologyParams.yield_stress_c if yield_stress_c is None else yield_stress_c
    mu_eff = SolidRheologyParams.yield_stress_mu if yield_stress_mu is None else yield_stress_mu
    max_eff = (
        SolidRheologyParams.yield_stress_max if yield_stress_max is None else yield_stress_max
    )
    invalid = _validate_inputs(
        (
            ('pressure', pressure, 'pressure', False),
            ('yield_stress_c', c_eff, 'nonneg', True),
            ('yield_stress_mu', mu_eff, 'nonneg', True),
            ('yield_stress_max', max_eff, 'pos', True),
        ),
        xp,
    )
    tau_y = _compute_yield_stress_core(
        pressure,
        yield_stress_c=c_eff,
        yield_stress_mu=mu_eff,
        yield_stress_max=max_eff,
        xp=xp,
    )
    return _unwrap_scalar(xp.where(invalid, xp.nan, tau_y), xp, pressure)

delegate_rheology(cls)

Expose :class:SolidRheologyParams fields as read-only properties reading self.rheology.

Parameters:

Name Type Description Default
cls type

Target class holding a rheology attribute of type :class:SolidRheologyParams.

required

Returns:

Type Description
type

The decorated class cls with one read-only property per field of :class:SolidRheologyParams.

Source code in src/aragog/rheology.py
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
def delegate_rheology(cls):
    """Expose :class:`SolidRheologyParams` fields as read-only properties reading ``self.rheology``.

    Parameters
    ----------
    cls : type
        Target class holding a ``rheology`` attribute of type
        :class:`SolidRheologyParams`.

    Returns
    -------
    type
        The decorated class ``cls`` with one read-only property per field of
        :class:`SolidRheologyParams`.
    """
    for f in fields(SolidRheologyParams):
        setattr(cls, f.name, property(lambda self, n=f.name: getattr(self.rheology, n)))
    return cls

merge_rheology(rheology, overrides)

Return rheology (default parameters when None) with field overrides applied.

Parameters:

Name Type Description Default
rheology SolidRheologyParams or Mapping[str, Any] or None

Base rheology parameter set, mapping of field values, or None for default :class:SolidRheologyParams.

required
overrides Mapping[str, Any]

Mapping of :class:SolidRheologyParams field names to replacement values within the valid parameter bounds of :class:SolidRheologyParams.

required

Returns:

Type Description
SolidRheologyParams

Validated rheology parameter set with overrides applied.

Raises:

Type Description
TypeError

If rheology is not a :class:SolidRheologyParams, a mapping or None.

(TypeError, ValueError)

If any field in rheology or overrides violates the type or range constraints of :class:SolidRheologyParams.

Source code in src/aragog/rheology.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
def merge_rheology(
    rheology: SolidRheologyParams | Mapping[str, Any] | None, overrides: Mapping[str, Any]
) -> SolidRheologyParams:
    """Return ``rheology`` (default parameters when None) with field ``overrides`` applied.

    Parameters
    ----------
    rheology : SolidRheologyParams or Mapping[str, Any] or None
        Base rheology parameter set, mapping of field values, or ``None`` for
        default :class:`SolidRheologyParams`.
    overrides : Mapping[str, Any]
        Mapping of :class:`SolidRheologyParams` field names to replacement values
        within the valid parameter bounds of :class:`SolidRheologyParams`.

    Returns
    -------
    SolidRheologyParams
        Validated rheology parameter set with ``overrides`` applied.

    Raises
    ------
    TypeError
        If ``rheology`` is not a :class:`SolidRheologyParams`, a mapping or None.
    TypeError, ValueError
        If any field in ``rheology`` or ``overrides`` violates the type or range
        constraints of :class:`SolidRheologyParams`.
    """
    if isinstance(rheology, Mapping):
        base = SolidRheologyParams(**rheology)
    elif rheology is None:
        base = SolidRheologyParams()
    elif isinstance(rheology, SolidRheologyParams):
        base = rheology
    else:
        raise TypeError(
            'rheology must be a table of SolidRheologyParams fields, a SolidRheologyParams '
            f'or None, got {type(rheology).__name__} ({rheology!r})'
        )
    return replace(base, **overrides) if overrides else base

viscous_mixing_length_factor(radii, r_in, r_out, mixing_length, s_top_inf=None, bottom_slope=None, theta=None, c_theta=None, *, xp=np)

Factor (l_v / l)^4 on the viscous MLT eddy diffusivity for the calibrated length.

The viscous eddy diffusivity scales as l^4 and the viscous convective velocity scales as l^3, so with l_v = min(bottom_slope (r - r_in), s_top(theta) (r_out - r)) (Wagner et al. 2019, eq. 11, written with the two boundary slopes) the diffusivity is multiplied by (l_v / l)^4 and the viscous velocity by (l_v / l)^3; the inviscid branch keeps l. When theta is provided, the upper slope is evaluated via :func:compute_mlt_top_slope.

Parameters:

Name Type Description Default
radii array

Basic-node radii [m].

required
r_in float

Inner and outer radius of the mantle [m].

required
r_out float

Inner and outer radius of the mantle [m].

required
mixing_length array

Abe mixing length l at the basic nodes [m].

required
s_top_inf float

Upper mixing-length slope at the surface when theta is None, or asymptotic upper slope in the stagnant-lid limit when theta is provided [-]. Defaults to SolidRheologyParams.s_top_inf when None.

None
bottom_slope float

Lower mixing-length slope at the CMB [-]. Defaults to SolidRheologyParams.mlt_bottom_slope when None.

None
theta float or array - like

Frank-Kamenetskii viscosity contrast parameter [-]. When provided, evaluates the upper slope via :func:compute_mlt_top_slope.

None
c_theta float

Exponential decay rate with respect to theta [-]. Defaults to SolidRheologyParams.c_theta when None.

None
xp module

Array namespace (keyword-only).

np

Returns:

Type Description
array

(l_v / l)^4, and 1 where l is 0 (the boundary nodes).

Raises:

Type Description
ValueError

If radii, r_in, r_out, or mixing_length is None. If r_in >= r_out or any finite radius lies outside [r_in, r_out] beyond tolerance max(1 m, 1e-9 * (r_out - r_in)) on NumPy. If c_theta is negative. On JAX (xp is jnp), domain violations evaluate the profile to NaN.

Source code in src/aragog/rheology.py
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
def viscous_mixing_length_factor(
    radii: Any,
    r_in: Any,
    r_out: Any,
    mixing_length: Any,
    s_top_inf: float | None = None,
    bottom_slope: float | None = None,
    theta: Any = None,
    c_theta: float | None = None,
    *,
    xp: Any = np,
) -> Any:
    r"""Factor ``(l_v / l)^4`` on the viscous MLT eddy diffusivity for the calibrated length.

    The viscous eddy diffusivity scales as ``l^4`` and the viscous convective
    velocity scales as ``l^3``, so with
    ``l_v = min(bottom_slope (r - r_in), s_top(theta) (r_out - r))`` (Wagner et al.
    2019, eq. 11, written with the two boundary slopes) the diffusivity is
    multiplied by ``(l_v / l)^4`` and the viscous velocity by ``(l_v / l)^3``;
    the inviscid branch keeps ``l``. When ``theta`` is provided, the upper slope
    is evaluated via :func:`compute_mlt_top_slope`.

    Parameters
    ----------
    radii : array
        Basic-node radii [m].
    r_in, r_out : float
        Inner and outer radius of the mantle [m].
    mixing_length : array
        Abe mixing length ``l`` at the basic nodes [m].
    s_top_inf : float, optional
        Upper mixing-length slope at the surface when ``theta`` is None, or asymptotic
        upper slope in the stagnant-lid limit when ``theta`` is provided [-].
        Defaults to ``SolidRheologyParams.s_top_inf`` when None.
    bottom_slope : float, optional
        Lower mixing-length slope at the CMB [-]. Defaults to
        ``SolidRheologyParams.mlt_bottom_slope`` when None.
    theta : float or array-like, optional
        Frank-Kamenetskii viscosity contrast parameter [-]. When provided, evaluates
        the upper slope via :func:`compute_mlt_top_slope`.
    c_theta : float, optional
        Exponential decay rate with respect to ``theta`` [-]. Defaults to
        ``SolidRheologyParams.c_theta`` when None.
    xp : module, default np
        Array namespace (keyword-only).

    Returns
    -------
    array
        ``(l_v / l)^4``, and 1 where ``l`` is 0 (the boundary nodes).

    Raises
    ------
    ValueError
        If ``radii``, ``r_in``, ``r_out``, or ``mixing_length`` is None.
        If ``r_in >= r_out`` or any finite radius lies outside ``[r_in, r_out]``
        beyond tolerance ``max(1 m, 1e-9 * (r_out - r_in))`` on NumPy.
        If ``c_theta`` is negative.
        On JAX (``xp is jnp``), domain violations evaluate the profile to NaN.
    """
    _require_x64_if_jax(xp)
    if radii is None:
        raise ValueError('radii must be a real number or array, got None')
    if r_in is None:
        raise ValueError('r_in must be a real number or array, got None')
    if r_out is None:
        raise ValueError('r_out must be a real number or array, got None')
    if mixing_length is None:
        raise ValueError('mixing_length must be a real number or array, got None')
    s_top_inf_eff = SolidRheologyParams.s_top_inf if s_top_inf is None else s_top_inf
    bottom_slope_eff = (
        SolidRheologyParams.mlt_bottom_slope if bottom_slope is None else bottom_slope
    )
    c_theta_eff = SolidRheologyParams.c_theta if c_theta is None else c_theta
    invalid = _validate_inputs(
        (
            ('radii', radii, 'finite', False),
            ('r_in', r_in, 'pos', True),
            ('r_out', r_out, 'pos', True),
            ('mixing_length', mixing_length, 'nonneg', False),
            ('s_top_inf', s_top_inf_eff, 'half_open_unit', True),
            ('bottom_slope', bottom_slope_eff, 'half_open_unit', True),
            ('c_theta', c_theta_eff, 'nonneg', True),
        ),
        xp,
    )
    r_arr = xp.asarray(radii, dtype=float)
    rin_val = xp.asarray(r_in, dtype=float)
    rout_val = xp.asarray(r_out, dtype=float)
    if xp is np:
        rin_finite = np.isfinite(rin_val)
        rout_finite = np.isfinite(rout_val)
        if rin_finite and rout_finite and float(rin_val) >= float(rout_val):
            raise ValueError(
                f'r_in must be strictly less than r_out, got r_in={r_in}, r_out={r_out}'
            )
        if rin_finite and rout_finite:
            tol = max(1.0, 1.0e-9 * (float(rout_val) - float(rin_val)))
            if np.any((r_arr < float(rin_val) - tol) | (r_arr > float(rout_val) + tol)):
                raise ValueError(
                    f'radii must lie within [r_in, r_out], got radii outside [{r_in}, {r_out}]'
                )
    else:
        tol = xp.maximum(1.0, 1.0e-9 * (rout_val - rin_val))
        domain_bad = (rin_val >= rout_val) | xp.any(
            (r_arr < rin_val - tol) | (r_arr > rout_val + tol)
        )
        invalid = invalid | domain_bad

    if theta is not None:
        eff_top_slope = compute_mlt_top_slope(
            theta, s_top_inf=s_top_inf_eff, c_theta=c_theta_eff, xp=xp
        )
        invalid = invalid | xp.isnan(eff_top_slope)
    else:
        eff_top_slope = s_top_inf_eff
    res = _viscous_mixing_length_factor_core(
        radii,
        r_in,
        r_out,
        mixing_length,
        s_top_inf=eff_top_slope,
        bottom_slope=bottom_slope_eff,
        theta=None,
        c_theta=c_theta_eff,
        xp=xp,
    )
    return xp.where(invalid, xp.nan, res)