A reusable report layer for MoonBit chemical-engineering calculations.
moon run cmd/mainmoon check --deny-warn
moon test --deny-warn
moon run cmd/main///|
let r = report(
"CSTR A-101 Mass Balance",
summary="A stable report record for a reactor inlet/outlet balance.",
inputs=[
input(
"feed flow",
quantity("100.0", "kmol/h"),
note="measured at battery limit",
),
],
assumptions=[assumption("steady state", "accumulation term is zero")],
formulas=[formula("A in", "F_A,in = F_feed * z_A", ["F_feed", "z_A"])],
results=[
result("A feed", quantity("42.0", "kmol/h"), procedure="100.0 * 0.42"),
],
warnings=[caution("conversion target should be reconciled before scale-up")],
sources=[source("design basis", "internal design basis document")],
)
///|
let markdown = r.to_markdown()
///|
let html = r.to_html_document()
///|
let json = r.to_json()moon fmt --check
moon check --deny-warn
moon info
moon test --deny-warnpub struct BalanceCheck {
status : BalanceStatus
inlet : String
outlet : String
difference : String
tolerance : String
} derive(Eq, Debug)pub struct ChangeDetail {
section : String
severity : ChangeSeverity
message : String
} derive(Eq, Debug)pub struct ChemReport {
title : String
summary : String
inputs : Array[ChemInput]
assumptions : Array[Assumption]
formulas : Array[Formula]
results : Array[ChemResult]
warnings : Array[ReportWarning]
sources : Array[DataSource]
} derive(Eq, Debug)fn ChemReport::warnings_with_severity(self : ChemReport, severity : Severity) -> Array[ReportWarning]pub struct ProvenanceLedger {
report_id : String
entries : Array[ProvenanceEvent]
} derive(Eq, Debug)fn ProvenanceLedger::record(self : ProvenanceLedger, event : ProvenanceEvent) -> Result[ProvenanceLedger, ProvenanceError]fn ReportArchive::append(self : ReportArchive, value : ReportSnapshot) -> Result[ReportArchive, ArchiveError]pub struct ReportBuilder {
title : String
summary : String
inputs : Array[ChemInput]
assumptions : Array[Assumption]
formulas : Array[Formula]
results : Array[ChemResult]
warnings : Array[ReportWarning]
sources : Array[DataSource]
} derive(Eq, Debug)fn ReportIndex::add(self : ReportIndex, id : String, report : ChemReport, keywords : Array[String]) -> ReportIndexpub struct ReportIndexEntry {
id : String
title : String
keywords : Array[String]
report : ChemReport
} derive(Eq, Debug)pub struct UnitSpec {
symbol : String
dimension : UnitDimension
to_base : String
offset : String
} derive(Eq, Debug)fn quality_policy(min_inputs? : Int, min_formulas? : Int, min_results? : Int, require_source_url? : Bool, reject_hazards? : Bool) -> QualityPolicyfn report(title : String, summary? : String, inputs? : Array[ChemInput], assumptions? : Array[Assumption], formulas? : Array[Formula], results? : Array[ChemResult], warnings? : Array[ReportWarning], sources? : Array[DataSource]) -> ChemReportfn unit_spec(symbol : String, dimension : UnitDimension, to_base : String, offset? : String) -> UnitSpecInstall
Download zipA reusable report layer for MoonBit chemical-engineering calculations.