OpenPyTEA 3.2.0__tar.gz → 3.2.2__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.
- {openpytea-3.2.0/src/OpenPyTEA.egg-info → openpytea-3.2.2}/PKG-INFO +16 -8
- {openpytea-3.2.0 → openpytea-3.2.2}/README.md +11 -7
- {openpytea-3.2.0 → openpytea-3.2.2}/pyproject.toml +7 -1
- {openpytea-3.2.0 → openpytea-3.2.2/src/OpenPyTEA.egg-info}/PKG-INFO +16 -8
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/analysis.py +150 -53
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/data/cost_correlations.csv +31 -27
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/equipment.py +38 -9
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/helpers.py +131 -76
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/plant.py +216 -78
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/plotting.py +82 -29
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_analysis.py +138 -8
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_composite_equipment.py +13 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_equipment.py +10 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_plant.py +65 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_plotting.py +130 -2
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_run_tea.py +1 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/LICENSE +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/setup.cfg +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/SOURCES.txt +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/dependency_links.txt +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/entry_points.txt +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/requires.txt +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/top_level.txt +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/__init__.py +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/cli.py +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/data/cepci_values.csv +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/src/openpytea/io.py +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_cli.py +0 -0
- {openpytea-3.2.0 → openpytea-3.2.2}/tests/test_smoke.py +0 -0
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenPyTEA
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.2
|
|
4
4
|
Summary: OpenPyTEA: An open-source Python toolkit for techno-economic assessment of process plants with economic sensitivity and uncertainty evaluation
|
|
5
5
|
Maintainer-email: "Panji B. Tamarona" <P.B.Tamarona@tudelft.nl>
|
|
6
6
|
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pbtamarona/OpenPyTEA
|
|
8
|
+
Project-URL: Documentation, https://openpytea.readthedocs.io
|
|
9
|
+
Project-URL: Changelog, https://github.com/pbtamarona/OpenPyTEA/releases
|
|
10
|
+
Project-URL: Issues, https://github.com/pbtamarona/OpenPyTEA/issues
|
|
7
11
|
Keywords: chemical-engineering,process-design,power-plant,techno-economic-analysis,process-plant
|
|
8
12
|
Requires-Python: >=3.10
|
|
9
13
|
Description-Content-Type: text/markdown
|
|
@@ -154,16 +158,20 @@ Software architecture and data flow of **OpenPyTEA**, illustrating the progressi
|
|
|
154
158
|
---
|
|
155
159
|
## 🖥️ Graphical User Interface
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
An optional desktop app provides the full TEA workflow — equipment costing, plant configuration, results, sensitivity/tornado analysis, Monte Carlo, and multi-plant comparison — without writing Python code. No Python or Node.js required.
|
|
158
162
|
|
|
159
|
-
|
|
163
|
+
**Download** the installer for your platform from the **[OpenPyTEA 3.2.2 release](https://github.com/pbtamarona/OpenPyTEA/releases/tag/v3.2.2)**:
|
|
160
164
|
|
|
161
|
-
|
|
165
|
+
| Platform | File |
|
|
166
|
+
|---|---|
|
|
167
|
+
| **Windows** (x64) | `OpenPyTEA_3.2.2_x64-setup.exe` (or the `.msi`) |
|
|
168
|
+
| **macOS** (Apple Silicon) | `OpenPyTEA_3.2.2_aarch64.dmg` |
|
|
162
169
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
**Install:**
|
|
171
|
+
- **Windows:** run the `.exe` and follow the setup wizard. If SmartScreen shows *"Windows protected your PC"* (the app isn't code-signed), click **More info** → **Run anyway**.
|
|
172
|
+
- **macOS:** open the `.dmg` and drag OpenPyTEA into **Applications**. Before the first launch, run `xattr -dr com.apple.quarantine /Applications/OpenPyTEA.app` once in Terminal (the app isn't code-signed).
|
|
173
|
+
|
|
174
|
+
Then click **Examples** in the app to load a case study and explore. To run the GUI from source, see the [GUI page of the docs](https://openpytea.readthedocs.io/en/latest/gui.html#running-from-source); to build the installers yourself, see [GUI development](https://openpytea.readthedocs.io/en/latest/gui_development.html).
|
|
167
175
|
|
|
168
176
|
---
|
|
169
177
|
## 🧠 Core Concepts
|
|
@@ -130,16 +130,20 @@ Software architecture and data flow of **OpenPyTEA**, illustrating the progressi
|
|
|
130
130
|
---
|
|
131
131
|
## 🖥️ Graphical User Interface
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
An optional desktop app provides the full TEA workflow — equipment costing, plant configuration, results, sensitivity/tornado analysis, Monte Carlo, and multi-plant comparison — without writing Python code. No Python or Node.js required.
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
**Download** the installer for your platform from the **[OpenPyTEA 3.2.2 release](https://github.com/pbtamarona/OpenPyTEA/releases/tag/v3.2.2)**:
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
| Platform | File |
|
|
138
|
+
|---|---|
|
|
139
|
+
| **Windows** (x64) | `OpenPyTEA_3.2.2_x64-setup.exe` (or the `.msi`) |
|
|
140
|
+
| **macOS** (Apple Silicon) | `OpenPyTEA_3.2.2_aarch64.dmg` |
|
|
138
141
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
**Install:**
|
|
143
|
+
- **Windows:** run the `.exe` and follow the setup wizard. If SmartScreen shows *"Windows protected your PC"* (the app isn't code-signed), click **More info** → **Run anyway**.
|
|
144
|
+
- **macOS:** open the `.dmg` and drag OpenPyTEA into **Applications**. Before the first launch, run `xattr -dr com.apple.quarantine /Applications/OpenPyTEA.app` once in Terminal (the app isn't code-signed).
|
|
145
|
+
|
|
146
|
+
Then click **Examples** in the app to load a case study and explore. To run the GUI from source, see the [GUI page of the docs](https://openpytea.readthedocs.io/en/latest/gui.html#running-from-source); to build the installers yourself, see [GUI development](https://openpytea.readthedocs.io/en/latest/gui_development.html).
|
|
143
147
|
|
|
144
148
|
---
|
|
145
149
|
## 🧠 Core Concepts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "OpenPyTEA"
|
|
3
|
-
version = "3.2.
|
|
3
|
+
version = "3.2.2"
|
|
4
4
|
description = "OpenPyTEA: An open-source Python toolkit for techno-economic assessment of process plants with economic sensitivity and uncertainty evaluation"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -28,6 +28,12 @@ maintainers = [
|
|
|
28
28
|
{ name = "Panji B. Tamarona", email = "P.B.Tamarona@tudelft.nl" }
|
|
29
29
|
]
|
|
30
30
|
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/pbtamarona/OpenPyTEA"
|
|
33
|
+
Documentation = "https://openpytea.readthedocs.io"
|
|
34
|
+
Changelog = "https://github.com/pbtamarona/OpenPyTEA/releases"
|
|
35
|
+
Issues = "https://github.com/pbtamarona/OpenPyTEA/issues"
|
|
36
|
+
|
|
31
37
|
[project.scripts]
|
|
32
38
|
openpytea = "openpytea.cli:main"
|
|
33
39
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenPyTEA
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.2
|
|
4
4
|
Summary: OpenPyTEA: An open-source Python toolkit for techno-economic assessment of process plants with economic sensitivity and uncertainty evaluation
|
|
5
5
|
Maintainer-email: "Panji B. Tamarona" <P.B.Tamarona@tudelft.nl>
|
|
6
6
|
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pbtamarona/OpenPyTEA
|
|
8
|
+
Project-URL: Documentation, https://openpytea.readthedocs.io
|
|
9
|
+
Project-URL: Changelog, https://github.com/pbtamarona/OpenPyTEA/releases
|
|
10
|
+
Project-URL: Issues, https://github.com/pbtamarona/OpenPyTEA/issues
|
|
7
11
|
Keywords: chemical-engineering,process-design,power-plant,techno-economic-analysis,process-plant
|
|
8
12
|
Requires-Python: >=3.10
|
|
9
13
|
Description-Content-Type: text/markdown
|
|
@@ -154,16 +158,20 @@ Software architecture and data flow of **OpenPyTEA**, illustrating the progressi
|
|
|
154
158
|
---
|
|
155
159
|
## 🖥️ Graphical User Interface
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
An optional desktop app provides the full TEA workflow — equipment costing, plant configuration, results, sensitivity/tornado analysis, Monte Carlo, and multi-plant comparison — without writing Python code. No Python or Node.js required.
|
|
158
162
|
|
|
159
|
-
|
|
163
|
+
**Download** the installer for your platform from the **[OpenPyTEA 3.2.2 release](https://github.com/pbtamarona/OpenPyTEA/releases/tag/v3.2.2)**:
|
|
160
164
|
|
|
161
|
-
|
|
165
|
+
| Platform | File |
|
|
166
|
+
|---|---|
|
|
167
|
+
| **Windows** (x64) | `OpenPyTEA_3.2.2_x64-setup.exe` (or the `.msi`) |
|
|
168
|
+
| **macOS** (Apple Silicon) | `OpenPyTEA_3.2.2_aarch64.dmg` |
|
|
162
169
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
**Install:**
|
|
171
|
+
- **Windows:** run the `.exe` and follow the setup wizard. If SmartScreen shows *"Windows protected your PC"* (the app isn't code-signed), click **More info** → **Run anyway**.
|
|
172
|
+
- **macOS:** open the `.dmg` and drag OpenPyTEA into **Applications**. Before the first launch, run `xattr -dr com.apple.quarantine /Applications/OpenPyTEA.app` once in Terminal (the app isn't code-signed).
|
|
173
|
+
|
|
174
|
+
Then click **Examples** in the app to load a case study and explore. To run the GUI from source, see the [GUI page of the docs](https://openpytea.readthedocs.io/en/latest/gui.html#running-from-source); to build the installers yourself, see [GUI development](https://openpytea.readthedocs.io/en/latest/gui_development.html).
|
|
167
175
|
|
|
168
176
|
---
|
|
169
177
|
## 🧠 Core Concepts
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from copy import deepcopy
|
|
2
3
|
from tqdm.auto import tqdm
|
|
3
4
|
from scipy import stats
|
|
4
5
|
import numpy as np
|
|
5
6
|
|
|
7
|
+
from openpytea.plant import DEFAULT_OPERATOR_HOURLY_RATE
|
|
6
8
|
from openpytea.helpers import (_make_label,
|
|
9
|
+
_legacy_label,
|
|
10
|
+
_tex_escape,
|
|
7
11
|
_get_original_value,
|
|
8
12
|
_update_and_evaluate,
|
|
9
13
|
_default_metric_label,
|
|
@@ -26,7 +30,8 @@ from openpytea.helpers import (_make_label,
|
|
|
26
30
|
# DATA PREPARATION (MAIN API)
|
|
27
31
|
# ======================================================
|
|
28
32
|
|
|
29
|
-
def direct_costs_data(plants, pct=False, expand_composites=False
|
|
33
|
+
def direct_costs_data(plants, pct=False, expand_composites=False,
|
|
34
|
+
by_category=False):
|
|
30
35
|
"""
|
|
31
36
|
Extract and organize direct cost data from one or more plants.
|
|
32
37
|
This function aggregates direct cost information from equipment lists
|
|
@@ -45,6 +50,12 @@ def direct_costs_data(plants, pct=False, expand_composites=False):
|
|
|
45
50
|
into its leaf components (labelled ``"Composite / component"``) using
|
|
46
51
|
:meth:`~openpytea.equipment.CompositeEquipment.direct_cost_breakdown`
|
|
47
52
|
instead of appearing as a single bar segment. Default is False.
|
|
53
|
+
by_category : bool, optional
|
|
54
|
+
If True, sum the direct costs per equipment ``category`` (one bar
|
|
55
|
+
segment per category) instead of listing each equipment by name.
|
|
56
|
+
A composite counts under its own category, or with
|
|
57
|
+
``expand_composites=True`` each of its components under the
|
|
58
|
+
component's category. Default is False.
|
|
48
59
|
Returns
|
|
49
60
|
-------
|
|
50
61
|
dict
|
|
@@ -65,6 +76,7 @@ def direct_costs_data(plants, pct=False, expand_composites=False):
|
|
|
65
76
|
>>> plant1 = Plant(name="Plant A", currency="$")
|
|
66
77
|
>>> data = direct_costs_data(plant1)
|
|
67
78
|
>>> data = direct_costs_data([plant1, plant2], pct=True)
|
|
79
|
+
>>> data = direct_costs_data(plant1, by_category=True)
|
|
68
80
|
"""
|
|
69
81
|
# ponytail: all five *_data functions repeat this wrapper; one _bar_data(plants,
|
|
70
82
|
# per_plant_fn, ylabel, pct)
|
|
@@ -80,10 +92,16 @@ def direct_costs_data(plants, pct=False, expand_composites=False):
|
|
|
80
92
|
components = {}
|
|
81
93
|
for eq in plant.equipment_list:
|
|
82
94
|
if expand_composites and hasattr(eq, "direct_cost_breakdown"):
|
|
83
|
-
|
|
84
|
-
|
|
95
|
+
# leaves() yields the components in direct_cost_breakdown's order
|
|
96
|
+
items = [(label if not by_category else leaf.category, cost)
|
|
97
|
+
for (_, leaf, _), (label, cost) in zip(
|
|
98
|
+
eq.leaves(), eq.direct_cost_breakdown().items())]
|
|
85
99
|
else:
|
|
86
|
-
|
|
100
|
+
items = [(eq.category if by_category else eq.name,
|
|
101
|
+
eq.direct_cost)]
|
|
102
|
+
for key, cost in items:
|
|
103
|
+
prev = components.get(key, 0.0) if by_category else 0.0
|
|
104
|
+
components[key] = prev + float(cost * scale)
|
|
87
105
|
components_list.append(components)
|
|
88
106
|
xlabels.append(plant.name)
|
|
89
107
|
|
|
@@ -199,6 +217,7 @@ def variable_opex_data(plants, pct=False):
|
|
|
199
217
|
|
|
200
218
|
components_list = []
|
|
201
219
|
xlabels = []
|
|
220
|
+
display_labels = {}
|
|
202
221
|
|
|
203
222
|
for plant in plants:
|
|
204
223
|
components = {}
|
|
@@ -212,14 +231,18 @@ def variable_opex_data(plants, pct=False):
|
|
|
212
231
|
else:
|
|
213
232
|
continue
|
|
214
233
|
|
|
215
|
-
|
|
216
|
-
|
|
234
|
+
# TODO(3.3.0): key by the name as typed and drop
|
|
235
|
+
# display_labels (see monte_carlo). 3.2.0 keys until then.
|
|
236
|
+
key = _legacy_label(name)
|
|
237
|
+
components[key] = float(val)
|
|
238
|
+
display_labels[key] = _make_label(name)
|
|
217
239
|
|
|
218
240
|
components_list.append(components)
|
|
219
241
|
xlabels.append(plant.name)
|
|
220
242
|
|
|
221
243
|
return _build_bar_data(components_list, xlabels,
|
|
222
|
-
"Annual variable OPEX", currency, pct
|
|
244
|
+
"Annual variable OPEX", currency, pct,
|
|
245
|
+
display_labels=display_labels)
|
|
223
246
|
|
|
224
247
|
|
|
225
248
|
def fixed_opex_data(plants, pct=False):
|
|
@@ -487,6 +510,20 @@ def _sensitivity_param_keys(plant, metric):
|
|
|
487
510
|
return price_keys, quantity_keys
|
|
488
511
|
|
|
489
512
|
|
|
513
|
+
def _sensitivity_x_value(plant, parameter, value):
|
|
514
|
+
"""
|
|
515
|
+
A sensitivity point's parameter value in its own units: the resulting
|
|
516
|
+
fixed capital / fixed OPEX for the fc / fp multipliers (computed, so
|
|
517
|
+
fixed_capital_components overrides are honoured), the value as set
|
|
518
|
+
for everything else.
|
|
519
|
+
"""
|
|
520
|
+
if parameter == "fixed_capital":
|
|
521
|
+
return float(deepcopy(plant).calculate_fixed_capital(fc=value))
|
|
522
|
+
if parameter == "fixed_opex":
|
|
523
|
+
return float(deepcopy(plant).calculate_fixed_opex(fp=value))
|
|
524
|
+
return float(value)
|
|
525
|
+
|
|
526
|
+
|
|
490
527
|
def sensitivity_data(plants,
|
|
491
528
|
parameter,
|
|
492
529
|
plus_minus_value,
|
|
@@ -547,12 +584,20 @@ def sensitivity_data(plants,
|
|
|
547
584
|
Plant name or identifier
|
|
548
585
|
- "x" : ndarray
|
|
549
586
|
Percentage changes along the variation range
|
|
587
|
+
- "x_value" : ndarray or None
|
|
588
|
+
The parameter's value at each point, in its own units
|
|
589
|
+
(for "fixed_capital" / "fixed_opex": the resulting fixed
|
|
590
|
+
capital / annual fixed OPEX); None if the plant lacks the
|
|
591
|
+
parameter
|
|
550
592
|
- "y" : ndarray or list
|
|
551
593
|
Metric values corresponding to each point
|
|
552
594
|
- "baseline" : float
|
|
553
595
|
Metric value at the baseline (0% variation)
|
|
554
596
|
- "xlabel" : str
|
|
555
597
|
Label for the x-axis (parameter name with % unit)
|
|
598
|
+
- "xlabel_value" : str
|
|
599
|
+
Label for the x-axis in the parameter's own units, used by
|
|
600
|
+
``plot_sensitivity(..., x_axis="value")``
|
|
556
601
|
- "ylabel" : str
|
|
557
602
|
Label for the y-axis (metric name and unit)
|
|
558
603
|
- "parameter" : str
|
|
@@ -673,17 +718,37 @@ def sensitivity_data(plants,
|
|
|
673
718
|
|
|
674
719
|
# --- X label ---
|
|
675
720
|
label_clean = _make_label(parameter.split(".")[-1])
|
|
721
|
+
pm_unit = rf" / [$\pm$ {_tex_escape('%')}]"
|
|
676
722
|
if parameter in top_level_keys:
|
|
677
|
-
x_label = label_clean +
|
|
723
|
+
x_label = label_clean + pm_unit
|
|
678
724
|
elif parameter in quantity_keys_all:
|
|
679
725
|
# "variable_opex_inputs.steam.consumption" ->
|
|
680
726
|
# "Steam consumption / [+- %]"
|
|
681
727
|
item, field = parameter.split(".")[1:]
|
|
682
728
|
x_label = (
|
|
683
|
-
f"{_make_label(item)} {field}" +
|
|
729
|
+
f"{_make_label(item)} {field}" + pm_unit
|
|
730
|
+
)
|
|
731
|
+
else:
|
|
732
|
+
x_label = label_clean + " price" + pm_unit
|
|
733
|
+
|
|
734
|
+
# --- X label in the parameter's own units (x_axis="value") ---
|
|
735
|
+
currency = plants[0].currency if plants else _tex_escape("$")
|
|
736
|
+
if parameter in top_level_keys:
|
|
737
|
+
value_unit = {
|
|
738
|
+
"fixed_capital": currency,
|
|
739
|
+
"fixed_opex": rf"{currency}$\cdot$yr$^{{-1}}$",
|
|
740
|
+
"project_lifetime": "years",
|
|
741
|
+
"operator_hourly_rate": rf"{currency}$\cdot$h$^{{-1}}$",
|
|
742
|
+
}.get(parameter, "-") # fractions as stored
|
|
743
|
+
x_label_value = f"{label_clean} / [{value_unit}]"
|
|
744
|
+
elif parameter in quantity_keys_all:
|
|
745
|
+
x_label_value = (
|
|
746
|
+
f"{_make_label(item)} {field}" + r" / [unit$\cdot$day$^{-1}$]"
|
|
684
747
|
)
|
|
685
748
|
else:
|
|
686
|
-
|
|
749
|
+
x_label_value = (
|
|
750
|
+
f"{label_clean} price / [{currency}" + r"$\cdot$unit$^{-1}$]"
|
|
751
|
+
)
|
|
687
752
|
|
|
688
753
|
# --- Core computation ---
|
|
689
754
|
results = []
|
|
@@ -704,6 +769,7 @@ def sensitivity_data(plants,
|
|
|
704
769
|
metric_values = np.full_like(
|
|
705
770
|
pct_axis, fill_value=base_value, dtype=float
|
|
706
771
|
)
|
|
772
|
+
x_values = None
|
|
707
773
|
else:
|
|
708
774
|
# fixed_capital/fixed_opex perturb the plant's actual
|
|
709
775
|
# configured multiplier, not an assumed 1.0
|
|
@@ -720,11 +786,16 @@ def sensitivity_data(plants,
|
|
|
720
786
|
)
|
|
721
787
|
for v in param_values
|
|
722
788
|
]
|
|
789
|
+
x_values = np.array([
|
|
790
|
+
_sensitivity_x_value(plant, parameter, v)
|
|
791
|
+
for v in param_values
|
|
792
|
+
])
|
|
723
793
|
|
|
724
794
|
results.append(
|
|
725
795
|
{
|
|
726
796
|
"plant": getattr(plant, "name", f"Plant {i+1}"),
|
|
727
797
|
"x": pct_axis,
|
|
798
|
+
"x_value": x_values,
|
|
728
799
|
"y": metric_values,
|
|
729
800
|
"baseline": base_value,
|
|
730
801
|
}
|
|
@@ -733,6 +804,7 @@ def sensitivity_data(plants,
|
|
|
733
804
|
return {
|
|
734
805
|
"curves": results,
|
|
735
806
|
"xlabel": x_label,
|
|
807
|
+
"xlabel_value": x_label_value,
|
|
736
808
|
"ylabel": label,
|
|
737
809
|
"parameter": parameter,
|
|
738
810
|
"metric": metric,
|
|
@@ -744,7 +816,8 @@ def tornado_data(plant,
|
|
|
744
816
|
metric="LCOP",
|
|
745
817
|
label=None,
|
|
746
818
|
additional_capex: bool = False,
|
|
747
|
-
|
|
819
|
+
category: str | None = None,
|
|
820
|
+
include_process_params: bool | None = None):
|
|
748
821
|
"""
|
|
749
822
|
Generate tornado plot data for sensitivity analysis (no plotting).
|
|
750
823
|
This function performs a sensitivity analysis on a plant model by varying
|
|
@@ -768,19 +841,23 @@ def tornado_data(plant,
|
|
|
768
841
|
additional_capex : bool, optional
|
|
769
842
|
Whether to include additional capital expenditure in calculations.
|
|
770
843
|
Default is False.
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
844
|
+
category : {"economic", "process", "both"}, optional
|
|
845
|
+
Which parameters to rank. ``"economic"`` (default): prices and
|
|
846
|
+
economic scalars (fixed capital/OPEX, project lifetime, interest
|
|
847
|
+
rate, operator hourly rate). ``"process"``: the plant's process
|
|
848
|
+
quantities -- every ``variable_opex_inputs`` item's consumption and
|
|
849
|
+
every ``plant_products`` entry's production. ``"both"``: all of
|
|
850
|
+
them.
|
|
777
851
|
|
|
778
852
|
This is independent of the dependency graph: process quantities are
|
|
779
853
|
ordinary economic drivers (a plant's production rate moves LCOP
|
|
780
854
|
whether or not anything is tied to it), so configuring a dependency
|
|
781
|
-
does not switch them on, and
|
|
782
|
-
|
|
783
|
-
|
|
855
|
+
does not switch them on, and ranking them does not require one. A
|
|
856
|
+
parameter that is *set by* a dependency is excluded in every
|
|
857
|
+
category -- see Notes.
|
|
858
|
+
include_process_params : bool, optional
|
|
859
|
+
Deprecated: use ``category``. ``True`` is ``category="both"``,
|
|
860
|
+
``False`` is ``category="economic"``.
|
|
784
861
|
dict
|
|
785
862
|
Dictionary containing tornado plot data with keys:
|
|
786
863
|
- factors : list[str]
|
|
@@ -814,11 +891,10 @@ def tornado_data(plant,
|
|
|
814
891
|
- A parameter that is itself set by a dependency is never a factor --
|
|
815
892
|
it has no value of its own to vary. This drops it from the top-level
|
|
816
893
|
keys (e.g. ``"fixed_capital"`` when ``fixed_capital_factor`` is a
|
|
817
|
-
dependent) and from
|
|
818
|
-
otherwise add.
|
|
894
|
+
dependent) and from the process quantities.
|
|
819
895
|
|
|
820
896
|
Dependencies do not, however, change *which kinds* of parameter are
|
|
821
|
-
ranked: that is ``
|
|
897
|
+
ranked: that is ``category`` alone. See
|
|
822
898
|
:func:`~openpytea.helpers._collect_sensitivity_keys`.
|
|
823
899
|
Examples
|
|
824
900
|
--------
|
|
@@ -827,13 +903,37 @@ def tornado_data(plant,
|
|
|
827
903
|
>>> lows = tornado_data["lows"]
|
|
828
904
|
>>> highs = tornado_data["highs"]
|
|
829
905
|
"""
|
|
906
|
+
if include_process_params is not None:
|
|
907
|
+
if category is not None:
|
|
908
|
+
raise ValueError(
|
|
909
|
+
"Pass either category or the deprecated "
|
|
910
|
+
"include_process_params, not both."
|
|
911
|
+
)
|
|
912
|
+
warnings.warn(
|
|
913
|
+
"include_process_params is deprecated; use "
|
|
914
|
+
"category='both' (for True) or category='economic' (for False).",
|
|
915
|
+
FutureWarning,
|
|
916
|
+
stacklevel=2,
|
|
917
|
+
)
|
|
918
|
+
category = "both" if include_process_params else "economic"
|
|
919
|
+
if category is None:
|
|
920
|
+
category = "economic"
|
|
921
|
+
if category not in ("economic", "process", "both"):
|
|
922
|
+
raise ValueError(
|
|
923
|
+
f"Invalid category {category!r}; must be 'economic', "
|
|
924
|
+
"'process', or 'both'."
|
|
925
|
+
)
|
|
926
|
+
|
|
830
927
|
metric = metric.upper()
|
|
831
928
|
if label is None:
|
|
832
929
|
label = _default_metric_label(plant.currency, metric)
|
|
833
930
|
|
|
834
|
-
keys = _collect_sensitivity_keys(
|
|
835
|
-
|
|
836
|
-
|
|
931
|
+
keys = _collect_sensitivity_keys(plant, metric, category=category)
|
|
932
|
+
if not keys:
|
|
933
|
+
raise ValueError(
|
|
934
|
+
f"Plant '{plant.name}' has no {category} parameters to rank "
|
|
935
|
+
"(parameters set by a dependency cannot be varied)."
|
|
936
|
+
)
|
|
837
937
|
|
|
838
938
|
base_value = _evaluate_baseline_metric(plant, metric, additional_capex)
|
|
839
939
|
|
|
@@ -1655,7 +1755,7 @@ def monte_carlo(plant,
|
|
|
1655
1755
|
("fixed_opex_factor", _resolve_dist_params(
|
|
1656
1756
|
cfg("fixed_opex_factor"), **factor_window), False),
|
|
1657
1757
|
("operator_hourly_rate", _resolve_item_dist_params(
|
|
1658
|
-
op_cfg, "rate",
|
|
1758
|
+
op_cfg, "rate", DEFAULT_OPERATOR_HOURLY_RATE, 10), False),
|
|
1659
1759
|
("project_lifetime", _window_dist_params(
|
|
1660
1760
|
cfg("project_lifetime"), plant.project_lifetime, 5, floor=5),
|
|
1661
1761
|
False),
|
|
@@ -1767,24 +1867,20 @@ def monte_carlo(plant,
|
|
|
1767
1867
|
)
|
|
1768
1868
|
|
|
1769
1869
|
# ---- Economic calculations ----
|
|
1870
|
+
# The fc/fp calls set the sampled factors; one cash-flow build
|
|
1871
|
+
# then serves every metric below
|
|
1770
1872
|
plant_copy.calculate_fixed_capital(fc=fixed_capitals[start:end])
|
|
1771
|
-
plant_copy.calculate_variable_opex()
|
|
1772
1873
|
plant_copy.calculate_fixed_opex(fp=fixed_opexs[start:end])
|
|
1773
1874
|
plant_copy.calculate_cash_flow()
|
|
1774
|
-
plant_copy.calculate_levelized_cost()
|
|
1775
1875
|
|
|
1776
1876
|
# ---- Store LCOP always ----
|
|
1777
|
-
mc_metrics["LCOP"][start:end] = plant_copy.
|
|
1877
|
+
mc_metrics["LCOP"][start:end] = plant_copy._levelized_cost()
|
|
1778
1878
|
|
|
1779
1879
|
# ---- If revenue available, compute all other metrics ----
|
|
1780
1880
|
if have_product_prices:
|
|
1781
|
-
mc_metrics["NPV"][start:end] = plant_copy.
|
|
1782
|
-
mc_metrics["ROI"][start:end] = plant_copy.
|
|
1783
|
-
|
|
1784
|
-
)
|
|
1785
|
-
mc_metrics["PBT"][start:end] = (
|
|
1786
|
-
plant_copy.calculate_payback_time()
|
|
1787
|
-
)
|
|
1881
|
+
mc_metrics["NPV"][start:end] = plant_copy._npv()
|
|
1882
|
+
mc_metrics["ROI"][start:end] = plant_copy._roi(additional_capex)
|
|
1883
|
+
mc_metrics["PBT"][start:end] = plant_copy._payback_time()
|
|
1788
1884
|
|
|
1789
1885
|
mc_inputs = {
|
|
1790
1886
|
"Fixed capital factor": fixed_capitals,
|
|
@@ -1796,23 +1892,23 @@ def monte_carlo(plant,
|
|
|
1796
1892
|
else {"Plant utilization": plant_utilizations}),
|
|
1797
1893
|
**({} if tax_rates is None
|
|
1798
1894
|
else {"Tax rate": tax_rates}),
|
|
1799
|
-
**{
|
|
1800
|
-
f"{k.replace('_', ' ').title()} price": v
|
|
1801
|
-
for k, v in variable_opex_price_samples.items()
|
|
1802
|
-
},
|
|
1803
|
-
**{
|
|
1804
|
-
f"{k.replace('_', ' ').title()} consumption": v
|
|
1805
|
-
for k, v in variable_opex_consumption_samples.items()
|
|
1806
|
-
},
|
|
1807
|
-
**{
|
|
1808
|
-
f"{k.replace('_', ' ').title()} product price": v
|
|
1809
|
-
for k, v in product_price_samples.items()
|
|
1810
|
-
},
|
|
1811
|
-
**{
|
|
1812
|
-
f"{k.replace('_', ' ').title()} production": v
|
|
1813
|
-
for k, v in product_production_samples.items()
|
|
1814
|
-
},
|
|
1815
1895
|
}
|
|
1896
|
+
# Fixed inputs are shown as named; item inputs under _make_label(name)
|
|
1897
|
+
display_labels = {key: key for key in mc_inputs}
|
|
1898
|
+
# TODO(3.3.0): key the items by their names as typed ("cooling_water
|
|
1899
|
+
# consumption") and drop display_labels; plots then label from the
|
|
1900
|
+
# key. Kept on the 3.2.0 title-case keys until then so 3.2.x stays
|
|
1901
|
+
# compatible.
|
|
1902
|
+
for samples, suffix in (
|
|
1903
|
+
(variable_opex_price_samples, "price"),
|
|
1904
|
+
(variable_opex_consumption_samples, "consumption"),
|
|
1905
|
+
(product_price_samples, "product price"),
|
|
1906
|
+
(product_production_samples, "production"),
|
|
1907
|
+
):
|
|
1908
|
+
for k, v in samples.items():
|
|
1909
|
+
key = f"{k.replace('_', ' ').title()} {suffix}"
|
|
1910
|
+
mc_inputs[key] = v
|
|
1911
|
+
display_labels[key] = f"{_make_label(k)} {suffix}"
|
|
1816
1912
|
|
|
1817
1913
|
# ---- Store on plant ----
|
|
1818
1914
|
plant.monte_carlo_metrics = mc_metrics
|
|
@@ -1822,6 +1918,7 @@ def monte_carlo(plant,
|
|
|
1822
1918
|
"name": plant.name,
|
|
1823
1919
|
"metrics": mc_metrics,
|
|
1824
1920
|
"inputs": mc_inputs,
|
|
1921
|
+
"display_labels": display_labels,
|
|
1825
1922
|
"num_samples": num_samples,
|
|
1826
1923
|
"additional_capex": additional_capex,
|
|
1827
1924
|
"currency": currency,
|