fugacio-sim 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. fugacio/sim/__init__.py +529 -0
  2. fugacio/sim/column.py +466 -0
  3. fugacio/sim/control/__init__.py +110 -0
  4. fugacio/sim/control/blocks.py +159 -0
  5. fugacio/sim/control/linearize.py +190 -0
  6. fugacio/sim/control/metrics.py +152 -0
  7. fugacio/sim/control/pid.py +195 -0
  8. fugacio/sim/control/tuning.py +174 -0
  9. fugacio/sim/design.py +312 -0
  10. fugacio/sim/diagrams.py +346 -0
  11. fugacio/sim/dynamics/__init__.py +76 -0
  12. fugacio/sim/dynamics/flowsheet.py +292 -0
  13. fugacio/sim/dynamics/integrate.py +517 -0
  14. fugacio/sim/dynamics/optimize.py +255 -0
  15. fugacio/sim/dynamics/units.py +580 -0
  16. fugacio/sim/economics.py +384 -0
  17. fugacio/sim/flowsheet.py +286 -0
  18. fugacio/sim/integration/__init__.py +89 -0
  19. fugacio/sim/integration/area.py +447 -0
  20. fugacio/sim/integration/network.py +429 -0
  21. fugacio/sim/integration/streams.py +169 -0
  22. fugacio/sim/integration/targeting.py +348 -0
  23. fugacio/sim/models.py +221 -0
  24. fugacio/sim/mpc/__init__.py +116 -0
  25. fugacio/sim/mpc/estimation.py +413 -0
  26. fugacio/sim/mpc/linear.py +608 -0
  27. fugacio/sim/mpc/nonlinear.py +336 -0
  28. fugacio/sim/mpc/qp.py +409 -0
  29. fugacio/sim/mpc/riccati.py +279 -0
  30. fugacio/sim/mpc/simulate.py +302 -0
  31. fugacio/sim/optimize.py +758 -0
  32. fugacio/sim/properties.py +186 -0
  33. fugacio/sim/py.typed +0 -0
  34. fugacio/sim/reactive.py +398 -0
  35. fugacio/sim/reactors.py +516 -0
  36. fugacio/sim/separations.py +146 -0
  37. fugacio/sim/stream.py +71 -0
  38. fugacio/sim/units.py +356 -0
  39. fugacio/sim/utilities.py +358 -0
  40. fugacio/sim/vle.py +58 -0
  41. fugacio_sim-0.0.1.dist-info/METADATA +150 -0
  42. fugacio_sim-0.0.1.dist-info/RECORD +43 -0
  43. fugacio_sim-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,529 @@
