Examples:
>>> import capeopen_thermo
>>> print(capeopen_thermo.systems()) #note: output is system dependent
['ChemSep Property Package Manager', 'Multiflash Property Package Manager', 'OATS Property Package Manager (CAPE-OPEN 1.1, x64)', 'REFPROP CAPE-OPEN 1.1', 'TEA (CAPE-OPEN 1.1)', 'Water']
>>> system=capeopen_thermo.System('REFPROP CAPE-OPEN 1.1')
>>> print(system.name)
REFPROP CAPE-OPEN 1.1
>>> print(system.package_names) #note, this assumes REFPROP CAPE-OPEN Property Package Manager is installed, and output depends on configured property packages
['C1C2', 'C1C2C3', 'C3 C4 C5']
>>> pkg=system.create_package('C1C2C3')
>>> print(pkg.name)
C1C2C3
>>> print([c.name for c in pkg.compounds])
['methane', 'ethane', 'propane']
>>> print(pkg.constant_compound_properties)
['casRegistryNumber', 'chemicalFormula', 'acentricFactor', 'charge', 'criticalDensity', 'criticalPressure', 'criticalTemperature', 'criticalVolume', 'dipoleMoment', 'molecularWeight', 'normalBoilingPoint']
>>> print(pkg.temperature_dependent_compound_properties)
['vaporPressure', 'vaporPressure.Dtemperature', 'fugacityCoefficientOfVapor', 'heatCapacityOfLiquid', 'heatOfVaporization', 'surfaceTensionSatLiquid', 'thermalConductivityOfLiquid', 'thermalConductivityOfVapor', 'virialCoefficient', 'virialCoefficient.Dtemperature', 'idealGasEnthalpy', 'idealGasEnthalpy.Dtemperature', 'idealGasEntropy', 'idealGasHeatCapacity', 'viscosityOfLiquid', 'viscosityOfVapor', 'volumeChangeUponVaporization', 'volumeOfLiquid']
>>> print(pkg.phase_properties)
['compressibility', 'compressibility.Dtemperature', 'compressibility.Dpressure', 'compressibility.Dmoles', 'compressibility.DmolFraction', 'compressibilityFactor', 'compressibilityFactor.Dtemperature', 'compressibilityFactor.Dpressure', 'compressibilityFactor.Dmoles', 'compressibilityFactor.DmolFraction', 'density', 'density.Dtemperature', 'density.Dpressure', 'density.Dmoles', 'density.DmolFraction', 'enthalpy', 'enthalpy.Dtemperature', 'enthalpy.Dpressure', 'enthalpy.Dmoles', 'enthalpy.DmolFraction', 'entropy', 'entropy.Dtemperature', 'entropy.Dpressure', 'entropy.Dmoles', 'entropy.DmolFraction', 'fugacity', 'fugacity.Dtemperature', 'fugacity.Dpressure', 'fugacity.Dmoles', 'fugacity.DmolFraction', 'fugacityCoefficient', 'fugacityCoefficient.Dtemperature', 'fugacityCoefficient.Dpressure', 'fugacityCoefficient.Dmoles', 'fugacityCoefficient.DmolFraction', 'gibbsEnergy', 'gibbsEnergy.Dtemperature', 'gibbsEnergy.Dpressure', 'gibbsEnergy.Dmoles', 'gibbsEnergy.DmolFraction', 'heatCapacityCp', 'heatCapacityCp.Dtemperature', 'heatCapacityCp.Dpressure', 'heatCapacityCp.Dmoles', 'heatCapacityCp.DmolFraction', 'heatCapacityCv', 'heatCapacityCv.Dtemperature', 'heatCapacityCv.Dpressure', 'heatCapacityCv.Dmoles', 'heatCapacityCv.DmolFraction', 'helmholtzEnergy', 'helmholtzEnergy.Dtemperature', 'helmholtzEnergy.Dpressure', 'helmholtzEnergy.Dmoles', 'helmholtzEnergy.DmolFraction', 'internalEnergy', 'internalEnergy.Dtemperature', 'internalEnergy.Dpressure', 'internalEnergy.Dmoles', 'internalEnergy.DmolFraction', 'jouleThomsonCoefficient', 'jouleThomsonCoefficient.Dtemperature', 'jouleThomsonCoefficient.Dpressure', 'jouleThomsonCoefficient.Dmoles', 'jouleThomsonCoefficient.DmolFraction', 'logFugacityCoefficient', 'logFugacityCoefficient.Dtemperature', 'logFugacityCoefficient.Dpressure', 'logFugacityCoefficient.Dmoles', 'logFugacityCoefficient.DmolFraction', 'speedOfSound', 'speedOfSound.Dtemperature', 'speedOfSound.Dpressure', 'speedOfSound.Dmoles', 'speedOfSound.DmolFraction', 'thermalConductivity', 'thermalConductivity.Dtemperature', 'thermalConductivity.Dpressure', 'thermalConductivity.Dmoles', 'thermalConductivity.DmolFraction', 'viscosity', 'viscosity.Dtemperature', 'viscosity.Dpressure', 'viscosity.Dmoles', 'viscosity.DmolFraction', 'volume', 'volume.Dtemperature', 'volume.Dpressure', 'volume.Dmoles', 'volume.DmolFraction', 'molecularWeight']
>>> print(pkg.phase_pair_properties)
['kvalue', 'kvalue.Dtemperature', 'kvalue.Dpressure', 'kvalue.Dmoles', 'kvalue.DmolFraction', 'logKvalue', 'logKvalue.Dtemperature', 'logKvalue.Dpressure', 'logKvalue.Dmoles', 'logKvalue.DmolFraction', 'surfaceTension', 'surfaceTension.Dtemperature', 'surfaceTension.Dpressure', 'surfaceTension.Dmoles', 'surfaceTension.DmolFraction']
>>> print(pkg.phase_equilibrium_properties)
['temperature', 'pressure', 'vaporFraction', 'enthalpy', 'entropyF', 'volume']
>>> c=pkg.compounds[1] #second compound
>>> print(c.name)
ethane
>>> print(c.constant_properties)
['casRegistryNumber', 'chemicalFormula', 'acentricFactor', 'charge', 'criticalDensity', 'criticalPressure', 'criticalTemperature', 'criticalVolume', 'dipoleMoment', 'molecularWeight', 'normalBoilingPoint']
>>> print(c.temperature_dependent_properties)
['vaporPressure', 'vaporPressure.Dtemperature', 'fugacityCoefficientOfVapor', 'heatCapacityOfLiquid', 'heatOfVaporization', 'surfaceTensionSatLiquid', 'thermalConductivityOfLiquid', 'thermalConductivityOfVapor', 'virialCoefficient', 'virialCoefficient.Dtemperature', 'idealGasEnthalpy', 'idealGasEnthalpy.Dtemperature', 'idealGasEntropy', 'idealGasHeatCapacity', 'viscosityOfLiquid', 'viscosityOfVapor', 'volumeChangeUponVaporization', 'volumeOfLiquid']
>>> print(c.formula)
C2H6
>>> print(c.get_constant('CriticalTemperature'))
305.322
>>> print(capeopen_thermo.unit_of_measure('CriticalTemperature'))
K
>>> print(c.get_temperature_dependent_property('VaporPressure',180))
78638.13697265263
>>> print(capeopen_thermo.unit_of_measure('VaporPressure'))
Pa
>>> print(c.get_temperature_dependent_property(['VaporPressure','VaporPressure.Dtemperature'],180)) #any iterable of strings can be used as property list
[78638.13697265263, 4485.691704657636]
>>> print([pt.state_of_aggregation for pt in pkg.phase_types])
['vapor', 'liquid']
>>> vap=pkg.create_vapor_phase(180,1e5,[0.1,0.3,0.6]) #any iterable of real can be used for composition
>>> print(vap.name,vap.t,vap.p,vap.x)
Vapor 180.0 100000.0 [0.1, 0.3, 0.6]
>>> vap.t=170
>>> print(vap.get_property('density'))
71.18843885384538
>>> print(capeopen_thermo.unit_of_measure('density'))
mol/m3
>>> print(vap.get_property(['logFugacityCoefficient','density','density.DmolFraction'])) #list of [list, scalar, list]
[[0.023221227916101796, -0.030950956130479112, -0.08299502341532716], 71.18843885384538, [-56.97110887633571, -50.66746743410051, -45.470775819829605]]
>>> e=pkg.create_phase_equilibrium(x=[0.3,0.5,0.2],p=1e5,vapor_fraction=0.5)
>>> print(e.vapor_fraction,e.t,e.p)
0.5 177.4309136102493 100000.0
>>> for phase in e.phases:
>>> print(phase.name,"fraction",phase.phase_fraction,"composition",phase.x,"fugacity",phase.get_property('fugacity'))
Vapor fraction 0.5 composition [0.583219546716666, 0.40018878210558884, 0.016591671177745182] fugacity [57920.84428219625, 38737.42354385154, 1565.2452012306112]
Liquid fraction 0.5 composition [0.016782702155810687, 0.5998104253548305, 0.3834068724893588] fugacity [57920.844282122685, 38737.42354380174, 1565.2452012286094]
>>> print(e.get_property('enthalpy'))
5826.384263659671
The following example requires
matplotlib
:
>>> import matplotlib.pyplot as plt
>>> import capeopen_thermo
>>> pkg=capeopen_thermo.System('TEA (CAPE-OPEN 1.1)').create_package('C1_C2')
>>> X=[i/20.0 for i in range(0,21)]
>>> Tbub=[pkg.create_phase_equilibrium([x1,1-x1],'pressure',1e5,'vaporfraction',0).t for x1 in X]
>>> Tdew=[pkg.create_phase_equilibrium([x1,1-x1],'pressure',1e5,'vaporfraction',1).t for x1 in X]
>>> plt.plot(X,Tbub,'rx-')
>>> plt.plot(X,Tdew,'bx-')
>>> plt.xlabel('X '+pkg.compounds[0].name+', mol/mol')
>>> plt.ylabel('T, K')
>>> plt.show()