Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.UUID;
import javax.measure.quantity.Temperature;
import javax.measure.quantity.Volume;
import org.apache.commons.lang3.NotImplementedException;
import tech.units.indriya.ComparableQuantity;

/** Thermal storage with cylindrical shape */
Expand Down Expand Up @@ -107,10 +106,8 @@ public ComparableQuantity<SpecificHeatCapacity> getC() {
return c;
}

@Override
public UniqueEntityBuilder copy() {
throw new NotImplementedException(
"Copying of " + this.getClass().getSimpleName() + " entities is not supported yet!");
public CylindricalStorageInputCopyBuilder copy() {
return new CylindricalStorageInputCopyBuilder(this);
}

@Override
Expand Down Expand Up @@ -157,4 +154,76 @@ public String toString() {
+ c
+ '}';
}

/**
* A builder pattern based approach to create copies of {@link CylindricalStorageInput} entities
* with altered field values. For detailed field descriptions refer to java docs of {@link
* CylindricalStorageInput}
*/
public static class CylindricalStorageInputCopyBuilder
extends ThermalUnitInput.ThermalUnitInputCopyBuilder<CylindricalStorageInputCopyBuilder> {

private ComparableQuantity<Volume> storageVolumeLvl;
private ComparableQuantity<Volume> storageVolumeLvlMin;
private ComparableQuantity<Temperature> inletTemp;
private ComparableQuantity<Temperature> returnTemp;
private ComparableQuantity<SpecificHeatCapacity> c;

private CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) {
super(entity);
this.storageVolumeLvl = entity.getStorageVolumeLvl();
this.storageVolumeLvlMin = entity.getStorageVolumeLvlMin();
this.inletTemp = entity.getInletTemp();
this.returnTemp = entity.getReturnTemp();
this.c = entity.getC();
}

@Override
public CylindricalStorageInput build() {
return new CylindricalStorageInput(
getUuid(),
getId(),
getOperator(),
getOperationTime(),
getThermalBus(),
storageVolumeLvl,
storageVolumeLvlMin,
inletTemp,
returnTemp,
c);
}

public CylindricalStorageInputCopyBuilder storageVolumeLvl(
ComparableQuantity<Volume> storageVolumeLvl) {
this.storageVolumeLvl = storageVolumeLvl;
return this;
}

public CylindricalStorageInputCopyBuilder storageVolumeLvlMin(
ComparableQuantity<Volume> storageVolumeLvlMin) {
this.storageVolumeLvlMin = storageVolumeLvlMin;
return this;
}

public CylindricalStorageInputCopyBuilder inletTemp(ComparableQuantity<Temperature> inletTemp) {
this.inletTemp = inletTemp;
return this;
}

public CylindricalStorageInputCopyBuilder returnTemp(
ComparableQuantity<Temperature> returnTemp) {
this.returnTemp = returnTemp;
return this;
}

public CylindricalStorageInputCopyBuilder c(ComparableQuantity<SpecificHeatCapacity> c) {
this.c = c;
return this;
}

@Override
protected CylindricalStorageInputCopyBuilder childInstance() {
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import edu.ie3.datamodel.models.input.AssetInput;
import edu.ie3.datamodel.models.input.OperatorInput;
import java.util.UUID;
import org.apache.commons.lang3.NotImplementedException;

/** A thermal bus, to which different {@link ThermalUnitInput} units may be connected */
public class ThermalBusInput extends AssetInput {
Expand All @@ -36,9 +35,30 @@ public ThermalBusInput(UUID uuid, String id) {
super(uuid, id);
}

@Override
public UniqueEntityBuilder copy() {
throw new NotImplementedException(
"Copying of " + this.getClass().getSimpleName() + " entities is not supported yet!");
public ThermalBusInputCopyBuilder copy() {
return new ThermalBusInputCopyBuilder(this);
}

/**
* A builder pattern based approach to create copies of {@link ThermalBusInput} entities with
* altered field values. For detailed field descriptions refer to java docs of {@link
* ThermalBusInput}
*/
public static class ThermalBusInputCopyBuilder
extends AssetInput.AssetInputCopyBuilder<ThermalBusInputCopyBuilder> {

private ThermalBusInputCopyBuilder(ThermalBusInput entity) {
super(entity);
}

@Override
public ThermalBusInput build() {
return new ThermalBusInput(getUuid(), getId(), getOperator(), getOperationTime());
}

@Override
protected ThermalBusInputCopyBuilder childInstance() {
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import edu.ie3.util.quantities.interfaces.ThermalConductance;
import java.util.Objects;
import java.util.UUID;
import org.apache.commons.lang3.NotImplementedException;
import tech.units.indriya.ComparableQuantity;

/** Quite simple thermal model of a house to serve as a heat sink */
Expand Down Expand Up @@ -70,10 +69,8 @@ public ComparableQuantity<HeatCapacity> getEthCapa() {
return ethCapa;
}

@Override
public UniqueEntityBuilder copy() {
throw new NotImplementedException(
"Copying of " + this.getClass().getSimpleName() + " entities is not supported yet!");
public ThermalHouseInputCopyBuilder copy() {
return new ThermalHouseInputCopyBuilder(this);
}

@Override
Expand Down Expand Up @@ -109,4 +106,50 @@ public String toString() {
+ ethCapa
+ '}';
}

/**
* A builder pattern based approach to create copies of {@link ThermalHouseInput} entities with
* altered field values. For detailed field descriptions refer to java docs of {@link
* ThermalHouseInput}
*/
public static class ThermalHouseInputCopyBuilder
extends ThermalUnitInput.ThermalUnitInputCopyBuilder<ThermalHouseInputCopyBuilder> {

private ComparableQuantity<ThermalConductance> ethLosses;
private ComparableQuantity<HeatCapacity> ethCapa;

private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) {
super(entity);
this.ethLosses = entity.getEthLosses();
this.ethCapa = entity.getEthCapa();
}

@Override
public ThermalHouseInput build() {
return new ThermalHouseInput(
getUuid(),
getId(),
getOperator(),
getOperationTime(),
getThermalBus(),
ethLosses,
ethCapa);
}

public ThermalHouseInputCopyBuilder ethLosses(
ComparableQuantity<ThermalConductance> ethLosses) {
this.ethLosses = ethLosses;
return this;
}

public ThermalHouseInputCopyBuilder ethCapa(ComparableQuantity<HeatCapacity> ethCapa) {
this.ethCapa = ethCapa;
return this;
}

@Override
protected ThermalHouseInputCopyBuilder childInstance() {
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,35 @@ public String toString() {
+ thermalBus.getUuid()
+ '}';
}

/**
* Abstract class for all builders that build child entities of abstract class {@link
* ThermalUnitInput}
*/
protected abstract static class ThermalUnitInputCopyBuilder<
T extends ThermalUnitInput.ThermalUnitInputCopyBuilder<T>>
extends AssetInputCopyBuilder<T> {

private ThermalBusInput thermalBus;

protected ThermalUnitInputCopyBuilder(ThermalUnitInput entity) {
super(entity);
this.thermalBus = entity.getThermalBus();
}

public T thermalBus(ThermalBusInput thermalBus) {
this.thermalBus = thermalBus;
return childInstance();
}

protected ThermalBusInput getThermalBus() {
return thermalBus;
}

@Override
public abstract ThermalUnitInput build();

@Override
protected abstract T childInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.thermal

import edu.ie3.test.common.ThermalUnitInputTestData
import spock.lang.Specification


class CylindricalStorageInputTest extends Specification {

def "A CylindricalStorageInput copy method should work as expected"() {
given:
def cylindricalStorageInput = ThermalUnitInputTestData.cylindricStorageInput

when:
def alteredUnit = cylindricalStorageInput.copy().storageVolumeLvl(ThermalUnitInputTestData.storageVolumeLvl)
.storageVolumeLvlMin(ThermalUnitInputTestData.storageVolumeLvlMin).inletTemp(ThermalUnitInputTestData.inletTemp)
.returnTemp(ThermalUnitInputTestData.returnTemp).c(ThermalUnitInputTestData.c)
.thermalBus(ThermalUnitInputTestData.thermalBus).build()


then:
alteredUnit.with {
assert uuid == cylindricalStorageInput.uuid
assert id == cylindricalStorageInput.id
assert operator == cylindricalStorageInput.operator
assert operationTime == cylindricalStorageInput.operationTime
assert thermalBus == cylindricalStorageInput.thermalBus
assert storageVolumeLvl == ThermalUnitInputTestData.storageVolumeLvl
assert storageVolumeLvlMin == ThermalUnitInputTestData.storageVolumeLvlMin
assert inletTemp == ThermalUnitInputTestData.inletTemp
assert returnTemp == ThermalUnitInputTestData.returnTemp
assert c == ThermalUnitInputTestData.c
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.thermal

import edu.ie3.test.common.ThermalUnitInputTestData
import spock.lang.Specification


class ThermalBusInputTest extends Specification {

def "A ThermalBusInput copy method should work as expected"() {
given:
def thermalBusInput = ThermalUnitInputTestData.thermalBus

when:
def alteredUnit = thermalBusInput.copy().build()


then:
alteredUnit.with {
assert uuid == thermalBusInput.uuid
assert id == thermalBusInput.id
assert operator == thermalBusInput.operator
assert operationTime == thermalBusInput.operationTime
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.thermal

import edu.ie3.test.common.ThermalUnitInputTestData
import spock.lang.Specification


class ThermalHouseInputTest extends Specification {

def "A ThermalHouseInput copy method should work as expected"() {
given:
def thermalHouseInput = ThermalUnitInputTestData.thermalHouseInput

when:
def alteredUnit = thermalHouseInput.copy().ethLosses(ThermalUnitInputTestData.thermalConductance)
.ethCapa(ThermalUnitInputTestData.ethCapa).thermalBus(ThermalUnitInputTestData.thermalBus).build()


then:
alteredUnit.with {
assert uuid == thermalHouseInput.uuid
assert id == thermalHouseInput.id
assert operator == thermalHouseInput.operator
assert operationTime == thermalHouseInput.operationTime
assert thermalBus == thermalHouseInput.thermalBus
assert ethLosses == ThermalUnitInputTestData.thermalConductance
assert ethCapa == ThermalUnitInputTestData.ethCapa
}
}
}