def calculateEquilibria(self, gmStat, setverb, T, P, x0):

        # setting verbosity (True or False - default), if set to yes, in particular, when getters are called the returned values are displayed in a comprehensive way
        oc.setVerbosity(setverb)

        # set pressure
        oc.setPressure(P)

        # set temperature
        oc.setTemperature(T)

        # set initial molar amounts
        oc.setElementMolarAmounts(x0)

        #Equilibrium
        if gmStat == 'Off':
            oc.calculateEquilibrium(gmstat.Off)
        elif gmStat == 'On':
            oc.calculateEquilibrium(gmstat.On)
        else:
            raise ValueError(
                'No suitable parameter for gmstat found: Choose from On/Off')

        self.gibbs = oc.getGibbsEnergy()
        self.mu = oc.getChemicalPotentials()
        self.cd = oc.getConstituentsDescription()
        self.mass = oc.getScalarResult('B')

        phasesAtEquilibrium = oc.getPhasesAtEquilibrium()
        self.pec = phasesAtEquilibrium.getPhaseElementComposition()
        self.pcc = phasesAtEquilibrium.getPhaseConstituentComposition()
        self.ps = phasesAtEquilibrium.getPhaseSites()
        self.ma = phasesAtEquilibrium.getPhaseMolarAmounts()
 def phase(self, x, **kwargs):
     """
     The string name of the phase in equilibrium at the conditions.
     """
     phasearray = self.eqfunc(x).Phase.sel(P=self.P, T=self.T, **kwargs)
     return phasearray.values.flatten()
     
     phasesAtEquilibrium=oc.getPhasesAtEquilibrium()
     
     
     self.pec = phasesAtEquilibrium.getPhaseElementComposition()
     self.pcc = phasesAtEquilibrium.getPhaseConstituentComposition() 
     self.ps = phasesAtEquilibrium.getPhaseSites()
     self.ma = phasesAtEquilibrium.getPhaseMolarAmounts()        
     self.mu = oc.getChemicalPotentials()
     self.cd = oc.getConstituentsDescription()
     self.mass=oc.getScalarResult('B')
Exemple #3
0
    def eqfunc(self, x, calc_value):

        # setting verbosity (True or False - default), if set to yes, in particular, when getters are called the returned values are displayed in a comprehensive way
        oc.setVerbosity(self.setverb)

        # set pressure
        oc.setPressure(self.P)

        # set temperature
        oc.setTemperature(self.T)

        # set initial molar amounts
        oc.setElementMolarAmounts(x)

        #Equilibrium
        oc.calculateEquilibrium(gmstat.Off)

        if calc_value == 'gibbs':
            self.eq_val = oc.getGibbsEnergy()

        elif calc_value == 'mu':
            self.eq_val = oc.getChemicalPotentials()

        elif calc_value == 'cd':
            self.eq_val = oc.getConstituentsDescription()

        elif calc_value == 'mass':
            self.eq_val = oc.getScalarResult('B')

        elif calc_value == 'pec':
            self.eq_val = oc.getPhasesAtEquilibrium(
            ).getPhaseElementComposition()

        elif calc_value == 'pcc':
            self.eq_val = oc.getPhasesAtEquilibrium(
            ).getPhaseConstituentComposition()

        elif calc_value == 'ps':
            self.eq_val = oc.getPhasesAtEquilibrium().getPhaseSites()

        elif calc_value == 'ma':
            self.eq_val = oc.getPhasesAtEquilibrium().getPhaseMolarAmounts()

        return self.eq_val
oc.setTemperature(2800)
## suspend all phases except the liquid one
oc.setPhasesStatus(('* ', ), phStat.Suspended)
oc.setPhasesStatus(('LIQUID', ), phStat.Entered)

oc.setElementMolarAmounts(x0)

# calculate equilibrium
oc.changeEquilibriumRecord('eq2')
oc.calculateEquilibrium(gmStat.Off)

# retrieving mu data
phasesAtEquilibrium = oc.getPhasesAtEquilibrium()
phaseConstituentComposition = phasesAtEquilibrium.getPhaseConstituentComposition(
)
mueq_inf = oc.getChemicalPotentials()

# calculate equilibrium with the grid-minimizer (equilibrium record = default equilibrium)
oc.changeEquilibriumRecord()
oc.calculateEquilibrium()

# retrieving mu data
phasesAtEquilibrium = oc.getPhasesAtEquilibrium()
phaseConstituentComposition = phasesAtEquilibrium.getPhaseConstituentComposition(
)
mueq = oc.getChemicalPotentials()

# Use of molarVolume class
epsilon = 0.1
molar_vol = MolarVolume_OC()
partialMolarVolumes, exactVolume, approxVolume = molar_vol.calculatePartialMolarVolume(
 def getChemicalPotentials(self):
     mu = oc.getChemicalPotentials()
     self.__eq_val = [ mu[comp] for comp in self.__comps if comp != 'VA' ]
     return self.__eq_val