Esempio n. 1
0
 def readStatefromJSON(self, fluid):
     Thermo.readStatefromJSON(self, fluid)
     if fluid:
         self.betas = unidades.TemperaturePressure(fluid["betas"])
         self.Gruneisen = unidades.Dimensionless(fluid["Gruneisen"])
         self.virialB = unidades.SpecificVolume(fluid["virialB"])
         self.virialC = unidades.SpecificVolume_square(fluid["virialC"])
         self.dpdT_rho = unidades.PressureTemperature(fluid["dpdT_rho"])
         self.dpdrho_T = unidades.PressureDensity(fluid["dpdrho_T"])
         self.drhodT_P = unidades.DensityTemperature(fluid["drhodT_P"])
         self.drhodP_T = unidades.DensityPressure(fluid["drhodP_T"])
         self.dhdT_rho = unidades.SpecificHeat(fluid["dhdT_rho"])
         self.dhdP_T = unidades.EnthalpyPressure(fluid["dhdP_T"])
         self.dhdT_P = unidades.SpecificHeat(fluid["dhdT_P"])
         self.dhdrho_T = unidades.EnthalpyDensity(fluid["dhdrho_T"])
         self.dhdP_rho = unidades.EnthalpyPressure(fluid["dhdP_rho"])
         self.kt = unidades.Dimensionless(fluid["kt"])
         self.ks = unidades.InvPressure(fluid["ks"])
         self.Ks = unidades.Pressure(fluid["Ks"])
         self.Kt = unidades.Pressure(fluid["Kt"])
         self.IntP = unidades.Pressure(fluid["IntP"])
         self.invT = unidades.InvTemperature(fluid["invT"])
         self.hInput = unidades.Enthalpy(fluid["hInput"])
         self.epsilon = unidades.Dimensionless(fluid["epsilon"])
