I have been looking for the upper and lower limits for the enthalpy inputs into the PropsSI function. I usually update my AbstractState with AS.update(CP.HmassP_INPUTS, h, P). I would like to know before hand if I am going to get an error before I update my h, and ask for props. I know CP knows the limits because when I get an error is tells it to me, which inspired this monstrosity:
def get_h_min_mol(P: float, fld: str) -> float:
# get min h from exception message
try:
CP.PropsSI('T', 'P', P, 'H', -1e6, fld)
except Exception as e:
# strip the execption message to get min h in J/mol
h_min = str(e).split("minimum value of")[1].split("J/mol")[0].strip()
# convert to float
try:
return float(h_min)
except ValueError:
raise ValueError(f"Could not extract h_min from CoolProp error message for P={P} Pa, fluid='{fld}'")
But there must be a better way.
Regards
Adam