iTMDpy 1.4.9__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,803 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Tue May 28 10:12:44 2024
4
+
5
+ @author: Folkers
6
+ """
7
+
8
+ """
9
+ Tool for the inverse design of centrifugal compressors. Starting at a defined inlet
10
+ state and a compression task an appropiate machine design is chosen through
11
+ the so-called process maps or the Cordier diagram. This design is refined
12
+ through a meanline analysis and the performance of the designed machine is
13
+ estimated through the use of loss models.
14
+
15
+ The tool requires either pyfluids, or carbatpy and a Refprop installation.
16
+ """
17
+
18
+ "Ensuring the correct files are imported"
19
+ import os.path
20
+ import sys
21
+ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
22
+
23
+
24
+ "Import of the necessary modules and functions/classes"
25
+ import numpy as np
26
+ import matplotlib.pyplot as plt
27
+ import math
28
+ import pandas as pd
29
+ import carbatpy as cb
30
+ import copy
31
+ from CoolProp.CoolProp import AbstractState # adjust import to match your usage
32
+ from scipy.optimize import fsolve
33
+
34
+ from Lib.CompressorVelocityTriangles import CentrifugalCompressorVelocityTriangles
35
+ from Lib.CompressorTFGeometry import CompressorTransferFunctionGeometry
36
+ from Lib.Thermodynamics import Compressor_Thermodynamics, ThermodynamicProperties, IsentropicStates
37
+ from Lib.Impeller import CentrifugalCompressorImpeller
38
+ from Lib.Diffusor import CentrifugalCompressorDiffusor
39
+ from Lib.Lossmodel import LossModelOh
40
+ from Lib.Efficiency import CompressorEfficiency
41
+ from Lib.CompressorChokeLimit import ImpellerChoke, DiffusorChoke
42
+
43
+
44
+
45
+ def build_deepcopy_memo(obj, memo=None, seen=None, NonCopyableTypes=(AbstractState,)):
46
+ """Recursively walk obj's attribute/container tree and register any
47
+ instance of NonCopyableTypes in memo so that copy.deepcopy will reuse
48
+ the existing reference instead of trying (and failing) to copy it."""
49
+ if memo is None:
50
+ memo = {}
51
+ if seen is None:
52
+ seen = set()
53
+
54
+ if id(obj) in seen:
55
+ return memo
56
+ seen.add(id(obj))
57
+
58
+ if isinstance(obj, NonCopyableTypes):
59
+ memo[id(obj)] = obj
60
+ return memo
61
+
62
+ if isinstance(obj, dict):
63
+ for k, v in obj.items():
64
+ build_deepcopy_memo(k, memo, seen, NonCopyableTypes)
65
+ build_deepcopy_memo(v, memo, seen, NonCopyableTypes)
66
+ elif isinstance(obj, (list, tuple, set)):
67
+ for item in obj:
68
+ build_deepcopy_memo(item, memo, seen, NonCopyableTypes)
69
+ elif hasattr(obj, "__dict__"):
70
+ for v in vars(obj).values():
71
+ build_deepcopy_memo(v, memo, seen, NonCopyableTypes)
72
+
73
+ return memo
74
+
75
+
76
+
77
+ "Class Definition"
78
+ class inverseCompressorDesignTool:
79
+ """This class utilizes an inverse approach to design a compressor.
80
+ The machine type and its basic configuration are selected based on the
81
+ given compression task. The machine is then designed and its performance
82
+ estimated through mean line analysis.
83
+
84
+ Parameters:
85
+ - VanedDiffusor(boolean, optional): wether a vaned diffusor is used
86
+ in the design. Default is True.
87
+ - IsentropicWorkCoefficient(float, optional): user defined isentropic
88
+ work coefficient (anglo-american definition). Default is 0.8.
89
+ - FlowCoefficient(float, optional): user defined flow coefficient.
90
+ Default is None for automatic selection by the method.
91
+ - CircumferentialMachNumber (float, optional): user defined
92
+ circumferential Mach number of the impeller. Default is 0.8.
93
+ - PropertyToolbox (string, optional): Selection of the fluid property
94
+ model to be used in the method. Options are coolprop (default) for
95
+ use of CoolProp (or Refprop via the CoolPorp low-level interface)
96
+ and refprop for the use of RefProp via the carbatpy wrapper.
97
+ """
98
+
99
+
100
+
101
+
102
+ def __init__(self, PropertyToolbox = "coolprop"):
103
+ """Initialisation of the inverseCompressorDesignTool class.
104
+
105
+ Parameters:
106
+ - PropertyToolbox (string, optional): Selection of the fluid property
107
+ model to be used in the method. Options are coolprop (default) for
108
+ use of CoolProp (or Refprop via the CoolPorp low-level interface)
109
+ and refprop for the use of RefProp via the carbatpy wrapper."""
110
+
111
+
112
+ self.PropertyToolbox = PropertyToolbox
113
+ return
114
+
115
+
116
+
117
+
118
+ def PolytropicEfficiencyCalculation(self, eta_p, p, T):
119
+
120
+ Steps = 1000
121
+ PressureStep = (p[1]-p[0])/Steps
122
+
123
+ p1 = p[0]
124
+ T1 = T[0]
125
+ State1 = self.Thermo.setState([p[0], T[0]], 'PT')
126
+ for step in range(Steps):
127
+ v = State1.sp_volume
128
+ y = v*PressureStep
129
+ del_h = y/eta_p[0]
130
+ p1 = p1+PressureStep
131
+ State1 = self.Thermo.setState([p1, State1.enthalpy+del_h], 'PH')
132
+ T1 = State1.temperature
133
+
134
+ return T1-T[1]
135
+
136
+
137
+ def designCompressor(self, WorkingFluid, WorkingFluidComposition, InletState, OutletPressure, MassFlow,
138
+ VanedDiffusor = True, IsentropicWorkCoefficient = 0.8, FlowCoefficient = None,
139
+ CircumferentialMachNumber = 0.875, SpecificSpeed = None, SpecificDiameter = None, GearedCompressor = False,
140
+ MaxIterations = 100, Plot=False):
141
+ """
142
+ Method for the design of a compressor.
143
+
144
+ Parameters:
145
+ - WorkingFluid (string): Working fluid of the compression. Can be a
146
+ single fluid or a mixture.
147
+ Has to be formated according to the thermofynamic property toolbox.
148
+ - Refprop: "Fluid1*Fluid2*Fluid3"
149
+ - Coolprop: ["Fluid1", "Fluid2", "Fluid3"]
150
+ - WorkingFluidComposition (list): List of the molar fractions of the
151
+ fluid components defined in WorkingFluid. Must add up to 1.
152
+ - InletState (class): Thermodynamic state of the working fluid at
153
+ the compressors inlet. Must be caclulated via the
154
+ ThermodynamicProperties class in this package.
155
+ - OutletPressure (float): Pressure of the working fluid at the
156
+ compressor outlet.
157
+ - MassFlow (float): Mass flow of the working fluid through the
158
+ compressor.
159
+ - VanedDiffusor (boolean, optional): Whether a vaned diffuser (True)
160
+ or vaneless diffuser is used in the design. Default is a vaned
161
+ diffuser.
162
+ - IsentropicWorkCoefficient (float, optional): Maximum isentropic
163
+ work coefficient of the compressor stages. Default is 0.8.
164
+ - FlowCoefficient (float, optional): Flow coefficient to be used in
165
+ all stages. Default is None, and the method selects the flow
166
+ coefficient.
167
+ - CircumferentialMachNumber (float, optional): Circumferential
168
+ Mach number of the first stage. Default is 0.875.
169
+ - SpecificSpeed (float, optional): Specific speed of the first
170
+ stage of the compressor. Default is None, and the method selects
171
+ the specific speed.
172
+ - SpecificDiameter (float, optional): Specific diameter of the first
173
+ stage of the compressor. Default is None, and the method selects
174
+ the specific diameter.
175
+ - GearedCompressor (boolean, optional): Wether an integrally geared
176
+ compressor design or a single-shaft design should be created.
177
+ Default is false, meaning a single-shaft design is created.
178
+ - MaxIterations (integer, optional): Maximum number of calculation
179
+ iterations allowed. Default is 100.
180
+ - Plot (boolean, optional): Wether the results of the design
181
+ process should be displayed in the console and plot pane. Default
182
+ is false, meaning no displayment.
183
+
184
+ """
185
+ if IsentropicWorkCoefficient != None:
186
+ self.IsentropicWorkCoefficient = IsentropicWorkCoefficient
187
+ else:
188
+ self.IsentropicWorkCoefficient = 0.8
189
+ self.VanedDiffusor = VanedDiffusor
190
+ self.FlowCoefficientAim = FlowCoefficient
191
+ if CircumferentialMachNumber != None:
192
+ self.Mau = CircumferentialMachNumber
193
+ else:
194
+ self.Mau = 0.875
195
+
196
+ EfficiencyConvergence = 10**-5 # Convergence criterium, maximum permissable difference in efficiency between iterations
197
+
198
+ if self.PropertyToolbox=="refprop":
199
+ self._cbFluid = cb.fprop.init_fluid(WorkingFluid, WorkingFluidComposition) # Fluid property object used in carbatpy's Refprop wrapper
200
+ self.Thermo = ThermodynamicProperties(WorkingFluid, # Class for the calculation of thermodynamic fluid properties
201
+ WorkingFluidComposition,
202
+ PropertyToolbox=self.PropertyToolbox,
203
+ cbFluid=self._cbFluid
204
+ )
205
+ else:
206
+ self._cbFluid = None # Dummy variable for uniformed method calls
207
+ self.Thermo = ThermodynamicProperties(WorkingFluid, # Class for the calculation of thermodynamic fluid properties
208
+ WorkingFluidComposition,
209
+ PropertyToolbox=self.PropertyToolbox,
210
+ )
211
+
212
+ self.InletState = InletState # Storing the inlet state in a class attribute
213
+ MachineInletState = self.InletState # Inlet state of the compressor
214
+ self.MassFlow = MassFlow # Storing the mass flow in a class attribute
215
+ InletVolumeFlow = MassFlow*self.InletState.sp_volume # Volume flow at the compressor inlet
216
+
217
+ # Design point operating conditions for use in performance map calculation
218
+ self.DP_WorkingFluid = WorkingFluid
219
+ self.DP_WorkingFluidComposition = WorkingFluidComposition
220
+ self.DP_InletPressure = self.InletState.pressure
221
+ self.DP_InletTemperature = self.InletState.temperature
222
+ self.DP_OutletPressure = OutletPressure
223
+ self.DP_InletVolumeFlow = InletVolumeFlow
224
+ self.DP_InletState = self.InletState
225
+
226
+ IsentropicOutletState = self.Thermo.setState([OutletPressure, self.InletState.entropy], "PS") # Outlet state for an isentropic compression
227
+
228
+ # Dictionary for the storage of the design classes
229
+ DesignResults = {
230
+ 'BasicParameters': [],
231
+ 'VelocityTriangles': [],
232
+ 'Thermodynamics': [],
233
+ 'Impellers': [],
234
+ 'Diffusors': [],
235
+ 'Losses': [],
236
+ 'Efficiencies': []
237
+ }
238
+ Pressure3 = [] # List for the outlet pressure of each stage
239
+ p_low = InletState.pressure*1.0001
240
+ p_high = OutletPressure*1.0001
241
+
242
+ if GearedCompressor==True: # Designing an integrally-geared compressor
243
+ StageNumber = np.ceil( (IsentropicOutletState.enthalpy-self.InletState.enthalpy) / (self.IsentropicWorkCoefficient*self.Mau**2*self.InletState.speed_of_sound**2) ) # Calculating the necessary number of stages based on the isentropic compression process
244
+ for i in range(int(StageNumber)): # Filling the dictionary with the correct number of classes as dummies for later reassignment
245
+ DesignResults['BasicParameters'].append(0)
246
+
247
+ StageEnthalpyIncrease = (IsentropicOutletState.enthalpy-self.InletState.enthalpy)/StageNumber # Isentropic stagewise enthalpy increase resulting from the stage number
248
+ for i in range(int(StageNumber)): # Loop over all stages
249
+ DesignResults['BasicParameters'][i] = CompressorTransferFunctionGeometry(MaximumMachNumber=self.Mau, PropertyToolbox=self.PropertyToolbox, cbFluid=self._cbFluid) # Initialization of the class for basic parameter selection
250
+ if i > 0:
251
+ StageInletState = self.Thermo.setState([self.InletState.enthalpy+StageEnthalpyIncrease*(i), self.InletState.entropy], "HS") # Updating the stage inlet state after the first stage
252
+ else:
253
+ StageInletState = InletState
254
+ StageOutletPressure = self.Thermo.setState([StageInletState.enthalpy+StageEnthalpyIncrease, StageInletState.entropy], "HS").pressure # Outlet pressure of the current stage
255
+ DesignResults['BasicParameters'][i].designIntegrallyGeared(StageInletState, StageOutletPressure, WorkingFluid, WorkingFluidComposition, self.MassFlow, InletState, OutletPressure, SpecificSpeed=SpecificSpeed) # Selection of the basic design parameters for each stage
256
+ # DesignResults['BasicParameters'].append(self.BasicParameters) # Saving the basic parameters in the results dictionary
257
+ DesignResults['BasicParameters'][i].StageNumber = int(StageNumber) # Setting the correct number of stages for the individual stages
258
+
259
+ Pressure3.append(StageOutletPressure)
260
+
261
+ if GearedCompressor==False: # Designing a single shaft compressor
262
+ self.BasicParameters = CompressorTransferFunctionGeometry(MaximumMachNumber=self.Mau, PropertyToolbox=self.PropertyToolbox, cbFluid=self._cbFluid) # Initialization of the class for basic parameter selection
263
+ self.BasicParameters.designSingleShaft(InletState, OutletPressure, WorkingFluid, WorkingFluidComposition, self.MassFlow, SpecificSpeed=SpecificSpeed, SpecificDiameter=SpecificDiameter) # Selection of the basic design parameters for each stage
264
+ # InletState, OutletPressure, WorkingFluid, WorkingFluidComposition, MassFlow, SpecificSpeed = None
265
+ for i in range(self.BasicParameters.StageNumber): # Saving the basic parameter class for each stage for uniformity
266
+ DesignResults['BasicParameters'].append(self.BasicParameters)
267
+
268
+ for i in range(DesignResults['BasicParameters'][0].StageNumber):
269
+ if self.PropertyToolbox=="refprop":
270
+ StageOutletEnthalpy = self.InletState.enthalpy + (i+1)*DesignResults['BasicParameters'][0].StageEnthalpyIncrease
271
+ p_i = self.Thermo.PressureFromHS(self.Thermo, StageOutletEnthalpy, self.InletState.entropy, p_low, p_high)
272
+ Pressure3.append(p_i)
273
+ p_low = p_i*1.0001
274
+ else:
275
+ StageOutletEnthalpy = self.InletState.enthalpy+(i+1)*DesignResults['BasicParameters'][0].StageEnthalpyIncrease
276
+ StageOutletState = self.Thermo.setState([StageOutletEnthalpy, self.InletState.entropy], "HS")
277
+ Pressure3.append(StageOutletState.pressure)
278
+
279
+ for i in range(DesignResults['BasicParameters'][0].StageNumber): # Filling the dictionary with the correct number of classes as dummies for later reassignment
280
+ DesignResults['VelocityTriangles'].append(0)
281
+ DesignResults['Thermodynamics'].append(0)
282
+ DesignResults['Impellers'].append(0)
283
+ DesignResults['Diffusors'].append(0)
284
+ DesignResults['Losses'].append(0)
285
+ DesignResults['Efficiencies'].append(0)
286
+
287
+ self.EstimatedIsentropicEfficiency = np.zeros(DesignResults['BasicParameters'][0].StageNumber)+DesignResults['BasicParameters'][0].EfficiencyEstimate # Efficiency estimation as starting value for the design process
288
+ self.IsentropicEfficiency = [DesignResults['BasicParameters'][0].EfficiencyEstimate] # Starting values of efficiency for the criterion of convergence
289
+
290
+
291
+ "Iteration of the velocity triangles, thermodynamics, geometry and loss calculations to create the design"
292
+ self.Iterations = 0 # Variable tracking the number of run iterations
293
+ MinIterations = 5 # Minimum number of iterations to avoid premature end of calculations
294
+ self.StageEfficiency = np.zeros(DesignResults['BasicParameters'][0].StageNumber)+self.EstimatedIsentropicEfficiency # List for the isentropic efficiency of each stage
295
+
296
+ for i in range(DesignResults['BasicParameters'][0].StageNumber): # Initializing the design classes
297
+ DesignResults['VelocityTriangles'][i] = CentrifugalCompressorVelocityTriangles()
298
+ DesignResults['Impellers'][i] = CentrifugalCompressorImpeller()
299
+ DesignResults['Diffusors'][i] = CentrifugalCompressorDiffusor()
300
+
301
+ Convergence = False # Variable tracking the reaching of a converged design solution
302
+ while Convergence == False: # Iterations until convergence is reached
303
+ StageInletState = self.InletState # Inlet conditions of the first stage
304
+
305
+ for i in range(DesignResults['BasicParameters'][0].StageNumber):
306
+ # Calculation of the necessary flow velocities
307
+
308
+ if self.Iterations == 0:
309
+ IsentropicThermodynamics = IsentropicStates(StageInletState, Pressure3, WorkingFluid, WorkingFluidComposition, (i+1), PropertyToolbox=self.PropertyToolbox, cbFluid=self._cbFluid)
310
+ if i == 0:
311
+ DesignResults['VelocityTriangles'][i].design(DesignResults['BasicParameters'][i], IsentropicThermodynamics, IsentropicEfficiency = self.StageEfficiency[i], FlowCoefficient = self.FlowCoefficientAim, Plot=False) # Calculation for the first stage to set the flow coefficient for all stages
312
+ else:
313
+ DesignResults['VelocityTriangles'][i].design(DesignResults['BasicParameters'][i], IsentropicThermodynamics, IsentropicEfficiency = self.StageEfficiency[i], FlowCoefficient = DesignResults['VelocityTriangles'][0].DesignFlowCoefficient, Plot=False) # Calculation ofr the later stages using the first stage flow coefficient
314
+ else:
315
+ if i == 0:
316
+ DesignResults['VelocityTriangles'][i].design(DesignResults['BasicParameters'][i], DesignResults['Efficiencies'][i], FlowCoefficient = self.FlowCoefficientAim, Plot=False) # Calculation for the first stage to set the flow coefficient for all stages
317
+ else:
318
+ DesignResults['VelocityTriangles'][i].design(DesignResults['BasicParameters'][i], DesignResults['Efficiencies'][i], FlowCoefficient = DesignResults['VelocityTriangles'][0].DesignFlowCoefficient, Plot=False) # Calculation ofr the later stages using the first stage flow coefficient
319
+
320
+ # Calculation of the thermodynamic states of the working fluid
321
+ DesignResults['Thermodynamics'][i] = Compressor_Thermodynamics(StageInletState, WorkingFluid, WorkingFluidComposition, PropertyToolbox=self.PropertyToolbox, cbFluid=self._cbFluid)
322
+ if self.Iterations == 0: # Using the estimated efficiency for the first iteration as starting value
323
+ DesignResults['Thermodynamics'][i].calculate(Pressure3[i], DesignResults['VelocityTriangles'][i], self.EstimatedIsentropicEfficiency[i])
324
+ else: # Using the calculated geometries for the following iterations
325
+ DesignResults['Thermodynamics'][i].calculate_setGeometryAndPressure(DesignResults['VelocityTriangles'][i], DesignResults['BasicParameters'][i], DesignResults['Impellers'][i], DesignResults['Diffusors'][i], self.MassFlow, Pressure3[i])
326
+
327
+ # Design of the impellers geometry
328
+ DesignResults['Impellers'][i].design(DesignResults['BasicParameters'][i], DesignResults['VelocityTriangles'][i], DesignResults['Thermodynamics'][i], self.MassFlow)
329
+
330
+ # Design of the diffusor
331
+ if self.VanedDiffusor == True: # Design of a vaned diffusor
332
+ DesignResults['Diffusors'][i].design_VanedDiffusor(DesignResults['BasicParameters'][i], DesignResults['VelocityTriangles'][i], DesignResults['Impellers'][i], DesignResults['Thermodynamics'][i])
333
+ else: # Design of a vaneless diffusor
334
+ DesignResults['Diffusors'][i].design_UnvanedDiffusor(DesignResults['BasicParameters'][i], DesignResults['VelocityTriangles'][i], DesignResults['Impellers'][i], DesignResults['Thermodynamics'][i])
335
+
336
+ # Calculation of the internal losses
337
+ DesignResults['Losses'][i] = LossModelOh(DesignResults['Thermodynamics'][i], DesignResults['Impellers'][i], DesignResults['Diffusors'][i], DesignResults['VelocityTriangles'][i])
338
+ DesignResults['Losses'][i].calculate(DesignResults['BasicParameters'][i], DesignResults['VelocityTriangles'][i], DesignResults['Thermodynamics'][i], DesignResults['Impellers'][i], DesignResults['Diffusors'][i], self.VanedDiffusor)
339
+
340
+ # Calculation of the thermodynamic states and efficiency of the stage based on the losses
341
+ DesignResults['Efficiencies'][i] = CompressorEfficiency(WorkingFluid, WorkingFluidComposition, PropertyToolbox=self.PropertyToolbox, cbFluid=self._cbFluid)
342
+ DesignResults['Efficiencies'][i].DesignPoint(DesignResults['VelocityTriangles'][i], DesignResults['Thermodynamics'][i], DesignResults['Diffusors'][i], DesignResults['Losses'][i])
343
+ StageInletState = DesignResults['Efficiencies'][i].State3 # Update of the stage inlet state for the next stage
344
+
345
+ # Large reductions of the efficiency between iterations may lead to self intensifying efficiency decline, therefor the decrease of efficiency iterations-wise is limited to a drop of 5%
346
+ if DesignResults['Efficiencies'][i].IsentropicEfficiency >= 0.95*self.StageEfficiency[i]: # Check, wether the efficiency decreased significantly since the last iteration
347
+ self.StageEfficiency[i] = DesignResults['Efficiencies'][i].IsentropicEfficiency # For moderate decreases the calculated efficiency is maintained as is
348
+ else:
349
+ self.StageEfficiency[i] = 0.95*self.StageEfficiency[i] # For large decreases the decrease is limited to 5%
350
+ # End of the loop over all stages
351
+ self.Iterations = self.Iterations+1 # Counter of iterations is raised by 1 after all stages are calculated
352
+
353
+ IsentropicEfficiencyLastIteration = (IsentropicOutletState.enthalpy-self.InletState.enthalpy)/(DesignResults["Efficiencies"][-1].State3.enthalpy-self.InletState.enthalpy) # Isentropic efficiency of the compressor in the latest iteration
354
+
355
+ if IsentropicEfficiencyLastIteration < 0.95*self.IsentropicEfficiency[-1]: # Limiting the update towards lower efficiency to avoid negative feedback loops
356
+ IsentropicEfficiencyLastIteration = 0.95*self.IsentropicEfficiency[-1]
357
+ self.IsentropicEfficiency.append(IsentropicEfficiencyLastIteration) # Saving the efficiency found in the latest iteration
358
+
359
+ if abs(self.IsentropicEfficiency[-1]-self.IsentropicEfficiency[-2]) < EfficiencyConvergence: # Convergence achieved by measure of the set permissable efficiency change between iterations
360
+ Convergence = True
361
+ if self.Iterations > MaxIterations: # Limiting the number of iterations to the set maximum to avoid endless calculations
362
+ Convergence = True
363
+ if self.Iterations < MinIterations: # Avoiding premature end of calculations
364
+ Convergence = False
365
+
366
+
367
+ self.DPIsentropicEfficiency = self.IsentropicEfficiency[-1] # Saving the isentropic efficiency at dsign conditions in a seperate variable for performance map calculations
368
+
369
+ # Results of the design process
370
+ OutletState = DesignResults["Efficiencies"][-1].State3
371
+
372
+ # Polytropic Efficiency of the compression
373
+ self.PolytropicEfficiency = fsolve(self.PolytropicEfficiencyCalculation, self.IsentropicEfficiency[-1], args=([InletState.pressure, OutletState.pressure], [InletState.temperature, OutletState.temperature]))[0]
374
+
375
+
376
+ # Estimated mass of the compressor
377
+ FatigueStrength = 145e6 # Fatigue strength of EN-GJL-350 (145 N mm^-2)
378
+ Density = 7850 # Density of general steel (7850 kg m^-3)
379
+ SecurityFactor = 2 # Security factor for the casing thickness
380
+ CasingThickness = (OutletPressure-1e5)*DesignResults['Diffusors'][0].OutletDiameter/(2*FatigueStrength/SecurityFactor) # Casing thickness estimated via the necessary thickness of a cylindrical pipe
381
+ Volume = (DesignResults['BasicParameters'][0].StageNumber+0.5) * (0.5*DesignResults['Impellers'][0].AxialLength*np.pi*(1.1*DesignResults['Diffusors'][0].OutletDiameter+2*CasingThickness)**2) # Volume of the compressor simplified as a cylinder
382
+ Mass = Volume*Density # Compressor mass derived from its volume and material density
383
+
384
+
385
+ if Plot==True:
386
+ # Plot of the resulting velocity triangles
387
+ for i in range(DesignResults['BasicParameters'][0].StageNumber):
388
+ DesignResults['VelocityTriangles'][i].design(DesignResults['BasicParameters'][i], DesignResults['Efficiencies'][i], FlowCoefficient = DesignResults['VelocityTriangles'][i].DesignFlowCoefficient, Plot=True)
389
+
390
+ # Return of the relevant design parameters in the console
391
+ print("")
392
+ print("#####Design Results#####")
393
+ if GearedCompressor == False:
394
+ print("Machine type: Single-shaft centrifugal compressor")
395
+ else:
396
+ print("Machine type: Integrally geared centrifugal compressor")
397
+ print("Specific Speed: " + str(round(DesignResults['BasicParameters'][0].SpecificSpeed, 4)))
398
+ print("Specific Diameter: " + str(round(DesignResults['BasicParameters'][0].SpecificDiameter, 4)))
399
+ print("Machine Work Coefficient: " + str(round(DesignResults['BasicParameters'][0].MachineWorkCoefficient*2, 4)))
400
+ print("Isentropic Work Coefficient: " + str(round(DesignResults['BasicParameters'][0].IsentropicWorkCoefficient*2, 4)))
401
+ print("Work Coefficient: " + str(round(DesignResults['VelocityTriangles'][0].WorkCoefficient*2, 4)))
402
+ print("Circumferential Mach number: " + str(round(DesignResults['BasicParameters'][0].CircumferentialMachNumber, 4)))
403
+ print("Stage Number: " + str(round(DesignResults['BasicParameters'][0].StageNumber, 4)))
404
+ print("Speed: " + str(round(DesignResults['BasicParameters'][0].Speed, 4))+" 1/s")
405
+ print("Impeller Diameter: " + str(round(DesignResults['BasicParameters'][0].ImpellerDiameter, 4))+"m")
406
+ print("Isentropic Efficiency: " + str(round(self.IsentropicEfficiency[-1]*100, 4))+ "%")
407
+ print("Polytropic Efficiency: " + str(round(self.PolytropicEfficiency*100, 4))+ "%")
408
+ print("Flow Coefficient: " + str(round(DesignResults['VelocityTriangles'][0].FlowCoefficient, 4)))
409
+ print("Mass Flow: " + str(round(self.MassFlow, 4))+ " kg/s")
410
+ print("Power: " + str(round(self.MassFlow*(DesignResults["Efficiencies"][-1].State3.enthalpy-self.InletState.enthalpy)/1000, 4))+" kW")
411
+ print("Iterations: " + str(self.Iterations))
412
+ print("Compressor Mass: " + str(round(Mass))+" kg")
413
+ print("")
414
+
415
+ print("Stagewise Isentropic Efficiency")
416
+ for i in range(DesignResults['BasicParameters'][0].StageNumber):
417
+ print("Stage "+str(i+1)+": "+str( round(self.StageEfficiency[i], 3) ))
418
+ print("")
419
+
420
+ # Total fluid properties at compressor inlet
421
+ self.TotalInletState = self.Thermo.setState([self.InletState.enthalpy+DesignResults['VelocityTriangles'][0].Absolute1**2/2, self.InletState.entropy], "HS")
422
+
423
+ print("Slip Factor Design Point: " + str(DesignResults['Impellers'][0].SlipFactor))
424
+ print("Blade Angle 2: " + str(round(DesignResults['Impellers'][0].Beta2Blade*180/np.pi, 4))+"°")
425
+ print("Flow Angle 2: " + str(round(DesignResults['VelocityTriangles'][0].Beta2*180/np.pi, 4))+"°")
426
+ print("Euler Specific Work: " + str(round((DesignResults['VelocityTriangles'][0].Rotational2*DesignResults['VelocityTriangles'][0].Absolute2Rotational/1000), 4))+" kJ/kg")
427
+ print("Total Enthalpy Increase: " + str(round((DesignResults['Efficiencies'][0].TotalState3.enthalpy-DesignResults['Efficiencies'][0].TotalState1.enthalpy)/1000, 4))+" kJ/kg")
428
+ print("")
429
+
430
+ print("Flow ")
431
+ print("Absolute1: " + str(round(DesignResults['VelocityTriangles'][0].Absolute1, 4))+" m/s")
432
+ print("Absolute2: " + str(round(DesignResults['VelocityTriangles'][0].Absolute2, 4))+" m/s")
433
+ print("Absolute3: " + str(round(DesignResults['VelocityTriangles'][0].Absolute3, 4))+" m/s")
434
+ print("Relative1: " + str(round(DesignResults['VelocityTriangles'][0].Relative1, 4))+" m/s")
435
+ print("Relative2: " + str(round(DesignResults['VelocityTriangles'][0].Relative2, 4))+" m/s")
436
+ print("Absolute2Rotational: " + str(round(DesignResults['VelocityTriangles'][0].Absolute2Rotational, 4))+" m/s")
437
+ print("")
438
+ print("Impeller Blade Number: " + str(DesignResults['Impellers'][0].BladeNumber))
439
+ if self.VanedDiffusor == True:
440
+ print("Diffusor Blade Number: " + str(DesignResults['Diffusors'][0].BladeNumber))
441
+
442
+ print(DesignResults['Efficiencies'][0].State3.pressure)
443
+
444
+
445
+ # Returning the outlet state of the last stage and the design parameters
446
+ return OutletState, DesignResults
447
+
448
+
449
+
450
+
451
+ def CalculateCompressor(self, DesignData, WorkingFluid, WorkingFluidComposition, InletState, MassFlow, SpeedFactor = 1, MaxIterations = 100, Plot=False):
452
+ """Method to calculate the performance of a previously designed
453
+ compressor for differing operation parameters.
454
+
455
+ Parameters:
456
+ - DesignData (dict): Dictionary containing the results of the design
457
+ process as returned by the Design method.
458
+ - WorkingFluid (string): Working fluid of the compression. Can be a
459
+ single fluid or a mixture.
460
+ Has to be formated according to the thermofynamic property toolbox.
461
+ - Refprop: "Fluid1*Fluid2*Fluid3"
462
+ - Coolprop: ["Fluid1", "Fluid2", "Fluid3"]
463
+ - WorkingFluidComposition (list): List of the molar fractions of the
464
+ fluid components defined in WorkingFluid. Must add up to 1.
465
+ - InletState (class): Thermodynamic state of the working fluid at
466
+ the compressors inlet. Must be caclulated via the
467
+ ThermodynamicProperties class in this package.
468
+ - MassFlow (float): Mass flow at which the performance is to be
469
+ determined.
470
+ - SpeedFactor (float, optional): Dimensionless rotational speed
471
+ defined as speed/design point speed. Used to set the rotational
472
+ speed at the current operating point, default is one (design point
473
+ speed).
474
+ - MaxIterations (integer, optional): Maximum number of calculation
475
+ iterations allowed. Default is 100.
476
+ - Plot (boolean, optional): Wether the results of the design
477
+ process should be displayed in the console and plot pane. Default
478
+ is false, meaning no displayment.
479
+ """
480
+ EfficiencyConvergence = 10**-5
481
+
482
+ # Extracting design data for each stage
483
+ memo = build_deepcopy_memo(DesignData)
484
+ if self._cbFluid is not None:
485
+ memo[id(self._cbFluid)] = self._cbFluid
486
+ Design = copy.deepcopy(DesignData, memo)
487
+
488
+ # Class for Thermodynamic Property Calculations
489
+ if self.PropertyToolbox=="refprop":
490
+ _cbFluid = cb.fprop.init_fluid(WorkingFluid, WorkingFluidComposition) # Fluid property object used in carbatpy's Refprop wrapper
491
+ self.Thermo = ThermodynamicProperties(WorkingFluid, # Class for the calculation of thermodynamic fluid properties
492
+ WorkingFluidComposition,
493
+ PropertyToolbox=self.PropertyToolbox,
494
+ cbFluid=_cbFluid
495
+ )
496
+ else:
497
+ _cbFluid = None # Dummy variable for uniformed method calls
498
+ self.Thermo = ThermodynamicProperties(WorkingFluid, # Class for the calculation of thermodynamic fluid properties
499
+ WorkingFluidComposition,
500
+ PropertyToolbox=self.PropertyToolbox,
501
+ )
502
+
503
+ InletVolumeFlow= MassFlow/InletState.sp_volume # Inlet volume flow
504
+
505
+ # Variables for iterative calculation
506
+ IsentropicEfficiency = [0, self.DPIsentropicEfficiency] # Starting with the efficiency at design point
507
+ Iterations = 0 # Counter for the number of iterations
508
+
509
+ # Loop Calculating the prformance for the assigned Mass Flow
510
+ # Loop criterion defined by the difference in efficiency to the previous iteration, as well as a maximum number to avoid indefinite calculation
511
+ while abs(IsentropicEfficiency[-1]-IsentropicEfficiency[-2]) > EfficiencyConvergence and Iterations < MaxIterations:
512
+
513
+ # Inlet state of the first stage equals inlet state of machine
514
+ StageInletState = InletState # Inlet Conditions of the first stage
515
+
516
+ # loop over the individual stages
517
+ for i in range(Design['BasicParameters'][0].StageNumber):
518
+ # Recalculating of the flow Velocity Triangles
519
+ try:
520
+ Design['VelocityTriangles'][i].calculate_nonDesignPoint(Design['BasicParameters'][i], MassFlow, Design['Efficiencies'][i], Design['Impellers'][i], Design['Diffusors'][i], SpeedFactor=SpeedFactor, Plot=False) # calculation of the velocity triangles
521
+
522
+ except:
523
+ Design['VelocityTriangles'][i].calculate_nonDesignPoint(Design['BasicParameters'][i], MassFlow, Design['Thermodynamics'][i], Design['Impellers'][i], Design['Diffusors'][i], SpeedFactor=SpeedFactor, Plot=False) # calculation of the velocity triangles
524
+
525
+ # Thermodynamic states along the stage
526
+ Design['Thermodynamics'][i] = Compressor_Thermodynamics(StageInletState, WorkingFluid, WorkingFluidComposition, PropertyToolbox = self.PropertyToolbox) # class initialization
527
+ Design['Thermodynamics'][i].calculate_setGeometry(Design['BasicParameters'][i], Design['VelocityTriangles'][i], Design['Impellers'][i], Design['Diffusors'][i], MassFlow) # calculation of the thermodynamic states
528
+
529
+ # Calculation of the internal losses
530
+ Design['Losses'][i] = LossModelOh(Design['Thermodynamics'][i], Design['Impellers'][i], Design['Diffusors'][i], Design['VelocityTriangles'][i])
531
+ Design['Losses'][i].calculate(Design['BasicParameters'][i], Design['VelocityTriangles'][i], Design['Thermodynamics'][i], Design['Impellers'][i], Design['Diffusors'][i], self.VanedDiffusor)
532
+
533
+ # Calculation of the thermodynamic states and efficiency of the stage based on the losses
534
+ Design['Efficiencies'][i] = CompressorEfficiency(WorkingFluid, WorkingFluidComposition, PropertyToolbox=self.PropertyToolbox, cbFluid=self._cbFluid)
535
+ Design['Efficiencies'][i].OffDesign(Design['BasicParameters'][i], Design['VelocityTriangles'][i], Design['Thermodynamics'][i], Design['Diffusors'][i], Design['Losses'][i])
536
+ StageInletState = Design['Efficiencies'][i].State3 # Update of the stage inlet state for the next stage
537
+
538
+ # Recalculating necessary values stored inside the diffusor class
539
+ Design['Diffusors'][i].OutletAbsoluteMeridionalVelocity = Design['Efficiencies'][i].DiffusorOutletVelocity # Meridional outlet velocity ddetermined by the efficiency class
540
+ Design['Diffusors'][i].OutletAbsoluteVelocity = Design['Efficiencies'][i].DiffusorOutletVelocity # Outlet velocity ddetermined by the efficiency class
541
+ Design['Diffusors'][i].InletAbsoluteRotationalVelocity = Design['VelocityTriangles'][i].Absolute2Rotational*Design['Diffusors'][i].InletDiameter/Design['Diffusors'][i].VanedInletDiameter # Rotational velocity at the vaned diffusor inlet
542
+ Design['Diffusors'][i].InletAbsoluteMeridionalVelocity = Design['BasicParameters'][0].MassFlow*Design['Thermodynamics'][i].State2.sp_volume/(Design['Diffusors'][i].InletBladeHeight*np.pi*Design['Diffusors'][i].VanedInletDiameter) # Meridional velocity at the vaned diffusor inlet
543
+ Design['Diffusors'][i].InletAbsoluteVelocity = (Design['Diffusors'][i].InletAbsoluteRotationalVelocity**2+Design['Diffusors'][i].InletAbsoluteMeridionalVelocity**2)**0.5 # Velocity at the vaned diffusor inlet
544
+ # End of the loop over the individual stages
545
+
546
+ # Total states at machine inlet and outlet
547
+ TotalInletState = Design['Thermodynamics'][0].TotalState1 # Total state at machine inlet
548
+ TotalOutletState = Design['Efficiencies'][i].TotalState3 # Total state at machine outlet
549
+
550
+ # Isentropic compression and static isentropic effciency
551
+ OutletPressure = Design["Efficiencies"][-1].State3.pressure # Outlet pressure of machine
552
+ IsentropicOutletEnthalpy = self.Thermo.setState([OutletPressure, InletState.entropy], "PS").enthalpy # Machine outlet enthalpy for the isentropic compression
553
+ self.IsentropicEfficiency.append((IsentropicOutletEnthalpy-InletState.enthalpy)/(Design["Efficiencies"][-1].State3.enthalpy-InletState.enthalpy)) # Static isentropic efficiency of the machine
554
+ Iterations += 1 # Counting the number of calculation iterations to avoid endless calculation through the break criterion
555
+
556
+
557
+ # Polytropic Efficiency of the compression
558
+ self.PolytropicEfficiency = fsolve(self.PolytropicEfficiencyCalculation, self.IsentropicEfficiency[-1], args=([InletState.pressure, OutletState.pressure], [InletState.temperature, OutletState.temperature]))[0]
559
+
560
+ # Displaing the results of the analysis process in the Python console
561
+ if Plot==True:
562
+ print("")
563
+ print("#####Recalculation Results#####")
564
+ print("Impeller Loss: "+str(round(Design['Losses'][0].ImpellerLoss, 4))+" J/kg")
565
+ print("Diffusor Loss: "+str(round(Design['Losses'][0].DiffusorLoss, 4))+" J/kg")
566
+ print("Pressure 3: "+str(round(Design['Efficiencies'][-1].State3.pressure/100000, 4))+" bar")
567
+ print("Total Pressure 3: "+str(round(Design['Efficiencies'][-1].TotalState3.pressure/100000, 4))+" bar")
568
+ print("Inlet Velocity: "+str(round(Design['VelocityTriangles'][0].Absolute1, 4))+" m/s")
569
+ print("Outlet Velocity: "+str(round(Design['Diffusors'][-1].OutletAbsoluteVelocity, 4))+" m/s")
570
+ print("Meridional Outlet Velocity: "+str(round(Design['Diffusors'][-1].OutletAbsoluteMeridionalVelocity, 4))+" m/s")
571
+ print("Isentropic Efficiency: " + str(round(self.IsentropicEfficiency[-1], 4)*100)+ " %")
572
+ print("Polytropic Efficiency: " + str(round(self.PolytropicEfficiency, 4)*100)+ " %")
573
+ print("Euler Specific Work: "+str(round((Design['VelocityTriangles'][0].Rotational2*Design['VelocityTriangles'][0].Absolute2Rotational/1000), 4))+" kJ/kg")
574
+ print("Total Enthalpy Increase: "+str(round((Design['Efficiencies'][0].TotalState3.enthalpy-Design['Efficiencies'][0].TotalState1.enthalpy)/1000, 4))+" kJ/kg")
575
+ print("Total Inlet Pressure: "+str(round(Design['Thermodynamics'][0].TotalState1.pressure/100000, 4))+" bar")
576
+ print("Total Inlet Temperature: "+str(round(Design['Thermodynamics'][0].TotalState1.temperature, 4))+" K")
577
+
578
+ print("")
579
+
580
+ print("Flow")
581
+ print("Absolute1: "+str(round(Design['VelocityTriangles'][0].Absolute1, 4))+" m/s")
582
+ print("Absolute2: "+str(round(Design['VelocityTriangles'][0].Absolute2, 4))+" m/s")
583
+ print("Absolute3: "+str(round(Design['VelocityTriangles'][0].Absolute3, 4))+" m/s")
584
+ print("Relative1: "+str(round(Design['VelocityTriangles'][0].Relative1, 4))+" m/s")
585
+ print("Relative2: "+str(round(Design['VelocityTriangles'][0].Relative2, 4))+" m/s")
586
+ print("Absolute2Rotational: "+str(round(Design['VelocityTriangles'][0].Absolute2Rotational, 4))+" m/s")
587
+
588
+ # Running the calculation of the velocity triangles of the first stage to display the triangles in the plots panel
589
+ Design['VelocityTriangles'][0].calculate_nonDesignPoint(Design['BasicParameters'][0], MassFlow, Design['Efficiencies'][0], Design['Impellers'][0], Design['Diffusors'][0], Plot=True)
590
+
591
+ # Returning compressor outlet state and isentropic compressor efficiency
592
+ return Design['Efficiencies'][-1].State3, Design, self.IsentropicEfficiency[-1]
593
+
594
+
595
+
596
+
597
+
598
+ def PerformanceMap(self, DesignData, WorkingFluid, WorkingFluidComposition, InletState, SpeedFactor = [1], MaxIterations = 100, Plot = False, FileName='Compressor_Characteristic.csv'):
599
+ """ Method to calculate the performance map of a designed compressor.
600
+ The performance map is given in terms of static pressure and isentropic
601
+ efficiency over the reduced mass flow. Multiple rotational speeds can
602
+ be analysed.
603
+
604
+ Parameters:
605
+ - DesignData (dict): Dictionary containing the results of the design
606
+ process as returned by the Design method.
607
+ - WorkingFluid (string): Working fluid of the compression. Can be a
608
+ single fluid or a mixture.
609
+ Has to be formated according to the thermofynamic property toolbox.
610
+ - Refprop: "Fluid1*Fluid2*Fluid3"
611
+ - Coolprop: ["Fluid1", "Fluid2", "Fluid3"]
612
+ - WorkingFluidComposition (list): List of the molar fractions of the
613
+ fluid components defined in WorkingFluid. Must add up to 1.
614
+ - InletState (class): Thermodynamic state of the working fluid at
615
+ the compressors inlet. Must be caclulated via the
616
+ ThermodynamicProperties class in this package.
617
+ - SpeedFactor (list, optional): List of floats containing the rotational
618
+ speed to be analysed. If a speed does not result in valid operating
619
+ points, it is ommited from the results. Default is [1] for nominal speed.
620
+ - MaxIterations (integer, optional): Maximum number of calculation
621
+ iterations per operating point allowed. Default is 100.
622
+ - Plot (boolean, optional): Wether the performance map should be
623
+ plotted in the plot panel. Default is false, meaning no displayment.
624
+ FileName (string, optional): Name of the file in which the performance
625
+ map is stored as a csv file. Default is Compressor_Characteristic.csv.
626
+ """
627
+
628
+ memo = build_deepcopy_memo(DesignData)
629
+ if self._cbFluid is not None:
630
+ memo[id(self._cbFluid)] = self._cbFluid
631
+ DesignInput = copy.deepcopy(DesignData, memo)
632
+
633
+ DPMassFlow = DesignData['BasicParameters'][0].MassFlow # Design point mass flow
634
+ DPV = DPMassFlow *DesignData['Thermodynamics'][0].State1.sp_volume # Design point inlet volume flow
635
+
636
+ # Variables to store results
637
+ MassFlowStorage = []
638
+ redMassFlowStorage = []
639
+ PressureRatioStorage = []
640
+ IsentropicEfficiencyStorage = []
641
+ SpeedStorage = []
642
+ TotalPressureRatioStorage = []
643
+ NormSpeedStorage = []
644
+
645
+ # Performance at design point
646
+ InletVolumeFlow = DPMassFlow*InletState.sp_volume
647
+ DPOutletState, DPEta, DPDesignState= self.CalculateCompressor(DesignData, WorkingFluid, WorkingFluidComposition, InletState, DPMassFlow, 1, Plot=False)
648
+ DPPressureRatio = DPOutletState.pressure/InletState.pressure
649
+
650
+
651
+ PiChoke = [0]
652
+ MaxMachStorage = []
653
+
654
+ # Loop over the selected speed factors
655
+ for speedfactor in SpeedFactor:
656
+ try:
657
+ PressureRatio = [] # Variables for the results of each speed line
658
+ TotalPressureRatio = []
659
+ StaticEfficiency = []
660
+ MassFlowRange = []
661
+ redMassFlowRange = []
662
+ ChokeLimit = False
663
+
664
+ MaxMach = []
665
+ # Loop over the feasible mass flows of each speed line
666
+
667
+ for MassFlow in np.linspace(0.5*DPMassFlow*speedfactor**1, 2*DPMassFlow*speedfactor**1, 50):
668
+ if ChokeLimit == False:
669
+ try:
670
+ OutletState, Eta, DesignState = self.CalculateCompressor(DesignInput, WorkingFluid, WorkingFluidComposition, InletState, MassFlow, speedfactor, Plot=False) # Calculation of the compressors performance
671
+ # Choke mass flow rate estimation
672
+ DiffusorChokeEstimation = DiffusorChoke(WorkingFluid, WorkingFluidComposition, self.PropertyToolbox)
673
+ DiffusorChokeMassFlow = DiffusorChokeEstimation.calculate(DesignState['VelocityTriangles'][0], DesignState['Diffusors'][0], DesignState['Thermodynamics'][0].State2)[0]
674
+ ImpellerChokeEstimation = ImpellerChoke(WorkingFluid, WorkingFluidComposition, self.PropertyToolbox)
675
+ ImpellerChokeMassFlow = ImpellerChokeEstimation.calculate(DesignState['VelocityTriangles'][0], DesignState['Impellers'][0], DesignState['Thermodynamics'][0].State1)
676
+ ChokeMassFlow = min(ImpellerChokeMassFlow, DiffusorChokeMassFlow)
677
+ print(MassFlow, DiffusorChokeMassFlow)
678
+ if MassFlow < ChokeMassFlow:
679
+ if OutletState.pressure/InletState.pressure > 1: # Checking whether the operating point resulted in an increase in pressure
680
+ PressureRatio.append(OutletState.pressure/InletState.pressure) # Saving the results in the respective variables
681
+ StaticEfficiency.append(Eta)
682
+ ReducedMassFlow = MassFlow*(DesignState['Thermodynamics'][0].TotalState1.temperature/InletState.temperature)**0.5/(DesignState['Thermodynamics'][0].TotalState1.pressure/InletState.pressure)
683
+ ReducedMassFlow = MassFlow*(DesignState['Thermodynamics'][0].State1.temperature/InletState.temperature)**0.5/(DesignState['Thermodynamics'][0].State1.pressure/InletState.pressure)
684
+ MassFlowRange.append(MassFlow)
685
+ redMassFlowRange.append(ReducedMassFlow)
686
+ TotalPressureRatio.append(DesignState['Efficiencies'][-1].TotalState3.pressure/DesignState['Efficiencies'][0].TotalState1.pressure)
687
+ MaxMach.append(max(DesignState['Thermodynamics'][0].Mach1, DesignState['Thermodynamics'][0].Mach2r, DesignState['Thermodynamics'][0].Mach2s, DesignState['Thermodynamics'][0].Mach3))
688
+ else:
689
+ ChokeLimit = True
690
+
691
+ except: # Exception skipping to the next mass flow in case of a calculation error
692
+ "Nothing"
693
+
694
+ PumpLimitIndex = np.argmax(PressureRatio) # Pump limit defined by the maximum of the pressure ratio
695
+ PressureRatiomax = max(PressureRatio)
696
+ PressureRatioWithoutmax = copy.deepcopy(PressureRatio)
697
+ PressureRatioWithoutmax.pop(PumpLimitIndex)
698
+ PressureRatiomax2 = max(PressureRatioWithoutmax)
699
+
700
+ # Loop deleting all operating points left of the pump limit as these are physically infeasible
701
+ for i in range(PumpLimitIndex):
702
+ PressureRatio.pop(0)
703
+ StaticEfficiency.pop(0)
704
+ MassFlowRange.pop(0)
705
+ redMassFlowRange.pop(0)
706
+ TotalPressureRatio.pop(0)
707
+ MaxMach.pop(0)
708
+
709
+ # Loop saving the results of the individual speed lines in the overall result variables
710
+ PiChoke.append(PressureRatio[-1])
711
+ if PiChoke[-1]>PiChoke[-2] or PiChoke[-2]<1.1:
712
+ for i in range(len(MassFlowRange)):
713
+ MassFlowStorage.append(MassFlowRange[i])
714
+ redMassFlowStorage.append(redMassFlowRange[i])
715
+ PressureRatioStorage.append(PressureRatio[i])
716
+ IsentropicEfficiencyStorage.append(StaticEfficiency[i])
717
+ SpeedStorage.append(speedfactor*DesignState['BasicParameters'][0].Speed)
718
+ NormSpeedStorage.append(speedfactor)
719
+ TotalPressureRatioStorage.append(TotalPressureRatio[i])
720
+ MaxMachStorage.append(MaxMach[i])
721
+
722
+
723
+ except: # Exception skipping to the next speed line in case no valid operating could can be found
724
+ "Nothing"
725
+
726
+ VolumeFlows = np.array(MassFlowStorage)*InletState.sp_volume # Converting the found mass flows into volume flows
727
+
728
+ # csv file with the performance map
729
+ df = pd.DataFrame({
730
+ 'm_dot': MassFlowStorage,
731
+ 'm_dot_red': redMassFlowStorage,
732
+ 'V_dot': VolumeFlows,
733
+ 'eta_is': IsentropicEfficiencyStorage,
734
+ 'p_ratio': PressureRatioStorage,
735
+ 'pt_ratio': TotalPressureRatioStorage,
736
+ 'n': SpeedStorage,
737
+ 'm_dot_N': DPMassFlow,
738
+ 'V_dot_N': DPV,
739
+ 'eta_is_N': DPEta,
740
+ 'p_ratio_N': DPPressureRatio,
741
+ 'n_N': DesignState['BasicParameters'][0].Speed,
742
+ 'Ma': MaxMachStorage,
743
+ 'n_norm': NormSpeedStorage
744
+ })
745
+ df = df[df["eta_is"] > 0]
746
+ df = df[df["eta_is"] < 1]
747
+ df.to_csv(FileName, index=False) # Saving the dataframe as a csv file
748
+ self.PerformanceCurve = df # Saving the dataframe as an attribute
749
+
750
+
751
+ if Plot == True:
752
+ # plot of the performance map
753
+ plt.figure(figsize=(10, 10))
754
+ plt.scatter(df["m_dot"], df["p_ratio"], c=df["eta_is"], cmap='jet', s=100, marker='o', edgecolors='face', vmin=None, vmax=None)
755
+ cbar = plt.colorbar()
756
+ cbar.set_label(r"Isentropic efficiency $\mathrm{\eta_{s}}$", fontsize=32)
757
+ cbar.ax.tick_params(labelsize=28)
758
+ plt.xlabel(r"Mass flow rate $\mathrm{\dot{m}}$ in kg $s^{-1}$", fontsize=32)
759
+ plt.ylabel(r"Pressure ratio $\mathrm{\Pi}$", fontsize=32)
760
+ plt.yticks(fontsize=28)
761
+ plt.xticks(fontsize=28)
762
+ plt.grid(True)
763
+ plt.show()
764
+
765
+ return
766
+
767
+
768
+
769
+
770
+
771
+
772
+ if __name__ == "__main__":
773
+ "Example of usage"
774
+
775
+ # Compression parameters
776
+ InletTemperature = 400
777
+ InletPressure = 1e5
778
+ OutletPressure = 1.5e5
779
+ WorkingFluid = ['air']
780
+ WorkingFluidComposition = [1] # mole fractions
781
+ MassFlow = 5
782
+ PropertyToolbox="coolprop"
783
+
784
+ # Thermodynamic property class
785
+ Thermo = ThermodynamicProperties(WorkingFluid, WorkingFluidComposition, PropertyToolbox=PropertyToolbox)
786
+ # Inle tstate of the fluid
787
+ InletState = Thermo.setState([InletPressure, InletTemperature], "PT")
788
+
789
+ # Class initialization
790
+ Results = inverseCompressorDesignTool(PropertyToolbox=PropertyToolbox)
791
+
792
+ # Design of the compressor
793
+ OutletState, DesignData = Results.designCompressor(WorkingFluid, WorkingFluidComposition, InletState, OutletPressure,
794
+ MassFlow, Plot=True,
795
+ GearedCompressor=False, SpecificSpeed = None,
796
+ VanedDiffusor = True, CircumferentialMachNumber=None,
797
+ IsentropicWorkCoefficient=None, MaxIterations=100)
798
+
799
+ # Calculation of the design point using the calculation method
800
+ OutletStateCalculated, DesignDataNew, EfficiencyNew = Results.CalculateCompressor(DesignData, WorkingFluid, WorkingFluidComposition, InletState, MassFlow, Plot=True)
801
+ # Calculation of the performance map
802
+ SpeedFactor = [0.9, 1, 1.1]
803
+ Results.PerformanceMap(DesignData, WorkingFluid, WorkingFluidComposition, InletState, SpeedFactor=SpeedFactor, Plot=True, FileName='iTD_Plausibilisation.csv')