Skip to content
Merged
4 changes: 2 additions & 2 deletions _alp/Agents/UI_EnergyHub/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ else if (members.size() > 8) {
f_reconstructGIS_Objects(deserializedEnergyModel, saveObject.c_GISObjects);

// Get profilePointer tableFunctions from 'original' energyModel
deserializedEnergyModel.c_profiles.forEach(x->{
/* deserializedEnergyModel.c_profiles.forEach(x->{
J_ProfilePointer origProfile = zero_Interface.energyModel.f_findProfile(x.name);
x.setTableFunction(origProfile.getTableFunction());
});
}); */
// get heatingTypeHashmap from 'old' energyModel.
deserializedEnergyModel.c_defaultHeatingStrategies = zero_Interface.energyModel.c_defaultHeatingStrategies;

Expand Down
8 changes: 4 additions & 4 deletions _alp/Agents/UI_company/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@

//Check heating demand asset is null (shouldnt be possible)
if (heatDemandAsset != null){
capacityThermal_kW = heatDemandAsset.yearlyDemand_kWh/8760*10; // --> average hourly consumption * 10 --> to always have enough capacity
capacityThermal_kW = heatDemandAsset.getBaseConsumption_kWh()/8760*10; // --> average hourly consumption * 10 --> to always have enough capacity
}
else{
//Select profile heat demand asset
J_EAProfile heatDemandAsset_Profile = findFirst(GC.c_profileAssets, j_ea->j_ea.energyCarrier == OL_EnergyCarriers.HEAT);
J_EAProfile heatDemandAsset_Profile = findFirst(GC.c_profileAssets, j_ea->j_ea.getEnergyCarrier() == OL_EnergyCarriers.HEAT);

if(heatDemandAsset_Profile != null){
capacityThermal_kW = heatDemandAsset_Profile.getProfileScaling_fr() * max(heatDemandAsset_Profile.a_energyProfile_kWh)*4;
capacityThermal_kW = heatDemandAsset_Profile.getPeakConsumptionPower_kW();//heatDemandAsset_Profile.getProfileScaling_fr() * max(heatDemandAsset_Profile.a_energyProfile_kWh)*4;
}
else{
traceln("No heating demand asset found for GC:" + GC.p_gridConnectionID);
Expand Down Expand Up @@ -1600,7 +1600,7 @@ else if(setAmountOfVehicles < local_HydrogenV_nb){ // Slider has decreased the a
currentHeatSavings = roundToInt((consumptionEAHEAT.getConsumptionScaling_fr() - 1)*-100);
}
else{
J_EAProfile profileEAHEAT = findFirst(p_gridConnection.c_profileAssets, profileAsset -> profileAsset.energyCarrier == OL_EnergyCarriers.HEAT);
J_EAProfile profileEAHEAT = findFirst(p_gridConnection.c_profileAssets, profileAsset -> profileAsset.getEnergyCarrier() == OL_EnergyCarriers.HEAT);
if (profileEAHEAT != null){
currentHeatSavings = roundToInt((profileEAHEAT.getProfileScaling_fr() - 1)*-100);
}
Expand Down
10 changes: 4 additions & 6 deletions _alp/Agents/UI_company/Levels/Level.level.xml
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,8 @@ for (J_EA j_ea : p_gridConnection.c_energyAssets){
if (j_ea.getEAType() == OL_EnergyAssetType.HEAT_DEMAND) {
((J_EAConsumption)j_ea).setConsumptionScaling_fr(consumptionScaling_fr);
}
}
if (j_ea instanceof J_EAProfile) {
if (((J_EAProfile) j_ea).energyCarrier== OL_EnergyCarriers.HEAT) {
} else if (j_ea instanceof J_EAProfile &amp;&amp; !(j_ea instanceof J_EAProduction)) {
if (((J_EAProfile) j_ea).getEnergyCarrier()== OL_EnergyCarriers.HEAT) {
((J_EAProfile) j_ea).setProfileScaling_fr( consumptionScaling_fr );
}
}
Expand Down Expand Up @@ -818,9 +817,8 @@ for (J_EA j_ea : p_gridConnection.c_energyAssets) {
if (j_ea.getEAType() == OL_EnergyAssetType.ELECTRICITY_DEMAND) {
((J_EAConsumption)j_ea).setConsumptionScaling_fr(consumptionScaling_fr);
}
}
if (j_ea instanceof J_EAProfile) {
if (((J_EAProfile) j_ea).energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
} else if (j_ea instanceof J_EAProfile &amp;&amp; !(j_ea instanceof J_EAProduction)) {
if (((J_EAProfile) j_ea).getEnergyCarrier() == OL_EnergyCarriers.ELECTRICITY) {
((J_EAProfile) j_ea).setProfileScaling_fr( consumptionScaling_fr );
}
}
Expand Down
2 changes: 1 addition & 1 deletion _alp/Agents/Zero_Interface/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public void write(int b) {
else{
for ( J_EAConsumption consumptionAsset : gc.c_consumptionAssets){
if( consumptionAsset.getEAType() == OL_EnergyAssetType.ELECTRICITY_DEMAND ){
yearlyElectricityConsumption_kWh += consumptionAsset.yearlyDemand_kWh;
yearlyElectricityConsumption_kWh += consumptionAsset.getBaseConsumption_kWh();
}
}
}
Expand Down
192 changes: 132 additions & 60 deletions _alp/Agents/Zero_Loader/Code/Functions.java

Large diffs are not rendered by default.

28 changes: 4 additions & 24 deletions _alp/Agents/Zero_Loader/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -630,30 +630,6 @@
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="protected" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
<Id>1726584205845</Id>
<Name><![CDATA[f_addChargingDemandProfile]]></Name>
<X>1320</X>
<Y>600</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Parameter>
<Name><![CDATA[GC]]></Name>
<Type><![CDATA[GCPublicCharger]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[profileName]]></Name>
<Type><![CDATA[String]]></Type>
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="protected" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>String</ReturnType>
Expand Down Expand Up @@ -1267,6 +1243,10 @@ verbruik = levering + productie - teruglevering]]></Description>
<Name><![CDATA[values]]></Name>
<Type><![CDATA[double[]]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[profileUnitType]]></Name>
<Type><![CDATA[OL_ProfileUnits]]></Type>
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="public" StaticFunction="false">
Expand Down
24 changes: 12 additions & 12 deletions _alp/Agents/tabElectricity/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
}
// Set Profile Assets
for (J_EAProfile j_ea : gc.c_profileAssets) {
if (j_ea.energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
if (j_ea.getEnergyCarrier() == OL_EnergyCarriers.ELECTRICITY) {
j_ea.setProfileScaling_fr( scalingFactor );
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ else if ( gc instanceof GCUtility ) {
GCHouse house = randomWhere(gcListHouses, x -> x.p_cookingMethod == OL_HouseholdCookingMethod.ELECTRIC);
J_EAConsumption cookingAsset = findFirst(house.c_consumptionAssets, p -> p.getEAType() == OL_EnergyAssetType.ELECTRIC_HOB );
if (cookingAsset != null) {
double yearlyCookingDemand_kWh = cookingAsset.yearlyDemand_kWh;
double yearlyCookingDemand_kWh = cookingAsset.getBaseConsumption_kWh();
cookingAsset.removeEnergyAsset();

J_ProfilePointer pp = zero_Interface.energyModel.f_findProfile("default_house_hot_water_demand_fr");
Expand All @@ -407,7 +407,7 @@ else if ( gc instanceof GCUtility ) {
else {
J_EAConsumption cookingAsset = findFirst(house.c_consumptionAssets, p -> p.getEAType() == OL_EnergyAssetType.GAS_PIT );
if (cookingAsset != null) {
double yearlyCookingDemand_kWh = cookingAsset.yearlyDemand_kWh;
double yearlyCookingDemand_kWh = cookingAsset.getBaseConsumption_kWh();
cookingAsset.removeEnergyAsset();

new J_EAConsumption(house, OL_EnergyAssetType.ELECTRIC_HOB, "default_house_cooking_demand_fr", yearlyCookingDemand_kWh, OL_EnergyCarriers.ELECTRICITY, zero_Interface.energyModel.p_timeParameters, null);
Expand Down Expand Up @@ -462,13 +462,13 @@ else if(gr_electricitySliders_residential.isVisible()){
List<J_EAProfile> profileEAs = findAll(GC.c_profileAssets, profile -> profile.getAssetFlowCategory() == OL_AssetFlowCategories.fixedConsumptionElectric_kW);
List<J_EAConsumption> consumptionEAs = findAll(GC.c_consumptionAssets, consumption -> consumption.getAssetFlowCategory() == OL_AssetFlowCategories.fixedConsumptionElectric_kW);
for(J_EAProfile profileEA : profileEAs){
double baseConsumption_kWh = ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
double baseConsumption_kWh = profileEA.getBaseConsumption_kWh(); //ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
totalBaseConsumption_kWh += baseConsumption_kWh;
totalSavedConsumption_kWh += (1 - profileEA.getProfileScaling_fr()) * baseConsumption_kWh;
}
for(J_EAConsumption consumptionEA : consumptionEAs){
totalBaseConsumption_kWh += consumptionEA.yearlyDemand_kWh;
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.yearlyDemand_kWh;
totalBaseConsumption_kWh += consumptionEA.getBaseConsumption_kWh();
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.getBaseConsumption_kWh();
}
}
}
Expand Down Expand Up @@ -571,13 +571,13 @@ else if(productionEA.getEAType() == OL_EnergyAssetType.WINDMILL){
List<J_EAProfile> profileEAs = findAll(GC.c_profileAssets, profile -> profile.getAssetFlowCategory() == OL_AssetFlowCategories.fixedConsumptionElectric_kW);
List<J_EAConsumption> consumptionEAs = findAll(GC.c_consumptionAssets, consumption -> consumption.getAssetFlowCategory() == OL_AssetFlowCategories.fixedConsumptionElectric_kW);
for(J_EAProfile profileEA : profileEAs){
double baseConsumption_kWh = ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
double baseConsumption_kWh = profileEA.getBaseConsumption_kWh(); //ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
totalBaseConsumption_kWh += baseConsumption_kWh;
totalSavedConsumption_kWh += (1 - profileEA.getProfileScaling_fr()) * baseConsumption_kWh;
}
for(J_EAConsumption consumptionEA : consumptionEAs){
totalBaseConsumption_kWh += consumptionEA.yearlyDemand_kWh;
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.yearlyDemand_kWh;
totalBaseConsumption_kWh += consumptionEA.getBaseConsumption_kWh();
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.getBaseConsumption_kWh();
}
}
}
Expand Down Expand Up @@ -616,13 +616,13 @@ else if(productionEA.getEAType() == OL_EnergyAssetType.WINDMILL){
List<J_EAProfile> profileEAs = findAll(GC.c_profileAssets, profile -> profile.getAssetFlowCategory() == OL_AssetFlowCategories.fixedConsumptionElectric_kW);
List<J_EAConsumption> consumptionEAs = findAll(GC.c_consumptionAssets, consumption -> consumption.getAssetFlowCategory() == OL_AssetFlowCategories.fixedConsumptionElectric_kW);
for(J_EAProfile profileEA : profileEAs){
double baseConsumption_kWh = ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
double baseConsumption_kWh = profileEA.getBaseConsumption_kWh();//ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
totalBaseConsumption_kWh += baseConsumption_kWh;
totalSavedConsumption_kWh += (1 - profileEA.getProfileScaling_fr()) * baseConsumption_kWh;
}
for(J_EAConsumption consumptionEA : consumptionEAs){
totalBaseConsumption_kWh += consumptionEA.yearlyDemand_kWh;
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.yearlyDemand_kWh;
totalBaseConsumption_kWh += consumptionEA.getBaseConsumption_kWh();
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.getBaseConsumption_kWh();
}
}
}
Expand Down
40 changes: 23 additions & 17 deletions _alp/Agents/tabHeating/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int f_setHeatingSystemsCompanies(List<GCUtility> gcList,ShapeSlider sliderGasbur
}
// Set Profile Assets
for (J_EAProfile j_ea : gc.c_profileAssets) {
if (j_ea.energyCarrier == OL_EnergyCarriers.HEAT) {
if (j_ea.getEnergyCarrier() == OL_EnergyCarriers.HEAT) {
j_ea.setProfileScaling_fr( scalingFactor );
}
}
Expand Down Expand Up @@ -216,17 +216,17 @@ int f_setHeatingSystemsWithCompanyUI(List<GCUtility> gcList,double targetHeatPum
double f_calculatePeakHeatDemand_kW(GridConnection gc)
{/*ALCODESTART::1749116448649*/
double peakHeatDemand_kW = 0.0;
for (J_EAConsumption j_ea : gc.c_consumptionAssets) {
/*for (J_EAConsumption j_ea : gc.c_consumptionAssets) {
if (j_ea.getEAType() == OL_EnergyAssetType.HEAT_DEMAND || j_ea.getEAType() == OL_EnergyAssetType.HOT_WATER_CONSUMPTION) {
double[] profile = j_ea.getProfilePointer().getAllValues();
double maxFactor = Arrays.stream(profile).max().getAsDouble();
peakHeatDemand_kW += maxFactor * j_ea.yearlyDemand_kWh * j_ea.getConsumptionScaling_fr();
peakHeatDemand_kW += maxFactor * j_ea.getYearlyDemand_kWh() * j_ea.getConsumptionScaling_fr();
}
}
}*/
for (J_EAProfile j_ea : gc.c_profileAssets) {
if (j_ea.energyCarrier == OL_EnergyCarriers.HEAT) {
double maxValue = j_ea.getProfileScaling_fr() * Arrays.stream(j_ea.a_energyProfile_kWh).max().getAsDouble();
peakHeatDemand_kW += maxValue / zero_Interface.energyModel.p_timeParameters.getTimeStep_h() * j_ea.getProfileScaling_fr();
if (j_ea.getEnergyCarrier() == OL_EnergyCarriers.HEAT && !(j_ea instanceof J_EAProduction)) {
//double maxPower_kW = j_ea.getPeakPower_kW(); //j_ea.getProfileScaling_fr() * Arrays.stream(j_ea.a_energyProfile_kWh).max().getAsDouble();
peakHeatDemand_kW += j_ea.getPeakConsumptionPower_kW(); //maxValue / zero_Interface.energyModel.p_timeParameters.getTimeStep_h() * j_ea.getProfileScaling_fr();
}
}
if (gc.p_BuildingThermalAsset != null) {
Expand Down Expand Up @@ -297,13 +297,18 @@ int f_setHeatingSystemsWithCompanyUI(List<GCUtility> gcList,double targetHeatPum
house.f_removeAllHeatingAssets();
house.p_parentNodeHeat = null;
house.p_parentNodeHeatID = null;

//add gasburner
double peakHeatDemand_kW = f_calculatePeakHeatDemand_kW(house);
new J_EAConversionGasBurner(house, peakHeatDemand_kW, zero_Interface.energyModel.avgc_data.p_avgEfficiencyGasBurner_fr, zero_Interface.energyModel.p_timeParameters, 90);
house.f_addHeatManagement(OL_GridConnectionHeatingType.GAS_BURNER, false);

/*
J_EAConsumption heatDemandAsset = findFirst(house.c_consumptionAssets, j_ea -> j_ea.getEAType() == OL_EnergyAssetType.HEAT_DEMAND);
J_EAConversionGasBurner gasBurner;
//if house has follows the general heat deamnd profile
if (heatDemandAsset != null) {
gasBurner = new J_EAConversionGasBurner(house, heatDemandAsset.yearlyDemand_kWh/8760*10, 0.99, zero_Interface.energyModel.p_timeParameters, 90);
gasBurner = new J_EAConversionGasBurner(house, heatDemandAsset.getYearlyDemand_kWh()/8760*10, 0.99, zero_Interface.energyModel.p_timeParameters, 90);
}
//if house has a thermalBuildingAsset
else if (house.p_BuildingThermalAsset != null){
Expand All @@ -312,11 +317,12 @@ else if (house.p_BuildingThermalAsset != null){
}
// Else house has a customprofiel
else {
J_EAProfile heatDemandProfile = (J_EAProfile)findFirst(house.c_profileAssets, x->x instanceof J_EAProfile && x.energyCarrier == OL_EnergyCarriers.HEAT);
double peakHeatDemand_kW = heatDemandProfile.getProfileScaling_fr() * Arrays.stream(heatDemandProfile.a_energyProfile_kWh).max().orElseThrow(() -> new RuntimeException("Unable to find the maximum of the heat demand profile"));
J_EAProfile heatDemandProfile = (J_EAProfile)findFirst(house.c_profileAssets, x->x instanceof J_EAProfile && x.getEnergyCarrier() == OL_EnergyCarriers.HEAT && !(x instanceof J_EAProduction));
double peakHeatDemand_kW = heatDemandProfile.getPeakPower_kW();//heatDemandProfile.getProfileScaling_fr() * Arrays.stream(heatDemandProfile.a_energyProfile_kWh).max().orElseThrow(() -> new RuntimeException("Unable to find the maximum of the heat demand profile"));
gasBurner = new J_EAConversionGasBurner(house, peakHeatDemand_kW, 0.99, zero_Interface.energyModel.p_timeParameters, 90);
}
house.f_addHeatManagement(OL_GridConnectionHeatingType.GAS_BURNER, false);
*/
}

//Update variable to change to custom scenario
Expand Down Expand Up @@ -710,13 +716,13 @@ else if(gr_heatingSliders_residential.isVisible()){
List<J_EAProfile> profileEAs = findAll(GC.c_profileAssets, profile -> profile.getEnergyCarrier() == OL_EnergyCarriers.HEAT);
List<J_EAConsumption> consumptionEAs = findAll(GC.c_consumptionAssets, consumption -> consumption.getActiveEnergyCarriers().contains(OL_EnergyCarriers.HEAT));
for(J_EAProfile profileEA : profileEAs){
double baseConsumption_kWh = ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
double baseConsumption_kWh = profileEA.getBaseConsumption_kWh(); //ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
totalBaseConsumption_kWh += baseConsumption_kWh;
totalSavedConsumption_kWh += (1 - profileEA.getProfileScaling_fr()) * baseConsumption_kWh;
}
for(J_EAConsumption consumptionEA : consumptionEAs){
totalBaseConsumption_kWh += consumptionEA.yearlyDemand_kWh;
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.yearlyDemand_kWh;
totalBaseConsumption_kWh += consumptionEA.getBaseConsumption_kWh();
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.getBaseConsumption_kWh();
}

if(GC.p_BuildingThermalAsset != null){
Expand Down Expand Up @@ -935,13 +941,13 @@ else if(gr_heatingSliders_residential.isVisible()){
List<J_EAProfile> profileEAs = findAll(GC.c_profileAssets, profile -> profile.getEnergyCarrier() == OL_EnergyCarriers.HEAT); // FIX FOR HOT WATER/PT IN LONG RUN
List<J_EAConsumption> consumptionEAs = findAll(GC.c_consumptionAssets, consumption -> consumption.getEAType() == OL_EnergyAssetType.HEAT_DEMAND);
for(J_EAProfile profileEA : profileEAs){
double baseConsumption_kWh = ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
double baseConsumption_kWh = profileEA.getBaseConsumption_kWh(); //ZeroMath.arraySum(profileEA.a_energyProfile_kWh);
totalBaseConsumption_kWh += baseConsumption_kWh;
totalSavedConsumption_kWh += (1 - profileEA.getProfileScaling_fr()) * baseConsumption_kWh;
}
for(J_EAConsumption consumptionEA : consumptionEAs){
totalBaseConsumption_kWh += consumptionEA.yearlyDemand_kWh;
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.yearlyDemand_kWh;
totalBaseConsumption_kWh += consumptionEA.getBaseConsumption_kWh();
totalSavedConsumption_kWh += (1-consumptionEA.getConsumptionScaling_fr())*consumptionEA.getBaseConsumption_kWh();
}

if(GC.p_BuildingThermalAsset != null){
Expand Down
1 change: 1 addition & 0 deletions _alp/Classes/Class.CustomProfile_data.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class CustomProfile_data {
String customProfileID;
List<Double> argumentsList;
List<Double> valuesList;
OL_ProfileUnits profileUnits;

public double[] getArgumentsArray() {
return ListUtil.doubleListToArray(argumentsList);
Expand Down
19 changes: 8 additions & 11 deletions _alp/Classes/Class.Settings.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;


/**
* Settings
*/

@Data
@Builder(toBuilder = true)
@Accessors(fluent = true)
@lombok.Builder
@lombok.Value
@lombok.experimental.Accessors(fluent = true)
//@FieldDefaults(level = AccessLevel.PRIVATE)
public class Settings {

//Simulation settings (Time)
@Builder.Default
@lombok.Builder.Default
double timeStep_h = 0.25; //Length of the simulation timestep in Hr
@Builder.Default
@lombok.Builder.Default
int summerWeekNumber = 18; //Week number of the year where data will be stored for to display a 'default' summerweek
@Builder.Default
@lombok.Builder.Default
int winterWeekNumber = 49; //Week number of the year where data will be stored for to display a 'default' winterweek
@Builder.Default
@lombok.Builder.Default
double simDuration_h = 8760; // (Rapid sim (and Live sim before loop) duration in hours since the start time h.


Expand Down