thermofluids 2.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.
@@ -0,0 +1,53 @@
1
+ from thermofluids import Statepoint, Quantity
2
+ from thermofluids.Base import Quantity
3
+ import types
4
+ from CoolProp.CoolProp import PropsSI
5
+
6
+ class Turbine():
7
+ def __init__(self, inlet=None, eta=None, Pout=None, output_name=None, work=None):
8
+ """
9
+ Models a turbine
10
+ :param inlet: [Statepoint] turbine inlet stream
11
+ :param eta: [Quantity] or [float] icentropic efficiency of turbo equipment
12
+ :param Pout: [Quantity] or [float] pressure at outlet of turbine
13
+ :return: [Statepoint] turbine outlet stream
14
+ """
15
+ self.inlet = inlet
16
+ self.eta = eta
17
+ self.Pout = Pout
18
+ self.output_name = output_name
19
+ self.work = work
20
+
21
+ def set_inlet(self, inlet):
22
+ self.inlet = inlet
23
+
24
+ def set_eta(self, eta):
25
+ self.eta = eta
26
+
27
+ def set_Pout(self, Pout):
28
+ self.Pout = Pout
29
+
30
+ def set_output(self, output_name):
31
+ self.output_name = output_name
32
+
33
+ def get_outlet(self):
34
+ assert isinstance(self.inlet, Statepoint), '\'inlet\' must be set to a Statepoint'
35
+ # assert isinstance(self.eta, Quantity or types.FloatType), 'eta must be set to a Quantity or Float'
36
+
37
+ self.outlet = Statepoint(name=self.output_name, fluid=self.inlet.fluid)
38
+ self.outlet.set_source(self.inlet)
39
+ self.outlet.set_m(self.inlet.m)
40
+ self.outlet.set_p(self.Pout)
41
+ try:
42
+ self.outlet.set_c(self.inlet.c)
43
+ except:
44
+ pass
45
+
46
+ outlet_s = Statepoint(name='outlet_s', fluid=self.inlet.fluid)
47
+ outlet_s.set_s(self.inlet.s)
48
+ outlet_s.set_p(self.Pout)
49
+
50
+ self.outlet.set_h(self.inlet.h - self.eta*(self.inlet.h - outlet_s.h))
51
+ self.work = self.outlet.m*(self.inlet.h - self.outlet.h)
52
+
53
+ return self.outlet
@@ -0,0 +1,35 @@
1
+ """
2
+ Manipulations of definition of flow coefficient, Cv=Q*sqrt(SG/dP), to calculate valve performance.
3
+ https://en.wikipedia.org/wiki/Flow_coefficient
4
+ """
5
+ from thermofluids import Quantity
6
+
7
+
8
+ def get_valve_flow_rate(statepoint, dP, C_v, units='kg*s^-1', debug=False):
9
+ flow_gpm = Quantity((C_v * (dP.to('psi') / (statepoint.rho / Quantity(1000., 'kg*m^-3')))**0.5).magnitude, 'gal*min^-1')
10
+ if debug:
11
+ print(('\tdP [psi]: %f' % dP.to('psi')))
12
+ print(('\tDensity: %f' % (statepoint.rho / Quantity(1000., 'kg*m^-3'))))
13
+ print(('\tFlow: %f' % flow_gpm))
14
+ return (flow_gpm * Quantity(0.00379, 'm^3*gal^-1') / Quantity(60., 's*min^-1') * statepoint.rho).to(units)
15
+
16
+
17
+ def get_valve_dP(statepoint, C_v, units='bar'):
18
+ dP = (statepoint.m / statepoint.rho).to('gal/min')**2. * statepoint.rho / Quantity(1000., 'kg*m^-3') / C_v ** 2.
19
+ return Quantity(dP.magnitude, 'psi').to(units)
20
+
21
+
22
+ def get_valve_C_v(statepoint, dP):
23
+ return ((statepoint.m / statepoint.rho).to('gal/min') * (statepoint.rho / Quantity(1000., 'kg*m^-3') / dP.to('psi'))**0.5).magnitude
24
+
25
+ if __name__ == '__main__':
26
+ from thermofluids.Base import Statepoint
27
+
28
+ C_v = 430.
29
+ sp = Statepoint(fluid='ammonia', p=15., t=80., m=2.)
30
+ dP = get_valve_dP(statepoint=sp, C_v=C_v)
31
+ print(dP)
32
+ mdot = get_valve_flow_rate(statepoint=sp, dP=dP, C_v=C_v)
33
+ print(mdot)
34
+ C_v_check = get_valve_C_v(statepoint=sp, dP=dP)
35
+ print(C_v_check)
@@ -0,0 +1,3 @@
1
+ from thermofluids.ProcessEquipment.Compressor import Compressor
2
+ from thermofluids.ProcessEquipment.Turbine import Turbine
3
+ from thermofluids.ProcessEquipment.Valve import get_valve_flow_rate, get_valve_C_v, get_valve_dP
@@ -0,0 +1,111 @@
1
+ from thermofluids import Statepoint, Quantity
2
+
3
+ def WriteFlow(template, SP, filename, SC):
4
+ text = open(template).read()
5
+ for i in range(0,len(SP),1):
6
+ try:
7
+ try:
8
+ # text = text.replace('T%s<'%(i), '%.3G' %float(SP[i].t) + u'\u2103' + '<')
9
+ text = text.replace(f'T{i}<', f'{SP[i].t.to("degC").magnitude: .3g}\u2103<')
10
+ except AttributeError:
11
+ pass
12
+ try:
13
+ # text = text.replace('M%s<'%(i), '%.4G kg/s<' %float(SP[i].m))
14
+ text = text.replace(f'M{i}<', f'{SP[i].m.to("kg/s").magnitude: .4g} kg/s<')
15
+ except AttributeError:
16
+ pass
17
+ try:
18
+ # text = text.replace('C%s<'%(i), '%.2G wtCon<' %float(SP[i].c))
19
+ text = text.replace(f'C{i}<', f'{SP[i].c: .2g} wtCon<')
20
+ except AttributeError:
21
+ pass
22
+ try:
23
+ # text = text.replace('P%s<'%(i), '%.4G bar<' %float(SP[i].p))
24
+ text = text.replace(f'P{i}<', f'{SP[i].p.to("bar").magnitude: .4g} bar<')
25
+ except AttributeError:
26
+ pass
27
+ try:
28
+ # text = text.replace('H%s<'%(i), '%.2G kJ/kg<' %float(SP[i].h))
29
+ text = text.replace(f'H{i}<', f'{SP[i].h.to("kJ/kg").magnitude: .2g} kJ/kg<')
30
+ except AttributeError:
31
+ pass
32
+ try:
33
+ # text = text.replace('S%s<'%(i), '%.2G kJ/kg-C<' %float(SP[i].s))
34
+ text = text.replace(f'S{i}<', f'{SP[i].s.to("kJ/(kg*delta_degC)").magnitude: .2g} kJ/kg-C<')
35
+ except AttributeError:
36
+ pass
37
+ try:
38
+ if 'humid' not in SP[i].fluid: #humid air has no quality term
39
+ # text = text.replace('X%s<'%(i), '%.2G<' %float(SP[i].x))
40
+ text = text.replace(f'X{i}<', f'{SP[i].x.to("").magnitude: .2g}<')
41
+ except AttributeError:
42
+ pass
43
+ except ValueError:
44
+ pass
45
+ except ValueError as e:
46
+ raise ValueError(f'Error diagramming statepoint {i}', e)
47
+
48
+ keys = SC.keys()
49
+ for key in keys:
50
+ try:
51
+ text = text.replace(str(key), str(SC[key]))
52
+ except AttributeError:
53
+ pass
54
+
55
+ flow = open(filename, 'w', encoding='utf-8')
56
+ flow.write(text)
57
+ flow.close()
58
+
59
+ def WriteFlowEnglish(template, SP, filename, SC):
60
+ text = open(template).read()
61
+ for i in range(0,len(SP),1):
62
+ try:
63
+ # text = text.replace('T%s<'%(i), '%.3G' %float(SP[i].t.toEnglish()) + u'\u2109' + '<')
64
+ text = text.replace(f'T{i}<', f'{SP[i].t.to("degF")}<')
65
+ except AttributeError:
66
+ pass
67
+ try:
68
+ # text = text.replace('M%s<'%(i), '%.3G lb/s<' %float(SP[i].m.toEnglish()))
69
+ text = text.replace(f'M{i}<', f'{SP[i].m.to("lb/s")}<')
70
+ except AttributeError:
71
+ pass
72
+ try:
73
+ # text = text.replace('C%s<'%(i), '%.2G <' %float(SP[i].c))
74
+ text = text.replace(f'C{i}<', f'{SP[i].c: .2g} wtCon<')
75
+ except AttributeError:
76
+ pass
77
+ try:
78
+ # text = text.replace('P%s<'%(i), '%.3G psi<' %float(SP[i].p.toEnglish()))
79
+ text = text.replace(f'P{i}<', f'{SP[i].p.to("psi")}<')
80
+ except AttributeError:
81
+ pass
82
+ try:
83
+ # text = text.replace('H%s<'%(i), '%.2G Btu/lb<' %float(SP[i].h.toEnglish()))
84
+ text = text.replace(f'H{i}<', f'{SP[i].h.to("BTU/lb")}<')
85
+ except AttributeError:
86
+ pass
87
+ try:
88
+ # text = text.replace('S%s<'%(i), '%.2G Btu/lb-F<' %float(SP[i].s.toEnglish()))
89
+ text = text.replace(f'S{i}<', f'{SP[i].s.to("BTU/(lb*delta_degF)")}<')
90
+ except AttributeError:
91
+ pass
92
+ try:
93
+ if 'humid' not in SP[i].fluid: # humid air has no quality term
94
+ # text = text.replace('X%s<'%(i), '%.2G<' %float(SP[i].x))
95
+ text = text.replace(f'X{i}<', f'{SP[i].x.to("").magnitude: .2g}<')
96
+
97
+ except AttributeError:
98
+ pass
99
+ except ValueError:
100
+ pass
101
+
102
+ keys = SC.keys()
103
+ for key in keys:
104
+ try:
105
+ text = text.replace(str(key), str(SC[key]))
106
+ except AttributeError:
107
+ pass
108
+
109
+ flow = open(filename, 'w')
110
+ flow.write(text)
111
+ flow.close()
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,3 @@
1
+ from .Base.Statepoint import Statepoint
2
+ from .Base.Quantity import Quantity
3
+ from .Base.Quantity import Quantity, pint_unit_registry
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.5
2
+ Name: thermofluids
3
+ Version: 2.0.0
4
+ Summary: Physically-consistent thermal and fluids modeling tools
5
+ Project-URL: Homepage, https://gitlab.com/ericksonla/thermofluids
6
+ Author: Luke Erickson, Russell Goldfarbmuren
7
+ Author-email: russell@rebound-tech.com
8
+ License-Expression: MIT
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >3.11
12
+ Requires-Dist: coolprop
13
+ Requires-Dist: pint
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Thermofluids
17
+
18
+ Thermofluids makes modeling thermofluid systems easier. The essential element is the `statepoint`. `statepoint` objects work like physical statepoints: they have two independent variables, many dependent variables, and sometimes extensive variables. You can use them like this:
19
+ ````python
20
+ sp = Statepoint(fluid='water', # define a fluid
21
+ t=25.0, # define one independent variable
22
+ p=1.0, # define a second independent variable
23
+ m=0.1) # define extensive varible
24
+
25
+ sp.rho, sp.h, sp.visc
26
+ # (<Quantity(997.047039, 'kilogram / meter ** 3')>, <Quantity(104.918893, 'kilojoule / kilogram')>, <Quantity(0.000890022674, 'kilogram / meter / second')>)
27
+ ````
28
+
29
+ A set of functions are made available to analyze statepoint systems in physically meaningful ways.
@@ -0,0 +1,32 @@
1
+ thermofluids/__init__.py,sha256=8CQPY_pPZ_2YR5YtHXNnM6SZKJjnKz-MaiHVlMfubQk,131
2
+ thermofluids/Base/Quantity.py,sha256=BJzbv40aArDHvCToMopktiejjnYJtJSp_6Vi2Y3h8fc,438
3
+ thermofluids/Base/Statepoint.py,sha256=TSX4y01u4A7M_icWOzil4wQnr1S1Sjp4ZSUgEl-sDis,51734
4
+ thermofluids/Base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ thermofluids/Base/thermofluids_registry.txt,sha256=ngeUgAEP10I9LZU5OnDgjp7SRa2SZsWiEs7Nt9r7ADo,127
6
+ thermofluids/Fluids/Drag.py,sha256=BW8e0GxGP9MyRLNPBfFxoS23NACWoeUU8KE60qztwAo,6798
7
+ thermofluids/Fluids/Moody.py,sha256=bjes0IjehKE-oEi7oGe1IuUz00clPosXzUgbhuhGxZ4,1761
8
+ thermofluids/Fluids/PressureDrop.py,sha256=k1Rgz_WvUo5RKqmT-x87B8aVkJC8CGWqfoFrQOFzIk4,13059
9
+ thermofluids/Fluids/Re.py,sha256=6mbmKVMlOl14k7D1e0fe55KRoa1KTIGBU9IN6ADWfNU,3763
10
+ thermofluids/Fluids/__init__.py,sha256=k0gTYO3okjUznTK9NmtXU4oQUxbMfwYddMZSqADbX9Q,361
11
+ thermofluids/HeatTransfer/Gr.py,sha256=dSztVuazHJ5MlEjfey6lgNoW9QRxcmP1D4dudlEiL-o,365
12
+ thermofluids/HeatTransfer/NTU.py,sha256=OSTXam2T9kwnuyVEHCjZQx-6g8AdEwc4zBPIOw9zL8E,1102
13
+ thermofluids/HeatTransfer/Nusselt.py,sha256=bICchSw-0nWGGzffomi2lljKIJz_KVQBj3CU9aw3Kac,2486
14
+ thermofluids/HeatTransfer/Ra.py,sha256=wlNaVwagmNwO0nHZ6mRzwnNay3hggbHsH9-2W6T8-58,819
15
+ thermofluids/HeatTransfer/TwoPhase.py,sha256=yl5Idq8PvVv5bIw437b-IBKostEuTJlnsWpzfLJNZUs,9537
16
+ thermofluids/HeatTransfer/__init__.py,sha256=BqxMzlHV0p4OiQCu3d-DveVnAgX2DHV9uvO6bVDVzZQ,315
17
+ thermofluids/HeatTransfer/lmtd.py,sha256=afqicephB-Z0QjVyN-Se0V4tzf83m9Ve6SMJ3L5m6Gw,959
18
+ thermofluids/ProcessEquipment/Column.py,sha256=G223CtU4FX_BL-eA5LJosbsaARdLpGw0_-EXOuJ-_Ok,50879
19
+ thermofluids/ProcessEquipment/Compressor.py,sha256=-4DCwryWvB4WRyln2ui3scJz7W9UkTi1AZfpCPh09Lw,6841
20
+ thermofluids/ProcessEquipment/Ejector.py,sha256=05kzO7cg2zm-Nd5qlyb0638qiQQs6WO_ofRWijUrtoA,5716
21
+ thermofluids/ProcessEquipment/HeatExchanger.py,sha256=z2KEcW1k2PJRyjtXZ5JDwIQ5Wy87-y-aFYgldxEBIHE,5968
22
+ thermofluids/ProcessEquipment/IsoCompressor.py,sha256=d2AUENbt9zximAhDfNGacPrxjeX_WzCL3g5iG28oEkY,4880
23
+ thermofluids/ProcessEquipment/Pipe.py,sha256=6EkNssz929K4z0tLuBA1iuCdlyPH52EVq9-vHkJF2Kg,458
24
+ thermofluids/ProcessEquipment/Pump.py,sha256=v5ui1Z7vwO-YAEpt_VDcya3KRxT6hpHzimO2fYUzEwI,6172
25
+ thermofluids/ProcessEquipment/Turbine.py,sha256=GDYRK_VsAnBKfpbNt6YRFSVAxK71kkLoLDxIvlOnFSo,1772
26
+ thermofluids/ProcessEquipment/Valve.py,sha256=SYfo5N1HJTSdyFdXPdEjC2Bhv2r9duSAy8d2Lqdky5E,1436
27
+ thermofluids/ProcessEquipment/__init__.py,sha256=GQ6YyM-WyJJhq-9W-mtFdw2-bxSPcARYh0gTmEIywPg,219
28
+ thermofluids/Utilities/FlowDiagram.py,sha256=Tx3sxX4dZITKHnKqQO2tCunibWzm42lzH7nf-7IT_jw,4377
29
+ thermofluids/Utilities/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
30
+ thermofluids-2.0.0.dist-info/METADATA,sha256=_fH91j23jgQ983MtuC6miLTJxF6acqafJYk4JsmtVGw,1332
31
+ thermofluids-2.0.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
32
+ thermofluids-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any