spectral_galerkin_heat.core.properties

Temperature-dependent material properties (expression branches + f_l blend).

Each property k(T), rho(T), c(T) is described by a solid-branch and a liquid-branch expression of T blended pointwise by the liquid fraction f_l(T) between the solidus and liquidus temperatures:

p(T) = (1 - f_l) * p_solid(T) + f_l * p_liquid(T)

This matches the reference 316L form used by the finite-element reference solver. The blended property is non-polynomial with slope kinks at T_S/T_L; this never enters the spectral scheme, because the weak-form property correction samples k and a but never differentiates them in T.

A plain scalar is also accepted (both branches collapse to the constant), so existing constant-property configs keep working unchanged.

Classes

TempProperty

A single temperature-dependent property with solid/liquid branch expressions.

MaterialModel

Aggregate of the temperature-dependent thermophysical properties.

Functions

liquid_fraction(T, T_solidus, T_liquidus)

Liquid fraction f_l(T) clamped to [0, 1].

Module Contents

spectral_galerkin_heat.core.properties.liquid_fraction(T, T_solidus, T_liquidus)

Liquid fraction f_l(T) clamped to [0, 1].

0 below the solidus, 1 above the liquidus, linear in between. When T_liquidus <= T_solidus (no mushy band configured) the ramp degenerates to a step at T_solidus.

class spectral_galerkin_heat.core.properties.TempProperty

A single temperature-dependent property with solid/liquid branch expressions.

Variables:
classmethod from_config(spec, T_solidus, T_liquidus)

Build a TempProperty from a config value.

Accepts:

  • a plain number, or a {value, unit} mapping → constant property;

  • a {solid: "<expr of T>", liquid: "<expr of T>"} mapping → branch expressions (a missing branch falls back to the other).

A branch mapping may also carry reference: (the constant k̄/ρ̄/C̄p, read by the material parser) and unit:. Both are ignored here.

Parameters:
  • spec (Any)

  • T_solidus (float)

  • T_liquidus (float)

Return type:

TempProperty

class spectral_galerkin_heat.core.properties.MaterialModel

Aggregate of the temperature-dependent thermophysical properties.

Bundles k(T), rho(T), c(T) and the derived volumetric sensible heat capacity a(T) = rho(T) * c(T). Used by the property-correction path of the spectral solver; None on a material with only scalar properties.

a(T)

Volumetric sensible heat capacity a(T) = rho(T) * c(T).

k_prime_a_prime(T, k_bar, a_bar)

Fluctuations (k(T) - k_bar, a(T) - a_bar) in a single fused pass.

latent_heat_source(T, T_prev, T_S, T_L, L_f, dt, out)

Latent-heat sink Q = -rho(T) L_f (f_l(T)-f_l(T_prev))/dt into out.

property is_constant: bool

True when every property is a single constant (null-correction path).

Return type:

bool

recommended_references(T_lo, T_hi, n_samples=512)

Recommended reference scalars over the working band [T_lo, T_hi].

The user supplies each T-dependent property’s reference constant explicitly, as a reference: key inside its config block. This helper only computes a recommendation for each: the midpoint of the property’s own extrema sampled across the range, ½(min p + max p). Centering every reference in the middle of its working range reduces the peak fluctuations and helps convergence.

Returns the recommended (k, rho, Cp) references.

Parameters:
  • T_lo (float)

  • T_hi (float)

  • n_samples (int)

classmethod from_config(mat_cfg, T_solidus, T_liquidus)

Build a MaterialModel from the material config section.

Returns None when none of k, rho, Cp is given as solid/liquid branch expressions, i.e. the material is fully constant. The solver then keeps its existing constant-coefficient path.

Parameters:
  • mat_cfg (dict)

  • T_solidus (float)

  • T_liquidus (float)

Return type:

Optional[MaterialModel]