processforge 0.1.0__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.1.0/LICENSE +29 -0
- processforge-0.1.0/MANIFEST.in +4 -0
- processforge-0.1.0/PKG-INFO +229 -0
- processforge-0.1.0/README.md +188 -0
- processforge-0.1.0/flowsheets/archive/example_dynamic_hybrid.json +41 -0
- processforge-0.1.0/flowsheets/archive/example_dynamic_tank.json +50 -0
- processforge-0.1.0/flowsheets/archive/example_flash.json +25 -0
- processforge-0.1.0/flowsheets/archive/hydraulic_chain.json +93 -0
- processforge-0.1.0/flowsheets/closed-loop-chain.json +127 -0
- processforge-0.1.0/pyproject.toml +65 -0
- processforge-0.1.0/setup.cfg +4 -0
- processforge-0.1.0/src/processforge/__init__.py +54 -0
- processforge-0.1.0/src/processforge/_schema.py +14 -0
- processforge-0.1.0/src/processforge/flowsheet.py +884 -0
- processforge-0.1.0/src/processforge/result.py +278 -0
- processforge-0.1.0/src/processforge/schemas/__init__.py +1 -0
- processforge-0.1.0/src/processforge/schemas/flowsheet_schema.json +221 -0
- processforge-0.1.0/src/processforge/simulate.py +138 -0
- processforge-0.1.0/src/processforge/solver.py +5 -0
- processforge-0.1.0/src/processforge/thermo.py +73 -0
- processforge-0.1.0/src/processforge/units/__init__.py +11 -0
- processforge-0.1.0/src/processforge/units/flash.py +103 -0
- processforge-0.1.0/src/processforge/units/heater.py +92 -0
- processforge-0.1.0/src/processforge/units/pipes.py +79 -0
- processforge-0.1.0/src/processforge/units/pump.py +54 -0
- processforge-0.1.0/src/processforge/units/solver.py +26 -0
- processforge-0.1.0/src/processforge/units/strainer.py +38 -0
- processforge-0.1.0/src/processforge/units/tank.py +199 -0
- processforge-0.1.0/src/processforge/units/valve.py +33 -0
- processforge-0.1.0/src/processforge/utils/__init__.py +0 -0
- processforge-0.1.0/src/processforge/utils/flowsheet_diagram.py +137 -0
- processforge-0.1.0/src/processforge/utils/validate_flowsheet.py +285 -0
- processforge-0.1.0/src/processforge/utils/validation.py +29 -0
- processforge-0.1.0/src/processforge/validate.py +26 -0
- processforge-0.1.0/src/processforge.egg-info/PKG-INFO +229 -0
- processforge-0.1.0/src/processforge.egg-info/SOURCES.txt +38 -0
- processforge-0.1.0/src/processforge.egg-info/dependency_links.txt +1 -0
- processforge-0.1.0/src/processforge.egg-info/entry_points.txt +2 -0
- processforge-0.1.0/src/processforge.egg-info/requires.txt +20 -0
- processforge-0.1.0/src/processforge.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018, the respective contributors, as shown by the AUTHORS file.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: processforge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python-based process simulation framework for chemical engineering applications.
|
|
5
|
+
Author-email: Process Forge Team <team@processforge.dev>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/urjanova/processforge
|
|
8
|
+
Project-URL: Repository, https://github.com/urjanova/processforge
|
|
9
|
+
Project-URL: Issues, https://github.com/urjanova/processforge/issues
|
|
10
|
+
Keywords: process,simulation,chemical,engineering,flowsheet
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: numpy>=2.0
|
|
23
|
+
Requires-Dist: scipy>=1.14
|
|
24
|
+
Requires-Dist: coolprop>=6.6
|
|
25
|
+
Requires-Dist: matplotlib>=3.9
|
|
26
|
+
Requires-Dist: loguru>=0.7
|
|
27
|
+
Requires-Dist: jsonschema>=4.20
|
|
28
|
+
Requires-Dist: graphviz>=0.20
|
|
29
|
+
Requires-Dist: pandas>=2.2
|
|
30
|
+
Requires-Dist: openpyxl>=3.1
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8; extra == "dev"
|
|
35
|
+
Requires-Dist: build; extra == "dev"
|
|
36
|
+
Requires-Dist: twine; extra == "dev"
|
|
37
|
+
Provides-Extra: docs
|
|
38
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
39
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# Process Forge
|
|
43
|
+
|
|
44
|
+
A Python-based process simulation framework for chemical process engineering applications.
|
|
45
|
+
|
|
46
|
+
## Table of Contents
|
|
47
|
+
|
|
48
|
+
- [Features](#features)
|
|
49
|
+
- [Available Unit Operations](#available-unit-operations)
|
|
50
|
+
- [Installation](#installation)
|
|
51
|
+
- [Usage](#usage)
|
|
52
|
+
- [Quick Start Examples](#quick-start-examples)
|
|
53
|
+
- [Project Structure](#project-structure)
|
|
54
|
+
- [Dependencies](#dependencies)
|
|
55
|
+
- [License](#license)
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
### Core Capabilities
|
|
60
|
+
- Steady-state and dynamic process simulations
|
|
61
|
+
- Thermodynamic property calculations using CoolProp
|
|
62
|
+
- Multiple unit operations for hydraulic and thermal systems
|
|
63
|
+
- Flowsheet modeling and solving with closed-loop (recycle) support
|
|
64
|
+
|
|
65
|
+
### Recycle Loop Support
|
|
66
|
+
- Automatic tear stream detection using graph analysis
|
|
67
|
+
- Wegstein convergence acceleration for faster solving
|
|
68
|
+
- Validation requirements ensure stability (Tank units required in loops)
|
|
69
|
+
- Configurable convergence tolerance and iteration limits
|
|
70
|
+
|
|
71
|
+
### Results & Visualization
|
|
72
|
+
- Export formats: CSV and JSON for easy data analysis
|
|
73
|
+
- Automatic plotting: temperature profiles and composition charts
|
|
74
|
+
- Graphviz flowsheet diagrams (PNG and SVG)
|
|
75
|
+
- Timeseries visualization for dynamic simulations
|
|
76
|
+
|
|
77
|
+
### Validation & Quality
|
|
78
|
+
- JSON schema validation for flowsheet configurations
|
|
79
|
+
- Connectivity checks (inlet sources, unused outlets, unreachable units)
|
|
80
|
+
- Comprehensive logging for debugging
|
|
81
|
+
|
|
82
|
+
## Available Unit Operations
|
|
83
|
+
|
|
84
|
+
| Unit Type | Mode | Description | Key Parameters |
|
|
85
|
+
|-----------|------|-------------|----------------|
|
|
86
|
+
| **Pump** | Steady-state | Adds pressure rise with efficiency losses | `deltaP`, `efficiency` |
|
|
87
|
+
| **Valve** | Steady-state | Isenthalpic pressure reduction | `pressure_ratio` |
|
|
88
|
+
| **Strainer** | Steady-state | Fixed pressure drop element | `deltaP` |
|
|
89
|
+
| **Pipes** | Steady-state & Dynamic | Laminar flow with friction losses | `delta_p`, `diameter` |
|
|
90
|
+
| **Tank** | Steady-state & Dynamic | Well-mixed molar tank | `inlet`, `outlet_flow`, `initial_n`, `initial_T`, `P`, `duty` |
|
|
91
|
+
| **Flash** | Steady-state | Isothermal flash separator | `P` |
|
|
92
|
+
| **Heater** | Steady-state | Temperature control unit | `duty`, `flowrate` |
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
### From PyPI
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install processforge
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### From source (development)
|
|
103
|
+
|
|
104
|
+
1. Clone the repository:
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/urjanova/processforge.git
|
|
107
|
+
cd processforge
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
2. Install the package:
|
|
111
|
+
```bash
|
|
112
|
+
pip install -e ".[dev]"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Or using uv:
|
|
116
|
+
```bash
|
|
117
|
+
uv sync
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Usage
|
|
121
|
+
|
|
122
|
+
### Command Line Interface
|
|
123
|
+
|
|
124
|
+
ProcessForge provides a CLI with three subcommands:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Run a simulation
|
|
128
|
+
processforge run flowsheets/closed-loop-chain.json
|
|
129
|
+
|
|
130
|
+
# Validate a flowsheet configuration
|
|
131
|
+
processforge validate flowsheets/closed-loop-chain.json
|
|
132
|
+
|
|
133
|
+
# Generate a flowsheet diagram
|
|
134
|
+
processforge diagram flowsheets/closed-loop-chain.json
|
|
135
|
+
processforge diagram flowsheets/closed-loop-chain.json --format svg --output-dir diagrams/
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Running a simulation generates output files in the `outputs/` directory:
|
|
139
|
+
- `*_results.json` - Simulation results in JSON format
|
|
140
|
+
- `*_timeseries.json` - Time-series data for dynamic simulations
|
|
141
|
+
- `*_timeseries.csv` - Tabular results with component compositions
|
|
142
|
+
- `*_validation.xlsx` - Validation report
|
|
143
|
+
|
|
144
|
+
### As a Python Module
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from processforge import Flowsheet, Pump, Tank, Pipes, validate_flowsheet
|
|
148
|
+
|
|
149
|
+
# Load and validate a flowsheet
|
|
150
|
+
config = validate_flowsheet("flowsheets/closed-loop-chain.json")
|
|
151
|
+
|
|
152
|
+
# Run simulation
|
|
153
|
+
fs = Flowsheet(config)
|
|
154
|
+
results = fs.run()
|
|
155
|
+
|
|
156
|
+
# Use individual unit operations
|
|
157
|
+
pump = Pump("my_pump", deltaP=1e5, efficiency=0.8)
|
|
158
|
+
outlet = pump.run({"T": 300, "P": 101325, "flowrate": 10, "z": {"Water": 1.0}})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Quick Start Examples
|
|
162
|
+
|
|
163
|
+
### Run a simulation
|
|
164
|
+
```bash
|
|
165
|
+
processforge run flowsheets/closed-loop-chain.json
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Validate a flowsheet
|
|
169
|
+
```bash
|
|
170
|
+
processforge validate flowsheets/closed-loop-chain.json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Generate a flowsheet diagram
|
|
174
|
+
```bash
|
|
175
|
+
processforge diagram flowsheets/closed-loop-chain.json
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Project Structure
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
processforge/
|
|
182
|
+
├── src/processforge/ # Core package
|
|
183
|
+
│ ├── __init__.py # Public API
|
|
184
|
+
│ ├── flowsheet.py # Flowsheet modeling with closed-loop handling
|
|
185
|
+
│ ├── thermo.py # Thermodynamic calculations via CoolProp
|
|
186
|
+
│ ├── result.py # Results export (CSV, JSON, Excel, plotting)
|
|
187
|
+
│ ├── simulate.py # CLI entry point with subcommands
|
|
188
|
+
│ ├── solver.py # Solver interface
|
|
189
|
+
│ ├── validate.py # Simple schema validation
|
|
190
|
+
│ ├── _schema.py # Schema loader (importlib.resources)
|
|
191
|
+
│ ├── units/ # Unit operations
|
|
192
|
+
│ │ ├── pump.py # Pump with efficiency
|
|
193
|
+
│ │ ├── valve.py # Pressure-reducing valve
|
|
194
|
+
│ │ ├── strainer.py # Pressure drop element
|
|
195
|
+
│ │ ├── pipes.py # Pipe with friction losses
|
|
196
|
+
│ │ ├── tank.py # Well-mixed tank (steady & dynamic)
|
|
197
|
+
│ │ ├── flash.py # Isothermal flash separator
|
|
198
|
+
│ │ └── heater.py # Temperature control heater
|
|
199
|
+
│ ├── utils/ # Utilities
|
|
200
|
+
│ │ ├── validate_flowsheet.py # Schema + connectivity validation
|
|
201
|
+
│ │ └── flowsheet_diagram.py # Graphviz visualization
|
|
202
|
+
│ └── schemas/ # Bundled JSON schemas
|
|
203
|
+
│ └── flowsheet_schema.json
|
|
204
|
+
├── flowsheets/ # Example flowsheet configurations
|
|
205
|
+
│ ├── closed-loop-chain.json # Main example with recycle
|
|
206
|
+
│ └── archive/ # Additional examples
|
|
207
|
+
├── pyproject.toml # Project configuration
|
|
208
|
+
└── MANIFEST.in # Source distribution manifest
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Dependencies
|
|
212
|
+
|
|
213
|
+
Core dependencies:
|
|
214
|
+
|
|
215
|
+
- **numpy** - Numerical computing
|
|
216
|
+
- **scipy** - Scientific computing and ODE solvers
|
|
217
|
+
- **coolprop** - Thermodynamic property calculations
|
|
218
|
+
- **matplotlib** - Plotting and visualization
|
|
219
|
+
- **loguru** - Logging
|
|
220
|
+
- **jsonschema** - Configuration validation
|
|
221
|
+
- **graphviz** - Flowsheet diagram generation
|
|
222
|
+
- **pandas** - Data manipulation
|
|
223
|
+
- **openpyxl** - Excel report generation
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
This project is licensed under the BSD 3-Clause License. See the [LICENSE](LICENSE) file for details.
|
|
228
|
+
|
|
229
|
+
For licensing inquiries, please [contact the development](https://forms.gle/wUweVnoSqA9VeD7m9) team.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Process Forge
|
|
2
|
+
|
|
3
|
+
A Python-based process simulation framework for chemical process engineering applications.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Features](#features)
|
|
8
|
+
- [Available Unit Operations](#available-unit-operations)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Quick Start Examples](#quick-start-examples)
|
|
12
|
+
- [Project Structure](#project-structure)
|
|
13
|
+
- [Dependencies](#dependencies)
|
|
14
|
+
- [License](#license)
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
### Core Capabilities
|
|
19
|
+
- Steady-state and dynamic process simulations
|
|
20
|
+
- Thermodynamic property calculations using CoolProp
|
|
21
|
+
- Multiple unit operations for hydraulic and thermal systems
|
|
22
|
+
- Flowsheet modeling and solving with closed-loop (recycle) support
|
|
23
|
+
|
|
24
|
+
### Recycle Loop Support
|
|
25
|
+
- Automatic tear stream detection using graph analysis
|
|
26
|
+
- Wegstein convergence acceleration for faster solving
|
|
27
|
+
- Validation requirements ensure stability (Tank units required in loops)
|
|
28
|
+
- Configurable convergence tolerance and iteration limits
|
|
29
|
+
|
|
30
|
+
### Results & Visualization
|
|
31
|
+
- Export formats: CSV and JSON for easy data analysis
|
|
32
|
+
- Automatic plotting: temperature profiles and composition charts
|
|
33
|
+
- Graphviz flowsheet diagrams (PNG and SVG)
|
|
34
|
+
- Timeseries visualization for dynamic simulations
|
|
35
|
+
|
|
36
|
+
### Validation & Quality
|
|
37
|
+
- JSON schema validation for flowsheet configurations
|
|
38
|
+
- Connectivity checks (inlet sources, unused outlets, unreachable units)
|
|
39
|
+
- Comprehensive logging for debugging
|
|
40
|
+
|
|
41
|
+
## Available Unit Operations
|
|
42
|
+
|
|
43
|
+
| Unit Type | Mode | Description | Key Parameters |
|
|
44
|
+
|-----------|------|-------------|----------------|
|
|
45
|
+
| **Pump** | Steady-state | Adds pressure rise with efficiency losses | `deltaP`, `efficiency` |
|
|
46
|
+
| **Valve** | Steady-state | Isenthalpic pressure reduction | `pressure_ratio` |
|
|
47
|
+
| **Strainer** | Steady-state | Fixed pressure drop element | `deltaP` |
|
|
48
|
+
| **Pipes** | Steady-state & Dynamic | Laminar flow with friction losses | `delta_p`, `diameter` |
|
|
49
|
+
| **Tank** | Steady-state & Dynamic | Well-mixed molar tank | `inlet`, `outlet_flow`, `initial_n`, `initial_T`, `P`, `duty` |
|
|
50
|
+
| **Flash** | Steady-state | Isothermal flash separator | `P` |
|
|
51
|
+
| **Heater** | Steady-state | Temperature control unit | `duty`, `flowrate` |
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
### From PyPI
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install processforge
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### From source (development)
|
|
62
|
+
|
|
63
|
+
1. Clone the repository:
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/urjanova/processforge.git
|
|
66
|
+
cd processforge
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
2. Install the package:
|
|
70
|
+
```bash
|
|
71
|
+
pip install -e ".[dev]"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or using uv:
|
|
75
|
+
```bash
|
|
76
|
+
uv sync
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
### Command Line Interface
|
|
82
|
+
|
|
83
|
+
ProcessForge provides a CLI with three subcommands:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Run a simulation
|
|
87
|
+
processforge run flowsheets/closed-loop-chain.json
|
|
88
|
+
|
|
89
|
+
# Validate a flowsheet configuration
|
|
90
|
+
processforge validate flowsheets/closed-loop-chain.json
|
|
91
|
+
|
|
92
|
+
# Generate a flowsheet diagram
|
|
93
|
+
processforge diagram flowsheets/closed-loop-chain.json
|
|
94
|
+
processforge diagram flowsheets/closed-loop-chain.json --format svg --output-dir diagrams/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Running a simulation generates output files in the `outputs/` directory:
|
|
98
|
+
- `*_results.json` - Simulation results in JSON format
|
|
99
|
+
- `*_timeseries.json` - Time-series data for dynamic simulations
|
|
100
|
+
- `*_timeseries.csv` - Tabular results with component compositions
|
|
101
|
+
- `*_validation.xlsx` - Validation report
|
|
102
|
+
|
|
103
|
+
### As a Python Module
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from processforge import Flowsheet, Pump, Tank, Pipes, validate_flowsheet
|
|
107
|
+
|
|
108
|
+
# Load and validate a flowsheet
|
|
109
|
+
config = validate_flowsheet("flowsheets/closed-loop-chain.json")
|
|
110
|
+
|
|
111
|
+
# Run simulation
|
|
112
|
+
fs = Flowsheet(config)
|
|
113
|
+
results = fs.run()
|
|
114
|
+
|
|
115
|
+
# Use individual unit operations
|
|
116
|
+
pump = Pump("my_pump", deltaP=1e5, efficiency=0.8)
|
|
117
|
+
outlet = pump.run({"T": 300, "P": 101325, "flowrate": 10, "z": {"Water": 1.0}})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Quick Start Examples
|
|
121
|
+
|
|
122
|
+
### Run a simulation
|
|
123
|
+
```bash
|
|
124
|
+
processforge run flowsheets/closed-loop-chain.json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Validate a flowsheet
|
|
128
|
+
```bash
|
|
129
|
+
processforge validate flowsheets/closed-loop-chain.json
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Generate a flowsheet diagram
|
|
133
|
+
```bash
|
|
134
|
+
processforge diagram flowsheets/closed-loop-chain.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Project Structure
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
processforge/
|
|
141
|
+
├── src/processforge/ # Core package
|
|
142
|
+
│ ├── __init__.py # Public API
|
|
143
|
+
│ ├── flowsheet.py # Flowsheet modeling with closed-loop handling
|
|
144
|
+
│ ├── thermo.py # Thermodynamic calculations via CoolProp
|
|
145
|
+
│ ├── result.py # Results export (CSV, JSON, Excel, plotting)
|
|
146
|
+
│ ├── simulate.py # CLI entry point with subcommands
|
|
147
|
+
│ ├── solver.py # Solver interface
|
|
148
|
+
│ ├── validate.py # Simple schema validation
|
|
149
|
+
│ ├── _schema.py # Schema loader (importlib.resources)
|
|
150
|
+
│ ├── units/ # Unit operations
|
|
151
|
+
│ │ ├── pump.py # Pump with efficiency
|
|
152
|
+
│ │ ├── valve.py # Pressure-reducing valve
|
|
153
|
+
│ │ ├── strainer.py # Pressure drop element
|
|
154
|
+
│ │ ├── pipes.py # Pipe with friction losses
|
|
155
|
+
│ │ ├── tank.py # Well-mixed tank (steady & dynamic)
|
|
156
|
+
│ │ ├── flash.py # Isothermal flash separator
|
|
157
|
+
│ │ └── heater.py # Temperature control heater
|
|
158
|
+
│ ├── utils/ # Utilities
|
|
159
|
+
│ │ ├── validate_flowsheet.py # Schema + connectivity validation
|
|
160
|
+
│ │ └── flowsheet_diagram.py # Graphviz visualization
|
|
161
|
+
│ └── schemas/ # Bundled JSON schemas
|
|
162
|
+
│ └── flowsheet_schema.json
|
|
163
|
+
├── flowsheets/ # Example flowsheet configurations
|
|
164
|
+
│ ├── closed-loop-chain.json # Main example with recycle
|
|
165
|
+
│ └── archive/ # Additional examples
|
|
166
|
+
├── pyproject.toml # Project configuration
|
|
167
|
+
└── MANIFEST.in # Source distribution manifest
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Dependencies
|
|
171
|
+
|
|
172
|
+
Core dependencies:
|
|
173
|
+
|
|
174
|
+
- **numpy** - Numerical computing
|
|
175
|
+
- **scipy** - Scientific computing and ODE solvers
|
|
176
|
+
- **coolprop** - Thermodynamic property calculations
|
|
177
|
+
- **matplotlib** - Plotting and visualization
|
|
178
|
+
- **loguru** - Logging
|
|
179
|
+
- **jsonschema** - Configuration validation
|
|
180
|
+
- **graphviz** - Flowsheet diagram generation
|
|
181
|
+
- **pandas** - Data manipulation
|
|
182
|
+
- **openpyxl** - Excel report generation
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
This project is licensed under the BSD 3-Clause License. See the [LICENSE](LICENSE) file for details.
|
|
187
|
+
|
|
188
|
+
For licensing inquiries, please [contact the development](https://forms.gle/wUweVnoSqA9VeD7m9) team.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"streams": {
|
|
3
|
+
"feed": {
|
|
4
|
+
"T": 300,
|
|
5
|
+
"P": 101325,
|
|
6
|
+
"z": {"Methane": 0.7, "Ethane": 0.3},
|
|
7
|
+
"flowrate": 2.0
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"units": {
|
|
11
|
+
"tank1": {
|
|
12
|
+
"type": "Tank",
|
|
13
|
+
"inlet": "feed",
|
|
14
|
+
"outlet_flow": 1.5,
|
|
15
|
+
"initial_n": {"Methane": 1.0, "Ethane": 1.0},
|
|
16
|
+
"initial_T": 300,
|
|
17
|
+
"P": 101325,
|
|
18
|
+
"duty": 100.0
|
|
19
|
+
},
|
|
20
|
+
"heater": {
|
|
21
|
+
"type": "Heater",
|
|
22
|
+
"in": "tank1",
|
|
23
|
+
"out": "hot",
|
|
24
|
+
"duty": 5000.0,
|
|
25
|
+
"flowrate": 1.5
|
|
26
|
+
},
|
|
27
|
+
"flash": {
|
|
28
|
+
"type": "Flash",
|
|
29
|
+
"in": "hot",
|
|
30
|
+
"out_vap": "vap",
|
|
31
|
+
"out_liq": "liq",
|
|
32
|
+
"P": 101325
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"simulation": {
|
|
36
|
+
"mode": "dynamic",
|
|
37
|
+
"t0": 0.0,
|
|
38
|
+
"tf": 20.0,
|
|
39
|
+
"dt": 1.0
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"streams": {
|
|
3
|
+
"feed": {
|
|
4
|
+
"T": 300,
|
|
5
|
+
"P": 101325,
|
|
6
|
+
"z": {"Methane": 0.7, "Ethane": 0.3},
|
|
7
|
+
"flowrate": 2.0
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"units": {
|
|
11
|
+
"tank1": {
|
|
12
|
+
"type": "Tank",
|
|
13
|
+
"inlet": "feed",
|
|
14
|
+
"outlet_flow": 1.5,
|
|
15
|
+
"initial_n": {"Methane": 1.0, "Ethane": 1.0},
|
|
16
|
+
"initial_T": 300,
|
|
17
|
+
"P": 101325,
|
|
18
|
+
"duty": 100.0
|
|
19
|
+
},
|
|
20
|
+
"tank2": {
|
|
21
|
+
"type": "Tank",
|
|
22
|
+
"inlet": "tank1",
|
|
23
|
+
"outlet_flow": 1.0,
|
|
24
|
+
"initial_n": {"Methane": 0.5, "Ethane": 0.5},
|
|
25
|
+
"initial_T": 300,
|
|
26
|
+
"P": 101325,
|
|
27
|
+
"duty": 50.0
|
|
28
|
+
},
|
|
29
|
+
"heater": {
|
|
30
|
+
"type": "Heater",
|
|
31
|
+
"in": "tank2",
|
|
32
|
+
"out": "hot",
|
|
33
|
+
"duty": 5000.0,
|
|
34
|
+
"flowrate": 1.0
|
|
35
|
+
},
|
|
36
|
+
"flash": {
|
|
37
|
+
"type": "Flash",
|
|
38
|
+
"in": "hot",
|
|
39
|
+
"out_vap": "vap",
|
|
40
|
+
"out_liq": "liq",
|
|
41
|
+
"P": 101325
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"simulation": {
|
|
45
|
+
"mode": "dynamic",
|
|
46
|
+
"t0": 0.0,
|
|
47
|
+
"tf": 20.0,
|
|
48
|
+
"dt": 1.0
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"streams": {
|
|
3
|
+
"feed": {
|
|
4
|
+
"T": 300,
|
|
5
|
+
"P": 101325,
|
|
6
|
+
"z": {"Methane": 0.5, "Ethane": 0.5}
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"units": {
|
|
10
|
+
"heater": {
|
|
11
|
+
"type": "Heater",
|
|
12
|
+
"in": "feed",
|
|
13
|
+
"out": "hot",
|
|
14
|
+
"duty": 20000,
|
|
15
|
+
"flowrate": 1.0
|
|
16
|
+
},
|
|
17
|
+
"flash": {
|
|
18
|
+
"type": "Flash",
|
|
19
|
+
"in": "hot",
|
|
20
|
+
"out_vap": "vap",
|
|
21
|
+
"out_liq": "liq",
|
|
22
|
+
"P": 101325
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"name": "Hydraulic Chain Example",
|
|
4
|
+
"description": "Base configuration for a two-pump, one-valve, one-strainer hydraulic system.",
|
|
5
|
+
"version": "1.0"
|
|
6
|
+
},
|
|
7
|
+
"streams": {
|
|
8
|
+
"feed": {
|
|
9
|
+
"T": 198.15,
|
|
10
|
+
"P": 101325,
|
|
11
|
+
"z": {
|
|
12
|
+
"Water": 0.8,
|
|
13
|
+
"Toluene": 0.2
|
|
14
|
+
},
|
|
15
|
+
"flowrate": 1.0
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"units": {
|
|
19
|
+
"pump_1": {
|
|
20
|
+
"type": "Pump",
|
|
21
|
+
"in": "feed",
|
|
22
|
+
"out": "after_pump_1",
|
|
23
|
+
"deltaP": 200000.0,
|
|
24
|
+
"efficiency": 0.75
|
|
25
|
+
},
|
|
26
|
+
"pipe_1": {
|
|
27
|
+
"type": "Pipes",
|
|
28
|
+
"in": "after_pump_1",
|
|
29
|
+
"out": "after_pipe_1",
|
|
30
|
+
"delta_p": 1000.0,
|
|
31
|
+
"diameter": 0.05
|
|
32
|
+
},
|
|
33
|
+
"valve_1": {
|
|
34
|
+
"type": "Valve",
|
|
35
|
+
"in": "after_pipe_1",
|
|
36
|
+
"out": "after_valve_1",
|
|
37
|
+
"pressure_ratio": 0.5
|
|
38
|
+
},
|
|
39
|
+
"pipe_2": {
|
|
40
|
+
"type": "Pipes",
|
|
41
|
+
"in": "after_valve_1",
|
|
42
|
+
"out": "after_pipe_2",
|
|
43
|
+
"delta_p": 1000.0,
|
|
44
|
+
"diameter": 0.08
|
|
45
|
+
},
|
|
46
|
+
"strainer_1": {
|
|
47
|
+
"type": "Strainer",
|
|
48
|
+
"in": "after_pipe_2",
|
|
49
|
+
"out": "after_strainer_1",
|
|
50
|
+
"deltaP": 5000.0
|
|
51
|
+
},
|
|
52
|
+
"pipe_3": {
|
|
53
|
+
"type": "Pipes",
|
|
54
|
+
"in": "after_strainer_1",
|
|
55
|
+
"out": "after_pipe_3",
|
|
56
|
+
"delta_p": 1000.0,
|
|
57
|
+
"diameter": 0.1
|
|
58
|
+
},
|
|
59
|
+
"pump_2": {
|
|
60
|
+
"type": "Pump",
|
|
61
|
+
"in": "after_pipe_3",
|
|
62
|
+
"out": "after_pump_2",
|
|
63
|
+
"deltaP": 300000.0,
|
|
64
|
+
"efficiency": 0.8
|
|
65
|
+
},
|
|
66
|
+
"pipe_4": {
|
|
67
|
+
"type": "Pipes",
|
|
68
|
+
"in": "after_pump_2",
|
|
69
|
+
"out": "after_pipe_4",
|
|
70
|
+
"delta_p": 1000.0,
|
|
71
|
+
"diameter": 0.12
|
|
72
|
+
},
|
|
73
|
+
"tank_1": {
|
|
74
|
+
"type": "Tank",
|
|
75
|
+
"in": "after_pipe_4",
|
|
76
|
+
"out": "product",
|
|
77
|
+
"outlet_flow": 1.0,
|
|
78
|
+
"initial_n": {
|
|
79
|
+
"Water": 9.0,
|
|
80
|
+
"Toluene": 1.0
|
|
81
|
+
},
|
|
82
|
+
"initial_T": 298.15,
|
|
83
|
+
"P": 101325,
|
|
84
|
+
"duty": 0.0
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"simulation": {
|
|
88
|
+
"mode": "dynamic",
|
|
89
|
+
"t0": 0.0,
|
|
90
|
+
"tf": 20.0,
|
|
91
|
+
"dt":
|
|
92
|
+
}
|
|
93
|
+
}
|