Esempio n. 2
0
    def fill(self, fase, estado):
        fase._bool = True
        fase.M = unidades.Dimensionless(estado.molar_mass()*1000)
        fase.rho = unidades.Density(estado.rhomass())
        fase.v = unidades.SpecificVolume(1./fase.rho)
        fase.Z = unidades.Dimensionless(estado.keyed_output(CP.iZ))

        fase.h = unidades.Enthalpy(estado.hmass())
        fase.s = unidades.SpecificHeat(estado.smass())
        fase.u = unidades.Enthalpy(estado.umass())
        fase.a = unidades.Enthalpy(fase.u-self.T*fase.s)
        fase.g = unidades.Enthalpy(fase.h-self.T*fase.s)
        if self._multicomponent:
            fase.fi = []
            fase.f = []
            for i in range(len(self.kwargs["ids"])):
                fase.fi.append(unidades.Dimensionless(
                    estado.fugacity_coefficient(i)))
                fase.f.append(unidades.Pressure(estado.fugacity(i)))
        else:
            fase.fi = [unidades.Dimensionless(
                exp(estado.alphar()+estado.delta()*estado.dalphar_dDelta() -
                    log(1+estado.delta()*estado.dalphar_dDelta())))]
            fase.f = [unidades.Pressure(self.P*f) for f in fase.fi]

        fase.cv = unidades.SpecificHeat(estado.cvmass())
        fase.cp = unidades.SpecificHeat(estado.cpmass())
        fase.cp_cv = unidades.Dimensionless(fase.cp/fase.cv)
        fase.gamma = fase.cp_cv
        fase.w = unidades.Speed(estado.speed_sound())

        fase.rhoM = unidades.MolarDensity(estado.rhomolar(), "molm3")
        fase.hM = unidades.MolarEnthalpy(estado.hmolar(), "Jmol")
        fase.sM = unidades.MolarSpecificHeat(estado.smolar(), "JmolK")
        fase.uM = unidades.MolarEnthalpy(estado.umolar(), "Jmol")
        fase.aM = unidades.MolarEnthalpy(fase.a*self.M)
        fase.gM = unidades.MolarEnthalpy(fase.g*self.M)
        fase.cvM = unidades.MolarSpecificHeat(estado.cvmolar(), "JmolK")
        fase.cpM = unidades.MolarSpecificHeat(estado.cpmolar(), "JmolK")

        fase.joule = unidades.TemperaturePressure(
            estado.first_partial_deriv(CP.iT, CP.iP, CP.iHmass))
        fase.Gruneisen = unidades.Dimensionless(
            fase.v/fase.cv*estado.first_partial_deriv(CP.iP, CP.iT, CP.iDmass))
        fase.alfav = unidades.InvTemperature(
            estado.isobaric_expansion_coefficient())
        fase.kappa = unidades.InvPressure(estado.isothermal_compressibility())
        fase.kappas = unidades.InvPressure(
            -1/fase.v*self.derivative("v", "P", "s", fase))
        fase.alfap = unidades.Density(fase.alfav/self.P/fase.kappa)
        fase.betap = unidades.Density(
            -1/self.P*self.derivative("P", "v", "T", fase))
        fase.betas = unidades.TemperaturePressure(
            estado.first_partial_deriv(CP.iT, CP.iP, CP.iSmass))

        fase.kt = unidades.Dimensionless(
            fase.rho/self.P*estado.first_partial_deriv(
                CP.iP, CP.iDmass, CP.iT))
        fase.Ks = unidades.Pressure(
            fase.rho*estado.first_partial_deriv(CP.iP, CP.iDmass, CP.iSmass))
        fase.Kt = unidades.Pressure(
            fase.rho*estado.first_partial_deriv(CP.iP, CP.iDmass, CP.iT))
        fase.ks = unidades.Dimensionless(
            fase.rho/self.P*estado.first_partial_deriv(
                CP.iP, CP.iDmass, CP.iSmass))
        fase.dhdT_rho = unidades.SpecificHeat(
            estado.first_partial_deriv(CP.iHmass, CP.iT, CP.iDmass))
        fase.dhdT_P = unidades.SpecificHeat(
            estado.first_partial_deriv(CP.iHmass, CP.iT, CP.iP))
        fase.dhdP_T = unidades.EnthalpyPressure(
            estado.first_partial_deriv(CP.iHmass, CP.iP, CP.iT))  # deltat
        fase.deltat = fase.dhdP_T
        fase.dhdP_rho = unidades.EnthalpyPressure(
            estado.first_partial_deriv(CP.iHmass, CP.iP, CP.iDmass))
        fase.dhdrho_T = unidades.EnthalpyDensity(
            estado.first_partial_deriv(CP.iHmass, CP.iDmass, CP.iT))
        fase.dhdrho_P = unidades.EnthalpyDensity(
            estado.first_partial_deriv(CP.iHmass, CP.iDmass, CP.iP))
        fase.dpdT_rho = unidades.PressureTemperature(
            estado.first_partial_deriv(CP.iP, CP.iT, CP.iDmass))
        fase.dpdrho_T = unidades.PressureDensity(
            estado.first_partial_deriv(CP.iP, CP.iDmass, CP.iT))
        fase.drhodP_T = unidades.DensityPressure(
            estado.first_partial_deriv(CP.iDmass, CP.iP, CP.iT))
        fase.drhodT_P = unidades.DensityTemperature(
            estado.first_partial_deriv(CP.iDmass, CP.iT, CP.iP))

        fase.Z_rho = unidades.SpecificVolume((fase.Z-1)/fase.rho)
        fase.IntP = unidades.Pressure(
            self.T*estado.first_partial_deriv(CP.iP, CP.iT, CP.iDmass)-self.P)
        fase.hInput = unidades.Enthalpy(
            -fase.rho*estado.first_partial_deriv(CP.iHmass, CP.iDmass, CP.iP))

        fase.virialB = unidades.SpecificVolume(estado.Bvirial())
        fase.virialC = unidades.SpecificVolume_square(estado.Cvirial())
        fase.invT = unidades.InvTemperature(-1/self.T)

        fase.mu = unidades.Viscosity(estado.viscosity())
        fase.nu = unidades.Diffusivity(fase.mu/fase.rho)
        fase.k = unidades.ThermalConductivity(estado.conductivity())
        fase.alfa = unidades.Diffusivity(fase.k/fase.rho/fase.cp)
        fase.Prandt = unidades.Dimensionless(estado.Prandtl())
        fase.fraccion = estado.get_mole_fractions()
        fase.fraccion_masica = estado.get_mass_fractions()
        fase.epsilon = unidades.Dimensionless(None)
