processforge 0.3.26__tar.gz → 0.4.3__tar.gz
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.
- {processforge-0.3.26/src/processforge.egg-info → processforge-0.4.3}/PKG-INFO +5 -1
- processforge-0.4.3/flowsheets/custom/crimson/simple_water_system.json +172 -0
- {processforge-0.3.26 → processforge-0.4.3}/pyproject.toml +6 -1
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/__init__.py +1 -1
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/__init__.py +1 -1
- processforge-0.4.3/src/processforge/cli/export_fmu.py +88 -0
- processforge-0.4.3/src/processforge/cli/runs.py +228 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/flowsheet.py +27 -14
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/fmu/_fmi_vars.py +35 -2
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/fmu/builder.py +60 -3
- processforge-0.4.3/src/processforge/fmu/interface.py +214 -0
- processforge-0.4.3/src/processforge/fmu/slave_template.py +572 -0
- processforge-0.4.3/src/processforge/pathsim/__init__.py +6 -0
- processforge-0.4.3/src/processforge/pathsim/adapter.py +184 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/result.py +164 -5
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/types.py +1 -1
- {processforge-0.3.26 → processforge-0.4.3/src/processforge.egg-info}/PKG-INFO +5 -1
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge.egg-info/SOURCES.txt +6 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge.egg-info/requires.txt +5 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_cli.py +14 -10
- processforge-0.4.3/tests/test_fmu_solverunit.py +281 -0
- processforge-0.4.3/tests/test_pathsim_adapter.py +66 -0
- processforge-0.4.3/tests/test_result_zarr.py +158 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_runs_command.py +110 -16
- processforge-0.3.26/src/processforge/cli/export_fmu.py +0 -41
- processforge-0.3.26/src/processforge/cli/runs.py +0 -88
- processforge-0.3.26/src/processforge/fmu/slave_template.py +0 -252
- processforge-0.3.26/tests/test_result_zarr.py +0 -73
- {processforge-0.3.26 → processforge-0.4.3}/LICENSE +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/MANIFEST.in +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/README.md +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/closed-loop-chain.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/coupled/msre_coupled.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/custom/crimson/MUWS_HB.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/custom/simple_hyrdaulic_scheme.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/festim/hydrogen_transport_1d.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/festim/tds_tungsten.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/hydraulic-chain.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/flowsheets/openmc/msre_eigenvalue.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/setup.cfg +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/__main__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/_schema.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/analysis/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/analysis/dof.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/api/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/api/serve.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/apply.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/common.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/diagram.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/display.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/export_modelica.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/init.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/persist.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/plan.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/run.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/cli/validate.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/compose.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/coupling.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/backends/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/backends/base.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/backends/casadi_backend.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/backends/pyomo_backend.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/backends/scipy_backend.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/flowsheet.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/jacobian.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/mixin.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/solver.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/stream_var.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/flash_eo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/heater_eo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/pipes_eo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/pump_eo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/strainer_eo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/eo/units/valve_eo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/fmu/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/lock.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/modelica/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/modelica/mo_writer.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/modelica/omc_runner.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/modelica/transpiler.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/modelica/unit_equations.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/output_collector.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/pcl/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/pcl/compiler.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/pcl/namespace.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/persistence/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/persistence/archive.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/persistence/artifact_store.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/provenance.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/base.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/base_jacobian_mixin.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/cantera_jacobian.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/cantera_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/container_client.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/coolprop_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/errors.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/festim_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/jacobian_contributor.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/manager.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/modelica_jacobian.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/modelica_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/openmc_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/reference_state_registry.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/providers/registry.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/quantity.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/result_schema.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/schemas/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/schemas/festim/festim_model.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/schemas/flowsheet_schema.json +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/schemas/openmc/openmc_model.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/simulate.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/solver.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/state.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/thermo.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/base.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/cstr.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/flash.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/heater.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/pfr.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/pipes.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/pump.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/registry.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/solver_unit.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/strainer.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/tank.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/units/valve.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/__init__.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/flowsheet_diagram.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/mermaid_diagram.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/s3_upload.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/topology.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/unit_consistency.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/validate_flowsheet.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge/utils/validation.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge.egg-info/dependency_links.txt +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge.egg-info/entry_points.txt +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/src/processforge.egg-info/top_level.txt +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_container_client.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_coupling.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_display.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_festim_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_festim_schema.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_init.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_openmc_provider.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_persist.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_provider_errors.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_providers.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_s3_upload.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_state.py +0 -0
- {processforge-0.3.26 → processforge-0.4.3}/tests/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: processforge
|
|
3
|
-
Version: 0.3
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: A Python-based process simulation framework for chemical engineering applications.
|
|
5
5
|
Author-email: Processforge Team <team@processforge.dev>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -43,9 +43,13 @@ Requires-Dist: pyomo>=6.7; extra == "eo-casadi"
|
|
|
43
43
|
Requires-Dist: casadi>=3.6; extra == "eo-casadi"
|
|
44
44
|
Provides-Extra: fmu
|
|
45
45
|
Requires-Dist: pythonfmu>=0.6; extra == "fmu"
|
|
46
|
+
Requires-Dist: fmpy>=0.3; extra == "fmu"
|
|
46
47
|
Provides-Extra: modelica
|
|
47
48
|
Requires-Dist: OMPython>=4.0.0; extra == "modelica"
|
|
48
49
|
Requires-Dist: fmpy>=0.3; extra == "modelica"
|
|
50
|
+
Provides-Extra: pathsim
|
|
51
|
+
Requires-Dist: pathsim>=0.9; extra == "pathsim"
|
|
52
|
+
Requires-Dist: fmpy>=0.3; extra == "pathsim"
|
|
49
53
|
Provides-Extra: cantera
|
|
50
54
|
Requires-Dist: cantera>=3.0; extra == "cantera"
|
|
51
55
|
Provides-Extra: coolprop
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"name": "Make-up Water System",
|
|
4
|
+
"description": "A two-pump, five-valve, one-strainer, one tank steady-state make-up water system.",
|
|
5
|
+
"version": "2.0"
|
|
6
|
+
},
|
|
7
|
+
"providers": {
|
|
8
|
+
"coolprop": {
|
|
9
|
+
"type": "coolprop"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"materials": {
|
|
13
|
+
"Water": {
|
|
14
|
+
"id": 1
|
|
15
|
+
},
|
|
16
|
+
"Steel": {
|
|
17
|
+
"id": 2
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"streams": {
|
|
21
|
+
"feed": {
|
|
22
|
+
"T": 313.00,
|
|
23
|
+
"P": 101325,
|
|
24
|
+
"flowrate": 1,
|
|
25
|
+
"z": { "Water": 1.0 }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"units": {
|
|
30
|
+
"tank_1": {
|
|
31
|
+
"type": "Tank",
|
|
32
|
+
"in": ["feed"],
|
|
33
|
+
"out": ["tank_1_to_pipe1", "tank_1_to_pipe2"],
|
|
34
|
+
"outlet_flow": 1.0,
|
|
35
|
+
"initial_n": {
|
|
36
|
+
"Water": 1.0
|
|
37
|
+
},
|
|
38
|
+
"initial_T": 298.15,
|
|
39
|
+
"P": 101325,
|
|
40
|
+
"material": 1
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
"pipe_1": {
|
|
45
|
+
"type": "Pipes",
|
|
46
|
+
"in": "tank_1_to_pipe1",
|
|
47
|
+
"out": "after_pipe_1",
|
|
48
|
+
"delta_p": 1000.0,
|
|
49
|
+
"diameter": 0.05,
|
|
50
|
+
"material": 2
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
"low_pressure_pump":{
|
|
56
|
+
"type": "Pump",
|
|
57
|
+
"in": "after_pipe_1",
|
|
58
|
+
"out": "after_low_pressure_pump",
|
|
59
|
+
"q_flowrate": 4,
|
|
60
|
+
"head": 57,
|
|
61
|
+
"efficiency": 36,
|
|
62
|
+
"power": 1.3,
|
|
63
|
+
"cap": 2.5,
|
|
64
|
+
"motor_rating": 370,
|
|
65
|
+
"design_press": 6,
|
|
66
|
+
"material": 2,
|
|
67
|
+
"delta_p": 1000.0
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
"pipe_2": {
|
|
71
|
+
"type": "Pipes",
|
|
72
|
+
"in": "tank_1_to_pipe2",
|
|
73
|
+
"out": "after_pipe_2",
|
|
74
|
+
"delta_p": 1000.0,
|
|
75
|
+
"diameter": 0.05,
|
|
76
|
+
"material": 2
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
"pipe_3": {
|
|
80
|
+
"type": "Pipes",
|
|
81
|
+
"in": "after_low_pressure_pump",
|
|
82
|
+
"out": "after_pipe_3",
|
|
83
|
+
"delta_p": 1000.0,
|
|
84
|
+
"diameter": 0.05,
|
|
85
|
+
"material": 2
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
"drain_valve_1": {
|
|
90
|
+
"type": "Valve",
|
|
91
|
+
"in": "after_pipe_2",
|
|
92
|
+
"out": "after_drain_valve_1",
|
|
93
|
+
"opening": 50,
|
|
94
|
+
"q_flowrate": 50,
|
|
95
|
+
"material": 2,
|
|
96
|
+
"pressure_ratio": 0.5
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
"make_up_valve_1": {
|
|
100
|
+
"type": "Valve",
|
|
101
|
+
"in": "after_pipe_3",
|
|
102
|
+
"out": "after_make_up_valve_1",
|
|
103
|
+
"opening": 50,
|
|
104
|
+
"q_flowrate": 50,
|
|
105
|
+
"material": 2,
|
|
106
|
+
"pressure_ratio": 0.5
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
"pipe_4": {
|
|
110
|
+
"type": "Pipes",
|
|
111
|
+
"in": "after_make_up_valve_1",
|
|
112
|
+
"out": "after_pipe_4",
|
|
113
|
+
"delta_p": 1000.0,
|
|
114
|
+
"diameter": 0.05,
|
|
115
|
+
"material": 2
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
"pipe_5": {
|
|
119
|
+
"type": "Pipes",
|
|
120
|
+
"in": "after_drain_valve_1",
|
|
121
|
+
"out": "after_pipe_5",
|
|
122
|
+
"delta_p": 1000.0,
|
|
123
|
+
"diameter": 0.05,
|
|
124
|
+
"material": 2
|
|
125
|
+
},
|
|
126
|
+
"tank_2": {
|
|
127
|
+
"type": "Tank",
|
|
128
|
+
"in": ["after_pipe_4", "after_pipe_5"],
|
|
129
|
+
"out": "after_tank_2",
|
|
130
|
+
"outlet_flow": 1.0,
|
|
131
|
+
"initial_n": {
|
|
132
|
+
"Water": 1.0
|
|
133
|
+
},
|
|
134
|
+
"initial_T": 298.15,
|
|
135
|
+
"P": 101325,
|
|
136
|
+
"material": 1
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
"pipe_6": {
|
|
140
|
+
"type": "Pipes",
|
|
141
|
+
"in": "after_tank_2",
|
|
142
|
+
"out": "after_pipe_6",
|
|
143
|
+
"delta_p": 1000.0,
|
|
144
|
+
"diameter": 0.05,
|
|
145
|
+
"material": 2
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
"manual_drain_valve": {
|
|
152
|
+
"type": "Valve",
|
|
153
|
+
"in": "after_pipe_6",
|
|
154
|
+
"out": "after_manual_drain_valve",
|
|
155
|
+
"opening": 50,
|
|
156
|
+
"q_flowrate": 50,
|
|
157
|
+
"material": 2,
|
|
158
|
+
"pressure_ratio": 0.5
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
},
|
|
162
|
+
"simulation": {
|
|
163
|
+
"mode": "dynamic",
|
|
164
|
+
"t0": 0.0,
|
|
165
|
+
"tf": 20.0,
|
|
166
|
+
"dt": 1.0,
|
|
167
|
+
"backend": "scipy"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "processforge"
|
|
7
|
-
version = "0.3
|
|
7
|
+
version = "0.4.3"
|
|
8
8
|
description = "A Python-based process simulation framework for chemical engineering applications."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "BSD-3-Clause"
|
|
@@ -55,11 +55,16 @@ eo-casadi = [
|
|
|
55
55
|
]
|
|
56
56
|
fmu = [
|
|
57
57
|
"pythonfmu>=0.6",
|
|
58
|
+
"fmpy>=0.3",
|
|
58
59
|
]
|
|
59
60
|
modelica = [
|
|
60
61
|
"OMPython>=4.0.0",
|
|
61
62
|
"fmpy>=0.3",
|
|
62
63
|
]
|
|
64
|
+
pathsim = [
|
|
65
|
+
"pathsim>=0.9",
|
|
66
|
+
"fmpy>=0.3",
|
|
67
|
+
]
|
|
63
68
|
cantera = [
|
|
64
69
|
"cantera>=3.0",
|
|
65
70
|
]
|
|
@@ -32,7 +32,7 @@ def register_commands(app: typer.Typer) -> None:
|
|
|
32
32
|
)(apply)
|
|
33
33
|
app.command(
|
|
34
34
|
"runs",
|
|
35
|
-
help="List runs for a flowsheet, or
|
|
35
|
+
help="List runs for a flowsheet, or inspect one run's Zarr result summary (pf runs <flowsheet> [<run_id>|latest] [--schema])",
|
|
36
36
|
)(runs)
|
|
37
37
|
app.command(
|
|
38
38
|
"plan",
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""``pf export-fmu`` — export flowsheet as FMI 2.0 co-simulation FMU."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import Literal
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
from loguru import logger
|
|
10
|
+
|
|
11
|
+
from .common import require_existing_file
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def export_fmu(
|
|
15
|
+
flowsheet: str = typer.Argument(help="Path to the flowsheet JSON file"),
|
|
16
|
+
output_dir: str = typer.Option(
|
|
17
|
+
"outputs",
|
|
18
|
+
"--output-dir",
|
|
19
|
+
"-o",
|
|
20
|
+
help="Directory for the output FMU (default: outputs/)",
|
|
21
|
+
),
|
|
22
|
+
backend: Literal["scipy", "pyomo", "casadi"] = typer.Option(
|
|
23
|
+
"scipy",
|
|
24
|
+
"--backend",
|
|
25
|
+
help="EO solver backend for steady-state mode (default: scipy)",
|
|
26
|
+
),
|
|
27
|
+
pathsim: bool = typer.Option(
|
|
28
|
+
False,
|
|
29
|
+
"--pathsim",
|
|
30
|
+
help="Also emit the fmu_interface.json manifest and a PathSim wiring example",
|
|
31
|
+
),
|
|
32
|
+
) -> None:
|
|
33
|
+
"""Export a flowsheet as an FMI 2.0 co-simulation FMU."""
|
|
34
|
+
require_existing_file(flowsheet)
|
|
35
|
+
|
|
36
|
+
from ..fmu import build_fmu # local import — pythonfmu is optional
|
|
37
|
+
|
|
38
|
+
output_dir = output_dir or "outputs"
|
|
39
|
+
backend = backend or "scipy"
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
fmu_path = build_fmu(
|
|
43
|
+
flowsheet,
|
|
44
|
+
output_dir=output_dir,
|
|
45
|
+
backend=backend,
|
|
46
|
+
write_manifest=pathsim,
|
|
47
|
+
)
|
|
48
|
+
logger.info(f"FMU written to: {fmu_path}")
|
|
49
|
+
if pathsim:
|
|
50
|
+
base = os.path.splitext(os.path.basename(fmu_path))[0]
|
|
51
|
+
manifest_path = os.path.join(output_dir, f"{base}_fmu_interface.json")
|
|
52
|
+
example_path = os.path.join(output_dir, f"{base}_pathsim.py")
|
|
53
|
+
_write_pathsim_example(example_path, fmu_path, manifest_path)
|
|
54
|
+
logger.info(f"Manifest written to: {manifest_path}")
|
|
55
|
+
logger.info(f"PathSim example written to: {example_path}")
|
|
56
|
+
except Exception as e:
|
|
57
|
+
logger.error(f"FMU export failed: {type(e).__name__}: {e}")
|
|
58
|
+
logger.debug("FMU export traceback:", exc_info=True)
|
|
59
|
+
raise SystemExit(1)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _write_pathsim_example(example_path: str, fmu_path: str, manifest_path: str) -> None:
|
|
63
|
+
"""Write a minimal PathSim wiring example next to the exported FMU."""
|
|
64
|
+
content = f'''"""Auto-generated PathSim wiring example."""
|
|
65
|
+
import pathsim as ps
|
|
66
|
+
from processforge.pathsim import ProcessForgeFMU
|
|
67
|
+
|
|
68
|
+
plant = ProcessForgeFMU(
|
|
69
|
+
fmu_path={fmu_path!r},
|
|
70
|
+
manifest_path={manifest_path!r},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Inspect available ports:
|
|
74
|
+
# print(plant.inputs)
|
|
75
|
+
# print(plant.outputs)
|
|
76
|
+
|
|
77
|
+
# Example: drive an input with a constant setpoint and read an output.
|
|
78
|
+
setpoint = ps.Constant(val=1.0)
|
|
79
|
+
sim = ps.Simulation(
|
|
80
|
+
blocks=[setpoint, plant],
|
|
81
|
+
connections=[
|
|
82
|
+
# ps.Connection(setpoint, plant["<unit>.<input>"]),
|
|
83
|
+
],
|
|
84
|
+
)
|
|
85
|
+
sim.run(time_span=(0, 10))
|
|
86
|
+
'''
|
|
87
|
+
with open(example_path, "w", encoding="utf-8") as f:
|
|
88
|
+
f.write(content)
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"""``pf runs`` — list runs and inspect their Zarr result summaries."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
import arrow
|
|
9
|
+
import typer
|
|
10
|
+
from loguru import logger
|
|
11
|
+
|
|
12
|
+
from .common import flowsheet_basename, output_root
|
|
13
|
+
from ..persistence.archive import ProcessStateArchive
|
|
14
|
+
from ..result import (
|
|
15
|
+
_fmt_scientific,
|
|
16
|
+
_one_line_summary,
|
|
17
|
+
_scalar_from_sequence,
|
|
18
|
+
summarize_zarr_store,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Fixed column widths for the compact single-run stream table.
|
|
22
|
+
STREAM_COL_WIDTH = 28
|
|
23
|
+
VAR_COL_WIDTH = 10
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _humanize_timestamp(ts: str) -> str:
|
|
27
|
+
"""Render a stored timestamp as a human-readable relative string.
|
|
28
|
+
|
|
29
|
+
Falls back to the raw string for values that aren't parseable ISO-8601
|
|
30
|
+
(e.g. ``20260101T000000Z`` used in some test fixtures).
|
|
31
|
+
"""
|
|
32
|
+
try:
|
|
33
|
+
return arrow.get(ts).humanize()
|
|
34
|
+
except (arrow.parser.ParserError, ValueError, TypeError):
|
|
35
|
+
return ts
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _zarr_path(archive_path: str, run_id: str) -> str:
|
|
39
|
+
"""Return the per-run Zarr store path."""
|
|
40
|
+
return os.path.join(archive_path, "results", run_id, "results.zarr")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _artifact_status(artifact: dict) -> str:
|
|
44
|
+
"""Return a short presence marker for an artifact dict."""
|
|
45
|
+
local_path = artifact.get("local_path")
|
|
46
|
+
remote_uris = artifact.get("remote_uris") or []
|
|
47
|
+
if local_path and os.path.exists(local_path):
|
|
48
|
+
return "local✓"
|
|
49
|
+
if remote_uris:
|
|
50
|
+
return "remote-only"
|
|
51
|
+
return "missing"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _format_run_compact(manifest, summary: dict) -> str:
|
|
55
|
+
"""Format a compact, human-readable result summary for a single run."""
|
|
56
|
+
lines = [
|
|
57
|
+
f"Run: {manifest.run_id}",
|
|
58
|
+
f"Timestamp: {manifest.timestamp}",
|
|
59
|
+
f"Mode: {summary.get('mode', manifest.mode)}",
|
|
60
|
+
"",
|
|
61
|
+
"Results:",
|
|
62
|
+
"────────",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
engine_outputs = summary.get("engine_outputs", {})
|
|
66
|
+
if engine_outputs:
|
|
67
|
+
for name, eo in engine_outputs.items():
|
|
68
|
+
engine = eo.get("engine", "")
|
|
69
|
+
sim_type = eo.get("sim_type", "")
|
|
70
|
+
status = eo.get("status", "")
|
|
71
|
+
lines.append(f"{name} ({engine} / {sim_type}) [{status}]")
|
|
72
|
+
for fname, fdata in eo.get("fields", {}).items():
|
|
73
|
+
val = _fmt_scientific(_scalar_from_sequence(fdata.get("value")))
|
|
74
|
+
unit = fdata.get("unit", "")
|
|
75
|
+
std = fdata.get("std_dev")
|
|
76
|
+
if std is not None:
|
|
77
|
+
lines.append(
|
|
78
|
+
f" {fname}: {val} ± {_fmt_scientific(std)} {unit}".strip()
|
|
79
|
+
)
|
|
80
|
+
else:
|
|
81
|
+
lines.append(f" {fname}: {val} {unit}".strip())
|
|
82
|
+
if eo.get("attrs") and not eo.get("fields"):
|
|
83
|
+
for k, v in eo["attrs"].items():
|
|
84
|
+
if not k.startswith("_") and k not in (
|
|
85
|
+
"engine",
|
|
86
|
+
"sim_type",
|
|
87
|
+
"status",
|
|
88
|
+
):
|
|
89
|
+
lines.append(
|
|
90
|
+
f" {k}: {_fmt_scientific(_scalar_from_sequence(v))}"
|
|
91
|
+
)
|
|
92
|
+
lines.append("")
|
|
93
|
+
else:
|
|
94
|
+
lines.append(" (no solver/engine outputs)")
|
|
95
|
+
lines.append("")
|
|
96
|
+
|
|
97
|
+
streams = summary.get("streams", {})
|
|
98
|
+
if streams:
|
|
99
|
+
lines.append("Streams (final timestep):")
|
|
100
|
+
all_vars: set[str] = set()
|
|
101
|
+
for sdata in streams.values():
|
|
102
|
+
all_vars.update(sdata.get("variables", []))
|
|
103
|
+
all_vars = sorted(all_vars)
|
|
104
|
+
|
|
105
|
+
header_parts = ["stream".ljust(STREAM_COL_WIDTH)] + [
|
|
106
|
+
v.rjust(VAR_COL_WIDTH) for v in all_vars
|
|
107
|
+
]
|
|
108
|
+
lines.append(" " + " ".join(header_parts))
|
|
109
|
+
lines.append(" " + "-" * len(" ".join(header_parts)))
|
|
110
|
+
for sname in sorted(streams):
|
|
111
|
+
sdata = streams[sname]
|
|
112
|
+
fields = sdata.get("fields", {})
|
|
113
|
+
display_name = sname[:STREAM_COL_WIDTH]
|
|
114
|
+
row = [display_name.ljust(STREAM_COL_WIDTH)]
|
|
115
|
+
for var in all_vars:
|
|
116
|
+
fdata = fields.get(var, {})
|
|
117
|
+
val = fdata.get("value")
|
|
118
|
+
row.append(
|
|
119
|
+
_fmt_scientific(_scalar_from_sequence(val)).rjust(VAR_COL_WIDTH)
|
|
120
|
+
)
|
|
121
|
+
lines.append(" " + " ".join(row))
|
|
122
|
+
lines.append("")
|
|
123
|
+
else:
|
|
124
|
+
lines.append("Streams: none")
|
|
125
|
+
lines.append("")
|
|
126
|
+
|
|
127
|
+
artifacts = summary.get("artifacts", [])
|
|
128
|
+
if artifacts:
|
|
129
|
+
lines.append("Artifacts:")
|
|
130
|
+
for art in artifacts:
|
|
131
|
+
name = art.get("name", "unknown")
|
|
132
|
+
kind = art.get("kind", "")
|
|
133
|
+
status = _artifact_status(art)
|
|
134
|
+
loc = (
|
|
135
|
+
art.get("local_path") or (art.get("remote_uris") or ["no location"])[0]
|
|
136
|
+
)
|
|
137
|
+
lines.append(f" [{kind}] {name}: {status} ({loc})")
|
|
138
|
+
else:
|
|
139
|
+
lines.append("Artifacts: none")
|
|
140
|
+
|
|
141
|
+
zarr_path = summary.get("_zarr_path")
|
|
142
|
+
if zarr_path:
|
|
143
|
+
lines.append("")
|
|
144
|
+
lines.append(f"Zarr store: {zarr_path}")
|
|
145
|
+
|
|
146
|
+
return "\n".join(lines)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def runs(
|
|
150
|
+
flowsheet: str = typer.Argument(..., help="Path to the flowsheet JSON"),
|
|
151
|
+
run_id: str = typer.Argument(
|
|
152
|
+
None,
|
|
153
|
+
help="Show this run's result summary. Use 'latest' for the most recent run.",
|
|
154
|
+
),
|
|
155
|
+
schema: bool = typer.Option(
|
|
156
|
+
False,
|
|
157
|
+
"--schema",
|
|
158
|
+
help="Print the result schema JSON instead of the summary.",
|
|
159
|
+
),
|
|
160
|
+
):
|
|
161
|
+
"""List runs for a flowsheet, or inspect one run's Zarr result summary."""
|
|
162
|
+
base = flowsheet_basename(flowsheet)
|
|
163
|
+
archive_path = os.path.join(output_root(), f"{base}.pfarchive")
|
|
164
|
+
|
|
165
|
+
if not os.path.isdir(archive_path):
|
|
166
|
+
logger.error(
|
|
167
|
+
f"No archive found for '{flowsheet}' at {archive_path}. "
|
|
168
|
+
"Run 'pf run' first."
|
|
169
|
+
)
|
|
170
|
+
raise typer.Exit(code=1)
|
|
171
|
+
|
|
172
|
+
archive = ProcessStateArchive(archive_path)
|
|
173
|
+
latest = archive.latest_run()
|
|
174
|
+
latest_id = latest.run_id if latest is not None else None
|
|
175
|
+
|
|
176
|
+
if run_id is not None:
|
|
177
|
+
resolved_id = latest_id if run_id == "latest" and latest_id else run_id
|
|
178
|
+
if resolved_id != run_id and latest_id is None:
|
|
179
|
+
logger.error(f"No latest run found in {archive_path}.")
|
|
180
|
+
raise typer.Exit(code=1)
|
|
181
|
+
|
|
182
|
+
if resolved_id not in archive.list_runs():
|
|
183
|
+
logger.error(f"Run '{resolved_id}' not found in {archive_path}/runs.")
|
|
184
|
+
raise typer.Exit(code=1)
|
|
185
|
+
|
|
186
|
+
zarr_path = _zarr_path(archive_path, resolved_id)
|
|
187
|
+
|
|
188
|
+
if schema:
|
|
189
|
+
schema_path = zarr_path + ".schema.json"
|
|
190
|
+
if not os.path.isfile(schema_path):
|
|
191
|
+
logger.error(f"No schema found for run '{resolved_id}'.")
|
|
192
|
+
raise typer.Exit(code=1)
|
|
193
|
+
with open(schema_path, "r", encoding="utf-8") as f:
|
|
194
|
+
typer.echo(f.read())
|
|
195
|
+
return
|
|
196
|
+
|
|
197
|
+
manifest = archive.load_run(resolved_id)
|
|
198
|
+
summary = summarize_zarr_store(zarr_path)
|
|
199
|
+
summary["_zarr_path"] = zarr_path
|
|
200
|
+
typer.echo(_format_run_compact(manifest, summary))
|
|
201
|
+
return
|
|
202
|
+
|
|
203
|
+
# List all runs with a one-line summary.
|
|
204
|
+
run_ids = archive.list_runs()
|
|
205
|
+
if not run_ids:
|
|
206
|
+
typer.echo(f"No runs found for '{flowsheet}'.")
|
|
207
|
+
return
|
|
208
|
+
|
|
209
|
+
header = f"{'RUN ID':<28} {'TIMESTAMP':<22} {'LATEST':<7} {'SUMMARY':<30}"
|
|
210
|
+
typer.echo(header)
|
|
211
|
+
typer.echo("-" * len(header))
|
|
212
|
+
for rid in run_ids:
|
|
213
|
+
manifest = archive.load_run(rid)
|
|
214
|
+
if manifest is None:
|
|
215
|
+
continue
|
|
216
|
+
marker = "*" if rid == latest_id else " "
|
|
217
|
+
zarr_path = _zarr_path(archive_path, rid)
|
|
218
|
+
summary = summarize_zarr_store(zarr_path)
|
|
219
|
+
one_liner = _one_line_summary(summary)
|
|
220
|
+
typer.echo(
|
|
221
|
+
f"{rid:<28} {_humanize_timestamp(manifest.timestamp):<22} {marker:<7} {one_liner:<30}"
|
|
222
|
+
)
|
|
223
|
+
typer.echo("")
|
|
224
|
+
typer.echo(
|
|
225
|
+
"'*' marks the latest run. "
|
|
226
|
+
"'pf runs <flowsheet> <run_id>' shows the result summary. "
|
|
227
|
+
"Use 'latest' as the run id for the most recent run."
|
|
228
|
+
)
|
|
@@ -835,6 +835,27 @@ class Flowsheet:
|
|
|
835
835
|
) from exc
|
|
836
836
|
return stream_ts
|
|
837
837
|
|
|
838
|
+
@staticmethod
|
|
839
|
+
def _store_dynamic_outlet(results: dict, cfg: dict, sol) -> None:
|
|
840
|
+
"""Store a unit's dynamic solution into the result streams.
|
|
841
|
+
|
|
842
|
+
Handles the three outlet conventions supported by the framework:
|
|
843
|
+
* ``out`` is a string -> single outlet stream.
|
|
844
|
+
* ``out`` is a list of strings -> broadcast the same solution to each.
|
|
845
|
+
* ``retentate_out`` / ``permeate_out`` -> split the solution by key.
|
|
846
|
+
"""
|
|
847
|
+
if "out" in cfg:
|
|
848
|
+
out_val = cfg["out"]
|
|
849
|
+
if isinstance(out_val, list):
|
|
850
|
+
for stream_name in out_val:
|
|
851
|
+
results[stream_name] = sol
|
|
852
|
+
else:
|
|
853
|
+
results[out_val] = sol
|
|
854
|
+
else:
|
|
855
|
+
for out_key in ["retentate_out", "permeate_out"]:
|
|
856
|
+
if out_key in cfg and out_key in sol:
|
|
857
|
+
results[cfg[out_key]] = sol[out_key]
|
|
858
|
+
|
|
838
859
|
def _run_dynamic_sequential(self, solver, processing_order, results, t_eval, num_steps, start_time, end_time):
|
|
839
860
|
"""Standard sequential dynamic simulation for non-recycle flowsheets."""
|
|
840
861
|
# Process units in topological order
|
|
@@ -842,7 +863,6 @@ class Flowsheet:
|
|
|
842
863
|
unit = self.units[unit_name]
|
|
843
864
|
cfg = self.config["units"][unit_name]
|
|
844
865
|
inlet_name = cfg["in"]
|
|
845
|
-
outlets = self._get_unit_outlets(unit_name)
|
|
846
866
|
if isinstance(inlet_name, list):
|
|
847
867
|
inlet_stream_ts = self._merge_inlet_timeseries(inlet_name, results, num_steps, t_eval)
|
|
848
868
|
else:
|
|
@@ -853,23 +873,13 @@ class Flowsheet:
|
|
|
853
873
|
sol = unit.run_dynamic(
|
|
854
874
|
inlet_stream_ts, (start_time, end_time), t_eval, solver
|
|
855
875
|
)
|
|
856
|
-
|
|
857
|
-
results[outlets[0]] = sol
|
|
858
|
-
else:
|
|
859
|
-
for out_key, stream_name in zip(["retentate_out", "permeate_out"], outlets):
|
|
860
|
-
if out_key in sol:
|
|
861
|
-
results[stream_name] = sol[out_key]
|
|
876
|
+
self._store_dynamic_outlet(results, cfg, sol)
|
|
862
877
|
else:
|
|
863
878
|
logger.debug(f"Processing static unit {unit_name} dynamically")
|
|
864
879
|
sol = self._process_static_unit(
|
|
865
880
|
unit, inlet_stream_ts, t_eval, num_steps
|
|
866
881
|
)
|
|
867
|
-
|
|
868
|
-
results[outlets[0]] = sol
|
|
869
|
-
else:
|
|
870
|
-
for out_key, stream_name in zip(["retentate_out", "permeate_out"], outlets):
|
|
871
|
-
if out_key in sol:
|
|
872
|
-
results[stream_name] = sol[out_key]
|
|
882
|
+
self._store_dynamic_outlet(results, cfg, sol)
|
|
873
883
|
|
|
874
884
|
self.results = results
|
|
875
885
|
logger.info("Dynamic simulation completed")
|
|
@@ -981,7 +991,10 @@ class Flowsheet:
|
|
|
981
991
|
|
|
982
992
|
# Store results for this timestep
|
|
983
993
|
if "out" in cfg:
|
|
984
|
-
|
|
994
|
+
out_val = cfg["out"]
|
|
995
|
+
targets = out_val if isinstance(out_val, list) else [out_val]
|
|
996
|
+
for stream_name in targets:
|
|
997
|
+
self._store_snapshot_in_timeseries(results, stream_name, outlet_snapshot, step, components)
|
|
985
998
|
else:
|
|
986
999
|
for out_key in ["retentate_out", "permeate_out"]:
|
|
987
1000
|
if out_key in cfg and out_key in outlet_snapshot:
|
|
@@ -3,12 +3,45 @@ from __future__ import annotations
|
|
|
3
3
|
|
|
4
4
|
import re
|
|
5
5
|
|
|
6
|
+
from .interface import SolverUnitPort
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
def _sanitize_name(s: str) -> str:
|
|
8
10
|
"""Replace characters invalid in Python identifiers with underscores."""
|
|
9
11
|
return re.sub(r"[^a-zA-Z0-9_]", "_", s)
|
|
10
12
|
|
|
11
13
|
|
|
14
|
+
def solverunit_port_to_spec(port: SolverUnitPort) -> dict:
|
|
15
|
+
"""Convert a :class:`SolverUnitPort` to the internal spec dict format."""
|
|
16
|
+
return {
|
|
17
|
+
"attr_name": port.attr_name,
|
|
18
|
+
"initial_value": float(port.initial_value),
|
|
19
|
+
"causality": port.causality,
|
|
20
|
+
"variability": port.variability,
|
|
21
|
+
"description": port.description,
|
|
22
|
+
"unit": port.unit,
|
|
23
|
+
"logical_name": f"{port.unit_name}.{port.path}",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def ensure_unique_attr_names(specs: list[dict]) -> list[dict]:
|
|
28
|
+
"""Deduplicate ``attr_name`` values by appending a counter.
|
|
29
|
+
|
|
30
|
+
Preserves order and returns a new list of specs.
|
|
31
|
+
"""
|
|
32
|
+
seen: dict[str, int] = {}
|
|
33
|
+
out: list[dict] = []
|
|
34
|
+
for spec in specs:
|
|
35
|
+
name = spec["attr_name"]
|
|
36
|
+
count = seen.get(name, 0)
|
|
37
|
+
if count:
|
|
38
|
+
new_name = f"{name}_{count}"
|
|
39
|
+
spec = {**spec, "attr_name": new_name}
|
|
40
|
+
seen[name] = count + 1
|
|
41
|
+
out.append(spec)
|
|
42
|
+
return out
|
|
43
|
+
|
|
44
|
+
|
|
12
45
|
def get_fmi_variable_specs(
|
|
13
46
|
feed_streams: list[str],
|
|
14
47
|
output_streams: list[str],
|
|
@@ -115,8 +148,8 @@ def get_fmi_variable_specs(
|
|
|
115
148
|
"description": f"Parameter '{key}' of unit '{unit_name}'",
|
|
116
149
|
})
|
|
117
150
|
|
|
118
|
-
# --- Tank state outputs (dynamic
|
|
119
|
-
if mode
|
|
151
|
+
# --- Tank state outputs (dynamic / solverunit_dynamic modes only) ---
|
|
152
|
+
if mode in ("dynamic", "solverunit_dynamic"):
|
|
120
153
|
for unit_name, unit_cfg in config["units"].items():
|
|
121
154
|
if unit_cfg.get("type") != "Tank":
|
|
122
155
|
continue
|