spectral_galerkin_heat.solvers.spectral_cpu_linear

Spectral CPU Linear Solver Implementation.

Classes

SpectralSolverCPULinear

SpectralSolverCPULinear implements a strictly linear spectral method

Module Contents

class spectral_galerkin_heat.solvers.spectral_cpu_linear.SpectralSolverCPULinear(context=None)

Bases: spectral_galerkin_heat.solvers.base.HeatSolver

SpectralSolverCPULinear implements a strictly linear spectral method for solving the heat equation on the CPU.

It disables latent heat and evaporation, applying only the laser source. Useful for testing against exact linear analytical solutions.

Parameters:

context (spectral_galerkin_heat.core.parameters.SimulationContext | None)

initialize(context=None)

Set up the spectral solver state, allocate buffers, and set the initial condition.

Parameters:

context (SimulationContext, optional) – If provided, replaces the stored SimulationContext. By default None.

Returns:

The initialized solver state object containing grid buffers and spectra.

Return type:

spectral_galerkin_heat.physics.spectral_cpu_kernels.SpectralSolverState

Raises:

RuntimeError – If SimulationContext is neither provided here nor at construction.

step(t, dt)

Advance the spectral solution by one time step linearly.

Only the laser source is applied. No latent heat or evaporation.

Parameters:
  • t (float) – Current simulation time.

  • dt (float) – Time step size.

Returns:

SsStatespectral_galerkin_heat.physics.spectral_cpu_kernels.SpectralSolverState

The updated linear solver state.

metricsdict

Metrics from the iteration, such as max temperature and number of evaporation steps.

Return type:

tuple

set_state(temperature_field)

Overwrite the internal spectral coefficients from a spatial temperature field.

Parameters:

temperature_field (np.ndarray) – A 3-D array (shape (N_z, N_y, N_x)) containing temperatures.

Raises:

RuntimeError – If called before the solver is initialized.

Return type:

None

finalize()

Clean up CPU resources.

Return type:

None