processpi 0.0.0__tar.gz → 0.1.2.10__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.
Potentially problematic release.
This version of processpi might be problematic. Click here for more details.
- processpi-0.1.2.10/PKG-INFO +225 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/README.md +55 -49
- processpi-0.1.2.10/processpi/__init__.py +80 -0
- processpi-0.1.2.10/processpi/calculations/__init__.py +65 -0
- processpi-0.1.2.10/processpi/calculations/base.py +101 -0
- processpi-0.1.2.10/processpi/calculations/engine.py +118 -0
- processpi-0.1.2.10/processpi/calculations/fluids/__init__.py +46 -0
- processpi-0.1.2.10/processpi/calculations/fluids/flow_type.py +60 -0
- processpi-0.1.2.10/processpi/calculations/fluids/friction_factor_colebrookwhite.py +84 -0
- processpi-0.1.2.10/processpi/calculations/fluids/optimium_pipe_dia.py +73 -0
- processpi-0.1.2.10/processpi/calculations/fluids/pressure_drop_darcy.py +67 -0
- processpi-0.1.2.10/processpi/calculations/fluids/pressure_drop_fanning.py +66 -0
- processpi-0.1.2.10/processpi/calculations/fluids/pressure_drop_hazen_williams.py +78 -0
- processpi-0.1.2.10/processpi/calculations/fluids/pump_power.py +85 -0
- processpi-0.1.2.10/processpi/calculations/fluids/reynolds_number.py +73 -0
- processpi-0.1.2.10/processpi/calculations/fluids/velocity.py +66 -0
- processpi-0.1.2.10/processpi/components/__init__.py +45 -0
- processpi-0.1.2.10/processpi/components/aceticacid.py +54 -0
- processpi-0.1.2.10/processpi/components/acetone.py +54 -0
- processpi-0.1.2.10/processpi/components/acrylicacid.py +54 -0
- processpi-0.1.2.10/processpi/components/air.py +54 -0
- processpi-0.1.2.10/processpi/components/ammonia.py +54 -0
- processpi-0.1.2.10/processpi/components/base.py +215 -0
- processpi-0.1.2.10/processpi/components/benzene.py +66 -0
- processpi-0.1.2.10/processpi/components/constants.py +11 -0
- processpi-0.1.2.10/processpi/components/gas.py +33 -0
- processpi-0.1.2.10/processpi/components/inorganic_liquid.py +18 -0
- processpi-0.1.2.10/processpi/components/oil.py +18 -0
- processpi-0.1.2.10/processpi/components/organic_liquid.py +18 -0
- processpi-0.1.2.10/processpi/components/steam.py +82 -0
- processpi-0.1.2.10/processpi/components/vapor.py +18 -0
- processpi-0.1.2.10/processpi/pipelines/__init__.py +38 -0
- processpi-0.1.2.10/processpi/pipelines/base.py +91 -0
- processpi-0.1.2.10/processpi/pipelines/design_rules.py +92 -0
- processpi-0.1.2.10/processpi/pipelines/engine.py +1500 -0
- processpi-0.1.2.10/processpi/pipelines/equipment.py +65 -0
- processpi-0.1.2.10/processpi/pipelines/fittings.py +112 -0
- processpi-0.1.2.10/processpi/pipelines/network.py +641 -0
- processpi-0.1.2.10/processpi/pipelines/nozzle.py +17 -0
- processpi-0.1.2.10/processpi/pipelines/pipelineresults.py +216 -0
- processpi-0.1.2.10/processpi/pipelines/pipes.py +161 -0
- processpi-0.1.2.10/processpi/pipelines/piping_costs.py +44 -0
- processpi-0.1.2.10/processpi/pipelines/pumps.py +153 -0
- processpi-0.1.2.10/processpi/pipelines/standards.py +632 -0
- processpi-0.1.2.10/processpi/pipelines/vessel.py +52 -0
- processpi-0.1.2.10/processpi/units/__init__.py +44 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/area.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/base.py +33 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/density.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/diameter.py +9 -4
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/dimensionless.py +17 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/heat_flux.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/heat_of_vaporization.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/heat_transfer_coefficient.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/length.py +6 -1
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/mass.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/mass_flowrate.py +6 -1
- processpi-0.1.2.10/processpi/units/power.py +53 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/pressure.py +10 -13
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/specific_heat.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/temperature.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/thermal_conductivity.py +5 -1
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/thermal_resistance.py +4 -0
- processpi-0.1.2.10/processpi/units/velocity.py +50 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/viscosity.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/volume.py +4 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/volumetric_flowrate.py +15 -0
- processpi-0.1.2.10/processpi.egg-info/PKG-INFO +225 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi.egg-info/SOURCES.txt +14 -1
- processpi-0.1.2.10/processpi.egg-info/requires.txt +5 -0
- processpi-0.1.2.10/pyproject.toml +39 -0
- processpi-0.1.2.10/setup.py +45 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/tests/test_network.py +2 -0
- processpi-0.0.0/PKG-INFO +0 -5
- processpi-0.0.0/processpi/__init__.py +0 -1
- processpi-0.0.0/processpi/calculations/__init__.py +0 -3
- processpi-0.0.0/processpi/calculations/base.py +0 -55
- processpi-0.0.0/processpi/calculations/engine.py +0 -69
- processpi-0.0.0/processpi/calculations/fluids/__init__.py +0 -13
- processpi-0.0.0/processpi/calculations/fluids/cool_brook_white.py +0 -49
- processpi-0.0.0/processpi/calculations/fluids/flow_type.py +0 -37
- processpi-0.0.0/processpi/calculations/fluids/optimium_pipe_dia.py +0 -45
- processpi-0.0.0/processpi/calculations/fluids/pressure_drop_darcy.py +0 -25
- processpi-0.0.0/processpi/calculations/fluids/pressure_drop_fanning.py +0 -25
- processpi-0.0.0/processpi/calculations/fluids/pump_power.py +0 -34
- processpi-0.0.0/processpi/calculations/fluids/reynolds_number.py +0 -24
- processpi-0.0.0/processpi/calculations/fluids/velocity.py +0 -36
- processpi-0.0.0/processpi/components/__init__.py +0 -5
- processpi-0.0.0/processpi/components/aceticacid.py +0 -19
- processpi-0.0.0/processpi/components/acetone.py +0 -20
- processpi-0.0.0/processpi/components/acrylicacid.py +0 -19
- processpi-0.0.0/processpi/components/air.py +0 -20
- processpi-0.0.0/processpi/components/ammonia.py +0 -19
- processpi-0.0.0/processpi/components/base.py +0 -85
- processpi-0.0.0/processpi/components/benzene.py +0 -40
- processpi-0.0.0/processpi/pipelines/__init__.py +0 -0
- processpi-0.0.0/processpi/pipelines/base.py +0 -76
- processpi-0.0.0/processpi/pipelines/design_rules.py +0 -91
- processpi-0.0.0/processpi/pipelines/engine.py +0 -718
- processpi-0.0.0/processpi/pipelines/equipment.py +0 -32
- processpi-0.0.0/processpi/pipelines/fittings.py +0 -76
- processpi-0.0.0/processpi/pipelines/network.py +0 -277
- processpi-0.0.0/processpi/pipelines/pipelineresults.py +0 -95
- processpi-0.0.0/processpi/pipelines/pipes.py +0 -84
- processpi-0.0.0/processpi/pipelines/pumps.py +0 -83
- processpi-0.0.0/processpi/pipelines/standards.py +0 -279
- processpi-0.0.0/processpi/pipelines/vessel.py +0 -34
- processpi-0.0.0/processpi/units/__init__.py +0 -38
- processpi-0.0.0/processpi/units/velocity.py +0 -45
- processpi-0.0.0/processpi.egg-info/PKG-INFO +0 -5
- processpi-0.0.0/pyproject.toml +0 -1
- {processpi-0.0.0 → processpi-0.1.2.10}/LICENSE +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/heat_transfer/__init__.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/heat_transfer/conduction_heat_loss.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/heat_transfer/convection_heat_loss.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/heat_transfer/heat_exchanger_area.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/mass_transfer/__init__.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/mass_transfer/distillation_stage_count.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/mass_transfer/drying_rate.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/reaction_engineering/__init__.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/reaction_engineering/catalyst_activity.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/reaction_engineering/reaction_rate.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/reaction_engineering/residence_time.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/thermodynamics/__init__.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/thermodynamics/enthalpy_change.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/thermodynamics/entropy_change.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/calculations/thermodynamics/heat_of_vaporization.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/benzoicacid.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/bromine.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/butane.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/carbondioxide.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/carbonmonoxide.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/carbontetrachloride.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/chlorine.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/chlorobenzene.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/chloroform.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/chloromethane.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/cyanogen.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/cyclohexene.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/ethane.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/ethanol.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/ethylacetate.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/methanol.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/toluene.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/components/water.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/pipelines/insulation.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/pipelines/materials.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/pipelines/selection.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi/units/strings.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi.egg-info/dependency_links.txt +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/processpi.egg-info/top_level.txt +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/setup.cfg +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/tests/test_engine_network.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/tests/test_pipeline_network.py +0 -0
- {processpi-0.0.0 → processpi-0.1.2.10}/tests/test_variables.py +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: processpi
|
|
3
|
+
Version: 0.1.2.10
|
|
4
|
+
Summary: Python toolkit for chemical engineering simulations, equipment design, and unit conversions
|
|
5
|
+
Home-page: https://github.com/varma666/ProcessPi
|
|
6
|
+
Author: Raviteja Varma Nadimpalli
|
|
7
|
+
Author-email: Raviteja Varma Nadimpalli <processpi.dev@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 Raviteja Varma Nadimpalli
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Project-URL: Homepage, https://github.com/varma666/ProcessPi
|
|
31
|
+
Project-URL: BugTracker, https://github.com/varma666/ProcessPi/issues
|
|
32
|
+
Project-URL: SourceCode, https://github.com/varma666/ProcessPi
|
|
33
|
+
Requires-Python: >=3.8
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Requires-Dist: tabulate>=0.9.0
|
|
37
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
38
|
+
Requires-Dist: networkx>=3.1
|
|
39
|
+
Requires-Dist: CoolProp>=6.5.0
|
|
40
|
+
Requires-Dist: tqdm>=4.65.0
|
|
41
|
+
Dynamic: author
|
|
42
|
+
Dynamic: home-page
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
Dynamic: requires-python
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<img src="https://img.shields.io/badge/Process_PI-🧪-blue?style=for-the-badge&logo=python" alt="Process PI Logo" height="40"/>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<h1 align="center">Process PI</h1>
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<strong>Python toolkit for chemical engineering simulations, equipment design, and unit conversions</strong>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<p align="center">
|
|
57
|
+
<img src="https://img.shields.io/badge/🛠_Unit_Conversions-blue?style=for-the-badge" alt="Unit Conversions"/>
|
|
58
|
+
<img src="https://img.shields.io/badge/💧_Components-blue?style=for-the-badge" alt="Components"/>
|
|
59
|
+
<img src="https://img.shields.io/badge/🏭_Pipelines_&_Network_Engine-blue?style=for-the-badge" alt="Pipelines & Network Engine"/>
|
|
60
|
+
<img src="https://img.shields.io/badge/♨️_Heat_Transfer_(WIP)-blue?style=for-the-badge" alt="Heat Transfer"/>
|
|
61
|
+
<img src="https://img.shields.io/badge/⚗️_Reaction_&_Mass_Transfer_(WIP)-blue?style=for-the-badge" alt="Reaction & Mass Transfer"/>
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
<a href="https://pypi.org/project/processpi/">
|
|
66
|
+
<img src="https://img.shields.io/pypi/v/processpi?style=for-the-badge&logo=pypi" alt="PyPI Version"/>
|
|
67
|
+
</a>
|
|
68
|
+
<a href="https://github.com/varma666/ProcessPi/stargazers">
|
|
69
|
+
<img src="https://img.shields.io/github/stars/varma666/ProcessPi?style=for-the-badge&logo=github" alt="GitHub Stars"/>
|
|
70
|
+
</a>
|
|
71
|
+
<a href="https://github.com/varma666/ProcessPi/network/members">
|
|
72
|
+
<img src="https://img.shields.io/github/forks/varma666/ProcessPi?style=for-the-badge&logo=github" alt="GitHub Forks"/>
|
|
73
|
+
</a>
|
|
74
|
+
<a href="https://github.com/varma666/ProcessPi/actions">
|
|
75
|
+
<img src="https://img.shields.io/github/actions/workflow/status/varma666/ProcessPi/python-package.yml?branch=main&style=for-the-badge" alt="Build Status"/>
|
|
76
|
+
</a>
|
|
77
|
+
</p>
|
|
78
|
+
|
|
79
|
+
<p align="center">
|
|
80
|
+
<em>Built with ❤️ for chemical engineers.</em>
|
|
81
|
+
</p>
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 📖 Overview
|
|
86
|
+
|
|
87
|
+
**Process PI** is a modular **Python toolkit** for chemical engineering that enables:
|
|
88
|
+
|
|
89
|
+
- **Pipeline network simulations**
|
|
90
|
+
- **Unit conversions across SI, CGS, and Imperial systems**
|
|
91
|
+
- **Component-based property calculations**
|
|
92
|
+
- And more, with advanced features under active development.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 📑 Table of Contents
|
|
97
|
+
|
|
98
|
+
- [Features](#-features)
|
|
99
|
+
- [Installation](#-installation)
|
|
100
|
+
- [Getting Started](#-getting-started)
|
|
101
|
+
- [Unit Conversions](#1-unit-conversions)
|
|
102
|
+
- [Components](#2-components)
|
|
103
|
+
- [Pipeline Network Engine](#3-pipeline-network-engine)
|
|
104
|
+
- [Roadmap](#-roadmap)
|
|
105
|
+
- [License](#-license)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## ⚡ Features
|
|
110
|
+
|
|
111
|
+
- ⚙️ **Unit Conversion System** – Instant conversions between engineering unit systems.
|
|
112
|
+
- 🧪 **Components Library** – Access educational thermodynamic properties for 25+ fluids and growing.
|
|
113
|
+
- 🌐 **Pipeline Network Engine** – Build and simulate simple pipelines or complex interconnected networks, analyzing:
|
|
114
|
+
- Pressure drops
|
|
115
|
+
- Flow rates
|
|
116
|
+
- Reynolds number
|
|
117
|
+
- Pump requirements
|
|
118
|
+
- 🧮 **Calculation Modules (WIP)** – Heat transfer, mass transfer, and reaction engineering models in progress.
|
|
119
|
+
- 📊 **Simulation Tools (Planned)** – Transient dynamics, optimization, and interactive visualizations.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📦 Installation
|
|
124
|
+
|
|
125
|
+
Install from **PyPI**:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pip install processpi
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
For development:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git clone https://github.com/varma666/ProcessPi.git
|
|
135
|
+
cd ProcessPi
|
|
136
|
+
pip install -e .
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🚀 Getting Started
|
|
142
|
+
|
|
143
|
+
### 1. Unit Conversions
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from processpi.units import Length, Pressure, Temperature
|
|
147
|
+
|
|
148
|
+
# Length conversion
|
|
149
|
+
length = Length(1.5, "m")
|
|
150
|
+
print(length.to("ft")) # Feet output
|
|
151
|
+
|
|
152
|
+
# Pressure conversion
|
|
153
|
+
p = Pressure(2, "bar")
|
|
154
|
+
print(p.to("psi")) # PSI output
|
|
155
|
+
|
|
156
|
+
# Temperature conversion
|
|
157
|
+
t = Temperature(100, "C")
|
|
158
|
+
print(t.to("K")) # Kelvin output
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 2. Components
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from processpi.components import Water, Ethanol
|
|
165
|
+
|
|
166
|
+
water = Water()
|
|
167
|
+
ethanol = Ethanol()
|
|
168
|
+
|
|
169
|
+
print(f"Water density: {water.density()} kg/m3")
|
|
170
|
+
print(f"Ethanol viscosity: {ethanol.viscosity()} Pa·s")
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
⚠ **Note**: Component data is for educational/demo purposes only. Extended property support is in progress.
|
|
174
|
+
|
|
175
|
+
### 3. Pipeline Network Engine
|
|
176
|
+
|
|
177
|
+
Perform single-pipe or multi-pipe network simulations.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from processpi.pipelines.engine import PipelineEngine
|
|
181
|
+
from processpi.pipelines.pipes import Pipe
|
|
182
|
+
from processpi.components import Water
|
|
183
|
+
from processpi.units import VolumetricFlowRate, Diameter, Length
|
|
184
|
+
|
|
185
|
+
# Define pipe and fluid
|
|
186
|
+
pipe = Pipe(
|
|
187
|
+
internal_diameter=Diameter(50, "mm"),
|
|
188
|
+
length=Length(10, "m")
|
|
189
|
+
)
|
|
190
|
+
water = Water()
|
|
191
|
+
|
|
192
|
+
# Set up engine
|
|
193
|
+
engine = PipelineEngine()
|
|
194
|
+
engine.fit(
|
|
195
|
+
flowrate=VolumetricFlowRate(0.001, "m3/s"),
|
|
196
|
+
pipe=pipe,
|
|
197
|
+
fluid=water
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# Run calculations
|
|
201
|
+
results = engine.run()
|
|
202
|
+
engine.summary()
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Planned upgrades:
|
|
206
|
+
- Dynamic simulations
|
|
207
|
+
- Branching/parallel pipeline analysis
|
|
208
|
+
- Integrated cost and energy optimization
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🛣 Roadmap
|
|
213
|
+
|
|
214
|
+
- ✅ Pipeline Network Engine – Functional for single and multi-segment networks
|
|
215
|
+
- 🚧 Heat Transfer Modules – In progress for exchangers, conduction, and convection models
|
|
216
|
+
- 🚧 Mass Transfer & Reaction Modules – Basic structure in place, calculations coming soon
|
|
217
|
+
- 🔮 Advanced Features – Transient analysis, energy optimization, and GUI/web interfaces
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 📜 License
|
|
222
|
+
|
|
223
|
+
This project is licensed under the **MIT License** – see the LICENSE file for details.
|
|
224
|
+
|
|
225
|
+
<p align="center"> <em>ProcessPI – Built with ❤️ for chemical engineers.</em> </p>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
<p align="center">
|
|
3
2
|
<img src="https://img.shields.io/badge/Process_PI-🧪-blue?style=for-the-badge&logo=python" alt="Process PI Logo" height="40"/>
|
|
4
3
|
</p>
|
|
@@ -12,9 +11,9 @@
|
|
|
12
11
|
<p align="center">
|
|
13
12
|
<img src="https://img.shields.io/badge/🛠_Unit_Conversions-blue?style=for-the-badge" alt="Unit Conversions"/>
|
|
14
13
|
<img src="https://img.shields.io/badge/💧_Components-blue?style=for-the-badge" alt="Components"/>
|
|
15
|
-
<img src="https://img.shields.io/badge/🏭
|
|
16
|
-
<img src="https://img.shields.io/badge/♨️
|
|
17
|
-
<img src="https://img.shields.io/badge/⚗️
|
|
14
|
+
<img src="https://img.shields.io/badge/🏭_Pipelines_&_Network_Engine-blue?style=for-the-badge" alt="Pipelines & Network Engine"/>
|
|
15
|
+
<img src="https://img.shields.io/badge/♨️_Heat_Transfer_(WIP)-blue?style=for-the-badge" alt="Heat Transfer"/>
|
|
16
|
+
<img src="https://img.shields.io/badge/⚗️_Reaction_&_Mass_Transfer_(WIP)-blue?style=for-the-badge" alt="Reaction & Mass Transfer"/>
|
|
18
17
|
</p>
|
|
19
18
|
|
|
20
19
|
<p align="center">
|
|
@@ -40,18 +39,23 @@
|
|
|
40
39
|
|
|
41
40
|
## 📖 Overview
|
|
42
41
|
|
|
43
|
-
**Process PI** is a
|
|
44
|
-
|
|
42
|
+
**Process PI** is a modular **Python toolkit** for chemical engineering that enables:
|
|
43
|
+
|
|
44
|
+
- **Pipeline network simulations**
|
|
45
|
+
- **Unit conversions across SI, CGS, and Imperial systems**
|
|
46
|
+
- **Component-based property calculations**
|
|
47
|
+
- And more, with advanced features under active development.
|
|
45
48
|
|
|
46
49
|
---
|
|
47
50
|
|
|
48
51
|
## 📑 Table of Contents
|
|
52
|
+
|
|
49
53
|
- [Features](#-features)
|
|
50
54
|
- [Installation](#-installation)
|
|
51
55
|
- [Getting Started](#-getting-started)
|
|
52
56
|
- [Unit Conversions](#1-unit-conversions)
|
|
53
57
|
- [Components](#2-components)
|
|
54
|
-
- [Pipeline Network
|
|
58
|
+
- [Pipeline Network Engine](#3-pipeline-network-engine)
|
|
55
59
|
- [Roadmap](#-roadmap)
|
|
56
60
|
- [License](#-license)
|
|
57
61
|
|
|
@@ -59,69 +63,73 @@ It provides a **modular framework** for learning, experimenting, and simulating
|
|
|
59
63
|
|
|
60
64
|
## ⚡ Features
|
|
61
65
|
|
|
62
|
-
- ⚙️ **Unit Conversion System** –
|
|
63
|
-
- 🧪 **Components
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
66
|
+
- ⚙️ **Unit Conversion System** – Instant conversions between engineering unit systems.
|
|
67
|
+
- 🧪 **Components Library** – Access educational thermodynamic properties for 25+ fluids and growing.
|
|
68
|
+
- 🌐 **Pipeline Network Engine** – Build and simulate simple pipelines or complex interconnected networks, analyzing:
|
|
69
|
+
- Pressure drops
|
|
70
|
+
- Flow rates
|
|
71
|
+
- Reynolds number
|
|
72
|
+
- Pump requirements
|
|
73
|
+
- 🧮 **Calculation Modules (WIP)** – Heat transfer, mass transfer, and reaction engineering models in progress.
|
|
74
|
+
- 📊 **Simulation Tools (Planned)** – Transient dynamics, optimization, and interactive visualizations.
|
|
67
75
|
|
|
68
76
|
---
|
|
69
77
|
|
|
70
78
|
## 📦 Installation
|
|
71
79
|
|
|
72
|
-
Install
|
|
80
|
+
Install from **PyPI**:
|
|
73
81
|
|
|
74
82
|
```bash
|
|
75
83
|
pip install processpi
|
|
76
84
|
```
|
|
77
85
|
|
|
86
|
+
For development:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/varma666/ProcessPi.git
|
|
90
|
+
cd ProcessPi
|
|
91
|
+
pip install -e .
|
|
92
|
+
```
|
|
93
|
+
|
|
78
94
|
---
|
|
79
95
|
|
|
80
96
|
## 🚀 Getting Started
|
|
81
97
|
|
|
82
98
|
### 1. Unit Conversions
|
|
83
99
|
|
|
84
|
-
Easily convert between SI, CGS, and Imperial units.
|
|
85
|
-
|
|
86
100
|
```python
|
|
87
101
|
from processpi.units import Length, Pressure, Temperature
|
|
88
102
|
|
|
89
|
-
# Length
|
|
90
|
-
|
|
91
|
-
print(
|
|
103
|
+
# Length conversion
|
|
104
|
+
length = Length(1.5, "m")
|
|
105
|
+
print(length.to("ft")) # Feet output
|
|
92
106
|
|
|
93
|
-
# Pressure
|
|
107
|
+
# Pressure conversion
|
|
94
108
|
p = Pressure(2, "bar")
|
|
95
|
-
print(p.to("
|
|
109
|
+
print(p.to("psi")) # PSI output
|
|
96
110
|
|
|
97
|
-
# Temperature
|
|
111
|
+
# Temperature conversion
|
|
98
112
|
t = Temperature(100, "C")
|
|
99
|
-
print(t.to("K"))
|
|
113
|
+
print(t.to("K")) # Kelvin output
|
|
100
114
|
```
|
|
101
115
|
|
|
102
|
-
---
|
|
103
|
-
|
|
104
116
|
### 2. Components
|
|
105
117
|
|
|
106
|
-
Access educational thermodynamic properties of chemical components.
|
|
107
|
-
|
|
108
118
|
```python
|
|
109
119
|
from processpi.components import Water, Ethanol
|
|
110
120
|
|
|
111
121
|
water = Water()
|
|
112
122
|
ethanol = Ethanol()
|
|
113
123
|
|
|
114
|
-
print(f"Water density: {water.density()} kg/
|
|
124
|
+
print(f"Water density: {water.density()} kg/m3")
|
|
115
125
|
print(f"Ethanol viscosity: {ethanol.viscosity()} Pa·s")
|
|
116
126
|
```
|
|
117
127
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
---
|
|
128
|
+
⚠ **Note**: Component data is for educational/demo purposes only. Extended property support is in progress.
|
|
121
129
|
|
|
122
|
-
### 3. Pipeline Network
|
|
130
|
+
### 3. Pipeline Network Engine
|
|
123
131
|
|
|
124
|
-
Perform
|
|
132
|
+
Perform single-pipe or multi-pipe network simulations.
|
|
125
133
|
|
|
126
134
|
```python
|
|
127
135
|
from processpi.pipelines.engine import PipelineEngine
|
|
@@ -129,37 +137,39 @@ from processpi.pipelines.pipes import Pipe
|
|
|
129
137
|
from processpi.components import Water
|
|
130
138
|
from processpi.units import VolumetricFlowRate, Diameter, Length
|
|
131
139
|
|
|
140
|
+
# Define pipe and fluid
|
|
132
141
|
pipe = Pipe(
|
|
133
142
|
internal_diameter=Diameter(50, "mm"),
|
|
134
143
|
length=Length(10, "m")
|
|
135
144
|
)
|
|
145
|
+
water = Water()
|
|
136
146
|
|
|
147
|
+
# Set up engine
|
|
137
148
|
engine = PipelineEngine()
|
|
138
149
|
engine.fit(
|
|
139
|
-
flowrate=VolumetricFlowRate(0.001, "
|
|
150
|
+
flowrate=VolumetricFlowRate(0.001, "m3/s"),
|
|
140
151
|
pipe=pipe,
|
|
141
|
-
fluid=
|
|
152
|
+
fluid=water
|
|
142
153
|
)
|
|
143
154
|
|
|
155
|
+
# Run calculations
|
|
144
156
|
results = engine.run()
|
|
145
157
|
engine.summary()
|
|
146
158
|
```
|
|
147
159
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
- Cost and energy optimization tools for network layouts
|
|
160
|
+
Planned upgrades:
|
|
161
|
+
- Dynamic simulations
|
|
162
|
+
- Branching/parallel pipeline analysis
|
|
163
|
+
- Integrated cost and energy optimization
|
|
153
164
|
|
|
154
165
|
---
|
|
155
166
|
|
|
156
167
|
## 🛣 Roadmap
|
|
157
168
|
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
- Enable integration with real process data and sensor-driven workflows
|
|
169
|
+
- ✅ Pipeline Network Engine – Functional for single and multi-segment networks
|
|
170
|
+
- 🚧 Heat Transfer Modules – In progress for exchangers, conduction, and convection models
|
|
171
|
+
- 🚧 Mass Transfer & Reaction Modules – Basic structure in place, calculations coming soon
|
|
172
|
+
- 🔮 Advanced Features – Transient analysis, energy optimization, and GUI/web interfaces
|
|
163
173
|
|
|
164
174
|
---
|
|
165
175
|
|
|
@@ -167,8 +177,4 @@ engine.summary()
|
|
|
167
177
|
|
|
168
178
|
This project is licensed under the **MIT License** – see the LICENSE file for details.
|
|
169
179
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<p align="center">
|
|
173
|
-
<em>Process PI – Built with ❤️ for chemical engineers.</em>
|
|
174
|
-
</p>
|
|
180
|
+
<p align="center"> <em>ProcessPI – Built with ❤️ for chemical engineers.</em> </p>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ProcessPI: Chemical & Process Engineering Tools
|
|
3
|
+
==============================================
|
|
4
|
+
|
|
5
|
+
ProcessPI is a Python library for process engineers to perform calculations,
|
|
6
|
+
simulate fluid systems, and design equipment.
|
|
7
|
+
|
|
8
|
+
Features:
|
|
9
|
+
---------
|
|
10
|
+
- Fluid mechanics and hydraulic calculations
|
|
11
|
+
- Pipeline network simulation and visualization
|
|
12
|
+
- Chemical and physical properties management
|
|
13
|
+
- Unit handling and conversions
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
import time
|
|
19
|
+
import importlib
|
|
20
|
+
import pkgutil
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
# -------------------------------------------------------------------
|
|
24
|
+
# Dynamic Version Handling
|
|
25
|
+
# -------------------------------------------------------------------
|
|
26
|
+
try:
|
|
27
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
28
|
+
__version__ = version("processpi")
|
|
29
|
+
except PackageNotFoundError:
|
|
30
|
+
__version__ = "0.1.0" # fallback version for dev environments
|
|
31
|
+
|
|
32
|
+
__all__ = []
|
|
33
|
+
|
|
34
|
+
# -------------------------------------------------------------------
|
|
35
|
+
# Sleek Loading Animation
|
|
36
|
+
# -------------------------------------------------------------------
|
|
37
|
+
def _loading_animation(text="Initializing ProcessPI"):
|
|
38
|
+
frames = ["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]
|
|
39
|
+
for i in range(20):
|
|
40
|
+
sys.stdout.write(f"\r{text} {frames[i % len(frames)]}")
|
|
41
|
+
sys.stdout.flush()
|
|
42
|
+
time.sleep(0.05)
|
|
43
|
+
sys.stdout.write("\r✅ ProcessPI Ready! \n")
|
|
44
|
+
|
|
45
|
+
# Only show animation in interactive sessions (terminal/Colab)
|
|
46
|
+
if sys.stdout.isatty() or "COLAB_GPU" in os.environ:
|
|
47
|
+
_loading_animation()
|
|
48
|
+
|
|
49
|
+
# -------------------------------------------------------------------
|
|
50
|
+
# Import Core Submodules
|
|
51
|
+
# -------------------------------------------------------------------
|
|
52
|
+
from . import calculations, pipelines, units, components
|
|
53
|
+
|
|
54
|
+
__all__.extend(["calculations", "pipelines", "units", "components"])
|
|
55
|
+
|
|
56
|
+
# -------------------------------------------------------------------
|
|
57
|
+
# Dynamic Discovery & Import of Component Classes
|
|
58
|
+
# -------------------------------------------------------------------
|
|
59
|
+
_components_dir = Path(__file__).parent / "components"
|
|
60
|
+
|
|
61
|
+
for _, module_name, is_pkg in pkgutil.iter_modules([str(_components_dir)]):
|
|
62
|
+
if not is_pkg: # Import each component module dynamically
|
|
63
|
+
module = importlib.import_module(f"{__name__}.components.{module_name}")
|
|
64
|
+
globals()[module_name] = module
|
|
65
|
+
__all__.append(module_name)
|
|
66
|
+
|
|
67
|
+
# Automatically collect all classes from components
|
|
68
|
+
for mod in list(__all__):
|
|
69
|
+
module_obj = globals().get(mod)
|
|
70
|
+
if module_obj and hasattr(module_obj, "__dict__"):
|
|
71
|
+
for name, obj in module_obj.__dict__.items():
|
|
72
|
+
if isinstance(obj, type): # only classes
|
|
73
|
+
globals()[name] = obj
|
|
74
|
+
__all__.append(name)
|
|
75
|
+
|
|
76
|
+
# -------------------------------------------------------------------
|
|
77
|
+
# Friendly Banner for Interactive Users
|
|
78
|
+
# -------------------------------------------------------------------
|
|
79
|
+
if sys.stdout.isatty() or "COLAB_GPU" in os.environ:
|
|
80
|
+
print(f"📦 ProcessPI v{__version__} | Chemical & Process Engineering Tools Loaded!\n")
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Initializes the main calculations module of ProcessPI.
|
|
3
|
+
|
|
4
|
+
This module dynamically discovers and loads all calculation submodules and
|
|
5
|
+
makes their classes accessible under the processpi.calculations namespace.
|
|
6
|
+
|
|
7
|
+
Example usage:
|
|
8
|
+
|
|
9
|
+
import processpi.calculations as calc
|
|
10
|
+
engine = calc.CalculationEngine()
|
|
11
|
+
water_calc = calc.fluids.PressureDropDarcy(...)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import importlib
|
|
15
|
+
import pkgutil
|
|
16
|
+
import inspect
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
import sys
|
|
19
|
+
import time
|
|
20
|
+
|
|
21
|
+
# ------------------------
|
|
22
|
+
# Loading animation
|
|
23
|
+
# ------------------------
|
|
24
|
+
def _show_loading_animation():
|
|
25
|
+
frames = ["⠁","⠂","⠄","⠂"]
|
|
26
|
+
sys.stdout.write(f"⏳ Loading ProcessPI Calculations... ")
|
|
27
|
+
sys.stdout.flush()
|
|
28
|
+
for frame in frames * 2:
|
|
29
|
+
sys.stdout.write(f"\r⏳ Loading ProcessPI Calculations... {frame}")
|
|
30
|
+
sys.stdout.flush()
|
|
31
|
+
time.sleep(0.1)
|
|
32
|
+
sys.stdout.write("\r✅ Calculations module ready! \n")
|
|
33
|
+
sys.stdout.flush()
|
|
34
|
+
|
|
35
|
+
_show_loading_animation()
|
|
36
|
+
|
|
37
|
+
# ------------------------
|
|
38
|
+
# Import core classes if any
|
|
39
|
+
# ------------------------
|
|
40
|
+
from .engine import CalculationEngine # optional; adjust as needed
|
|
41
|
+
from .base import CalculationBase
|
|
42
|
+
|
|
43
|
+
__all__ = ["CalculationEngine", "CalculationBase"]
|
|
44
|
+
|
|
45
|
+
# ------------------------
|
|
46
|
+
# Dynamically import submodules (e.g., fluids, heat_transfer, etc.)
|
|
47
|
+
# ------------------------
|
|
48
|
+
package_dir = Path(__file__).parent
|
|
49
|
+
package_name = __name__
|
|
50
|
+
|
|
51
|
+
for finder, name, ispkg in pkgutil.iter_modules([str(package_dir)]):
|
|
52
|
+
# skip private or undesired modules if any
|
|
53
|
+
if name.startswith("_"):
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
full_mod = f"{package_name}.{name}"
|
|
57
|
+
module = importlib.import_module(full_mod)
|
|
58
|
+
globals()[name] = module
|
|
59
|
+
__all__.append(name)
|
|
60
|
+
|
|
61
|
+
# Optionally, auto-import module-level classes
|
|
62
|
+
for cls_name, cls_obj in inspect.getmembers(module, inspect.isclass):
|
|
63
|
+
if cls_obj.__module__ == module.__name__:
|
|
64
|
+
globals()[cls_name] = cls_obj
|
|
65
|
+
__all__.append(cls_name)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class CalculationBase(ABC):
|
|
4
|
+
"""
|
|
5
|
+
Abstract base class for all calculation modules in the processpi library.
|
|
6
|
+
|
|
7
|
+
This class defines a standard interface and common utility methods for all
|
|
8
|
+
calculation classes, ensuring they have a consistent structure for input
|
|
9
|
+
validation, calculation execution, and result handling. All specific
|
|
10
|
+
calculation classes (e.g., `PressureDropDarcy`, `ReynoldsNumber`) must
|
|
11
|
+
inherit from this class.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, **kwargs):
|
|
15
|
+
"""
|
|
16
|
+
Initializes the calculation object and stores all input parameters.
|
|
17
|
+
|
|
18
|
+
The method automatically calls `validate_inputs()` to ensure that the
|
|
19
|
+
provided arguments are valid before the object is fully constructed.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
**kwargs: Arbitrary keyword arguments representing the inputs for the
|
|
23
|
+
specific calculation.
|
|
24
|
+
"""
|
|
25
|
+
self.inputs = kwargs
|
|
26
|
+
self.validate_inputs()
|
|
27
|
+
|
|
28
|
+
@abstractmethod
|
|
29
|
+
def validate_inputs(self):
|
|
30
|
+
"""
|
|
31
|
+
Abstract method to validate the inputs.
|
|
32
|
+
|
|
33
|
+
Subclasses must implement this method to check for the presence and
|
|
34
|
+
validity of required inputs. It should raise a `ValueError` if any
|
|
35
|
+
input is missing or invalid.
|
|
36
|
+
"""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def calculate(self):
|
|
41
|
+
"""
|
|
42
|
+
Abstract method to perform the calculation.
|
|
43
|
+
|
|
44
|
+
Subclasses must implement this method to execute the core calculation
|
|
45
|
+
logic. The method should return the results, typically as a dictionary
|
|
46
|
+
or a specific unit object.
|
|
47
|
+
"""
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
def get_inputs(self):
|
|
51
|
+
"""
|
|
52
|
+
Returns the original inputs provided during initialization.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
dict: A dictionary of the input parameters.
|
|
56
|
+
"""
|
|
57
|
+
return self.inputs
|
|
58
|
+
|
|
59
|
+
def to_dict(self):
|
|
60
|
+
"""
|
|
61
|
+
Performs the calculation and returns a dictionary with both inputs and results.
|
|
62
|
+
|
|
63
|
+
This method combines the inputs and the output of the `calculate()` method
|
|
64
|
+
into a single, comprehensive dictionary.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
dict: A dictionary containing two keys: "inputs" and "results".
|
|
68
|
+
"""
|
|
69
|
+
result = self.calculate()
|
|
70
|
+
return {
|
|
71
|
+
"inputs": self.inputs,
|
|
72
|
+
"results": result
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def _get_value(x, name):
|
|
77
|
+
"""
|
|
78
|
+
A static utility method to extract the numeric value from an input.
|
|
79
|
+
|
|
80
|
+
This method handles both simple numeric types (like `int`, `float`)
|
|
81
|
+
and custom objects that have a `.value` attribute, such as unit objects.
|
|
82
|
+
It raises a `TypeError` if the value cannot be interpreted as a number.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
x: The input value, which can be a number or a unit object.
|
|
86
|
+
name (str): The name of the input, used for a more informative
|
|
87
|
+
error message.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
float: The numeric value of the input.
|
|
91
|
+
|
|
92
|
+
Raises:
|
|
93
|
+
TypeError: If the input value cannot be converted to a float.
|
|
94
|
+
"""
|
|
95
|
+
if hasattr(x, "value"):
|
|
96
|
+
return x.value
|
|
97
|
+
try:
|
|
98
|
+
# Accept numpy/scalar numbers.
|
|
99
|
+
return float(x)
|
|
100
|
+
except (TypeError, ValueError):
|
|
101
|
+
raise TypeError(f"Could not interpret {name} value: {x!r}")
|