src.spyice.models.stefan_problem#

This module provides analytical and semi-analytical solutions for the Stefan phase-change problem in one-dimensional sea ice systems.

Both:

  • One-phase Stefan formulation

  • Two-phase (solid–liquid) formulation

are implemented.

The solutions are primarily used for:

  • Model validation

  • Benchmarking numerical solvers

  • Comparing analytical and numerical ice growth

Mathematical Background#

The classical one-phase Stefan problem describes phase boundary motion governed by heat diffusion:

\[\frac{\partial T}{\partial t} = \alpha \frac{\partial^2 T}{\partial z^2}\]

with a moving boundary determined by the Stefan condition:

\[\rho L \frac{ds}{dt} = -k \frac{\partial T}{\partial z}\]

The analytical solution involves the similarity variable:

\[s(t) = 2 \lambda \sqrt{\alpha t}\]

where \(\lambda\) is obtained from a transcendental equation.

Class: StefanProblem#

class StefanProblem#

A utility class providing static methods to compute one-phase and two-phase Stefan solutions.

Static Methods#

stefan_problem#

static stefan_problem(t, ui)#

Compute the one-phase Stefan solution depth.

Parameters:
  • t (float) – Time.

  • ui (UserInput) – User input configuration.

Returns:

Ice thickness depth.

The solution uses a Newton method to determine the similarity parameter \(\lambda\).

calculate_temperature_profile#

static calculate_temperature_profile(depth_stefan, t, dz, nz, ui)#

Compute the temperature profile for the one-phase solution.

Parameters:
  • depth_stefan (float) – Ice thickness.

  • t (float) – Time.

  • dz (float) – Grid spacing.

  • nz (int) – Number of grid cells.

  • ui (UserInput) – User input configuration.

Returns:

Temperature array.

The profile is based on the error function solution:

\[T(z,t) = T_b - (T_b - T_m) \frac{\operatorname{erf}(z / 2\sqrt{\alpha t})} {\operatorname{erf}(s / 2\sqrt{\alpha t})}\]

calculate_temperature_twophase_profiles#

static calculate_temperature_twophase_profiles(depth_stefan, t, dz, nz, ui)#

Compute temperature and salinity profiles for the two-phase Stefan problem.

Parameters:
  • depth_stefan (float) – Interface position.

  • t (float) – Time.

  • dz (float) – Grid spacing.

  • nz (int) – Number of grid cells.

  • ui (UserInput) – User input configuration.

Returns:

Tuple of:

  • Temperature array

  • Salinity array

Uses complementary error functions for the liquid region.

stefan_problem_twophase#

static stefan_problem_twophase(t, ui)#

Compute the moving interface for a two-phase solid–liquid system.

Parameters:
  • t (float) – Time.

  • ui (UserInput) – User configuration.

Returns:

Interface depth.

The solution requires solving a nonlinear root problem via Newton iteration.

_plot_stefan_temp_twophase#

static _plot_stefan_temp_twophase(z_depth=0.5)#

Utility method for plotting temperature evolution at a specified depth.

Parameters:

z_depth (float) – Relative depth location.

Returns:

Temperature and salinity history arrays.

Intended for validation and debugging.

Dependencies#

  • numpy

  • scipy.optimize

  • scipy.special.erfc

  • matplotlib

  • spyice.parameters.user_input

Notes#

  • Newton iteration tolerance is set to moderate precision.

  • Analytical solutions assume constant thermophysical properties.

  • Two-phase formulation accounts for salinity depression of melting temperature.

  • Intended primarily for verification against the numerical solver.