Skip to main content

Block Solver

Jasper uses a sequential modular solver that processes unit operations one at a time in topological order, with recycle convergence for cyclic flowsheets.

Algorithm

1. Select property package from project.thermodynamics.propertyMethod
2. Initialize feed streams (T, P, flow, composition → enthalpy)
3. Topological sort with tear stream detection
4. If no recycles:
Solve blocks in order → done
5. If recycles detected:
Initialize tear streams with defaults
Loop (max 50 iterations):
a. Solve all blocks in topo order
b. Compare tear stream values (T, P, flow, composition)
c. Apply Wegstein acceleration
d. If max relative change < 1e-4 → converged

Property Package Threading

The solver creates a PropertyPackage from the project settings and passes it to every block solver. This means:

  • Flash drums use the correct K-value model (Ideal, PR, or NRTL)
  • Compressors use rigorous entropy for isentropic calculations
  • Distillation columns use property-package K-values for relative volatilities
  • Absorbers use K-values for equilibrium slope in Kremser
const methodName = project.thermodynamics?.propertyMethod ?? 'Ideal';
const pkg = getPropertyPackage(methodName);

Recycle Convergence

Tear Stream Detection

During topological sort, back-edges in the DFS identify recycle loops. These edges become tear streams — the solver breaks the loop at these points and iterates.

Wegstein Acceleration

After 2+ iterations, Wegstein acceleration is applied to tear stream variables:

slope = (g(x2) - g(x1)) / (x2 - x1)
q = slope / (slope - 1)
x_new = (1 - q) · g(x2) + q · x2

Where q is bounded to [-5, 0] for stability.

Convergence Criteria

  • Tolerance: max relative change < 1e-4
  • Max iterations: 50
  • Variables checked: T, P, flow, all mole fractions

SolverResult

interface SolverResult {
converged: boolean;
streams: Map<string, StreamState>;
blockResults: Map<string, any>;
error?: string;
recycleIterations?: number;
}

StreamState

interface StreamState {
id: string;
name: string;
T: number; // K
P: number; // bar
flow: number; // kmol/h
composition: Record<string, number>; // mole fractions
phase: 'V' | 'L' | 'VL';
H: number; // kJ/mol
}

Supported Block Types

TypeSolverKey Feature
FeedInitializeReads params or edge spec
Flash / SeparatorVLE flashProperty-package K-values
MixerEnthalpy balanceNewton iteration for T
SplitterFlow divisionSplit ratio parameter
PumpΔP + powerRackett liquid density
CompressorIsentropic + efficiencyEntropy-based Newton iteration
ValveIsenthalpicPressure drop
Heater / CoolerEnergy balanceRigorous enthalpy duty
DistillationColumnFenske-Underwood-GillilandShortcut distillation
RStoic / RCSTR / RPfr / etc.Stoichiometric + heat of rxnAdiabatic or isothermal
REquil / RGibbsEquilibriumKeq from ΔG, bisection
AbsorberKremserGeneral multi-solute
StripperKremserGeneral stripping
HeatExchangerCounter-current80% effectiveness

Source

src/sim/solver/blockSolver.ts