Skip to content

Add TemperatureGradient quantity with related units.#349

Merged
iliekturtles merged 1 commit into
iliekturtles:masterfrom
crystal-growth:add_temperature_gradient
Sep 3, 2022
Merged

Add TemperatureGradient quantity with related units.#349
iliekturtles merged 1 commit into
iliekturtles:masterfrom
crystal-growth:add_temperature_gradient

Conversation

@crystal-growth

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 force-pushed the add_temperature_gradient branch from 56d74ce to ede7791 Compare September 3, 2022 13:45
@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