Skip to main content

Custom Sizing

Custom units can carry their own sizing definition, so novel equipment (electrolyzers, membrane skids, proprietary reactors) gets sized and costed instead of falling out of the economics.

Two modes

A CustomUnit's sizing spec declares a size quantity (area, volume, power, or heat_duty) and one of two methods:

  • inherit — reuse the built-in correlation of the unit's base type. A custom CSTR variant inherits residence-time sizing from RCSTR.
  • formula — a sandboxed arithmetic expression evaluated against the unit's simulation results.

Formula variables

VariableMeaningUnit
dutyHeat duty (signed: + heating, − cooling)kW
workMechanical work / powerkW
flow_molFeed molar flowkmol/h
flow_volFeed volumetric flowm³/s
density_lLiquid outlet (or feed) densitykg/m³
density_vVapor outlet densitykg/m³
TFeed temperatureK
PFeed pressurebar

Plus any named constants the spec defines (e.g. tau: 7200). Example — a reactor sized by an explicit residence time:

expression: "flow_vol * tau"
variables: { tau: 7200 }
sizeQuantity: volume

When a formula yields a volume, diameter and length are derived with the standard L/D = 3 cylinder so the result stays consistent with the vessel cost correlations.

The expression sandbox

Formulas are evaluated by a purpose-built parser — never JavaScript eval. The grammar allows:

  • Numbers, the declared variables, and the constants pi, e
  • Operators + − * / % ^ and parentheses
  • Functions: sqrt, cbrt, abs, exp, ln, log10, pow, min, max

Anything else — property access, assignment, unknown identifiers — is rejected. Formulas are validated when the unit is proposed; a formula that fails validation falls back to the base type's sizing and surfaces a warning.

Provenance

Agent- or user-defined sizing is always distinguishable from built-in correlations. Every custom-sized result records:

  • the flag agent-defined sizing (not a validated built-in)
  • the literal formula used
  • the cited source from the spec, if provided

so a reviewer can audit exactly where a size came from.