Skip to content

Commit 095b5e3

Browse files
committed
Merge branch 'main' into ms/#320-adding-new-feature-to-GeoUtils
# Conflicts: # CHANGELOG.md
2 parents 60a6506 + b2f4b03 commit 095b5e3

File tree

3 files changed

+66
-10
lines changed

3 files changed

+66
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Added implicit classes for `loactiontec.jts` Geometries that represent geographical geometries with functionality before located in `GeoUtils` [#163](https://github.com/ie3-institute/PowerSystemUtils/issues/163)
1111
- `OsmEntity` and `OsmContainer` to provide a simple, lightweight representation of openstreetmap data
1212
- QuantityUtils previously implemented in SIMONA [#288](https://github.com/ie3-institute/PowerSystemUtils/issues/288)
13-
- Enhanced `RichQuantityDouble` with new units and generic method [#312](https://github.com/ie3-institute/PowerSystemUtils/issues/312)
13+
- Enhanced `RichQuantityDouble` with new units and generic method [#312](https://github.com/ie3-institute/PowerSystemUtils/issues/312), [#322](https://github.com/ie3-institute/PowerSystemUtils/issues/322)
1414
- Calculation of bounding box to `GeoUtils` [#320](https://github.com/ie3-institute/PowerSystemUtils/issues/320)
1515

1616
### Changed

src/main/scala/edu/ie3/util/quantities/QuantityUtils.scala

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ import javax.measure.quantity.{
3939
Energy,
4040
Length,
4141
Power,
42-
Time
42+
Temperature,
43+
Time,
44+
Volume
4345
}
4446
import scala.math.BigDecimal.RoundingMode
4547
import scala.math.BigDecimal.RoundingMode.RoundingMode
@@ -211,18 +213,34 @@ object QuantityUtils {
211213
def asMicroFarradPerKilometre: ComparableQuantity[SpecificCapacitance] =
212214
as(MICROFARAD_PER_KILOMETRE)
213215

216+
/* ==== Thermal ==== */
217+
218+
def asKelvin: ComparableQuantity[Temperature] = as(
219+
KELVIN
220+
)
221+
222+
def asDegreeCelsius: ComparableQuantity[Temperature] = as(
223+
CELSIUS
224+
)
225+
226+
def asKiloWattPerKelvin: ComparableQuantity[ThermalConductance] = as(
227+
KILOWATT_PER_KELVIN
228+
)
229+
214230
def asKiloWattHourPerKelvin: ComparableQuantity[HeatCapacity] =
215231
as(KILOWATTHOUR_PER_KELVIN)
216232

217233
def asKiloWattHourPerKelvinTimesCubicMetre
218234
: ComparableQuantity[SpecificHeatCapacity] =
219235
as(KILOWATTHOUR_PER_KELVIN_TIMES_CUBICMETRE)
220236

221-
/* ==== Thermal Conductance ==== */
237+
/* ==== Volume ==== */
222238

223-
def asKiloWattPerKelvin: ComparableQuantity[ThermalConductance] = as(
224-
KILOWATT_PER_KELVIN
225-
)
239+
def asCubicMetre: ComparableQuantity[Volume] =
240+
as(CUBIC_METRE)
241+
242+
def asLitre: ComparableQuantity[Volume] =
243+
as(LITRE)
226244

227245
/** Create a quantity from the double with given unit
228246
* @param unit

src/test/scala/edu/ie3/util/quantities/QuantityUtilsSpec.scala

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,32 @@ class QuantityUtilsSpec
381381
)
382382
}
383383

384+
/* ==== Thermal ==== */
385+
386+
"convert a double to kelvin quantity" in {
387+
value.asKelvin should equalWithTolerance(
388+
Quantities.getQuantity(
389+
value,
390+
KELVIN
391+
)
392+
)
393+
}
394+
395+
"convert a double to a degree celsius quantity" in {
396+
value.asDegreeCelsius should equalWithTolerance(
397+
Quantities.getQuantity(
398+
value,
399+
CELSIUS
400+
)
401+
)
402+
}
403+
404+
"convert a double to a kilowatt per kelvin quantity" in {
405+
value.asKiloWattPerKelvin should equalWithTolerance(
406+
Quantities.getQuantity(value, KILOWATT_PER_KELVIN)
407+
)
408+
}
409+
384410
"convert a double to a kilowatthour per kelvin quantity" in {
385411
value.asKiloWattHourPerKelvin should equalWithTolerance(
386412
Quantities.getQuantity(value, KILOWATTHOUR_PER_KELVIN)
@@ -396,11 +422,23 @@ class QuantityUtilsSpec
396422
)
397423
}
398424

399-
/* ==== Thermal Conductance ==== */
425+
/* ==== Volume ==== */
400426

401-
"convert a double to a kilowatt per kelvin quantity" in {
402-
value.asKiloWattPerKelvin should equalWithTolerance(
403-
Quantities.getQuantity(value, KILOWATT_PER_KELVIN)
427+
"convert a double to a cubic metre quantity" in {
428+
value.asCubicMetre should equalWithTolerance(
429+
Quantities.getQuantity(
430+
value,
431+
CUBIC_METRE
432+
)
433+
)
434+
}
435+
436+
"convert a double to a litre quantity" in {
437+
value.asLitre should equalWithTolerance(
438+
Quantities.getQuantity(
439+
value,
440+
LITRE
441+
)
404442
)
405443
}
406444
}

0 commit comments

Comments
 (0)