turbo-design 1.0.8__tar.gz → 1.0.9__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 turbo-design might be problematic. Click here for more details.

Files changed (32) hide show
  1. {turbo_design-1.0.8 → turbo_design-1.0.9}/PKG-INFO +1 -1
  2. {turbo_design-1.0.8 → turbo_design-1.0.9}/pyproject.toml +1 -1
  3. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/td_math.py +2 -2
  4. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/turbinespool.py +98 -35
  5. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/__init__.py +0 -0
  6. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/arrayfuncs.py +0 -0
  7. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/bladerow.py +0 -0
  8. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/cantera_gas/co2.yaml +0 -0
  9. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/compressorspool.py +0 -0
  10. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/coolant.py +0 -0
  11. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/enums.py +0 -0
  12. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/inlet.py +0 -0
  13. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/isentropic.py +0 -0
  14. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/__init__.py +0 -0
  15. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/compressor/__init__.py +0 -0
  16. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/losstype.py +0 -0
  17. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/TD2.py +0 -0
  18. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/__init__.py +0 -0
  19. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/ainleymathieson.py +0 -0
  20. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/craigcox.py +0 -0
  21. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/fixedefficiency.py +0 -0
  22. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/fixedpressureloss.py +0 -0
  23. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/kackerokapuu.py +0 -0
  24. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/loss/turbine/traupel.py +0 -0
  25. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/lossinterp.py +0 -0
  26. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/outlet.py +0 -0
  27. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/passage.py +0 -0
  28. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/radeq.py +0 -0
  29. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/rotor.py +0 -0
  30. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/solve_radeq.py +0 -0
  31. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/spool.py +0 -0
  32. {turbo_design-1.0.8 → turbo_design-1.0.9}/turbodesign/stage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: turbo-design
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: TurboDesign is a library used to design turbines and compressors using radial equilibrium.
5
5
  Author: Paht Juangphanich
6
6
  Author-email: paht.juangphanich@nasa.gov
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "turbo-design"
3
- version = "1.0.8"
3
+ version = "1.0.9"
4
4
  description = "TurboDesign is a library used to design turbines and compressors using radial equilibrium."
5
5
  authors = ["Paht Juangphanich <paht.juangphanich@nasa.gov>"]