Esempio n. 3
0
    def fill(self, fase, T, rho, x):
        if sum(x) != 1:
            x = [round(xi, 10) for xi in x]
        mol = refprop.wmol(x)
        thermo = refprop.therm2(T, rho, x)
        thermo3 = refprop.therm3(T, rho, x)

        fase._bool = True
        fase.M = unidades.Dimensionless(mol["wmix"])
        fase.rho = unidades.Density(rho*fase.M)
        fase.v = unidades.SpecificVolume(1./fase.rho)
        fase.Z = unidades.Dimensionless(thermo["Z"])

        fase.u = unidades.Enthalpy(thermo["e"]/fase.M, "Jg")
        fase.h = unidades.Enthalpy(thermo["h"]/fase.M, "Jg")
        fase.s = unidades.SpecificHeat(thermo["s"]/fase.M, "JgK")
        fase.a = unidades.Enthalpy(thermo["A"]/fase.M, "Jg")
        fase.g = unidades.Enthalpy(thermo["G"]/fase.M, "Jg")

        fase.cv = unidades.SpecificHeat(thermo["cv"]/fase.M, "JgK")
        fase.cp = unidades.SpecificHeat(thermo["cp"]/fase.M, "JgK")
        fase.cp_cv = unidades.Dimensionless(fase.cp/fase.cv)
        fase.gamma = fase.cp_cv
        fase.w = unidades.Speed(thermo["w"])

        fase.rhoM = unidades.MolarDensity(fase.rho/self.M)
        fase.hM = unidades.MolarEnthalpy(fase.h*self.M)
        fase.sM = unidades.MolarSpecificHeat(fase.s*self.M)
        fase.uM = unidades.MolarEnthalpy(fase.u*self.M)
        fase.aM = unidades.MolarEnthalpy(fase.a*self.M)
        fase.gM = unidades.MolarEnthalpy(fase.g*self.M)
        fase.cvM = unidades.MolarSpecificHeat(fase.cv*self.M)
        fase.cpM = unidades.MolarSpecificHeat(fase.cp*self.M)

        residual = refprop.residual(T, rho, x)
        fase.pr = unidades.Pressure(residual["pr"], "kPa")
        fase.ur = unidades.Enthalpy(residual["er"]/fase.M, "Jg")
        fase.hr = unidades.Enthalpy(residual["hr"]/fase.M, "Jg")
        fase.sr = unidades.SpecificHeat(residual["sr"]/fase.M, "JgK")
        fase.ar = unidades.Enthalpy(residual["Ar"]/fase.M, "Jg")
        fase.gr = unidades.Enthalpy(residual["Gr"]/fase.M, "Jg")
        fase.cvr = unidades.SpecificHeat(residual["cvr"]/fase.M, "JgK")
        fase.cpr = unidades.SpecificHeat(residual["cpr"]/fase.M, "JgK")

        fase.alfav = unidades.InvTemperature(thermo["beta"])
        fase.kappa = unidades.InvPressure(thermo["xkappa"], "kPa")
        fase.kappas = unidades.InvPressure(thermo3["betas"], "kPa")
        fase.alfap = unidades.Density(fase.alfav/self.P/fase.kappa)
        fase.deltat = unidades.EnthalpyPressure(
            thermo3["thrott"]/fase.M, "kJkgkPa")
        fase.joule = unidades.TemperaturePressure(thermo["hjt"], "KkPa")
        fase.betas = unidades.TemperaturePressure(
            self.derivative("T", "P", "s", fase))
        fase.betap = unidades.Density(
            -1/self.P*self.derivative("P", "v", "T", fase))

        fase.Kt = unidades.Pressure(thermo3["xkkt"], "kPa")
        fase.Ks = unidades.Pressure(thermo3["bs"], "kPa")
        fase.kt = unidades.Dimensionless(thermo3["xkt"])
        fase.ks = unidades.Dimensionless(thermo3["xisenk"])

        dh = refprop.dhd1(T, rho, x)
        fase.dhdT_rho = unidades.SpecificHeat(dh["dhdt_D"]/fase.M, "kJkgK")
        fase.dhdT_P = unidades.SpecificHeat(dh["dhdt_p"]/fase.M, "kJkgK")
        fase.dhdP_T = unidades.EnthalpyPressure(dh["dhdp_t"]/fase.M, "kJkgkPa")
        # dhdtp_D : fix in library
        fase.dhdP_rho = unidades.EnthalpyPressure(
            dh["dhdtp_D"]/fase.M, "kJkgkPa")
        fase.dhdrho_T = unidades.EnthalpyDensity(
            dh["dhdD_t"]/fase.M**2, "kJkgkgm3")
        fase.dhdrho_P = unidades.EnthalpyDensity(
            dh["dhdD_p"]/fase.M**2, "kJkgkgm3")

        fase.dpdT_rho = unidades.PressureTemperature(thermo["dpdt"], "kPaK")
        fase.dpdrho_T = unidades.PressureDensity(
            thermo["dpdD"]/fase.M, "kPakgm3")
        # TODO: Add unit for derivative d^2p/dD^2 [kPa-L^2/mol^2]
        # MPa·m⁶/kg²
        fase.d2pdrho2 = unidades.Dimensionless(thermo["d2pdD2"]/fase.M**2/1000)
        fase.drhodP_T = unidades.DensityPressure(
            thermo["dDdp"]*fase.M, "kgm3kPa")
        fase.drhodT_P = unidades.DensityTemperature(thermo["dDdt"]*fase.M)
        fase.Gruneisen = unidades.Dimensionless(fase.v/fase.cv*fase.dpdT_rho)

        fase.Z_rho = unidades.SpecificVolume((fase.Z-1)/fase.rho)
        fase.IntP = unidades.Pressure(thermo3["pint"], "kPa")
        fase.hInput = unidades.Enthalpy(thermo3["spht"]/fase.M, "kJkg")
        fase.invT = unidades.InvTemperature(-1/self.T)

        fpv = refprop.fpv(T, rho, self.P.kPa, x)["Fpv"]
        fase.fpv = unidades.Dimensionless(fpv)

        chempot = refprop.chempot(T, rho, x)["u"]
        fase.chempot = [unidades.Enthalpy(c/fase.M) for c in chempot]
        fi = refprop.fugcof(T, rho, x)["f"]
        fase.fi = [unidades.Dimensionless(f) for f in fi]
        f = refprop.fgcty(T, rho, x)["f"]
        fase.f = [unidades.Pressure(f_i, "kPa") for f_i in f]

        b = refprop.virb(T, x)["b"]
        fase.virialB = unidades.SpecificVolume(b/self.M)
        c = refprop.virc(T, x)["c"]
        fase.virialC = unidades.SpecificVolume_square(c/self.M**2)
        # viriald don't supported for windows
        d = refprop.vird(T, x)["d"]
        fase.virialD = unidades.Dimensionless(d/self.M**3)
        ba = refprop.virba(T, x)["ba"]
        fase.virialBa = unidades.SpecificVolume(ba/self.M)
        ca = refprop.virca(T, x)["ca"]
        fase.virialCa = unidades.SpecificVolume_square(ca/self.M**2)
        dcdt = refprop.dcdt(T, x)["dct"]
        fase.dCdt = unidades.Dimensionless(dcdt/self.M**2)
        dcdt2 = refprop.dcdt2(T, x)["dct2"]
        fase.dCdt2 = unidades.Dimensionless(dcdt2/self.M**2)
        dbdt = refprop.dbdt(T, x)["dbt"]
        fase.dBdt = unidades.Dimensionless(dbdt/self.M)

        b12 = refprop.b12(T, x)["b"]
        fase.b12 = unidades.SpecificVolume(b12*fase.M)
        try:
            cstar = refprop.cstar(T, self.P.kPa, 0, x)["cs"]
            fase.cstar = unidades.Dimensionless(cstar)
        except refprop.RefpropdllError:
            fase.cstar = unidades.Dimensionless(None)

        fase.fraccion = [unidades.Dimensionless(xi) for xi in x]
        xg = refprop.xmass(x)["xkg"]
        fase.fraccion_masica = [unidades.Dimensionless(xi) for xi in xg]

        transport = refprop.trnprp(T, rho, x)
        fase.mu = unidades.Viscosity(transport["eta"], "muPas")
        fase.nu = unidades.Diffusivity(fase.mu/fase.rho)
        fase.k = unidades.ThermalConductivity(transport["tcx"])
        fase.alfa = unidades.Diffusivity(fase.k/fase.rho/fase.cp)
        fase.Prandt = unidades.Dimensionless(fase.mu*fase.cp/fase.k)

        dielec = refprop.dielec(T, rho, x)
        fase.epsilon = unidades.Dimensionless(dielec["de"])
