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

Add TemperatureGradient quantity with related units. #349

Merged

Conversation

crystal-growth
Copy link
Contributor

Adding temperature gradient quantity [TemperatureInterval / Length], with base unit Kelvin / meter.

I've checked that it returns TemperatureInterval when multiplied by length:

let tgrad = TemperatureGradient::new::<kelvin_per_meter>(1.0);
let l = Length::new::<meter>(2.0);
let t_int: TemperatureInterval = tgrad * l; // ok

and fails (as it should) when trying to assign to ThermodynamicTemperature:

let t_abs: ThermodynamicTemperature = tgrad * l; // error[E0308]: mismatched types, ^^^^^^^^^ expected trait TemperatureKind, found trait Kind

Is just not providing "TempertureKind" a correct way of declaring quantities containing temperature interval in their dimension?

@iliekturtles
Copy link
Owner

In short, yes. However Kind is a pretty ugly wart in uom right now. See discussion in #313. Any multiplication or division loses kind information and defaults back to uom::Kind.

@crystal-growth
Copy link
Contributor Author

Thank you!
Now I see why it is non-trivial to implement Entropy [J/K] and Molar Entropy [J/(K/*mol)] quantities, having the same dimension as heat capacity and molar heat capacity, but with absolute temperature instead of temperature interval.
Without specifying TemperatureKind they conflict with heat capacity and molar heat capacity.
With TemperatureKind -- they fail with mismatched type error since the kind disappears in all equatiuons like
dS = dQ[Energy]/T[AbsoluteTemperature]

@iliekturtles
Copy link
Owner

Exactly. The work-around right now is to use result.into() to force the result quantity into another quantity with the appropriate kind.

@iliekturtles iliekturtles force-pushed the add_temperature_gradient branch 2 times, most recently from 4beb11f to 56d74ce Compare September 3, 2022 13:40
@iliekturtles iliekturtles merged commit 630100c into iliekturtles:master Sep 3, 2022
@crystal-growth crystal-growth deleted the add_temperature_gradient branch September 3, 2022 14:03
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.

2 participants