thermotools / thermopack

Thermopack is a thermodynamic model library for fluid properties and PVT calculations
Other
51 stars 13 forks source link

Multicomponent GERG fails #98

Closed laods closed 1 year ago

laods commented 1 year ago

Dear developers,

I have an issue when trying to evaluate the enthalpy in an O2-N2 athmosphere with zero H2 and H2O components. As you see from the script below, it works fine when the EOS is initialized with only "O2,N2", or with either H2 or H2O added, but not when I add both.

Best, Lars

import numpy as np
from thermopack.multiparameter import multiparam

T = 288.0
p = 101325
nO2 = 0.21
nN2 = 0.79

eos = multiparam('O2,N2', 'MEOS')
z = [nO2, nN2]
h, = eos.enthalpy(T, p, z, eos.VAPPH)
print(T, p, h)

eos = multiparam('H2,O2,N2', 'MEOS')
z = [0, nO2, nN2]
h, = eos.enthalpy(T, p, z, eos.VAPPH)
print(T, p, h)

eos = multiparam('O2,N2,H2O', 'MEOS')
z = [nO2, nN2, 0]
h, = eos.enthalpy(T, p, z, eos.VAPPH)
print(T, p, h)

eos = multiparam('H2,O2,N2,H2O', 'MEOS')
z = [0.01, nO2, nN2-0.01, 0]
h, = eos.enthalpy(T, p, z, eos.VAPPH)
print(T, p, h)

# This fails
eos = multiparam('H2,O2,N2,H2O', 'MEOS')
z = [0, nO2, nN2, 0]
h, = eos.enthalpy(T, p, z, eos.VAPPH)
print(T, p, h)
morteham commented 1 year ago

Thanks Lars,

It is a divide by zero issue. I have corrected the code.