diff --git a/Zero_engine.alpx b/Zero_engine.alpx
index 348fd46..af10aca 100644
--- a/Zero_engine.alpx
+++ b/Zero_engine.alpx
@@ -779,35 +779,30 @@
1718560423698
-
- true
+
-
diff --git a/_alp/Agents/GridConnection/Code/Functions.java b/_alp/Agents/GridConnection/Code/Functions.java
index 9f0c77b..ce0840e 100644
--- a/_alp/Agents/GridConnection/Code/Functions.java
+++ b/_alp/Agents/GridConnection/Code/Functions.java
@@ -123,6 +123,7 @@
}
+
/*ALCODEEND*/}
double f_resetStates()
@@ -309,10 +310,10 @@ else if (productionAsset.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
energyModel.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh;
}
-} else if (j_ea instanceof J_EAProfile profileAsset) {
- c_profileAssets.add(profileAsset);
} else if (j_ea instanceof J_EAPetroleumFuelTractor tractor) {
c_profileAssets.add(tractor);
+} else if (j_ea instanceof J_EAProfile profileAsset) {
+ c_profileAssets.add(profileAsset);
} else if (j_ea instanceof J_EAChargingSession chargingSession) {
if(p_chargingManagement == null){
f_addChargingManagement(OL_ChargingAttitude.SIMPLE);
@@ -606,7 +607,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
// Keep feedin power within connection capacity
if (fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < - v_liveConnectionMetaData.contractedFeedinCapacity_kW) { // overproduction!
for (J_EAProduction j_ea : c_productionAssets) {
- j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) - v_liveConnectionMetaData.contractedFeedinCapacity_kW, this);
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) - v_liveConnectionMetaData.contractedFeedinCapacity_kW);
+ f_removeFlows(flowPacket, j_ea);
if (!(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < - v_liveConnectionMetaData.contractedFeedinCapacity_kW)) {
break;
}
@@ -617,7 +619,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
if(energyModel.pp_dayAheadElectricityPricing_eurpMWh.getCurrentValue() < 0.0) {
if (fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < 0.0) { // Feedin, bring to zero!
for (J_EAProduction j_ea : c_productionAssets) {
- j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY), this);
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY));
+ f_removeFlows(flowPacket, j_ea);
if (!(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < 0.0)) {
break;
}
@@ -632,7 +635,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
double v_currentPowerElectricitySetpoint_kW = fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) * max(0,1+(p_parentNodeElectric.v_currentTotalNodalPrice_eurpkWh-priceTreshold_eur)*5);
for (J_EAProduction j_ea : c_productionAssets) {
- j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, v_currentPowerElectricitySetpoint_kW - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY), this);
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, v_currentPowerElectricitySetpoint_kW - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY));
+ f_removeFlows(flowPacket, j_ea);
if (!(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < v_currentPowerElectricitySetpoint_kW)) {
break;
}
@@ -703,37 +707,39 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
}
/*ALCODEEND*/}
-double f_removeFlows(J_FlowsMap flowsMap,double energyUse_kW,J_ValueMap assetFlowsMap_kW,J_EA caller)
+double f_removeFlows(J_FlowPacket flowPacket,J_EA caller)
{/*ALCODESTART::1722512642645*/
-for (OL_EnergyCarriers EC : flowsMap.keySet()) {
- fm_currentBalanceFlows_kW.addFlow(EC, -flowsMap.get(EC));
+for (OL_EnergyCarriers EC : flowPacket.flowsMap.keySet()) {
+ fm_currentBalanceFlows_kW.addFlow(EC, -flowPacket.flowsMap.get(EC));
- if (flowsMap.get(EC) < 0) {
- fm_currentProductionFlows_kW.addFlow(EC, flowsMap.get(EC));
+ if (flowPacket.flowsMap.get(EC) < 0) {
+ fm_currentProductionFlows_kW.addFlow(EC, flowPacket.flowsMap.get(EC));
}
- else if (flowsMap.get(EC) > 0){
- fm_currentConsumptionFlows_kW.addFlow(EC, -flowsMap.get(EC));
+ else if (flowPacket.flowsMap.get(EC) > 0){
+ fm_currentConsumptionFlows_kW.addFlow(EC, -flowPacket.flowsMap.get(EC));
}
}
if (caller instanceof J_EAStorageElectric) {
// Only allocate battery losses as consumption. Charging/discharging is neither production nor consumption. Do we need an element in flowsmap indicating power into storage??
- fm_currentConsumptionFlows_kW.addFlow(OL_EnergyCarriers.ELECTRICITY, max(0, energyUse_kW));
- v_currentFinalEnergyConsumption_kW += max(0, energyUse_kW);
+ fm_currentConsumptionFlows_kW.addFlow(OL_EnergyCarriers.ELECTRICITY, max(0, flowPacket.energyUse_kW));
+ v_currentFinalEnergyConsumption_kW += max(0, flowPacket.energyUse_kW);
} else {
- double curtailment_kW = max(0, -energyUse_kW);
- double lostLoad_kW = max(0, energyUse_kW);
+ double curtailment_kW = max(0, -flowPacket.energyUse_kW);
+ double lostLoad_kW = max(0, flowPacket.energyUse_kW);
v_currentEnergyCurtailed_kW += curtailment_kW;
v_currentPrimaryEnergyProduction_kW -= curtailment_kW;
v_currentFinalEnergyConsumption_kW -= lostLoad_kW;
}
if ( caller instanceof J_EAConversionHeatPump ) {
- v_currentPrimaryEnergyProductionHeatpumps_kW += energyUse_kW;
-}
-for(var AC : assetFlowsMap_kW.keySet()) {
- fm_currentAssetFlows_kW.addFlow(AC, -assetFlowsMap_kW.get(AC));
+ v_currentPrimaryEnergyProductionHeatpumps_kW += flowPacket.energyUse_kW;
}
+fm_currentAssetFlows_kW.removeFlows(flowPacket.assetFlowsMap);
+/*for(var AC : flowPacket.assetFlowsMap.keySet()) {
+ fm_currentAssetFlows_kW.addFlow(AC, -flowPacket.assetFlowsMap.get(AC));
+}*/
+
/*ALCODEEND*/}
double f_fillLiveDataSets(J_TimeVariables timeVariables)
diff --git a/_alp/Agents/GridConnection/Code/Functions.xml b/_alp/Agents/GridConnection/Code/Functions.xml
index c192289..cd685dd 100644
--- a/_alp/Agents/GridConnection/Code/Functions.xml
+++ b/_alp/Agents/GridConnection/Code/Functions.xml
@@ -412,16 +412,8 @@
true
true
-
-
-
-
-
-
-
-
-
- ]]>
+
+
diff --git a/_alp/Classes/Class.J_BatteryManagementPeakShavingForecast.java b/_alp/Classes/Class.J_BatteryManagementPeakShavingForecast.java
index 53ce76a..531b2d3 100644
--- a/_alp/Classes/Class.J_BatteryManagementPeakShavingForecast.java
+++ b/_alp/Classes/Class.J_BatteryManagementPeakShavingForecast.java
@@ -90,7 +90,8 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {
for(J_EAProfile elecConsumptionProfile : elecConsumptionProfiles) {
if(elecConsumptionProfile != null){
- double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecConsumptionProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecConsumptionProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
+ //double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecConsumptionProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecConsumptionProfile.getProfileScaling_fr()/p_timestep_h);
+ double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecConsumptionProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), elecConsumptionProfile.getProfileScaling_fr()*elecConsumptionProfile.getProfileUnitScaler_fr());
for (int i = 0; i < tempNettoBalance_kW.length; i++) {
nettoBalanceTotal_kW[i] += tempNettoBalance_kW[i];
}
@@ -98,7 +99,8 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {
}
for(J_EAProfile elecHeatPumpProfile : elecHeatPumpProfiles) {
if(elecHeatPumpProfile != null){
- double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecHeatPumpProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecHeatPumpProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
+ //double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecHeatPumpProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecHeatPumpProfile.getProfileScaling_fr()/p_timestep_h);
+ double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecHeatPumpProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), elecHeatPumpProfile.getProfileScaling_fr()*elecHeatPumpProfile.getProfileUnitScaler_fr());
for (int i = 0; i < tempNettoBalance_kW.length; i++) {
nettoBalanceTotal_kW[i] += tempNettoBalance_kW[i];
}
@@ -106,7 +108,7 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {
}
for(J_EAProfile elecEVProfile : elecEVProfiles) {
if(elecEVProfile != null){
- double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecEVProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecEVProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
+ double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecEVProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), elecEVProfile.getProfileScaling_fr()*elecEVProfile.getProfileUnitScaler_fr());
for (int i = 0; i < tempNettoBalance_kW.length; i++) {
nettoBalanceTotal_kW[i] += tempNettoBalance_kW[i];
}
@@ -114,7 +116,8 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {
}
for(J_EAProfile surveyHeatDemandProfile : surveyHeatDemandProfiles) {
if(surveyHeatDemandProfile != null){
- double[] heatPower_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(surveyHeatDemandProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), surveyHeatDemandProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
+ //double[] heatPower_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(surveyHeatDemandProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), surveyHeatDemandProfile.getProfileScaling_fr()/p_timestep_h);
+ double[] heatPower_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(surveyHeatDemandProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), surveyHeatDemandProfile.getProfileScaling_fr()*surveyHeatDemandProfile.getProfileUnitScaler_fr());
//traceln(heatPower_kW);
double eta_r = parentGC.energyModel.avgc_data.p_avgEfficiencyHeatpump_fr;
double outputTemperature_degC = parentGC.energyModel.avgc_data.p_avgOutputTemperatureElectricHeatpump_degC;
@@ -136,14 +139,14 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {
double COP_r = eta_r * ( 273.15 + outputTemperature_degC ) / ( outputTemperature_degC - baseTemperature_degC );
//traceln(genericHeatDemandProfile.getProfilePointer().getValue(time)*genericHeatDemandProfile.yearlyDemand_kWh);
- nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericHeatDemandProfile.getProfilePointer().getValue(time)*genericHeatDemandProfile.yearlyDemand_kWh*genericHeatDemandProfile.getConsumptionScaling_fr() / COP_r;
+ nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericHeatDemandProfile.getProfilePointer().getValue(time)*genericHeatDemandProfile.getBaseConsumption_kWh()*genericHeatDemandProfile.getConsumptionScaling_fr() / COP_r;
}
}
}
for(J_EAConsumption genericBuildingProfile : genericBuildingProfiles) {
if(genericBuildingProfile != null){ //table function
for(double time = energyModel_time_h; time < energyModel_time_h + 24; time += timeParameters.getTimeStep_h()){
- nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericBuildingProfile.getProfilePointer().getValue(time)*genericBuildingProfile.yearlyDemand_kWh*genericBuildingProfile.getConsumptionScaling_fr();
+ nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericBuildingProfile.getProfilePointer().getValue(time)*genericBuildingProfile.getBaseConsumption_kWh()*genericBuildingProfile.getConsumptionScaling_fr();
}
}
}
diff --git a/_alp/Classes/Class.J_EAConsumption.java b/_alp/Classes/Class.J_EAConsumption.java
index d24cbba..dccebc1 100644
--- a/_alp/Classes/Class.J_EAConsumption.java
+++ b/_alp/Classes/Class.J_EAConsumption.java
@@ -1,13 +1,10 @@
/**
* J_EAConsumption
*/
-public class J_EAConsumption extends zero_engine.J_EAFixed implements Serializable {
- protected J_ProfilePointer profilePointer;
- public double yearlyDemand_kWh;
- protected OL_EnergyCarriers energyCarrier;
- private double consumptionScaling_fr = 1;
- public double loadLoad_kWh = 0;
- //private J_profilePointer profilePointer;
+public class J_EAConsumption extends zero_engine.J_EAProfile implements Serializable {
+
+ private double yearlyDemand_kWh;
+ //public double loadLoad_kWh = 0;
/**
* Default constructor
*/
@@ -18,18 +15,25 @@ public J_EAConsumption() {
* Constructor initializing the fields
*/
public J_EAConsumption(I_AssetOwner owner, OL_EnergyAssetType type, String name, double yearlyDemand_kWh, OL_EnergyCarriers energyCarrier, J_TimeParameters timeParameters, J_ProfilePointer profile) {
- if (profile == null) {
- throw new RuntimeException("profile pointer for J_EAConsumption " + name + " is is null");
- }
+ /*if (yearlyDemand_kWh == 0.0) {
+ throw new RuntimeException("Unable to construct J_EAConsumption: " + name + " because consumption is zero." );
+ }*/
this.setOwner(owner);
- this.timeParameters = timeParameters;
-
+ this.timeParameters = timeParameters;
+
this.energyAssetName = name;
this.energyAssetType = type;
+
this.yearlyDemand_kWh = yearlyDemand_kWh;
+ if (profile.getProfileUnits() == OL_ProfileUnits.YEARLYTOTALFRACTION) {
+ this.profileUnitScaler_r = yearlyDemand_kWh;
+ this.profilePointer = profile;
+ } else {
+ throw new RuntimeException("Invalid OL_ProfileUnits type for J_EAConsumption!");
+ }
this.energyCarrier = energyCarrier;
- profilePointer = profile;
+
this.activeConsumptionEnergyCarriers.add(this.energyCarrier);
if (this.energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
@@ -51,38 +55,68 @@ else if (this.energyCarrier == OL_EnergyCarriers.HEAT) {
registerEnergyAsset(timeParameters);
}
+
+ public String getAssetName() {
+ return this.energyAssetName;
+ }
public void setConsumptionScaling_fr(double consumptionScaling_fr) {
- this.consumptionScaling_fr = consumptionScaling_fr;
+ this.profileScaling_fr = consumptionScaling_fr;
}
public double getConsumptionScaling_fr() {
- return this.consumptionScaling_fr;
+ return this.profileScaling_fr;
}
-
- @Override
- public void operate(J_TimeVariables timeVariables) {
+
+
+ /*@Override
+ public void f_updateAllFlows(double v_powerFraction_fr) {
+ throw new RuntimeException("J_EAConsumption.f_updateAllFlows() should be called without arguments!");
+ }
+
+ public void f_updateAllFlows() {
double ratioOfCapacity = profilePointer.getCurrentValue();
+ this.operate(ratioOfCapacity);
+ if (ratioOfCapacity>0.0) { // Skip when there is no consumption -> saves time?
+ if (parentAgent instanceof GridConnection) {
+ //((GridConnection)parentAgent).f_addFlows(arr, this);
+ ((GridConnection)parentAgent).f_addFlows(flowsMap, this.energyUse_kW, assetFlowsMap, this);
+ }
+
+ }
+ this.lastFlowsMap.cloneMap(this.flowsMap);
+ this.lastEnergyUse_kW = this.energyUse_kW;
+ this.clear();
+ }
+
+ @Override
+ public void operate(double ratioOfCapacity) {
double consumption_kW = ratioOfCapacity * this.yearlyDemand_kWh * this.consumptionScaling_fr;
this.energyUse_kW = consumption_kW;
- this.energyUsed_kWh += this.energyUse_kW * this.timeParameters.getTimeStep_h();
+ this.energyUsed_kWh += this.energyUse_kW * this.timestep_h;
flowsMap.put(this.energyCarrier, consumption_kW);
if (this.assetFlowCategory != null) {
assetFlowsMap.put(this.assetFlowCategory, consumption_kW);
}
- }
+ }*/
public J_ProfilePointer getProfilePointer() {
return this.profilePointer;
}
+ @Override
+ public double getBaseConsumption_kWh() {
+ return yearlyDemand_kWh;
+ }
+
@Override
public String toString() {
return
"type = " + this.getClass().toString() + " " +
+ "owner = " + this.getOwner() +" " +
"energyCarrier = " + this.energyCarrier + " " +
"yearlyDemand_kWh = " + this.yearlyDemand_kWh;
}
diff --git a/_alp/Classes/Class.J_EAPetroleumFuelTractor.java b/_alp/Classes/Class.J_EAPetroleumFuelTractor.java
index 2dd0853..2c967ee 100644
--- a/_alp/Classes/Class.J_EAPetroleumFuelTractor.java
+++ b/_alp/Classes/Class.J_EAPetroleumFuelTractor.java
@@ -44,6 +44,21 @@ public J_EAPetroleumFuelTractor(I_AssetOwner owner, double yearlyPetroleumFuelCo
registerEnergyAsset(timeParameters);
}
+ @Override
+ public J_FlowPacket f_updateAllFlows(J_TimeVariables timeVariables) {
+ this.operate(timeVariables);
+ if (this.assetFlowCategory != null) {
+ assetFlowsMap.put(this.assetFlowCategory, Math.abs(energyUse_kW));
+ }
+ J_FlowsMap flowsMapCopy = new J_FlowsMap();
+ J_ValueMap assetFlowsMapCopy = new J_ValueMap(OL_AssetFlowCategories.class);
+ J_FlowPacket flowPacket = new J_FlowPacket(flowsMapCopy.cloneMap(this.flowsMap), this.energyUse_kW, assetFlowsMapCopy.cloneMap(this.assetFlowsMap));
+ this.lastFlowsMap.cloneMap(this.flowsMap);
+ this.lastEnergyUse_kW = this.energyUse_kW;
+ this.clear();
+ return flowPacket;
+ }
+
@Override
public void operate(J_TimeVariables timeVariables) {
if (!shouldWork(timeVariables)) {
diff --git a/_alp/Classes/Class.J_EAProduction.java b/_alp/Classes/Class.J_EAProduction.java
index cd7ba0c..e5ce819 100644
--- a/_alp/Classes/Class.J_EAProduction.java
+++ b/_alp/Classes/Class.J_EAProduction.java
@@ -1,12 +1,12 @@
/**
* J_EAProduction
*/
-public class J_EAProduction extends zero_engine.J_EAFixed implements Serializable {
- protected J_ProfilePointer profilePointer;
- protected OL_EnergyCarriers energyCarrier = OL_EnergyCarriers.ELECTRICITY;
+public class J_EAProduction extends zero_engine.J_EAProfile implements Serializable {
+ //protected J_ProfilePointer profilePointer;
+ //protected OL_EnergyCarriers energyCarrier = OL_EnergyCarriers.ELECTRICITY;
protected double totalEnergyCurtailed_kWh=0;
//protected double outputTemperature_degC;
- protected double capacity_kW;
+ //protected double capacity_kW;
/**
* Default constructor
@@ -18,12 +18,20 @@ public J_EAProduction() {
* Constructor initializing the fields
*/
public J_EAProduction(I_AssetOwner owner, OL_EnergyAssetType type, String name, OL_EnergyCarriers energyCarrier, double capacity_kW, J_TimeParameters timeParameters, J_ProfilePointer profile) {
- if (profile == null) {
- throw new RuntimeException("profile pointer for J_EAProduction " + name + " is is null");
- }
this.setOwner(owner);
this.timeParameters = timeParameters;
this.energyAssetType = type;
+ this.energyAssetName = name;
+ this.energyCarrier = energyCarrier;
+ //this.capacity_kW = capacity_kW;
+ this.signScaler_r = -1.0;
+ if (profile.getProfileUnits() == OL_ProfileUnits.NORMALIZEDPOWER) {
+ this.profileUnitScaler_r = capacity_kW;
+ this.profilePointer = profile;
+ } else {
+ throw new RuntimeException("Invalid OL_ProfileUnits type for J_EAProduction!");
+ }
+
if (type == OL_EnergyAssetType.PHOTOVOLTAIC) {
this.assetFlowCategory = OL_AssetFlowCategories.pvProductionElectric_kW;
} else if (type == OL_EnergyAssetType.WINDMILL) {
@@ -35,11 +43,6 @@ public J_EAProduction(I_AssetOwner owner, OL_EnergyAssetType type, String name,
} else {
throw new RuntimeException("No valid OL_EnergyAssetType, cannot assign AssetFlowCategory!");
}
- this.energyAssetName = name;
- this.energyCarrier = energyCarrier;
- this.capacity_kW = capacity_kW;
-
- this.profilePointer = profile;
this.activeProductionEnergyCarriers.add(this.energyCarrier);
registerEnergyAsset(timeParameters);
@@ -48,7 +51,7 @@ public J_EAProduction(I_AssetOwner owner, OL_EnergyAssetType type, String name,
public void setCapacityElectric_kW(double capacityElectric_kW, GridConnection gc) {
// Calculate the difference with the set and the previous capacity to update totals in GC, GN and EnergyModel
if (energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
- double difference_kW = capacityElectric_kW - this.capacity_kW;
+ double difference_kW = capacityElectric_kW - this.profileUnitScaler_r;
if (this.energyAssetType == OL_EnergyAssetType.WINDMILL) {
gc.v_liveAssetsMetaData.totalInstalledWindPower_kW += difference_kW;
if (gc.p_parentNodeElectric != null) {
@@ -66,7 +69,8 @@ else if (this.energyAssetType == OL_EnergyAssetType.PHOTOVOLTAIC) {
gc.energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW += difference_kW;
}
- this.capacity_kW = capacityElectric_kW;
+ this.profileUnitScaler_r = capacityElectric_kW;
+
} else {
throw new RuntimeException("Production assets energy carrier is not electricity!");
}
@@ -74,7 +78,7 @@ else if (this.energyAssetType == OL_EnergyAssetType.PHOTOVOLTAIC) {
public double getCapacityElectric_kW() {
if (energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
- return this.capacity_kW;
+ return this.profileUnitScaler_r;
} else {
throw new RuntimeException("J_EAProduction is not electric!");
}
@@ -82,7 +86,7 @@ public double getCapacityElectric_kW() {
public double getCapacityHeat_kW() {
if (energyCarrier == OL_EnergyCarriers.HEAT) {
- return capacity_kW;
+ return profileUnitScaler_r;
} else {
throw new RuntimeException("J_EAProduction is not thermal!");
}
@@ -93,52 +97,60 @@ public String getName() {
}
@Override
- public void operate(J_TimeVariables timeVariables) {
- double powerFraction_fr = profilePointer.getCurrentValue();
+ public void operate(J_TimeVariables timeVariables) {
+ /*
+ ratioOfCapacity = profilePointer.getCurrentValue();
//if (ratioOfCapacity>0.0) { // Skip when there is no production -> saves time?
- double currentProduction_kW = powerFraction_fr * this.capacity_kW;
+ double currentProduction_kW = ratioOfCapacity * this.capacity_kW;
this.energyUse_kW = -currentProduction_kW;
- this.energyUsed_kWh += this.energyUse_kW * this.timeParameters.getTimeStep_h();
+ this.energyUsed_kWh += this.energyUse_kW * this.timestep_h;
this.flowsMap.put(this.energyCarrier, -currentProduction_kW);
this.assetFlowsMap.put(this.assetFlowCategory, currentProduction_kW);
//}
throw new RuntimeException("J_EAProduction operate override is called!");
+ */
+ }
+
+ /*
+ @Override
+ public void f_updateAllFlows(double v_powerFraction_fr) {
+ throw new RuntimeException("J_EAProduction.f_updateAllFlows() should be called without arguments!");
}
- public J_FlowPacket f_updateAllFlows(J_TimeVariables timeVariables) {
+ public void f_updateAllFlows() {
double ratioOfCapacity = profilePointer.getCurrentValue();
if (ratioOfCapacity>0.0) { // Skip when there is no production -> saves time?
double currentProduction_kW = ratioOfCapacity * this.capacity_kW;
this.energyUse_kW = -currentProduction_kW;
- this.energyUsed_kWh += this.energyUse_kW * this.timeParameters.getTimeStep_h();
+ this.energyUsed_kWh += this.energyUse_kW * this.timestep_h;
this.flowsMap.put(this.energyCarrier, -currentProduction_kW);
this.assetFlowsMap.put(this.assetFlowCategory, currentProduction_kW);
+ if (parentAgent instanceof GridConnection) {
+ //((GridConnection)parentAgent).f_addFlows(arr, this);
+ ((GridConnection)parentAgent).f_addFlows(flowsMap, this.energyUse_kW, assetFlowsMap, this);
+ }
+
}
- J_FlowsMap flowsMapCopy = new J_FlowsMap();
- J_ValueMap assetFlowsMapCopy = new J_ValueMap(OL_AssetFlowCategories.class);
- J_FlowPacket flowPacket = new J_FlowPacket(flowsMapCopy.cloneMap(this.flowsMap), this.energyUse_kW, assetFlowsMapCopy.cloneMap(this.assetFlowsMap));
this.lastFlowsMap.cloneMap(this.flowsMap);
this.lastEnergyUse_kW = this.energyUse_kW;
this.clear();
- return flowPacket;
-
- }
+ }*/
- public double curtailEnergyCarrierProduction(OL_EnergyCarriers curtailedEnergyCarrier, double curtailmentAmount_kW, GridConnection gc) { // The curtailment setpoint is the requested amount of curtailment; requested reduction of production. (which may or may not be provided, depending on what the current production is)
+ public J_FlowPacket curtailEnergyCarrierProduction(OL_EnergyCarriers curtailedEnergyCarrier, double curtailmentAmount_kW) { // The curtailment setpoint is the requested amount of curtailment; requested reduction of production. (which may or may not be provided, depending on what the current production is)
- if(this.energyCarrier != curtailedEnergyCarrier) {
+ /*if(this.energyCarrier != curtailedEnergyCarrier) {
//new RuntimeException("Trying to curtail the wrong a production asset with the wrong energyCarrier");
return 0;
- }
+ }*/
- double currentProduction_kW = -this.lastFlowsMap.get(curtailedEnergyCarrier);
+ double currentProduction_kW = max(0,-this.lastFlowsMap.get(curtailedEnergyCarrier));
double curtailmentPower_kW = max(0,min(currentProduction_kW, curtailmentAmount_kW)); // Can only curtail what was produced in the first place.
- energyUsed_kWh += curtailmentPower_kW * timeParameters.getTimeStep_h(); // energyUsed_kWh is negative for production assets. Curtailment makes it 'less negative', so a positive number is added to energyUsed_kWh.
- this.totalEnergyCurtailed_kWh += curtailmentPower_kW * timeParameters.getTimeStep_h();
+ energyUsed_kWh += curtailmentPower_kW * this.timeParameters.getTimeStep_h(); // energyUsed_kWh is negative for production assets. Curtailment makes it 'less negative', so a positive number is added to energyUsed_kWh.
+ this.totalEnergyCurtailed_kWh += curtailmentPower_kW * this.timeParameters.getTimeStep_h();
J_FlowsMap curtailmentFlow = new J_FlowsMap();
curtailmentFlow.put(curtailedEnergyCarrier, -curtailmentPower_kW); // To remove production, a negative flow must be removed. Thus this flowmap with a negative flow will be sent to GC.f_removeFlows()
J_ValueMap assetFlows_kW = new J_ValueMap(OL_AssetFlowCategories.class);
@@ -147,11 +159,9 @@ public J_FlowPacket f_updateAllFlows(J_TimeVariables timeVariables) {
this.lastFlowsMap.addFlow(curtailedEnergyCarrier, curtailmentPower_kW); // production is a negative flow, so to remove production, a positive value must be added to lastFlows.
this.lastEnergyUse_kW += curtailmentPower_kW; // production is a negative flow, so to remove production, a positive value must be added to lastEnergyUse_kW.
- //traceln("Electricity production of asset %s curtailed by %s kW!", this, curtailmentPower_kW);
- gc.f_removeFlows(curtailmentFlow, curtailedEnergyUse_kW, assetFlows_kW, this);
- clear();
-
- return curtailmentPower_kW;
+ //gc.f_removeFlows(curtailmentFlow, curtailedEnergyUse_kW, assetFlows_kW, this);
+ J_FlowPacket flowPacket = new J_FlowPacket(curtailmentFlow, curtailedEnergyUse_kW, assetFlows_kW);
+ return flowPacket;
}
public double getEnergyCurtailed_kWh() {
@@ -172,15 +182,14 @@ public void storeStatesAndReset() {
public String toString() {
return
"type = " + this.getClass().toString() + " " +
- "capacity_kW = " + capacity_kW +" "+
+ "owner = " + this.getOwner() +" " +
+ "capacity_kW = " + profileUnitScaler_r +" "+
"energyCarrier = " + energyCarrier +" "+
+ "assetFlowCategory = " + this.assetFlowCategory + " " +
"energyProduced_kWh = " + (-this.energyUsed_kWh) + " ";
}
- //public String getOwnerAgent() {
- //return parentAgent.agentInfo();
- //}
-
+
/*public double getCurrentTemperature() {
return outputTemperature_degC;
}*/
diff --git a/_alp/Classes/Class.J_EAProfile.java b/_alp/Classes/Class.J_EAProfile.java
index b1884eb..5766677 100644
--- a/_alp/Classes/Class.J_EAProfile.java
+++ b/_alp/Classes/Class.J_EAProfile.java
@@ -1,16 +1,15 @@
+import zeroPackage.ZeroMath;
/**
* J_EAProfile
*/
public class J_EAProfile extends zero_engine.J_EAFixed implements Serializable {
+ protected J_ProfilePointer profilePointer;
+ protected double profileUnitScaler_r = 4.0; // This factor translates tablefunction data in kWh/qh, normalized power or consumption-fraction into power [kW]. To go from kWh/qh to kW, that is a factor 4.
+ protected OL_EnergyCarriers energyCarrier; // = OL_EnergyCarriers.ELECTRICITY;
+ protected double lostLoad_kWh = 0;
+ protected double profileScaling_fr = 1.0; // This factor can be used to change the magnitude of the profile in this asset, for example when an energy-saving slider is operated.
+ protected double signScaler_r = 1.0;
- public OL_EnergyCarriers energyCarrier = OL_EnergyCarriers.ELECTRICITY;
- public double[] a_energyProfile_kWh;
- private double profileTimestep_h;
- private double profileStarTime_h = 0;
- public double lostLoad_kWh = 0;
- private double profileScaling_fr = 1;
- private boolean enableProfileLooping = true;
-
/**
* Default constructor
*/
@@ -20,72 +19,122 @@ public J_EAProfile() {
/**
* Constructor initializing the fields
*/
- public J_EAProfile(I_AssetOwner owner, OL_EnergyCarriers energyCarrier, double[] profile_kWh, OL_AssetFlowCategories assetCategory, double profileTimestep_h, J_TimeParameters timeParameters) {
- this.setOwner(owner);
- this.timeParameters = timeParameters;
+
+ public J_EAProfile(I_AssetOwner owner, OL_EnergyCarriers energyCarrier, J_ProfilePointer profile, OL_AssetFlowCategories assetCategory, J_TimeParameters timeParameters) {
+ this.setOwner(owner);
+ this.timeParameters = timeParameters;
this.energyCarrier = energyCarrier;
- this.a_energyProfile_kWh = profile_kWh;
- //this.profileType = profileType;
- this.profileTimestep_h = profileTimestep_h;
- this.assetFlowCategory = assetCategory;
+ if (profile == null) {
+ throw new RuntimeException("Cannot create J_EAProfile without a valid ProfilePointer!");
+ } else {
+ profilePointer = profile;
+ if (profilePointer.getProfileUnits() == OL_ProfileUnits.KWHPQUARTERHOUR) {
+ profileUnitScaler_r = 4.0;
+ } else if (profilePointer.getProfileUnits() == OL_ProfileUnits.KW) {
+ profileUnitScaler_r = 1.0;
+ } else {
+ throw new RuntimeException("Unsupported ProfileUnits of profilePointer for J_EAProfile!");
+ }
+ }
+ this.assetFlowCategory = assetCategory;
+
this.activeConsumptionEnergyCarriers.add(this.energyCarrier);
+
registerEnergyAsset(timeParameters);
}
-
- public void setStartTime_h(double startTime_h) {
- this.profileStarTime_h = startTime_h;
- }
-
- @Override
- public void operate(J_TimeVariables timeVariables) {
- double time_h = timeVariables.getT_h()-this.profileStarTime_h;
- if (enableProfileLooping && time_h >= a_energyProfile_kWh.length * profileTimestep_h) {
- time_h = time_h % a_energyProfile_kWh.length * profileTimestep_h;
- } else if ( (int)floor(time_h/profileTimestep_h) >= a_energyProfile_kWh.length ) {
- traceln("Time out of upper bound for evaluating J_EAProfile power in profile asset %s!", this.energyAssetName);
-// time_h = a_energyProfile_kWh.length * profileTimestep_h - 1;
- throw new RuntimeException(String.format("Time out of upper bound for evaluating J_EAProfile power! Time is: %s", time_h));
- }
- if ( time_h < 0 ) {
- traceln("Time out of lower bound for evaluating J_EAProfile power in profile asset %s!", this.energyAssetName);
- throw new RuntimeException(String.format("Time out of lower bound for evaluating J_EAProfile power! Time is: %s", time_h));
- }
-
- double currentPower_kW = this.profileScaling_fr * this.a_energyProfile_kWh[(int)floor(time_h/profileTimestep_h)]/profileTimestep_h;
+
+ public J_FlowPacket f_updateAllFlows(J_TimeVariables timeVariables) {
+ double profileValue = profilePointer.getCurrentValue();
+ double currentPower_kW = profileValue * this.profileUnitScaler_r * this.profileScaling_fr * this.signScaler_r;
+
this.energyUse_kW = currentPower_kW;
- this.energyUsed_kWh += timeParameters.getTimeStep_h() * energyUse_kW;
- this.flowsMap.put(this.energyCarrier, currentPower_kW);
+ this.energyUsed_kWh += this.energyUse_kW * this.timeParameters.getTimeStep_h();
+
+ flowsMap.put(this.energyCarrier, currentPower_kW);
if (this.assetFlowCategory != null) {
- this.assetFlowsMap.put(this.assetFlowCategory, currentPower_kW);
+ assetFlowsMap.put(this.assetFlowCategory, Math.abs(currentPower_kW));
}
+ J_FlowsMap flowsMapCopy = new J_FlowsMap();
+ J_ValueMap assetFlowsMapCopy = new J_ValueMap(OL_AssetFlowCategories.class);
+ J_FlowPacket flowPacket = new J_FlowPacket(flowsMapCopy.cloneMap(this.flowsMap), this.energyUse_kW, assetFlowsMapCopy.cloneMap(this.assetFlowsMap));
+ this.lastFlowsMap.cloneMap(this.flowsMap);
+ this.lastEnergyUse_kW = this.energyUse_kW;
+ this.clear();
+ return flowPacket;
}
+
+ @Override
+ public void operate(J_TimeVariables timeVariables) {
+ throw new RuntimeException("J_EAProfile method operate() is not used!");
+ }
+
- public void curtailElectricityConsumption(double curtailmentSetpoint_kW, GridConnection gc) {
- double currentElectricityConsumption_kW = this.lastFlowsMap.get(OL_EnergyCarriers.ELECTRICITY);
+ public J_FlowPacket curtailElectricityConsumption(double curtailmentSetpoint_kW) {
+ double currentElectricityConsumption_kW = max(0,this.lastFlowsMap.get(OL_EnergyCarriers.ELECTRICITY));
double curtailmentPower_kW = max(0,min(currentElectricityConsumption_kW, curtailmentSetpoint_kW));
- energyUsed_kWh -= curtailmentPower_kW * timeParameters.getTimeStep_h();
- lostLoad_kWh += curtailmentPower_kW * timeParameters.getTimeStep_h();
+ energyUsed_kWh -= curtailmentPower_kW * this.timeParameters.getTimeStep_h();
+ lostLoad_kWh += curtailmentPower_kW * this.timeParameters.getTimeStep_h();
J_FlowsMap flowsMap = new J_FlowsMap();
flowsMap.put(OL_EnergyCarriers.ELECTRICITY, curtailmentPower_kW);
J_ValueMap assetFlows_kW = new J_ValueMap(OL_AssetFlowCategories.class);
assetFlows_kW.put(this.assetFlowCategory, curtailmentPower_kW);
- this.energyUse_kW = -curtailmentPower_kW;
-
this.lastFlowsMap.put(OL_EnergyCarriers.ELECTRICITY, this.lastFlowsMap.get(OL_EnergyCarriers.ELECTRICITY) - curtailmentPower_kW);
this.lastEnergyUse_kW -= curtailmentPower_kW;
- gc.f_removeFlows(flowsMap, this.energyUse_kW, assetFlows_kW, this);
+ //gc.f_removeFlows(flowsMap, this.energyUse_kW, assetFlows_kW, this);
+ J_FlowPacket flowPacket = new J_FlowPacket(flowsMap, curtailmentPower_kW, assetFlows_kW);
+ return flowPacket;
+
+ }
+
+ public J_ProfilePointer getProfilePointer() {
+ return this.profilePointer;
}
-
+
+ public double getProfileUnitScaler_fr() {
+ return this.profileUnitScaler_r;
+ }
+
public double getProfileScaling_fr() {
- return profileScaling_fr;
+ return this.profileScaling_fr;
}
public void setProfileScaling_fr( double scaling_fr ) {
this.profileScaling_fr = scaling_fr;
}
+ public double getPeakConsumptionPower_kW() {
+ if (this.signScaler_r < 0) {
+ return 0.0;
+ } else {
+ return max(profilePointer.getAllValues()) * this.profileUnitScaler_r * this.profileScaling_fr;
+ }
+ }
+
+ public double getPeakProductionPower_kW() {
+ if (this.signScaler_r > 0) {
+ return 0.0;
+ } else {
+ return max(profilePointer.getAllValues()) * this.profileUnitScaler_r * this.profileScaling_fr;
+ }
+ }
+
+ public double getBaseConsumption_kWh() {
+ if (this.signScaler_r < 0) {
+ return 0.0;
+ } else {
+ double[] values = profilePointer.getAllValues();
+ double dataTimeStep_h = profilePointer.getDataTimeStep_h();
+ double baseConsumption_kWh = ZeroMath.arraySumPos(values) * dataTimeStep_h * this.profileUnitScaler_r;
+ return baseConsumption_kWh;
+ }
+ }
+
+ public double getTotalConsumption_kWh() {
+ return this.getBaseConsumption_kWh() * this.profileScaling_fr;
+ }
+
public OL_EnergyCarriers getEnergyCarrier() {
return this.energyCarrier;
}
@@ -93,7 +142,13 @@ public OL_EnergyCarriers getEnergyCarrier() {
@Override
public String toString() {
return
- "Energy consumed = " + this.energyUsed_kWh +
- "energyUsed_kWh (losses) = " + this.energyUsed_kWh + " ";
+ "owner = " + this.getOwner() +", Energy consumed = " + this.energyUsed_kWh +
+ "assetFlowCategory = " + this.assetFlowCategory + " ";
}
+
+ /**
+ * This number is here for model snapshot storing purpose
+ * It needs to be changed when this class gets changed
+ */
+ private static final long serialVersionUID = 1L;
}
diff --git a/_alp/Classes/Class.J_FlowsMap.java b/_alp/Classes/Class.J_FlowsMap.java
index 089050d..e160e61 100644
--- a/_alp/Classes/Class.J_FlowsMap.java
+++ b/_alp/Classes/Class.J_FlowsMap.java
@@ -53,6 +53,16 @@ public final J_FlowsMap addFlows( J_FlowsMap f) {
return this;
}
+ public final J_FlowsMap removeFlows( J_FlowsMap f) {
+ int len = valuesArray.length;
+ for(int i=0; i 0) {
if (remainingPTProduction_kW > 0) {//Heat (for now always curtail over produced heat!)
for (J_EAProduction j_ea : ptAssets) {
- remainingPTProduction_kW -= j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW, gc);
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW);
+ gc.f_removeFlows(flowPacket, j_ea);
+ remainingPTProduction_kW += flowPacket.energyUse_kW; // Curtailed energyUse_kW will be a negative number when curtailing a production asset, hence the += !
if (remainingPTProduction_kW <= 0) {
break;
diff --git a/_alp/Classes/Class.J_HeatingManagementBuildingHybridHeatPump.java b/_alp/Classes/Class.J_HeatingManagementBuildingHybridHeatPump.java
index 56b41b0..3633c9b 100644
--- a/_alp/Classes/Class.J_HeatingManagementBuildingHybridHeatPump.java
+++ b/_alp/Classes/Class.J_HeatingManagementBuildingHybridHeatPump.java
@@ -120,8 +120,9 @@ else if(remainingPTProduction_kW > 0) {
remainingPTProduction_kW = max(0, remainingPTProduction_kW - heatBufferCharge_kW);
if (remainingPTProduction_kW > 0) {//Heat (for now always curtail over produced heat!)
for (J_EAProduction j_ea : ptAssets) {
- remainingPTProduction_kW -= j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW, gc);
-
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW);
+ gc.f_removeFlows(flowPacket, j_ea);
+ remainingPTProduction_kW += flowPacket.energyUse_kW;
if (remainingPTProduction_kW <= 0) {
break;
}
diff --git a/_alp/Classes/Class.J_HeatingManagementBuildingWithPTBufferSimple.java b/_alp/Classes/Class.J_HeatingManagementBuildingWithPTBufferSimple.java
index 108d614..ef16c55 100644
--- a/_alp/Classes/Class.J_HeatingManagementBuildingWithPTBufferSimple.java
+++ b/_alp/Classes/Class.J_HeatingManagementBuildingWithPTBufferSimple.java
@@ -81,8 +81,10 @@ else if(remainingPTProduction_kW > 0) {
remainingPTProduction_kW = max(0, remainingPTProduction_kW - heatBufferCharge_kW);
if (remainingPTProduction_kW > 0) {//Heat (for now always curtail over produced heat!)
for (J_EAProduction j_ea : ptAssets) {
- remainingPTProduction_kW -= j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW);
-
+
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW);
+ gc.f_removeFlows(flowPacket, j_ea);
+ remainingPTProduction_kW += flowPacket.energyUse_kW;
if (remainingPTProduction_kW <= 0) {
break;
}
diff --git a/_alp/Classes/Class.J_HeatingManagementProfileWithPTBufferSimple.java b/_alp/Classes/Class.J_HeatingManagementProfileWithPTBufferSimple.java
index 90e36c1..78ce4d4 100644
--- a/_alp/Classes/Class.J_HeatingManagementProfileWithPTBufferSimple.java
+++ b/_alp/Classes/Class.J_HeatingManagementProfileWithPTBufferSimple.java
@@ -81,8 +81,9 @@ else if(remainingPTProduction_kW > 0) {
remainingPTProduction_kW = max(0, remainingPTProduction_kW - heatBufferCharge_kW);
if (remainingPTProduction_kW > 0) {//Heat (for now always curtail over produced heat!)
for (J_EAProduction j_ea : ptAssets) {
- remainingPTProduction_kW -= j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW);
-
+ J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction( OL_EnergyCarriers.HEAT, remainingPTProduction_kW);
+ gc.f_removeFlows(flowPacket, j_ea);
+ remainingPTProduction_kW += flowPacket.energyUse_kW;
if (remainingPTProduction_kW <= 0) {
break;
}
diff --git a/_alp/Classes/Class.J_ProfilePointer.java b/_alp/Classes/Class.J_ProfilePointer.java
index f17da14..ea0003f 100644
--- a/_alp/Classes/Class.J_ProfilePointer.java
+++ b/_alp/Classes/Class.J_ProfilePointer.java
@@ -7,7 +7,7 @@
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@JsonAutoDetect(
- fieldVisibility = Visibility.PROTECTED_AND_PUBLIC, // ✅ only public fields are serialized
+ fieldVisibility = Visibility.ANY, // also stores full profiles to file. Maybe arrange a way to 'skip' this?
getterVisibility = Visibility.NONE,
isGetterVisibility = Visibility.NONE,
setterVisibility = Visibility.NONE,
@@ -18,7 +18,13 @@
public class J_ProfilePointer implements Serializable {
public String name = "";
private double currentValue = 0;
- private TableFunction tableFunction;
+ private OL_ProfileUnits profileUnits;
+
+ // Using internal array instead of tableFunction
+ private double[] a_profile;
+ private double dataTimeStep_h;
+ private double dataStartTime_h; // relative to 00:00h on jan 1st of simulation year
+ private boolean enableProfileLooping = true;
/**
* Default constructor
@@ -27,33 +33,54 @@ public J_ProfilePointer() {
}
- public J_ProfilePointer(String name, TableFunction tableFunction) {
+ public J_ProfilePointer(String name, double[] profile, double dataTimeStep_h, double dataStartTime_h, OL_ProfileUnits profileUnits) {
+ if (profileUnits == null) {
+ throw new RuntimeException("Attemtping to create J_ProfilePointer with null profileUnits!");
+ }
this.name = name;
- this.tableFunction = tableFunction;
+ this.a_profile = profile;
+ this.dataTimeStep_h = dataTimeStep_h;
+ this.dataStartTime_h = dataStartTime_h;
+ this.profileUnits = profileUnits;
}
public void updateValue(double t_h) {
- this.currentValue = this.tableFunction.get(t_h);
+ this.currentValue = this.getValue(t_h);
}
public double getCurrentValue() {
return this.currentValue;
}
- public double getValue(double t_h) {
- return this.tableFunction.get(t_h);
+ public double getValue(double time_h) {
+ //return this.tableFunction.get(t_h);
+ int index_n = (int)((time_h-dataStartTime_h)/dataTimeStep_h);
+ if (enableProfileLooping && index_n >= a_profile.length) {
+ index_n = index_n % a_profile.length;
+ } else if ( index_n >= a_profile.length ) {
+ traceln("Time out of upper bound for evaluating J_EAProfile power in profile %s!", this.name);
+// time_h = a_energyProfile_kWh.length * profileTimestep_h - 1;
+ throw new RuntimeException(String.format("Time out of upper bound for evaluating J_EAProfile power! Time is: %s", time_h));
+ }
+ if ( index_n < 0 ) {
+ traceln("Time out of lower bound for evaluating J_EAProfile power in profile %s!", this.name);
+ throw new RuntimeException(String.format("Time out of lower bound for evaluating J_EAProfile power! Time is: %s", time_h));
+ }
+ double currentValue_kW = this.a_profile[index_n];
+ return currentValue_kW;
}
-
+
public double[] getAllValues() {
- return this.tableFunction.getValues();
+ //return this.tableFunction.getValues();
+ return this.a_profile;
}
- public TableFunction getTableFunction() {
- return tableFunction;
+ public double getDataTimeStep_h() {
+ return dataTimeStep_h;
}
- public void setTableFunction(TableFunction tf) {
- this.tableFunction = tf;
+ public OL_ProfileUnits getProfileUnits() {
+ return profileUnits;
}
@Override
@@ -61,10 +88,4 @@ public String toString() {
return "profile: " + this.name + " current value: " + this.currentValue;
}
- /**
- * This number is here for model snapshot storing purpose
- * It needs to be changed when this class gets changed
- */
- private static final long serialVersionUID = 1L;
-
}
\ No newline at end of file
diff --git a/_alp/Classes/Class.J_ValueMap.java b/_alp/Classes/Class.J_ValueMap.java
index 03c2856..5220072 100644
--- a/_alp/Classes/Class.J_ValueMap.java
+++ b/_alp/Classes/Class.J_ValueMap.java
@@ -50,6 +50,16 @@ public final J_ValueMap addFlows( J_ValueMap f) {
return this;
}
+ public final J_ValueMap removeFlows( J_ValueMap f) {
+ int len = valuesArray.length;
+ for(int i=0; i