Internals

Pyrolysis.Internal is an umbrella module that re-exports the public surface of every submodule for advanced users:

using Pyrolysis
using Pyrolysis.Internal   # brings in Geometry accessors, Solver helpers, …

These names are not part of the stable public API and may change between releases. The User Guide's import cheat-sheet maps common tasks to the right imports.

Solution post-processing (Pyrolysis.Solver)

Pyrolysis.Solver.get_profileFunction
get_profile(solution::PyrolysisSolution, field::Symbol, time_idx::Int)

Get a field profile at a specific saved time index.

Arguments

  • solution: The solution
  • field: :T for temperature, :ξ for all concentrations, or :ξ1, :ξ2, etc.
  • time_idx: Index into solution.t

Returns

Vector of values at cell centers.

source

Boundary temperatures (Pyrolysis.Discretization)

Solver callbacks and iterative solvers (Pyrolysis.Solver)

Pyrolysis.Solver.create_thickness_termination_callbackFunction
create_thickness_termination_callback(sv_ref, min_thickness) -> ContinuousCallback

Create a callback that terminates the simulation when thickness falls below threshold.

This is used with ALE StateLayouts where node positions are part of the state vector.

Arguments

  • sv_ref: Either a StateLayout directly, or a DepletionCallbackState (for shared reference)
  • min_thickness::Float64: Minimum allowed thickness [m]

Returns

A ContinuousCallback that terminates when thickness < min_thickness.

Notes

When used with depletion handling, pass a DepletionCallbackState so that the state vector descriptor is automatically updated when cells are merged.

source
Pyrolysis.Solver.create_depletion_callbackFunction
create_depletion_callback(ws, mesh, material, layout;
						  threshold=0.05, min_cells=2) -> DiscreteCallback

Create a callback that detects and handles thin cells.

This callback checks at each timestep whether ANY cell has shrunk below a threshold fraction of its initial thickness. When this occurs, the callback:

  1. Finds all thin cells, sorted by z-position (surface first)
  2. Merges the first thin cell with its best neighbor
  3. Resizes the workspace's caches
  4. Resizes the integrator's state vector using resize!(integrator, ...)
  5. Remaps the solution to the new mesh

Only ONE merge is performed per callback invocation to allow the ODE solver to adapt between merges.

This prevents numerical issues from extremely thin cells:

  • Very small timesteps (CFL condition scales with Δx²)
  • Extreme aspect ratios between cells
  • Numerical instabilities

Arguments

  • ws: Mutable Workspace being solved
  • mesh::Mesh1D: The mesh (will be modified during merges)
  • material: Material definition (used for energy-conserving merge)
  • layout::StateLayout: Initial state vector descriptor

Keyword Arguments

  • threshold::Float64=0.05: Thickness fraction threshold for depletion detection. Cell is considered depleted when current_thickness < threshold × its own initial thickness. Default 0.05 means cells are merged when shrunk to 5% of their original thickness.
  • min_cells::Int=2: Minimum number of cells before terminating instead of merging. When only min_cells remain, simulation terminates rather than merging.

Returns

A DiscreteCallback that handles cell depletion.

Notes

  • The callback uses resize!(integrator, new_length) to inform the ODE solver of the state vector size change
  • Works with the unified ALE workspace and state layout
  • The state vector descriptor in ws.layout is automatically updated
  • All cells (surface and interior) are monitored for depletion

Example

def = to_problem_def(problem; use_ale = true)
ws = build_workspace(problem, def)
u0 = create_state_vector(ws.layout, ws.mesh)
layout = ws.layout

# Merge cells when they shrink to 5% of original thickness
depletion_cb = create_depletion_callback(ws, mesh, material, layout;
										 threshold=0.05, min_cells=3)

prob = ODEProblem(ws, u0, tspan)
sol = solve(prob, Rodas5P(); callback=depletion_cb)
source
Pyrolysis.Solver.ILUGMRESFactorizationType
ILUGMRESFactorization(; τ=0.1, gmres_rtol=1e-8, restart=30)

ILU-preconditioned GMRES as a drop-in replacement for KLUFactorization().

Inherits LinearSolve.AbstractSparseFactorization so that OrdinaryDiffEq materializes the concrete sparse W = I/(γdt) - J matrix (rather than wrapping it in a matrix-free WOperator). The solve! method then builds an ILU(τ) preconditioner and solves with Krylov.jl's GMRES.

source
Pyrolysis.Solver.ILUBiCGSTABFactorizationType
ILUBiCGSTABFactorization(; τ=0.1, rtol=1e-8)

ILU-preconditioned BiCGSTAB as a drop-in replacement for SparspakFactorization(). Same approach as ILUGMRESFactorization but uses BiCGSTAB instead of GMRES. BiCGSTAB has fixed memory cost (no restart parameter) and can be faster for some matrix structures.

source