Skip to content

Commit

Permalink
Merge branch 'dev' into df/#554-squants_grid
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/EvcsModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/HpModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/PvModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/SystemParticipantTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/WecModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/load/ProfileLoadModelTest.groovy
#	src/test/groovy/edu/ie3/simona/model/participant/load/RandomLoadModelTest.groovy
  • Loading branch information
danielfeismann committed Jul 13, 2023
2 parents 32d06d5 + 93cf3ee commit 7a570aa
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.unit.Units.CELSIUS
import static tech.units.indriya.unit.Units.PERCENT

import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed
import edu.ie3.datamodel.models.input.system.type.BmTypeInput

import squants.energy.Megawatts$
import squants.thermal.Celsius$
import edu.ie3.simona.model.participant.control.QControl
Expand All @@ -24,8 +29,7 @@ import tech.units.indriya.quantity.Quantities

import java.time.ZonedDateTime

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.unit.Units.PERCENT


/**
* Test class that tries to cover all special cases of the current implementation of the {@link BMModel}
Expand Down Expand Up @@ -69,7 +73,7 @@ class BMModelTest extends Specification {
bmType.getCosPhiRated(),
"MockNode",
true,
bmType.getOpex() as ComparableQuantity<EnergyPrice>,
bmType.opex as ComparableQuantity<EnergyPrice>,
Quantities.getQuantity(0.051d, EURO_PER_KILOWATTHOUR),
0.05)
}
Expand Down Expand Up @@ -176,13 +180,13 @@ class BMModelTest extends Specification {
bmType.getCosPhiRated(),
"MockNode",
true,
bmType.getOpex() as ComparableQuantity<EnergyPrice>,
bmType.opex as ComparableQuantity<EnergyPrice>,
Quantities.getQuantity(feedInTariff, EURO_PER_KILOWATTHOUR),
0.05)

def pElCalc = bmModel.calculateElOutput(usage, eff)

then: "compare in watts"
then: "compare in Kilowatts"
pElCalc - Sq.create(pElSol, Kilowatts$.MODULE$) < Sq.create(0.0001d, Kilowatts$.MODULE$)

where:
Expand Down Expand Up @@ -229,7 +233,7 @@ class BMModelTest extends Specification {
bmType.getCosPhiRated(),
"MockNode",
costControlled,
bmType.getOpex() as ComparableQuantity<EnergyPrice>,
bmType.opex as ComparableQuantity<EnergyPrice>,
Quantities.getQuantity(0.051d, EURO_PER_KILOWATTHOUR),
0.05)

Expand All @@ -239,6 +243,8 @@ class BMModelTest extends Specification {
when: "the power from the grid is calculated"
def powerCalc = bmModel.calculateActivePower(relevantData)

then: "compare in watts"
Math.abs(powerCalc.toSystemUnit().value.doubleValue() - Quantities.getQuantity(powerSol, KILOWATT).toSystemUnit().value.doubleValue()) < 1e-12
then: "compare in kilowatts"
powerCalc - Sq.create(powerSol, Kilowatts$.MODULE$) < Sq.create(1e-12d, Kilowatts$.MODULE$)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.quantity.Quantities.getQuantity
import static tech.units.indriya.unit.Units.PERCENT

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.StandardUnits
import edu.ie3.datamodel.models.input.OperatorInput
Expand All @@ -25,10 +29,6 @@ import squants.energy.*
import squants.space.CubicMeters$
import squants.thermal.Celsius$

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.quantity.Quantities.getQuantity
import static tech.units.indriya.unit.Units.PERCENT

class ChpModelTest extends Specification {

@Shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*

import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed
import edu.ie3.datamodel.models.input.system.type.evcslocation.EvcsLocationType
import edu.ie3.simona.api.data.ev.model.EvModel
Expand All @@ -23,10 +25,6 @@ import tech.units.indriya.quantity.Quantities

import scala.collection.immutable.Set

import static edu.ie3.util.quantities.PowerSystemUnits.*



class EvcsModelTest extends Specification {

static final double TESTING_TOLERANCE = 1e-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
Expand All @@ -20,8 +23,7 @@ import spock.lang.Specification
import squants.energy.*
import tech.units.indriya.quantity.Quantities

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs


class FixedFeedModelTest extends Specification {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE
import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT
import static tech.units.indriya.quantity.Quantities.getQuantity
import static tech.units.indriya.unit.Units.CELSIUS

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.StandardUnits
Expand All @@ -25,18 +29,7 @@ import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll

import squants.energy.Kilowatts$
import squants.thermal.Celsius$
import squants.time.Seconds$

import javax.measure.Unit
import javax.measure.quantity.Temperature

import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE
import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT

import static tech.units.indriya.quantity.Quantities.getQuantity
import static tech.units.indriya.unit.Units.CELSIUS

class HpModelTest extends Specification {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.MEGAWATT
import static java.util.Locale.US
import static java.util.Locale.setDefault
import static tech.units.indriya.quantity.Quantities.getQuantity

import edu.ie3.datamodel.io.source.csv.CsvJointGridContainerSource
import edu.ie3.datamodel.models.input.system.PvInput

Expand All @@ -29,13 +34,7 @@ import javax.measure.quantity.Power
import java.time.ZonedDateTime
import java.util.zip.GZIPInputStream

import static edu.ie3.util.quantities.PowerSystemUnits.MEGAWATT

import static java.util.Locale.US
import static java.util.Locale.setDefault
import static tech.units.indriya.quantity.Quantities.getQuantity
import static tech.units.indriya.unit.Units.KELVIN
import static tech.units.indriya.unit.Units.METRE_PER_SECOND

/**
* A simple integration test that uses pre-calculated data to check if the pv model works as expected.
Expand All @@ -60,8 +59,8 @@ class PvModelIT extends Specification implements PvModelITHelper {
setDefault(US)

pvModels = createPvModels()
weatherMap = getWeatherData()
resultsMap = getResultsData()
weatherMap = weatherData
resultsMap = resultsData
}

def "8 pv panels full year test"() {
Expand Down Expand Up @@ -102,7 +101,7 @@ class PvModelIT extends Specification implements PvModelITHelper {

"collect the results and calculate the difference between the provided results and the calculated ones"
double calc = model.calculatePower(0L, voltage, neededData).p().value().doubleValue()
double sol = resultsMap.get(dateTime).get(modelId).getValue().doubleValue()
double sol = resultsMap.get(dateTime).get(modelId).value.doubleValue()

testRes.add(Math.abs(calc - sol))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.quantity.Quantities.getQuantity

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
Expand Down Expand Up @@ -33,8 +36,7 @@ import squants.space.SquareMeters$

import java.time.ZonedDateTime

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.quantity.Quantities.getQuantity


/**
* Test class that tries to cover all special cases of the current implementation of the PvModel
Expand Down Expand Up @@ -97,16 +99,16 @@ class PvModelTest extends Specification {
// build the PvModel
double scalingFactor = 1.0d
pvModel = PvModel.apply(
pvInput.getUuid(),
pvInput.getId(),
pvInput.uuid,
pvInput.id,
OperationInterval.apply(0L, 86400L),
scalingFactor,
QControl.apply(pvInput.getqCharacteristics()),
Sq.create(pvInput.getsRated().to(KILOWATT).getValue().doubleValue(), Kilowatts$.MODULE$),
pvInput.getCosPhiRated(),
pvInput.cosPhiRated,
pvInput.getNode().getGeoPosition().getY(),
pvInput.getNode().getGeoPosition().getX(),
pvInput.getAlbedo(),
pvInput.albedo,
Sq.create(pvInput.getEtaConv().to(PU).getValue().doubleValue(), Each$.MODULE$),
Sq.create(pvInput.getAzimuth().to(RADIAN).getValue().doubleValue(), Radians$.MODULE$),
Sq.create(pvInput.getElevationAngle().getValue().doubleValue(), Radians$.MODULE$),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*

import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed
import edu.ie3.datamodel.models.input.system.characteristic.CosPhiP
import edu.ie3.datamodel.models.input.system.characteristic.QV
Expand All @@ -14,8 +16,10 @@ import edu.ie3.simona.test.common.model.MockParticipant
import edu.ie3.util.scala.OperationInterval
import edu.ie3.util.scala.quantities.Sq
import spock.lang.Specification
import squants.*
import squants.energy.*
import tech.units.indriya.quantity.Quantities
import javax.measure.quantity.Power



class SystemParticipantTest extends Specification {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

package edu.ie3.simona.model.participant

import static edu.ie3.util.quantities.PowerSystemUnits.*
import static edu.ie3.datamodel.models.StandardUnits.*
import static edu.ie3.util.quantities.QuantityUtil.equals
import static edu.ie3.simona.model.participant.WecModel.WecRelevantData
import static tech.units.indriya.quantity.Quantities.getQuantity

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
Expand All @@ -30,10 +36,7 @@ import squants.motion.Pressure
import squants.space.SquareMeters$
import squants.thermal.Celsius$

import static edu.ie3.datamodel.models.StandardUnits.*
import static edu.ie3.simona.model.participant.WecModel.WecRelevantData
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static tech.units.indriya.quantity.Quantities.getQuantity


class WecModelTest extends Specification {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

package edu.ie3.simona.model.participant.load

import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower
import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
Expand All @@ -24,10 +29,7 @@ import squants.energy.Kilowatts$
import squants.energy.Watts$
import tech.units.indriya.quantity.Quantities

import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower
import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs


class FixedLoadModelTest extends Specification {
def loadInput =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

package edu.ie3.simona.model.participant.load

import static edu.ie3.datamodel.models.profile.BdewStandardLoadProfile.*
import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower
import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
Expand All @@ -27,11 +33,6 @@ import tech.units.indriya.quantity.Quantities
import java.time.temporal.ChronoUnit
import java.util.stream.Collectors

import static edu.ie3.datamodel.models.profile.BdewStandardLoadProfile.*
import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower
import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs


class ProfileLoadModelTest extends Specification {
Expand Down Expand Up @@ -147,7 +148,7 @@ class ProfileLoadModelTest extends Specification {
when:
def max = relevantDatas.stream().mapToDouble({ relevantData ->
dut.calculateActivePower(relevantData).toMegawatts().doubleValue()
}).max().getAsDouble()
}).max().asDouble
then:
abs(max - expectedMax) < wattTolerance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

package edu.ie3.simona.model.participant.load

import static edu.ie3.datamodel.models.profile.BdewStandardLoadProfile.H0
import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower
import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs

import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
Expand All @@ -27,12 +33,6 @@ import edu.ie3.util.scala.quantities.Sq
import java.time.temporal.ChronoUnit
import java.util.stream.Collectors

import static edu.ie3.datamodel.models.profile.BdewStandardLoadProfile.H0
import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower
import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption
import static edu.ie3.util.quantities.PowerSystemUnits.*
import static org.apache.commons.math3.util.FastMath.abs

class RandomLoadModelTest extends Specification {
def loadInput = new LoadInput(
UUID.fromString("4eeaf76a-ec17-4fc3-872d-34b7d6004b03"),
Expand Down

0 comments on commit 7a570aa

Please sign in to comment.