1
+ """Differentiable process-simulation layer for Fugacio (depends on ``fugacio.thermo``).
2
+
3
+ The layer provides:
4
+
5
+ * `Stream`: the differentiable material stream passed between units;
6
+ * a stream property bridge (`enthalpy_flow`, `entropy_flow`,
7
+ `molar_enthalpy`, `molar_entropy`, `mass_flow`) that gives any
8
+ stream a two-phase-aware enthalpy/entropy via `fugacio.thermo`;
9
+ * unit operations with rigorous material *and* energy balances
10
+ (`flash_drum`, `heater`, `valve`, `pump`,
11
+ `compressor`, `turbine`, `mix`, `splitter`,
12
+ `component_separator`);
13
+ * a thermodynamic-model bridge (`eos_model_for`, `nrtl_model_for`,
14
+ `uniquac_model_for`, `unifac_model_for`, `saft_model_for`) that turns
15
+ component names into a ready EOS, gamma-phi, or PC-SAFT `EquilibriumModel`;
16
+ * non-ideal separation units (`flash_vle`, `decanter`,
17
+ `three_phase_flash`) and binary diagram / azeotrope / residue-curve helpers
18
+ (`pxy_diagram`, `txy_diagram`, `azeotrope_pressure`,
19
+ `azeotrope_temperature`, `residue_curve`, `residue_curve_map`);
20
+ * reactor unit operations (`equilibrium_reactor`,
21
+ `stoichiometric_reactor`, `cstr`, `pfr`,
22
+ `batch_reactor`) and reactive separations (`reactive_flash`,
23
+ `reactive_distillation`);
24
+ * a differentiable optimization toolkit (`minimize`, `argmin`,
25
+ `least_squares`) that differentiates *through the optimum* by the
26
+ implicit function theorem;
27
+ * design specifications and set-point controllers (`meet_spec`,
28
+ `solve_design`, `controller`) that adjust a degree of freedom to
29
+ hit a target, plus end-to-end flowsheet optimization (`optimize_flowsheet`);
30
+ * equipment sizing, Turton bare-module costing, utility pricing, and financial
31
+ metrics (`heat_exchanger_area`, `bare_module_cost`,
32
+ `utility_cost`, `total_annual_cost`, `npv`) for money-valued
33
+ design objectives;
34
+ * differentiable heat integration / pinch analysis (`pinch_analysis`,
35
+ `composite_curves`, `grand_composite_curve`, `area_target`,
36
+ `optimal_dt_min`, `synthesize_network`) for minimum-utility targets
37
+ and heat-exchanger-network synthesis (see `fugacio.sim.integration`);
38
+ * advanced process control: model predictive control and state estimation
39
+ (`linear_mpc`, `nonlinear_mpc`, `solve_qp`, `dare`,
40
+ `lqr`, `kalman_gain`, `KalmanFilter`,
41
+ `ExtendedKalmanFilter`, `UnscentedKalmanFilter`,
42
+ `moving_horizon_estimate`, `simulate_closed_loop`,
43
+ `tune_mpc`), differentiable end to end, so the controller weights are
44
+ tunable by gradient descent (see `fugacio.sim.mpc`);
45
+ * physical steam/cooling-water utilities on IAPWS-95 steam tables
46
+ (`steam_heating`, `cooling_water`, `steam_turbine`,
47
+ `condensate_flash_fraction`) for utility balances with real latent
48
+ heats, differentiable end to end;
49
+ * the original lightweight modified-Raoult helpers (`bubble_pressure`,
50
+ `antoine_psat`).
51
+ """
52
+
53
+ from fugacio.sim.column import (
54
+ ColumnResult,
55
+ ShortcutResult,
56
+ fenske_min_stages,
57
+ gilliland_stages,
58
+ kirkbride_feed_stage,
59
+ relative_volatility,
60
+ shortcut_column,
61
+ solve_column,
62
+ underwood_min_reflux,
63
+ )
64
+
65
+ # Dynamic simulation & control (time-domain). Imported last; these layers build on
66
+ # the steady-state engine above (control depends on the optimizers, the dynamic
67
+ # units on the thermodynamic property bridge).
68
+ from fugacio.sim.control import (
69
+ PID,
70
+ FOPDTModel,
71
+ PIDState,
72
+ StateSpace,
73
+ StepInfo,
74
+ amigo,
75
+ bode,
76
+ cohen_coon,
77
+ dc_gain,
78
+ first_order_step,
79
+ fit_fopdt,
80
+ fopdt_step,
81
+ frequency_response,
82
+ iae,
83
+ imc_tuning,
84
+ is_stable,
85
+ ise,
86
+ itae,
87
+ linearize,
88
+ overshoot,
89
+ p_only,
90
+ pi,
91
+ poles,
92
+ rise_time,
93
+ second_order_step,
94
+ settling_time,
95
+ step_info,
96
+ ziegler_nichols,
97
+ )
98
+ from fugacio.sim.design import (
99
+ DesignSpec,
100
+ FlowsheetOptResult,
101
+ SpecResult,
102
+ controller,
103
+ meet_spec,
104
+ optimize_flowsheet,
105
+ solve_design,
106
+ )
107
+ from fugacio.sim.diagrams import (
108
+ AzeotropeResult,
109
+ PxyDiagram,
110
+ ResidueCurve,
111
+ TxyDiagram,
112
+ azeotrope_pressure,
113
+ azeotrope_temperature,
114
+ pxy_diagram,
115
+ residue_curve,
116
+ residue_curve_map,
117
+ txy_diagram,
118
+ )
119
+ from fugacio.sim.dynamics import (
120
+ DynamicCSTR,
121
+ DynamicEstimateResult,
122
+ DynamicFlash,
123
+ DynamicFlowsheet,
124
+ DynamicResult,
125
+ DynamicUnit,
126
+ GasReceiver,
127
+ LevelTank,
128
+ MixingTank,
129
+ ODEResult,
130
+ OptimalControlResult,
131
+ ThermalMass,
132
+ estimate_dynamics,
133
+ integrate,
134
+ odeint,
135
+ odeint_final,
136
+ optimal_control,
137
+ simulate,
138
+ tune_pid,
139
+ )
140
+ from fugacio.sim.economics import (
141
+ CEPCI_DEFAULT,
142
+ CEPCI_REF,
143
+ EquipmentCost,
144
+ Utility,
145
+ annualized_capital,
146
+ bare_module_cost,
147
+ capital_recovery_factor,
148
+ column_diameter,
149
+ column_height,
150
+ cylinder_volume,
151
+ discounted_payback,
152
+ heat_exchanger_area,
153
+ installed_capital,
154
+ lmtd,
155
+ npv,
156
+ pressure_factor,
157
+ purchased_cost,
158
+ total_annual_cost,
159
+ utility_cost,
160
+ vapor_molar_volume_ideal,
161
+ vessel_volume,
162
+ )
163
+ from fugacio.sim.flowsheet import Flowsheet, tear_solve
164
+ from fugacio.sim.integration import (
165
+ CompositeCurves,
166
+ Exchanger,
167
+ GrandComposite,
168
+ HeatCascade,
169
+ HeatExchangerNetwork,
170
+ HeatStream,
171
+ OptimalDtMin,
172
+ PinchResult,
173
+ SuperTargetResult,
174
+ UnitsTarget,
175
+ area_target,
176
+ capital_cost_target,
177
+ composite_curves,
178
+ grand_composite_curve,
179
+ heat_cascade,
180
+ heat_stream,
181
+ make_stream,
182
+ minimum_utilities,
183
+ optimal_dt_min,
184
+ pinch_analysis,
185
+ supertarget,
186
+ synthesize_network,
187
+ total_annual_cost_target,
188
+ units_target,
189
+ verify_network,
190
+ )
191
+ from fugacio.sim.models import (
192
+ UnifacModel,
193
+ eos_model_for,
194
+ nrtl_model_for,
195
+ saft_model_for,
196
+ unifac_model_for,
197
+ uniquac_model_for,
198
+ )
199
+
200
+ # Advanced process control (model predictive control + state estimation). Builds on
201
+ # the optimizers, the state-space linearization in ``control`` and the differentiable
202
+ # integrator in ``dynamics``.
203
+ from fugacio.sim.mpc import (
204
+ ClosedLoop,
205
+ ExtendedKalmanFilter,
206
+ GaussianState,
207
+ KalmanFilter,
208
+ LinearMPC,
209
+ MHEResult,
210
+ MPCResult,
211
+ MPCState,
212
+ NMPCResult,
213
+ NonlinearMPC,
214
+ QPSettings,
215
+ QPSolution,
216
+ UnscentedKalmanFilter,
217
+ c2d,
218
+ care,
219
+ closed_loop_cost,
220
+ constant_setpoint,
221
+ dare,
222
+ discretize,
223
+ dlqr,
224
+ kalman_gain,
225
+ linear_feedback,
226
+ linear_mpc,
227
+ lqr,
228
+ moving_horizon_estimate,
229
+ nonlinear_feedback,
230
+ nonlinear_mpc,
231
+ quadratic_tracking,
232
+ simulate_closed_loop,
233
+ solve_qp,
234
+ solve_qp_canonical,
235
+ tune_mpc,
236
+ )
237
+ from fugacio.sim.optimize import (
238
+ OptimizeResult,
239
+ argmin,
240
+ least_squares,
241
+ minimize,
242
+ )
243
+ from fugacio.sim.properties import (
244
+ column_diameter_for,
245
+ enthalpy_flow,
246
+ entropy_flow,
247
+ liquid_density,
248
+ liquid_thermal_conductivity,
249
+ liquid_viscosity,
250
+ liquid_volumetric_flow,
251
+ mass_flow,
252
+ molar_enthalpy,
253
+ molar_entropy,
254
+ molar_mass,
255
+ surface_tension,
256
+ vapor_density,
257
+ vapor_thermal_conductivity,
258
+ vapor_viscosity,
259
+ vapor_volumetric_flow,
260
+ )
261
+ from fugacio.sim.reactive import (
262
+ ReactiveColumnResult,
263
+ ReactiveFlashResult,
264
+ reactive_distillation,
265
+ reactive_flash,
266
+ )
267
+ from fugacio.sim.reactors import (
268
+ ReactorResult,
269
+ batch_reactor,
270
+ conversion,
271
+ cstr,
272
+ equilibrium_reactor,
273
+ pfr,
274
+ stoichiometric_reactor,
275
+ )
276
+ from fugacio.sim.separations import decanter, flash_vle, three_phase_flash
277
+ from fugacio.sim.stream import Stream
278
+ from fugacio.sim.units import (
279
+ HeaterResult,
280
+ PumpResult,
281
+ WorkResult,
282
+ component_separator,
283
+ compressor,
284
+ flash_drum,
285
+ heater,
286
+ mix,
287
+ pump,
288
+ splitter,
289
+ turbine,
290
+ valve,
291
+ )
292
+ from fugacio.sim.utilities import (
293
+ STEAM_LEVELS,
294
+ CoolingWaterResult,
295
+ SteamHeatingResult,
296
+ SteamTurbineResult,
297
+ condensate_flash_fraction,
298
+ cooling_water,
299
+ saturated_steam_temperature,
300
+ steam_enthalpy,
301
+ steam_heating,
302
+ steam_quality_after_letdown,
303
+ steam_turbine,
304
+ )
305
+ from fugacio.sim.vle import antoine_psat, bubble_pressure
306
+
307
+ __all__ = [
308
+ "CEPCI_DEFAULT",
309
+ "CEPCI_REF",
310
+ "PID",
311
+ "STEAM_LEVELS",
312
+ "AzeotropeResult",
313
+ "ClosedLoop",
314
+ "ColumnResult",
315
+ "CompositeCurves",
316
+ "CoolingWaterResult",
317
+ "DesignSpec",
318
+ "DynamicCSTR",
319
+ "DynamicEstimateResult",
320
+ "DynamicFlash",
321
+ "DynamicFlowsheet",
322
+ "DynamicResult",
323
+ "DynamicUnit",
324
+ "EquipmentCost",
325
+ "Exchanger",
326
+ "ExtendedKalmanFilter",
327
+ "FOPDTModel",
328
+ "Flowsheet",
329
+ "FlowsheetOptResult",
330
+ "GasReceiver",
331
+ "GaussianState",
332
+ "GrandComposite",
333
+ "HeatCascade",
334
+ "HeatExchangerNetwork",
335
+ "HeatStream",
336
+ "HeaterResult",
337
+ "KalmanFilter",
338
+ "LevelTank",
339
+ "LinearMPC",
340
+ "MHEResult",
341
+ "MPCResult",
342
+ "MPCState",
343
+ "MixingTank",
344
+ "NMPCResult",
345
+ "NonlinearMPC",
346
+ "ODEResult",
347
+ "OptimalControlResult",
348
+ "OptimalDtMin",
349
+ "OptimizeResult",
350
+ "PIDState",
351
+ "PinchResult",
352
+ "PumpResult",
353
+ "PxyDiagram",
354
+ "QPSettings",
355
+ "QPSolution",
356
+ "ReactiveColumnResult",
357
+ "ReactiveFlashResult",
358
+ "ReactorResult",
359
+ "ResidueCurve",
360
+ "ShortcutResult",
361
+ "SpecResult",
362
+ "StateSpace",
363
+ "SteamHeatingResult",
364
+ "SteamTurbineResult",
365
+ "StepInfo",
366
+ "Stream",
367
+ "SuperTargetResult",
368
+ "ThermalMass",
369
+ "TxyDiagram",
370
+ "UnifacModel",
371
+ "UnitsTarget",
372
+ "UnscentedKalmanFilter",
373
+ "Utility",
374
+ "WorkResult",
375
+ "amigo",
376
+ "annualized_capital",
377
+ "antoine_psat",
378
+ "area_target",
379
+ "argmin",
380
+ "azeotrope_pressure",
381
+ "azeotrope_temperature",
382
+ "bare_module_cost",
383
+ "batch_reactor",
384
+ "bode",
385
+ "bubble_pressure",
386
+ "c2d",
387
+ "capital_cost_target",
388
+ "capital_recovery_factor",
389
+ "care",
390
+ "closed_loop_cost",
391
+ "cohen_coon",
392
+ "column_diameter",
393
+ "column_diameter_for",
394
+ "column_height",
395
+ "component_separator",
396
+ "composite_curves",
397
+ "compressor",
398
+ "condensate_flash_fraction",
399
+ "constant_setpoint",
400
+ "controller",
401
+ "conversion",
402
+ "cooling_water",
403
+ "cstr",
404
+ "cylinder_volume",
405
+ "dare",
406
+ "dc_gain",
407
+ "decanter",
408
+ "discounted_payback",
409
+ "discretize",
410
+ "dlqr",
411
+ "enthalpy_flow",
412
+ "entropy_flow",
413
+ "eos_model_for",
414
+ "equilibrium_reactor",
415
+ "estimate_dynamics",
416
+ "fenske_min_stages",
417
+ "first_order_step",
418
+ "fit_fopdt",
419
+ "flash_drum",
420
+ "flash_vle",
421
+ "fopdt_step",
422
+ "frequency_response",
423
+ "gilliland_stages",
424
+ "grand_composite_curve",
425
+ "heat_cascade",
426
+ "heat_exchanger_area",
427
+ "heat_stream",
428
+ "heater",
429
+ "iae",
430
+ "imc_tuning",
431
+ "installed_capital",
432
+ "integrate",
433
+ "is_stable",
434
+ "ise",
435
+ "itae",
436
+ "kalman_gain",
437
+ "kirkbride_feed_stage",
438
+ "least_squares",
439
+ "linear_feedback",
440
+ "linear_mpc",
441
+ "linearize",
442
+ "liquid_density",
443
+ "liquid_thermal_conductivity",
444
+ "liquid_viscosity",
445
+ "liquid_volumetric_flow",
446
+ "lmtd",
447
+ "lqr",
448
+ "make_stream",
449
+ "mass_flow",
450
+ "meet_spec",
451
+ "minimize",
452
+ "minimum_utilities",
453
+ "mix",
454
+ "molar_enthalpy",
455
+ "molar_entropy",
456
+ "molar_mass",
457
+ "moving_horizon_estimate",
458
+ "nonlinear_feedback",
459
+ "nonlinear_mpc",
460
+ "npv",
461
+ "nrtl_model_for",
462
+ "odeint",
463
+ "odeint_final",
464
+ "optimal_control",
465
+ "optimal_dt_min",
466
+ "optimize_flowsheet",
467
+ "overshoot",
468
+ "p_only",
469
+ "pfr",
470
+ "pi",
471
+ "pinch_analysis",
472
+ "poles",
473
+ "pressure_factor",
474
+ "pump",
475
+ "purchased_cost",
476
+ "pxy_diagram",
477
+ "quadratic_tracking",
478
+ "reactive_distillation",
479
+ "reactive_flash",
480
+ "relative_volatility",
481
+ "residue_curve",
482
+ "residue_curve_map",
483
+ "rise_time",
484
+ "saft_model_for",
485
+ "saturated_steam_temperature",
486
+ "second_order_step",
487
+ "settling_time",
488
+ "shortcut_column",
489
+ "simulate",
490
+ "simulate_closed_loop",
491
+ "solve_column",
492
+ "solve_design",
493
+ "solve_qp",
494
+ "solve_qp_canonical",
495
+ "splitter",
496
+ "steam_enthalpy",
497
+ "steam_heating",
498
+ "steam_quality_after_letdown",
499
+ "steam_turbine",
500
+ "step_info",
501
+ "stoichiometric_reactor",
502
+ "supertarget",
503
+ "surface_tension",
504
+ "synthesize_network",
505
+ "tear_solve",
506
+ "three_phase_flash",
507
+ "total_annual_cost",
508
+ "total_annual_cost_target",
509
+ "tune_mpc",
510
+ "tune_pid",
511
+ "turbine",
512
+ "txy_diagram",
513
+ "underwood_min_reflux",
514
+ "unifac_model_for",
515
+ "uniquac_model_for",
516
+ "units_target",
517
+ "utility_cost",
518
+ "valve",
519
+ "vapor_density",
520
+ "vapor_molar_volume_ideal",
521
+ "vapor_thermal_conductivity",
522
+ "vapor_viscosity",
523
+ "vapor_volumetric_flow",
524
+ "verify_network",
525
+ "vessel_volume",
526
+ "ziegler_nichols",
527
+ ]
528
+
529
+ __version__ = "0.0.1"