CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
594 stars 114 forks source link

PT_surface_special fails for mixture PR78MIX due to missing Tc and Pc attributes #131

Closed wandadars closed 1 year ago

wandadars commented 1 year ago

PT_surface_special method for multicomponent mixtures throws an error: AttributeError: 'PR78MIX' object has no attribute 'Tc'

I looked into it, and it seems that the PT_surface_special method in the GCEOS pure cubic equation of state base class makes a call to the method P_PIP_transition, which as the first line checks whether the temperature argument is below self.Tc. Which for a mixture, this value does not appear to ever be set. I imagine that as part of the init method of the mixture class, would be a call to simply set self.Tc and self.Pc to the pseudo_Tc and pseudo_Pc values. The PR78MIX derived class for example sets self.Tcs and self.Pcs, but never sets self.Tc and self.Pc using those pseduo critical value methods.

A minimal example to reproduce the error is below.

crit_temperatures = [33.18, 154.58]
crit_pressures = [13e5, 50.43e5]
accentric_factors = [-0.220, 0.022]
mole_fractions = [ 1.0, 0.0]

def main():
    preos = thermo.eos_mix.PR78MIX(Tcs=crit_temperatures, Pcs=crit_pressures, omegas=accentric_factors, zs=mole_fractions,P=101325, T=300)
    plot_handle = preos.PT_surface_special(show=True)

if __name__ == "__main__":
    main()
CalebBell commented 1 year ago

Hi Chris, I have improved this functionality and you shouldn't see any crashes there. Caleb