Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to express specific heat capacity #64

Open
Mehgugs opened this issue Jul 9, 2024 · 2 comments
Open

Unable to express specific heat capacity #64

Mehgugs opened this issue Jul 9, 2024 · 2 comments

Comments

@Mehgugs
Copy link

Mehgugs commented Jul 9, 2024

Encoding specific heat capacity isn't currently possible in elm-units. I'm primarily using this library for unitful calculations and conversions but am finding the lack of a Kelvin quantity problematic.

@ianmackenzie
Copy link
Owner

Hi @Mehgugs, have you looked at the Temperature module? It's perhaps slightly funky but it includes both a Temperature type (which is kind of its own specialized thing, since e.g. it doesn't make sense to add two temperatures, so it can't be a normal Quantity), but also a Temperature.Delta type which represents the difference between two temperatures and so is a normal Quantity. I think you should be able to use Temperature.celsiusDegrees for what you want; for instance, you can evaluate this in an Elm REPL:

> Energy.joules 10 |> Quantity.per (Temperature.celsiusDegrees 1.0 |> Quantity.per Mass.kilogram)
Quantity 10
    : Quantity.Quantity
          Float
          (
          Quantity.Rate
              Energy.Joules
              (Quantity.Rate Temperature.CelsiusDegrees Mass.Kilograms)
          )

(I will admit that the fact that Temperature.degreesCelsius gives you an absolute Temperature, and Temperature.celsiusDegrees gives you a Temperature.Delta, and Temperature.kelvins gives you an absolute Temperature is all a bit awkward - perhaps it would have been cleaner to split out a separate Temperature.Delta module so that Temperature.kelvins would give you a Temperature and Temperature.Delta.kelvins would give you a Temperature.Delta, but 🤷‍♂️)

@Mehgugs
Copy link
Author

Mehgugs commented Jul 16, 2024

Thanks for the response (and for making this library)! I hadn't thought about using the Temperature.celsiusDegrees for both Celsius and Kelvin. I have some additional code for serializing units so I had a definition already referring to the kelvin functions and got a bit stuck in my head 😵

you can close this, but I would be interested in that re-organization of the modules if that happens in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants