moonbit-reactor

    Chemical reactor design toolkit for CSTR, PFR, and batch calculations in MoonBit.

    reactor
    chemical-engineering
    cstr
    pfr
    batch
    numerical-methods
    Download zip
    Version
    0.3.0
    License
    Apache-2.0
    Last updated
    last month
    Downloads
    10

    #moonbit-reactor

    Deterministic MoonBit tools for early-stage chemical reactor design: CSTR, PFR, and batch models; kinetics; thermal screening; profiles; reactor trains; numerical solvers; sensitivity; uncertainty; validation; optimization; and offline benchmarks.

    #Example

    ///|
    test {
    let reaction = Reaction::new(name="A -> B", order=First, k_ref=0.5)
    let feed = Feed::new(
    concentration=1.0,
    volumetric_flow=2.0,
    temperature=300.0,
    )
    let point = design_pfr(reaction, feed, 4.0)
    assert_true(point.conversion > 0.63 && point.conversion < 0.64)
    }

    Run the examples and benchmarks with moon run cmd/main and moon run cmd/benchmarks. The package uses Apache-2.0; model assumptions and benchmark provenance are documented in docs/.

    BenchmarkCase

    pub(all) struct BenchmarkCase {
    id : String
    title : String
    category : BenchmarkCategory
    source : String
    source_url : String
    units : String
    assumptions : String
    expected : Double
    tolerance : Double
    } derive(ToJson,
    Debug
    )

    BenchmarkCategory

    pub(all) enum BenchmarkCategory {
    Analytical
    LiteratureKinetics
    MeasuredProperty
    Screening
    } derive(Eq, ToJson,
    Debug
    )

    BenchmarkCategory::to_string

    fn BenchmarkCategory::to_string(category : BenchmarkCategory) -> String

    BenchmarkResult

    pub(all) struct BenchmarkResult {
    id : String
    expected : Double
    actual : Double
    absolute_error : Double
    tolerance : Double
    passed : Bool
    source_url : String
    } derive(ToJson,
    Debug
    )

    BenchmarkResult::to_csv_row

    fn BenchmarkResult::to_csv_row(self : BenchmarkResult) -> String

    BracketResult

    pub(all) struct BracketResult {
    root : Double
    residual : Double
    iterations : Int
    converged : Bool
    } derive(ToJson,
    Debug
    )

    ControllerConfig

    pub(all) struct ControllerConfig {
    proportional : Double
    integral : Double
    derivative : Double
    minimum : Double
    maximum : Double
    } derive(ToJson,
    Debug
    )

    PID gains and actuator limits.

    ControllerConfig::new

    fn ControllerConfig::new(proportional~ : Double, integral~ : Double, derivative~ : Double, minimum~ : Double, maximum~ : Double) -> ControllerConfig

    Construct conservative controller gains and actuator limits.

    ControllerConfig::validate

    fn ControllerConfig::validate(self : ControllerConfig) -> Bool

    ControllerState

    pub(all) struct ControllerState {
    integral : Double
    previous_error : Double
    output : Double
    } derive(ToJson,
    Debug
    )

    Persistent state for a discrete controller.

    ControllerState::default

    ControllerStep

    pub(all) struct ControllerStep {
    output : Double
    state : ControllerState
    saturated : Bool
    } derive(ToJson,
    Debug
    )

    The controller output and updated state.

    ConversionInterval

    pub(all) struct ConversionInterval {
    minimum_conversion : Double
    maximum_conversion : Double
    nominal_conversion : Double
    minimum_temperature : Double
    maximum_temperature : Double
    } derive(ToJson,
    Debug
    )

    A conservative interval for a screening calculation.

    CostAssumptions

    pub(all) struct CostAssumptions {
    annual_hours : Double
    electricity_price : Double
    vessel_cost_per_volume : Double
    pump_cost_per_flow : Double
    maintenance_fraction : Double
    } derive(ToJson,
    Debug
    )

    Economic assumptions for early-stage design screening.

    CostAssumptions::default

    CostEstimate

    pub(all) struct CostEstimate {
    capital : Double
    utilities : Double
    maintenance : Double
    total : Double
    } derive(ToJson,
    Debug
    )

    A transparent annualized cost estimate.

    DesignPoint

    pub(all) struct DesignPoint {
    kind : ReactorKind
    thermal_mode : ThermalMode
    volume : Double
    residence_time : Double
    conversion : Double
    outlet_concentration : Double
    outlet_temperature : Double
    heat_removed : Double
    rate_at_outlet : Double
    } derive(ToJson,
    Debug
    )

    DesignPoint::summary_rows

    fn DesignPoint::summary_rows(self : DesignPoint) -> Array[ReportColumn]

    DesignPoint::to_markdown

    fn DesignPoint::to_markdown(self : DesignPoint) -> String

    EnvelopePoint

    pub(all) struct EnvelopePoint {
    volume : Double
    conversion : Double
    temperature : Double
    feasible : Bool
    reason : String
    } derive(ToJson,
    Debug
    )

    A design point annotated with feasibility checks.

    Feed

    pub(all) struct Feed {
    concentration : Double
    volumetric_flow : Double
    temperature : Double
    heat_capacity_flow : Double
    } derive(ToJson,
    Debug
    )

    Feed::new

    fn Feed::new(concentration~ : Double, volumetric_flow~ : Double, temperature~ : Double, heat_capacity_flow? : Double) -> Feed

    HeatExchange

    pub(all) struct HeatExchange {
    ua : Double
    coolant_temperature : Double
    } derive(ToJson,
    Debug
    )

    HeatExchange::new

    fn HeatExchange::new(ua~ : Double, coolant_temperature~ : Double) -> HeatExchange

    IntegrationResult

    pub(all) struct IntegrationResult {
    value : Double
    estimated_error : Double
    evaluations : Int
    converged : Bool
    } derive(ToJson,
    Debug
    )

    A numerical integration result with an explicit error estimate.

    KineticOrder

    pub(all) enum KineticOrder {
    Zero
    First
    Second
    } derive(Eq, ToJson,
    Debug
    )

    KineticOrder::to_string

    fn KineticOrder::to_string(order : KineticOrder) -> String

    NetworkResult

    pub(all) struct NetworkResult {
    stages : Array[DesignPoint]
    final_conversion : Double
    final_concentration : Double
    final_temperature : Double
    total_volume : Double
    } derive(ToJson,
    Debug
    )

    ObjectiveScore

    pub(all) struct ObjectiveScore {
    volume : Double
    conversion : Double
    temperature : Double
    score : Double
    feasible : Bool
    } derive(ToJson,
    Debug
    )

    A single design objective used by screening optimizers.

    OperatingScenario

    pub(all) struct OperatingScenario {
    name : String
    reaction : Reaction
    feed : Feed
    volume : Double
    thermal_mode : ThermalMode
    exchange : HeatExchange?
    } derive(ToJson,
    Debug
    )

    A named operating scenario for repeatable screening.

    OperatingScenario::adiabatic

    fn OperatingScenario::adiabatic(name~ : String, reaction~ : Reaction, feed~ : Feed, volume~ : Double) -> OperatingScenario

    Construct an adiabatic scenario.

    OperatingScenario::isothermal

    fn OperatingScenario::isothermal(name~ : String, reaction~ : Reaction, feed~ : Feed, volume~ : Double) -> OperatingScenario

    Construct an isothermal scenario.

    OperatingScenario::jacketed

    fn OperatingScenario::jacketed(name~ : String, reaction~ : Reaction, feed~ : Feed, volume~ : Double, exchange~ : HeatExchange) -> OperatingScenario

    Construct a jacketed scenario.

    OptimizationResult

    pub(all) struct OptimizationResult {
    volume : Double
    conversion : Double
    temperature : Double
    objective : Double
    feasible : Bool
    } derive(ToJson,
    Debug
    )

    ParallelReactionResult

    pub(all) struct ParallelReactionResult {
    product_a_rate : Double
    product_b_rate : Double
    product_a_selectivity : Double
    product_b_selectivity : Double
    } derive(ToJson,
    Debug
    )

    Perturbation

    pub(all) struct Perturbation {
    rate_multiplier : Double
    temperature_offset : Double
    flow_multiplier : Double
    } derive(ToJson,
    Debug
    )

    A reproducible input perturbation used by sensitivity analysis.

    ProfilePoint

    pub(all) struct ProfilePoint {
    position : Double
    time : Double
    conversion : Double
    concentration : Double
    temperature : Double
    rate : Double
    } derive(ToJson,
    Debug
    )

    A sampled axial or temporal reactor state.

    Reaction

    pub(all) struct Reaction {
    name : String
    order : KineticOrder
    k_ref : Double
    activation_energy : Double
    reference_temperature : Double
    reaction_enthalpy : Double
    } derive(ToJson,
    Debug
    )

    Reaction::new

    fn Reaction::new(name~ : String, order~ : KineticOrder, k_ref~ : Double, activation_energy? : Double, reference_temperature? : Double, reaction_enthalpy? : Double) -> Reaction

    Reaction::rate

    fn Reaction::rate(self : Reaction, concentration : Double, temperature : Double) -> Double

    Reaction::rate_constant

    fn Reaction::rate_constant(self : Reaction, temperature : Double) -> Double

    ReactorKind

    pub(all) enum ReactorKind {
    Cstr
    Pfr
    Batch
    } derive(Eq, ToJson,
    Debug
    )

    ReactorKind::to_string

    fn ReactorKind::to_string(kind : ReactorKind) -> String

    ReactorStage

    pub(all) struct ReactorStage {
    kind : ReactorKind
    volume : Double
    thermal_mode : ThermalMode
    exchange : HeatExchange?
    } derive(ToJson,
    Debug
    )

    ReactorStage::batch

    fn ReactorStage::batch(time~ : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> ReactorStage

    ReactorStage::cstr

    fn ReactorStage::cstr(volume~ : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> ReactorStage

    ReactorStage::pfr

    fn ReactorStage::pfr(volume~ : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> ReactorStage

    ReactorSweepPoint

    pub(all) struct ReactorSweepPoint {
    volume : Double
    conversion : Double
    outlet_temperature : Double
    } derive(ToJson,
    Debug
    )

    ReportColumn

    pub(all) struct ReportColumn {
    name : String
    value : String
    } derive(ToJson,
    Debug
    )

    ReversibleFirstOrder

    pub(all) struct ReversibleFirstOrder {
    forward_rate : Double
    reverse_rate : Double
    equilibrium_concentration : Double
    } derive(ToJson,
    Debug
    )

    SafetyBoundary

    pub(all) struct SafetyBoundary {
    max_safe_volume : Double
    max_safe_residence_time : Double
    hot_spot_temperature : Double
    conversion_at_boundary : Double
    limited_by_temperature : Bool
    } derive(ToJson,
    Debug
    )

    SearchConfig

    pub(all) struct SearchConfig {
    minimum : Double
    maximum : Double
    steps : Int
    } derive(ToJson,
    Debug
    )

    A bounded one-dimensional search configuration.

    SearchConfig::new

    fn SearchConfig::new(minimum~ : Double, maximum~ : Double, steps~ : Int) -> SearchConfig

    Construct a normalized search configuration.

    SearchRange

    pub(all) struct SearchRange {
    min : Double
    max : Double
    steps : Int
    } derive(ToJson,
    Debug
    )

    SearchRange::new

    fn SearchRange::new(min~ : Double, max~ : Double, steps~ : Int) -> SearchRange

    SensitivityReport

    pub(all) struct SensitivityReport {
    conversion_wrt_volume : Double
    conversion_wrt_rate_constant : Double
    conversion_wrt_temperature : Double
    temperature_wrt_volume : Double
    volume_wrt_target_conversion : Double
    } derive(ToJson,
    Debug
    )

    Local finite-difference sensitivities of a design point.

    SeriesReactionResult

    pub(all) struct SeriesReactionResult {
    intermediate_concentration : Double
    product_concentration : Double
    intermediate_selectivity : Double
    } derive(ToJson,
    Debug
    )

    SolverReport

    pub(all) struct SolverReport {
    status : SolverStatus
    root : Double
    residual : Double
    iterations : Int
    } derive(ToJson,
    Debug
    )

    SolverSettings

    pub(all) struct SolverSettings {
    tolerance : Double
    max_iterations : Int
    } derive(ToJson,
    Debug
    )

    SolverSettings::default

    SolverSettings::loose

    SolverStatus

    pub(all) enum SolverStatus {
    Converged
    BracketFailure
    IterationLimit
    InvalidRange
    } derive(Eq, ToJson,
    Debug
    )

    ThermalMode

    pub(all) enum ThermalMode {
    Isothermal
    Adiabatic
    NonIsothermal
    } derive(Eq, ToJson,
    Debug
    )

    ThermalMode::to_string

    fn ThermalMode::to_string(mode : ThermalMode) -> String

    ThermalScreening

    pub(all) struct ThermalScreening {
    inlet_temperature : Double
    outlet_temperature : Double
    maximum_temperature : Double
    margin : Double
    safe : Bool
    } derive(ToJson,
    Debug
    )

    A thermal runaway screening result.

    TrainResult

    pub(all) struct TrainResult {
    stages : Array[DesignPoint]
    final_conversion : Double
    total_volume : Double
    total_residence_time : Double
    } derive(ToJson,
    Debug
    )

    Per-stage and aggregate results for a train.

    UncertaintySummary

    pub(all) struct UncertaintySummary {
    samples : Int
    minimum : Double
    maximum : Double
    mean : Double
    standard_deviation : Double
    p05 : Double
    p50 : Double
    p95 : Double
    } derive(ToJson,
    Debug
    )

    Summary statistics for deterministic uncertainty samples.

    ValidationLevel

    pub(all) enum ValidationLevel {
    Info
    Warning
    Error
    } derive(Eq, ToJson,
    Debug
    )

    ValidationLevel::to_string

    fn ValidationLevel::to_string(level : ValidationLevel) -> String

    ValidationMessage

    pub(all) struct ValidationMessage {
    level : ValidationLevel
    field : String
    message : String
    } derive(ToJson,
    Debug
    )

    ValidationMessage::to_line

    fn ValidationMessage::to_line(self : ValidationMessage) -> String

    ValidationReport

    pub(all) struct ValidationReport {
    messages : Array[ValidationMessage]
    } derive(ToJson,
    Debug
    )

    ValidationReport::count

    fn ValidationReport::count(self : ValidationReport, level : ValidationLevel) -> Int

    ValidationReport::has_errors

    fn ValidationReport::has_errors(self : ValidationReport) -> Bool

    ValidationReport::new

    ValidationReport::push

    fn ValidationReport::push(self : ValidationReport, level : ValidationLevel, field : String, message : String) -> ValidationReport

    ValidationReport::to_text

    fn ValidationReport::to_text(self : ValidationReport) -> String

    absolute

    fn absolute(x : Double) -> Double

    adiabatic_rise

    fn adiabatic_rise(heat_release : Double, heat_capacity_flow : Double) -> Double

    Estimate an adiabatic temperature rise from heat release.

    adiabatic_temperature

    fn adiabatic_temperature(feed : Feed, reaction : Reaction, conversion : Double) -> Double

    adjacent_differences

    fn adjacent_differences(values : ArrayView[Double]) -> Array[Double]

    Difference between adjacent samples.

    analyze_thermal_train

    fn analyze_thermal_train(reaction : Reaction, feed : Feed, stages : ArrayView[ReactorStage], mode : ThermalMode, exchange : HeatExchange?) -> TrainResult

    Run a train with a shared thermal mode and optional jacket.

    analyze_train

    fn analyze_train(reaction : Reaction, feed : Feed, stages : ArrayView[ReactorStage]) -> TrainResult

    Run a typed reactor train, passing each outlet to the next stage.

    argmax

    fn argmax(values : ArrayView[Double]) -> Int?

    Return the index of the largest sampled value.

    argmin

    fn argmin(values : ArrayView[Double]) -> Int?

    Return the index of the smallest sampled value.

    arrhenius_multiplier

    fn arrhenius_multiplier(activation_energy : Double, temperature : Double, reference : Double) -> Double

    Compute a normalized Arrhenius temperature multiplier.

    average_batch_conversion

    fn average_batch_conversion(reaction : Reaction, feed : Feed, duration : Double, points : Int) -> Double

    Average batch conversion over a time window.

    average_pfr_advantage

    fn average_pfr_advantage(curve : ArrayView[(Double, Double, Double)]) -> Double

    Average advantage of a PFR curve over a CSTR curve.

    balance_closure

    fn balance_closure(inlet : Double, outlet : Double, side_products : Double) -> Double

    Carbon or atom balance closure from measured flows.

    batch_concentration_curve

    fn batch_concentration_curve(reaction : Reaction, feed : Feed, times : ArrayView[Double]) -> Array[Double]

    Batch concentration at a sequence of times.

    batch_conversion_curve

    fn batch_conversion_curve(reaction : Reaction, feed : Feed, times : ArrayView[Double]) -> Array[Double]

    Batch conversion at a sequence of times.

    batch_conversion_gain

    fn batch_conversion_gain(reaction : Reaction, feed : Feed, first_time : Double, second_time : Double) -> Double

    Batch conversion gain between two times.

    batch_conversion_isothermal

    fn batch_conversion_isothermal(reaction : Reaction, feed : Feed, time : Double) -> Double

    batch_curve_is_monotone

    fn batch_curve_is_monotone(values : ArrayView[Double]) -> Bool

    Check monotonicity of a batch curve.

    batch_design_window

    fn batch_design_window(reaction : Reaction, feed : Feed, minimum_conversion : Double, maximum_temperature : Double, maximum_time : Double, points : Int) -> Array[EnvelopePoint]

    A conservative batch design window.

    batch_productivity

    fn batch_productivity(feed : Feed, conversion : Double, cycle_time : Double, cleaning_time : Double) -> Double

    Batch productivity at a selected cycle time.

    batch_profile

    fn batch_profile(reaction : Reaction, feed : Feed, final_time : Double, points~ : Int, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> Array[ProfilePoint]

    Build a batch trajectory using RK4 on the conversion state.

    batch_rate_curve

    fn batch_rate_curve(reaction : Reaction, feed : Feed, times : ArrayView[Double]) -> Array[Double]

    Batch rate at a sequence of times.

    batch_time_for_target

    fn batch_time_for_target(reaction : Reaction, feed : Feed, target : Double, maximum_time : Double, points : Int) -> Double?

    Find the first time at which a batch conversion target is reached.

    benchmark_case

    fn benchmark_case(id : String) -> BenchmarkCase?

    benchmark_cases

    fn benchmark_cases() -> Array[BenchmarkCase]

    benchmark_failure_count

    fn benchmark_failure_count(results : ArrayView[BenchmarkResult]) -> Int

    Count benchmark failures.

    benchmark_metadata_complete

    fn benchmark_metadata_complete(case : BenchmarkCase) -> Bool

    Check that benchmark metadata is complete.

    benchmark_report_csv

    fn benchmark_report_csv() -> String

    benchmark_report_markdown

    fn benchmark_report_markdown() -> String

    benchmark_result_is_reproducible

    fn benchmark_result_is_reproducible(result : BenchmarkResult) -> Bool

    Check whether a benchmark result meets its declared tolerance.

    benchmark_result_to_markdown

    fn benchmark_result_to_markdown(result : BenchmarkResult) -> String

    Render a benchmark result with an explicit status.

    benchmark_results

    fn benchmark_results() -> Array[BenchmarkResult]

    benchmark_results_to_markdown

    fn benchmark_results_to_markdown(results : ArrayView[BenchmarkResult]) -> String

    Render all benchmark results as a stable table.

    benchmark_tolerances_valid

    fn benchmark_tolerances_valid(cases : ArrayView[BenchmarkCase]) -> Bool

    Validate all declared benchmark tolerances.

    best_objective

    fn best_objective(scores : ArrayView[ObjectiveScore]) -> ObjectiveScore?

    Find the highest-scoring candidate, preserving the first tie.

    best_scenario

    fn best_scenario(scenarios : ArrayView[OperatingScenario], target_conversion : Double, maximum_temperature : Double) -> OperatingScenario?

    Select the highest-scoring scenario.

    bisect

    fn bisect(lower : Double, upper : Double, f : (Double) -> Double, settings? : SolverSettings) -> BracketResult

    bisect_report

    fn bisect_report(lower : Double, upper : Double, f : (Double) -> Double, settings? : SolverSettings) -> SolverReport

    bisection_budget

    fn bisection_budget(lower : Double, upper : Double, tolerance : Double) -> Int

    Return a conservative iteration budget for bisection.

    blasius_friction_factor

    fn blasius_friction_factor(reynolds : Double) -> Double

    Blasius friction-factor approximation for turbulent flow.

    bounded_actuator

    fn bounded_actuator(value : Double, minimum : Double, maximum : Double) -> Double

    A smooth actuator map that avoids negative heat-removal commands.

    bracket_condition_number

    fn bracket_condition_number(lower : Double, upper : Double, tolerance : Double) -> Double

    Condition number estimate for a bisection interval.

    celsius_to_kelvin

    fn celsius_to_kelvin(celsius : Double) -> Double

    Convert Celsius to Kelvin with a physical lower bound.

    central_difference

    fn central_difference(x : Double, f : (Double) -> Double, step? : Double) -> Double

    Estimate a derivative using a scale-aware central difference.

    clamp_conversion

    fn clamp_conversion(x : Double) -> Double

    clamp_rate_constant

    fn clamp_rate_constant(value : Double, minimum : Double, maximum : Double) -> Double

    Clamp a rate constant to a safe non-negative interval.

    clamp_temperature

    fn clamp_temperature(temperature : Double, minimum : Double, maximum : Double) -> Double

    Clamp an engineering temperature to a declared operating window.

    clip_values

    fn clip_values(values : ArrayView[Double], minimum : Double, maximum : Double) -> Array[Double]

    Clip a sampled signal to a physical range.

    closest_target

    fn closest_target(scores : ArrayView[ObjectiveScore], target_conversion : Double, target_volume : Double, target_temperature : Double) -> ObjectiveScore?

    Select the closest target design.

    compare_reactor_curves

    fn compare_reactor_curves(reaction : Reaction, feed : Feed, volumes : ArrayView[Double]) -> Array[(Double, Double, Double)]

    Compare CSTR and PFR curves at equal volumes.

    compare_scenarios

    fn compare_scenarios(first : OperatingScenario, second : OperatingScenario, assumptions : CostAssumptions) -> Double

    Compare two scenarios across conversion, temperature, and cost.

    compare_train_to_single_pfr

    fn compare_train_to_single_pfr(reaction : Reaction, feed : Feed, stages : ArrayView[ReactorStage]) -> (TrainResult, DesignPoint, Double)

    Compare a train with a single reference reactor at equal total volume.

    complete_benchmark_count

    fn complete_benchmark_count(cases : ArrayView[BenchmarkCase]) -> Int

    Count metadata-complete benchmark cases.

    concentration_from_conversion

    fn concentration_from_conversion(feed : Feed, conversion : Double) -> Double

    concentration_trajectory

    fn concentration_trajectory(initial : Double, rate_constant : Double, order : KineticOrder, duration : Double, points : Int) -> Array[Double]

    Generate a concentration trajectory for an order.

    controller_peak_error

    fn controller_peak_error(trace : ArrayView[ControllerStep], setpoint : Double) -> Double

    The maximum absolute tracking error in a controller trace.

    controller_reset

    fn controller_reset(_state : ControllerState) -> ControllerState

    Reset a controller after a mode change or safety trip.

    controller_step

    fn controller_step(config : ControllerConfig, state : ControllerState, setpoint : Double, measurement : Double, dt : Double) -> ControllerStep

    Execute one discrete PID step with anti-windup by clamping the integral.

    controller_to_csv

    fn controller_to_csv(trace : ArrayView[ControllerStep]) -> String

    Render a controller trace as CSV.

    controller_trace_is_bounded

    fn controller_trace_is_bounded(trace : ArrayView[ControllerStep], config : ControllerConfig) -> Bool

    Check the standard monotonicity and boundedness invariants of a trace.

    conversion_from_concentration

    fn conversion_from_concentration(feed : Feed, outlet : Double) -> Double

    conversion_from_exposure

    fn conversion_from_exposure(exposure : Double, order : KineticOrder, concentration : Double) -> Double

    Conversion from an integrated rate exposure for a selected order.

    conversion_from_flows

    fn conversion_from_flows(inlet : Double, outlet : Double) -> Double

    Conversion inferred from an inlet and outlet mass flow.

    conversion_is_physical

    fn conversion_is_physical(conversion : Double) -> Bool

    conversion_residual

    fn conversion_residual(expected : Double, actual : Double) -> Double

    A dimensionless conversion residual.

    conversion_target_is_well_conditioned

    fn conversion_target_is_well_conditioned(target : Double) -> Bool

    Check whether a conversion target is too close to the singular limit.

    conversion_time_first_order

    fn conversion_time_first_order(k : Double, conversion : Double) -> Double

    conversion_volume_area

    fn conversion_volume_area(curve : ArrayView[(Double, Double, Double)], use_pfr : Bool) -> Double

    Integrate a conversion curve with respect to volume.

    corrected_rate

    fn corrected_rate(reaction : Reaction, concentration : Double, temperature : Double) -> Double

    Temperature-corrected rate for a declared reaction.

    cost_per_conversion

    fn cost_per_conversion(cost : CostEstimate, point : DesignPoint) -> Double

    Return the cost per unit of converted feed, with a safe zero boundary.

    cost_savings

    fn cost_savings(reference : CostEstimate, candidate : CostEstimate) -> Double

    Compare the annualized cost of two design points.

    cost_to_markdown

    fn cost_to_markdown(cost : CostEstimate) -> String

    Render a cost estimate as Markdown.

    cstr_conversion_curve

    fn cstr_conversion_curve(reaction : Reaction, feed : Feed, volumes : ArrayView[Double]) -> Array[Double]

    CSTR conversion over a sequence of volumes.

    cstr_conversion_isothermal

    fn cstr_conversion_isothermal(reaction : Reaction, feed : Feed, volume : Double) -> Double

    cstr_volume_from_endpoint

    fn cstr_volume_from_endpoint(flow : Double, target_conversion : Double, endpoint_ordinate : Double) -> Double

    CSTR volume from an endpoint Levenspiel ordinate.

    curve_volume_for_target

    fn curve_volume_for_target(curve : ArrayView[(Double, Double, Double)], target : Double, use_pfr : Bool) -> Double?

    Select the smallest volume meeting a target on a curve.

    damkohler_from_time

    fn damkohler_from_time(rate_constant : Double, residence : Double) -> Double

    Damkohler number from a residence time.

    damkohler_number

    fn damkohler_number(reaction : Reaction, feed : Feed, volume : Double) -> Double

    Dimensionless Damkohler number for a feed and reaction.

    demo_report

    fn demo_report() -> String

    design_batch

    fn design_batch(reaction : Reaction, feed : Feed, time : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> DesignPoint

    design_cstr

    fn design_cstr(reaction : Reaction, feed : Feed, volume : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> DesignPoint

    design_envelope

    fn design_envelope(reaction : Reaction, feed : Feed, minimum_volume : Double, maximum_volume : Double, steps : Int, minimum_conversion : Double, maximum_temperature : Double) -> Array[EnvelopePoint]

    Evaluate a volume grid against conversion and temperature limits.

    design_pfr

    fn design_pfr(reaction : Reaction, feed : Feed, volume : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> DesignPoint

    design_point_is_physical

    fn design_point_is_physical(point : DesignPoint, feed : Feed) -> Bool

    Check common physical invariants of a design point.

    design_point_to_csv_row

    fn design_point_to_csv_row(point : DesignPoint) -> String

    Render a design point as a machine-readable CSV row.

    design_points_to_csv

    fn design_points_to_csv(points : ArrayView[DesignPoint]) -> String

    Render a list of design points with a stable header.

    design_quality_score

    fn design_quality_score(conversion_error : Double, temperature_error : Double, mass_balance_error : Double, conversion_weight : Double, temperature_weight : Double, balance_weight : Double) -> Double

    Weighted quality score for a design calculation.

    design_sensitivity

    fn design_sensitivity(reaction : Reaction, feed : Feed, volume : Double) -> SensitivityReport

    Calculate local sensitivities with symmetric finite differences.

    design_with_perturbation

    fn design_with_perturbation(reaction : Reaction, feed : Feed, volume : Double, perturbation : Perturbation) -> DesignPoint

    Evaluate a design under a controlled perturbation.

    dominates

    fn dominates(a : ObjectiveScore, b : ObjectiveScore) -> Bool

    Pareto dominance for conversion, volume, and temperature.

    envelope_to_markdown

    fn envelope_to_markdown(points : ArrayView[EnvelopePoint]) -> String

    Render an envelope table with feasibility reasons.

    equal_volume_cstr_train

    fn equal_volume_cstr_train(stages : Int, total_volume : Double, thermal_mode? : ThermalMode) -> Array[ReactorStage]

    equal_volume_pfr_train

    fn equal_volume_pfr_train(stages : Int, total_volume : Double, thermal_mode? : ThermalMode) -> Array[ReactorStage]

    equilibrium_conversion

    fn equilibrium_conversion(forward : Double, reverse : Double) -> Double

    First-order equilibrium conversion from forward and reverse rates.

    estimate_annual_cost

    fn estimate_annual_cost(point : DesignPoint, assumptions : CostAssumptions) -> CostEstimate

    Estimate annualized cost for an early design point.

    estimate_order

    fn estimate_order(first_concentration : Double, second_concentration : Double, first_rate : Double, second_rate : Double) -> Double

    Estimate reaction order from two rate measurements at constant temperature.

    ethyl_acetate_saponification

    fn ethyl_acetate_saponification() -> DesignPoint

    euler_integrate

    fn euler_integrate(initial : Double, dt : Double, steps : Int, derivative : (Double, Double) -> Double) -> Double

    evaluate_grid

    fn evaluate_grid(config : SearchConfig, objective : (Double) -> Double) -> Array[ObjectiveScore]

    Evaluate a scalar objective over a uniform grid.

    evaluate_scenario

    fn evaluate_scenario(scenario : OperatingScenario) -> DesignPoint

    Evaluate a scenario with the declared thermal mode.

    evaluate_scenarios

    fn evaluate_scenarios(scenarios : ArrayView[OperatingScenario]) -> Array[DesignPoint]

    Evaluate several scenarios.

    exchanger_duty

    fn exchanger_duty(ua : Double, delta_hot : Double, delta_cold : Double) -> Double

    Heat transfer duty from UA and a temperature driving force.

    exothermic_cstr_boundary

    fn exothermic_cstr_boundary() -> SafetyBoundary

    feasible_scenario_count

    fn feasible_scenario_count(scenarios : ArrayView[OperatingScenario], minimum_conversion : Double, maximum_temperature : Double) -> Int

    Count scenarios that meet both safety and conversion targets.

    final_stage_gain

    fn final_stage_gain(result : TrainResult) -> Double

    Return the last stage conversion gain, or zero for an empty train.

    find_temperature_boundary

    fn find_temperature_boundary(reaction : Reaction, feed : Feed, max_volume : Double, max_temperature : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> SafetyBoundary

    first_difference

    fn first_difference(values : ArrayView[Double], step : Double) -> Array[Double]

    Compute a discrete first difference.

    first_invalid_benchmark

    fn first_invalid_benchmark(cases : ArrayView[BenchmarkCase]) -> String?

    Return the first invalid benchmark id.

    first_order_concentration

    fn first_order_concentration(initial : Double, rate_constant : Double, time : Double) -> Double

    First-order concentration decay.

    first_order_condition_number

    fn first_order_condition_number(damkohler : Double) -> Double

    Condition number estimate for first-order PFR conversion.

    first_order_cstr_error

    fn first_order_cstr_error(point : DesignPoint, damkohler : Double) -> Double

    Compare a design point with an analytical first-order CSTR oracle.

    first_order_exposure

    fn first_order_exposure(rate_constant : Double, time : Double) -> Double

    Integrated first-order exposure.

    first_order_pfr_error

    fn first_order_pfr_error(point : DesignPoint, damkohler : Double) -> Double

    Compare a design point with an analytical first-order PFR oracle.

    first_order_series_example

    fn first_order_series_example() -> Double

    first_order_time

    fn first_order_time(rate_constant : Double, conversion : Double) -> Double

    Invert a first-order conversion to time.

    first_sweep_target

    fn first_sweep_target(points : ArrayView[ReactorSweepPoint], target : Double) -> ReactorSweepPoint?

    Return the first sweep point meeting a conversion target.

    first_under_volume

    fn first_under_volume(scores : ArrayView[ObjectiveScore], maximum_volume : Double) -> ObjectiveScore?

    Select the first score under a maximum volume.

    first_unsafe_sweep_point

    fn first_unsafe_sweep_point(points : ArrayView[ReactorSweepPoint], maximum_temperature : Double) -> ReactorSweepPoint?

    Find the first unsafe point in a sweep.

    fit_first_order_rate

    fn fit_first_order_rate(initial : Double, final_value : Double, time : Double) -> Double

    Estimate a rate constant from two first-order measurements.

    fit_second_order_rate

    fn fit_second_order_rate(initial : Double, final_value : Double, time : Double) -> Double

    Estimate a second-order rate constant from two measurements.

    flow_velocity

    fn flow_velocity(volumetric_flow : Double, diameter : Double) -> Double

    Flow velocity from volumetric flow and diameter.

    format_double

    fn format_double(x : Double, digits? : Int) -> String

    format_optional

    fn format_optional(value : Double?, digits : Int) -> String

    Format a nullable numeric result for stable human-readable reports.

    friction_factor

    fn friction_factor(reynolds : Double) -> Double

    Choose a smooth friction-factor approximation by Reynolds number.

    half_life

    fn half_life(rate_constant : Double) -> Double

    Estimate a half-life for a first-order rate.

    has_standard_csv_header

    fn has_standard_csv_header(report : String, header : String) -> Bool

    Check whether a report contains the standard CSV header.

    heat_capacity_constant

    fn heat_capacity_constant(value : Double) -> Double

    A compact heat-capacity correlation for screening calculations.

    heat_capacity_flow

    fn heat_capacity_flow(volumetric_flow : Double, density : Double, specific_heat : Double) -> Double

    Compute a heat-capacity flow from flow, density, and specific heat.

    heat_capacity_linear

    fn heat_capacity_linear(base : Double, slope : Double, temperature : Double, reference : Double) -> Double

    Linear temperature heat-capacity correction.

    heat_release_number

    fn heat_release_number(reaction : Reaction, feed : Feed) -> Double

    Dimensionless heat-release number for a reaction and feed.

    heat_removed_by_jacket

    fn heat_removed_by_jacket(exchange : HeatExchange, reactor_temperature : Double) -> Double

    highest_conversion_scenario

    fn highest_conversion_scenario(scenarios : ArrayView[OperatingScenario]) -> (String, Double)?

    Find the highest-conversion scenario.

    hottest_scenario

    fn hottest_scenario(scenarios : ArrayView[OperatingScenario]) -> (String, Double)?

    Find the hottest scenario.

    incremental_conversion_rate

    fn incremental_conversion_rate(previous : DesignPoint, next : DesignPoint) -> Double

    Conversion improvement per added reactor volume.

    integrate_adaptive

    fn integrate_adaptive(lower : Double, upper : Double, f : (Double) -> Double, tolerance? : Double, max_depth? : Int) -> IntegrationResult

    Adaptive quadrature that preserves the sign of reversed intervals.

    integrate_rk4

    fn integrate_rk4(initial : Double, start : Double, end : Double, steps : Int, derivative : (Double, Double) -> Double) -> Double

    Integrate a scalar ODE with fixed-step RK4.

    integrate_simpson

    fn integrate_simpson(lower : Double, upper : Double, steps : Int, f : (Double) -> Double) -> Double

    Composite Simpson quadrature for a fixed, reproducible grid.

    integrate_trapezoid

    fn integrate_trapezoid(lower : Double, upper : Double, steps : Int, f : (Double) -> Double) -> Double

    integrate_trapezoid_report

    fn integrate_trapezoid_report(lower : Double, upper : Double, steps : Int, f : (Double) -> Double) -> SolverReport

    interval_encloses_nominal

    fn interval_encloses_nominal(interval : ConversionInterval) -> Bool

    Check that a conversion interval encloses its nominal point.

    jacket_duty

    fn jacket_duty(target_temperature : Double, reactor_temperature : Double, coolant_temperature : Double, gain : Double) -> Double

    Convert a temperature error into a bounded jacket duty cycle.

    jacket_heat_removal

    fn jacket_heat_removal(exchange : HeatExchange, reactor_temperature : Double, target_temperature : Double, gain : Double) -> Double

    Estimate heat removal from a bounded jacket duty cycle.

    jacket_number

    fn jacket_number(exchange : HeatExchange, feed : Feed) -> Double

    Dimensionless jacket strength.

    kelvin_to_celsius

    fn kelvin_to_celsius(kelvin : Double) -> Double

    Convert Kelvin to Celsius.

    laminar_friction_factor

    fn laminar_friction_factor(reynolds : Double) -> Double

    Laminar friction-factor approximation.

    last_over_conversion

    fn last_over_conversion(scores : ArrayView[ObjectiveScore], minimum_conversion : Double) -> ObjectiveScore?

    Select the last score over a minimum conversion.

    last_safe_sweep_point

    fn last_safe_sweep_point(points : ArrayView[ReactorSweepPoint], maximum_temperature : Double) -> ReactorSweepPoint?

    Determine the largest safe point in a sweep.

    levenspiel_ordinate

    fn levenspiel_ordinate(reaction : Reaction, feed : Feed, conversion : Double) -> Double

    Levenspiel ordinate for a selected order.

    linspace

    fn linspace(minimum : Double, maximum : Double, count : Int) -> Array[Double]

    A deterministic linearly spaced sample.

    liters_per_minute_to_m3_per_second

    fn liters_per_minute_to_m3_per_second(value : Double) -> Double

    Convert litres per minute to cubic metres per second.

    log_mean_temperature_difference

    fn log_mean_temperature_difference(delta_hot : Double, delta_cold : Double) -> Double

    Log-mean temperature difference for a counter-current exchanger.

    logspace

    fn logspace(minimum : Double, maximum : Double, count : Int) -> Array[Double]

    Generate geometric samples over positive bounds.

    low_pass

    fn low_pass(values : ArrayView[Double], alpha : Double) -> Array[Double]

    First-order low-pass filter for deterministic sampled data.

    m3_per_second_to_liters_per_minute

    fn m3_per_second_to_liters_per_minute(value : Double) -> Double

    Convert cubic metres per second to litres per minute.

    maximize_conversion_under_temperature

    fn maximize_conversion_under_temperature(reaction : Reaction, feed : Feed, range : SearchRange, max_temperature : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> OptimizationResult

    maximum_absolute_error

    fn maximum_absolute_error(first : ArrayView[Double], second : ArrayView[Double]) -> Double

    Maximum absolute error between two signals.

    maximum_benchmark_error

    fn maximum_benchmark_error(results : ArrayView[BenchmarkResult]) -> Double

    Find the largest benchmark error.

    maximum_scalar

    fn maximum_scalar(scores : ArrayView[ObjectiveScore]) -> ObjectiveScore?

    Return the maximizer of a scalar objective.

    maximum_sweep_conversion

    fn maximum_sweep_conversion(points : ArrayView[ReactorSweepPoint]) -> Double

    Maximum conversion of a sweep.

    maximum_temperature_margin

    fn maximum_temperature_margin(points : ArrayView[ReactorSweepPoint], maximum_temperature : Double) -> Double

    Maximum temperature margin in a sweep.

    mean_absolute_error

    fn mean_absolute_error(first : ArrayView[Double], second : ArrayView[Double]) -> Double

    Mean absolute error between two equal-length signals.

    mean_sweep_conversion

    fn mean_sweep_conversion(points : ArrayView[ReactorSweepPoint]) -> Double

    Mean conversion of a sweep.

    midpoints

    fn midpoints(values : ArrayView[Double]) -> Array[Double]

    Midpoints of an ordered sample grid.

    minimize_volume_for_conversion

    fn minimize_volume_for_conversion(reaction : Reaction, feed : Feed, range : SearchRange, target_conversion : Double, kind? : ReactorKind) -> OptimizationResult

    minimum_feasible_volume

    fn minimum_feasible_volume(points : ArrayView[EnvelopePoint]) -> EnvelopePoint?

    Select the feasible point with the lowest volume.

    minimum_scalar

    fn minimum_scalar(scores : ArrayView[ObjectiveScore]) -> ObjectiveScore?

    Return the minimizer of a scalar objective.

    minimum_sweep_conversion

    fn minimum_sweep_conversion(points : ArrayView[ReactorSweepPoint]) -> Double

    Minimum conversion of a sweep.

    minimum_temperature_margin

    fn minimum_temperature_margin(points : ArrayView[ReactorSweepPoint], maximum_temperature : Double) -> Double

    Minimum temperature margin in a sweep.

    mixed_temperature

    fn mixed_temperature(first_flow : Double, first_temperature : Double, second_flow : Double, second_temperature : Double) -> Double

    Estimate the outlet temperature of a mixed feed and recycle stream.

    mixing_ratio

    fn mixing_ratio(residence : Double, mixing_time : Double) -> Double

    Peclet-like screening ratio between axial residence and mixing time.

    molar_liter_to_molar_meter

    fn molar_liter_to_molar_meter(value : Double) -> Double

    Convert concentration in mol/L to mol/m3.

    molar_meter_to_molar_liter

    fn molar_meter_to_molar_liter(value : Double) -> Double

    Convert concentration in mol/m3 to mol/L.

    natural_log

    fn natural_log(x : Double) -> Double

    nearly_equal

    fn nearly_equal(a : Double, b : Double, tolerance? : Double) -> Bool

    network_to_markdown

    fn network_to_markdown(result : NetworkResult) -> String

    normalize_to_range

    fn normalize_to_range(values : ArrayView[Double], minimum : Double, maximum : Double) -> Array[Double]

    Normalize a signal to a target range.

    objective_improvement

    fn objective_improvement(reference : ObjectiveScore, candidate : ObjectiveScore) -> Double

    Return the percentage improvement between two objective scores.

    objective_surface

    fn objective_surface(reaction : Reaction, feed : Feed, volumes : ArrayView[Double], conversion_weight : Double, volume_weight : Double, temperature_limit : Double) -> Array[ObjectiveScore]

    Enumerate a coarse, deterministic design objective surface.

    objective_surface_to_csv

    fn objective_surface_to_csv(scores : ArrayView[ObjectiveScore]) -> String

    Render an objective surface as CSV.

    optimize_batch_cycle

    fn optimize_batch_cycle(reaction : Reaction, feed : Feed, maximum_time : Double, cleaning_time : Double, points : Int) -> ObjectiveScore?

    Optimize batch cycle time on a regular grid.

    optimize_pfr_volume

    fn optimize_pfr_volume(reaction : Reaction, feed : Feed, config : SearchConfig, target_conversion : Double, maximum_temperature : Double) -> ObjectiveScore?

    Find the smallest volume satisfying a conversion target and temperature limit.

    optimize_rate_multiplier

    fn optimize_rate_multiplier(reaction : Reaction, feed : Feed, volume : Double, config : SearchConfig, maximum_temperature : Double) -> ObjectiveScore?

    Search a reaction rate multiplier under a thermal limit.

    optimize_train_count

    fn optimize_train_count(reaction : Reaction, feed : Feed, total_volume : Double, minimum_stages : Int, maximum_stages : Int) -> ObjectiveScore?

    Optimize a CSTR/PFR train count at fixed total volume.

    outlet_flow

    fn outlet_flow(feed : Feed, point : DesignPoint) -> Double

    Outlet flow under constant-density assumptions.

    package_name

    fn package_name() -> String

    parallel_first_order_rates

    fn parallel_first_order_rates(concentration : Double, product_a_rate_constant : Double, product_b_rate_constant : Double) -> ParallelReactionResult

    parallel_product_rate

    fn parallel_product_rate(concentration : Double, rate_constant : Double, order : KineticOrder) -> Double

    Parallel product formation rate.

    parallel_selectivity

    fn parallel_selectivity(first_rate : Double, second_rate : Double) -> Double

    Selectivity of a parallel pair.

    parallel_split

    fn parallel_split(concentration : Double, first_rate : Double, second_rate : Double, first_order : KineticOrder, second_order : KineticOrder) -> (Double, Double)

    Product split between two parallel pathways.

    pareto_frontier

    fn pareto_frontier(scores : ArrayView[ObjectiveScore]) -> Array[ObjectiveScore]

    Filter a set to its non-dominated frontier.

    penalty_score

    fn penalty_score(score : Double, feasible : Bool, penalty : Double) -> Double

    Penalize an infeasible objective without changing feasible ranking.

    pfr_advantage_over_cstr

    fn pfr_advantage_over_cstr(damkohler : Double) -> Double

    Calculate the CSTR/PFR conversion advantage at equal Damkohler number.

    pfr_conversion_curve

    fn pfr_conversion_curve(reaction : Reaction, feed : Feed, volumes : ArrayView[Double]) -> Array[Double]

    PFR conversion over a sequence of volumes.

    pfr_conversion_isothermal

    fn pfr_conversion_isothermal(reaction : Reaction, feed : Feed, volume : Double) -> Double

    pfr_profile

    fn pfr_profile(reaction : Reaction, feed : Feed, volume : Double, points~ : Int, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> Array[ProfilePoint]

    Build an ideal plug-flow concentration profile.

    pfr_volume_from_curve

    fn pfr_volume_from_curve(conversions : ArrayView[Double], ordinates : ArrayView[Double], flow : Double) -> Double

    PFR volume from a tabulated Levenspiel curve.

    power_law_rate

    fn power_law_rate(rate_constant : Double, concentration : Double, order : Double) -> Double

    A generic power-law rate evaluation for screening.

    pressure_drop

    fn pressure_drop(length : Double, diameter : Double, density : Double, velocity : Double, friction_factor : Double) -> Double

    A conservative pressure-drop estimate for a pipe segment.

    product_molar_flow

    fn product_molar_flow(feed : Feed, point : DesignPoint, stoichiometric_yield : Double) -> Double

    Molar production rate of the desired product.

    profile_interpolate

    fn profile_interpolate(profile : ArrayView[ProfilePoint], position : Double) -> ProfilePoint

    Conversion at an arbitrary dimensionless axial coordinate.

    profile_is_monotone

    fn profile_is_monotone(profile : ArrayView[ProfilePoint]) -> Bool

    Check that a profile never decreases in conversion beyond tolerance.

    profile_rate_exposure

    fn profile_rate_exposure(profile : ArrayView[ProfilePoint]) -> Double

    Integrate conversion-weighted rate exposure over a profile.

    profile_summary

    fn profile_summary(profile : ArrayView[ProfilePoint]) -> String

    Render profile diagnostics as Markdown.

    profile_to_csv

    fn profile_to_csv(profile : ArrayView[ProfilePoint]) -> String

    Convert a profile to a stable CSV representation for notebooks.

    propagate_interval

    fn propagate_interval(reaction : Reaction, feed : Feed, volume : Double, rate_fraction : Double, temperature_delta : Double) -> ConversionInterval

    Build a conservative rectangular interval by evaluating all corners.

    rate_residual

    fn rate_residual(reaction : Reaction, concentration : Double, temperature : Double, measured : Double) -> Double

    Rate-law residual for a measured point.

    rate_temperature_ratio

    fn rate_temperature_ratio(reaction : Reaction, first_temperature : Double, second_temperature : Double) -> Double

    Rate ratio between two temperatures.

    relative_design_change

    fn relative_design_change(a : DesignPoint, b : DesignPoint) -> Double

    Compare two design points using normalized output deltas.

    relative_rate_error

    fn relative_rate_error(reaction : Reaction, concentration : Double, temperature : Double, measured : Double) -> Double

    Relative rate-law error.

    report_contains_all

    fn report_contains_all(report : String, labels : ArrayView[String]) -> Bool

    Check a text report for required labels.

    report_row_count

    fn report_row_count(report : String) -> Int

    Validate a stable report row count.

    required_cstr_volume

    fn required_cstr_volume(reaction : Reaction, feed : Feed, target_conversion : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> Double

    required_pfr_volume

    fn required_pfr_volume(reaction : Reaction, feed : Feed, target_conversion : Double, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> Double

    required_ua

    fn required_ua(duty : Double, delta_hot : Double, delta_cold : Double) -> Double

    Estimate a required UA from a duty and terminal temperature differences.

    residence_time

    fn residence_time(feed : Feed, volume : Double) -> Double

    residence_time_ratio

    fn residence_time_ratio(first : DesignPoint, second : DesignPoint) -> Double

    Residence-time ratio between two designs.

    residence_window_ok

    fn residence_window_ok(residence : Double, minimum : Double, maximum : Double) -> Bool

    Screen a residence time against a minimum and maximum.

    reversible_conversion

    fn reversible_conversion(forward : Double, reverse : Double, time : Double) -> Double

    Approach to equilibrium for a reversible first-order reaction.

    reversible_first_order_rate

    fn reversible_first_order_rate(model : ReversibleFirstOrder, reactant_concentration : Double, product_concentration : Double) -> Double

    reynolds_number

    fn reynolds_number(density : Double, velocity : Double, diameter : Double, viscosity : Double) -> Double

    Reynolds number for a pipe screening calculation.

    richardson_derivative

    fn richardson_derivative(x : Double, f : (Double) -> Double, step? : Double) -> Double

    Return a Richardson-improved derivative estimate.

    rk4_step

    fn rk4_step(time : Double, state : Double, step : Double, derivative : (Double, Double) -> Double) -> Double

    A single fourth-order Runge-Kutta step.

    root_mean_square

    fn root_mean_square(values : ArrayView[Double]) -> Double

    Root-mean-square of a signal.

    run_benchmark

    fn run_benchmark(case : BenchmarkCase) -> BenchmarkResult

    run_network

    fn run_network(reaction : Reaction, feed : Feed, stages : ArrayView[ReactorStage]) -> NetworkResult

    safety_counts

    fn safety_counts(points : ArrayView[ReactorSweepPoint], maximum_temperature : Double) -> (Int, Int)

    Count safe and unsafe points.

    safety_factor

    fn safety_factor(limit : Double, observed : Double) -> Double

    Safety factor between a limit and an observed value.

    safety_factor_ok

    fn safety_factor_ok(limit : Double, observed : Double, minimum_factor : Double) -> Bool

    Convert a safety factor to a pass/fail result.

    scale_scenario_flow

    fn scale_scenario_flow(scenario : OperatingScenario, multiplier : Double) -> OperatingScenario

    Apply a flow multiplier to an operating scenario.

    scale_scenario_rate

    fn scale_scenario_rate(scenario : OperatingScenario, multiplier : Double) -> OperatingScenario

    Apply a rate multiplier to an operating scenario.

    scenario_matrix

    fn scenario_matrix(base : OperatingScenario, rate_multipliers : ArrayView[Double], temperature_offsets : ArrayView[Double]) -> Array[OperatingScenario]

    Generate a Cartesian set of rate and temperature scenarios.

    scenario_meets_conversion

    fn scenario_meets_conversion(scenario : OperatingScenario, minimum_conversion : Double) -> Bool

    A conversion target envelope for a scenario.

    scenario_safety

    fn scenario_safety(scenario : OperatingScenario, maximum_temperature : Double) -> Bool

    A temperature safety envelope for a scenario.

    scenario_score

    fn scenario_score(scenario : OperatingScenario, target_conversion : Double, maximum_temperature : Double) -> Double

    Return a scenario's normalized performance score.

    scenario_volume_sweep

    fn scenario_volume_sweep(scenario : OperatingScenario, volumes : ArrayView[Double]) -> Array[ReactorSweepPoint]

    Evaluate a scenario across a volume grid.

    scenarios_to_csv

    fn scenarios_to_csv(scenarios : ArrayView[OperatingScenario]) -> String

    Build a scenario comparison CSV.

    score_design

    fn score_design(point : DesignPoint, conversion_weight : Double, volume_weight : Double, temperature_limit : Double) -> ObjectiveScore

    Score a candidate using conversion benefit and volume penalty.

    score_precedes

    fn score_precedes(a : ObjectiveScore, b : ObjectiveScore) -> Bool

    Stable tie-breaking comparator for design scores.

    screen_scenario

    fn screen_scenario(scenario : OperatingScenario, minimum_conversion : Double, maximum_temperature : Double) -> Bool

    Screen a scenario against conversion and temperature limits.

    screen_temperature

    fn screen_temperature(point : DesignPoint, maximum_temperature : Double) -> ThermalScreening

    Screen one design point against a maximum temperature.

    second_order_concentration

    fn second_order_concentration(initial : Double, rate_constant : Double, time : Double) -> Double

    Second-order concentration decay.

    second_order_exposure

    fn second_order_exposure(rate_constant : Double, concentration : Double, time : Double) -> Double

    Integrated second-order exposure.

    second_order_half_life

    fn second_order_half_life(rate_constant : Double, concentration : Double) -> Double

    Estimate a half-life for a second-order rate and concentration.

    second_order_time

    fn second_order_time(initial : Double, rate_constant : Double, conversion : Double) -> Double

    Invert a second-order conversion to time.

    selectivity_from_rates

    fn selectivity_from_rates(desired : Double, undesired : Double) -> Double

    Selectivity from desired and undesired product rates.

    selectivity_series_first_order

    fn selectivity_series_first_order(k1 : Double, k2 : Double, residence_time : Double) -> Double

    sensible_enthalpy

    fn sensible_enthalpy(capacity : Double, temperature : Double, reference : Double) -> Double

    Sensible enthalpy change under a constant heat capacity.

    sensible_enthalpy_linear

    fn sensible_enthalpy_linear(base : Double, slope : Double, temperature : Double, reference : Double) -> Double

    Sensible enthalpy change under a linear heat-capacity model.

    sensitivity_scan

    fn sensitivity_scan(reaction : Reaction, feed : Feed, volume : Double, multipliers : ArrayView[Double]) -> Array[DesignPoint]

    Generate a deterministic one-factor-at-a-time response table.

    sensitivity_to_markdown

    fn sensitivity_to_markdown(report : SensitivityReport) -> String

    Render a sensitivity report as Markdown.

    series_first_order_batch

    fn series_first_order_batch(initial_concentration : Double, first_rate : Double, second_rate : Double, time : Double) -> SeriesReactionResult

    series_intermediate

    fn series_intermediate(initial : Double, first_rate : Double, second_rate : Double, time : Double) -> Double

    Consecutive first-order intermediate concentration.

    series_product

    fn series_product(initial : Double, first_rate : Double, second_rate : Double, time : Double) -> Double

    Consecutive first-order product concentration.

    shift_scenario_temperature

    fn shift_scenario_temperature(scenario : OperatingScenario, offset : Double) -> OperatingScenario

    Apply a temperature offset to an operating scenario.

    sign_change_count

    fn sign_change_count(values : ArrayView[Double]) -> Int

    Detect a sign change between adjacent samples.

    simulate_controller

    fn simulate_controller(config : ControllerConfig, setpoint : Double, initial_measurement : Double, process_gain : Double, process_time_constant : Double, dt : Double, steps : Int) -> Array[ControllerStep]

    Simulate a controller against a first-order process model.

    space_time

    fn space_time(feed : Feed, volume : Double) -> Double

    space_velocity

    fn space_velocity(feed : Feed, volume : Double) -> Double

    Space velocity in inverse time.

    sweep_cstr

    fn sweep_cstr(reaction : Reaction, feed : Feed, max_volume : Double, points : Int, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> Array[ReactorSweepPoint]

    sweep_is_sorted

    fn sweep_is_sorted(points : ArrayView[ReactorSweepPoint]) -> Bool

    Check whether a sweep is sorted by volume.

    sweep_pfr

    fn sweep_pfr(reaction : Reaction, feed : Feed, max_volume : Double, points : Int, thermal_mode? : ThermalMode, exchange? : HeatExchange) -> Array[ReactorSweepPoint]

    sweep_temperature_range

    fn sweep_temperature_range(points : ArrayView[ReactorSweepPoint]) -> (Double, Double)

    Temperature range of a sweep.

    sweep_to_csv

    fn sweep_to_csv(points : ArrayView[ReactorSweepPoint]) -> String

    tabulated_trapezoid

    fn tabulated_trapezoid(x : ArrayView[Double], y : ArrayView[Double]) -> Double

    Trapezoid area for tabulated data.

    target_conversion_for_production

    fn target_conversion_for_production(feed : Feed, production : Double, product_yield : Double) -> Double

    Estimate a conversion target from a desired production rate.

    target_distance

    fn target_distance(point : ObjectiveScore, target_conversion : Double, target_volume : Double, target_temperature : Double) -> Double

    Compute a weighted distance from a target design.

    temperature_for_mode

    fn temperature_for_mode(mode : ThermalMode, feed : Feed, reaction : Reaction, conversion : Double, exchange : HeatExchange?) -> Double

    temperature_for_multiplier

    fn temperature_for_multiplier(activation_energy : Double, multiplier : Double, reference : Double) -> Double

    Estimate the temperature at which a rate reaches a target multiplier.

    temperature_residual

    fn temperature_residual(expected : Double, actual : Double) -> Double

    A dimensionless temperature residual.

    thermal_margin

    fn thermal_margin(temperature : Double, maximum : Double) -> Double

    Thermal feasibility margin relative to a maximum temperature.

    thermal_window_ok

    fn thermal_window_ok(temperature : Double, minimum : Double, maximum : Double) -> Bool

    True when all thermal values are finite in an engineering range.

    train_mass_balance_residual

    fn train_mass_balance_residual(feed : Feed, result : TrainResult) -> Double

    A stage-wise mass-balance residual for a train.

    train_peak_temperature

    fn train_peak_temperature(result : TrainResult) -> Double

    Return the largest temperature excursion in a train.

    train_summary

    fn train_summary(result : TrainResult) -> String

    Render a train summary as Markdown.

    train_to_csv

    fn train_to_csv(result : TrainResult) -> String

    Convert train results to a compact CSV table.

    uncertainty_samples

    fn uncertainty_samples(reaction : Reaction, feed : Feed, volume : Double, samples : Int) -> Array[Double]

    Produce deterministic samples for reproducible offline reports.

    uncertainty_summary

    fn uncertainty_summary(reaction : Reaction, feed : Feed, volume : Double, samples : Int) -> UncertaintySummary

    Summarize deterministic uncertainty samples with nearest-rank quantiles.

    uncertainty_summary_is_ordered

    fn uncertainty_summary_is_ordered(summary : UncertaintySummary) -> Bool

    Check that an uncertainty summary is ordered and non-negative.

    uncertainty_to_markdown

    fn uncertainty_to_markdown(summary : UncertaintySummary) -> String

    Render an uncertainty summary as Markdown.

    uniform_grid

    fn uniform_grid(config : SearchConfig) -> Array[Double]

    Sample a closed interval uniformly.

    validate_controller_settings

    fn validate_controller_settings(config : ControllerConfig, dt : Double, steps : Int) -> ValidationReport

    Validate controller sampling settings.

    validate_design_inputs

    fn validate_design_inputs(reaction : Reaction, feed : Feed, volume : Double) -> ValidationReport

    validate_design_point

    fn validate_design_point(point : DesignPoint, feed : Feed) -> ValidationReport

    Validate a candidate design point.

    validate_feed

    fn validate_feed(feed : Feed) -> ValidationReport

    validate_feed_window

    fn validate_feed_window(feed : Feed, minimum_temperature : Double, maximum_temperature : Double) -> ValidationReport

    Validate a feed against a named operating window.

    validate_reaction

    fn validate_reaction(reaction : Reaction) -> ValidationReport

    validate_reaction_temperature

    fn validate_reaction_temperature(reaction : Reaction, temperature : Double) -> ValidationReport

    Validate a reaction for a stated design temperature.

    validate_sweep

    fn validate_sweep(points : ArrayView[ReactorSweepPoint], feed : Feed) -> ValidationReport

    Validate every point in a reactor sweep.

    validate_temperature_interval

    fn validate_temperature_interval(minimum : Double, maximum : Double) -> ValidationReport

    Validate a temperature interval before a design sweep.

    validate_tolerance

    fn validate_tolerance(tolerance : Double, maximum_depth : Int) -> ValidationReport

    Validate that a numerical tolerance is useful and finite.

    validate_train

    fn validate_train(result : TrainResult) -> ValidationReport

    Validate a train's aggregate volume and conversion.

    validate_volume_grid

    fn validate_volume_grid(minimum : Double, maximum : Double, points : Int) -> ValidationReport

    Validate a volume grid.

    validation_to_markdown

    fn validation_to_markdown(report : ValidationReport) -> String

    Render validation messages with a stable severity prefix.

    velocity_window_ok

    fn velocity_window_ok(velocity : Double, minimum : Double, maximum : Double) -> Bool

    Check whether a pipe flow is inside a declared velocity window.

    volume_for_production

    fn volume_for_production(reaction : Reaction, feed : Feed, production : Double, product_yield : Double) -> Double

    Estimate volume required for a production target with a PFR point.

    volumetric_heat_release

    fn volumetric_heat_release(reaction : Reaction, feed : Feed, conversion : Double) -> Double

    Heat released per unit feed volume.

    volumetric_heat_removal

    fn volumetric_heat_removal(exchange : HeatExchange, temperature : Double, coolant : Double) -> Double

    Heat removal per unit volume from a lumped jacket.

    volumetric_productivity

    fn volumetric_productivity(feed : Feed, point : DesignPoint) -> Double

    Volumetric productivity for a design point.

    weighted_mean

    fn weighted_mean(values : ArrayView[Double], weights : ArrayView[Double]) -> Double

    Weighted mean of a tabulated signal.

    yield_from_conversion_selectivity

    fn yield_from_conversion_selectivity(conversion : Double, selectivity : Double) -> Double

    yield_from_metrics

    fn yield_from_metrics(conversion : Double, selectivity : Double, stoichiometric_factor : Double) -> Double

    Yield from conversion and selectivity.

    zero_order_concentration

    fn zero_order_concentration(initial : Double, rate_constant : Double, time : Double) -> Double

    Zero-order consumption over a bounded time interval.

    zero_order_time

    fn zero_order_time(initial : Double, rate_constant : Double, conversion : Double) -> Double

    Invert a zero-order conversion to time.