Skip to content

ChemE-as-Code

Plant design as code. A process plant kept as plain files in a git repository: DEXPI 2.0.1 P&IDs, engineering lists in YAML, decisions in Markdown. Engineers and coding agents such as Claude Code edit the files; cheme, the command of the cheme-as-code package, checks them.

cheme gives people and agents what they need to work on engineering files the way they work on code: a validator with file:line findings, a formatter that keeps diffs small, a renderer, a visual diff and engineering-step gates. On top of that it generates the BFD and PFD from process YAML, builds a 3D layout model, and derives a material take-off, an estimate and an LCA from the committed files.

Status

Research prototype of the Process Intelligence Research group. Since 0.7.0 the package is cheme-as-code, the import name chemeascode and the command cheme (formerly plantcode); plant repositories migrate once, see Rename.

Where to start

At a glance

cheme init my-plant --name "Ethanol plant"   # folders, schemas, agent skills, CI
cd my-plant && git init && cheme git-setup    # readable P&ID diffs, pre-commit hook
cheme validate                                # P&IDs + lists, and lists vs P&IDs
cheme validate --ignore cheme.label-literal  # leave a rule out (--only: just these)
cheme sheet new P-01 --title "Feed and reaction"  # a sheet with a real title block
cheme sheet meta P-01 Revision=B Status=issued   # title-block values, texts updated too
cheme fmt                                     # canonical XML, a readable id on every object
cheme render                                  # build/<sheet>.svg
cheme render --png --crop 150,50,300,180      # build/<sheet>_crop-150-50-300-180.png
cheme render --png --tiles 4x3 --findings     # build/<sheet>_tile-A1.png ... C4, findings marked
cheme diff main                               # build/diff.html, changes highlighted
cheme diff main --list                        # one line per changed plant item
cheme show T4750                              # where an object is, and what it connects to
cheme show K-4101 --layout                    # measured plot-plan distances around it
cheme --version                               # cheme-as-code, pyDEXPI, the interpreter path
cheme run scripts/draft_P-02.py pid/P-02.xml  # a generator, with pyDEXPI importable
cheme regen P-02                              # rebuild a generated sheet (plant.yaml generator:)
cheme copy P4711 --prefix Pump_P4711B --tag P4711B --offset 0,30   # a spare, with its drawing
cheme fragment valve --id V1 --class GateValve --dn 80 --at 70,184 # XML to paste
cheme move Inst_FI101 --offset -8,12          # nudge a symbol with its nodes and labels
cheme rename T4101_I1 T4101_N6 --children     # an id, every #reference, the ids under it
cheme set Line_101 FluidCode=Nitrogen         # a data value and the labels that show it
cheme status [--json]                         # sheets, findings by sheet, gates, sign-offs
cheme check                                   # engineering-step gates (checks/checks.yaml)
cheme cause-effect                            # build/cause-effect.html + .csv
cheme process build                           # BFD and PFD from process/materials.yaml + flowsheet.yaml
cheme process streams [--md]                  # stream table with provenance, block balances
cheme process propagate --fill                # compositions/flows through compressors, mixers, splitters, reactors
cheme process reactors                        # per reactor: extents, heats of reaction, ln(Q/K), duty
cheme process crystallizers                   # per crystallizer/filter: basis, crystals, recovery, dry solid and moisture
cheme process energy                          # energy balances, simulation energy audit, boundary gaps
cheme process pinch --dt-min 10               # pinch targets of the recorded simulation run
cheme process furnace [K-101]                 # lime kiln: elements, off-gas, furnace energy closure (extra cantera)
cheme chemistry thermo ammonia                # ideal-gas formation data for materials.yaml (extra props)
cheme process props --fill                    # phase, density, enthalpy (extra props), in range only
cheme process methods                         # which thermodynamic models phase/simulate run, substitutes
cheme process phase A B --model Peng-Robinson # kij coverage per pair; with -T/-P a flash (extra props)
cheme process extract [UNIT] [--systems]      # LLE extraction stages, process/extraction.yaml (extra props)
cheme process layout --view pfd --pin         # keep the generated positions in flowsheet.yaml
cheme layout build [--check]                  # layout/plant-model.yaml: 3D parts, nozzles, envelopes
cheme layout cables [--write]                 # cable schedule: from, to, size, trays, length
cheme layout lifting [--write]                # lifting study: radius, load moment, capacity per heavy lift
cheme assess mto | estimate [--write]         # material take-off of the model, factor estimate
cheme assess equipment [--write]              # equipment costs from published correlations (Turton)
cheme assess tea [--write] [--compare REV]    # TEA: capex build-up, cash flow, NPV/IRR/LCOP, drivers
cheme assess lca [--write | --check]          # LCA per functional unit; lca/dataset.yaml, results
cheme assess lca --write --case B             # case B's own LCI dataset: lca/datasets/<id>-b.yaml
cheme datasheets draft [--tag T]              # draft datasheets for items without one (sources, TBD)
cheme datasheets fill [--tag T] [--param k=v] # calculated sizes with their basis into the drafts
cheme schema [equipment]                      # JSON Schema of a YAML file kind (none: list them)
cheme migrate [--check | --write]             # add `schema: cheme/<kind>/v1` where a YAML input lacks it
cheme serve                                   # read-only JSON API on 127.0.0.1:8765