Docs › Worked physics and service recipes › Heat transfer recipes
6.10 Heat transfer recipes
6.10.1 Enthalpy and liquid fraction during heating
Use specific enthalpy as the initial state and derive temperature and liquid fraction from the phase law. The mushy interval spreads the latent heat across a finite temperature range.
from onesim.physics.heat_transfer import PhaseChangeHeating, ThermalPhaseChangeLawSet
domain = LumpedDomain()
model = PhaseChangeHeating(
domain=domain.system,
mass=2,
heating_power=4,
phase_law=ThermalPhaseChangeLawSet("mushy", 300, 302, 4, 2, 3),
)
t, data = history_case(
domain,
model,
dict(specific_enthalpy=-2.0),
("specific_enthalpy", "temperature", "liquid_fraction"),
end=6,
dt=0.02,
)
np.testing.assert_allclose(data["specific_enthalpy"], -2 + 2 * t, atol=1e-10)
fig = history_plot("Enthalpy and liquid fraction during heating", model, t, data)
plt.show()

6.10.2 Advection and decay of a temperature wave
Use a periodic Fourier mode to distinguish phase transport from amplitude decay. The carrier here stores cell averages. The analytic curve includes the cell-average sinc factor.
from onesim.physics.heat_transfer import HeatAdvectionDiffusion
line = Line(start=(0, 0, 0), end=(1, 0, 0))
speed, diffusivity = 0.6, 0.02
model = HeatAdvectionDiffusion(
domain=line.line, velocity=speed, thermal_diffusivity=diffusivity
)
n, end = 64, 0.15
result = line_experiment(
line,
model,
dict(temperature=lambda x: 300 + 10 * np.cos(2 * np.pi * x)),
FiniteVolume(
convection=Rusanov(), reconstruction=MUSCL(), diffusion=TwoPointDiffusion()
),
cells=n,
end=end,
dt=0.0005,
)
exact = lambda x: 300 + 10 * np.sinc(1 / n) * np.exp(
-diffusivity * (2 * np.pi) ** 2 * end
) * np.cos(2 * np.pi * (x - speed * end))
field = result.field(model.temperature)
np.testing.assert_allclose(
field.values, exact(field.space.dof_coordinates[:, 0]), atol=0.06, rtol=0
)
fig = profile_figure(
"Periodic heat transport",
result,
model,
("temperature",),
reference={"temperature": exact},
)
plt.show()
