-
Notifications
You must be signed in to change notification settings - Fork 26
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
Degrees celsius get converted to Kelvin in operations #269
Comments
Both the iflag and eflag act like an imaginary number. When you square them they go away. iflag*iflag=one The units those flags are used on fall into a couple categories. The first is where the unit itself has some sort of directionality to it, like VAR, which nominally is identical to Watts but represent the imaginary power component of phasor. In which case squaring it and having the flag go away is exactly what you want it to do. The other is a slight hack to discriminate units that otherwise cannot be discriminated. In this case squaring them would produce the otherwise equivalent unit squared which is still valid but doesn't work as well for display purposes I suppose. |
Are you implying that a different mechanism is needed to handle, e.g., degree Celsius correctly? |
My understanding of mathematical operations involving temperature units is that they should be carried out in Kelvins (or Rankine). Thus when developing the temperature handling mechanism. The fact that degC*degC produced K^2 was an acceptable feature and didn't impact common uses of temperature conversion. And I couldn't find any use case where the units using the flag intersected in common use case. Obviously you can come up with one, but I am curious what practical cases you are using where this is an issue. |
It didn't come up in any practical case. We were just extending our units support and ran some tests. What you are saying sounds like we should not even allow multiplication with degree Celsius. Is there an easy way of doing that? Either in LLNL/Units or user code. |
I comes up when dealing with uncertainties: A measurement in units degC has a standard deviation in degC, but a variance of degC^2. One could argue that we can store it in Kelvin, but then we would need to make sure that operations between degC and K work and give the expected results. |
I tweaked the eflag so it works differently than the iflag now. So degC can be raised to a power and still maintain the unit. |
Given
auto u = llnl::units::unit_from_string("degC");
, bothu*u
andpow(u, 2)
produce Kelvin squared. It seems that the e-flag gets lost in these operations.I didn't test other units because I am unsure when the e-flag gets used and how.
The text was updated successfully, but these errors were encountered: