Exemplo n.º 1
0
    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"]
Exemplo n.º 2
0
def getLimit(fluid, config):
    method = getMethod()
    if method == "meos":
        if isinstance(config, dict):
            option = config
        else:
            option = {}
            option["eq"] = config.getint("MEoS", "eq")
            option["visco"] = config.getint("MEoS", "visco")
            option["thermal"] = config.getint("MEoS", "thermal")
        Tmin = fluid.eq[option["eq"]]["Tmin"]
        Tmax = fluid.eq[option["eq"]]["Tmax"]
        Pmin = fluid._new(T=fluid.eq[option["eq"]]["Tmin"], x=1, **option).P
        Pmax = fluid.eq[option["eq"]]["Pmax"] * 1000
    elif method == "coolprop":
        Tmin = fluid.eq["Tmin"]
        Tmax = fluid.eq["Tmax"]
        Pmin = fluid.eq["Pmin"]
        Pmax = fluid.eq["Pmax"]
    elif method == "refprop":
        import refprop
        refprop.setup("def", fluid.name)
        limit = refprop.limitx([1], t=-1)
        # Using the tiple point temperature the Tmin value returned here can be
        # lower if define en thermal or viscosity procedures
        Tmin = fluid.Tt
        try:
            Pmin = fluid(T=fluid.Tt, x=1).P
        except:
            Pmin = 100
        Tmax = limit["tmax"]
        Pmax = limit["pmax"] * 1000

    return Tmin, Tmax, Pmin, Pmax
Exemplo n.º 3
0
def setup(hrf, *hfld, **_3to2kwargs):
    if 'hfmix' in _3to2kwargs:
        hfmix = _3to2kwargs['hfmix']
        del _3to2kwargs['hfmix']
    else:
        hfmix = u'HMX.BNC'
    u'''Define models and initialize arrays.'''
    _checksetupblock(u'setup')
    return refprop.setup(hrf, *hfld, hfmix=hfmix)
Exemplo n.º 4
0
    def _initialization(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"]

        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)
Exemplo n.º 5
0
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'
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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')
Exemplo n.º 8
0
def setup(hrf, *hfld, hfmix='HMX.BNC'):
    '''Define models and initialize arrays.'''
    _checksetupblock('setup')
    return refprop.setup(hrf, *hfld, hfmix=hfmix)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    1633: u"r141b",
    241: u"r142b",
    243: u"r143a",
    245: u"r152a",
    671: u"r218",
    1872: u"r227ea",
    1873: u"r236fa",
    1817: u"r245fa",
    692: u"rc318",
    475: u"air"
}

noId = ["d2", "parahyd", "d2o", "r365mfc", "r404a", "r410a", "r407c", "r507a"]

if __name__ == '__main__':
    import sys
    from PyQt4 import QtGui
    #    app = QtGui.QApplication(sys.argv)
    from ctypes import CDLL, RTLD_GLOBAL
    _rp = CDLL("/usr/local/lib/librefprop.so", mode=RTLD_GLOBAL)
    #    fluido=RefProp(fluido=[u"water"], T=303.15, P=101325.)
    #    print fluido.Liquido.rho, fluido.Liquido.h, fluido.Liquido.s, fluido.Liquido.cv, fluido.Liquido.cp, fluido.Liquido.Z, fluido.Liquido.G

    prop = refprop.setup(u'def', u'air')
#    print prop
#    prop = refprop.wmol(prop[u'x'])
#    print prop

#    fluido=RefProp(fluido=[u'hydrogen', u'nitrogen', u'oxygen', u'water'], fraccionMolar=[0.03, 0.95, 0.01, 0.01], T=300, P=1e5)
#    print fluido.rho, fluido.cp.kJkgK, fluido.cv.kJkgK
Exemplo n.º 11
0
def setup(hrf, *hfld, hfmix='HMX.BNC'):
    '''Define models and initialize arrays.'''
    _checksetupblock('setup')
    return refprop.setup(hrf, *hfld, hfmix=hfmix)
Exemplo n.º 12
0
    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"))
Exemplo n.º 13
0
    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"))
Exemplo n.º 14
0
    def calculatePlot(self, fluid):
        """Calculate data for plot
            fluid: class of meos fluid to calculate"""
        data = {}
        points = get_points(config.Preferences)
        method = getMethod()

        # Melting and sublimation line only supported in internal meos method
        if method == "meos":
            # Calculate melting line
            if fluid._melting:
                self.parent().statusbar.showMessage(
                    QtWidgets.QApplication.translate(
                        "pychemqt", "Calculating melting line..."))
                T = linspace(fluid._melting["Tmin"], fluid._melting["Tmax"],
                             points)
                fluidos = []
                for Ti in T:
                    P = fluid._Melting_Pressure(Ti)
                    fluido = calcPoint(fluid, self.config, T=Ti, P=P)
                    if fluido:
                        fluidos.append(fluido)
                    self.parent().progressBar.setValue(5*len(fluidos)/len(T))
                    QtWidgets.QApplication.processEvents()
                if fluidos:
                    data["melting"] = saveProperties(fluidos)

            # Calculate sublimation line
            if fluid._sublimation:
                self.parent().statusbar.showMessage(
                    QtWidgets.QApplication.translate(
                        "pychemqt", "Calculating sublimation line..."))
                T = linspace(fluid._sublimation["Tmin"],
                             fluid._sublimation["Tmax"], points)
                fluidos = []
                for Ti in T:
                    P = fluid._Sublimation_Pressure(Ti)
                    fluido = calcPoint(fluid, self.config, T=Ti, P=P)
                    if fluido:
                        fluidos.append(fluido)
                    self.parent().progressBar.setValue(5+5*len(fluidos)/len(T))
                    QtWidgets.QApplication.processEvents()
                if fluidos:
                    data["sublimation"] = saveProperties(fluidos)

        # Define the saturation temperature
        T = list(concatenate([linspace(fluid.Tt, 0.9*fluid.Tc, points),
                              linspace(0.9*fluid.Tc, 0.99*fluid.Tc, points),
                              linspace(0.99*fluid.Tc, fluid.Tc, points)]))
        for i in range(2, 0, -1):
            del T[points*i]

        # Calculate saturation
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating Liquid-Vapour saturation line..."))
        for fase in [0, 1]:
            fluidos = []
            for Ti in T:
                print("x = %i" % fase, Ti)
                try:
                    fluidos.append(fluid._new(T=Ti, x=fase))
                except:
                    pass
                self.parent().progressBar.setValue(
                    10+5*fase+5*len(fluidos)/len(T))
                QtWidgets.QApplication.processEvents()

            data["saturation_%i" % fase] = saveProperties(fluidos)

        # Calculate isoquality lines
        data["x"] = {}
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating isoquality lines..."))
        values = self.LineList("Isoquality", config.Preferences)
        for i, value in enumerate(values):
            fluidos = calcIsoline(fluid, self.config,
                                  "T", "x", T, value, 20, i, 20,
                                  len(values), self.parent().progressBar)

            data["x"][value] = saveProperties(fluidos)

        # Get limit equation
        if method == "meos":
            eq = fluid.eq[self.parent().currentConfig.getint("MEoS", "eq")]
            Tmin = eq["Tmin"]
            Tmax = eq["Tmax"]

            Tt = eq.get("Tt", fluid.Tt)
            if Tmin > Tt:
                Lt = fluid._new(T=Tmin, x=0)
            else:
                Lt = fluid._new(T=Tt, x=0)
            Pmin = Lt.P

            Pmax = eq["Pmax"]*1000
        elif method == "coolprop":
            Tmin = fluid.eq["Tmin"]
            Tmax = fluid.eq["Tmax"]
            Pmin = fluid.eq["Pmin"]
            Pmax = fluid.eq["Pmax"]
        elif method == "refprop":
            import refprop
            refprop.setup("def", fluid.name)
            limit = refprop.limitx([1], t=-1)
            Tmin = limit["tmin"]
            try:
                Pmin = fluid(T=fluid.Tt, x=1).P
            except:
                Pmin = 100
            Tmax = limit["tmax"]
            Pmax = limit["pmax"]*1000

        T = list(concatenate(
            [linspace(Tmin, 0.9*fluid.Tc, points),
             linspace(0.9*fluid.Tc, 0.99*fluid.Tc, points),
             linspace(0.99*fluid.Tc, fluid.Tc, points),
             linspace(fluid.Tc, 1.01*fluid.Tc, points),
             linspace(1.01*fluid.Tc, 1.1*fluid.Tc, points),
             linspace(1.1*fluid.Tc, Tmax, points)]))
        P = list(concatenate(
            [logspace(log10(Pmin), log10(0.9*fluid.Pc), points),
             linspace(0.9*fluid.Pc, 0.99*fluid.Pc, points),
             linspace(0.99*fluid.Pc, fluid.Pc, points),
             linspace(fluid.Pc, 1.01*fluid.Pc, points),
             linspace(1.01*fluid.Pc, 1.1*fluid.Pc, points),
             logspace(log10(1.1*fluid.Pc), log10(Pmax), points)]))
        for i in range(5, 0, -1):
            del T[points*i]
            del P[points*i]

        # Calculate isotherm lines
        data["T"] = {}
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating isotherm lines..."))
        values = self.LineList("Isotherm", config.Preferences, fluid)
        for i, value in enumerate(values):
            fluidos = calcIsoline(fluid, self.config,
                                  "P", "T", P, value, 40, i, 10,
                                  len(values), self.parent().progressBar)

            data["T"][value] = saveProperties(fluidos)

        # Calculate isobar lines
        data["P"] = {}
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating isobar lines..."))
        values = self.LineList("Isobar", config.Preferences, fluid)
        for i, value in enumerate(values):
            fluidos = calcIsoline(fluid, self.config,
                                  "T", "P", T, value, 50, i, 10,
                                  len(values), self.parent().progressBar)
            data["P"][value] = saveProperties(fluidos)

        # Calculate isochor lines
        data["v"] = {}
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating isochor lines..."))
        values = self.LineList("Isochor", config.Preferences, fluid)
        for i, value in enumerate(values):
            fluidos = calcIsoline(fluid, self.config,
                                  "T", "v", T, value, 60, i, 10,
                                  len(values), self.parent().progressBar)
            data["v"][value] = saveProperties(fluidos)

        # Calculate isoenthalpic lines
        data["h"] = {}
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating isoenthalpic lines..."))
        vals = self.LineList("Isoenthalpic", config.Preferences, fluid)
        for i, value in enumerate(vals):
            fluidos = calcIsoline(fluid, self.config,
                                  "P", "h", P, value, 70, i, 10,
                                  len(values), self.parent().progressBar)
            data["h"][value] = saveProperties(fluidos)

        # Calculate isoentropic lines
        data["s"] = {}
        self.parent().statusbar.showMessage(QtWidgets.QApplication.translate(
            "pychemqt", "Calculating isoentropic lines..."))
        values = self.LineList("Isoentropic", config.Preferences, fluid)
        for i, value in enumerate(values):
            fluidos = calcIsoline(fluid, self.config,
                                  "P", "s", P, value, 80, i, 20,
                                  len(values), self.parent().progressBar)
            data["s"][value] = saveProperties(fluidos)

        return data
Exemplo n.º 15
0
def setup(hrf, *hfld, **_3to2kwargs):
    if 'hfmix' in _3to2kwargs: hfmix = _3to2kwargs['hfmix']; del _3to2kwargs['hfmix']
    else: hfmix = u'HMX.BNC'
    u'''Define models and initialize arrays.'''
    _checksetupblock(u'setup')
    return refprop.setup(hrf, *hfld, hfmix=hfmix)
Exemplo n.º 16
0
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"