contrailcirrus / pycontrails

Python library for modeling contrails and other aviation climate impacts
https://py.contrails.org/
Apache License 2.0
59 stars 17 forks source link

Possible typo in thermo.py under def c_pm() #184

Closed Mahendhar1021 closed 6 months ago

Mahendhar1021 commented 6 months ago

Current : return constants.c_pd (1.0 + (constants.c_pv / constants.c_pd + 1.0) q)

Proposed modification : return constants.c_pd (1.0 + (constants.c_pv / constants.c_pd - 1.0) q)

Reason: When q(specific humidity) is 0, c_pm = c_pd but when q=1, c_pm should be equal to c_pv, which is not the case.

thabbott commented 6 months ago

I agree that this is a typo! Thanks for bringing it to our attention.

I think the best thing to do is implement the calculation as constants.c_pd * (1.0 - q) + constants.c_pv * q. That's equivalent to what you derived but makes the physics (specific heat capacities weighted by mass fractions) much more obvious.

I'll patch this (unless you're interested in contributing, in which case feel free to open a PR!).

mlshapiro commented 6 months ago

Thanks for catching this error @Mahendhar1021!

I agree @thabbott I'd prefer the formula constants.c_pd * (1.0 - q) + constants.c_pv * q (more aligned with the text)