Correction d'une faute d'orthographe
[memoirecycle.git] / element.py
blobde626c293e1cd253675eecbf98113754c3d809fd
1 import wx
2 import notif
3 import prop
4 from connection import Connection
5 import collections
6 import equa
7 from equa import V
8 from equa import K
9 import logging
11 logger = logging.getLogger()
13 global allElem
14 ''' Contains State and all the Transformation in this file '''
15 allElem = set() # set(tuple(genericname, klass))
17 def isPointInZone(point,zone):
18 ''' A zone is where you see Element or Connection on GUI panel '''
19 if point[0] >= zone[0][0] \
20 and point[1] >= zone[0][1] \
21 and point[0] <= zone[1][0] \
22 and point[1] <= zone[1][1] :
23 return True
24 else :
25 return False
27 def clicked(elem,point):
28 ''' Return element or connection clicked '''
29 connMatch = False
30 myzone = elem.zone
31 if elem.genericName() != 'state' \
32 or (elem.genericName() == 'state' \
33 and elem.connection['I1'].link == None \
34 and elem.connection['O1'].link == None):
36 for x in elem.connection:
37 myconnzone = ((elem.pos[0]+elem.connection[x].dpos[0],elem.pos[1]+elem.connection[x].dpos[1]),\
38 (elem.pos[0]+elem.connection[x].dpos[0]+10,elem.pos[1]+elem.connection[x].dpos[1]+10))
40 if isPointInZone(point,myconnzone):
41 connMatch = True
42 return elem.connection[x]
44 else:
45 if elem.genericName() == 'state' and elem.connection['I1'].link == None : # In case where O1 != None
46 x = 'I1'
47 myconnzone = ((elem.pos[0]+elem.connection[x].dpos[0],elem.pos[1]+elem.connection[x].dpos[1]),\
48 (elem.pos[0]+elem.connection[x].dpos[0]+10,elem.pos[1]+elem.connection[x].dpos[1]+10))
49 if isPointInZone(point,myconnzone):
50 connMatch = True
51 return elem.connection[x]
52 elif elem.genericName() == 'state' and elem.connection['O1'].link == None : # In case where I1 != None
53 x = 'O1'
54 myconnzone = ((elem.pos[0]+elem.connection[x].dpos[0],elem.pos[1]+elem.connection[x].dpos[1]),\
55 (elem.pos[0]+elem.connection[x].dpos[0]+10,elem.pos[1]+elem.connection[x].dpos[1]+10))
56 if isPointInZone(point,myconnzone):
57 connMatch = True
58 return elem.connection[x]
59 # In case where I1 and O1 != None, we just need to do nothing (so we do not check Connection)
61 if isPointInZone(point,myzone) and connMatch == False:
62 return elem
65 def elemUpdate(element,equationList):
66 ''' Check in Element's equation if it can find solution and tell them'''
67 for x in equationList :
68 result = equa.evalEquation(x,element)
69 if result != None:
70 result[0].tell(result[1],set(result[2]))
72 ################################################################################
73 class Element(notif.Notifier):
74 ################################################################################
75 ''' Generic class for element, it contains element's position and project
76 Others instance variable must be defined in subclass '''
77 genericNumber = 0
78 genericname = 'element'
79 def __init__(self, project, pos):
80 notif.Notifier.__init__(self)
81 self.__connection={} # Contains all the Element's Connection [string : conn]
82 self.__pos = pos
83 self.__project = project
84 self.__selected = False
85 self._bmp = wx.Image("images/element/"+ self.genericName() +'.png').ConvertToBitmap()
86 self._properties = {}
87 self.doProp([('name',prop.StringFixedProperty,0)]) # Fills self._properties
89 @classmethod
90 def clearGN(klass):
91 ''' Clear genericNumber '''
92 klass.genericNumber = 0
94 @classmethod
95 def generateName(klass):
96 ''' Create the name that will be used in Project's elemList and nameList '''
97 klass.genericNumber +=1
98 return klass.genericname+str(klass.genericNumber)
100 @classmethod
101 def genericName(klass):
102 return klass.genericname
104 @classmethod
105 def genericnumber(klass):
106 return klass.genericNumber
108 @property
109 def bmp(self):
110 return self._bmp
112 @property
113 def connection(self):
114 return self.__connection
116 @property
117 def pos(self):
118 return self.__pos
120 @pos.setter
121 def pos(self,p):
122 assert type(p)==tuple
123 self.__pos = p
125 @property
126 def project(self):
127 return self.__project
129 @property
130 def properties(self):
131 return self._properties
133 @property
134 def selected(self):
135 return self.__selected
137 @selected.setter
138 def selected(self,val):
139 assert type(val) == bool
140 self.__selected = val
142 def addConn(self, kind, dpos, namedic):
143 ''' Add a Connection in Element's Connection dictionnary.
144 nameDic : fromElem = IN -> I+number, toElem = OUT -> O+number '''
145 conn = Connection(self, kind, dpos)
146 self.__connection[namedic] = conn
147 return conn
149 def clicked(self,point):
150 return clicked(self,point)
153 def connect(self, conn, conn2):
154 ''' Connect if conn2 is a Connection, deconnect if conn2 is None'''
155 conn.link = conn2 # read link.setter DOC
156 self.connectionChanged()
158 def connectionChanged(self):
159 ''' Do notification in case of Connection's change'''
160 for x in self._properties:
161 self._properties[x].relax()
162 self.__project.doNotify()
164 def deselect(self):
165 self._bmp = wx.Image("images/element/"+ self.genericName() +'.png').ConvertToBitmap()
166 self.__selected = False
167 if self.__project.currentElem == self:
168 self.__project.currentElem = None
169 self.__project.doNotify()
171 def detachFromAll(self):
172 ''' Deconnect myself with everybody I'm connected with AND deconnect everybody who was connected with me '''
173 for x in self.__connection:
174 self.__connection[x].link = None
175 self.connectionChanged()
177 def doProp(self, propList):
178 ''' Fill self._properties dictionnary in Element
179 propList : [( 'name', 'propCategory', labelKey ), ( 'name', 'propCategory', labelKey ), ...]
180 -> propCategory gives the type of property -- read Property DOC
181 -> labelKey gives the order of apparition in propGrid '''
182 for x in propList:
183 if x[1] == 'floatfixed' :
184 x = (x[0],prop.FloatFixedProperty, x[2])
185 elif x[1] == 'stringfixed':
186 x = (x[0],prop.StringFixedProperty, x[2])
187 elif x[1] == 'floatvar':
188 x = (x[0],prop.FloatVariableProperty, x[2])
189 elif x[1] == 'stringvar' :
190 x = (x[0],prop.StringVariableProperty, x[2])
191 self._properties[x[0]] = x[1](self.project, x[0])
192 self._properties[x[0]].labelKey = x[2]
193 self._properties[x[0]].wantNotif.add(self) # for Element's flash
194 if x[0] == 'name':
195 self._properties[x[0]].value = str(self.genericName())+str(self.genericnumber()+1) # generate automatic name
197 def select(self):
198 self._bmp = wx.Image("images/element/"+ self.genericName() +'select'+'.png').ConvertToBitmap()
199 self.__selected = True
200 self.__project.doNotify()
203 ## les fonction ci-apres doivent y rester pour cause d utilisation des fonctions precedentes
204 def clear(self):
205 self.detachFromAll()
206 self.clearGN()
207 self.__project.doNotify()
209 ################################################################################
210 class State(Element):
211 ################################################################################
212 ''' State flash themselve to complete theyr properties '''
213 genericNumber = 0
214 genericname = 'state'
216 #FLASH Equation
217 equaState = equa.Equation()
219 #Specific volume
220 equaState.addEquation(V('specific volume')-equa.v_pT(V('pressure'),V('temperature')))
221 equaState.addEquation(V('specific volume')-equa.v_ph(V('pressure'),V('enthalpy')))
222 equaState.addEquation(V('specific volume')-equa.v_ps(V('pressure'),V('entropy')))
224 #Temperature
225 equaState.addEquation(V('temperature')-equa.T_px(V('pressure'),V('quality')))
226 equaState.addEquation(V('temperature')-equa.T_ph(V('pressure'),V('enthalpy')))
227 equaState.addEquation(V('temperature')-equa.T_hs(V('enthalpy'),V('entropy')))
229 #Pressure
230 equaState.addEquation(V('pressure')-equa.p_Tx(V('temperature'),V('quality')))
231 equaState.addEquation(V('pressure')-equa.p_hs(V('enthalpy'),V('entropy')))
233 #Enthalpy
234 equaState.addEquation(V('enthalpy')-equa.h_pT(V('pressure'),V('temperature')))
235 equaState.addEquation(V('enthalpy')-equa.h_ps(V('pressure'),V('entropy')))
236 equaState.addEquation(V('enthalpy')-equa.h_px(V('pressure'),V('quality')))
237 equaState.addEquation(V('enthalpy')-equa.h_Tx(V('temperature'),V('quality')))
239 #Entropy
240 equaState.addEquation(V('entropy')-equa.s_pT(V('pressure'),V('temperature')))
241 equaState.addEquation(V('entropy')-equa.s_ph(V('pressure'),V('enthalpy')))
243 #quality
244 equaState.addEquation(V('quality')-equa.x_ph(V('pressure'),V('enthalpy')))
245 equaState.addEquation(V('quality')-equa.x_ps(V('pressure'),V('entropy')))
247 #Exergy
248 equaState.addEquation(V('exergy')-V('enthalpy')+ \
249 equa.RefVar('reference enthalpy',None)+ \
250 equa.RefVar('reference temperature',None)*(V('entropy')-equa.RefVar('reference entropy',None)))
251 equaState.addEquation(equa.CheckNullExergy(V('exergy')))
253 #Reference (please refer to equa.py ifyou want to know howto build these equation)
254 equaState.addEquation(equa.selfRefVar('reference enthalpy')-equa.selfRefVar('enthalpy'))
255 equaState.addEquation(equa.selfRefVar('reference entropy')-equa.selfRefVar('entropy'))
256 equaState.addEquation(equa.selfRefVar('reference temperature')-equa.selfRefVar('temperature'))
257 equaState.addEquation(equa.selfRefVar('reference quality')-equa.selfRefVar('quality'))
258 equaState.addEquation(equa.selfRefVar('reference pressure')-equa.selfRefVar('pressure'))
259 equaState.addEquation(equa.CheckRef(V('reference state')))
261 equaState.addEquation(equa.RefVar('reference pressure',None)-equa.p_Tx(equa.RefVar('reference temperature',None),equa.RefVar('reference quality',None)))
262 equaState.addEquation(equa.RefVar('reference temperature',None)-equa.T_ph(equa.RefVar('reference pressure',None),equa.RefVar('reference enthalpy',None)))
263 equaState.addEquation(equa.RefVar('reference temperature',None)-equa.T_hs(equa.RefVar('reference enthalpy',None),equa.RefVar('reference entropy',None)))
264 equaState.addEquation(equa.RefVar('reference pressure',None)-equa.p_hs(equa.RefVar('reference enthalpy',None),equa.RefVar('reference entropy',None)))
265 equaState.addEquation(equa.RefVar('reference enthalpy',None)-equa.h_px(equa.RefVar('reference pressure',None),equa.RefVar('reference quality',None)))
266 equaState.addEquation(equa.RefVar('reference enthalpy',None)-equa.h_pT(equa.RefVar('reference pressure',None),equa.RefVar('reference temperature',None)))
267 equaState.addEquation(equa.RefVar('reference enthalpy',None)-equa.h_ps(equa.RefVar('reference pressure',None),equa.RefVar('reference entropy',None)))
268 equaState.addEquation(equa.RefVar('reference enthalpy',None)-equa.h_Tx(equa.RefVar('reference temperature',None),equa.RefVar('reference quality',None)))
269 equaState.addEquation(equa.RefVar('reference entropy',None)-equa.s_pT(equa.RefVar('reference pressure',None),equa.RefVar('reference temperature',None)))
270 equaState.addEquation(equa.RefVar('reference entropy',None)-equa.s_ph(equa.RefVar('reference pressure',None),equa.RefVar('reference enthalpy',None)))
271 equaState.addEquation(equa.RefVar('reference quality',None)-equa.x_ph(equa.RefVar('reference pressure',None),equa.RefVar('reference enthalpy',None)))
272 equaState.addEquation(equa.RefVar('reference quality',None)-equa.x_ps(equa.RefVar('reference pressure',None),equa.RefVar('reference entropy',None)))
274 equaState.processTodo()
276 def __init__(self,project,pos):
277 Element.__init__(self,project,pos)
278 self.conn1 = self.addConn('fromElem',(-10,6.5),'I1')
279 self.conn2 = self.addConn('toElem',(78,6.5),'O1')
280 self.__zone = (self.pos,(self.pos[0]+45,self.pos[1]+45))
281 self.doProp( [ ('fluid',prop.FluidProperty,1),\
282 ('specific volume',prop.FloatTellProperty,2),\
283 ('temperature','floatvar',3),\
284 ('pressure','floatvar',4),\
285 ('quality',prop.QualityProperty,5),\
286 ('entropy','floatvar',6),\
287 ('enthalpy','floatvar',7),\
288 ('exergy','floatvar',8),\
289 ('flow','floatvar',9),\
290 ('reference temperature','floatvar',10),\
291 ('reference quality',prop.QualityProperty,11),\
292 ('reference pressure','floatvar',12),\
293 ('reference entropy','floatvar',13),\
294 ('reference enthalpy','floatvar',14),\
295 ('reference state',prop.BoolProperty,15)] )
296 #Le quality est la proportion de vapeur dans le melange eau-vapeur.
297 #Specific volume = masse volumique [m ^ 3/kg]
300 @property
301 def zone(self):
302 ''' The zone contains the area of the State's picture in GUI panel'''
303 self.__zone = (self.pos,(self.pos[0]+80,self.pos[1]+23))
304 return self.__zone
306 @property
307 def bmp(self):
308 if self.selected == False:
309 if self.connection['I1'].link == None and self.connection['O1'].link == None:
310 self._bmp = wx.Image("images/element/statenoconn.png").ConvertToBitmap()
311 elif self.connection['I1'].link == None:
312 self._bmp = wx.Image("images/element/stateO1conn.png").ConvertToBitmap()
313 elif self.connection['O1'].link == None:
314 self._bmp = wx.Image("images/element/stateI1conn.png").ConvertToBitmap()
315 elif self.connection['I1'].link != None and self.connection['O1'].link != None:
316 self._bmp = wx.Image("images/element/stateconn.png").ConvertToBitmap()
317 else :
318 if self.connection['I1'].link == None and self.connection['O1'].link == None:
319 self._bmp = wx.Image("images/element/statenoconnselect.png").ConvertToBitmap()
320 elif self.connection['I1'].link == None:
321 self._bmp = wx.Image("images/element/stateO1connselect.png").ConvertToBitmap()
322 elif self.connection['O1'].link == None:
323 self._bmp = wx.Image("images/element/stateI1connselect.png").ConvertToBitmap()
324 elif self.connection['I1'].link != None and self.connection['O1'].link != None:
325 self._bmp = wx.Image("images/element/stateconnselect.png").ConvertToBitmap()
326 return self._bmp
328 def select(self):
329 if self.connection['I1'].link == None and self.connection['O1'].link == None:
330 self._bmp = wx.Image("images/element/statenoconnselect.png").ConvertToBitmap()
331 elif self.connection['I1'].link == None:
332 self._bmp = wx.Image("images/element/stateO1connselect.png").ConvertToBitmap()
333 elif self.connection['O1'].link == None:
334 self._bmp = wx.Image("images/element/stateI1connselect.png").ConvertToBitmap()
335 elif self.connection['I1'].link != None and self.connection['O1'].link != None:
336 self._bmp = wx.Image("images/element/stateconnselect.png").ConvertToBitmap()
337 self.selected = True
338 self.project.doNotify()
341 def update(self):
342 ''' Check in Element's equation if it can find solution and tell them'''
343 elemUpdate(self,State.equaState.equationList)
345 allElem.add((State.genericname, State)) # Add State
349 ################################################################################
350 class Transfo(Element):
351 ################################################################################
352 ''' Transformation take variable from a state to transform it with theyr
353 equation, and return result to the next state '''
354 genericNumber = 0
355 genericname = 'transfo'
357 def __init__(self,project,pos):
358 Element.__init__(self,project,pos)
359 self._watchedConnectionVariables=set()
361 @property
362 def watchedConnectionVariables(self):
363 ''' TODO : DOC '''
364 return self._watchedConnectionVariables
366 def connectionChanged(self):
367 ''' Do notification in case of Connection's change'''
368 for x in self.watchedConnectionVariables:
369 x.wantNotif.remove(self)
370 self.watchedConnectionVariables.clear()
371 for x in self.connection:
372 y = self.connection[x].link
373 if y != None:
374 for z in y.elem.properties:
375 y.elem.properties[z].wantNotif.add(self)
376 self.watchedConnectionVariables.add(y.elem.properties[z]) # To be removed from wantNotif later
378 def update(self):
379 ''' Check in Element's equation if it can find solution and tell them'''
380 pass
383 ################################################################################
384 class TransfoInOut(Transfo):
385 ################################################################################
386 ''' Specific class for transformation with one in and one out. '''
387 #Equations
388 equaTransfoInOut = equa.Equation()
389 equaTransfoInOut.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
390 equaTransfoInOut.addEquation(V('flow','I1')-V('flow','O1'))
391 equaTransfoInOut.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
392 equaTransfoInOut.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
393 equaTransfoInOut.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
394 equaTransfoInOut.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
395 equaTransfoInOut.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
396 equaTransfoInOut.processTodo()
398 def __init__(self,project,pos):
399 Transfo.__init__(self,project,pos)
401 ################################################################################
402 class Pump(TransfoInOut):
403 ################################################################################
404 ''' Isentropic pump'''
405 genericNumber = 0
406 genericname = 'pump'
408 #Equations
409 equaPump = equa.Equation()
411 #equaPump.addEquation(V('pressure','O1')/V('pressure','I1') -V('pressure ratio'))
412 equaPump.addEquation(V('pressure','O1')-V('pressure','I1') -V('pressure delta'))
413 equaPump.addEquation(V('polytropic efficiency')-V('specific volume','I1')* \
414 (V('pressure','O1')-V('pressure','I1'))/((V('enthalpy','O1')-V('enthalpy','I1')))) # eta_pi = v dp / dh
415 #We use specific volume from I1 fluid. BE CAREFULL specific volume will change during the process.
416 #User must check if the variation of specific volume doesn't matter !
418 #Energy By convention : when fluid recieve energy, work will be positive, when fluid give energy, work is negative
419 equaPump.addEquation(V('work')+V('enthalpy','I1')-V('enthalpy','O1'))
421 #Power
422 equaPump.addEquation(V('power lost')-V('flow','I1')*V('work')/V('mechanical efficiency'))
423 equaPump.processTodo()
425 def __init__(self,project,pos):
426 TransfoInOut.__init__(self,project,pos)
427 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+55))
428 self.conn1 = self.addConn('fromElem',(70,22),'I1')
429 self.conn2 = self.addConn('toElem',(-5,22),'O1')
430 self.doProp([('pressure delta','floatvar',1),\
431 ('polytropic efficiency','floatvar',2),\
432 ('mechanical efficiency','floatvar',3),\
433 ('work','floatvar',4),\
434 ('power lost','floatvar',5)])
435 #logger.info('Pump created')
437 @property
438 def zone(self):
439 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+55))
440 return self.__zone
442 def update(self):
443 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
444 elemUpdate(self,Pump.equaPump.equationList)
446 allElem.add((Pump.genericname, Pump))
449 ################################################################################
450 class Condenser(TransfoInOut):
451 ################################################################################
452 ''' Isobar and isotherm condenser that impose saturation for fluid out '''
453 genericNumber = 0
454 genericname = 'condenser'
456 #Equation
457 equaCondenser = equa.Equation()
459 #Hypothesis : condenser is isobar , impose saturation
460 equaCondenser.addEquation(V('pressure','I1')-V('pressure','O1'))
461 equaCondenser.addEquation(V('quality','O1'))
462 equaCondenser.addEquation(V('temperature','O1')-V('temperature out'))
463 equaCondenser.addEquation(V('energy lost')+V('enthalpy','I1')-V('enthalpy','O1'))
464 equaCondenser.addEquation(V('power lost')-V('flow','I1')*V('energy lost'))
465 equaCondenser.processTodo()
467 def __init__(self,project,pos):
468 TransfoInOut.__init__(self,project,pos)
469 self.__zone = (self.pos,(self.pos[0]+80,self.pos[1]+50))
470 self.conn1 = self.addConn('fromElem',(33,0),'I1')
471 self.conn2 = self.addConn('toElem',(33,45),'O1')
472 self.doProp([('temperature out','floatvar',1),\
473 ('power lost','floatvar',2),\
474 ('energy lost','floatvar',3)])
475 #logger.info('Condenser created')
477 @property
478 def zone(self):
479 self.__zone = (self.pos,(self.pos[0]+80,self.pos[1]+50))
480 return self.__zone
482 def update(self):
483 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
484 elemUpdate(self,Condenser.equaCondenser.equationList)
486 allElem.add((Condenser.genericname, Condenser))
489 ################################################################################
490 class Boiler(TransfoInOut):
491 ################################################################################
492 ''' Isobar boiler with no combustion compute'''
493 genericNumber = 0
494 genericname = 'boiler'
496 #Equation
497 equaBoiler = equa.Equation()
499 #Hypothesis : boiler is isobar
500 equaBoiler.addEquation(V('temperature','O1')-V('temperature out'))
501 equaBoiler.addEquation(V('pressure','O1')-V('pressure','I1'))
502 equaBoiler.addEquation(V('power')-V('flow','I1')*(V('enthalpy','I1')-V('enthalpy','O1'))/V('efficiency'))
503 equaBoiler.addEquation(V('power lost')-(K(1)-V('efficiency'))*V('power'))
504 equaBoiler.processTodo()
506 def __init__(self,project,pos):
507 TransfoInOut.__init__(self,project,pos)
508 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+110))
509 self.conn1 = self.addConn('fromElem',(32.5,105),'I1')
510 self.conn2 = self.addConn('toElem',(33,0),'O1')
511 self.doProp([('temperature out','floatvar',1),\
512 ('efficiency','floatvar',2),\
513 ('power','floatvar',3),\
514 ('power lost','floatvar',4)])
515 #logger.info('Boiler created')
517 @property
518 def zone(self):
519 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+110))
520 return self.__zone
522 def update(self):
523 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
524 elemUpdate(self,Boiler.equaBoiler.equationList)
526 allElem.add((Boiler.genericname, Boiler))
529 ################################################################################
530 class Turbine(TransfoInOut):
531 ################################################################################
532 ''' Turbine '''
533 genericNumber = 0
534 genericname = 'turbine'
536 #Equation
537 equaTurbine = equa.Equation()
539 #Hypothesis
540 equaTurbine.addEquation(V('isentropic efficiency')- \
541 ((V('enthalpy','I1')-V('enthalpy','O1'))/ \
542 (V('enthalpy','I1')-equa.h_ps(V('pressure','O1'),V('entropy','I1')))))
544 equaTurbine.addEquation(V('enthalpy','I1')- \
545 (V('isentropic efficiency')*equa.h_ps(V('pressure','O1'), \
546 V('entropy','I1'))-V('enthalpy','O1'))/(V('isentropic efficiency')-K(1)))
547 #Besoin des deux equations en cas de redondance des variables dans les equations.
549 #Energy convention : when fluid recieve energy, work will be positive, when fluid give energy, work is negative
550 equaTurbine.addEquation(V('work')+V('enthalpy','I1')-V('enthalpy','O1'))
551 equaTurbine.addEquation(V('power')-V('mechanical efficiency')*V('flow','I1')*(V('work')))
552 equaTurbine.addEquation(V('power lost')-(K(1)-V('mechanical efficiency'))*V('flow','I1')*(V('work')))
553 equaTurbine.processTodo()
555 def __init__(self,project,pos):
556 TransfoInOut.__init__(self,project,pos)
557 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+78))
558 self.conn1 = self.addConn('fromElem',(0,27),'I1')
559 self.conn2 = self.addConn('toElem',(63,70),'O1')
560 self.doProp([('isentropic efficiency','floatvar',1),\
561 ('mechanical efficiency','floatvar',2),\
562 ('work','floatvar',3),\
563 ('power','floatvar',4),\
564 ('power lost','floatvar',5)])
565 #logger.info('Turbine created')
567 @property
568 def zone(self):
569 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+78))
570 return self.__zone
572 def update(self):
573 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
574 elemUpdate(self,Turbine.equaTurbine.equationList)
576 allElem.add((Turbine.genericname, Turbine))
579 ################################################################################
580 class Delta(TransfoInOut):
581 ################################################################################
582 ''' Delta allow to impose delat of pressure, temperature,enthalpy,
583 entropy and exergy between In and Out '''
584 genericNumber = 0
585 genericname = 'delta'
587 #Equation
588 equaDelta = equa.Equation()
589 equaDelta.addEquation(V('delta temperature')+V('temperature','I1')-V('temperature','O1'))
590 equaDelta.addEquation(V('delta pressure')+V('pressure','I1')-V('pressure','O1'))
591 equaDelta.addEquation(V('delta enthalpy')+V('enthalpy','I1')-V('enthalpy','O1'))
592 equaDelta.addEquation(V('delta entropy')+V('entropy','I1')-V('entropy','O1'))
593 equaDelta.addEquation(V('delta exergy')+V('exergy','I1')-V('exergy','O1'))
594 equaDelta.processTodo()
596 def __init__(self,project,pos):
597 TransfoInOut.__init__(self,project,pos)
598 self.__zone = (self.pos,(self.pos[0]+50,self.pos[1]+50))
599 self.conn1 = self.addConn('toElem',(-5,20),'O1')
600 self.conn2 = self.addConn('fromElem',(45,20),'I1')
601 self.doProp( [('delta temperature','floatvar',1),\
602 ('delta pressure','floatvar',2),\
603 ('delta enthalpy','floatvar',3),\
604 ('delta entropy','floatvar',4),\
605 ('delta exergy','floatvar',5)] )
606 #logger.info('Delta created')
608 @property
609 def zone(self):
610 self.__zone = (self.pos,(self.pos[0]+50,self.pos[1]+50))
611 return self.__zone
613 def update(self):
614 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
615 elemUpdate(self,Delta.equaDelta.equationList)
617 allElem.add((Delta.genericname, Delta))
620 ################################################################################
621 class ExtractionTurbine(Transfo):
622 ################################################################################
623 ''' Turbine with one extraction set at the middle of enthalpy '''
624 genericNumber = 0
625 genericname = 'extraction turbine'
626 equaExTurb = equa.Equation()
628 #Pour la sortie O1 normale:
629 equaExTurb.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
630 equaExTurb.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
631 equaExTurb.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
632 equaExTurb.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
633 equaExTurb.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
634 equaExTurb.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
636 #Besoin des deux equations car redondance des variables dans les equations.
637 equaExTurb.addEquation(V('isentropic efficiency')-((V('enthalpy','I1')-V('enthalpy','O1'))/(V('enthalpy','I1')-equa.h_ps(V('pressure','O1'),V('entropy','I1')))))
638 equaExTurb.addEquation(V('enthalpy','I1')-(V('isentropic efficiency')*equa.h_ps(V('pressure','O1'),V('entropy','I1'))-V('enthalpy','O1'))/(V('isentropic efficiency')-K(1)))
640 #Pour la sortie O2 soutiree:
641 equaExTurb.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O2')))
642 equaExTurb.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O2'))
643 equaExTurb.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O2'))
644 equaExTurb.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O2'))
645 equaExTurb.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O2'))
646 equaExTurb.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O2'))
648 #Besoin des deux equations car redondance des variables dans les equations.
649 equaExTurb.addEquation(V('isentropic efficiency')-((V('enthalpy','I1')-V('enthalpy','O2'))/(V('enthalpy','I1')-equa.h_ps(V('pressure','O2'),V('entropy','I1')))))
650 equaExTurb.addEquation(V('enthalpy','I1')-(V('isentropic efficiency')*equa.h_ps(V('pressure','O2'),V('entropy','I1'))-V('enthalpy','O2'))/(V('isentropic efficiency')-K(1)))
651 #On trouve la pression a partir d'un etat isentropique,qui est la meme que l'etat normal. : h7s obtenu avec l'equation du rendement: H3-(H3-H7(i))/RendIsTu, s7s = sI1
652 equaExTurb.addEquation(V('pressure','O2')-equa.p_hs((V('enthalpy','I1')-((V('enthalpy','I1')-V('enthalpy','O2'))/V('isentropic efficiency'))) ,V('entropy','I1')))
656 #L'enthalpie de la fraction soutiree est par hypothese au milieu entre celle de l'entree de celle de sortie
657 equaExTurb.addEquation(V('enthalpy','O2')-V('enthalpy','I1')/K(2)-V('enthalpy','O1')/K(2))
658 #Flow
659 equaExTurb.addEquation(V('flow','I1')-V('flow','O1')-V('flow','O2'))
660 # Attention aux conventions sur le signe du travail, Wmt*FlowO1 = (h3-h4)*FlowO1+(h3-h7)*FlowO2
661 equaExTurb.addEquation(V('work')*V('flow','I1') + (V('enthalpy','I1')-V('enthalpy','O1'))* V('flow','O1') + (V('enthalpy','I1')-V('enthalpy','O2')) * V('flow','O2') )
663 #Equation similaire au travail, sauf qu'on ne multiplie plus le travail par flow
664 equaExTurb.addEquation(V('power') + V('work')*V('flow','I1') )
666 equaExTurb.addEquation(V('power lost')-(K(1)-V('mechanical efficiency'))*V('flow','I1')*(V('work')))
668 equaExTurb.processTodo()
670 def __init__(self, project,pos):
671 Transfo.__init__(self, project,pos)
672 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+78))
673 self.conn1 = self.addConn('toElem',(63,70),'O1') #first out = normal way
674 self.conn2 = self.addConn('toElem',(27,58),'O2') #second out = extract way
675 self.conn3 = self.addConn('fromElem',(0,27),'I1')
676 self.doProp([('isentropic efficiency','floatvar',1),\
677 ('mechanical efficiency','floatvar',2),\
678 ('work','floatvar',3),\
679 ('power','floatvar',4),\
680 ('power lost','floatvar',5)])
682 @property
683 def zone(self):
684 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+78))
685 return self.__zone
687 def update(self):
688 elemUpdate(self,ExtractionTurbine.equaExTurb.equationList)
690 allElem.add((ExtractionTurbine.genericname, ExtractionTurbine))
693 ################################################################################
694 class HeaterCondenser(Transfo):
695 ################################################################################
696 ''' Heat exchanger contercurrent where the hot fluid get out at saturation '''
697 #User must be carefull when he connect Hot fluid and Cold fluid!
698 #Hot fluid is line 1
699 #Cold fluid is line 2
700 genericNumber = 0
701 genericname = 'heater condenser' #page 70
702 equaHeaterCond = equa.Equation()
703 #Hypothesis: exchanger condenser set titre at 0 for hot fluid, is isobar
704 #Line 1 Hot fluid:
705 equaHeaterCond.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
706 equaHeaterCond.addEquation(V('flow','I1')-V('flow','O1'))
707 equaHeaterCond.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
708 equaHeaterCond.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
709 equaHeaterCond.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
710 equaHeaterCond.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
711 equaHeaterCond.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
712 equaHeaterCond.addEquation(V('quality','O1')-K(0))
713 equaHeaterCond.addEquation(V('pressure','I1')-V('pressure','O1'))
714 #Line 2 Cold fluid: hot part of these line = cold part of line 1 - delta temperature between the two fluid at the begining of line 2 (= pincement)
715 equaHeaterCond.addEquation(equa.PropagateFluid(V('fluid','I2'),V('fluid','O2')))
716 equaHeaterCond.addEquation(V('flow','I2')-V('flow','O2'))
717 equaHeaterCond.addEquation(equa.RefVar('reference temperature','I2')-equa.RefVar('reference temperature','O2'))
718 equaHeaterCond.addEquation(equa.RefVar('reference entropy','I2')-equa.RefVar('reference entropy','O2'))
719 equaHeaterCond.addEquation(equa.RefVar('reference enthalpy','I2')-equa.RefVar('reference enthalpy','O2'))
720 equaHeaterCond.addEquation(equa.RefVar('reference quality','I2')-equa.RefVar('reference quality','O2'))
721 equaHeaterCond.addEquation(equa.RefVar('reference pressure','I2')-equa.RefVar('reference pressure','O2'))
722 equaHeaterCond.addEquation(V('pressure','I2')-V('pressure','O2'))
723 equaHeaterCond.addEquation(V('delta T')+V('temperature','O1')-V('temperature','O2')) #faire un schema d'un echangeur contrecourant
725 #Equation for flow
726 equaHeaterCond.addEquation(V('flow','I1')*(V('enthalpy','I1')-V('enthalpy','O1'))-V('flow','I2')*(V('enthalpy','O2')-V('enthalpy','I2')))
727 equaHeaterCond.addEquation(V('delta flow')+V('flow','I1')-V('flow','I2'))
729 equaHeaterCond.processTodo()
732 def __init__(self,project,pos):
733 Transfo.__init__(self,project,pos)
734 self.__zone = (self.pos,(self.pos[0]+60,self.pos[1]+60))
735 self.conn1 = self.addConn('fromElem',(25,0),'I1')
736 self.conn2 = self.addConn('toElem',(25,45),'O1')
737 self.conn3 = self.addConn('fromElem',(50,23),'I2')
738 self.conn4 = self.addConn('toElem',(0,23),'O2')
739 self.doProp([('delta T','floatvar',1),\
740 ('delta flow','floatvar',2)])
742 @property
743 def zone(self):
744 self.__zone = (self.pos,(self.pos[0]+60,self.pos[1]+60))
745 return self.__zone
747 def update(self):
748 elemUpdate(self,HeaterCondenser.equaHeaterCond.equationList)
750 allElem.add((HeaterCondenser.genericname, HeaterCondenser))
752 ################################################################################
753 class Subcooler(Transfo):
754 ################################################################################
755 ''' Heat exchanger contercurrent with specific hypothesis and no
756 LMTD calculation '''
757 #User must be carefull when he connect Hot fluid and Cold fluid!
758 #Hot fluid is line 1
759 #Cold fluid is line 2
760 genericNumber = 0
761 genericname = 'subcooler' #page 70
762 equaSC = equa.Equation()
763 #Hypothesis: exchanger condenser set titre at 0 for hot fluid, is isobar
764 #Line 1 Hot fluid:
765 equaSC.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
766 equaSC.addEquation(V('flow','I1')-V('flow','O1'))
767 equaSC.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
768 equaSC.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
769 equaSC.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
770 equaSC.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
771 equaSC.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
772 equaSC.addEquation(V('pressure','I1')-V('pressure','O1'))
773 #Line 2 Cold fluid: hot part of these line = cold part of line 1 - delta temperature between the two fluid at the begining of line 2 (= pincement)
774 equaSC.addEquation(equa.PropagateFluid(V('fluid','I2'),V('fluid','O2')))
775 equaSC.addEquation(V('flow','I2')-V('flow','O2'))
776 equaSC.addEquation(equa.RefVar('reference temperature','I2')-equa.RefVar('reference temperature','O2'))
777 equaSC.addEquation(equa.RefVar('reference entropy','I2')-equa.RefVar('reference entropy','O2'))
778 equaSC.addEquation(equa.RefVar('reference enthalpy','I2')-equa.RefVar('reference enthalpy','O2'))
779 equaSC.addEquation(equa.RefVar('reference quality','I2')-equa.RefVar('reference quality','O2'))
780 equaSC.addEquation(equa.RefVar('reference pressure','I2')-equa.RefVar('reference pressure','O2'))
781 equaSC.addEquation(V('pressure','I2')-V('pressure','O2'))
782 equaSC.addEquation(V('delta T')+V('temperature','I2')-V('temperature','O1')) #faire un schema d'un echangeur contrecourant
783 #Equation for flow
784 equaSC.addEquation(V('flow','I1')*(V('enthalpy','I1')-V('enthalpy','O1'))-V('flow','I2')*(V('enthalpy','O2')-V('enthalpy','I2')))
785 equaSC.addEquation(V('delta flow')+V('flow','I1')-V('flow','I2'))
786 equaSC.processTodo()
787 equaSC.processTodo()
790 def __init__(self,project,pos):
791 Transfo.__init__(self,project,pos)
792 self.__zone = (self.pos,(self.pos[0]+60,self.pos[1]+60))
793 self.conn1 = self.addConn('fromElem',(25,0),'I1')
794 self.conn2 = self.addConn('toElem',(25,45),'O1')
795 self.conn3 = self.addConn('fromElem',(50,23),'I2')
796 self.conn4 = self.addConn('toElem',(0,23),'O2')
797 self.doProp([('delta T','floatvar',1),\
798 ('delta flow','floatvar',2)])
800 @property
801 def zone(self):
802 self.__zone = (self.pos,(self.pos[0]+60,self.pos[1]+60))
803 return self.__zone
805 def update(self):
806 elemUpdate(self,Subcooler.equaSC.equationList)
808 allElem.add((Subcooler.genericname, Subcooler))
810 ################################################################################
811 class Valve(TransfoInOut):
812 ################################################################################
813 ''' Valve'''
814 genericNumber = 0
815 genericname = 'valve'
817 #Equation
818 equaValve = equa.Equation()
819 #hypothesis: adiabatic+no work = isenthalpic
820 equaValve.addEquation(V('enthalpy','I1')-V('enthalpy','O1'))
821 equaValve.addEquation(V('pressure','O1')-V('pressure','I1')-V('delta pressure'))
822 equaValve.processTodo()
824 def __init__(self, project,pos):
825 TransfoInOut.__init__(self, project,pos)
826 self.__zone = (self.pos,(self.pos[0]+76,self.pos[1]+27))
827 self.conn1 = self.addConn('toElem',(0,9),'O1')
828 self.conn2 = self.addConn('fromElem',(74,9),'I1')
829 self.doProp([('delta pressure','floatvar',1)])
832 @property
833 def zone(self):
834 self.__zone = (self.pos,(self.pos[0]+76,self.pos[1]+27))
835 return self.__zone
837 def update(self):
838 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
839 elemUpdate(self,Valve.equaValve.equationList)
842 allElem.add((Valve.genericname, Valve))
844 ################################################################################
845 class ExtractCondenser(Transfo):
846 ################################################################################
847 '''Condenser with two In and one Out'''
848 genericNumber = 0
849 genericname = 'extract condenser'
851 #Equation
852 eq = equa.Equation()
853 eq.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
854 eq.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
855 eq.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
856 eq.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
857 eq.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
858 eq.addEquation(equa.RefVar('reference temperature','I2')-equa.RefVar('reference temperature','O1'))
859 eq.addEquation(equa.RefVar('reference entropy','I2')-equa.RefVar('reference entropy','O1'))
860 eq.addEquation(equa.RefVar('reference enthalpy','I2')-equa.RefVar('reference enthalpy','O1'))
861 eq.addEquation(equa.RefVar('reference quality','I2')-equa.RefVar('reference quality','O1'))
862 eq.addEquation(equa.RefVar('reference pressure','I2')-equa.RefVar('reference pressure','O1'))
863 #hypothesis:
864 eq.addEquation(V('pressure','I1')-V('pressure','O1'))
865 eq.addEquation(V('pressure','I2')-V('pressure','O1'))
866 eq.addEquation(V('temperature','I1')-V('temperature','O1'))
867 eq.addEquation(V('temperature','I2')-V('temperature','O1'))
868 eq.addEquation(V('quality','O1')-K(0))
869 eq.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
870 eq.addEquation(equa.PropagateFluid(V('fluid','I2'),V('fluid','O1')))
871 eq.addEquation(V('flow','I1')+V('flow','I2')-V('flow','O1'))
872 # P = (hI1-h4)*flowI1 + (hI2-h4)*flowI2
873 eq.addEquation(V('power lost')-(V('enthalpy','O1')-V('enthalpy','I1'))*V('flow','I1')-(V('enthalpy','O1')-V('enthalpy','I2'))*V('flow','I2'))
874 eq.addEquation(V('temperature out')-V('temperature','O1'))
875 eq.processTodo()
877 def __init__(self,project,pos):
878 Transfo.__init__(self,project,pos)
879 self.__zone = (self.pos,(self.pos[0]+80,self.pos[1]+50))
880 self.conn1 = self.addConn('fromElem',(33,0),'I1')
881 self.conn1 = self.addConn('fromElem',(0,20),'I2')
882 self.conn2 = self.addConn('toElem',(33,45),'O1')
883 self.doProp([('temperature out','floatvar',1),\
884 ('power lost','floatvar',2)])
886 @property
887 def zone(self):
888 self.__zone = (self.pos,(self.pos[0]+80,self.pos[1]+50))
889 return self.__zone
891 def update(self):
892 elemUpdate(self,ExtractCondenser.eq.equationList)
894 allElem.add((ExtractCondenser.genericname, ExtractCondenser))
895 ################################################################################
896 class Mixer(Transfo):
897 ################################################################################
898 ''' Mix two fluid with the SAME properties except for flows'''
899 genericNumber = 0
900 genericname = 'mixer'
902 #Equation
903 eq = equa.Equation()
904 eq.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
905 eq.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
906 eq.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
907 eq.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
908 eq.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
909 eq.addEquation(equa.RefVar('reference temperature','I2')-equa.RefVar('reference temperature','O1'))
910 eq.addEquation(equa.RefVar('reference entropy','I2')-equa.RefVar('reference entropy','O1'))
911 eq.addEquation(equa.RefVar('reference enthalpy','I2')-equa.RefVar('reference enthalpy','O1'))
912 eq.addEquation(equa.RefVar('reference quality','I2')-equa.RefVar('reference quality','O1'))
913 eq.addEquation(equa.RefVar('reference pressure','I2')-equa.RefVar('reference pressure','O1'))
915 #hypothesis : isobare and SAME fluid
916 eq.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
917 eq.addEquation(equa.PropagateFluid(V('fluid','I2'),V('fluid','O1')))
918 eq.addEquation(V('pressure','I1')-V('pressure','O1'))
919 eq.addEquation(V('pressure','I2')-V('pressure','O1'))
920 #Bilan de masse
921 eq.addEquation(V('flow','O1')-V('flow','I1')-V('flow','I2'))
922 #Bilan d'energie
923 eq.addEquation(V('enthalpy','O1')-(V('flow','I1')*V('enthalpy','I1')+V('flow','I2')*V('enthalpy','I2'))/V('flow','O1'))
924 eq.processTodo()
926 def __init__(self, project,pos):
927 Transfo.__init__(self, project,pos)
928 self.__zone = (self.pos,(self.pos[0]+76,self.pos[1]+27))
929 self.conn1 = self.addConn('toElem',(0,8),'O1')
930 self.conn2 = self.addConn('fromElem',(74,-3),'I1')
931 self.conn3 = self.addConn('fromElem',(74,21),'I2')
934 @property
935 def zone(self):
936 self.__zone = (self.pos,(self.pos[0]+76,self.pos[1]+27))
937 return self.__zone
939 def update(self):
940 elemUpdate(self,Mixer.eq.equationList)
943 allElem.add((Mixer.genericname, Mixer))
946 ################################################################################
947 class Demixer(Transfo):
948 ################################################################################
949 ''' Split fluid in two '''
950 genericNumber = 0
951 genericname = 'demixer'
953 #Equation
954 eq = equa.Equation()
955 eq.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O1'))
956 eq.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O1'))
957 eq.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O1'))
958 eq.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O1'))
959 eq.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O1'))
960 eq.addEquation(equa.RefVar('reference temperature','I1')-equa.RefVar('reference temperature','O2'))
961 eq.addEquation(equa.RefVar('reference entropy','I1')-equa.RefVar('reference entropy','O2'))
962 eq.addEquation(equa.RefVar('reference enthalpy','I1')-equa.RefVar('reference enthalpy','O2'))
963 eq.addEquation(equa.RefVar('reference quality','I1')-equa.RefVar('reference quality','O2'))
964 eq.addEquation(equa.RefVar('reference pressure','I1')-equa.RefVar('reference pressure','O2'))
966 #Hypothesis :
967 eq.addEquation(equa.PropagateFluid(V('fluid','I1'),V('fluid','O1')))
968 eq.addEquation(V('flow','I1')-V('flow','O1')-V('flow','O2'))
969 eq.addEquation(V('flow','I1')*V('fraction flow')-V('flow','O1'))
970 eq.addEquation(V('flow','I1')*(K(1)-V('fraction flow'))-V('flow','O1'))
971 eq.processTodo()
973 def __init__(self, project,pos):
974 Transfo.__init__(self, project,pos)
975 self.__zone = (self.pos,(self.pos[0]+76,self.pos[1]+27))
976 self.conn1 = self.addConn('toElem',(0,-3),'O1')
977 self.conn2 = self.addConn('toElem',(0,21),'O2')
978 self.conn3 = self.addConn('fromElem',(74,8),'I1')
979 self.doProp = ([('fraction flow','floatvar',1)])
981 @property
982 def zone(self):
983 self.__zone = (self.pos,(self.pos[0]+76,self.pos[1]+27))
984 return self.__zone
986 def update(self):
987 elemUpdate(self,Demixer.eq.equationList)
989 allElem.add((Demixer.genericname, Demixer))
991 ################################################################################
992 class Compressor(TransfoInOut):
993 ################################################################################
994 genericNumber = 0
995 genericname = 'compressor'
997 #Equation
998 eq = equa.Equation()
999 #hypothesys:
1000 #specific heat is the same for all the transformation
1002 eq.addEquation((V('pressure','O1')/V('pressure','I1'))**((V('gamma')-K(1))/(V('gamma')*V('polytropic efficiency')))-V('temperature','O1')/V('temperature','I1'))
1003 eq.addEquation(V('pressure','O1')/V('pressure','I1')-V('pressure ratio'))
1004 eq.addEquation(V('power lost')-V('flow','I1')*(V('enthalpy','I1')-V('enthalpy','O1')))
1006 eq.processTodo()
1008 def __init__(self,project,pos):
1009 TransfoInOut.__init__(self,project,pos)
1010 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+55))
1011 self.conn1 = self.addConn('fromElem',(70,22),'I1')
1012 self.conn2 = self.addConn('toElem',(-5,22),'O1')
1013 self.doProp([('pressure ratio','floatvar',1),\
1014 ('polytropic efficiency','floatvar',2),\
1015 ('gamma','floatvar',3),\
1016 ('power lost','floatvar',4)])
1018 @property
1019 def zone(self):
1020 self.__zone = (self.pos,(self.pos[0]+75,self.pos[1]+55))
1021 return self.__zone
1023 def update(self):
1024 elemUpdate(self,TransfoInOut.equaTransfoInOut.equationList)
1025 elemUpdate(self,Compressor.eq.equationList)
1027 allElem.add((Compressor.genericname,Compressor))