processpi 0.0.0__py3-none-any.whl
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.
- processpi/__init__.py +1 -0
- processpi/calculations/__init__.py +3 -0
- processpi/calculations/base.py +55 -0
- processpi/calculations/engine.py +69 -0
- processpi/calculations/fluids/__init__.py +13 -0
- processpi/calculations/fluids/cool_brook_white.py +49 -0
- processpi/calculations/fluids/flow_type.py +37 -0
- processpi/calculations/fluids/optimium_pipe_dia.py +45 -0
- processpi/calculations/fluids/pressure_drop_darcy.py +25 -0
- processpi/calculations/fluids/pressure_drop_fanning.py +25 -0
- processpi/calculations/fluids/pump_power.py +34 -0
- processpi/calculations/fluids/reynolds_number.py +24 -0
- processpi/calculations/fluids/velocity.py +36 -0
- processpi/calculations/heat_transfer/__init__.py +4 -0
- processpi/calculations/heat_transfer/conduction_heat_loss.py +26 -0
- processpi/calculations/heat_transfer/convection_heat_loss.py +23 -0
- processpi/calculations/heat_transfer/heat_exchanger_area.py +26 -0
- processpi/calculations/mass_transfer/__init__.py +3 -0
- processpi/calculations/mass_transfer/distillation_stage_count.py +346 -0
- processpi/calculations/mass_transfer/drying_rate.py +132 -0
- processpi/calculations/reaction_engineering/__init__.py +4 -0
- processpi/calculations/reaction_engineering/catalyst_activity.py +109 -0
- processpi/calculations/reaction_engineering/reaction_rate.py +143 -0
- processpi/calculations/reaction_engineering/residence_time.py +80 -0
- processpi/calculations/thermodynamics/__init__.py +4 -0
- processpi/calculations/thermodynamics/enthalpy_change.py +23 -0
- processpi/calculations/thermodynamics/entropy_change.py +25 -0
- processpi/calculations/thermodynamics/heat_of_vaporization.py +20 -0
- processpi/components/__init__.py +5 -0
- processpi/components/aceticacid.py +19 -0
- processpi/components/acetone.py +20 -0
- processpi/components/acrylicacid.py +19 -0
- processpi/components/air.py +20 -0
- processpi/components/ammonia.py +19 -0
- processpi/components/base.py +85 -0
- processpi/components/benzene.py +40 -0
- processpi/components/benzoicacid.py +19 -0
- processpi/components/bromine.py +19 -0
- processpi/components/butane.py +19 -0
- processpi/components/carbondioxide.py +19 -0
- processpi/components/carbonmonoxide.py +17 -0
- processpi/components/carbontetrachloride.py +17 -0
- processpi/components/chlorine.py +17 -0
- processpi/components/chlorobenzene.py +17 -0
- processpi/components/chloroform.py +17 -0
- processpi/components/chloromethane.py +17 -0
- processpi/components/cyanogen.py +17 -0
- processpi/components/cyclohexene.py +17 -0
- processpi/components/ethane.py +17 -0
- processpi/components/ethanol.py +20 -0
- processpi/components/ethylacetate.py +17 -0
- processpi/components/methanol.py +20 -0
- processpi/components/toluene.py +22 -0
- processpi/components/water.py +24 -0
- processpi/pipelines/__init__.py +0 -0
- processpi/pipelines/base.py +76 -0
- processpi/pipelines/design_rules.py +91 -0
- processpi/pipelines/engine.py +718 -0
- processpi/pipelines/equipment.py +32 -0
- processpi/pipelines/fittings.py +76 -0
- processpi/pipelines/insulation.py +0 -0
- processpi/pipelines/materials.py +102 -0
- processpi/pipelines/network.py +277 -0
- processpi/pipelines/pipelineresults.py +95 -0
- processpi/pipelines/pipes.py +84 -0
- processpi/pipelines/pumps.py +83 -0
- processpi/pipelines/selection.py +89 -0
- processpi/pipelines/standards.py +279 -0
- processpi/pipelines/vessel.py +34 -0
- processpi/units/__init__.py +38 -0
- processpi/units/area.py +51 -0
- processpi/units/base.py +57 -0
- processpi/units/density.py +47 -0
- processpi/units/diameter.py +58 -0
- processpi/units/dimensionless.py +42 -0
- processpi/units/heat_flux.py +46 -0
- processpi/units/heat_of_vaporization.py +47 -0
- processpi/units/heat_transfer_coefficient.py +45 -0
- processpi/units/length.py +47 -0
- processpi/units/mass.py +50 -0
- processpi/units/mass_flowrate.py +50 -0
- processpi/units/pressure.py +57 -0
- processpi/units/specific_heat.py +47 -0
- processpi/units/strings.py +31 -0
- processpi/units/temperature.py +51 -0
- processpi/units/thermal_conductivity.py +45 -0
- processpi/units/thermal_resistance.py +46 -0
- processpi/units/velocity.py +45 -0
- processpi/units/viscosity.py +78 -0
- processpi/units/volume.py +50 -0
- processpi/units/volumetric_flowrate.py +52 -0
- processpi-0.0.0.dist-info/METADATA +5 -0
- processpi-0.0.0.dist-info/RECORD +96 -0
- processpi-0.0.0.dist-info/WHEEL +5 -0
- processpi-0.0.0.dist-info/licenses/LICENSE +21 -0
- processpi-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class Chlorine(Component):
|
|
4
|
+
name = "Chlorine"
|
|
5
|
+
formula = "Cl2"
|
|
6
|
+
molecular_weight = 70.906
|
|
7
|
+
_critical_temperature = Temperature(417.15, "K")
|
|
8
|
+
_critical_pressure = Pressure(7.71, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.124, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.276 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.0688 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [2.23,0.27645,417.15,0.2926]
|
|
13
|
+
_specific_heat_constants = [63936,46.35,-0.1623,0,0]
|
|
14
|
+
_viscosity_constants = [-9.5412,456.62,0,0,0]
|
|
15
|
+
_thermal_conductivity_constants = [0.2246, -0.000064,-0.000000788,0,0]
|
|
16
|
+
_vapor_pressure_constants = [71.334,-3855,-8.5171,1.24E-02, 1]
|
|
17
|
+
_enthalpy_constants = [3.068E-7, 0.8458, -0.9001,0.453, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class ChloroBenzene(Component):
|
|
4
|
+
name = "Chloro Benzene"
|
|
5
|
+
formula = "C6H5Cl"
|
|
6
|
+
molecular_weight = 112.557
|
|
7
|
+
_critical_temperature = Temperature(632.35, "K")
|
|
8
|
+
_critical_pressure = Pressure(4.519, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.308, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.265 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.2499 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [0.8711,0.26805,632.35,0.2799]
|
|
13
|
+
_specific_heat_constants = [-1307500,15338,-53.974,0.063483,0]
|
|
14
|
+
_viscosity_constants = [0.15772,540.5,-1.6075,1.50E+14,-6.00E+00]
|
|
15
|
+
_thermal_conductivity_constants = [0.1841, -0.0001917,0,0,0]
|
|
16
|
+
_vapor_pressure_constants = [54.144,-6244.40,-4.5343,4.70E-18, 6]
|
|
17
|
+
_enthalpy_constants = [5.148E-7,0.36614, 227.95,4.3707, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class Chloroform(Component):
|
|
4
|
+
name = "Chloroform"
|
|
5
|
+
formula = "CHCl3"
|
|
6
|
+
molecular_weight = 119.378
|
|
7
|
+
_critical_temperature = Temperature(536.4, "K")
|
|
8
|
+
_critical_pressure = Pressure(5.472, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.239, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.293 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.2219 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [1.0841,0.2581,536.4,0.2741]
|
|
13
|
+
_specific_heat_constants = [124850,-166.34,0.43209,0,0]
|
|
14
|
+
_viscosity_constants = [-14.109,1049.2,0.5377,0,0]
|
|
15
|
+
_thermal_conductivity_constants = [0.1778, -0.0002023,0,0,0]
|
|
16
|
+
_vapor_pressure_constants = [146.43,-7792.30,-20.614,2.46E-02, 1]
|
|
17
|
+
_enthalpy_constants = [4.186E-7,0.3584, 209.63,3.5047, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class ChloroMethane(Component):
|
|
4
|
+
name = "Chloro Methane"
|
|
5
|
+
formula = "CH3Cl"
|
|
6
|
+
molecular_weight = 50.488
|
|
7
|
+
_critical_temperature = Temperature(416.25, "K")
|
|
8
|
+
_critical_pressure = Pressure(6.68, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.143, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.276 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.1531 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [1.817,0.25877,416.25,0.2833]
|
|
13
|
+
_specific_heat_constants = [96910,-207.9,0.37456,0.000488,0]
|
|
14
|
+
_viscosity_constants = [-25.132,1381.9,2.0811,-4.50E-27,10]
|
|
15
|
+
_thermal_conductivity_constants = [0.41067, -0.0008478,0,0,0]
|
|
16
|
+
_vapor_pressure_constants = [64.697,-4048.10,-6.8066,1.04E-05, 2]
|
|
17
|
+
_enthalpy_constants = [2.9745E-7,0.353, 175.43,2.452, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class Cyanogen(Component):
|
|
4
|
+
name = "Cyanogen"
|
|
5
|
+
formula = "C2N2"
|
|
6
|
+
molecular_weight = 52.035
|
|
7
|
+
_critical_temperature = Temperature(400.15, "K")
|
|
8
|
+
_critical_pressure = Pressure(5.98, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.195, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.351 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.279 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [1.0743,0.20948,400.15,0.20724]
|
|
13
|
+
_specific_heat_constants = [65516,-144.7,0.063229,0,0]
|
|
14
|
+
_viscosity_constants = [-12.086,994.23,0,0,0]
|
|
15
|
+
_thermal_conductivity_constants = [0.4685, -0.00086594,0,0,0]
|
|
16
|
+
_vapor_pressure_constants = [81.565,-4808.90,-9.3748,1.39E-05, 2]
|
|
17
|
+
_enthalpy_constants = [3.384E-7,0.3707, 245.25,2.3803, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class Cyclohexane(Component):
|
|
4
|
+
name = "Cyclohexane"
|
|
5
|
+
formula = "C6H12"
|
|
6
|
+
molecular_weight = 84.159
|
|
7
|
+
_critical_temperature = Temperature(553.8, "K")
|
|
8
|
+
_critical_pressure = Pressure(4.08, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.308, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.273 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.2081 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [0.88998,0.27376,553.8,0.28571]
|
|
13
|
+
_specific_heat_constants = [-220600,3118.30,-9.4216,0.010687,0]
|
|
14
|
+
_viscosity_constants = [-33.763,2497.2,3.2236,0,0]
|
|
15
|
+
_thermal_conductivity_constants = [0.19813, -0.0002505,0,0,0]
|
|
16
|
+
_vapor_pressure_constants = [51.087,-5226.40,-4.2278,19.76E-18, 6]
|
|
17
|
+
_enthalpy_constants = [4.4902E-7,0.39881, 279.69,3.392, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class Ethane(Component):
|
|
4
|
+
name = "Ethane"
|
|
5
|
+
formula = "C2H6"
|
|
6
|
+
molecular_weight = 30.069
|
|
7
|
+
_critical_temperature = Temperature(305.32, "K")
|
|
8
|
+
_critical_pressure = Pressure(4.872, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.1455, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.279 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.0995 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [1.9122,0.27937,305.32,0.29187]
|
|
13
|
+
_specific_heat_constants = [44.009,89718,918.77,-1886,0]
|
|
14
|
+
_viscosity_constants = [-7.0046,276.38,-0.6087,-3.11E-18,7]
|
|
15
|
+
_thermal_conductivity_constants = [0.35758, -0.0011458,6.19E-07,0,0]
|
|
16
|
+
_vapor_pressure_constants = [51.857,-2598.70,-5.1283,1.49E-05, 2]
|
|
17
|
+
_enthalpy_constants = [2.1091E-7,0.60646, -0.55492,0.32799, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
from .base import Component
|
|
3
|
+
from processpi.units import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Ethanol(Component):
|
|
7
|
+
name = "Ethanol"
|
|
8
|
+
formula = "C2H5OH"
|
|
9
|
+
molecular_weight = 46.068
|
|
10
|
+
_critical_temperature = Temperature(514.00, "K")
|
|
11
|
+
_critical_pressure = Pressure(6.137, "MPa")
|
|
12
|
+
_critical_volume = Volume(0.168, "m3") # Placeholder for critical volume per Kmole
|
|
13
|
+
_critical_zc = 0.241 # Placeholder for critical compressibility factor
|
|
14
|
+
_critical_acentric_factor = 0.6436 # Placeholder for critical acentric factor
|
|
15
|
+
_density_constants = [1.6288, 0.27469, 514, 0.23178]
|
|
16
|
+
_specific_heat_constants = [102640,-139.63,-0.030341,0.0020386,0]
|
|
17
|
+
_viscosity_constants = [7.875, 781.98, -3.0418, 0, 0]
|
|
18
|
+
_thermal_conductivity_constants = [0.2468, -0.000264, 0,0,0]
|
|
19
|
+
_vapor_pressure_constants = [73.304, -7122.3, -7.1424, 0.0000028853, 2]
|
|
20
|
+
_enthalpy_constants = [5.5789E-7, 0.31245, 159.05, 4.9694, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
class EthlylAcetate(Component):
|
|
4
|
+
name = "Ethlyl Acetate"
|
|
5
|
+
formula = "C4H8O2"
|
|
6
|
+
molecular_weight = 88.105
|
|
7
|
+
_critical_temperature = Temperature(523.3, "K")
|
|
8
|
+
_critical_pressure = Pressure(3.88, "MPa")
|
|
9
|
+
_critical_volume = Volume(0.286, "m3") # Placeholder for critical volume per Kmole
|
|
10
|
+
_critical_zc = 0.255 # Placeholder for critical compressibility factor
|
|
11
|
+
_critical_acentric_factor = 0.3664 # Placeholder for critical acentric factor
|
|
12
|
+
_density_constants = [0.8996,0.25856,523.3,0.278]
|
|
13
|
+
_specific_heat_constants = [226230,-624.8,1.472,0,0]
|
|
14
|
+
_viscosity_constants = [14.354,-154.6,-3.7887,0,0]
|
|
15
|
+
_thermal_conductivity_constants = [0.2501, -0.0003563,0,0,0]
|
|
16
|
+
_vapor_pressure_constants = [66.824,-6227.60,-6.41,1.79E-17, 6]
|
|
17
|
+
_enthalpy_constants = [4.933E-7,0.3847, 189.6,4.149, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
from .base import Component
|
|
3
|
+
from processpi.units import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Methanol(Component):
|
|
7
|
+
name = "Methanol"
|
|
8
|
+
formula = "CH3OH"
|
|
9
|
+
molecular_weight = 32.042
|
|
10
|
+
_critical_temperature = Temperature(512.6, "K")
|
|
11
|
+
_critical_pressure = Pressure(8.1, "MPa")
|
|
12
|
+
_critical_volume = Volume(0.117, "m3") # Placeholder for critical volume per Kmole
|
|
13
|
+
_critical_zc = 0.222 # Placeholder for critical compressibility factor
|
|
14
|
+
_critical_acentric_factor = 0.5658 # Placeholder for critical acentric factor
|
|
15
|
+
_density_constants = [2.3267, 0.27073, 512.5, 0.24713]
|
|
16
|
+
_specific_heat_constants = [105800,-362.23,0.9379,0,0]
|
|
17
|
+
_viscosity_constants = [-25.317, 1789.2, 2.069, 0, 0]
|
|
18
|
+
_thermal_conductivity_constants = [0.2837, -0.000281, 0,0,0]
|
|
19
|
+
_vapor_pressure_constants = [82.718, -6904.5, -8.8622, 0.0000074664, 2]
|
|
20
|
+
_enthalpy_constants = [5.0451e-7, 0.33594, 175.47, 4.3825, 0] # Placeholder for enthalpy constants
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
from .base import Component
|
|
3
|
+
from processpi.units import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Toluene(Component):
|
|
7
|
+
name = "Toluene"
|
|
8
|
+
formula = "C7H8"
|
|
9
|
+
molecular_weight = 92.138
|
|
10
|
+
_critical_temperature = Temperature(591.8, "K")
|
|
11
|
+
_critical_pressure = Pressure(4.1, "MPa")
|
|
12
|
+
_critical_volume = Volume(0.316, "m3") # Placeholder for critical volume per Kmole
|
|
13
|
+
_critical_zc = 0.264 # Placeholder for critical compressibility factor
|
|
14
|
+
_critical_acentric_factor = 0.264 # Placeholder for critical acentric factor
|
|
15
|
+
_density_constants = [0.8792, 0.27136, 591.75, 0.29241]
|
|
16
|
+
_specific_heat_constants = [140140,-152.3,0.695,0,0]
|
|
17
|
+
|
|
18
|
+
_viscosity_constants = [-226.08, 6805.7,37.542,-0.060853, 1]
|
|
19
|
+
_thermal_conductivity_constants = [0.20463, -0.00024252, 0,0,0]
|
|
20
|
+
_vapor_pressure_constants = [76.945, -6729.8, -8.179, 0.0000053017, 2]
|
|
21
|
+
_enthalpy_constants = [4.9507E-7, 0.37742, 178.18, 4.3246, 0] # Placeholder for enthalpy constants
|
|
22
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from .base import Component
|
|
2
|
+
from processpi.units import *
|
|
3
|
+
from math import *
|
|
4
|
+
|
|
5
|
+
class Water(Component):
|
|
6
|
+
name = "Water"
|
|
7
|
+
formula = "H2O"
|
|
8
|
+
molecular_weight = 18.015
|
|
9
|
+
_critical_temperature = Temperature(647.096, "K")
|
|
10
|
+
_critical_pressure = Pressure(22.06, "MPa")
|
|
11
|
+
_density_constants = [-13.851, 0.654, -0.00191, 0.000002]
|
|
12
|
+
_specific_heat_constants = [276370,-2090.10,8.125,-0.014116,9.37e-6]
|
|
13
|
+
_viscosity_constants = [-52.843, 3703.6, 5.866, -5.879e-29, 10]
|
|
14
|
+
_thermal_conductivity_constants = [-0.432, 0.0057255, -0.000008078,1.861E-09,0]
|
|
15
|
+
_vapor_pressure_constants = [73.649, -7258.2, -7.3037, 4.1653E-06, 2]
|
|
16
|
+
_enthalpy_constants = [5.2053E-7, 0.3199, -0.212, 0.25795, 0]
|
|
17
|
+
|
|
18
|
+
def density(self, temperature: Temperature = None) -> Density:
|
|
19
|
+
temperature = temperature or self.temperature
|
|
20
|
+
Tr = temperature.value / self._critical_temperature.value
|
|
21
|
+
tou = 1 - Tr
|
|
22
|
+
den = 17.863 + (58.606 * (tou**0.35)) - (95.396 * (tou**(2/3))) + (213.89 * tou) - (141.26 * (tou**(4/3)))
|
|
23
|
+
den = den * self.molecular_weight
|
|
24
|
+
return Density(den, "kg/m3")
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# processpi/pipelines/base.py
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from typing import Any, Dict
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PipelineBase(ABC):
|
|
8
|
+
"""
|
|
9
|
+
Abstract base class for all pipeline-related calculations in ProcessPI.
|
|
10
|
+
|
|
11
|
+
Notes:
|
|
12
|
+
- Keeps parameter handling and validation generic.
|
|
13
|
+
- Specific pipe attributes (diameter, schedule, roughness, material)
|
|
14
|
+
are defined in `pipes.py` and should be used there.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, **kwargs):
|
|
18
|
+
"""
|
|
19
|
+
Initialize a pipeline calculation with input parameters.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
**kwargs: Arbitrary keyword arguments for inputs.
|
|
23
|
+
"""
|
|
24
|
+
self.params = kwargs
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def calculate(self) -> Dict[str, Any]:
|
|
28
|
+
"""
|
|
29
|
+
Perform the pipeline calculation.
|
|
30
|
+
|
|
31
|
+
Must be implemented by subclasses.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
dict: Results of the calculation in key-value format.
|
|
35
|
+
"""
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
def get_param(self, key: str, default: Any = None) -> Any:
|
|
39
|
+
"""
|
|
40
|
+
Safely fetch an input parameter.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
key (str): Parameter name.
|
|
44
|
+
default (Any): Default value if key not found.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Any: The value of the parameter or the default.
|
|
48
|
+
"""
|
|
49
|
+
return self.params.get(key, default)
|
|
50
|
+
|
|
51
|
+
def validate_required(self, required_keys: list):
|
|
52
|
+
"""
|
|
53
|
+
Ensure that required input parameters are present.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
required_keys (list): List of required parameter names.
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
ValueError: If any required parameter is missing.
|
|
60
|
+
"""
|
|
61
|
+
missing = [k for k in required_keys if k not in self.params]
|
|
62
|
+
if missing:
|
|
63
|
+
raise ValueError(f"Missing required parameters: {', '.join(missing)}")
|
|
64
|
+
|
|
65
|
+
def _getattr(self, attr_name: str, default: Any = None) -> Any:
|
|
66
|
+
"""
|
|
67
|
+
Safely fetch an attribute from the pipeline instance.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
attr_name (str): Name of the attribute.
|
|
71
|
+
default (Any): Default value if attribute not found.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Any: The value of the attribute or the default.
|
|
75
|
+
"""
|
|
76
|
+
return getattr(self, attr_name, default)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# processpi/pipelines/design_rules.py
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Pipeline Design Rules Module
|
|
5
|
+
|
|
6
|
+
This module defines pipeline design rules inspired by industry practices
|
|
7
|
+
(similar to Aspen). It does not contain calculation logic directly,
|
|
8
|
+
but instead integrates functions from processpi.calculations to validate
|
|
9
|
+
pipeline designs against engineering standards.
|
|
10
|
+
|
|
11
|
+
Each function acts as a design "rule" or "check".
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from processpi.calculations.fluids.reynolds_number import ReynoldsNumber
|
|
15
|
+
from processpi.calculations.fluids.friction_factor import ColebrookWhite
|
|
16
|
+
from processpi.calculations.fluids.flow_type import FlowType
|
|
17
|
+
from processpi.calculations.fluids.optimum_pipe_diameter import OptimumPipeDiameter
|
|
18
|
+
from processpi.calculations.pressure.drop import PressureDrop # assumed module
|
|
19
|
+
from processpi.calculations.velocity import Velocity # assumed module
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def check_flow_regime(velocity: float, diameter: float, density: float, viscosity: float) -> str:
|
|
23
|
+
"""
|
|
24
|
+
Rule: Determine if flow is laminar, transition, or turbulent.
|
|
25
|
+
"""
|
|
26
|
+
Re = ReynoldsNumber(velocity, diameter, density, viscosity).calculate()
|
|
27
|
+
return FlowType(Re).calculate()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def check_pressure_drop(flowrate: float, diameter: float, length: float, density: float, viscosity: float, roughness: float) -> float:
|
|
31
|
+
"""
|
|
32
|
+
Rule: Calculate pressure drop across the pipeline.
|
|
33
|
+
"""
|
|
34
|
+
return PressureDrop(flowrate, diameter, length, density, viscosity, roughness).calculate()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def check_friction_factor(Re: float, diameter: float, roughness: float) -> float:
|
|
38
|
+
"""
|
|
39
|
+
Rule: Calculate friction factor using Colebrook-White.
|
|
40
|
+
"""
|
|
41
|
+
return ColebrookWhite(Re, diameter, roughness).calculate()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def recommend_optimum_diameter(flowrate: float, density: float) -> float:
|
|
45
|
+
"""
|
|
46
|
+
Rule: Recommend optimum diameter based on economic sizing correlation.
|
|
47
|
+
"""
|
|
48
|
+
return OptimumPipeDiameter(flowrate, density).calculate()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def check_velocity_limits(velocity: float, fluid_type: str = "liquid") -> bool:
|
|
52
|
+
"""
|
|
53
|
+
Rule: Check if velocity is within recommended design limits.
|
|
54
|
+
|
|
55
|
+
Typical guidelines:
|
|
56
|
+
- Liquids: 1–3 m/s (avoid erosion/cavitation)
|
|
57
|
+
- Gases/steam: 10–20 m/s
|
|
58
|
+
"""
|
|
59
|
+
if fluid_type.lower() == "liquid":
|
|
60
|
+
return 1.0 <= velocity <= 3.0
|
|
61
|
+
elif fluid_type.lower() in ["gas", "steam"]:
|
|
62
|
+
return 10.0 <= velocity <= 20.0
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def check_pressure_drop_limit(pressure_drop: float, limit: float = 10.0) -> bool:
|
|
67
|
+
"""
|
|
68
|
+
Rule: Ensure pressure drop per 100 m of pipe length is within design limits (default 10 kPa/100 m).
|
|
69
|
+
"""
|
|
70
|
+
return pressure_drop <= limit
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def check_design_compliance(flowrate: float, diameter: float, length: float, density: float, viscosity: float, roughness: float, fluid_type: str = "liquid") -> dict:
|
|
74
|
+
"""
|
|
75
|
+
Perform a complete design compliance check.
|
|
76
|
+
Returns a dictionary summarizing pass/fail status of all rules.
|
|
77
|
+
"""
|
|
78
|
+
velocity = Velocity(flowrate, diameter).calculate()
|
|
79
|
+
Re = ReynoldsNumber(velocity, diameter, density, viscosity).calculate()
|
|
80
|
+
flow_regime = FlowType(Re).calculate()
|
|
81
|
+
friction_factor = ColebrookWhite(Re, diameter, roughness).calculate()
|
|
82
|
+
pressure_drop = PressureDrop(flowrate, diameter, length, density, viscosity, roughness).calculate()
|
|
83
|
+
optimum_d = OptimumPipeDiameter(flowrate, density).calculate()
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
"flow_regime": flow_regime,
|
|
87
|
+
"velocity_ok": check_velocity_limits(velocity, fluid_type),
|
|
88
|
+
"pressure_drop_ok": check_pressure_drop_limit(pressure_drop),
|
|
89
|
+
"friction_factor": friction_factor,
|
|
90
|
+
"optimum_diameter_mm": optimum_d,
|
|
91
|
+
}
|