squants.thermal
Type members
Classlikes
Represents a quantity of temperature
Represents a quantity of temperature
Temperatures are somewhat unique in the world of quantities for a couple of reasons.
First, different units (scales) have different "zero" values. This means that these scales are not simple multiples of the others. There is a "zero offset" that must be applied to conversions from one scale to another.
Second, temperatures are often quoted as though they were quantities, when in fact they are just points on a scale. Similar to a mile marker on a highway, the quantity represented is the number degrees (miles) from a specific "zero" value on the scale.
In fact an absolute quantity of thermodynamic temperature should be measured from absolute zero. Thus, Kelvin, is the SI Base unit for temperature.
The other scales supported here, Celsius and Fahrenheit, are known as empirical scales. Of course, these scales set their respective zero values well above absolute zero. This is done to provide a granular and reasonably sized ranges of values for dealing with everyday temperatures.
This library supports another absolute scale, the Rankine scale. Rankine sets its zero at absolute zero, but degrees are measure in Fahrenheit (as opposed to Celsius, as the Kelvin scale uses).
In consideration of these more unique scale conversions, two conversion types are supported: Degrees and Scale.
Scale based conversions DO adjust for the zero offset. Thus 5 degrees C is the same as 41 degrees F on the thermometer.
Degrees based conversions DO NOT adjust for the zero point. Thus 5 degrees C|K is the same amount of temperature as 9 degrees F|R.
When creating a temperature it is not important to consider these differences. It is also irrelevant when performing operation on temperatures in the same scale. However, when performing operations on two temperatures of different scales these factors do become important.
The Quantity.to(unit) and Quantity.in(unit) methods are overridden to use Scale conversions for convenience
The Ordered.compare method is implemented to use Scale conversions
The Quantity.plus and Quantity.minus methods are implemented to treat right operands as Quantity of Degrees and not a scale Temperature. Operands that differ in scale will use Degree conversions. This supports mixed scale expressions:
val temp = Fahrenheit(100) - Celsius(5) // returns Fahrenheit(91)
This also supports declaring temperature ranges using typical nomenclature:
val tempRange = 65.F +- 5.C // returns QuantityRange(56.0°F,74.0°F)
The toDegrees(unit) methods are implemented to use Degree conversions.
- Value Params
- value
the value of the temperature
- Authors
garyKeorkunian
- Since
0.1
- Companion
- object
Base trait for units of squants.thermal.Temperature
Base trait for units of squants.thermal.Temperature
Represents the capacity of some substance or system to hold thermal energy.
Represents the capacity of some substance or system to hold thermal energy.
Also a representation of Entropy
- Value Params
- value
the value in squants.thermal.JoulesPerKelvin
- Authors
garyKeorkunian
- Since
0.1
- Companion
- object