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_profile — Function
get_profile(solution::PyrolysisSolution, field::Symbol, time_idx::Int)Get a field profile at a specific saved time index.
Arguments
solution: The solutionfield: :T for temperature, :ξ for all concentrations, or :ξ1, :ξ2, etc.time_idx: Index into solution.t
Returns
Vector of values at cell centers.
Pyrolysis.Solver.get_cell_positions — Function
get_cell_positions(solution::PyrolysisSolution)Get cell center positions from the solution's mesh.
Pyrolysis.Solver.interpolate_solution — Function
interpolate_solution(solution::PyrolysisSolution, t::Real)Interpolate the full state vector at time t.
Boundary temperatures (Pyrolysis.Discretization)
Pyrolysis.Discretization.get_surface_temperature — Function
get_surface_temperature(mesh)Get the top surface temperature from the solved boundary state.
Pyrolysis.Discretization.get_back_face_temperature — Function
get_back_face_temperature(mesh)Get the back face (bottom) temperature from the solved boundary state.
Solver callbacks and iterative solvers (Pyrolysis.Solver)
Pyrolysis.Solver.create_thickness_termination_callback — Function
create_thickness_termination_callback(sv_ref, min_thickness) -> ContinuousCallbackCreate 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.
Pyrolysis.Solver.create_depletion_callback — Function
create_depletion_callback(ws, mesh, material, layout;
threshold=0.05, min_cells=2) -> DiscreteCallbackCreate 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:
- Finds all thin cells, sorted by z-position (surface first)
- Merges the first thin cell with its best neighbor
- Resizes the workspace's caches
- Resizes the integrator's state vector using
resize!(integrator, ...) - 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: MutableWorkspacebeing solvedmesh::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 onlymin_cellsremain, 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.layoutis 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)Pyrolysis.Solver.ILUGMRESFactorization — Type
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.
Pyrolysis.Solver.ILUBiCGSTABFactorization — Type
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.