OpenPyTEA 3.2.1__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.1/src/OpenPyTEA.egg-info → openpytea-3.2.2}/PKG-INFO +12 -8
- {openpytea-3.2.1 → openpytea-3.2.2}/README.md +11 -7
- {openpytea-3.2.1 → openpytea-3.2.2}/pyproject.toml +1 -1
- {openpytea-3.2.1 → openpytea-3.2.2/src/OpenPyTEA.egg-info}/PKG-INFO +12 -8
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/analysis.py +18 -4
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/data/cost_correlations.csv +4 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/equipment.py +11 -3
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/helpers.py +8 -2
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/plotting.py +19 -14
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_composite_equipment.py +13 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_plotting.py +28 -3
- {openpytea-3.2.1 → openpytea-3.2.2}/LICENSE +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/setup.cfg +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/SOURCES.txt +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/dependency_links.txt +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/entry_points.txt +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/requires.txt +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/OpenPyTEA.egg-info/top_level.txt +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/__init__.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/cli.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/data/cepci_values.csv +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/io.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/src/openpytea/plant.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_analysis.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_cli.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_equipment.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_plant.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_run_tea.py +0 -0
- {openpytea-3.2.1 → openpytea-3.2.2}/tests/test_smoke.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
@@ -158,16 +158,20 @@ Software architecture and data flow of **OpenPyTEA**, illustrating the progressi
|
|
|
158
158
|
---
|
|
159
159
|
## 🖥️ Graphical User Interface
|
|
160
160
|
|
|
161
|
-
|
|
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.
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
**Download** the installer for your platform from the **[OpenPyTEA 3.2.2 release](https://github.com/pbtamarona/OpenPyTEA/releases/tag/v3.2.2)**:
|
|
164
164
|
|
|
165
|
-
|
|
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` |
|
|
166
169
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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).
|
|
171
175
|
|
|
172
176
|
---
|
|
173
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"
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
@@ -158,16 +158,20 @@ Software architecture and data flow of **OpenPyTEA**, illustrating the progressi
|
|
|
158
158
|
---
|
|
159
159
|
## 🖥️ Graphical User Interface
|
|
160
160
|
|
|
161
|
-
|
|
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.
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
**Download** the installer for your platform from the **[OpenPyTEA 3.2.2 release](https://github.com/pbtamarona/OpenPyTEA/releases/tag/v3.2.2)**:
|
|
164
164
|
|
|
165
|
-
|
|
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` |
|
|
166
169
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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).
|
|
171
175
|
|
|
172
176
|
---
|
|
173
177
|
## 🧠 Core Concepts
|
|
@@ -30,7 +30,8 @@ from openpytea.helpers import (_make_label,
|
|
|
30
30
|
# DATA PREPARATION (MAIN API)
|
|
31
31
|
# ======================================================
|
|
32
32
|
|
|
33
|
-
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):
|
|
34
35
|
"""
|
|
35
36
|
Extract and organize direct cost data from one or more plants.
|
|
36
37
|
This function aggregates direct cost information from equipment lists
|
|
@@ -49,6 +50,12 @@ def direct_costs_data(plants, pct=False, expand_composites=False):
|
|
|
49
50
|
into its leaf components (labelled ``"Composite / component"``) using
|
|
50
51
|
:meth:`~openpytea.equipment.CompositeEquipment.direct_cost_breakdown`
|
|
51
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.
|
|
52
59
|
Returns
|
|
53
60
|
-------
|
|
54
61
|
dict
|
|
@@ -69,6 +76,7 @@ def direct_costs_data(plants, pct=False, expand_composites=False):
|
|
|
69
76
|
>>> plant1 = Plant(name="Plant A", currency="$")
|
|
70
77
|
>>> data = direct_costs_data(plant1)
|
|
71
78
|
>>> data = direct_costs_data([plant1, plant2], pct=True)
|
|
79
|
+
>>> data = direct_costs_data(plant1, by_category=True)
|
|
72
80
|
"""
|
|
73
81
|
# ponytail: all five *_data functions repeat this wrapper; one _bar_data(plants,
|
|
74
82
|
# per_plant_fn, ylabel, pct)
|
|
@@ -84,10 +92,16 @@ def direct_costs_data(plants, pct=False, expand_composites=False):
|
|
|
84
92
|
components = {}
|
|
85
93
|
for eq in plant.equipment_list:
|
|
86
94
|
if expand_composites and hasattr(eq, "direct_cost_breakdown"):
|
|
87
|
-
|
|
88
|
-
|
|
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())]
|
|
89
99
|
else:
|
|
90
|
-
|
|
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)
|
|
91
105
|
components_list.append(components)
|
|
92
106
|
xlabels.append(plant.name)
|
|
93
107
|
|
|
@@ -419,3 +419,7 @@ wastewater_primary_secondary_tertiary_seider_2013,Utilities,"Wastewater treatmen
|
|
|
419
419
|
water_ion_exchange_plant_towler_2010,Utilities,Water ion exchange plant,"flow, m^3/h",1,50,,,14000,6200,0.75,,,,,,,,,,offset power-law,2010,Carbon steel,Towler & Sinnott (2010) Table 7.2,,Purchased cost.,doi.org/10.1016/B978-0-12-821179-3.00007-8,
|
|
420
420
|
internal_coils_vaporizers_turton_2001,Vaporizers,Internal coils/jackets,"volume, m^3",1,100,,,,,,,,,,4,0.4321,0.17,,,log-log quadratic,2001,Carbon steel,Turton et al. (2018) Table A.1,,"Purchased cost, ambient pressure",https://richardturton.faculty.wvu.edu/publications/analysis-synthesis-and-design-of-chemical-processes-5th-edition,
|
|
421
421
|
jacketed_vessels_vaporizers_turton_2001,Vaporizers,Jacketed vessels,"volume, m^3",1,100,,,,,,,,,,3.8751,0.3328,0.1901,,,log-log quadratic,2001,Carbon steel,Turton et al. (2018) Table A.1,,"Purchased cost, ambient pressure",https://richardturton.faculty.wvu.edu/publications/analysis-synthesis-and-design-of-chemical-processes-5th-edition,
|
|
422
|
+
electrolyzer_pem_current_doe_2016,Electrolysis,"PEM electrolyzer, current (2019)","hydrogen production, kg/day",1500,50000,,,,,,,1500,2132440,0.9255,,,,,,power-sizing,2016,n.a.,"Peterson, Vickers & DeSantis (2019) Table 2","CE Index = 542 (rounded); precise 2016 annual average = 541.7. Costs in USD 2016; total uninstalled capital; 599 USD/kW at 1,500 and 460 at 50,000 kg H2/day (current); unit cost per kW converted using the study's MW rating (3.56 MW at 1,500 kg/day, 119 MW at 50,000 kg/day); two-point fit.",Purchased cost.,https://www.hydrogen.energy.gov/docs/hydrogenprogramlibraries/pdfs/19009_h2_production_cost_pem_electrolysis_2019.pdf,
|
|
423
|
+
electrolyzer_pem_future_doe_2016,Electrolysis,"PEM electrolyzer, future (2035)","hydrogen production, kg/day",1500,50000,,,,,,,1500,1337870,0.8621,,,,,,power-sizing,2016,n.a.,"Peterson, Vickers & DeSantis (2019) Table 2","CE Index = 542 (rounded); precise 2016 annual average = 541.7. Costs in USD 2016; total uninstalled capital; 379 USD/kW at 1,500 and 233 at 50,000 kg H2/day (future 2035); unit cost per kW converted using the study's MW rating (3.53 MW at 1,500 kg/day, 118 MW at 50,000 kg/day); two-point fit.",Purchased cost.,https://www.hydrogen.energy.gov/docs/hydrogenprogramlibraries/pdfs/19009_h2_production_cost_pem_electrolysis_2019.pdf,
|
|
424
|
+
biomass_cfb_chp_irena_2012,Biomass combustion,CFB CHP,"electrical capacity, MWe",0.5,8.8,,,,,,,0.5,7395000,0.544,,,,,,power-sizing,2010,n.a.,"IRENA (2012) Section 5.2, p. 32","CE Index = 551 (rounded); precise 2010 annual average = 550.8. Costs in USD 2010; specific cost 14,790 USD/kW at 0.5 MWe, 4,000 at 8.8 MWe; unit cost per kW converted using the study's MW rating; two-point fit.",Purchased cost.,https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2012/RE_Technologies_Cost_Analysis-BIOMASS.pdf,
|
|
425
|
+
electrolyzer_nrel_2008,Electrolysis,Electrolyzer (PEM / alkaline),"hydrogen production, kg/h",0.1,100,,,0,224490,0.6156,,,,,,,,,,offset power-law,2008,n.a.,"Saur (2008) Section 5.1, Eq. 1",CE Index = 575 (rounded); precise 2008 annual average = 575.4. Costs in USD 2008 (H2A basis).,Purchased cost.,https://doi.org/10.2172/944892,
|
|
@@ -371,7 +371,7 @@ class Equipment:
|
|
|
371
371
|
Values are dicts with factors: fer, fp, fi, fel, fc, fs, fl.
|
|
372
372
|
material_factors : dict
|
|
373
373
|
Material type multipliers mapping material names to cost factors
|
|
374
|
-
(1.0 to
|
|
374
|
+
(1.0 to 2.5).
|
|
375
375
|
|
|
376
376
|
Parameters
|
|
377
377
|
----------
|
|
@@ -510,11 +510,19 @@ class Equipment:
|
|
|
510
510
|
"Stainless steel": 1.3,
|
|
511
511
|
"304 stainless steel": 1.3,
|
|
512
512
|
"316 stainless steel": 1.3,
|
|
513
|
+
"316 stainless steel (machined)": 1.3,
|
|
514
|
+
"Glass-reinforced plastic": 1.4,
|
|
513
515
|
"321 stainless steel": 1.5,
|
|
514
516
|
"Hastelloy C": 1.55,
|
|
515
517
|
"Monel": 1.65,
|
|
516
518
|
"Nickel": 1.7,
|
|
517
519
|
"Inconel": 1.7,
|
|
520
|
+
"316 stainless steel (welded)": 1.75,
|
|
521
|
+
# EDF (Aromada et al. 2021) doesn't define "exotic
|
|
522
|
+
# material", so titanium or zirconium aren't
|
|
523
|
+
# mapped to it
|
|
524
|
+
"Exotic material (machined)": 1.75,
|
|
525
|
+
"Exotic material (welded)": 2.5,
|
|
518
526
|
}
|
|
519
527
|
|
|
520
528
|
def __init__(
|
|
@@ -774,7 +782,7 @@ class Equipment:
|
|
|
774
782
|
f"Material={self.material}, Process Type={self.process_type}, "
|
|
775
783
|
f"Parameter={self.param}, Number of units={self.num_units}, "
|
|
776
784
|
f"Purchased Cost={self.purchased_cost:.3f}, "
|
|
777
|
-
f"Direct Cost={self.direct_cost:.3f}
|
|
785
|
+
f"Direct Cost={self.direct_cost:.3f}"
|
|
778
786
|
)
|
|
779
787
|
|
|
780
788
|
|
|
@@ -1148,7 +1156,7 @@ class CompositeEquipment:
|
|
|
1148
1156
|
f"Installation={self.installation}, "
|
|
1149
1157
|
f"Number of units={self.num_units}, "
|
|
1150
1158
|
f"Purchased Cost={self.purchased_cost:.3f}, "
|
|
1151
|
-
f"Direct Cost={self.direct_cost:.3f}
|
|
1159
|
+
f"Direct Cost={self.direct_cost:.3f}"
|
|
1152
1160
|
)
|
|
1153
1161
|
body = "\n".join(
|
|
1154
1162
|
f" - {obj.name} (x{obj.num_units}): "
|
|
@@ -39,7 +39,8 @@ def _format_scripts(s, underscore=None) -> str:
|
|
|
39
39
|
``T_{in}``); ``^`` followed by digits, a sign or ``{...}`` becomes a
|
|
40
40
|
superscript (``m^3``, ``s^-1``, ``Fe^{3+}``). Any other underscore is
|
|
41
41
|
replaced by ``underscore``: by default an underscore, escaped for LaTeX
|
|
42
|
-
only when ``text.usetex`` is active (see :func:`_tex_escape`)
|
|
42
|
+
only when ``text.usetex`` is active (see :func:`_tex_escape`), and so is
|
|
43
|
+
an ampersand (``&`` or ``\\&``). Math
|
|
43
44
|
segments (``$...$``) are left as they are, so applying this twice
|
|
44
45
|
changes nothing.
|
|
45
46
|
|
|
@@ -59,10 +60,15 @@ def _format_scripts(s, underscore=None) -> str:
|
|
|
59
60
|
body = (m[1] or m[2]).strip("{}")
|
|
60
61
|
return f"${'_' if m[1] else '^'}{{\\mathrm{{{body}}}}}$"
|
|
61
62
|
|
|
63
|
+
# An ampersand, bare (user names, categories) or escaped (built-in
|
|
64
|
+
# labels), is escaped only for a real LaTeX run
|
|
65
|
+
amp = _tex_escape("&")
|
|
66
|
+
|
|
62
67
|
# Keep math segments; an escaped \$ (a currency sign) delimits nothing
|
|
63
68
|
parts = re.split(r"((?<!\\)\$.*?(?<!\\)\$)", str(s))
|
|
64
69
|
s = "".join(
|
|
65
|
-
p if i % 2 else
|
|
70
|
+
p if i % 2 else re.sub(r"\\?&", lambda _: amp, _SCRIPT_RE.sub(script, p))
|
|
71
|
+
for i, p in enumerate(parts)
|
|
66
72
|
)
|
|
67
73
|
# Join neighbouring scripts (x_1^2) into one math segment
|
|
68
74
|
return re.sub(r"\}\$\$(?=[_^]\{)", "}", s)
|
|
@@ -308,8 +308,9 @@ def plot_sensitivity(data, figsize=(3.2, 2.2), ax=None, show=True,
|
|
|
308
308
|
is asked of data without actual values.
|
|
309
309
|
Notes
|
|
310
310
|
-----
|
|
311
|
-
- With ``x_axis="value"``, a plant that lacks the parameter
|
|
312
|
-
|
|
311
|
+
- With ``x_axis="value"``, a plant that lacks the parameter shows as a
|
|
312
|
+
flat line at its baseline across the other plants' values, as it
|
|
313
|
+
does on the % axis.
|
|
313
314
|
- Multiple curves are plotted with colors from the Set2 colormap.
|
|
314
315
|
- If a new figure is created, tight_layout() is applied before showing.
|
|
315
316
|
- If an existing axes is provided, canvas is redrawn instead of calling
|
|
@@ -332,19 +333,23 @@ def plot_sensitivity(data, figsize=(3.2, 2.2), ax=None, show=True,
|
|
|
332
333
|
|
|
333
334
|
line_colors = cycle(plt.cm.Set2.colors)
|
|
334
335
|
|
|
336
|
+
# A plant lacking the parameter has no values of its own; on the value
|
|
337
|
+
# axis it spans the other plants' values at its baseline, as on the % axis
|
|
338
|
+
# (sensitivity_data rejects a parameter no plant has, so spans is never
|
|
339
|
+
# empty)
|
|
340
|
+
spans = [c["x_value"] for c in data["curves"] if c["x_value"] is not None]
|
|
341
|
+
if by_value:
|
|
342
|
+
x_span = [min(np.min(s) for s in spans),
|
|
343
|
+
max(np.max(s) for s in spans)]
|
|
344
|
+
|
|
335
345
|
for curve in data["curves"]:
|
|
336
346
|
color = next(line_colors) # same color per plant in either mode
|
|
337
|
-
if by_value
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
"so it has no values to plot on the value axis; "
|
|
341
|
-
"leaving it out.",
|
|
342
|
-
stacklevel=2,
|
|
343
|
-
)
|
|
344
|
-
continue
|
|
347
|
+
x, y = (curve["x_value"] if by_value else curve["x"]), curve["y"]
|
|
348
|
+
if by_value and x is None:
|
|
349
|
+
x, y = x_span, [curve["baseline"]] * 2
|
|
345
350
|
ax.plot(
|
|
346
|
-
|
|
347
|
-
|
|
351
|
+
x,
|
|
352
|
+
y,
|
|
348
353
|
linewidth=1.2,
|
|
349
354
|
color=color,
|
|
350
355
|
label=_format_scripts(curve["plant"]),
|
|
@@ -930,13 +935,13 @@ def _plot_input_histogram_grid(inputs, figsize, bins, hist_color, title,
|
|
|
930
935
|
)
|
|
931
936
|
ax.set_title(
|
|
932
937
|
_format_scripts((display_labels or {}).get(label, label)),
|
|
933
|
-
fontsize=
|
|
938
|
+
fontsize=14,
|
|
934
939
|
)
|
|
935
940
|
|
|
936
941
|
for i in range(n_params, len(axes)):
|
|
937
942
|
axes[i].axis("off")
|
|
938
943
|
|
|
939
|
-
fig.suptitle(_format_scripts(title), fontsize=
|
|
944
|
+
fig.suptitle(_format_scripts(title), fontsize=16, fontweight="bold")
|
|
940
945
|
# Reserve a top margin sized to fit the suptitle in absolute
|
|
941
946
|
# inches rather than a fixed fraction of figure height -- a flat
|
|
942
947
|
# fraction leaves a disproportionately large gap on tall,
|
|
@@ -219,6 +219,19 @@ def test_composite_in_plant_and_direct_costs_data(psa):
|
|
|
219
219
|
assert set(expanded) == {"PSA / Vessel", "PSA / Adsorbent", "Pump"}
|
|
220
220
|
assert sum(expanded.values()) == pytest.approx(sum(lumped.values()))
|
|
221
221
|
|
|
222
|
+
# By category: the composite under its own category, or split over its
|
|
223
|
+
# components' categories
|
|
224
|
+
by_cat = direct_costs_data(plant, by_category=True)["components"][0]
|
|
225
|
+
assert by_cat == pytest.approx({"Adsorption": lumped["PSA"],
|
|
226
|
+
"Pumps": lumped["Pump"]})
|
|
227
|
+
split = direct_costs_data(plant, expand_composites=True,
|
|
228
|
+
by_category=True)["components"][0]
|
|
229
|
+
assert split == pytest.approx({
|
|
230
|
+
"Pressure vessels": expanded["PSA / Vessel"],
|
|
231
|
+
"Packings & adsorbents": expanded["PSA / Adsorbent"],
|
|
232
|
+
"Pumps": expanded["Pump"],
|
|
233
|
+
})
|
|
234
|
+
|
|
222
235
|
|
|
223
236
|
def test_json_builds_nested_composite(psa):
|
|
224
237
|
from openpytea.io import _build_equipment_list
|
|
@@ -140,6 +140,28 @@ def test_tornado_legend_has_no_literal_backslash(test_plant):
|
|
|
140
140
|
plt.close(fig)
|
|
141
141
|
|
|
142
142
|
|
|
143
|
+
def test_ampersand_labels_follow_usetex(test_plant):
|
|
144
|
+
r"""Bare & (names, categories) and built-in \& labels: \& for LaTeX, & otherwise."""
|
|
145
|
+
from openpytea import fixed_opex_data
|
|
146
|
+
from openpytea.helpers import _format_scripts
|
|
147
|
+
|
|
148
|
+
old = plt.rcParams["text.usetex"]
|
|
149
|
+
try:
|
|
150
|
+
plt.rcParams["text.usetex"] = True
|
|
151
|
+
assert _format_scripts("Packings & adsorbents") == r"Packings \& adsorbents"
|
|
152
|
+
assert _format_scripts(r"R\&D") == r"R\&D"
|
|
153
|
+
plt.rcParams["text.usetex"] = False
|
|
154
|
+
assert _format_scripts(r"R\&D") == "R&D"
|
|
155
|
+
finally:
|
|
156
|
+
plt.rcParams["text.usetex"] = old
|
|
157
|
+
|
|
158
|
+
fig, ax = plot_stacked_bar(fixed_opex_data(test_plant), show=False)
|
|
159
|
+
labels = [t.get_text() for t in ax.get_legend().get_texts()]
|
|
160
|
+
assert "Taxes & insurance" in labels
|
|
161
|
+
assert not any("\\" in lab for lab in labels)
|
|
162
|
+
plt.close(fig)
|
|
163
|
+
|
|
164
|
+
|
|
143
165
|
def test_plot_cash_flow_accepts_round_tripped_results(test_plant):
|
|
144
166
|
"""Results reloaded from JSON arrive as lists, not arrays."""
|
|
145
167
|
import json
|
|
@@ -248,9 +270,12 @@ def test_plot_sensitivity_x_axis(test_plant, test_plant_b):
|
|
|
248
270
|
test_plant_b.variable_opex_inputs["steam"] = {"consumption": 1, "price": 1}
|
|
249
271
|
data = sensitivity_data([test_plant, test_plant_b],
|
|
250
272
|
"variable_opex_inputs.steam", 0.2, n_points=3)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
273
|
+
fig, ax = plot_sensitivity(data, show=False, x_axis="value")
|
|
274
|
+
assert len(ax.lines) == 2 # plant lacking steam: flat at its baseline
|
|
275
|
+
lacking = data["curves"][0]
|
|
276
|
+
np.testing.assert_allclose(ax.lines[0].get_xdata(), [0.8, 1.2])
|
|
277
|
+
np.testing.assert_allclose(ax.lines[0].get_ydata(),
|
|
278
|
+
[lacking["baseline"]] * 2)
|
|
254
279
|
plt.close(fig)
|
|
255
280
|
|
|
256
281
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|