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

Fix apparent typo in JavaDoc of Quantity #254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vorburger
Copy link

@vorburger vorburger commented Oct 8, 2023

@keilw


This change is Reviewable

Copy link
Member

@keilw keilw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vorburger Kelvin is wrong here.
The numeric value is indeed a little incorrect,
It should be 2°C + 1°C = 276.15°C.

If you could fix that I'd be happy to merge the PR.

@vorburger
Copy link
Author

should be 2°C + 1°C = 276.15°C

Wait, what? Is that a typo, or intentional? It doesn't make sense to me, like this... adding two quantities (2+1) of the same °C unit, becomes a 276.15°C, really?

@keilw
Copy link
Member

keilw commented Oct 9, 2023

Yes, that's the whole point of Quantity.Scale.

Check out the Indriya (RI) TemperatureTest
or
QuantitiesTest by Seshat, another compatible implementation.

As well as TemperatureDemo for

Ask @desruisseaux for the motivation.

@desruisseaux
Copy link
Contributor

Hello @vorburger

adding two quantities (2+1) of the same °C unit, becomes a 276.15°C, really?

Yes, really at least in some cases for the particular case of °C. Actually it depends on whether 1°C is an absolute temperature or an increment. This is why there is a Quantity.Scale enumeration with two values: ABSOLUTE and RELATIVE.

If 1°C is an increment (Scale.RELATIVE), then 2°C + 1°C is equal to 3°C. But if 1°C is a temperature measurement (Scale.ABSOLUTE), then the calculation must be done in K. This is required by thermodynamic laws. So 2°C + 1°C is equal to 275.15 K + 274.15 K = 549.30 K = 276.15°C. The reason is that we are computing the amount of energy in a system.

So if you want 2°C + 1°C = 3°C, you need to tell the library that 1°C is an increment rather than an absolute measurement. This ambiguity exists for °C and not for other standard units (ignoring °F) because °C has a zero which is shifted compared to the base SI unit. For non-shifted units, the distinction between absolute and relative makes no difference, because the shift is zero.

@desruisseaux
Copy link
Contributor

A few resources are below. We have to be careful with the answers of this kind of forum as they may sometime be questionable, but the high-ranked answers have good chances to be good resources:

@keilw
Copy link
Member

keilw commented Oct 10, 2023

@vorburger Any chance you could fix this PR? As it's just a single digit, we could also close it and address the viable part of it separately.

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

Successfully merging this pull request may close these issues.

None yet

3 participants