Repository navigation
Flowsheets and routes
A process is many steps joined by streams, and some streams return to an earlier step. extensions/chemistry/flowsheet.mojo solves the steady state of such a loop. routes.mojo searches a library of reactions for the sequences that make a product from what is on hand.
This page is a reference. For the rest of the library, see Process chemistry.

A Flowsheet has components, the substances its streams carry. add_stream(name) returns a StreamId. A stream is a feed, which the caller sets, or the outlet of one unit.
| Method | Unit |
|---|---|
set_feed(id, names, amounts) |
Sets a feed stream |
mixer(name, inlets, outlet) |
Adds its inlets |
reactor(name, inlet, outlet, reaction, conversion) |
Runs a reaction to a share of its limiting reactant |
splitter(name, inlet, first, second, names, shares) |
Sends a share of each named component to the first outlet, and the rest to the second |
The units run in the order they were added. A stream has one source, a feed or one unit, and it goes to one unit at most.
A recycle makes a loop. set_guess(id, names, amounts) gives a stream in the loop a starting value. solve() then runs the units again and again until every stream stops changing. This is successive substitution on the loop's tear streams. It returns the passes taken, and it raises an error if the streams do not settle.
amount(id, name) reads a component of a stream. net(element) is the element balance of the whole sheet: what the feeds bring in, less what leaves in streams that no unit takes. At steady state, it is zero.
The amounts are on any basis the caller chooses: per second, per hour or per batch.
processes.titanium.kroll_loop() returns the Kroll route as a flowsheet:
- The chlorinator turns rutile, coke and chlorine into TiCl4 gas and CO2.
- The condenser takes the TiCl4. The rest leaves as off-gas.
- Magnesium reduces the TiCl4 to titanium sponge and MgCl2.
- An electrolysis cell splits the MgCl2. Its magnesium returns to the reducer, and its chlorine returns to the chlorinator.
The feeds are one mole of rutile and of carbon, and 0.1 mole of make-up chlorine. The loop settles in 22 passes to one mole of titanium, with two moles each of magnesium and chlorine in the recycles. examples/kroll_loop.mojo draws the figure above from the solved sheet.
find_routes(library, feeds, target, low, high, pressure, max_steps) searches a list of reactions breadth first. A state is the set of substances on hand, by name. A reaction can run when every reactant is on hand and it has a window: a temperature in the range where it proceeds. Its products join the substances on hand.
Each route is a list of indices into the library, shortest first, each reaction used once. A route that holds every step of a shorter route is left out, because one of its steps does nothing. max_routes limits the count, 100 by default.
From rutile, chlorine, coke and magnesium, the search finds the Kroll route and the magnesiothermic reduction of rutile. It does not find carbothermic reduction, because that has no window below 1500 K.
A route is a candidate, not a process. The search knows only the driving force of each step. Build a Step for each candidate to check its rates, phases and equipment.
The units have no energy balance. Use heat_duty from balance for each unit. A reactor runs to a fixed conversion, not to equilibrium. Use Chemical equilibrium to find a conversion. Successive substitution converges slowly where a loop's recycle is much larger than its feed.
Tutorials
How-to
- Install
- Run the checks
- GPU backend
- Coverage
- Measure examples
- Add a feature
- Add a scanned building
- Write documentation
Reference
- Scene graph
- Rotations
- Cameras
- Geometry
- Geometry addons
- Lofts and clipping groups
- Sculptor
- Procedural generators
- Meshes and assets
- Lines
- Points and sprites
- Helpers
- Scene objects
- Animated objects
- Raycasting
- Curves and paths
- Animation
- Skinning
- Materials
- Node materials
- TSL functions
- Lights
- Lighting addons
- Fog
- Textures
- Renderer
- Renderer hooks and material flags
- Rasterization
- GPU backend
- Render target
- Post-processing
- GPU computation
- Compute nodes
- Progressive light map
- Gaussian splats
- Voxel global illumination
- SVG renderer
- Image files
- Image decode queue
- Model files
- More model files
- Exporters
- Scene JSON
- Windowing and controls
- C ABI and hosts
- Math
- Norm consumers
- Math addons
- Units
- Coverage tool
- Commands
- Examples
- Benchmarks
- Extensions
- Shared physics
- Physics query snapshots
- Continuous collision
- Tick force restoration
- Water
- Warp drives
- Vegetation
- Village
- Streamline
- Animals
-
Buildings
- Numerics
- Building topology
- Building model
- IFC exchange
- Procedural towers
- Floor plans and interiors
- Frame analysis
- Shell analysis
- Building energy
- Construction kits
- Bearing walls
- Scanned buildings
- SOG files
- Compressed PLY files
- Scan parts
- Cleaning and orienting scans
- Walking through a scan
- Virtual scans
- Castle
- CARLA
- Femur
- Tibia
- Fibula
- Patella
- Knee
- Muscles
- Vessels
- Lymph
- Nerves
- Integument
- Leg
- Foot
- Pelvis
- Torso
- Arm
- Hand
- Head
- Genome
- Game humanoid
- Humanoid fidelity
- Mixamo animations
- Audio-aligned game faces
- Converted assets
- Mesh quality
- Garments
- Outfits and armor
- Cloth and spring bones
- Attire estimates
- Segment inertia
- Process chemistry
- Thermochemical data
- Chemical equilibrium
- Process maps
- Rates and transport
- Electrolysis and film color
- Binary solutions
- Flowsheets and routes
- Materials and coatings
- Crystals and figures
Explanation
- Software rasterizer
- Scene graph as an array
- Linear color
- Normals are not colors
- Perspective correction
- Fixed-point coverage
- Per-fragment shading
- Mipmaps
- Sorted transparency
- Types and checks
- Render hooks as a trait
- Shared CPU and GPU code
- Bands and threads
- PNG structure
- Extensions beside the port
- Process temperatures
- Scans as building models
- CUDA teardown hang
- Mojo compiler hang