Skip to content

Releases

v0.5.0

Choose a tag to compare

@jkitchin jkitchin released this 31 Oct 00:48
ba3341e

Highlights

  • Breaking: the browser editor now ships as difflow-app with the difflow book. difflow.gui is renamed difflow.workspace, and difflow.publish is removed (sweep, SweepAxis and SweepResult live in difflow.sweeps and are still exported from difflow).
  • New: an interactive flowsheet debugger (difflow.debug, difflow debug, and MCP tools), feedback control (difflow.control: PI(D) and linear MPC), and model-discrimination / c-optimal experiment design.
  • Fixed: Fisher confidence intervals were too narrow by √2 (#512), plus planner, monitoring, reconciliation, stochastic and dynamic-CSTR fixes (#513–#519). The notebooks now run on jax 0.11 (#525).

Full details from CHANGELOG.md:

Breaking

  • The browser editor moved out of difflow, to the app that comes with the difflow book. difflow is the
    open engine; the editor (canvas, inspector, results, planning, console, assistant, and the debugger's
    Debug and Trace panels), its server, its frontend and the static publish page are now difflow-app,
    which registers itself as a difflow.apps entry point. difflow gui and the agent tool
    open_in_editor run it when it is installed and say where it comes from when it is not; a bare
    difflow prints usage without it. The session engine stays open and is renamed difflow.gui ->
    difflow.workspace (FlowsheetSession, edit, boilerplate, console, context, docs, docs_index,
    doclinks, examples, layout, planning, sensitivity, and the new topology); the agent and MCP tools are
    unchanged. difflow.publish is gone: sweep, SweepAxis and SweepResult are in difflow.sweeps (and
    still exported from difflow); the HTML page is the app's. The docs search index is
    src/difflow/workspace/data/docs-index.json, rebuilt with make docs-index (CI checks it); the
    gui-build/gui-test/gui make targets, the editor's CI job and the difflow-gui script are removed.

Added

  • Example notebook examples/69_flowsheet_debugger.ipynb. The flowsheet debugger on a recycle loop: stepping
    by unit and tear iteration, breakpoints on a unit, a condition and an event, on_error finding the unit where a
    NaN is born (in the tear-guessing pass), set tear, record and replay, and what-ifs on a loop with two steady
    states (including Anderson converging to the unstable middle one); DebugRunner and the JSON protocol.

  • An interactive debugger for flowsheet solves. New difflow.debug (docs/debugger.md) and difflow debug plant.py|plant.json. Pauses a sequential-modular solve at solve_start, before_unit/after_unit (each
    unit call, tagged by phase: init, solve, probe, final, sequential), unit_error, iteration (the
    tear map and its residual), after_accel and terminated; steps by tear iteration (step), by unit
    (next) or by checkpoint (stepi). Breakpoints by iteration, before a unit, on a condition
    (break if residual>1e3 && iter>5) or on an event (nonfinite where a NaN is born, inner_unconverged,
    residual_rise, unit_error); print streams, units, the tear table (x, g(x), |g - x| per field)
    and the history; watch, diagnose, save, and interact (Python with the pause in scope).
    on_error=True stops only post mortem. One engine, three front ends: a readline REPL, the difflow-dbg/1
    JSON protocol (a self-describing hello, pause/result events with request ids) and DebugRunner, which
    runs the solve on a worker thread for a server or an agent. Detached it costs one thread-local read per
    checkpoint; attached it only reads, and quit raises DebugQuit. Design and the editor/agent phases in
    plans/debugger.org, after pounce's and discopt's debuggers.
    set tear STREAM.FIELD VALUE (at an iteration or after_accel pause) changes the guess the next pass
    runs on; edits are listed in the terminated event and Flowsheet.last_solve_debug_edits.
    debug.record(fs, solve_kwargs) solves once through every checkpoint and returns a difflow-trace/1
    trace (summarize, state_at and compare read it). A what-if replays the recorded solve with one
    tear value set at a frame (record(..., edits=, baseline=)): a replay, not a fresh solve, so the
    accelerator keeps its history; frames before the edit are checked against the recording (diverged_at),
    and compare says whether the two runs reached the same answer. FlowsheetSession (now
    difflow.workspace) carries a live debugger for front ends that cannot block on a prompt: a long poll
    (debug_start|command|wait|pause|stop, 20 s per call) over DebugRunner, which gained state and
    pause(), plus debug_record/debug_whatif, refusing a recording of a since-changed flowsheet; the
    solve runs on a copy. (The book's browser editor puts its Debug and Trace panels on these.)
    For agents, difflow mcp serves the same debugger: debug_guide (the contract and the handshake),
    debug_start, debug_command, debug_wait, debug_pause, debug_state, debug_stop, over the
    session's FlowsheetSession.debug_* methods; the fix_convergence prompt uses them. Record and what-if
    for agents: debug_record (a per-iteration summary: frame, residual, largest tear entry, events, regime),
    debug_trace_frame (one frame with every stream's value there) and debug_whatif (the replay compared
    with the recording, same_answer flagging a second steady state); difflow.debug.record.summarize,
    state_at and compare. Recording and replay now run on a copy of the flowsheet.

  • Model-discrimination and c-optimal experiment design (issue 520).
    difflow.estimation.design_discrimination(models, thetas, candidates, n, criterion='HR') chooses the
    candidate runs that best tell rival models apart, each model at its own fitted parameters: 'HR'
    (Hunter-Reiner, the squared prediction differences over the model pairs weighted by 1/sigma^2; additive,
    so the best run replicated) or 'BF' (Buzzi-Ferraris, the difference against the measurement and both
    models' prediction variances, from covariances= or the existing= runs; greedy on the set). It returns a
    DiscriminationResult with every candidate's score, per model pair, and each model's predictions over the
    pool (one vmap per model). design_experiments(..., criterion='C', quantity=g) is c-optimal design: it
    minimizes c^T FIM^-1 c, the predicted variance of a derived quantity g(theta) (c = jax.grad(g) at
    theta, or quantity=c directly); design_criterion(fim, 'C', c=...) gives the value and
    DesignResult.c the gradient. CRITERIA now includes 'C'.

  • Feedback control: PI(D) and linear MPC (issue 520). New difflow.control (docs/control.md).
    PIDController (also in difflow.dynamic) is a dynamic unit for a DynamicFlowsheet: parallel PI(D) with
    derivative on the filtered measurement, output limits and back-calculation anti-windup (tracking time
    constant tau_T, inf for none), reverse/direct action; gains, setpoint and limits are constants, f(t),
    f(t, args) or (setpoint) a port, read per call from params, so jax.grad through simulate tunes the
    loop. Its output is a signal stream whose T carries u; DynamicCSTR now takes duty, UA or Tc from
    such a port and declares that its outlet does not read it (output_dependencies/partial_outputs), so a
    controller measuring the outlet closes the loop without an algebraic loop (DynamicFlowsheet accepts
    output_dependencies(inlet_ports) as a method). LinearMPC (from_model linearizes a StateSpaceModel by
    autodiff) solves the input-bounded receding-horizon QP exactly with box_qp (primal-dual active set, JAX),
    offset-free through an output bias; run_mpc runs the closed loop against any JAX plant as one lax.scan.
    StateSpaceModel.from_flowsheet makes a DynamicFlowsheet a model for difflow.mhe and the MPC (input as
    the flowsheet's args, theta as its params), and DynamicFlowsheetResult.stream_history returns a
    stream over the trajectory.

Fixed

  • make notebooks installs what the notebooks import, and they run on jax 0.11. The notebook rule ran under
    plain uv run, which installs no extras, so every notebook that imports tabulate, asdex, gaspype or pounce
    died with ModuleNotFoundError; it now runs with the examples, solvers and gaspype extras and
    pounce-solver[jax]. jax 0.11 removed jax.core.get_opaque_trace_state and jax.core.Effect, which flax
    0.12.2 still called, and xla_pmap_p, which numpyro 0.20 (under gpjax) still imported: flax is floored at
    0.12.9 on Python >= 3.12 and numpyro at 0.21.0. pandas joins the examples extra. Every notebook is
    re-executed (#525).

  • difflow.particles exports DRAG_METHODS. It was missing from __all__, so
    from difflow.particles import * raised NameError on it (#525).

  • The bastnasite example cuts between Ce and Pr. Its extraction pH (1.05) was tuned on the REE circuit model
    before the organic-flow, loading-capacity and scrub-recycle fixes; on the corrected model it sent 86 % of the
    Pr to the raffinate and net income never changed sign over the scale sweep. At pH 1.20 the closed loop
    recovers 99.7 % Pr and 100 % Nd and rejects 99.95 % Ce. The purity ceiling now counts only the elements
    between the extraction and strip cuts (Dy and Y stay on the solvent), and the prose no longer says a third
    of the Pr is lost whatever the scrub does: Pr is placed by stages, at the cost of recycle inventory (#525).

  • The debugger's p history and diagnose read a history mid-solve by its observed rate ("falling, about
    x0.039 per iteration", or creeping, rising, oscillating) instead of applying the verdict meant for a finished
    solve, which called a residual falling fast after three iterations "creeping".

  • Fisher confidence intervals were too narrow by sqrt(2) (issue 512).
    fisher_confidence_intervals...

Read more

v0.4.0

Choose a tag to compare

@jkitchin jkitchin released this 28 Oct 14:56
fe1c6b5

The first release on PyPI since 0.2.2: 0.3.0 was prepared but never tagged or published, so
0.4.0 also carries everything listed under 0.3.0 in
CHANGELOG.md.

Added

  • Unit-ops book Part VI gaps (issue 451).
    Costs. difflow.economics.dryer_cost (rotary direct, drum and tray from Turton et al. Table A.1; spray from
    Towler & Sinnott Table 7.2), crystallizer_cost (forced-circulation and draft-tube-baffled from Seider et al.
    Table 16.32, in t/day; batch from Turton), cooling_tower_cost (Towler & Sinnott cooling tower and pumps, L/s),
    and separator_cost(area, "filter_press") plus leaf, cartridge, gravity, pan, table and tube filters (Turton).
    New tables DRYER_COSTS, CRYSTALLIZER_COSTS, COOLING_TOWER_COSTS. The constants were read from the
    openpytea 3.2.0 and ecoana 0.0.1 transcriptions of those tables (cited in the code), not the printed books.
    Cooling tower. CoolingTower fan power: fill_pressure_drop, or fill_loss_coefficient + frontal_area,
    plus other_pressure_drop, fan_efficiency (default 0.65) and fan_location add
    info["fill_pressure_drop"], ["total_pressure_drop"], ["air_volumetric_flow"] and ["fan_power"] (W). No
    published fill correlation is built in yet; outputs are unchanged when the new parameters are not given.
    Drying. DryerParams.T_heater_in sets the heater-inlet air for the energy basis (the mixed air with
    recirculation), and info["heater_duty"].
    Crystallization. Optional Arrhenius kinetics (kinetics_Ea=[E_g, E_b], kinetics_T_ref;
    arrhenius_factor), so dL50/dT is no longer zero at fixed residence time. Optional Randolph-Larson R-z fines
    destruction and classified product removal (fines_ratio, fines_cut_size, product_classification,
    product_cut_size; rz_distribution, rz_moments): a piecewise-exponential population density, with the
    moments, closure and L_50 taken from it, and new info keys M_product, product_moments, fines_dissolved.
    Mechanical. DiscStackParams(d_bins=, mass_fractions=), as for Settler/Cyclone (per-bin
    grade_efficiency, overall_efficiency).
    Solvers. difflow.solve_scalar: a differentiable scalar root finder (Newton with an optional
    bisection-safeguarded bracket) that works under jit, differentiates by the implicit function theorem with
    respect to args and closed-over values, and returns a converged flag with return_info=True.
    All new options default off.

  • Gaspype species data in GibbsReactor (#492). New difflow.gaspype_import: GaspypeThermo(species)
    adapts gaspype's ~1000 NASA-9 gas-phase species to GibbsReactor's thermo
    interface, and list_available_species searches its database. Gaspype's own JAX equilibrium cannot be
    differentiated under jax.jit (a while_loop), but through the adapter the reactor's implicit gradients
    compile. GaspypeThermo is exported flat (gaspype is imported only when one is built), and a flowsheet
    using it saves, reloads and goes through codegen. Optional extra difflow[gaspype]; also in dev, so
    the tests run in CI. Example notebook examples/65_gaspype_thermo.ipynb.

  • The editor asks before a file runs code. Opening a flowsheet ran its code context (and a .py script, and
    now modules named by import path) with no question asked. A file that would run code now opens nothing until
    trusted: the page shows the code and the modules and asks Trust it and open?; declining leaves no file open,
    so Save cannot write an empty canvas over it. difflow gui --trust skips the question; bundled examples, files
    saved in the session and code typed into the editor are never asked about. Python: FlowsheetSession(..., trust=True), open_file(path, trust=True), needs_trust/blocked, and serialize.untrusted_modules. Undo and
    redo now rebuild with the trust their model was opened with (they failed on a model naming a module of yours),
    and Workbench(allow_exec=False) refuses a JSON with a code context, as it did a .py file.

  • serialize covers every difflow model. save/load now also take a DynamicFlowsheet (units as their
    class and constructor call, time-dependent feeds), a PowerNetwork and a RadialFeederFlowsheet; a
    Flowsheet subclass (GasNetworkFlowsheet) keeps its class. New: CubicThermo, ActivityThermo and
    dataclass thermos (IdealGasThermo, GibbsThermo); functions and classes by import path, difflow's
    (kinetic_fn=monod_kinetics, which left every bioreactor flowsheet unsaveable) and yours, the latter loaded
    only with trust=True; any object whose class keeps its constructor arguments by name (checked by
    rebuilding it on write) or records its call (difflow.init_args.record_init_args); saved results
    (save(..., results=streams), fs.saved_results, serialize.warm_start); and single objects
    (save_object/load_object, dumps_object/loads_object, to_value/from_value). Format version 3,
    written only when a file needs it: a plain flowsheet is still version 2.

  • serialize/codegen write PengRobinson and SRK. An equation of state is written as the critical
    properties and k_ij that build it ($eos; a {(i, j): value} dict as [i, j, value] triples), wherever it
    appears: EOSFlash's required eos (such a flowsheet could not be saved at all), Flash(..., eos=...)
    (which warned and reloaded as an ideal flash), or a Params field such as CSTRParams.eos. codegen writes
    it as get_critical_props lookups when the properties match the database. A subclass is refused rather than
    rebuilt as its base.

  • Example notebook examples/64_serialization.ipynb. Saving and reloading a recycle flowsheet with
    difflow.serialize (exact answer and gradient after reload), what the file holds, refs= and extras=,
    format versions, and export through difflow.codegen.

  • Core membrane separations (unit-ops book Ch. 22). New difflow.units.membranes: GasPermeator (any
    number of species; complete mixing, cross flow, cocurrent or countercurrent; given area or stage cut;
    implicit-function gradients), ReverseOsmosis (plug-flow RO with solution-diffusion fluxes, film-theory
    polarization, van't Hoff osmotic pressure and the recovery limit), and library functions: the binary
    complete-mixing closed forms (Geankoplis 5e §13.4), permeation_stage, area_for_stage_cut,
    osmotic_pressure, ro_local_flux, polarization_modulus, gel_polarization_flux, uf_flux,
    batch_concentration_time, BARRER, GPU. The carbon-capture MembraneSeparator/MultistageMembrane
    use the core solver and gain flow_pattern= and n_steps=; bio gel_layer_flux uses the core gel model.
    The plug-flow models are tested against hand integrations in the feed-side mole fraction.

  • difflow.adsorption (unit-ops book Ch 23). A core module for adsorption, ion exchange and chromatography,
    independent of the CO2-only cycle models in difflow_cc and the mAb column in difflow_bio: linear, Langmuir
    (affinity form) and Freundlich isotherms; fit_isotherm (linearized start, Levenberg-Marquardt polish);
    batch_adsorption; the length-of-unused-bed method (lub_analysis, lub_break_time, stoichiometric_time);
    fixed_bed_breakthrough, an isothermal LDF bed. A clean bed without dispersion is solved in corrected time
    theta = t - eps z/v_s, where the fluid hold-up drops out exactly, so a liquid bed that lasts months costs a few
    hundred steps; otherwise a method-of-lines form. Both use adaptive Tsit5 with the step capped inside the stability
    region so reverse-mode gradients are right (uncapped, the gradient of the stoichiometric time came out -1010
    against +50); klinkenberg_breakthrough; ion_exchange_equilibrium (mass action, any valences);
    and retention_factor, plate_count, resolution, purnell_resolution, plates_for_resolution, van_deemter,
    van_deemter_optimum, gaussian_peak. Tests reproduce Geankoplis 5e Examples 12.2-1 and 12.3-1 (data recalled
    from memory) and the Klinkenberg solution (tests/test_adsorption.py).

  • create_objective / Flowsheet.make_objective_fn forward solve keywords and reach Unit.params. Extra
    keyword arguments go to fs.solve (e.g. max_iter for a slow loop under jax.grad, which takes plain
    substitution), and a "unit.field" key that names an entry of the unit's call-keyword dict (a splitter's
    split_frac, a reactor's T_spec) now sets it; before, only fields of the operation's Params were reachable
    and split_frac raised AttributeError. A field that is neither still raises.

  • Unit-ops book Part V gaps (issue 448).
    Extraction. CascadeParams.stage_efficiency (Murphree, raffinate phase) now applies to counter-current
    (Lewis overall efficiency, exact for straight lines) and crossflow (stage by stage), not only co-current; its
    default is None (ideal stages; co-current keeps 0.8), and the rigorous model rejects anything but 1.
    CascadeParams.profile_stages tabulates profiles under jit over a traced n_stages (NaN past n_stages;
    without it a warning says the profiles hold only the inlet row). hunter_nash and tie_line_through are
    differentiable (roots replayed in jnp through the implicit function theorem; eager only, not under jit);
    tie_line_through(..., on_outside="flag") returns two_phase=False instead of raising.
    Absorption. Absorber/Stripper model="stages" gain an opt-in stage energy balance
    (energy_balance, cp_gas, intercooler_stages, intercooler_T); Stripper gains live steam that
    condenses (steam_species, steam_latent_heat; steam_condensed, steam_duty in info). CH4 in
    HENRY_WATER (Sander 2015). wilke_chang_diffusivity raises WilkeChangAccuracyWarning for small solutes
    (V_A < 40 cm^...

Read more

v0.2.2

Choose a tag to compare

@jkitchin jkitchin released this 06 Oct 03:33
efac77f

Fixed

  • Gas plant columns: 0.2.1's retry of a non-converging first pass compiled
    that pass three times (a lax.cond per retry). Every jit or jacfwd
    through a gas plant column grew by about a quarter -- a jacfwd through
    the isomerization DIH went from 10.7 to 13.3 GB -- and the shard of the
    Publish gate holding the DIH tests ran its runner out of memory, so 0.2.1
    never reached PyPI. The retries are now one while_loop that traces the
    pass once; same refluxes, same answers.
  • C5/C6 isomerization: one pass of the DIH recycle is jitted (it ran eagerly,
    op by op, on every Anderson iteration and every jvp), and its implicit
    derivative linearizes the pass once instead of compiling three jvps. A
    recycle solve went from about 390 s to 17 s; a jacfwd through the unit
    from 213 s and 13.3 GB to 103 s and 7.1 GB.

0.2.1 was tagged but never reached PyPI; 0.2.2 includes its fixes.

v0.2.1

Choose a tag to compare

@jkitchin jkitchin released this 06 Oct 01:14
402330f

Fixed

  • Gas plant columns: the initial guess solved its component balances by an LU
    solve, which returns round-off for a heavy cut at the top of a long
    column (true ~e^-600). A 1e-12 change of a feed, or a different CPU's
    rounding, moved those log flows by hundreds and the deisobutanizer's first
    Newton pass could stall on a near-singular Jacobian (this failed the 0.2.0
    Publish gate, so 0.2.0 never reached PyPI). The guess now eliminates the
    M-matrix without pivoting in logs: every gas plant factory case converges in
    the same iterations under feed perturbations. A first pass that still does
    not converge is retried from guesses at half and twice the guessed reflux
    (the C3/C4 splitter on an FCC feed needs it).

v0.2.0

Choose a tag to compare

@jkitchin jkitchin released this 05 Oct 12:56
de0f486

Breaking

  • Python 3.10 is no longer supported; difflow requires Python >= 3.11 (#261).

Added

  • difflow_refinery, a new plugin for petroleum refining: crude assay
    characterisation (Twu 1984), differentiable crude and vacuum distillation
    units, a crude preheat train with a desalter and preflash drum, a saturated gas
    plant, C5/C6 isomerization (once-through and with DIH/DIP recycle), a
    hydrotreater, a hydrocracker, an FCC, a reformer, alkylation, a residue
    desulfurizer, a hydrogen network and a product blending pool with nonlinear
    blending rules. The crude unit also works as a delta-base planning block. It is
    validated against independent IDAES, Pyomo/IPOPT and DWSIM 9.0.5 references,
    and there is a whole-refinery example (examples/40)
    (#296, #299, #300, #302, #303, #316, #317, #319-#322, #324, #335, #336, #345, #351).
  • difflow_power, a new plugin for electrical grids: AC power flow, DC-OPF
    and AC-OPF (#205).
  • difflow.planning: delta-base planning from differentiable flowsheets,
    with second-order subproblems, feasibility restoration, multi-period inventory,
    delta-vector health checks, delta attribution estimated from plant history,
    and Pyomo export (#184, #185, #187, #252, #293).
  • difflow.stochastic: design under uncertainty by sample average
    approximation (#236).
  • difflow.reconciliation: data reconciliation, monitoring over time,
    pooled parameter estimation, and gating and filtering of parameter updates
    from plant data (#175, #183, #244).
  • Flowsheets as data: kinetics, a unit catalog, JSON serialization and code
    generation (#182). Params field descriptions now appear in the catalog
    schema (#218).
  • Local browser editor (difflow.gui): build, wire, rename and edit
    flowsheets, open Python-script flowsheets, browse example flowsheets, and
    use a code editor, hover cards and per-unit documentation
    (#186, #216, #229, #230, #233, #240-#243, #337, #340-#344).
  • Recycle convergence: automatic tear-stream selection
    (fs.solve(tears="auto"), fs.tear_analysis()), loop-gain and error
    estimates for the step tolerance (TearToleranceWarning,
    tol_basis="error"), a corpus of hard flowsheets for measuring the solver's
    pass rate, and a working solve(damping=...) (#258, #260, #262, #273, #274).
  • The distillation columns now run on a cubic EOS (#214).
  • Heater and Cooler now use a real enthalpy balance (#232).
  • Gas network schematics and a worked model-updating example (#176).
  • REE: a mass-action closure, saponification, a train graph and four analysis
    modules (#207).
  • An "Ask" docs assistant in the Jupyter Book (#325), a refinery units summary
    page, and logos for the package and every plugin (#348, #350).

Fixed

  • Distillation: the feed-stage section convention is set in one place, the
    energy balance uses the feed's thermal condition q, and component balances
    close on the CMO path (#215, #217, #225). Fixed the Hengstebeck-Geddes non-key
    split in ShortcutColumn (#323).
  • Flowsheet: a recycle starts from the stream being recycled, and a solve that
    did not converge now says so (#254, #256).
  • CSTR: the molar density that sets residence time now has a name, and the
    water fallback raises CSTRDensityWarning (#234).
  • REE: extraction loading, capacity, mechanism and activity models were
    corrected (#204). Extractant correlations were refit against named sources
    (#270, #282, #283, #290). The Kremser two-inlet boundary condition was fixed
    (#285). The capital estimate is now anchored to disclosed project costs
    (#272). Several smaller fixes (#275-#280, #287, #289).
  • Solvers: sparsity is derived from the graph instead of defaulting to dense
    (#209).
  • Fixed eight defects that adversarial testing found across numerics, streams,
    pytrees, serialization, economics, bio and carbon capture (#292).
  • Fact-checked the example notebooks against the literature (#281, #291).

Changed

  • Physics validation (the release test marker) runs nightly and before every
    publish, instead of on every commit. CI shards the suite by measured test
    duration (#245, #304, #318, #347, #352, #353).
  • The PyPI wheel check covers all seven packages.

v0.1.0

Choose a tag to compare

@jkitchin jkitchin released this 11 Aug 02:00

First public release of difflow, a JAX-based framework for fully differentiable
simulation of chemical processes. It provides exact gradients through unit operations,
thermodynamics, flowsheet recycle convergence, and technoeconomic models, which makes
gradient-based optimization, sensitivity analysis, and uncertainty quantification
available on a whole flowsheet rather than on isolated pieces.

This is also the first release published to PyPI and archived on Zenodo.

Install

pip install difflow

Extras: [examples] for the notebook dependencies, [visualization] for the flowsheet
viewer, [all] for everything.

What is included

The core package covers reactors (CSTR, PFR, fed-batch), separators (flash,
distillation, liquid-liquid extraction), and heat exchangers, with thermodynamics
ranging from ideal mixtures to cubic equations of state (Peng-Robinson, SRK).
Flowsheets with recycles are converged with Anderson and Wegstein acceleration, and
gradients come from implicit differentiation of the converged solution rather than
from unrolling the iteration. A technoeconomic module supplies differentiable capital
and operating cost correlations, and there is support for dynamic (DAE) modeling.

Four domain plugins ship in the same distribution and register through the
difflow.plugins entry points:

  • difflow_bio: bioreactors, centrifugation, filtration, chromatography
  • difflow_ree: rare-earth-element solvent extraction and precipitation
  • difflow_cc: carbon capture by amine absorption, membranes, and adsorption
  • difflow_gas: gas transmission networks with topology-driven sequential decomposition

Alpha software

This is a proof of concept under active development and APIs may change without notice.
Claude Code was used heavily to generate the code, examples, and tests. Please confirm
the equations and physical property models used in any flowsheet you build; they seem
reasonable and the notebooks are run regularly, but accuracy is not guaranteed in all
cases. Issues and pull requests are welcome.

Citing

Citation metadata is in CITATION.cff, and GitHub's "Cite this repository" button
renders BibTeX or APA from it. This release is archived on Zenodo with a DOI.