def _fixed(self): """Calculate fixed properties with the chemical compound ids specified, valid only for one component""" x = self._x() fluido = self._name() refprop.setup("def", fluido) info = refprop.info() self.M = unidades.Dimensionless(info["wmm"]) self.Tt = unidades.Temperature(info["ttrp"]) self.Tb = unidades.Temperature(info["tnbpt"]) self.Tc = unidades.Temperature(info["tcrit"]) self.R = unidades.SpecificHeat(info["Rgas"]/self.M) self.f_accent = unidades.Dimensionless(info["acf"]) self.momentoDipolar = unidades.DipoleMoment(info["dip"], "Debye") self.rhoc = unidades.Density(info["Dcrit"]*self.M) self.zc = unidades.Dimensionless(info["zcrit"]) self.Pc = unidades.Pressure(self.R*self.Tc*self.rhoc*self.zc, "kPa") name = refprop.name() self.name = name["hname"] self.CAS = name["hcas"]
def _maintest(rp): #examples and test setup rp.SetErrorDebug.off() #turn on =>> for testing purpose if rp.test(): #if True; rptest =>>for testing purpose print u'refprop installed correctely' print u'test results' print rp.testresult print u'fluidlib' rp.fluidlib() print u'\n' prop = rp.setup( u'def', u'air', ) print u'setup air' print prop, u'\n' x = prop[u'x'] print u'critp(x)' print rp.critp(x), u'\n' print u'setup water ammonia' print rp.setup( u'def', u'water', u'ammonia', ), u'\n' #alternative setup input rp.setup( u'def', [u'water', u'ammonia'], ) x = [0.5, 0.3] prop = rp.normalize(x) x = prop[u'x'] prop = rp.critp(x) prop = rp.therm(prop[u'tcrit'], prop[u'Dcrit'], x) print u'therm' print prop, u'\n' p = prop[u'p'] print u'therm2' print rp.therm2(prop[u't'], prop[u'D'], x), u'\n' print u'therm0' print rp.therm0(prop[u't'], prop[u'D'], x), u'\n' print u'residual' print rp.residual(prop[u't'], prop[u'D'], x), u'\n' print u'entro' print rp.entro(prop[u't'], prop[u'D'], x), u'\n' print u'enthal' print rp.enthal(prop[u't'], prop[u'D'], x), u'\n' print u'ag' print rp.ag(prop[u't'], prop[u'D'], x), u'\n' print u'cvcp' print rp.cvcp(prop[u't'], prop[u'D'], x), u'\n' print u'dddp' print rp.dddp(prop[u't'], prop[u'D'], x), u'\n' print u'dddt' print rp.dddt(prop[u't'], prop[u'D'], x), u'\n' print u'dhd1' print rp.dhd1(prop[u't'], prop[u'D'], x), u'\n' print u'dpdd' print rp.dpdd(prop[u't'], prop[u'D'], x), u'\n' print u'dpdd2' print rp.dpdd2(prop[u't'], prop[u'D'], x), u'\n' print u'dpdt' print rp.dpdt(prop[u't'], prop[u'D'], x), u'\n' D = prop[u'D'] #function not supported in Windows if platform.system() == u'Linux': print u'dcdt' print rp.dcdt(prop[u't'], x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'dcdt2' print rp.dcdt2(prop[u't'], x), u'\n' print u'fgcty' print rp.fgcty(prop[u't'], D, x), u'\n' print u'gibbs' print rp.gibbs(prop[u't'], prop[u'D'], x), u'\n' #~ print('fgcty2') #~ print(rp.fgcty2(prop['t'], prop['D'], x), '\n') prop = rp.therm3(prop[u't'], prop[u'D'], x) print u'therm3' print prop, u'\n' D = prop[u'D'] print u'virb' print rp.virb(prop[u't'], x), u'\n' print u'virc' print rp.virc(prop[u't'], x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'vird' print rp.vird(prop[u't'], x), u'\n' print u'virba' print rp.virba(prop[u't'], x), u'\n' print u'virca' print rp.virca(prop[u't'], x), u'\n' print u'cvcpk' print rp.cvcpk(1, prop[u't'], D), u'\n' print u'dbdt' print rp.dbdt(prop[u't'], x), u'\n' print u'dpddk' print rp.dpddk(1, prop[u't'], D), u'\n' print u'dpdtk' print rp.dpdtk(2, prop[u't'], D), u'\n' D = 55 t = 373 prop = rp.press(t, D, x) print u'press' print prop, u'\n' p = prop[u'p'] print u'purefld(1)' prop = rp.purefld(1) print prop, u'\n' x = [1] resetup_test_prop_d = prop print u'satt' prop = rp.satt(t, x) print prop, u'\n' print u'satp' prop = rp.satp(prop[u'p'], x) print prop, u'\n' print u'satd' print rp.satd(prop[u'Dliq'], x), u'\n' print u'sath' print rp.sath(47000, x, 0), u'\n' print u'sate' print rp.sate(0.96047E-13, x), u'\n' print u'sats' print rp.sats(50, x, 0), u'\n' print u'purefld(0)' print rp.purefld(0), u'\n' x = [0.5, 0.3] x = rp.normalize(x)[u'x'] print u'csatk' print rp.csatk(1, t), u'\n' print u'dptsatk' print rp.dptsatk(1, t), u'\n' print u'cv2pk' print rp.cv2pk(2, t, D), u'\n' print u'tprho' print rp.tprho(t, p, x, 2, 1, 58), u'\n' print u'flsh, tp' prop = rp.flsh(u'tp', t, p, x) print prop, u'\n' print u'flsh, th' print rp.flsh(u'tH', 305, prop[u'h'], x, 1), u'\n' print u'flsh, tD' print rp.flsh(u'tD', t, 30, x), u'\n' print u'info()' print rp.info(), u'\n' print u'info(2)' print rp.info(2), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'rmix2' print rp.rmix2(x), u'\n' print u'xmass' prop = rp.xmass(x) print prop, u'\n' print u'xmole' print rp.xmole(prop[u'xkg']), u'\n' print u'limitx' print rp.limitx(x, u'eos', t, D, p), u'\n' print u'limitk' print rp.limitk(u'eos', 1, t, D, p), u'\n' print u'limits' print rp.limits(x), u'\n' print u'flsh, ts' prop = rp.flsh(u'ts', t, 40, x) print prop, u'\n' print u'flsh, te' print rp.flsh(u'te', t, prop[u'e'], x), u'\n' print u'flsh, pD' prop = rp.flsh(u'Pd', p, D, x) print prop, u'\n' print u'flsh, ph' prop = rp.flsh(u'ph', p, prop[u'h'], x) print prop, u'\n' print u'flsh, ps' prop = rp.flsh(u'ps', p, prop[u's'], x) print prop, u'\n' print u'flsh, pe' prop = rp.flsh(u'pE', p, prop[u'e'], x) print prop, u'\n' print u'flsh, es' prop = rp.flsh(u'es', prop[u'e'], prop[u's'], x) print prop, u'\n' print u'flsh, hs' prop = rp.flsh(u'hs', 40000, 100, x) print prop, u'\n' print u'flsh, es' print rp.flsh(u'es', 175, 13, x), u'\n' print u'flsh, Dh' print rp.flsh(u'DH', 20, 18000, x), u'\n' print u'flsh, Ds' prop = rp.flsh(u'Ds', 20, 50, x) print prop, u'\n' print u'flsh, De' prop = rp.flsh(u'DE', 20, prop[u'e'], x) print prop, u'\n' print u'flsh, tq' prop = rp.flsh(u'tq', t, prop[u'q'], x) print prop, u'\n' print u'flsh, pq' print rp.flsh(u'pq', 1200, prop[u'q'], x), u'\n' prop = rp.flsh(u'tp', 350, 1200, x) print u'flsh, tp' print prop, u'\n' s = prop[u's'] e = prop[u'e'] h = prop[u'h'] D = prop[u'D'] t = prop[u't'] p = prop[u'p'] Dmin = 40 Dmax = 55 print u'flsh1, liq, ph' print rp.flsh1(u'Ph', p, h, x, 1), u'\n' print u'getphase' print rp.getphase(prop), u'\n' print u'flsh1, liq, pD' print rp.flsh1(u'PD', p, D, x), u'\n' print u'flsh1, liq, ps' print rp.flsh1(u'Ps', p, s, x), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, th' print rp.flsh1(u'th', t, h, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, ts' print rp.flsh1(u'ts', t, s, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, te' print rp.flsh1(u'te', t, e, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, pe' print rp.flsh1(u'Pe', p, e, x), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, hs' print rp.flsh1(u'hs', h, s, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, Dh' print rp.flsh1(u'Dh', D, h, x), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, Ds' print rp.flsh1(u'Ds', D, s, x), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, liq, De' print rp.flsh1(u'De', D, e, x), u'\n' prop = rp.flsh(u'tp', 400, 100, x) s = prop[u's'] e = prop[u'e'] h = prop[u'h'] D = prop[u'D'] Dmin = 0.01 Dmax = 0.05 t = prop[u't'] p = prop[u'p'] print u'flsh1, vap, ph' print rp.flsh1(u'Ph', p, h, x, 2), u'\n' print u'getphase' print rp.getphase(prop), u'\n' print u'flsh1, vap, pD' print rp.flsh1(u'PD', p, D, x, 2), u'\n' print u'flsh1, vap, ps' print rp.flsh1(u'Ps', p, s, x, 2), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, th' print rp.flsh1(u'th', t, h, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, ts' print rp.flsh1(u'ts', t, s, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, te' print rp.flsh1(u'te', t, e, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, pe' print rp.flsh1(u'Pe', p, e, x, 2), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, hs' print rp.flsh1(u'hs', h, s, x, Dmin=Dmin, Dmax=Dmax), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, Dh' print rp.flsh1(u'Dh', D, h, x), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, Ds' print rp.flsh1(u'Ds', D, s, x), u'\n' #unsupported in Windows if platform.system() == u'Linux': print u'flsh1, vap, De' print rp.flsh1(u'De', D, e, x), u'\n' print u'cstar' print rp.cstar(t, p, 8, x), u'\n' print u'fpv' print rp.fpv(t, D, p, x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'excess' print rp.excess(t, p, x, kph=2), u'\n' prop = rp.flsh(u'pq', 1200, 0.65, x) D = prop[u'D'] Dliq = prop[u'Dliq'] Dvap = prop[u'Dvap'] xliq = prop[u'xliq'] xvap = prop[u'xvap'] e = prop[u'e'] h = prop[u'h'] s = prop[u's'] q = prop[u'q'] p = prop[u'p'] t = prop[u't'] #function not supported in Windows if platform.system() == u'Linux': print u'tpfl2' print rp.flsh2(u'tp', t, p, x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'Dhfl2' print rp.flsh2(u'Dh', D, h, x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'Dsfl2' print rp.flsh2(u'Ds', D, s, x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'Defl2' print rp.flsh2(u'De', D, e, x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'thfl2' print rp.flsh2(u'th', t, h, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'tsfl2' print rp.flsh2(u'ts', t, s, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'tefl2' print rp.flsh2(u'te', t, e, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'tDfl2' print rp.flsh2(u'tD', t, D, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'pDfl2' print rp.flsh2(u'pD', p, D, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'phfl2' print rp.flsh2(u'ph', p, h, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'psfl2' print rp.flsh2(u'ps', p, s, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'pefl2' print rp.flsh2(u'pe', p, e, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'tqfl2' print rp.flsh2(u'tq', t, q, x, ksat=0), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'pqfl2' print rp.flsh2(u'pq', p, q, x, ksat=0), u'\n' #function not supported in Windows #~ if platform.system() == 'Linux': #~ print('Dqfl2') #~ print(rp.flsh2('Dq', D, q, x), '\n') prop = rp.flsh(u'tp', 340, 100, x) t = prop[u't'] Dliq = prop[u'Dliq'] Dvap = prop[u'Dvap'] xliq = prop[u'xliq'] xvap = prop[u'xvap'] print u'qmass' prop = rp.qmass(prop[u'q'], xliq, xvap) print prop, u'\n' print u'qmole' print rp.qmole(prop[u'qkg'], prop[u'xlkg'], prop[u'xvkg']), u'\n' print u'wmol' print rp.wmol(x), u'\n' prop = rp.flsh(u'tp', 340, 100, x) print u'dielec' print rp.dielec(prop[u't'], prop[u'D'], x), u'\n' print u'surten' print rp.surten(t, Dliq, Dvap, xliq, xvap), u'\n' print u'surft' print rp.surft(240, x), u'\n' rp.setup(u'def', u'water') print u'meltt' print rp.meltt(273.15, [1]), u'\n' print u'meltp' print rp.meltp(100, [1]), u'\n' print u'sublt' print rp.sublt(273.15, [1]), u'\n' print u'sublp' print rp.sublp(0.1, [1]), u'\n' rp.setup( u'def', u'butane', u'ethane', u'propane', u'methane', ) x = [0.5, 0.15, 0.3, 0.05] rp.setref(u'nbp') prop = rp.flsh(u'tp', 260, 150, x) D = prop[u'D'] print u'trnprp, setref NBP' print rp.trnprp(260, D, x), u'\n' print u'B12' print rp.b12(260, x), u'\n' print u'chempot' print rp.chempot(260, D, x), u'\n' print u'fugcof' print rp.fugcof(260, D, x), u'\n' ##function not supported in Windows #if platform.system() == 'Linux': #print('phiderv') #print(rp.phiderv(2, 1, 260, D, x), '\n') #function not supported in Windows if platform.system() == u'Linux': print u'getmod' print rp.getmod(1, u'EOS'), u'\n' rp.setmod(u'tcx', u'ecs', [u'tc2', u'tc1', u'tc2', u'tc2']) rp.setup( u'def', u'butane', u'ethane', u'propane', u'methane', ) x = [0.5, 0.15, 0.3, 0.05] rp.setref(u'nbp') prop = rp.flsh(u'tp', 260, 200, x) print u'trnprp, setref NBP, setmod [tcx, ecs, tc2, tc1, tc2, tc2]' print rp.trnprp(260, prop[u'D'], x), u'\n' #function not supported in Windows if platform.system() == u'Linux': print u'getmod' print rp.getmod(3, u'tcx'), u'\n' rp.setref(u'oth', 1, [1], 0, 0, 273, 100) print u'setref = OTH' prop = rp.flsh(u'tp', 260, 200, x) print prop, u'\n' resetup_test_prop_a = prop rp.setref(u'???', 1, [1], 0, 0, 373, 100) print u'setref = ???' prop = rp.flsh(u'tp', 260, 200, x) print prop, u'\n' resetup_test_prop_b = prop print u'name' print rp.name(1), u'\n' rp.setup( u'def', u'butane', u'ethane', u'propane', u'methane', ) x = [0.5, 0.15, 0.3, 0.05] print u'getktv' prop = rp.getktv(1, 3) print prop, u'\n' print u'setktv' prop = rp.setktv( 1, 3, u'lin', prop[u'fij'], prop[u'hfmix'], ) print prop, u'\n' resetup_test_prop_c = prop print u'reset setktv' print rp.setktv(1, 2, u'rst'), u'\n' print u'getfij' print rp.getfij(u'LIN'), u'\n' print u'resetup_test_prop, setref, setmod' print resetup_test_prop_a, u'\n' print u'resetup' print rp.resetup(resetup_test_prop_a), u'\n' print u'resetup_test_prop, setref(???), setmod' print resetup_test_prop_b, u'\n' print u'resetup' print rp.resetup(resetup_test_prop_b), u'\n' print u'resetup_test_prop, setktv' print resetup_test_prop_c, u'\n' print u'resetup' print rp.resetup(resetup_test_prop_c), u'\n' print u'resetup_test_prop, purefld' print resetup_test_prop_d, u'\n' print u'resetup' print rp.resetup(resetup_test_prop_d), u'\n' #normalize([0.2, 0.2, 0.1, 0.1]) print u'normalize' print rp.normalize([0.2, 0.2, 0.1, 0.1]), u'\n' #setup_details print u'setup_details' print rp.setup_details({ u'hfld': [u'BUTANE', u'ETHANE', u'PROPANE', u'METHANE'], u'D': 0.21683907260570098, u'Dvap': 0.09664613429889905, u'hfmix': u'HMX.BNC', u'setmod': { u'hcomp': [u'TC2', u'TC1', u'TC2', u'TC2'], u'htype': u'TCX', u'hmix': u'ECS' }, u'cp': -9999980.0, u'xliq': [ Decimal(u'0.7125650648765283717349528049'), Decimal(u'0.04065955068790887177072495080'), Decimal(u'0.2449672538076863186375885862'), Decimal(u'0.001808130627876437856733658079') ], u'xvap': [ Decimal(u'0.2304027911956556081031262882'), Decimal(u'0.2886769748808782463382744488'), Decimal(u'0.3697982730402927396744896960'), Decimal(u'0.1111219608831734058841095670') ], u'x': [0.5, 0.15, 0.3, 0.05], u'e': -13828.39837781548, u'h': -12906.055381248256, u'nc': 4, u'Dliq': 11.150114864150222, u'cv': -9999980.0, u'q': 0.4408579356823604, u'p': 200.0, u's': -44.047682476988044, u't': 260.0, u'w': -9999980.0, u'kph': 1, u'setref': { u'p0': 100, u'ixflag': 1, u'h0': 0, u's0': 0, u't0': 273, u'hrf': [u'OTH', u'???'] }, u'hrf': u'DEF' }), u'\n' #gerg04 print u'gerg04 = 1' rp.gerg04(1) print rp.setup(u'def', u'butane', u'ethane', u'propane'), u'\n' #reset gerg04 print u'gerg04 = 0' rp.gerg04(0) print rp.setup(u'def', u'butane', u'ethane', u'propane'), u'\n' #preos print u'preos = 2' print rp.preos(2), u'\n' print u'preos = -1' print rp.preos(-1), u'\n' print u'preos = 0' print rp.preos(0), u'\n' print u'preos = -1' print rp.preos(-1), u'\n' #setaga print u'setaga' print rp.setaga(), u'\n' #unsetaga print u'unsetaga' print rp.unsetaga(), u'\n' #setup_settings print u'setup_setting' print rp.setup_setting(), u'\n'
def convert_fluid(fluid_name, out_path, step=0.25): ''' Converts the fluid to the the binary format ''' # if 'R' != fluid_name[0]: # print 'Ingnoring irrelevant refrigerant', fluid_name # return try: # Prepare the fluid in Refprop fluid = r.setup(u'def', fluid_name) if fluid_name in ALIASES: fluid_name = ALIASES[fluid_name] else: if u'.PPF' in fluid_name: fluid_name.replace(u'.PPF', '') # remove any unnecessary file extensions #fluid_name = r.name()['hname'] print 'Converting ' + fluid_name # Get some of the meta data for the fluid x = [] # the fluid composition (mole fractions of mixtures). Empty for single fluid if 'x' in fluid: x = fluid['x'] limits = r.limits(x) info = r.info() # print fluid_name, 'limits are', limits tmin = math.ceil(float(limits['tmin'])) tmax = math.floor(float(r.critp(x)['tcrit'])) tmax = math.floor(float(limits['tmax'])) delta = (tmax - tmin) - 2 rows = int(delta / step) tmax = tmin + (rows * step) # snap tmax down to step interval bubble = [] dew = [] rowsOut = 0 for i in range(rows): temp = tmin + (step * i) try: bapp = r.satt(temp, x, kph=1)['p'] dapp = r.satt(temp, x, kph=2)['p'] bubble.append(bapp) dew.append(dapp) rowsOut = rowsOut + 1 except: if rowsOut > 0: # print 'Failed to get saturated temperature. Finalizing fluid at current row' break if rowsOut <= 0: print 'Failed to export fluid {0} with expected rows {1}: \n{2}'.format(fluid_name, rows, traceback.format_exc()) return False # else: # print fluid_name, 'exported', rowsOut, 'rows of lookup data with tmin=', tmin, 'and tmax=', tmax, 'and expected rows=', rows similar = True # Check if the fluid has a pressure difference for the different phases for i in range(rowsOut): similar = math.fabs(bubble[i] - dew[i]) <= EPSILON if not similar: print fluid_name, 'failed to be similar at temp', (i * step + tmin) break # Write the fluid to its file file = open(out_path + fluid_name + OUT_EXT, 'wb') data = None vals = bubble if similar: fmt = '>BB{0}siifI?{1}f'.format(len(fluid_name), str(rowsOut)) else: fmt = '>BB{0}siifI?{1}f'.format(len(fluid_name), str(rowsOut * 2)) vals = vals + dew data = struct.pack(fmt, VERSION, len(fluid_name), str(fluid_name), tmin, tmax, step, rowsOut, similar, *vals) file.write(data) file.flush() file.close() return True except Exception, e: print 'Failed to convert fluid {0}: \n{1}'.format(fluid_name, traceback.format_exc()) return False
def _maintest(rp): #examples and test setup rp.SetErrorDebug.off() #turn on =>> for testing purpose if rp.test(): #if True; rptest =>>for testing purpose print('refprop installed correctely') print('test results') print(rp.testresult) print('fluidlib') rp.fluidlib() print('\n') prop = rp.setup('def', 'air',) print('setup air') print(prop, '\n') x = prop['x'] print('critp(x)') print(rp.critp(x), '\n') print('setup water ammonia') print(rp.setup('def', 'water', 'ammonia',), '\n') #alternative setup input rp.setup('def', ['water', 'ammonia'],) x = [0.5, 0.3] prop = rp.normalize(x) x = prop['x'] prop = rp.critp(x) prop = rp.therm(prop['tcrit'], prop['Dcrit'], x) print('therm') print(prop, '\n') p = prop['p'] print('therm2') print(rp.therm2(prop['t'], prop['D'], x), '\n') print('therm0') print(rp.therm0(prop['t'], prop['D'], x), '\n') print('residual') print(rp.residual(prop['t'], prop['D'], x), '\n') print('entro') print(rp.entro(prop['t'], prop['D'], x), '\n') print('enthal') print(rp.enthal(prop['t'], prop['D'], x), '\n') print('ag') print(rp.ag(prop['t'], prop['D'], x), '\n') print('cvcp') print(rp.cvcp(prop['t'], prop['D'], x), '\n') print('dddp') print(rp.dddp(prop['t'], prop['D'], x), '\n') print('dddt') print(rp.dddt(prop['t'], prop['D'], x), '\n') print('dhd1') print(rp.dhd1(prop['t'], prop['D'], x), '\n') print('dpdd') print(rp.dpdd(prop['t'], prop['D'], x), '\n') print('dpdd2') print(rp.dpdd2(prop['t'], prop['D'], x), '\n') print('dpdt') print(rp.dpdt(prop['t'], prop['D'], x), '\n') D = prop['D'] #function not supported in Windows if platform.system() == 'Linux': print('dcdt') print(rp.dcdt(prop['t'], x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('dcdt2') print(rp.dcdt2(prop['t'], x), '\n') print('fgcty') print(rp.fgcty(prop['t'], D, x), '\n') print('gibbs') print(rp.gibbs(prop['t'], prop['D'], x), '\n') #~ print('fgcty2') #~ print(rp.fgcty2(prop['t'], prop['D'], x), '\n') prop = rp.therm3(prop['t'], prop['D'], x) print('therm3') print(prop, '\n') D = prop['D'] print('virb') print(rp.virb(prop['t'], x), '\n') print('virc') print(rp.virc(prop['t'], x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('vird') print(rp.vird(prop['t'], x), '\n') print('virba') print(rp.virba(prop['t'], x), '\n') print('virca') print(rp.virca(prop['t'], x), '\n') print('cvcpk') print(rp.cvcpk(1, prop['t'], D), '\n') print('dbdt') print(rp.dbdt(prop['t'], x), '\n') print('dpddk') print(rp.dpddk(1, prop['t'], D), '\n') print('dpdtk') print(rp.dpdtk(2, prop['t'], D), '\n') D = 55 t = 373 prop = rp.press(t, D, x) print('press') print(prop, '\n') p = prop['p'] print('purefld(1)') prop = rp.purefld(1) print(prop, '\n') x = [1] resetup_test_prop_d = prop print('satt') prop = rp.satt(t, x) print(prop, '\n') print('satp') prop = rp.satp(prop['p'], x) print(prop, '\n') print('satd') print(rp.satd(prop['Dliq'], x), '\n') print('sath') print(rp.sath(47000, x, 0), '\n') print('sate') print(rp.sate(0.96047E-13, x), '\n') print('sats') print(rp.sats(50, x, 0), '\n') print('purefld(0)') print(rp.purefld(0), '\n') x = [0.5, 0.3] x = rp.normalize(x)['x'] print('csatk') print(rp.csatk(1, t), '\n') print('dptsatk') print(rp.dptsatk(1, t), '\n') print('cv2pk') print(rp.cv2pk(2, t, D), '\n') print('tprho') print(rp.tprho(t, p, x, 2, 1, 58), '\n') print('flsh, tp') prop = rp.flsh('tp', t, p, x) print(prop, '\n') print('flsh, th') print(rp.flsh('tH', 305, prop['h'], x, 1), '\n') print('flsh, tD') print(rp.flsh('tD', t, 30, x), '\n') print('info()') print(rp.info(), '\n') print('info(2)') print(rp.info(2), '\n') #unsupported in Windows if platform.system() == 'Linux': print('rmix2') print(rp.rmix2(x), '\n') print('xmass') prop = rp.xmass(x) print(prop, '\n') print('xmole') print(rp.xmole(prop['xkg']), '\n') print('limitx') print(rp.limitx(x, 'eos', t, D, p), '\n') print('limitk') print(rp.limitk('eos', 1, t, D, p), '\n') print('limits') print(rp.limits(x), '\n') print('flsh, ts') prop = rp.flsh('ts', t, 40, x) print(prop, '\n') print('flsh, te') print(rp.flsh('te', t, prop['e'], x), '\n') print('flsh, pD') prop = rp.flsh('Pd', p, D, x) print(prop, '\n') print('flsh, ph') prop = rp.flsh('ph', p, prop['h'], x) print(prop, '\n') print('flsh, ps') prop = rp.flsh('ps', p, prop['s'], x) print(prop, '\n') print('flsh, pe') prop = rp.flsh('pE', p, prop['e'], x) print(prop, '\n') print('flsh, es') prop = rp.flsh('es', prop['e'], prop['s'], x) print(prop, '\n') print('flsh, hs') prop = rp.flsh('hs', 40000, 100, x) print(prop, '\n') print('flsh, es') print(rp.flsh('es', 175, 13, x), '\n') print('flsh, Dh') print(rp.flsh('DH', 20, 18000, x), '\n') print('flsh, Ds') prop = rp.flsh('Ds', 20, 50, x) print(prop, '\n') print('flsh, De') prop = rp.flsh('DE', 20, prop['e'], x) print(prop, '\n') print('flsh, tq') prop = rp.flsh('tq', t, prop['q'], x) print(prop, '\n') print('flsh, pq') print(rp.flsh('pq', 1200, prop['q'], x), '\n') prop = rp.flsh('tp', 350, 1200, x) print('flsh, tp') print(prop, '\n') s = prop['s'] e = prop['e'] h = prop['h'] D = prop['D'] t = prop['t'] p = prop['p'] Dmin = 40 Dmax = 55 print('flsh1, liq, ph') print(rp.flsh1('Ph', p, h, x, 1), '\n') print('getphase') print(rp.getphase(prop), '\n') print('flsh1, liq, pD') print(rp.flsh1('PD', p, D, x), '\n') print('flsh1, liq, ps') print(rp.flsh1('Ps', p, s, x), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, th') print(rp.flsh1('th', t, h, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, ts') print(rp.flsh1('ts', t, s, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, te') print(rp.flsh1('te', t, e, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, pe') print(rp.flsh1('Pe', p, e, x), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, hs') print(rp.flsh1('hs', h, s, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, Dh') print(rp.flsh1('Dh', D, h, x), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, Ds') print(rp.flsh1('Ds', D, s, x), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, liq, De') print(rp.flsh1('De', D, e, x), '\n') prop = rp.flsh('tp', 400, 100, x) s = prop['s'] e = prop['e'] h = prop['h'] D = prop['D'] Dmin = 0.01 Dmax = 0.05 t = prop['t'] p = prop['p'] print('flsh1, vap, ph') print(rp.flsh1('Ph', p, h, x, 2), '\n') print('getphase') print(rp.getphase(prop), '\n') print('flsh1, vap, pD') print(rp.flsh1('PD', p, D, x, 2), '\n') print('flsh1, vap, ps') print(rp.flsh1('Ps', p, s, x, 2), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, th') print(rp.flsh1('th', t, h, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, ts') print(rp.flsh1('ts', t, s, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, te') print(rp.flsh1('te', t, e, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, pe') print(rp.flsh1('Pe', p, e, x, 2), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, hs') print(rp.flsh1('hs', h, s, x, Dmin=Dmin, Dmax=Dmax), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, Dh') print(rp.flsh1('Dh', D, h, x), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, Ds') print(rp.flsh1('Ds', D, s, x), '\n') #unsupported in Windows if platform.system() == 'Linux': print('flsh1, vap, De') print(rp.flsh1('De', D, e, x), '\n') print('cstar') print(rp.cstar(t, p, 8, x), '\n') print('fpv') print(rp.fpv(t, D, p, x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('excess') print(rp.excess(t, p, x, kph=2), '\n') prop = rp.flsh('pq', 1200, 0.65, x) D = prop['D'] Dliq = prop['Dliq'] Dvap = prop['Dvap'] xliq = prop['xliq'] xvap = prop['xvap'] e = prop['e'] h = prop['h'] s = prop['s'] q = prop['q'] p = prop['p'] t = prop['t'] #function not supported in Windows if platform.system() == 'Linux': print('tpfl2') print(rp.flsh2('tp', t, p, x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('Dhfl2') print(rp.flsh2('Dh', D, h, x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('Dsfl2') print(rp.flsh2('Ds', D, s, x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('Defl2') print(rp.flsh2('De', D, e, x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('thfl2') print(rp.flsh2('th', t, h, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('tsfl2') print(rp.flsh2('ts', t, s, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('tefl2') print(rp.flsh2('te', t, e, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('tDfl2') print(rp.flsh2('tD', t, D, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('pDfl2') print(rp.flsh2('pD', p, D, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('phfl2') print(rp.flsh2('ph', p, h, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('psfl2') print(rp.flsh2('ps', p, s, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('pefl2') print(rp.flsh2('pe', p, e, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('tqfl2') print(rp.flsh2('tq', t, q, x, ksat=0), '\n') #function not supported in Windows if platform.system() == 'Linux': print('pqfl2') print(rp.flsh2('pq', p, q, x, ksat=0), '\n') #function not supported in Windows #~ if platform.system() == 'Linux': #~ print('Dqfl2') #~ print(rp.flsh2('Dq', D, q, x), '\n') prop = rp.flsh('tp', 340, 100, x) t = prop['t'] Dliq = prop['Dliq'] Dvap = prop['Dvap'] xliq = prop['xliq'] xvap = prop['xvap'] print('qmass') prop = rp.qmass(prop['q'], xliq, xvap) print(prop, '\n') print('qmole') print(rp.qmole(prop['qkg'], prop['xlkg'], prop['xvkg']), '\n') print('wmol') print(rp.wmol(x), '\n') prop = rp.flsh('tp', 340, 100, x) print('dielec') print(rp.dielec(prop['t'], prop['D'], x), '\n') print('surten') print(rp.surten (t, Dliq, Dvap, xliq, xvap), '\n') print('surft') print(rp.surft(240, x), '\n') rp.setup('def', 'water') print('meltt') print(rp.meltt(273.15, [1]), '\n') print('meltp') print(rp.meltp(100, [1]), '\n') print('sublt') print(rp.sublt(273.15, [1]), '\n') print('sublp') print(rp.sublp(0.1, [1]), '\n') rp.setup('def', 'butane', 'ethane', 'propane', 'methane',) x = [0.5, 0.15, 0.3, 0.05] rp.setref('nbp') prop = rp.flsh('tp', 260, 150, x) D = prop['D'] print('trnprp, setref NBP') print(rp.trnprp(260, D, x), '\n') print('B12') print(rp.b12(260, x), '\n') print('chempot') print(rp.chempot(260, D, x), '\n') print('fugcof') print(rp.fugcof(260, D, x), '\n') ##function not supported in Windows #if platform.system() == 'Linux': #print('phiderv') #print(rp.phiderv(2, 1, 260, D, x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('getmod') print(rp.getmod(1, 'EOS'), '\n') rp.setmod('tcx', 'ecs', ['tc2', 'tc1', 'tc2', 'tc2']) rp.setup('def', 'butane', 'ethane', 'propane', 'methane',) x = [0.5, 0.15, 0.3, 0.05] rp.setref('nbp') prop = rp.flsh('tp', 260, 200, x) print('trnprp, setref NBP, setmod [tcx, ecs, tc2, tc1, tc2, tc2]') print(rp.trnprp(260, prop['D'], x), '\n') #function not supported in Windows if platform.system() == 'Linux': print('getmod') print(rp.getmod(3, 'tcx'), '\n') rp.setref('oth', 1, [1], 0, 0, 273, 100) print('setref = OTH') prop = rp.flsh('tp', 260, 200, x) print(prop, '\n') resetup_test_prop_a = prop rp.setref('???', 1, [1], 0, 0, 373, 100) print('setref = ???') prop = rp.flsh('tp', 260, 200, x) print(prop, '\n') resetup_test_prop_b = prop print('name') print(rp.name(1), '\n') rp.setup('def', 'butane', 'ethane', 'propane', 'methane',) x = [0.5, 0.15, 0.3, 0.05] print('getktv') prop = rp.getktv(1, 3) print(prop, '\n') print('setktv') prop = rp.setktv(1, 3, 'lin', prop['fij'], prop['hfmix'],) print(prop, '\n') resetup_test_prop_c = prop print('reset setktv') print(rp.setktv(1, 2, 'rst'), '\n') print('getfij') print(rp.getfij('LIN'), '\n') print('resetup_test_prop, setref, setmod') print(resetup_test_prop_a, '\n') print('resetup') print(rp.resetup(resetup_test_prop_a), '\n') print('resetup_test_prop, setref(???), setmod') print(resetup_test_prop_b, '\n') print('resetup') print(rp.resetup(resetup_test_prop_b), '\n') print('resetup_test_prop, setktv') print(resetup_test_prop_c, '\n') print('resetup') print(rp.resetup(resetup_test_prop_c), '\n') print('resetup_test_prop, purefld') print(resetup_test_prop_d, '\n') print('resetup') print(rp.resetup(resetup_test_prop_d), '\n') #normalize([0.2, 0.2, 0.1, 0.1]) print('normalize') print(rp.normalize([0.2, 0.2, 0.1, 0.1]), '\n') #setup_details print('setup_details') print(rp.setup_details({'hfld': ['BUTANE', 'ETHANE', 'PROPANE', 'METHANE'], 'D': 0.21683907260570098, 'Dvap': 0.09664613429889905, 'hfmix': 'HMX.BNC', 'setmod': {'hcomp': ['TC2', 'TC1', 'TC2', 'TC2'], 'htype': 'TCX', 'hmix': 'ECS'}, 'cp': -9999980.0, 'xliq': [Decimal('0.7125650648765283717349528049'), Decimal('0.04065955068790887177072495080'), Decimal('0.2449672538076863186375885862'), Decimal('0.001808130627876437856733658079')], 'xvap': [Decimal('0.2304027911956556081031262882'), Decimal('0.2886769748808782463382744488'), Decimal('0.3697982730402927396744896960'), Decimal('0.1111219608831734058841095670')], 'x': [0.5, 0.15, 0.3, 0.05], 'e': -13828.39837781548, 'h': -12906.055381248256, 'nc': 4, 'Dliq': 11.150114864150222, 'cv': -9999980.0, 'q': 0.4408579356823604, 'p': 200.0, 's': -44.047682476988044, 't': 260.0, 'w': -9999980.0, 'kph': 1, 'setref': {'p0': 100, 'ixflag': 1, 'h0': 0, 's0': 0, 't0': 273, 'hrf': ['OTH', '???']}, 'hrf': 'DEF'}), '\n') #gerg04 print('gerg04 = 1') rp.gerg04(1) print(rp.setup('def', 'butane', 'ethane', 'propane'), '\n') #reset gerg04 print('gerg04 = 0') rp.gerg04(0) print(rp.setup('def', 'butane', 'ethane', 'propane'), '\n') #preos print('preos = 2') print(rp.preos(2), '\n') print('preos = -1') print(rp.preos(-1), '\n') print('preos = 0') print(rp.preos(0), '\n') print('preos = -1') print(rp.preos(-1), '\n') #setaga print('setaga') print(rp.setaga(), '\n') #unsetaga print('unsetaga') print(rp.unsetaga(), '\n') #setup_settings print('setup_setting') print(rp.setup_setting(), '\n')
def _rpfunc(): return refprop.info(icomp)
def calculo(self): refprop.setup(self.kwargs["ref"], self.kwargs["fluido"]) m = refprop.wmol(self.kwargs["fraccionMolar"])["wmix"] self.M = unidades.Dimensionless(m) crit = refprop.critp(self.kwargs["fraccionMolar"]) self.Pc = unidades.Pressure(crit["pcrit"], "kPa") self.Tc = unidades.Temperature(crit["tcrit"]) self.rhoc = unidades.Density(crit["Dcrit"] * self.M) args = self.args() flash = refprop.flsh(*args) self.phase, self.x = self.getphase(flash) self.T = unidades.Temperature(flash["t"]) self.P = unidades.Pressure(flash["p"], "kPa") self.rho = unidades.Density(flash["D"] * self.M) self.v = unidades.SpecificVolume(1. / self.rho) name = refprop.name(flash["nc"]) info = refprop.info(flash["nc"]) if flash["nc"] == 1: self.name = name["hname"] self.synonim = name["hn80"] self.CAS = name["hcas"] self.Tt = unidades.Temperature(info["ttrp"]) self.Tb = unidades.Temperature(info["tnbpt"]) self.f_accent = unidades.Dimensionless(info["acf"]) self.momentoDipolar = unidades.DipoleMoment(info["dip"], "Debye") self.Liquido = Fluid() self.Vapor = Fluid() if self.x < 1.: # Hay fase liquida liquido_thermo = refprop.therm2(flash["t"], flash["Dliq"], flash["xliq"]) liquido_mol = refprop.wmol(flash["xliq"]) try: liquido_transport = refprop.trnprp(flash["t"], flash["Dliq"], flash["xliq"]) except refprop.RefpropError as e: print e liquido_transport = None liquido_dielec = refprop.dielec(flash["t"], flash["Dliq"], flash["xliq"]) liquido_thermo0 = refprop.therm0(flash["t"], flash["Dliq"], flash["xliq"]) self.fill(self.Liquido, flash, liquido_thermo, liquido_mol, liquido_transport, liquido_dielec, liquido_thermo0) if self.x > 0.: # Hay fase vapor vapor_thermo = refprop.therm2(flash["t"], flash["Dvap"], flash["xvap"]) vapor_mol = refprop.wmol(flash["xvap"]) try: vapor_transport = refprop.trnprp(flash["t"], flash["Dvap"], flash["xvap"]) except refprop.RefpropError as e: print e vapor_transport = None vapor_dielec = refprop.dielec(flash["t"], flash["Dvap"], flash["xvap"]) vapor_thermo0 = refprop.therm0(flash["t"], flash["Dvap"], flash["xvap"]) self.fill(self.Vapor, flash, vapor_thermo, vapor_mol, vapor_transport, vapor_dielec, vapor_thermo0) # crit = multiRP.mRP[u'process'](target=multiRP.critp, args=(self.kwargs["fraccionMolar"], setup, multiRP.mRP)) # mol = multiRP.mRP[u'process'](target=multiRP.wmol, args=(self.kwargs["fraccionMolar"], setup, multiRP.mRP)) # processlist = [crit, mol] # multiRP.run_mRP(processlist) # self.Pc=unidades.Pressure(multiRP.mRP[u'result'][processlist[0].name]["pcrit"], "kPa") # self.Tc=unidades.Temperature(multiRP.mRP[u'result'][processlist[0].name]["tcrit"]) # self.rhoc=unidades.Density(multiRP.mRP[u'result'][processlist[0].name]["Dcrit"]*self.M) # args=self.args() # flash = multiRP.mRP[u'process'](target=multiRP.flsh, args=args, kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # name = multiRP.mRP[u'process'](target=multiRP.name, args=(1, setup, multiRP.mRP)) # info = multiRP.mRP[u'process'](target=multiRP.info, args=(1, setup, multiRP.mRP)) # processlist = [flash, name, info] # multiRP.run_mRP(processlist) # flash=multiRP.mRP[u'result'][processlist[0].name] # self.phase, self.x=self.getphase(flash) # self.nc=flash["nc"] # self.fraccion=self.kwargs["fraccionMolar"] # if flash["nc"] ==1: # self.name=multiRP.mRP[u'result'][processlist[1].name]["hname"] # self.synonim=multiRP.mRP[u'result'][processlist[1].name]["hn80"] # self.CAS=multiRP.mRP[u'result'][processlist[1].name]["hcas"] # # self.Tt=unidades.Temperature(multiRP.mRP[u'result'][processlist[2].name]["ttrp"]) # self.Tb=unidades.Temperature(multiRP.mRP[u'result'][processlist[2].name]["tnbpt"]) # self.f_accent=unidades.Dimensionless(multiRP.mRP[u'result'][processlist[2].name]["acf"]) # self.momentoDipolar=unidades.DipoleMoment(multiRP.mRP[u'result'][processlist[2].name]["dip"], "Debye") # self.Rgas=unidades.SpecificHeat(multiRP.mRP[u'result'][processlist[2].name]["Rgas"]/self.M) # else: # self.Rgas=unidades.SpecificHeat(refprop.rmix2(self.kwargs["fraccionMolar"])["Rgas"]/self.M) # self.T=unidades.Temperature(flash["t"]) # self.P=unidades.Pressure(flash["p"], "kPa") # self.rho=unidades.Density(flash["D"]*self.M) # self.v=unidades.SpecificVolume(1./self.rho) # self.Liquido=Fluid() # self.Vapor=Fluid() # if self.x<1.: #Hay fase liquida # liquido_thermo = multiRP.mRP[u'process'](target=multiRP.therm2, args=(flash["t"], flash["Dliq"], flash["xliq"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # liquido_mol = multiRP.mRP[u'process'](target=multiRP.wmol, args=(flash["xliq"], setup, multiRP.mRP)) # liquido_transport = multiRP.mRP[u'process'](target=multiRP.trnprp, args=(flash["t"], flash["Dliq"], flash["xliq"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # liquido_dielec = multiRP.mRP[u'process'](target=multiRP.dielec, args=(flash["t"], flash["Dliq"], flash["xliq"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # liquido_thermo0 = multiRP.mRP[u'process'](target=multiRP.therm0, args=(flash["t"], flash["Dliq"], flash["xliq"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # processlist = [liquido_thermo, liquido_mol, liquido_transport, liquido_dielec, liquido_thermo0] # try: # multiRP.run_mRP(processlist) # transport=multiRP.mRP[u'result'][processlist[2].name] # except refprop.RefpropError as e: # print e # transport=None # self.fill(self.Liquido, flash, multiRP.mRP[u'result'][processlist[0].name], multiRP.mRP[u'result'][processlist[1].name], # transport, multiRP.mRP[u'result'][processlist[3].name], multiRP.mRP[u'result'][processlist[4].name]) # if self.x>0.: #Hay fase vapor # vapor_thermo = multiRP.mRP[u'process'](target=multiRP.therm2, args=(flash["t"], flash["Dvap"], flash["xvap"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # vapor_mol = multiRP.mRP[u'process'](target=multiRP.wmol, args=(flash["xvap"], setup, multiRP.mRP)) # vapor_transport = multiRP.mRP[u'process'](target=multiRP.trnprp, args=(flash["t"], flash["Dvap"], flash["xvap"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # vapor_dielec = multiRP.mRP[u'process'](target=multiRP.dielec, args=(flash["t"], flash["Dvap"], flash["xvap"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # vapor_thermo0 = multiRP.mRP[u'process'](target=multiRP.therm0, args=(flash["t"], flash["Dvap"], flash["xvap"]), kwargs={u'prop': setup, u'mRP': multiRP.mRP}) # processlist = [vapor_thermo, vapor_mol, vapor_transport, vapor_dielec, vapor_thermo0] # try: # multiRP.run_mRP(processlist) # transport=multiRP.mRP[u'result'][processlist[2].name] # except refprop.RefpropError as e: # print e # transport=None # # self.fill(self.Vapor, flash, multiRP.mRP[u'result'][processlist[0].name], multiRP.mRP[u'result'][processlist[1].name], # transport, multiRP.mRP[u'result'][processlist[3].name], multiRP.mRP[u'result'][processlist[4].name]) self.h = unidades.Enthalpy(self.x * self.Vapor.h + (1 - self.x) * self.Liquido.h) self.s = unidades.SpecificHeat(self.x * self.Vapor.s + (1 - self.x) * self.Liquido.s) self.cp = unidades.SpecificHeat(self.x * self.Vapor.cp + (1 - self.x) * self.Liquido.cp) self.cp0 = unidades.SpecificHeat(self.x * self.Vapor.cp0 + (1 - self.x) * self.Liquido.cp0) self.cv = unidades.SpecificHeat(self.x * self.Vapor.cv + (1 - self.x) * self.Liquido.cv) self.cp_cv = unidades.Dimensionless(self.cp / self.cv) self.cp0_cv = unidades.Dimensionless(self.cp0 / self.cv) if self.T <= self.Tc: surten = refprop.surten(flash["t"], flash["Dliq"], flash["Dvap"], flash["xliq"], flash["xvap"]) self.surten = unidades.Tension(surten["sigma"]) else: self.surten = unidades.Tension(None)
def calculo(self): # TODO: Add configuration section to Preferences # preos = Preferences.getboolean("refProp", "preos") # aga = Preferences.getboolean("refProp", "aga") # gerg = Preferences.getboolean("refProp", "gerg") preos = self.kwargs["preos"] aga = self.kwargs["aga"] gerg = self.kwargs["gerg"] x = self._x() fluido = self._name() kwmod = [self.kwargs[k] for k in ('htype', 'hmix', 'hcomp')] refprop.setmod(*kwmod) if gerg: refprop.gerg04(ixflag=1) refprop.setup("def", fluido) # refprop.setktv() if preos: refprop.preos(ixflag=2) elif aga: refprop.setaga() kwref = {k: self.kwargs[k] for k in ( 'hrf', 'ixflag', 'x0', 'h0', 's0', 't0', 'p0')} refprop.setref(**kwref) m = refprop.wmol(x)["wmix"] self.M = unidades.Dimensionless(m) crit = refprop.critp(x) self.Pc = unidades.Pressure(crit["pcrit"], "kPa") self.Tc = unidades.Temperature(crit["tcrit"]) self.rhoc = unidades.Density(crit["Dcrit"]*self.M) args = self.args() flash = refprop.flsh(*args) # check if ['q'] in fld if 'q' in flash.keys(): x = flash['q'] elif 'h' in flash.keys(): x = refprop.flsh('ph', flash['p'], flash['h'], flash['x'])['q'] elif 's' in flash.keys(): x = refprop.flsh('ps', flash['p'], flash['s'], flash['x'])['q'] if 0 < x < 1: region = 4 else: region = 1 if x < 0: x = 0 elif x > 1: x = 1 self.x = unidades.Dimensionless(x) self.T = unidades.Temperature(flash["t"]) self.P = unidades.Pressure(flash["p"], "kPa") self.Tr = unidades.Dimensionless(self.T/self.Tc) self.Pr = unidades.Dimensionless(self.P/self.Pc) self.rho = unidades.Density(flash["D"]*self.M) self.v = unidades.SpecificVolume(1./self.rho) self.phase = self.getphase(Tc=self.Tc, Pc=self.Pc, T=self.T, P=self.Pc, x=self.x, region=region) if flash["nc"] == 1: name = refprop.name(flash["nc"]) self.name = name["hname"] self.synonim = name["hn80"] self.CAS = name["hcas"] info = refprop.info(flash["nc"]) self.R = unidades.SpecificHeat(info["Rgas"]/self.M) self.Tt = unidades.Temperature(info["ttrp"]) self.Tb = unidades.Temperature(info["tnbpt"]) self.f_accent = unidades.Dimensionless(info["acf"]) self.momentoDipolar = unidades.DipoleMoment(info["dip"], "Debye") self._doc = {} for htype in ['EOS', 'CP0', 'ETA', 'VSK', 'TCX', 'TKK', 'STN', 'DE ', 'MLT', 'SBL', 'PS ', 'DL ', 'DV ']: self._doc[htype] = refprop.getmod(flash["nc"], htype)["hcite"] else: self.name = "" self.synonim = "" self.CAS = "" rmix = refprop.rmix2(flash["x"]) self.R = unidades.SpecificHeat(rmix["Rgas"]/self.M) self.Tt = unidades.Temperature(None) self.Tb = unidades.Temperature(None) self.f_accent = unidades.Dimensionless(None) self.momentoDipolar = unidades.DipoleMoment(None) self._doc = {} self._cp0(flash) self.Liquido = ThermoRefProp() self.Gas = ThermoRefProp() if self.x == 0: # liquid phase self.fill(self.Liquido, flash["t"], flash["Dliq"], flash["xliq"]) self.fill(self, flash["t"], flash["Dliq"], flash["xliq"]) self.fillNone(self.Gas) elif self.x == 1: # vapor phase self.fill(self.Gas, flash["t"], flash["Dvap"], flash["xvap"]) self.fill(self, flash["t"], flash["Dvap"], flash["xvap"]) self.fillNone(self.Liquido) else: # Two phase self.fill(self.Liquido, flash["t"], flash["Dliq"], flash["xliq"]) self.fill(self.Gas, flash["t"], flash["Dvap"], flash["xvap"]) self.u = unidades.Enthalpy(flash["e"]/self.M, "Jg") self.h = unidades.Enthalpy(flash["h"]/self.M, "Jg") self.s = unidades.SpecificHeat(flash["s"]/self.M, "JgK") self.a = unidades.Enthalpy(self.u-self.T*self.s) self.g = unidades.Enthalpy(self.h-self.T*self.s) if self.x < 1 and self.T <= self.Tc: surten = refprop.surten(flash["t"], flash["Dliq"], flash["Dvap"], flash["xliq"], flash["xvap"]) self.sigma = unidades.Tension(surten["sigma"]) else: self.sigma = unidades.Tension(None) if 0 < self.x < 1: self.Hvap = unidades.Enthalpy(self.Gas.h-self.Liquido.h) self.Svap = unidades.SpecificHeat(self.Gas.s-self.Liquido.s) self.K = [] for x, y in zip(self.Liquido.fraccion, self.Gas.fraccion): self.K.append(unidades.Dimensionless(y/x)) else: self.Hvap = unidades.Enthalpy(None) self.Svap = unidades.SpecificHeat(None) self.K = [unidades.Dimensionless(1)]*flash["nc"] # NOT supported on Windows excess = refprop.excess(flash["t"], flash["D"], flash["x"]) self.vE = unidades.Volume(excess["vE"]/self.M) self.uE = unidades.Enthalpy(excess["eE"]/self.M, "Jg") self.hE = unidades.Enthalpy(excess["hE"]/self.M, "Jg") self.sE = unidades.SpecificHeat(excess["sE"]/self.M, "JgK") self.aE = unidades.Enthalpy(excess["aE"]/self.M, "Jg") self.gE = unidades.Enthalpy(excess["gE"]/self.M, "Jg") self.csat = [] self.dpdt_sat = [] self.cv2p = [] for i in range(1, flash["nc"]+1): dat = refprop.dptsatk(i, flash["t"], kph=2) self.csat.append(unidades.SpecificHeat(dat["csat"]/self.M, "JgK")) self.dpdt_sat.append( unidades.PressureTemperature(dat["dpdt"], "kPaK")) cv2 = refprop.cv2pk(i, flash["t"], flash["D"]) self.cv2p.append(unidades.SpecificHeat(cv2["cv2p"]/self.M, "JgK"))
def calculo(self): # TODO: Add configuration section to Preferences # preos = Preferences.getboolean("refProp", "preos") # aga = Preferences.getboolean("refProp", "aga") # gerg = Preferences.getboolean("refProp", "gerg") preos = self.kwargs["preos"] aga = self.kwargs["aga"] gerg = self.kwargs["gerg"] x = self._x() fluido = self._name() kwmod = [self.kwargs[k] for k in ('htype', 'hmix', 'hcomp')] refprop.setmod(*kwmod) if gerg: refprop.gerg04(ixflag=1) refprop.setup("def", fluido) # refprop.setktv() if preos: refprop.preos(ixflag=2) elif aga: refprop.setaga() kwref = {k: self.kwargs[k] for k in ( 'hrf', 'ixflag', 'x0', 'h0', 's0', 't0', 'p0')} refprop.setref(**kwref) m = refprop.wmol(x)["wmix"] self.M = unidades.Dimensionless(m) crit = refprop.critp(x) self.Pc = unidades.Pressure(crit["pcrit"], "kPa") self.Tc = unidades.Temperature(crit["tcrit"]) self.rhoc = unidades.Density(crit["Dcrit"]*self.M) args = self.args() flash = refprop.flsh(*args) # check if ['q'] in fld if 'q' in flash.keys(): x = flash['q'] elif 'h' in flash.keys(): x = refprop.flsh('ph', flash['p'], flash['h'], flash['x'])['q'] elif 's' in flash.keys(): x = refprop.flsh('ps', flash['p'], flash['s'], flash['x'])['q'] if 0 < x < 1: region = 4 else: region = 1 if x < 0: x = 0 elif x > 1: x = 1 self.x = unidades.Dimensionless(x) self.T = unidades.Temperature(flash["t"]) self.P = unidades.Pressure(flash["p"], "kPa") self.Tr = unidades.Dimensionless(self.T/self.Tc) self.Pr = unidades.Dimensionless(self.P/self.Pc) self.rho = unidades.Density(flash["D"]*self.M) self.v = unidades.SpecificVolume(1./self.rho) self.phase = self.getphase(Tc=self.Tc, Pc=self.Pc, T=self.T, P=self.Pc, x=self.x, region=region) if flash["nc"] == 1: name = refprop.name(flash["nc"]) self.name = name["hname"] self.synonim = name["hn80"] self.CAS = name["hcas"] info = refprop.info(flash["nc"]) self.R = unidades.SpecificHeat(info["Rgas"]/self.M) self.Tt = unidades.Temperature(info["ttrp"]) self.Tb = unidades.Temperature(info["tnbpt"]) self.f_accent = unidades.Dimensionless(info["acf"]) self.momentoDipolar = unidades.DipoleMoment(info["dip"], "Debye") self._doc = {} for htype in ['EOS', 'CP0', 'ETA', 'VSK', 'TCX', 'TKK', 'STN', 'DE ', 'MLT', 'SBL', 'PS ', 'DL ', 'DV ']: self._doc[htype] = refprop.getmod(flash["nc"], htype)["hcite"] else: self.name = "" self.synonim = "" self.CAS = "" rmix = refprop.rmix2(flash["x"]) self.R = unidades.SpecificHeat(rmix["Rgas"]/self.M) self.Tt = unidades.Temperature(None) self.Tb = unidades.Temperature(None) self.f_accent = unidades.Dimensionless(None) self.momentoDipolar = unidades.DipoleMoment(None) self._doc = {} self._cp0(flash) self.Liquido = ThermoRefProp() self.Gas = ThermoRefProp() if self.x == 0: # liquid phase self.fill(self.Liquido, flash["t"], flash["Dliq"], flash["xliq"]) self.fill(self, flash["t"], flash["Dliq"], flash["xliq"]) self.fillNone(self.Gas) elif self.x == 1: # vapor phase self.fill(self.Gas, flash["t"], flash["Dvap"], flash["xvap"]) self.fill(self, flash["t"], flash["Dvap"], flash["xvap"]) self.fillNone(self.Liquido) else: # Two phase self.fill(self.Liquido, flash["t"], flash["Dliq"], flash["xliq"]) self.fill(self.Gas, flash["t"], flash["Dvap"], flash["xvap"]) self.u = unidades.Enthalpy(flash["e"]/self.M, "Jg") self.h = unidades.Enthalpy(flash["h"]/self.M, "Jg") self.s = unidades.SpecificHeat(flash["s"]/self.M, "JgK") self.a = unidades.Enthalpy(self.u-self.T*self.s) self.g = unidades.Enthalpy(self.h-self.T*self.s) if self.x < 1 and self.T <= self.Tc: surten = refprop.surten(flash["t"], flash["Dliq"], flash["Dvap"], flash["xliq"], flash["xvap"]) self.sigma = unidades.Tension(surten["sigma"]) else: self.sigma = unidades.Tension(None) if 0 < self.x < 1: self.Hvap = unidades.Enthalpy(self.Gas.h-self.Liquido.h) self.Svap = unidades.SpecificHeat(self.Gas.s-self.Liquido.s) self.K = [] for x, y in zip(self.Liquido.fraccion, self.Gas.fraccion): self.K.append(unidades.Dimensionless(y/x)) else: self.Hvap = unidades.Enthalpy(None) self.Svap = unidades.SpecificHeat(None) self.K = [unidades.Dimensionless(1)]*flash["nc"] # NOT supported on Windows if sys.platform != "win32": excess = refprop.excess(flash["t"], flash["D"], flash["x"]) self.vE = unidades.Volume(excess["vE"]/self.M) self.uE = unidades.Enthalpy(excess["eE"]/self.M, "Jg") self.hE = unidades.Enthalpy(excess["hE"]/self.M, "Jg") self.sE = unidades.SpecificHeat(excess["sE"]/self.M, "JgK") self.aE = unidades.Enthalpy(excess["aE"]/self.M, "Jg") self.gE = unidades.Enthalpy(excess["gE"]/self.M, "Jg") else: self.vE = unidades.Volume(0) self.uE = unidades.Enthalpy(0) self.hE = unidades.Enthalpy(0) self.sE = unidades.SpecificHeat(0) self.aE = unidades.Enthalpy(0) self.gE = unidades.Enthalpy(0) self.csat = [] self.dpdt_sat = [] self.cv2p = [] for i in range(1, flash["nc"]+1): dat = refprop.dptsatk(i, flash["t"], kph=2) self.csat.append(unidades.SpecificHeat(dat["csat"]/self.M, "JgK")) self.dpdt_sat.append( unidades.PressureTemperature(dat["dpdt"], "kPaK")) cv2 = refprop.cv2pk(i, flash["t"], flash["D"]) self.cv2p.append(unidades.SpecificHeat(cv2["cv2p"]/self.M, "JgK"))
def _maintest(rp): # examples and test setup rp.SetErrorDebug.off() # turn on =>> for testing purpose if rp.test(): # if True; rptest =>>for testing purpose print u"refprop installed correctely" print u"test results" print rp.testresult print u"fluidlib" rp.fluidlib() print u"\n" prop = rp.setup(u"def", u"air") print u"setup air" print prop, u"\n" x = prop[u"x"] print u"critp(x)" print rp.critp(x), u"\n" print u"setup water ammonia" print rp.setup(u"def", u"water", u"ammonia"), u"\n" # alternative setup input rp.setup(u"def", [u"water", u"ammonia"]) x = [0.5, 0.3] prop = rp.normalize(x) x = prop[u"x"] prop = rp.critp(x) prop = rp.therm(prop[u"tcrit"], prop[u"Dcrit"], x) print u"therm" print prop, u"\n" p = prop[u"p"] print u"therm2" print rp.therm2(prop[u"t"], prop[u"D"], x), u"\n" print u"therm0" print rp.therm0(prop[u"t"], prop[u"D"], x), u"\n" print u"residual" print rp.residual(prop[u"t"], prop[u"D"], x), u"\n" print u"entro" print rp.entro(prop[u"t"], prop[u"D"], x), u"\n" print u"enthal" print rp.enthal(prop[u"t"], prop[u"D"], x), u"\n" print u"ag" print rp.ag(prop[u"t"], prop[u"D"], x), u"\n" print u"cvcp" print rp.cvcp(prop[u"t"], prop[u"D"], x), u"\n" print u"dddp" print rp.dddp(prop[u"t"], prop[u"D"], x), u"\n" print u"dddt" print rp.dddt(prop[u"t"], prop[u"D"], x), u"\n" print u"dhd1" print rp.dhd1(prop[u"t"], prop[u"D"], x), u"\n" print u"dpdd" print rp.dpdd(prop[u"t"], prop[u"D"], x), u"\n" print u"dpdd2" print rp.dpdd2(prop[u"t"], prop[u"D"], x), u"\n" print u"dpdt" print rp.dpdt(prop[u"t"], prop[u"D"], x), u"\n" D = prop[u"D"] # function not supported in Windows if platform.system() == u"Linux": print u"dcdt" print rp.dcdt(prop[u"t"], x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"dcdt2" print rp.dcdt2(prop[u"t"], x), u"\n" print u"fgcty" print rp.fgcty(prop[u"t"], D, x), u"\n" print u"gibbs" print rp.gibbs(prop[u"t"], prop[u"D"], x), u"\n" # ~ print('fgcty2') # ~ print(rp.fgcty2(prop['t'], prop['D'], x), '\n') prop = rp.therm3(prop[u"t"], prop[u"D"], x) print u"therm3" print prop, u"\n" D = prop[u"D"] print u"virb" print rp.virb(prop[u"t"], x), u"\n" print u"virc" print rp.virc(prop[u"t"], x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"vird" print rp.vird(prop[u"t"], x), u"\n" print u"virba" print rp.virba(prop[u"t"], x), u"\n" print u"virca" print rp.virca(prop[u"t"], x), u"\n" print u"cvcpk" print rp.cvcpk(1, prop[u"t"], D), u"\n" print u"dbdt" print rp.dbdt(prop[u"t"], x), u"\n" print u"dpddk" print rp.dpddk(1, prop[u"t"], D), u"\n" print u"dpdtk" print rp.dpdtk(2, prop[u"t"], D), u"\n" D = 55 t = 373 prop = rp.press(t, D, x) print u"press" print prop, u"\n" p = prop[u"p"] print u"purefld(1)" prop = rp.purefld(1) print prop, u"\n" x = [1] resetup_test_prop_d = prop print u"satt" prop = rp.satt(t, x) print prop, u"\n" print u"satp" prop = rp.satp(prop[u"p"], x) print prop, u"\n" print u"satd" print rp.satd(prop[u"Dliq"], x), u"\n" print u"sath" print rp.sath(47000, x, 0), u"\n" print u"sate" print rp.sate(0.46047e-13, x), u"\n" print u"sats" print rp.sats(50, x, 0), u"\n" print u"purefld(0)" print rp.purefld(0), u"\n" x = [0.5, 0.3] x = rp.normalize(x)[u"x"] print u"csatk" print rp.csatk(1, t), u"\n" print u"dptsatk" print rp.dptsatk(1, t), u"\n" print u"cv2pk" print rp.cv2pk(2, t, D), u"\n" print u"tprho" print rp.tprho(t, p, x, 2, 1, 58), u"\n" print u"flsh, tp" prop = rp.flsh(u"tp", t, p, x) print prop, u"\n" print u"flsh, th" print rp.flsh(u"tH", 305, prop[u"h"], x, 1), u"\n" print u"flsh, tD" print rp.flsh(u"tD", t, 30, x), u"\n" print u"info()" print rp.info(), u"\n" print u"info(2)" print rp.info(2), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"rmix2" print rp.rmix2(x), u"\n" print u"xmass" prop = rp.xmass(x) print prop, u"\n" print u"xmole" print rp.xmole(prop[u"xkg"]), u"\n" print u"limitx" print rp.limitx(x, u"eos", t, D, p), u"\n" print u"limitk" print rp.limitk(u"eos", 1, t, D, p), u"\n" print u"limits" print rp.limits(x), u"\n" print u"flsh, ts" prop = rp.flsh(u"ts", t, 40, x) print prop, u"\n" print u"flsh, te" print rp.flsh(u"te", t, prop[u"e"], x), u"\n" print u"flsh, pD" prop = rp.flsh(u"Pd", p, D, x) print prop, u"\n" print u"flsh, ph" prop = rp.flsh(u"ph", p, prop[u"h"], x) print prop, u"\n" print u"flsh, ps" prop = rp.flsh(u"ps", p, prop[u"s"], x) print prop, u"\n" print u"flsh, pe" prop = rp.flsh(u"pE", p, prop[u"e"], x) print prop, u"\n" print u"flsh, es" prop = rp.flsh(u"es", prop[u"e"], prop[u"s"], x) print prop, u"\n" print u"flsh, hs" prop = rp.flsh(u"hs", 40000, 100, x) print prop, u"\n" print u"flsh, es" print rp.flsh(u"es", 175, 13, x), u"\n" print u"flsh, Dh" print rp.flsh(u"DH", 20, 18000, x), u"\n" print u"flsh, Ds" prop = rp.flsh(u"Ds", 20, 50, x) print prop, u"\n" print u"flsh, De" prop = rp.flsh(u"DE", 20, prop[u"e"], x) print prop, u"\n" print u"flsh, tq" prop = rp.flsh(u"tq", t, prop[u"q"], x) print prop, u"\n" print u"flsh, pq" print rp.flsh(u"pq", 1200, prop[u"q"], x), u"\n" prop = rp.flsh(u"tp", 350, 1200, x) print u"flsh, tp" print prop, u"\n" s = prop[u"s"] e = prop[u"e"] h = prop[u"h"] D = prop[u"D"] t = prop[u"t"] p = prop[u"p"] Dmin = 40 Dmax = 55 print u"flsh1, liq, ph" print rp.flsh1(u"Ph", p, h, x, 1), u"\n" print u"getphase" print rp.getphase(prop), u"\n" print u"flsh1, liq, pD" print rp.flsh1(u"PD", p, D, x), u"\n" print u"flsh1, liq, ps" print rp.flsh1(u"Ps", p, s, x), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, th" print rp.flsh1(u"th", t, h, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, ts" print rp.flsh1(u"ts", t, s, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, te" print rp.flsh1(u"te", t, e, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, pe" print rp.flsh1(u"Pe", p, e, x), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, hs" print rp.flsh1(u"hs", h, s, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, Dh" print rp.flsh1(u"Dh", D, h, x), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, Ds" print rp.flsh1(u"Ds", D, s, x), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, liq, De" print rp.flsh1(u"De", D, e, x), u"\n" prop = rp.flsh(u"tp", 400, 100, x) s = prop[u"s"] e = prop[u"e"] h = prop[u"h"] D = prop[u"D"] Dmin = 0.01 Dmax = 0.05 t = prop[u"t"] p = prop[u"p"] print u"flsh1, vap, ph" print rp.flsh1(u"Ph", p, h, x, 2), u"\n" print u"getphase" print rp.getphase(prop), u"\n" print u"flsh1, vap, pD" print rp.flsh1(u"PD", p, D, x, 2), u"\n" print u"flsh1, vap, ps" print rp.flsh1(u"Ps", p, s, x, 2), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, th" print rp.flsh1(u"th", t, h, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, ts" print rp.flsh1(u"ts", t, s, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, te" print rp.flsh1(u"te", t, e, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, pe" print rp.flsh1(u"Pe", p, e, x, 2), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, hs" print rp.flsh1(u"hs", h, s, x, Dmin=Dmin, Dmax=Dmax), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, Dh" print rp.flsh1(u"Dh", D, h, x), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, Ds" print rp.flsh1(u"Ds", D, s, x), u"\n" # unsupported in Windows if platform.system() == u"Linux": print u"flsh1, vap, De" print rp.flsh1(u"De", D, e, x), u"\n" print u"cstar" print rp.cstar(t, p, 8, x), u"\n" print u"fpv" print rp.fpv(t, D, p, x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"excess" print rp.excess(t, p, x, kph=2), u"\n" prop = rp.flsh(u"pq", 1200, 0.65, x) D = prop[u"D"] Dliq = prop[u"Dliq"] Dvap = prop[u"Dvap"] xliq = prop[u"xliq"] xvap = prop[u"xvap"] e = prop[u"e"] h = prop[u"h"] s = prop[u"s"] q = prop[u"q"] p = prop[u"p"] t = prop[u"t"] # function not supported in Windows if platform.system() == u"Linux": print u"tpfl2" print rp.flsh2(u"tp", t, p, x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"Dhfl2" print rp.flsh2(u"Dh", D, h, x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"Dsfl2" print rp.flsh2(u"Ds", D, s, x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"Defl2" print rp.flsh2(u"De", D, e, x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"thfl2" print rp.flsh2(u"th", t, h, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"tsfl2" print rp.flsh2(u"ts", t, s, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"tefl2" print rp.flsh2(u"te", t, e, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"tDfl2" print rp.flsh2(u"tD", t, D, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"pDfl2" print rp.flsh2(u"pD", p, D, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"phfl2" print rp.flsh2(u"ph", p, h, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"psfl2" print rp.flsh2(u"ps", p, s, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"pefl2" print rp.flsh2(u"pe", p, e, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"tqfl2" print rp.flsh2(u"tq", t, q, x, ksat=0), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"pqfl2" print rp.flsh2(u"pq", p, q, x, ksat=0), u"\n" # function not supported in Windows # ~ if platform.system() == 'Linux': # ~ print('Dqfl2') # ~ print(rp.flsh2('Dq', D, q, x), '\n') prop = rp.flsh(u"tp", 340, 100, x) t = prop[u"t"] Dliq = prop[u"Dliq"] Dvap = prop[u"Dvap"] xliq = prop[u"xliq"] xvap = prop[u"xvap"] print u"qmass" prop = rp.qmass(prop[u"q"], xliq, xvap) print prop, u"\n" print u"qmole" print rp.qmole(prop[u"qkg"], prop[u"xlkg"], prop[u"xvkg"]), u"\n" print u"wmol" print rp.wmol(x), u"\n" prop = rp.flsh(u"tp", 340, 100, x) print u"dielec" print rp.dielec(prop[u"t"], prop[u"D"], x), u"\n" print u"surten" print rp.surten(t, Dliq, Dvap, xliq, xvap), u"\n" print u"surft" print rp.surft(240, x), u"\n" rp.setup(u"def", u"water") print u"meltt" print rp.meltt(273.15, [1]), u"\n" print u"meltp" print rp.meltp(100, [1]), u"\n" print u"sublt" print rp.sublt(273.15, [1]), u"\n" print u"sublp" print rp.sublp(0.1, [1]), u"\n" rp.setup(u"def", u"butane", u"ethane", u"propane", u"methane") x = [0.5, 0.15, 0.3, 0.05] rp.setref(u"nbp") prop = rp.flsh(u"tp", 260, 150, x) D = prop[u"D"] print u"trnprp, setref" print rp.trnprp(260, D, x), u"\n" print u"B12" print rp.b12(260, x), u"\n" print u"chempot" print rp.chempot(260, D, x), u"\n" print u"fugcof" print rp.fugcof(260, D, x), u"\n" ###function not supported in Windows # if platform.system() == 'Linux': input values changed.............................. # print('phiderv') # print(rp.phiderv(2, 1, 260, D, x), '\n') # function not supported in Windows if platform.system() == u"Linux": print u"getmod" print rp.getmod(1, u"EOS"), u"\n" rp.setmod(u"tcx", u"ecs", [u"tc2", u"tc1", u"tc2", u"tc2"]) rp.setup(u"def", u"butane", u"ethane", u"propane", u"methane") x = [0.5, 0.15, 0.3, 0.05] prop = rp.flsh(u"tp", 260, 200, x) print u"trnprp, setref NBP, setmod [tcx, ecs, tc2, tc1, tc2, tc2]" print rp.trnprp(260, prop[u"D"], x), u"\n" # function not supported in Windows if platform.system() == u"Linux": print u"getmod" print rp.getmod(3, u"tcx"), u"\n" rp.setref(u"oth", 1, [1], 0, 0, 273, 100) print u"setref = OTH" prop = rp.flsh(u"tp", 260, 200, x) print prop, u"\n" resetup_test_prop_a = prop rp.setref(u"???", 1, [1], 0, 0, 373, 100) print u"setref = ???" prop = rp.flsh(u"tp", 260, 200, x) print prop, u"\n" resetup_test_prop_b = prop print u"name" print rp.name(1), u"\n" rp.setup(u"def", u"butane", u"ethane", u"propane", u"methane") x = [0.5, 0.15, 0.3, 0.05] print u"getktv" prop = rp.getktv(1, 3) print prop, u"\n" print u"setktv" prop = rp.setktv(1, 3, u"lin", prop[u"fij"], prop[u"hfmix"]) print prop, u"\n" resetup_test_prop_c = prop print u"reset setktv" print rp.setktv(1, 2, u"rst"), u"\n" print u"getfij" print rp.getfij(u"LIN"), u"\n" print u"resetup_test_prop, setref, setmod" print resetup_test_prop_a, u"\n" print u"resetup" print rp.resetup(resetup_test_prop_a), u"\n" print u"resetup_test_prop, setref(???), setmod" print resetup_test_prop_b, u"\n" print u"resetup" print rp.resetup(resetup_test_prop_b), u"\n" print u"resetup_test_prop, setktv" print resetup_test_prop_c, u"\n" print u"resetup" print rp.resetup(resetup_test_prop_c), u"\n" print u"resetup_test_prop, purefld" print resetup_test_prop_d, u"\n" print u"resetup" print rp.resetup(resetup_test_prop_d), u"\n" # normalize([0.2, 0.2, 0.1, 0.1]) print u"normalize" print rp.normalize([0.2, 0.2, 0.1, 0.1]), u"\n" # setup_details print u"setup_details" print rp.setup_details( { u"hfld": [u"BUTANE", u"ETHANE", u"PROPANE", u"METHANE"], u"D": 0.21683907260570098, u"Dvap": 0.09664613429889905, u"hfmix": u"HMX.BNC", u"setmod": {u"hcomp": [u"TC2", u"TC1", u"TC2", u"TC2"], u"htype": u"TCX", u"hmix": u"ECS"}, u"cp": -9999980.0, u"xliq": [ Decimal(u"0.7125650648765283717349528049"), Decimal(u"0.04065955068790887177072495080"), Decimal(u"0.2449672538076863186375885862"), Decimal(u"0.001808130627876437856733658079"), ], u"xvap": [ Decimal(u"0.2304027911956556081031262882"), Decimal(u"0.2886769748808782463382744488"), Decimal(u"0.3697982730402927396744896960"), Decimal(u"0.1111219608831734058841095670"), ], u"x": [0.5, 0.15, 0.3, 0.05], u"e": -13828.39837781548, u"h": -12906.055381248256, u"nc": 4, u"Dliq": 11.150114864150222, u"cv": -9999980.0, u"q": 0.4408579356823604, u"p": 200.0, u"s": -44.047682476988044, u"t": 260.0, u"w": -9999980.0, u"kph": 1, u"setref": {u"p0": 100, u"ixflag": 1, u"h0": 0, u"s0": 0, u"t0": 273, u"hrf": [u"OTH", u"???"]}, u"hrf": u"DEF", } ), u"\n" # gerg04 print u"gerg04 = 1" rp.gerg04(1) print rp.setup(u"def", u"butane", u"ethane", u"propane"), u"\n" # reset gerg04 print u"gerg04 = 0" rp.gerg04(0) print rp.setup(u"def", u"butane", u"ethane", u"propane"), u"\n" # preos print u"preos = 2" print rp.preos(2), u"\n" print u"preos = -1" print rp.preos(-1), u"\n" print u"preos = 0" print rp.preos(0), u"\n" print u"preos = -1" print rp.preos(-1), u"\n" # setaga print u"setaga" print rp.setaga(), u"\n" # unsetaga print u"unsetaga" print rp.unsetaga(), u"\n" # setup_settings print u"setup_setting" print rp.setup_setting(), u"\n"
def _calculo(self): self._initialization() x = self._x() m = refprop.wmol(x)["wmix"] self.M = unidades.Dimensionless(m) crit = refprop.critp(x) self.Pc = unidades.Pressure(crit["pcrit"], "kPa") self.Tc = unidades.Temperature(crit["tcrit"]) self.rhoc = unidades.Density(crit["Dcrit"]*self.M) args = self.args() flash = refprop.flsh(*args) # check if ['q'] in fld if 'q' in flash.keys(): x = flash['q'] elif 'h' in flash.keys(): x = refprop.flsh('ph', flash['p'], flash['h'], flash['x'])['q'] elif 's' in flash.keys(): x = refprop.flsh('ps', flash['p'], flash['s'], flash['x'])['q'] if 0 < x < 1: region = 4 else: region = 1 if x < 0: x = 0 elif x > 1: x = 1 self.x = unidades.Dimensionless(x) self.T = unidades.Temperature(flash["t"]) self.P = unidades.Pressure(flash["p"], "kPa") self.Tr = unidades.Dimensionless(self.T/self.Tc) self.Pr = unidades.Dimensionless(self.P/self.Pc) self.rho = unidades.Density(flash["D"]*self.M) self.v = unidades.SpecificVolume(1./self.rho) self.phase = self.getphase(Tc=self.Tc, Pc=self.Pc, T=self.T, P=self.Pc, x=self.x, region=region) if flash["nc"] == 1: name = refprop.name(flash["nc"]) self.name = name["hname"] self.synonim = name["hn80"] self.CAS = name["hcas"] info = refprop.info(flash["nc"]) self.R = unidades.SpecificHeat(info["Rgas"]/self.M) self.Tt = unidades.Temperature(info["ttrp"]) self.Tb = unidades.Temperature(info["tnbpt"]) self.f_accent = unidades.Dimensionless(info["acf"]) self.momentoDipolar = unidades.DipoleMoment(info["dip"], "Debye") self._doc = {} for htype in ['EOS', 'CP0', 'ETA', 'VSK', 'TCX', 'TKK', 'STN', 'DE ', 'MLT', 'SBL', 'PS ', 'DL ', 'DV ']: self._doc[htype] = refprop.getmod(flash["nc"], htype)["hcite"] else: self.name = "" self.synonim = "" self.CAS = "" rmix = refprop.rmix2(flash["x"]) self.R = unidades.SpecificHeat(rmix["Rgas"]/self.M) self.Tt = unidades.Temperature(None) self.Tb = unidades.Temperature(None) self.f_accent = unidades.Dimensionless(None) self.momentoDipolar = unidades.DipoleMoment(None) self._doc = {} self._cp0(flash) self.Liquido = ThermoRefProp() self.Gas = ThermoRefProp() if self.x == 0.: # liquid phase self.fill(self.Liquido, flash["t"], flash["D"], flash["x"]) self.fill(self, flash["t"], flash["D"], flash["x"]) self.fillNone(self.Gas) elif self.x == 1.: # vapor phase self.fill(self.Gas, flash["t"], flash["D"], flash["x"]) self.fill(self, flash["t"], flash["D"], flash["x"]) self.fillNone(self.Liquido) else: # Two phase self.fillNone(self) self.fill(self.Liquido, flash["t"], flash["Dliq"], flash["xliq"]) self.fill(self.Gas, flash["t"], flash["Dvap"], flash["xvap"]) self.v = unidades.SpecificVolume(x*self.Gas.v+(1-x)*self.Liquido.v) self.rho = unidades.Density(1./self.v) self.u = unidades.Enthalpy(flash["e"]/self.M, "Jg") self.h = unidades.Enthalpy(flash["h"]/self.M, "Jg") self.s = unidades.SpecificHeat(flash["s"]/self.M, "JgK") self.a = unidades.Enthalpy(self.u-self.T*self.s) self.g = unidades.Enthalpy(self.h-self.T*self.s) self.rhoM = unidades.MolarDensity(self.rho/self.M) self.hM = unidades.MolarEnthalpy(self.h*self.M) self.sM = unidades.MolarSpecificHeat(self.s*self.M) self.uM = unidades.MolarEnthalpy(self.u*self.M) self.aM = unidades.MolarEnthalpy(self.a*self.M) self.gM = unidades.MolarEnthalpy(self.g*self.M) if self.x < 1 and self.T <= self.Tc: surten = refprop.surten(flash["t"], flash["Dliq"], flash["Dvap"], flash["xliq"], flash["xvap"]) self.sigma = unidades.Tension(surten["sigma"]) else: self.sigma = unidades.Tension(None) if 0 < self.x < 1: self.Hvap = unidades.Enthalpy(self.Gas.h-self.Liquido.h) self.Svap = unidades.SpecificHeat(self.Gas.s-self.Liquido.s) self.K = [] for x, y in zip(self.Liquido.fraccion, self.Gas.fraccion): self.K.append(unidades.Dimensionless(y/x)) else: self.Hvap = unidades.Enthalpy(None) self.Svap = unidades.SpecificHeat(None) self.K = [unidades.Dimensionless(1)]*flash["nc"] self.invT = unidades.InvTemperature(-1/self.T) # NOT supported on Windows if sys.platform != "win32": excess = refprop.excess(flash["t"], flash["D"], flash["x"]) self.vE = unidades.Volume(excess["vE"]/self.M) self.uE = unidades.Enthalpy(excess["eE"]/self.M, "Jg") self.hE = unidades.Enthalpy(excess["hE"]/self.M, "Jg") self.sE = unidades.SpecificHeat(excess["sE"]/self.M, "JgK") self.aE = unidades.Enthalpy(excess["aE"]/self.M, "Jg") self.gE = unidades.Enthalpy(excess["gE"]/self.M, "Jg") else: self.vE = unidades.Volume(0) self.uE = unidades.Enthalpy(0) self.hE = unidades.Enthalpy(0) self.sE = unidades.SpecificHeat(0) self.aE = unidades.Enthalpy(0) self.gE = unidades.Enthalpy(0) self.csat = [] self.dpdt_sat = [] self.cv2p = [] if self.Tt <= flash["t"] <= self.Tc: for i in range(1, flash["nc"]+1): dat = refprop.dptsatk(i, flash["t"], kph=2) cs = unidades.SpecificHeat(dat["csat"]/self.M, "JgK") self.csat.append(cs) self.dpdt_sat.append( unidades.PressureTemperature(dat["dpdt"], "kPaK")) cv2 = refprop.cv2pk(i, flash["t"], flash["D"]) cv = unidades.SpecificHeat(cv2["cv2p"]/self.M, "JgK") self.cv2p.append(cv)