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
6 changes: 3 additions & 3 deletions _alp/Agents/EnergyCoop/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
if (ConnectingChildActor.p_actorGroup.contains("production") || ConnectingChildActor.p_actorGroup.contains("Production") || ConnectingChildActor.p_actorGroup.contains("member")) { // Count owned production-sites as 'behind the meter'
c_coopMembers.add( ConnectingChildActor);
c_memberGridConnections.addAll(((ConnectionOwner)ConnectingChildActor).c_ownedGridConnections);
(((ConnectionOwner)ConnectingChildActor).c_ownedGridConnections).forEach( gc -> gc.c_parentCoops.add(this));
//traceln("Adding: %s", ((ConnectionOwner)ConnectingChildActor).c_ownedGridConnections);
} else {
c_coopCustomers.add( ConnectingChildActor );
c_customerGridConnections.addAll(((ConnectionOwner)ConnectingChildActor).c_ownedGridConnections);

}
} else {
c_coopCustomers.add( ConnectingChildActor );
Expand Down Expand Up @@ -1164,8 +1164,7 @@

double f_initializeCustomCoop(ArrayList<GridConnection> gcList)
{/*ALCODESTART::1739974426481*/
c_memberGridConnections = gcList;

c_memberGridConnections.addAll(gcList);

//Basic initialization
f_initialize();
Expand Down Expand Up @@ -1297,6 +1296,7 @@ HashSet<GridConnection> f_getAllChildMemberGridConnections_recursion(HashSet<Gri

//Recursive loop (repeat this function till bottom)
List<Agent> childCoops = findAll(c_coopMembers, coopMember -> coopMember instanceof EnergyCoop);

if(childCoops.size() == 0){
return allMemberGridConnections;
}
Expand Down
2 changes: 0 additions & 2 deletions _alp/Agents/EnergyCoop/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@
<ReturnType>ArrayList&lt;GridConnection&gt;</ReturnType>
<Id>1740493169961</Id>
<Name><![CDATA[f_getAllChildCustomerGridConnections]]></Name>
<Description><![CDATA[Function that gets all grid nodes and the children of those grid nodes, etc. All the way to the bottom node.]]></Description>
<X>60</X>
<Y>420</Y>
<Label>
Expand All @@ -503,7 +502,6 @@
<ReturnType>HashSet&lt;GridConnection&gt;</ReturnType>
<Id>1740493169963</Id>
<Name><![CDATA[f_getAllChildCustomerGridConnections_recursion]]></Name>
<Description><![CDATA[Recursion Function that gets all grid nodes and the children of those grid nodes, etc. All the way to the bottom node. For basic use should be called with an empty list!]]></Description>
<X>80</X>
<Y>440</Y>
<Label>
Expand Down
8 changes: 8 additions & 0 deletions _alp/Agents/EnergyModel/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,9 @@ EnergyCoop f_addEnergyCoop(ArrayList<GridConnection> gcList)
// Initialisation, collecting data and calculating KPIs.
energyCoop.f_initializeCustomCoop(gcList);

// Adding this coop to the list of coops in the GC
gcList.forEach(gc -> gc.c_parentCoops.add(energyCoop));

// Return energyCoop to caller
return energyCoop;
/*ALCODEEND*/}
Expand All @@ -1818,6 +1821,11 @@ EnergyCoop f_removeEnergyCoop(EnergyCoop energyCoop)
}
}

// Removing this coop from the list of coops in the GC
for (GridConnection GC : energyCoop.f_getAllChildMemberGridConnections()) {
GC.c_parentCoops.remove(energyCoop);
}

// Remove energyCoop from pop_energyCoops.
remove_pop_energyCoops(energyCoop);

Expand Down
39 changes: 25 additions & 14 deletions _alp/Agents/GridConnection/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1170,19 +1170,23 @@ else if (p_primaryHeatingAsset== null && p_secondaryHeatingAsset != null && v_ha

if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOVOLTAIC) {
v_hasPV = true;
v_liveAssetsMetaData.totalInstalledPVPower_kW += ((J_EAProduction)j_ea).getCapacityElectric_kW();
double capacity_kW = ((J_EAProduction)j_ea).getCapacityElectric_kW();
v_liveAssetsMetaData.totalInstalledPVPower_kW += capacity_kW;
if (l_parentNodeElectric.getConnectedAgent() != null) {
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.PHOTOVOLTAIC, ((J_EAProduction)j_ea).getCapacityElectric_kW(), true);
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.PHOTOVOLTAIC, capacity_kW, true);
}
energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW += ((J_EAProduction)j_ea).getCapacityElectric_kW();
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledPVPower_kW += capacity_kW);
energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW += capacity_kW;
c_pvAssets.add(j_ea);
}
else if (j_ea.energyAssetType == OL_EnergyAssetType.WINDMILL) {
v_liveAssetsMetaData.totalInstalledWindPower_kW += ((J_EAProduction)j_ea).getCapacityElectric_kW();
double capacity_kW = ((J_EAProduction)j_ea).getCapacityElectric_kW();
v_liveAssetsMetaData.totalInstalledWindPower_kW += capacity_kW;
if (l_parentNodeElectric.getConnectedAgent() != null) {
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.WINDMILL, ((J_EAProduction)j_ea).getCapacityElectric_kW(), true);
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.WINDMILL, capacity_kW, true);
}
energyModel.v_liveAssetsMetaData.totalInstalledWindPower_kW += ((J_EAProduction)j_ea).getCapacityElectric_kW();
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledWindPower_kW += capacity_kW);
energyModel.v_liveAssetsMetaData.totalInstalledWindPower_kW += capacity_kW;
c_windAssets.add(j_ea);
}
} else if (j_ea instanceof J_EAConversion) {
Expand Down Expand Up @@ -1242,8 +1246,10 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.CHP) {
} else if (j_ea instanceof J_EAStorageElectric) {
p_batteryAsset = (J_EAStorageElectric)j_ea;
c_batteryAssets.add(j_ea);
v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += ((J_EAStorageElectric)j_ea).getStorageCapacity_kWh()/1000;
energyModel.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += ((J_EAStorageElectric)j_ea).getStorageCapacity_kWh()/1000;
double capacity_MWh = ((J_EAStorageElectric)j_ea).getStorageCapacity_kWh()/1000;
v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh;
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh);
energyModel.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh;

} else if (j_ea instanceof J_EAStorageHeat) {
energyModel.c_ambientAirDependentAssets.add(j_ea);
Expand All @@ -1260,6 +1266,7 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.CHP) {
} else if( ((J_EAProfile)j_ea).profileType == OL_ProfileAssetType.WINDTURBINE){
//v_windProductionElectric_kW += flowsArray[0];
c_windAssets.add(j_ea);
// TODO: Add some to the total installed wind (of this GC, its GN, the energymodel (and its parent coop))
} else if( ((J_EAProfile)j_ea).profileType == OL_ProfileAssetType.HEATDEMAND){
//Do nothing
} else if( ((J_EAProfile)j_ea).profileType == OL_ProfileAssetType.METHANEDEMAND){
Expand Down Expand Up @@ -1701,19 +1708,23 @@ else if(electricityBalance_kW < - v_maxPeakFeedin_kW){
if (otherPV == null) {
v_hasPV = false;
}
v_liveAssetsMetaData.totalInstalledPVPower_kW -= ((J_EAProduction)j_ea).getCapacityElectric_kW();
double capacity_kW = ((J_EAProduction)j_ea).getCapacityElectric_kW();
v_liveAssetsMetaData.totalInstalledPVPower_kW -= capacity_kW;
if (l_parentNodeElectric.getConnectedAgent() != null) {
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.PHOTOVOLTAIC, ((J_EAProduction)j_ea).getCapacityElectric_kW(), false);
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.PHOTOVOLTAIC, capacity_kW, false);
}
energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW -= ((J_EAProduction)j_ea).getCapacityElectric_kW();
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledPVPower_kW -= capacity_kW);
energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW -= capacity_kW;
c_pvAssets.remove(j_ea);
}
else if (j_ea.energyAssetType == OL_EnergyAssetType.WINDMILL) {
v_liveAssetsMetaData.totalInstalledWindPower_kW -= ((J_EAProduction)j_ea).getCapacityElectric_kW();
double capacity_kW = ((J_EAProduction)j_ea).getCapacityElectric_kW();
v_liveAssetsMetaData.totalInstalledWindPower_kW -= capacity_kW;
if (l_parentNodeElectric.getConnectedAgent() != null) {
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.WINDMILL, ((J_EAProduction)j_ea).getCapacityElectric_kW(), false);
l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.WINDMILL, capacity_kW, false);
}
energyModel.v_liveAssetsMetaData.totalInstalledWindPower_kW -= ((J_EAProduction)j_ea).getCapacityElectric_kW();
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledPVPower_kW -= capacity_kW);
energyModel.v_liveAssetsMetaData.totalInstalledWindPower_kW -= capacity_kW;
c_windAssets.remove(j_ea);
}
} else if (j_ea instanceof J_EAConversion) {
Expand Down
18 changes: 18 additions & 0 deletions _alp/Agents/GridConnection/Variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2754,4 +2754,22 @@
<ValueElementClass>String</ValueElementClass>
</Properties>
</Variable>
<Variable Class="CollectionVariable">
<Id>1742484728807</Id>
<Name><![CDATA[c_parentCoops]]></Name>
<X>270</X>
<Y>480</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Properties SaveInSnapshot="true" AccessType="public" StaticVariable="false">
<CollectionClass>ArrayList</CollectionClass>
<ElementClass>EnergyCoop</ElementClass>
<ValueElementClass>String</ValueElementClass>
</Properties>
</Variable>
</Variables>
45 changes: 21 additions & 24 deletions _alp/Classes/Class.J_AssetsMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public void updateActiveAssetData(ArrayList<GridConnection> gcList) {
this.hasCHP = false;
this.hasV2G = false;
this.hasElectricCooking = false;


//Electric heating
for(GridConnection GC : gcList){
Expand All @@ -62,35 +61,23 @@ public void updateActiveAssetData(ArrayList<GridConnection> gcList) {
}
//PV
for(GridConnection GC : gcList){
if(GC.c_pvAssets.size()>0 && GC.v_isActive){
for(J_EA pvAsset : GC.c_pvAssets){
if(((J_EAProduction)pvAsset).getCapacityElectric_kW() > 0) {
this.hasPV = true;
this.totalInstalledPVPower_kW += ((J_EAProduction)pvAsset).getCapacityElectric_kW();
}
}
if (GC.v_liveAssetsMetaData.totalInstalledPVPower_kW > 0 && GC.v_isActive) {
this.hasPV = true;
break;
}
}
//Wind
for(GridConnection GC : gcList){
if(GC.c_windAssets.size()>0 && GC.v_isActive){
for(J_EA windturbine : GC.c_windAssets){
if(((J_EAProduction)windturbine).getCapacityElectric_kW() > 0) {
this.hasWindturbine = true;
this.totalInstalledWindPower_kW += ((J_EAProduction)windturbine).getCapacityElectric_kW();
}
}
if (GC.v_liveAssetsMetaData.totalInstalledWindPower_kW > 0 && GC.v_isActive) {
this.hasWindturbine = true;
break;
}
}
//Battery
for(GridConnection GC : gcList){
if(GC.c_batteryAssets.size()>0 && GC.v_isActive){
for(J_EA battery : GC.c_batteryAssets){
if(((J_EAStorageElectric)battery).getStorageCapacity_kWh() > 0){
this.hasBattery = true;
this.totalInstalledBatteryStorageCapacity_MWh += ((J_EAStorageElectric)battery).getStorageCapacity_kWh()/1000;
}
}
if (GC.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh > 0 && GC.v_isActive) {
this.hasBattery = true;
break;
}
}
//Heat grid
Expand Down Expand Up @@ -153,7 +140,17 @@ public J_AssetsMetaData getClone() {

@Override
public String toString() {
return super.toString();
return "totalInstalledPVPower_kW: " + totalInstalledPVPower_kW +
", totalInstalledWindPower_kW: " + totalInstalledWindPower_kW +
", totalInstalledBatteryStorageCapacity_MWh: " + totalInstalledBatteryStorageCapacity_MWh +
", hasElectricHeating: " + hasElectricHeating +
", hasElectricTransport: " + hasElectricTransport +
", hasWindturbine: " + hasWindturbine +
", hasBattery: " + hasBattery +
", hasHeatGridConnection: " + hasHeatGridConnection +
", hasElectrolyser: " + hasElectrolyser +
", hasCHP: " + hasCHP +
", hasV2G: " + hasV2G +
", hasElectricCooking: " + hasElectricCooking;
}

}
2 changes: 2 additions & 0 deletions _alp/Classes/Class.J_EAProduction.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ public void setCapacityElectric_kW(double capacityElectric_kW) {
if (((GridConnection) this.parentAgent).l_parentNodeElectric.getConnectedAgent() != null) {
((GridConnection) this.parentAgent).l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.WINDMILL, difference_kW, true);
}
((GridConnection) this.parentAgent).c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledWindPower_kW += difference_kW);
((GridConnection) this.parentAgent).energyModel.v_liveAssetsMetaData.totalInstalledWindPower_kW += difference_kW;
}
else if (this.energyAssetType == OL_EnergyAssetType.PHOTOVOLTAIC && this.parentAgent instanceof GridConnection) {
((GridConnection) this.parentAgent).v_liveAssetsMetaData.totalInstalledPVPower_kW += difference_kW;
if (((GridConnection) this.parentAgent).l_parentNodeElectric.getConnectedAgent() != null) {
((GridConnection) this.parentAgent).l_parentNodeElectric.getConnectedAgent().f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.PHOTOVOLTAIC, difference_kW, true);
}
((GridConnection) this.parentAgent).c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledPVPower_kW += difference_kW);
((GridConnection) this.parentAgent).energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW += difference_kW;
}

Expand Down