Comprehensive MoonBit Safety Relief Calculation & Sizing Library for Process Safety Engineering
| Area | Functionality |
|---|---|
| Gas and vapor | API 520 critical/subcritical sizing, real-gas correction, steam tables, fire heat load, blowdown and dust venting |
| Liquid | Incompressible sizing, viscosity iteration, backpressure and overpressure corrections, thermal expansion and subcooled flashing |
| Two-phase | DIERS Leung Omega, TPHEM, Henry-Fauske, slip ratio, void fraction and flow-regime classification |
| Thermodynamics | Peng-Robinson/SRK EoS, PT/PH/PS flash solvers, Rachford-Rice, DIPPR correlations and matrix solvers |
| Devices | API 520 orifices, API 526 catalog data, spring mechanics, pilot-operated configuration, bellows and rupture disks |
| Piping | Colebrook/Darcy-Weisbach, inlet 3% rule, discharge Mach check, flare headers, water hammer and ASME B31.3 wall thickness |
| Assurance | Input bounds, scenario rules, API 520 checklist, LOPA/PSM review, governing envelopes and pressure sensitivity |
| Reports | Markdown, HTML, text, CSV, LaTeX and SPI XML calculation outputs |
| Package | Path | Responsibility |
|---|---|---|
| Core types | src/types | Process conditions, fluid properties, scenarios, errors and units |
| Thermodynamics | src/thermo | EoS, flash solvers, property correlations and matrix algorithms |
| Gas | src/gas | Gas/vapor and fire-case sizing |
| Liquid | src/liquid | Liquid sizing, viscosity and thermal relief |
| Two-phase | src/twophase | DIERS and flashing-flow models |
| Devices | src/devices | Orifice/device catalogs and mechanical checks |
| Piping | src/piping | Relief inlet, outlet and flare-network hydraulics |
| Validation | src/validation | Bounds, scenarios, envelopes and safety audits |
| Workflow | src/workflow | Typed end-to-end case evaluation and sensitivity analysis |
| Reports | src/report | Engineering report renderers |
| Benchmarks | src/benchmarks | Standard and textbook regression cases |
moon version --all
moon check --target all
moon test --target all
moon run cmd/benchmark --target nativeimport {
"wjcoomk/moonbit-relief/src/types",
"wjcoomk/moonbit-relief/src/workflow",
}
fn main {
let case = @workflow.api520_gas_reference("PSV-101")
match @workflow.evaluate_case(case) {
Ok(result) => {
println("Area: \{result.required_area_mm2} mm2")
println("Orifice: \{result.selected_orifice.letter}")
println("Margin: \{result.margin_percent}%")
}
Err(error) => println(error.message())
}
}let request = @workflow.SizingInput::Liquid(
proc=process_conditions,
fluid=fluid_properties,
specific_gravity=0.92,
kd=0.65,
kc=1.0,
)
let case : @workflow.ReliefDesignCase = {
tag: "P-204",
scenario: @types.ReliefScenario::ThermalExpansion,
sizing: request,
}$files = Get-ChildItem src -Recurse -Filter '*.mbt' | Where-Object {
$_.FullName -notmatch '\\benchmarks\\' -and $_.Name -notmatch '_test\.mbt$'
}
($files | Get-Content | Measure-Object -Line).Linesmoon check --target all
moon test --target all
moon check --deny-warn
moon test --deny-warn
moon fmt --check
moon info
moon build --target native
moon run cmd/benchmark --target nativemoon fmt --check
moon check --deny-warn
moon test --deny-warn
moon info
moon run cmd/benchmark --target nativeComprehensive MoonBit Safety Relief Calculation & Sizing Library for Process Safety Engineering