CliMA / Thermodynamics.jl

A package containing a library of moist thermodynamic relations.
https://clima.github.io/Thermodynamics.jl/dev/
Apache License 2.0
61 stars 2 forks source link

Add capability for user-defined parameter sets, with an example (take 2) #210

Closed glwagner closed 6 months ago

glwagner commented 7 months ago

This PR re-opens #172.

This PR tweaks the internal API for defining parameter sets to support user-defined parameters. This is important, because it will allow users to invoke functions in Thermodynamics.jl without requiring the full suite of parameters in ThermodynamicsParameters. For example, if one is only interested in computing density as a function of temperature, pressure, and (total) specific humidity, then they only require the universal gas constant and the molar masses of air and water.

Next, this PR adds an example which illustrates such a parameter set, called ConstitutiveParameters. It culminates in this plot:

image

which uses sea level data derived from the JRA55 reanalysis (subsampled to make the dataset smaller), showing the primary dependence of density on temperature, secondary dependence on pressure, and teritiary dependence on specific humidity for the typical conditions of the Earth's atmosphere at sea level.

Currently, there are no examples, so this PR introduces the first one. I'd be happy to turn the example into something that appears in the documentation via Literate (the example is very close to that form already).

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.93%. Comparing base (46f51af) to head (808b6b6).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #210 +/- ## ======================================= Coverage 90.93% 90.93% ======================================= Files 10 10 Lines 1180 1180 ======================================= Hits 1073 1073 Misses 107 107 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

glwagner commented 7 months ago

@navidcy @charleskawczynski @simone-silvestri this passes now.

charleskawczynski commented 7 months ago

Can we please rebase and squash this PR? I like having a tidy and linear history.

glwagner commented 7 months ago

Why?

charleskawczynski commented 7 months ago

Why?

It's good practice. I can do it. Just let me know when you're ready to merge, @glwagner.

glwagner commented 7 months ago

I disagree that it's good practice for us. The PR is ready.

navidcy commented 6 months ago

I added the examples in the Docs via Literate. Feel free to revert if you don't think this is a good idea.