6
6
  packages = [
@@ -57,8 +57,8 @@ def compute_massflow(row:BladeRow) -> None:
57
57
  massflow = row.percent_hub_shroud*0
58
58
  total_area = 0
59
59
  for j in range(1,len(row.percent_hub_shroud)):
60
- Vm = row.Vm[j]
61
- rho = row.rho[j]
60
+ Vm = (row.Vm[j]+row.Vm[j-1])/2
61
+ rho = (row.rho[j]+row.rho[j-1])/2
62
62
  if np.abs((row.x[j]-row.x[j-1]))<1E-12: # Axial Machines
63
63
  total_area += np.pi*(row.r[j]**2-row.r[j-1]**2)
64
64
  massflow[j] = Vm * rho * np.pi* (row.r[j]**2-row.r[j-1]**2) + massflow[j-1]
@@ -3,7 +3,7 @@ from cantera.composite import Solution
3
3
  from .bladerow import BladeRow, interpolate_streamline_radii
4
4
  from .enums import RowType, MassflowConstraint, LossType, PassageType
5
5
  from .spool import Spool
6
- import json
6
+ import json, copy
7
7
  from .passage import Passage
8
8
  from scipy.interpolate import interp1d
9
9
  import numpy as np
@@ -11,7 +11,8 @@ import numpy.typing as npt
11
11
  from .td_math import inlet_calc,rotor_calc, stator_calc, compute_massflow, compute_power, compute_gas_constants
12
12
  from .solve_radeq import adjust_streamlines, radeq
13
13
  from scipy.optimize import minimize_scalar, minimize, fmin_slsqp
14
-
14
+ from .inlet import Inlet
15
+ from .outlet import Outlet
15
16
 
16
17
  class TurbineSpool(Spool):
17
18
  def __init__(self,passage:Passage,
@@ -49,7 +50,7 @@ class TurbineSpool(Spool):
49
50
  self.blade_rows[0].total_massflow = W0
50
51
  self.blade_rows[0].total_massflow_no_coolant = W0
51
52
 
52
- interpolate_streamline_radii(self.blade_rows[0],self.passage)
53
+ interpolate_streamline_radii(self.blade_rows[0],self.passage,self.num_streamlines)
53
54
 
54
55
  # Set the gas to total values for now
55
56
  self.blade_rows[0].fluid.TP = self.blade_rows[0].T0.mean(), self.blade_rows[0].P0.mean()
@@ -61,7 +62,7 @@ class TurbineSpool(Spool):
61
62
  inlet_calc(self.blade_rows[0])
62
63
 
63
64
  for row in self.blade_rows:
64
- interpolate_streamline_radii(row,self.passage)
65
+ interpolate_streamline_radii(row,self.passage,self.num_streamlines)
65
66
 
66
67
  outlet = self.blade_rows[-1]
67
68
  for j in range(self.num_streamlines):
@@ -191,56 +192,118 @@ class TurbineSpool(Spool):
191
192
  3. Adjust the streamlines for each blade row to balance the massflow
192
193
  """
193
194
 
194
- # Balance the massflow between Stages
195
- def balance_massflows(x0:List[float],blade_rows:List[List[BladeRow]],P0:npt.NDArray,P:npt.NDArray):
196
- total_massflow = list(); massflow_stage = list()
197
- stage_ids = list(set([row.stage_id for row in self.blade_rows if row.stage_id>=0])); s = 0
198
- sign = 1
199
- for j in range(self.num_streamlines):
200
- Ps_range = outlet_pressure(x0,P0[j],P[j])
201
- for i in range(1,len(blade_rows)-1):
202
- blade_rows[i].P[j] = Ps_range[i-1]
203
- blade_rows[-1].P = P
204
- calculate_massflows(blade_rows,True)
195
+ def calculate_error(blade_rows):
196
+ total_massflow = list(); s = 0; massflow_stage = list()
197
+ stage_ids = list(set([row.stage_id for row in self.blade_rows if row.stage_id>=0]))
205
198
  for row in blade_rows[1:]:
206
199
  total_massflow.append(row.total_massflow_no_coolant)
207
- for s in stage_ids:
208
- for row in blade_rows:
209
- if row.stage_id == s and row.row_type == RowType.Rotor:
210
- massflow_stage.append(sign*row.total_massflow_no_coolant)
211
- sign*=-1
212
- if len(stage_ids) % 2 == 1:
213
- massflow_stage.append(massflow_stage[-1]*sign)
214
- print(x0)
200
+
201
+ sign = 1
202
+ for s in stage_ids:
203
+ for row in blade_rows:
204
+ if row.stage_id == s and row.row_type == RowType.Rotor:
205
+ massflow_stage.append(sign*row.total_massflow_no_coolant)
206
+ sign*=-1
207
+ if len(stage_ids) % 2 == 1:
208
+ massflow_stage.append(massflow_stage[-1]*sign)
209
+
215
210
  return np.std(total_massflow)*2 # + abs(sum(massflow_stage)) # Equation 28
216
-
211
+
212
+ # Balance the massflow between Stages
213
+ def balance_massflows(x0:List[float],blade_rows:List[List[BladeRow]],P0:npt.NDArray,P:npt.NDArray,balance_mean_pressure:bool=True):
214
+ """Balance Massflows.
215
+
216
+ Steps:
217
+ 1. Balance the mean static pressure in between the blade rows. X0 = [0.2,0.5,...] size = num_rows
218
+ P = outlet static pressure
219
+
220
+ 2. Keep the mean
221
+
222
+ Args:
223
+ x0 (List[float]): _description_
224
+ blade_rows (List[List[BladeRow]]): _description_
225
+ P0 (npt.NDArray): _description_
226
+ P (npt.NDArray): (1) Outlet Static Pressure. (2)
227
+ balance_mean_pressure (bool, optional): _description_. Defaults to True.
228
+
229
+ Returns:
230
+ _type_: _description_
231
+ """
232
+ try:
233
+ if balance_mean_pressure:
234
+ for j in range(self.num_streamlines):
235
+ Ps_range = outlet_pressure(x0,P0[j],P[j])
236
+ for i in range(1,len(blade_rows)-1):
237
+ blade_rows[i].P[j] = Ps_range[i-1]
238
+ blade_rows[-1].P = P
239
+ else:
240
+ for i in range(1,len(blade_rows)-1):
241
+ for j in range(self.num_streamlines):
242
+ blade_rows[i].P[j] = P[i][j]*x0[(i-1)*self.num_streamlines+j] # x0 size = num_streamlines -1
243
+
244
+ calculate_massflows(blade_rows,True)
245
+ print(x0)
246
+ return calculate_error(blade_rows)
247
+ except:
248
+ for i in range(1,len(blade_rows)-1):
249
+ for j in range(self.num_streamlines):
250
+ blade_rows[i].P[j] = P[i][j]
251
+ calculate_massflows(blade_rows,True)
252
+ return 10
217
253
  # Break apart the rows to stages
218
- outlet_P=list(); outlet_P_guess = list()
254
+ outlet_P=list(); outlet_P_guess = list() # Outlet P is the bounds, outlet_p_guess is the guessed values
219
255
 
220
256
  for i in range(1,len(self.blade_rows)-2):
221
257
  outlet_P.append(self.blade_rows[i].inlet_to_outlet_pratio)
222
258
  outlet_P_guess.append(np.mean(self.blade_rows[i].inlet_to_outlet_pratio))
223
259
 
260
+ print('Find average P in between stages')
224
261
  if len(outlet_P) == 1:
225
- res1 = minimize_scalar(fun=balance_massflows,args=(self.blade_rows[:-1],self.blade_rows[0].P0,self.blade_rows[-1].P),
226
- bounds=outlet_P[0],tol=0.001,options={'disp': True})
227
- x = res1.x
262
+ res = minimize_scalar(fun=balance_massflows,args=(self.blade_rows[:-1],self.blade_rows[0].P0,self.blade_rows[-1].P),
263
+ bounds=outlet_P[0],tol=0.0001,options={'disp': True})
264
+ x = res.x
228
265
  else:
229
266
  x = fmin_slsqp(func=balance_massflows,args=(self.blade_rows[:-1],self.blade_rows[0].P0,self.blade_rows[-1].P),
230
267
  bounds=outlet_P, x0=outlet_P_guess,epsilon=0.001,iter=100) # ,tol=0.001,options={'disp': True})
268
+ outlet_P_guess = x
231
269
 
232
270
  # Adjust the inlet: Set the massflow
233
271
  self.blade_rows[0].massflow = np.linspace(0,1,self.num_streamlines)*self.blade_rows[1].total_massflow_no_coolant
234
272
  inlet_calc(self.blade_rows[0]) # adjust the inlet to match massflow
235
- for _ in range(3):
273
+
274
+ for _ in range(2):
236
275
  adjust_streamlines(self.blade_rows[:-1],self.passage)
237
276
  self.blade_rows[-1].transfer_quantities(self.blade_rows[-2])
238
277
  self.blade_rows[-1].P = self.blade_rows[-1].get_static_pressure(self.blade_rows[-1].percent_hub_shroud)
239
- err = balance_massflows(x,self.blade_rows[:-1],self.blade_rows[0].P0,self.blade_rows[-1].P)
240
- if err>5E-2:
241
- print(f"Massflow is not convergenced error:{err}")
242
- else:
243
- print(f"Massflow converged to less than 0.05kg/s error:{err}")
278
+ balance_massflows(x,self.blade_rows[:-1],self.blade_rows[0].P0,self.blade_rows[-1].P)
279
+ err = calculate_error(self.blade_rows[:-1])
280
+ print(f"Massflow convergenced error:{err}")
281
+
282
+ # finetune = True
283
+ # if finetune:
284
+ # print('Finetune static pressure between stages')
285
+ # self.blade_rows[-1].transfer_quantities(self.blade_rows[-2])
286
+ # self.blade_rows[-1].P = self.blade_rows[-1].get_static_pressure(self.blade_rows[-1].percent_hub_shroud)
287
+ # P = [row.P for row in self.blade_rows] # Average static pressures
288
+ # bounds = []; guess = []
289
+ # for i in range(1,len(self.blade_rows)-1): # set the bounds
290
+ # for j in range(self.num_streamlines):
291
+ # bounds.append([0.8,1.2]) # vary by +- 20%
292
+ # guess.append(1)
293
+
294
+ # x = fmin_slsqp(func=balance_massflows,args=(self.blade_rows[:-1],self.blade_rows[0].P0,P,False),
295
+ # bounds=bounds, x0=guess,epsilon=0.001,iter=200)
296
+ # P = [row.P for row in self.blade_rows] # Average static pressures
297
+
298
+ # for _ in range(2):
299
+ # adjust_streamlines(self.blade_rows[:-1],self.passage)
300
+ # self.blade_rows[-1].transfer_quantities(self.blade_rows[-2])
301
+ # self.blade_rows[-1].P = self.blade_rows[-1].get_static_pressure(self.blade_rows[-1].percent_hub_shroud)
302
+ # balance_massflows(x,self.blade_rows[:-1],self.blade_rows[0].P0,P,False)
303
+
304
+ # err = calculate_error(self.blade_rows[:-1])
305
+ # print(f"Massflow convergenced error after finetuning:{err}")
306
+
244
307
 
245
308
  def export_properties(self,filename:str="turbine_spool.json"):
246
309
  """Export the spool object to json
@@ -326,7 +389,7 @@ def calculate_massflows(blade_rows:List[BladeRow],calculate_vm:bool=False):
326
389
  else:
327
390
  downstream = None
328
391
 
329
- # Pressure loss = shift in entropy which affects the total pressure of the row
392
+ # Pressure loss = shift in entropy which affects the total pressure of the row
330
393
  if row.row_type == RowType.Inlet:
331
394
  row.Yp = 0
332
395
  else: