From b36d552e80c99648c9432598d85a7e6948869e30 Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Mon, 21 Jul 2025 17:00:13 +0200 Subject: [PATCH 01/16] Interface & Default Implementations - New interface I_ManageHeating that has a method manageHeating() that operates the assets and function(s) initialize to check if the combination is valid - A couple standard implementations of the interface such as J_HeatingManagementBuildingSimple - Cleanup of f_connectToJ_EA and f_removeTheJ_EA functions. No longer parameters for primary, secondary ... etc. Just one collection --- Zero_engine.alpx | 20 +++ _alp/Agents/EnergyModel/Code/Functions.java | 2 +- _alp/Agents/EnergyModel/EmbeddedObjects.xml | 120 ++++------------ .../AOC.GCDistrictHeating.xml | 12 +- .../GCDistrictHeating/Code/Functions.java | 1 - _alp/Agents/GCDistrictHeating/Variables.xml | 1 + .../AOC.GCEnergyConversion.xml | 12 +- .../AOC.GCEnergyProduction.xml | 12 +- .../GCGridBattery/AOC.GCGridBattery.xml | 12 +- _alp/Agents/GCHouse/AOC.GCHouse.xml | 12 +- .../GCHouse/Code/AdditionalClassCode.java | 5 - _alp/Agents/GCHouse/Code/Functions.java | 17 +-- _alp/Agents/GCHouse/Code/Functions.xml | 9 ++ _alp/Agents/GCIndustry/AOC.GCIndustry.xml | 13 +- .../GCNeighborhood/AOC.GCNeighborhood.xml | 12 +- .../Code/AdditionalClassCode.java | 2 +- _alp/Agents/GCNeighborhood/Code/Functions.xml | 10 +- .../GCPublicCharger/AOC.GCPublicCharger.xml | 12 +- _alp/Agents/GCUtility/AOC.GCUtility.xml | 12 +- _alp/Agents/GCUtility/Code/Functions.java | 2 +- .../Agents/GridConnection/Code/Functions.java | 82 +++++------ _alp/Agents/GridConnection/Code/Functions.xml | 19 ++- _alp/Agents/GridConnection/Variables.xml | 128 ++++++------------ _alp/Classes/Class.I_HeatingManagement.java | 8 ++ _alp/Classes/Class.J_EA.java | 16 --- .../Classes/Class.J_EAConversionHeatPump.java | 10 -- _alp/Classes/Class.J_EAStorageHeat.java | 3 - ...ass.J_HeatingManagementBuildingSimple.java | 112 +++++++++++++++ ...ss.J_HeatingManagementDistrictHeating.java | 70 ++++++++++ ...ass.J_HeatingManagementHybridHeatPump.java | 106 +++++++++++++++ ...lass.J_HeatingManagementProfileSimple.java | 63 +++++++++ 31 files changed, 569 insertions(+), 346 deletions(-) create mode 100644 _alp/Classes/Class.I_HeatingManagement.java create mode 100644 _alp/Classes/Class.J_HeatingManagementBuildingSimple.java create mode 100644 _alp/Classes/Class.J_HeatingManagementDistrictHeating.java create mode 100644 _alp/Classes/Class.J_HeatingManagementHybridHeatPump.java create mode 100644 _alp/Classes/Class.J_HeatingManagementProfileSimple.java diff --git a/Zero_engine.alpx b/Zero_engine.alpx index b5e55d46..cb654673 100644 --- a/Zero_engine.alpx +++ b/Zero_engine.alpx @@ -1611,6 +1611,26 @@ 1749651263461 + + 1753088272170 + + + + 1753088398654 + + + + 1753090559114 + + + + 1753100278618 + + + + 1753102129145 + + com.anylogic.libraries.modules.markup_descriptors diff --git a/_alp/Agents/EnergyModel/Code/Functions.java b/_alp/Agents/EnergyModel/Code/Functions.java index b8e98adc..5f697bb7 100644 --- a/_alp/Agents/EnergyModel/Code/Functions.java +++ b/_alp/Agents/EnergyModel/Code/Functions.java @@ -229,7 +229,7 @@ v_currentEnergyCurtailed_kW += gc.v_currentEnergyCurtailed_kW; v_currentPrimaryEnergyProductionHeatpumps_kW += gc.v_currentPrimaryEnergyProductionHeatpumps_kW; } -} +} else { for(GridConnection gc : c_gridConnections) { gc.f_calculateEnergyBalance(); diff --git a/_alp/Agents/EnergyModel/EmbeddedObjects.xml b/_alp/Agents/EnergyModel/EmbeddedObjects.xml index 9395f603..8f7d6599 100644 --- a/_alp/Agents/EnergyModel/EmbeddedObjects.xml +++ b/_alp/Agents/EnergyModel/EmbeddedObjects.xml @@ -163,15 +163,9 @@ - - - - - - @@ -232,9 +226,6 @@ - - - @@ -244,6 +235,9 @@ + + + true @@ -1028,15 +1022,9 @@ - - - - - - @@ -1130,9 +1118,6 @@ - - - @@ -1151,6 +1136,9 @@ + + + true @@ -1223,15 +1211,9 @@ - - - - - - @@ -1292,9 +1274,6 @@ - - - @@ -1310,6 +1289,9 @@ + + + true @@ -1382,15 +1364,9 @@ - - - - - - @@ -1451,9 +1427,6 @@ - - - @@ -1466,6 +1439,9 @@ + + + true @@ -1541,15 +1517,9 @@ - - - - - - @@ -1649,9 +1619,6 @@ - - - @@ -1661,6 +1628,9 @@ + + + true @@ -1736,15 +1706,9 @@ - - - - - - @@ -1802,9 +1766,6 @@ - - - @@ -1814,6 +1775,9 @@ + + + true @@ -1886,15 +1850,9 @@ - - - - - - @@ -1955,9 +1913,6 @@ - - - @@ -1967,6 +1922,9 @@ + + + true @@ -2039,15 +1997,9 @@ - - - - - - @@ -2108,9 +2060,6 @@ - - - @@ -2123,6 +2072,9 @@ + + + true @@ -2513,15 +2465,9 @@ - - - - - - @@ -2591,9 +2537,6 @@ - - - @@ -2627,6 +2570,9 @@ + + + true @@ -2703,15 +2649,9 @@ - - - - - - @@ -2769,9 +2709,6 @@ - - - @@ -2814,6 +2751,9 @@ + + + true diff --git a/_alp/Agents/GCDistrictHeating/AOC.GCDistrictHeating.xml b/_alp/Agents/GCDistrictHeating/AOC.GCDistrictHeating.xml index d511d5d4..97ba1bed 100644 --- a/_alp/Agents/GCDistrictHeating/AOC.GCDistrictHeating.xml +++ b/_alp/Agents/GCDistrictHeating/AOC.GCDistrictHeating.xml @@ -23,15 +23,9 @@ - - - - - - @@ -92,9 +86,6 @@ - - - @@ -104,6 +95,9 @@ + + + false diff --git a/_alp/Agents/GCDistrictHeating/Code/Functions.java b/_alp/Agents/GCDistrictHeating/Code/Functions.java index 0220f17f..12b1b4f9 100644 --- a/_alp/Agents/GCDistrictHeating/Code/Functions.java +++ b/_alp/Agents/GCDistrictHeating/Code/Functions.java @@ -332,7 +332,6 @@ else if ( p_BuildingThermalAsset.getCurrentTemperature() < p_BuildingThermalAsse //} } else if (j_ea instanceof J_EAStorageHeat ) { p_DHheatStorage = (J_EAStorageHeat)j_ea; - energyModel.c_storageAssets.add((J_EAStorage)j_ea); } else { traceln("f_connectToChild in EnergyAsset: Exception! EnergyAsset " + j_ea + " is of unknown type or null! "); } diff --git a/_alp/Agents/GCDistrictHeating/Variables.xml b/_alp/Agents/GCDistrictHeating/Variables.xml index c594c81d..38644522 100644 --- a/_alp/Agents/GCDistrictHeating/Variables.xml +++ b/_alp/Agents/GCDistrictHeating/Variables.xml @@ -183,6 +183,7 @@ 1721810038977 + true 480 430 - - 1660115363643 - - 580 - 80 - - false - true - true - - - NONE - false - - - - - 1660115363641 - TEXT_BOX - 0 - 100 - NO_DELIMETER - - - 1660229326795 @@ -1341,34 +1313,6 @@ - - 1665486155689 - - 580 - 100 - - false - true - true - - - NONE - false - - - - - 1665486155687 - TEXT_BOX - 0 - 100 - NO_DELIMETER - - - 1665487815862 @@ -1809,34 +1753,6 @@ - - 1722513783034 - - 580 - 120 - - false - true - true - - - NONE - false - - - - - 1722513783032 - TEXT_BOX - 0 - 100 - NO_DELIMETER - - - 1722411169263 @@ -1966,6 +1882,31 @@ + + 1753099355801 + + 580 + 100 + + false + true + true + + + NONE + false + + 1753099355799 + TEXT_BOX + 0 + 100 + NO_DELIMETER + + + 1659962626903 @@ -2435,4 +2376,23 @@ String + + 1753088511626 + + + 580 + 120 + + false + true + true + + ArrayList + J_EAConversion + String + + diff --git a/_alp/Classes/Class.I_HeatingManagement.java b/_alp/Classes/Class.I_HeatingManagement.java new file mode 100644 index 00000000..1d3c952f --- /dev/null +++ b/_alp/Classes/Class.I_HeatingManagement.java @@ -0,0 +1,8 @@ +public interface I_HeatingManagement +{ +void manageHeating(); +// Initiliaze throws an exception when the configuration of assets is not a valid combination +void initializeAssets(); +// not initialized sets the isInitialized flag to false. Is called when the (heating) assets in the GC change +void notInitialized(); +} \ No newline at end of file diff --git a/_alp/Classes/Class.J_EA.java b/_alp/Classes/Class.J_EA.java index fd64a68f..3c9f9b8e 100644 --- a/_alp/Classes/Class.J_EA.java +++ b/_alp/Classes/Class.J_EA.java @@ -156,22 +156,6 @@ public double getEnergyUsed_kWh() { return energyUsed_kWh; } - public double getElectricityProduced_kWh() { - return electricityProduced_kWh; - } - - public double getSetTemperature_degC() { - return 0; - } - - public double getMinTemperature_degC() { - return 0; - } - - public double getMaxTemperature_degC() { - return 0; - } - public Agent getParentAgent() { return parentAgent; } diff --git a/_alp/Classes/Class.J_EAConversionHeatPump.java b/_alp/Classes/Class.J_EAConversionHeatPump.java index 986515d2..9f455916 100644 --- a/_alp/Classes/Class.J_EAConversionHeatPump.java +++ b/_alp/Classes/Class.J_EAConversionHeatPump.java @@ -89,16 +89,6 @@ public double getCOP() { //traceln("Heatpump output temperature: " + this.outputTemperature_degC); return this.COP_r; } - - @Override - public void f_updateAllFlows(double powerFraction_fr) { - if (powerFraction_fr > 0) { - super.f_updateAllFlows(powerFraction_fr); - } - else { - this.lastFlowsMap.clear(); - } - } @Override public void operate(double ratioOfCapacity) { diff --git a/_alp/Classes/Class.J_EAStorageHeat.java b/_alp/Classes/Class.J_EAStorageHeat.java index 4a162b32..c4e6c59c 100644 --- a/_alp/Classes/Class.J_EAStorageHeat.java +++ b/_alp/Classes/Class.J_EAStorageHeat.java @@ -184,17 +184,14 @@ public double getCurrentTemperature() { return temperature_degC; } - @Override public double getSetTemperature_degC() { return setTemperature_degC; } - @Override public double getMinTemperature_degC() { return minTemperature_degC; } - @Override public double getMaxTemperature_degC() { return maxTemperature_degC; } diff --git a/_alp/Classes/Class.J_HeatingManagementBuildingSimple.java b/_alp/Classes/Class.J_HeatingManagementBuildingSimple.java new file mode 100644 index 00000000..4867e555 --- /dev/null +++ b/_alp/Classes/Class.J_HeatingManagementBuildingSimple.java @@ -0,0 +1,112 @@ +/** + * J_HeatingManagementBuildingSimple + */ +public class J_HeatingManagementBuildingSimple implements I_HeatingManagement { + + private boolean isInitialized = false; + private GridConnection gc; + private J_EABuilding building; + private J_EAConversion heatingAsset; + + private double startOfDay_h = 8; + private double startOfNight_h = 23; + private double dayTimeSetPoint_degC = 19; + private double nightTimeSetPoint_degC = 19; + private double heatingKickinTreshhold_degC = 1; + + /** + * Default constructor + */ + public J_HeatingManagementBuildingSimple( GridConnection gc ) { + this.gc = gc; + this.building = gc.p_BuildingThermalAsset; + } + + public J_HeatingManagementBuildingSimple( GridConnection gc, double startOfDay_h, double startOfNight_h, double dayTimeSetPoint_degC, double nightTimeSetPoint_degC, double heatingKickinTreshhold_degC ) { + this.gc = gc; + this.building = gc.p_BuildingThermalAsset; + this.startOfDay_h = startOfDay_h; + this.startOfNight_h = startOfNight_h; + this.dayTimeSetPoint_degC = dayTimeSetPoint_degC; + this.nightTimeSetPoint_degC = nightTimeSetPoint_degC; + this.heatingKickinTreshhold_degC = heatingKickinTreshhold_degC; + } + + public void manageHeating() { + if ( !isInitialized ) { + this.initializeAssets(); + } + double heatDemand_kW = gc.fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT); + double buildingTemp_degC = building.getCurrentTemperature(); + double timeOfDay_h = gc.energyModel.t_hourOfDay; + if (timeOfDay_h < startOfDay_h || timeOfDay_h >= startOfNight_h) { + if (buildingTemp_degC < nightTimeSetPoint_degC - heatingKickinTreshhold_degC) { + // Nighttime and building temperature too low + double buildingPower_kW = heatingAsset.getOutputCapacity_kW() - heatDemand_kW; + building.f_updateAllFlows( buildingPower_kW / building.getCapacityHeat_kW() ); + heatingAsset.f_updateAllFlows( 1.0 ); + return; + } + else { + // Nighttime and building temperature acceptable + building.f_updateAllFlows( 0.0 ); + heatingAsset.f_updateAllFlows( heatDemand_kW / heatingAsset.getOutputCapacity_kW() ); + return; + } + } + else { + if (buildingTemp_degC < dayTimeSetPoint_degC - heatingKickinTreshhold_degC) { + // Daytime and building temperature too low + double buildingPower_kW = heatingAsset.getOutputCapacity_kW() - heatDemand_kW; + building.f_updateAllFlows( buildingPower_kW / building.getCapacityHeat_kW() ); + heatingAsset.f_updateAllFlows( 1.0 ); + return; + } + else { + // Daytime and building temperature acceptable + building.f_updateAllFlows( 0.0 ); + heatingAsset.f_updateAllFlows( heatDemand_kW / heatingAsset.getOutputCapacity_kW() ); + return; + } + } + } + + public void initializeAssets() { + if (gc.p_heatBuffer != null) { + throw new RuntimeException(this.getClass() + " does not support heat buffers."); + } + if (building == null) { + throw new RuntimeException(this.getClass() + " requires a building asset."); + } + J_EAConsumption heatProfile = findFirst(gc.c_consumptionAssets, x -> x.getEAType() == OL_EnergyAssetType.HEAT_DEMAND && x.getEAType() != OL_EnergyAssetType.HOT_WATER_CONSUMPTION); + if (heatProfile != null) { + throw new RuntimeException(this.getClass() + " does not support HEAT_DEMAND profiles."); + } + if (gc.c_heatingAssets.size() == 0) { + throw new RuntimeException(this.getClass() + " requires at least one heating asset."); + } + if (gc.c_heatingAssets.size() > 1) { + throw new RuntimeException(this.getClass() + " does not support more than one heating asset."); + } + // TODO: Add a check if the power of the asset is sufficient? + // TODO: Add a check if the heatingAsset is of the correct type, e.g. not a hydrogen burner or not a CHP. + this.heatingAsset = gc.c_heatingAssets.get(0); + this.isInitialized = true; + } + + public void notInitialized() { + this.isInitialized = false; + } + + @Override + public String toString() { + return super.toString(); + } + + /** + * 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_HeatingManagementDistrictHeating.java b/_alp/Classes/Class.J_HeatingManagementDistrictHeating.java new file mode 100644 index 00000000..9d127273 --- /dev/null +++ b/_alp/Classes/Class.J_HeatingManagementDistrictHeating.java @@ -0,0 +1,70 @@ +/** + * J_HeatingManagementDistrictHeating + */ +public class J_HeatingManagementDistrictHeating implements Serializable { + + private boolean isInitialized = false; + private GridConnection gc; + private J_EAConversion heatingAsset; + + private double previousHeatFeedin_kW = 0; + + /** + * Default constructor + */ + public J_HeatingManagementDistrictHeating( GridConnection gc ) { + if (!(gc instanceof GCDistrictHeating)) { + throw new RuntimeException("Impossible to connect " + this.getClass() + " to a GC that is not GCDistrictHeating"); + } + this.gc = gc; + } + + public void manageHeating() { + if ( !isInitialized ) { + this.initializeAssets(); + } + // v_currentLoad_kW is the GN load of the previous timestep + double heatTransferToNetwork_kW = max(0, gc.p_parentNodeHeat.v_currentLoad_kW + previousHeatFeedin_kW); + if (heatTransferToNetwork_kW > heatingAsset.getOutputCapacity_kW()) { + throw new RuntimeException("Heating asset in " + this.getClass() + " does not have sufficient capacity."); + } + heatingAsset.f_updateAllFlows( heatTransferToNetwork_kW / heatingAsset.getOutputCapacity_kW() ); + previousHeatFeedin_kW = -gc.fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT); + } + + public void initializeAssets() { + if (gc.p_parentNodeHeat == null) { + throw new RuntimeException(this.getClass() + " requires the GC: " + gc.p_gridConnectionID + " to be connected to a GridNodeHeat"); + } + if (gc.p_heatBuffer != null) { + throw new RuntimeException(this.getClass() + " does not support heat buffers."); + } + if (gc.p_BuildingThermalAsset != null) { + throw new RuntimeException(this.getClass() + " does not support a building asset."); + } + if (gc.c_heatingAssets.size() == 0) { + throw new RuntimeException(this.getClass() + " requires at least one heating asset."); + } + if (gc.c_heatingAssets.size() > 1) { + throw new RuntimeException(this.getClass() + " does not support more than one heating asset."); + } + this.heatingAsset = gc.c_heatingAssets.get(0); + this.isInitialized = true; + } + + public void notInitialized() { + this.isInitialized = false; + } + + @Override + public String toString() { + return super.toString(); + } + + /** + * 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_HeatingManagementHybridHeatPump.java b/_alp/Classes/Class.J_HeatingManagementHybridHeatPump.java new file mode 100644 index 00000000..d0c1e23c --- /dev/null +++ b/_alp/Classes/Class.J_HeatingManagementHybridHeatPump.java @@ -0,0 +1,106 @@ +/** + * J_HeatingManagementHybridHeatPump + */ +public class J_HeatingManagementHybridHeatPump implements I_HeatingManagement { + + private boolean isInitialized = false; + private GridConnection gc; + private J_EAConversionHeatPump heatPumpAsset; + private J_EAConversionGasBurner gasBurnerAsset; + + /** + * Default constructor + */ + public J_HeatingManagementHybridHeatPump( GridConnection gc ) { + this.gc = gc; + } + + public void manageHeating() { + if ( !isInitialized ) { + this.initializeAssets(); + } + double heatDemand_kW = gc.fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT); + if (heatPumpAsset.getCOP() > 3.0 ) { + if (heatDemand_kW < heatPumpAsset.getOutputCapacity_kW()) { + heatPumpAsset.f_updateAllFlows( heatDemand_kW / heatPumpAsset.getOutputCapacity_kW() ); + gasBurnerAsset.f_updateAllFlows( 0.0 ); + return; + } + else if (heatDemand_kW < heatPumpAsset.getOutputCapacity_kW() + gasBurnerAsset.getOutputCapacity_kW() ) { + heatPumpAsset.f_updateAllFlows( 1.0 ); + gasBurnerAsset.f_updateAllFlows( (heatDemand_kW - heatPumpAsset.getOutputCapacity_kW()) / gasBurnerAsset.getOutputCapacity_kW() ); + return; + } + else { + throw new RuntimeException(this.getClass() + " in GC: " + gc.p_gridConnectionID + " does not have enough combined capacity to fulfil the heat demand"); + } + } + else { + if (heatDemand_kW < gasBurnerAsset.getOutputCapacity_kW()) { + gasBurnerAsset.f_updateAllFlows( heatDemand_kW / gasBurnerAsset.getOutputCapacity_kW() ); + heatPumpAsset.f_updateAllFlows( 0.0 ); + return; + } + else if (heatDemand_kW < gasBurnerAsset.getOutputCapacity_kW() + heatPumpAsset.getOutputCapacity_kW() ) { + gasBurnerAsset.f_updateAllFlows( 1.0 ); + heatPumpAsset.f_updateAllFlows( (heatDemand_kW - gasBurnerAsset.getOutputCapacity_kW()) / heatPumpAsset.getOutputCapacity_kW() ); + return; + } + else { + throw new RuntimeException(this.getClass() + " in GC: " + gc.p_gridConnectionID + " does not have enough combined capacity to fulfil the heat demand"); + } + } + } + + public void initializeAssets() { + if (gc.p_heatBuffer != null) { + throw new RuntimeException(this.getClass() + " does not support heat buffers."); + } + if (gc.p_BuildingThermalAsset != null) { + throw new RuntimeException(this.getClass() + " does not support a building asset."); + } + J_EAConsumption heatProfile = findFirst(gc.c_consumptionAssets, x -> x.getEAType() == OL_EnergyAssetType.HEAT_DEMAND && x.getEAType() != OL_EnergyAssetType.HOT_WATER_CONSUMPTION); + if (heatProfile == null) { + throw new RuntimeException(this.getClass() + " requires a HEAT_DEMAND profile."); + } + if (gc.c_heatingAssets.size() != 2) { + throw new RuntimeException(this.getClass() + " requires exactly two heating assets."); + } + // TODO: Add a check if the power of the asset is sufficient? + if (gc.c_heatingAssets.get(0) instanceof J_EAConversionGasBurner) { + this.gasBurnerAsset = (J_EAConversionGasBurner)gc.c_heatingAssets.get(0); + } + else if (gc.c_heatingAssets.get(1) instanceof J_EAConversionGasBurner) { + this.gasBurnerAsset = (J_EAConversionGasBurner)gc.c_heatingAssets.get(1); + } + else { + throw new RuntimeException(this.getClass() + " requires a Gas Burner"); + } + if (gc.c_heatingAssets.get(0) instanceof J_EAConversionHeatPump) { + this.heatPumpAsset = (J_EAConversionHeatPump)gc.c_heatingAssets.get(0); + } + else if (gc.c_heatingAssets.get(1) instanceof J_EAConversionHeatPump) { + this.heatPumpAsset = (J_EAConversionHeatPump)gc.c_heatingAssets.get(1); + } + else { + throw new RuntimeException(this.getClass() + " requires a Heat Pump"); + } + this.isInitialized = true; + } + + public void notInitialized() { + this.isInitialized = false; + } + + @Override + public String toString() { + return super.toString(); + } + + /** + * 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_HeatingManagementProfileSimple.java b/_alp/Classes/Class.J_HeatingManagementProfileSimple.java new file mode 100644 index 00000000..148f1906 --- /dev/null +++ b/_alp/Classes/Class.J_HeatingManagementProfileSimple.java @@ -0,0 +1,63 @@ +/** + * J_HeatingManagementProfileSimple + */ +public class J_HeatingManagementProfileSimple implements I_HeatingManagement { + + private boolean isInitialized = false; + private GridConnection gc; + private J_EAConversion heatingAsset; + + /** + * Default constructor + */ + public J_HeatingManagementProfileSimple( GridConnection gc ) { + this.gc = gc; + } + + public void manageHeating() { + if ( !isInitialized ) { + this.initializeAssets(); + } + double heatDemand_kW = gc.fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT); + heatingAsset.f_updateAllFlows( heatDemand_kW / heatingAsset.getOutputCapacity_kW() ); + } + + public void initializeAssets() { + if (gc.p_heatBuffer != null) { + throw new RuntimeException(this.getClass() + " does not support heat buffers."); + } + if (gc.p_BuildingThermalAsset != null) { + throw new RuntimeException(this.getClass() + " does not support a building asset."); + } + J_EAConsumption heatProfile = findFirst(gc.c_consumptionAssets, x -> x.getEAType() == OL_EnergyAssetType.HEAT_DEMAND && x.getEAType() != OL_EnergyAssetType.HOT_WATER_CONSUMPTION); + if (heatProfile == null) { + throw new RuntimeException(this.getClass() + " requires a HEAT_DEMAND profile."); + } + if (gc.c_heatingAssets.size() == 0) { + throw new RuntimeException(this.getClass() + " requires at least one heating asset."); + } + if (gc.c_heatingAssets.size() > 1) { + throw new RuntimeException(this.getClass() + " does not support more than one heating asset."); + } + // TODO: Add a check if the power of the asset is sufficient? + // TODO: Add a check if the heatingAsset is of the correct type, e.g. not a hydrogen burner or not a CHP. + this.heatingAsset = gc.c_heatingAssets.get(0); + this.isInitialized = true; + } + + public void notInitialized() { + this.isInitialized = false; + } + + @Override + public String toString() { + return super.toString(); + } + + /** + * 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 From 8e1e5c0b43accb98772928ecac3ecd184ba27227 Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Tue, 22 Jul 2025 13:11:51 +0200 Subject: [PATCH 02/16] New J_HeatingManagementNeighborhood - New class for GCNeighborhood (RES Model) that implements the new heating interface. - Cleanup of old heating stuff in GC (and extensions) --- Zero_engine.alpx | 4 + _alp/Agents/EnergyModel/EmbeddedObjects.xml | 6 - .../Code/AdditionalClassCode.java | 4 +- .../GCDistrictHeating/Code/Functions.xml | 10 +- _alp/Agents/GCDistrictHeating/Variables.xml | 1 - .../Code/AdditionalClassCode.java | 10 - .../Agents/GCNeighborhood/Code/Functions.java | 2 +- _alp/Agents/GCNeighborhood/Code/Functions.xml | 6 + _alp/Agents/GCNeighborhood/Variables.xml | 77 ++--- .../Agents/GridConnection/Code/Functions.java | 7 +- ...Class.J_HeatingManagementNeighborhood.java | 288 ++++++++++++++++++ 11 files changed, 331 insertions(+), 84 deletions(-) create mode 100644 _alp/Classes/Class.J_HeatingManagementNeighborhood.java diff --git a/Zero_engine.alpx b/Zero_engine.alpx index cb654673..35e7b5cf 100644 --- a/Zero_engine.alpx +++ b/Zero_engine.alpx @@ -1631,6 +1631,10 @@ 1753102129145 + + 1753172542012 + + com.anylogic.libraries.modules.markup_descriptors diff --git a/_alp/Agents/EnergyModel/EmbeddedObjects.xml b/_alp/Agents/EnergyModel/EmbeddedObjects.xml index 8f7d6599..6c9fb687 100644 --- a/_alp/Agents/EnergyModel/EmbeddedObjects.xml +++ b/_alp/Agents/EnergyModel/EmbeddedObjects.xml @@ -2733,18 +2733,12 @@ - - - - - - diff --git a/_alp/Agents/GCDistrictHeating/Code/AdditionalClassCode.java b/_alp/Agents/GCDistrictHeating/Code/AdditionalClassCode.java index 9fb33488..2f46be02 100644 --- a/_alp/Agents/GCDistrictHeating/Code/AdditionalClassCode.java +++ b/_alp/Agents/GCDistrictHeating/Code/AdditionalClassCode.java @@ -1,3 +1,4 @@ +/* @Override public void f_operateFlexAssets(){ f_operateAssetsDistrictHeating(); @@ -7,4 +8,5 @@ public void f_operateFlexAssets(){ public void f_connectToJ_EA(J_EA j_ea){ f_connectToJ_EA_default(j_ea); f_connectToJ_EA_DistrictHeating(j_ea); -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/_alp/Agents/GCDistrictHeating/Code/Functions.xml b/_alp/Agents/GCDistrictHeating/Code/Functions.xml index 5c46feaa..239da0cc 100644 --- a/_alp/Agents/GCDistrictHeating/Code/Functions.xml +++ b/_alp/Agents/GCDistrictHeating/Code/Functions.xml @@ -5,8 +5,9 @@ double 1663773953770 - 910 - 200 + true + 1120 + 0