Esempio n. 4
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"))
Esempio n. 5
0
    def _calculo(self):
        self._initialization()

        x = self._x()
        m = refprop.wmol(x)["wmix"]
        self.M = unidades.Dimensionless(m)
        crit = refprop.critp(x)
        self.Pc = unidades.Pressure(crit["pcrit"], "kPa")
        self.Tc = unidades.Temperature(crit["tcrit"])
        self.rhoc = unidades.Density(crit["Dcrit"]*self.M)

        args = self.args()
        flash = refprop.flsh(*args)

        # check if ['q'] in fld
        if 'q' in flash.keys():
            x = flash['q']
        elif 'h' in flash.keys():
            x = refprop.flsh('ph', flash['p'], flash['h'], flash['x'])['q']
        elif 's' in flash.keys():
            x = refprop.flsh('ps', flash['p'], flash['s'], flash['x'])['q']
        if 0 < x < 1:
            region = 4
        else:
            region = 1

        if x < 0:
            x = 0
        elif x > 1:
            x = 1
        self.x = unidades.Dimensionless(x)
        self.T = unidades.Temperature(flash["t"])
        self.P = unidades.Pressure(flash["p"], "kPa")
        self.Tr = unidades.Dimensionless(self.T/self.Tc)
        self.Pr = unidades.Dimensionless(self.P/self.Pc)
        self.rho = unidades.Density(flash["D"]*self.M)
        self.v = unidades.SpecificVolume(1./self.rho)
        self.phase = self.getphase(Tc=self.Tc, Pc=self.Pc, T=self.T, P=self.Pc,
                                   x=self.x, region=region)

        if flash["nc"] == 1:
            name = refprop.name(flash["nc"])
            self.name = name["hname"]
            self.synonim = name["hn80"]
            self.CAS = name["hcas"]

            info = refprop.info(flash["nc"])
            self.R = unidades.SpecificHeat(info["Rgas"]/self.M)
            self.Tt = unidades.Temperature(info["ttrp"])
            self.Tb = unidades.Temperature(info["tnbpt"])
            self.f_accent = unidades.Dimensionless(info["acf"])
            self.momentoDipolar = unidades.DipoleMoment(info["dip"], "Debye")
            self._doc = {}
            for htype in ['EOS', 'CP0', 'ETA', 'VSK', 'TCX', 'TKK', 'STN',
                          'DE ', 'MLT', 'SBL', 'PS ', 'DL ', 'DV ']:
                self._doc[htype] = refprop.getmod(flash["nc"], htype)["hcite"]
        else:
            self.name = ""
            self.synonim = ""
            self.CAS = ""

            rmix = refprop.rmix2(flash["x"])
            self.R = unidades.SpecificHeat(rmix["Rgas"]/self.M)
            self.Tt = unidades.Temperature(None)
            self.Tb = unidades.Temperature(None)
            self.f_accent = unidades.Dimensionless(None)
            self.momentoDipolar = unidades.DipoleMoment(None)
            self._doc = {}

        self._cp0(flash)

        self.Liquido = ThermoRefProp()
        self.Gas = ThermoRefProp()
        if self.x == 0.:
            # liquid phase
            self.fill(self.Liquido, flash["t"], flash["D"], flash["x"])
            self.fill(self, flash["t"], flash["D"], flash["x"])
            self.fillNone(self.Gas)
        elif self.x == 1.:
            # vapor phase
            self.fill(self.Gas, flash["t"], flash["D"], flash["x"])
            self.fill(self, flash["t"], flash["D"], flash["x"])
            self.fillNone(self.Liquido)
        else:
            # Two phase
            self.fillNone(self)
            self.fill(self.Liquido, flash["t"], flash["Dliq"], flash["xliq"])
            self.fill(self.Gas, flash["t"], flash["Dvap"], flash["xvap"])

            self.v = unidades.SpecificVolume(x*self.Gas.v+(1-x)*self.Liquido.v)
            self.rho = unidades.Density(1./self.v)

            self.u = unidades.Enthalpy(flash["e"]/self.M, "Jg")
            self.h = unidades.Enthalpy(flash["h"]/self.M, "Jg")
            self.s = unidades.SpecificHeat(flash["s"]/self.M, "JgK")
            self.a = unidades.Enthalpy(self.u-self.T*self.s)
            self.g = unidades.Enthalpy(self.h-self.T*self.s)

            self.rhoM = unidades.MolarDensity(self.rho/self.M)
            self.hM = unidades.MolarEnthalpy(self.h*self.M)
            self.sM = unidades.MolarSpecificHeat(self.s*self.M)
            self.uM = unidades.MolarEnthalpy(self.u*self.M)
            self.aM = unidades.MolarEnthalpy(self.a*self.M)
            self.gM = unidades.MolarEnthalpy(self.g*self.M)

        if self.x < 1 and self.T <= self.Tc:
            surten = refprop.surten(flash["t"], flash["Dliq"], flash["Dvap"],
                                    flash["xliq"], flash["xvap"])
            self.sigma = unidades.Tension(surten["sigma"])
        else:
            self.sigma = unidades.Tension(None)

        if 0 < self.x < 1:
            self.Hvap = unidades.Enthalpy(self.Gas.h-self.Liquido.h)
            self.Svap = unidades.SpecificHeat(self.Gas.s-self.Liquido.s)
            self.K = []
            for x, y in zip(self.Liquido.fraccion, self.Gas.fraccion):
                self.K.append(unidades.Dimensionless(y/x))
        else:
            self.Hvap = unidades.Enthalpy(None)
            self.Svap = unidades.SpecificHeat(None)
            self.K = [unidades.Dimensionless(1)]*flash["nc"]
        self.invT = unidades.InvTemperature(-1/self.T)

        # NOT supported on Windows
        if sys.platform != "win32":
            excess = refprop.excess(flash["t"], flash["D"], flash["x"])
            self.vE = unidades.Volume(excess["vE"]/self.M)
            self.uE = unidades.Enthalpy(excess["eE"]/self.M, "Jg")
            self.hE = unidades.Enthalpy(excess["hE"]/self.M, "Jg")
            self.sE = unidades.SpecificHeat(excess["sE"]/self.M, "JgK")
            self.aE = unidades.Enthalpy(excess["aE"]/self.M, "Jg")
            self.gE = unidades.Enthalpy(excess["gE"]/self.M, "Jg")
        else:
            self.vE = unidades.Volume(0)
            self.uE = unidades.Enthalpy(0)
            self.hE = unidades.Enthalpy(0)
            self.sE = unidades.SpecificHeat(0)
            self.aE = unidades.Enthalpy(0)
            self.gE = unidades.Enthalpy(0)

        self.csat = []
        self.dpdt_sat = []
        self.cv2p = []
        if self.Tt <= flash["t"] <= self.Tc:
            for i in range(1, flash["nc"]+1):
                dat = refprop.dptsatk(i, flash["t"], kph=2)
                cs = unidades.SpecificHeat(dat["csat"]/self.M, "JgK")
                self.csat.append(cs)
                self.dpdt_sat.append(
                    unidades.PressureTemperature(dat["dpdt"], "kPaK"))
                cv2 = refprop.cv2pk(i, flash["t"], flash["D"])
                cv = unidades.SpecificHeat(cv2["cv2p"]/self.M, "JgK")
                self.cv2p.append(cv)