Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
- `OsmEntity` and `OsmContainer` to provide a simple, lightweight representation of openstreetmap data
- QuantityUtils previously implemented in SIMONA [#288](https://github.com/ie3-institute/PowerSystemUtils/issues/288)
- Enhanced `RichQuantityDouble` with new units and generic method [#312](https://github.com/ie3-institute/PowerSystemUtils/issues/312)
- 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)

### Changed
- Refactored `GeoUtils`, moved them to the scala package and tailored them toward the `loactiontec.jts` Geometries used in the `OsmContainer` [#163](https://github.com/ie3-institute/PowerSystemUtils/issues/163)
Expand Down
28 changes: 23 additions & 5 deletions src/main/scala/edu/ie3/util/quantities/QuantityUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import javax.measure.quantity.{
Energy,
Length,
Power,
Time
Temperature,
Time,
Volume
}
import scala.math.BigDecimal.RoundingMode
import scala.math.BigDecimal.RoundingMode.RoundingMode
Expand Down Expand Up @@ -211,19 +213,35 @@ object QuantityUtils {
def asMicroFarradPerKilometre: ComparableQuantity[SpecificCapacitance] =
as(MICROFARAD_PER_KILOMETRE)

def asKiloWattHourPerKelvin: ComparableQuantity[HeatCapacity] =
as(KILOWATTHOUR_PER_KELVIN)

def asKiloWattHourPerKelvinTimesCubicMetre
: ComparableQuantity[SpecificHeatCapacity] =
as(KILOWATTHOUR_PER_KELVIN_TIMES_CUBICMETRE)

/* ==== Thermal Conductance ==== */
/* ==== Thermal ==== */

def asKelvin: ComparableQuantity[Temperature] = as(
KELVIN
)

def asDegreeCelsius: ComparableQuantity[Temperature] = as(
CELSIUS
)

def asKiloWattPerKelvin: ComparableQuantity[ThermalConductance] = as(
KILOWATT_PER_KELVIN
)

def asKiloWattHourPerKelvin: ComparableQuantity[HeatCapacity] =
as(KILOWATTHOUR_PER_KELVIN)

/* ==== Volume ==== */

def asCubicMetre: ComparableQuantity[Volume] =
as(CUBIC_METRE)

def asLitre: ComparableQuantity[Volume] =
as(LITRE)

/** Create a quantity from the double with given unit
* @param unit
* the unit to create the quantity with
Expand Down
52 changes: 45 additions & 7 deletions src/test/scala/edu/ie3/util/quantities/QuantityUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,6 @@ class QuantityUtilsSpec
)
}

"convert a double to a kilowatthour per kelvin quantity" in {
value.asKiloWattHourPerKelvin should equalWithTolerance(
Quantities.getQuantity(value, KILOWATTHOUR_PER_KELVIN)
)
}

"convert a double to a kilowatthour per kelvin times cubic metre quantity" in {
value.asKiloWattHourPerKelvinTimesCubicMetre should equalWithTolerance(
Quantities.getQuantity(
Expand All @@ -396,13 +390,57 @@ class QuantityUtilsSpec
)
}

/* ==== Thermal Conductance ==== */
/* ==== Thermal ==== */

"convert a double to kelvin quantity" in {
value.asKelvin should equalWithTolerance(
Quantities.getQuantity(
value,
KELVIN
)
)
}

"convert a double to a degree celsius quantity" in {
value.asDegreeCelsius should equalWithTolerance(
Quantities.getQuantity(
value,
CELSIUS
)
)
}

"convert a double to a kilowatt per kelvin quantity" in {
value.asKiloWattPerKelvin should equalWithTolerance(
Quantities.getQuantity(value, KILOWATT_PER_KELVIN)
)
}

"convert a double to a kilowatthour per kelvin quantity" in {
value.asKiloWattHourPerKelvin should equalWithTolerance(
Quantities.getQuantity(value, KILOWATTHOUR_PER_KELVIN)
)
}

/* ==== Volume ==== */

"convert a double to a cubic metre quantity" in {
value.asCubicMetre should equalWithTolerance(
Quantities.getQuantity(
value,
CUBIC_METRE
)
)
}

"convert a double to a litre quantity" in {
value.asLitre should equalWithTolerance(
Quantities.getQuantity(
value,
LITRE
)
)
}
}

"extend the quantity functionality" should {
Expand Down