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
51 changes: 28 additions & 23 deletions _alp/Agents/EnergyCoop/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,18 @@


for(GridConnection gc : c_memberGridConnections) { // Can't do this in parallel due to different threads writing to the same values!

fm_currentBalanceFlows_kW.addFlows(gc.fm_currentBalanceFlows_kW);
fm_currentProductionFlows_kW.addFlows(gc.fm_currentProductionFlows_kW);
fm_currentConsumptionFlows_kW.addFlows(gc.fm_currentConsumptionFlows_kW);
fm_currentAssetFlows_kW.addFlows(gc.fm_currentAssetFlows_kW);
v_currentFinalEnergyConsumption_kW += gc.v_currentFinalEnergyConsumption_kW;
v_currentPrimaryEnergyProduction_kW += gc.v_currentPrimaryEnergyProduction_kW;
v_currentEnergyCurtailed_kW += gc.v_currentEnergyCurtailed_kW;
v_batteryStoredEnergy_kWh += gc.v_batteryStoredEnergy_kWh;
v_currentPrimaryEnergyProductionHeatpumps_kW += gc.v_currentPrimaryEnergyProductionHeatpumps_kW;
v_currentOwnElectricityProduction_kW += gc.fm_currentProductionFlows_kW.get(OL_EnergyCarriers.ELECTRICITY);


if(gc.v_isActive){
fm_currentBalanceFlows_kW.addFlows(gc.fm_currentBalanceFlows_kW);
fm_currentProductionFlows_kW.addFlows(gc.fm_currentProductionFlows_kW);
fm_currentConsumptionFlows_kW.addFlows(gc.fm_currentConsumptionFlows_kW);
fm_currentAssetFlows_kW.addFlows(gc.fm_currentAssetFlows_kW);
v_currentFinalEnergyConsumption_kW += gc.v_currentFinalEnergyConsumption_kW;
v_currentPrimaryEnergyProduction_kW += gc.v_currentPrimaryEnergyProduction_kW;
v_currentEnergyCurtailed_kW += gc.v_currentEnergyCurtailed_kW;
v_batteryStoredEnergy_kWh += gc.v_batteryStoredEnergy_kWh;
v_currentPrimaryEnergyProductionHeatpumps_kW += gc.v_currentPrimaryEnergyProductionHeatpumps_kW;
v_currentOwnElectricityProduction_kW += gc.fm_currentProductionFlows_kW.get(OL_EnergyCarriers.ELECTRICITY);
}
}

// gather electricity flows
Expand All @@ -222,15 +221,17 @@
}

for (GridConnection GC : c_customerGridConnections) { // Take 'behind the meter' production and consumption!
for (OL_EnergyCarriers energyCarrier : v_activeEnergyCarriers) {
double nettConsumption_kW = GC.fm_currentBalanceFlows_kW.get(energyCarrier);
fm_currentProductionFlows_kW.addFlow( energyCarrier, max(0, -nettConsumption_kW));
fm_currentConsumptionFlows_kW.addFlow( energyCarrier, max(0, nettConsumption_kW));
fm_currentBalanceFlows_kW.addFlow( energyCarrier, nettConsumption_kW);

if (energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
v_currentCustomerFeedIn_kW += max(0,-nettConsumption_kW);
v_currentCustomerDelivery_kW += max(0,nettConsumption_kW);
if(GC.v_isActive){
for (OL_EnergyCarriers energyCarrier : v_activeEnergyCarriers) {
double nettConsumption_kW = GC.fm_currentBalanceFlows_kW.get(energyCarrier);
fm_currentProductionFlows_kW.addFlow( energyCarrier, max(0, -nettConsumption_kW));
fm_currentConsumptionFlows_kW.addFlow( energyCarrier, max(0, nettConsumption_kW));
fm_currentBalanceFlows_kW.addFlow( energyCarrier, nettConsumption_kW);

if (energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
v_currentCustomerFeedIn_kW += max(0,-nettConsumption_kW);
v_currentCustomerDelivery_kW += max(0,nettConsumption_kW);
}
}
}
}
Expand Down Expand Up @@ -1412,7 +1413,6 @@ HashSet<GridConnection> f_getAllChildCustomerGridConnections_recursion(HashSet<G
//Connect to coop
coopBattery.c_parentCoops.add(this);
c_memberGridConnections.add(coopBattery);
//v_liveAssetsMetaData.hasBattery = true;
}
/*ALCODEEND*/}

Expand Down Expand Up @@ -1576,3 +1576,8 @@ EnergyCoop f_addAssetFlow(OL_AssetFlowCategories AC)

/*ALCODEEND*/}

List<GridConnection> f_getMemberGridConnectionsCollectionPointer()
{/*ALCODESTART::1754908113703*/
return this.c_memberGridConnections; // This should NOT be a copy, it should be a pointer!!
/*ALCODEEND*/}

18 changes: 17 additions & 1 deletion _alp/Agents/EnergyCoop/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
<Id>1742569887460</Id>
<Name><![CDATA[f_connectCoopBattery]]></Name>
<X>990</X>
<Y>300</Y>
<Y>290</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand Down Expand Up @@ -689,4 +689,20 @@
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="public" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>List&lt;GridConnection&gt;</ReturnType>
<Id>1754908113703</Id>
<Name><![CDATA[f_getMemberGridConnectionsCollectionPointer]]></Name>
<X>1440</X>
<Y>450</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
</Functions>
2 changes: 1 addition & 1 deletion _alp/Agents/EnergyCoop/Variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Properties SaveInSnapshot="true" AccessType="public" StaticVariable="false">
<Properties SaveInSnapshot="true" AccessType="private" StaticVariable="false">
<CollectionClass>ArrayList</CollectionClass>
<ElementClass>GridConnection</ElementClass>
<ValueElementClass>Object</ValueElementClass>
Expand Down
11 changes: 10 additions & 1 deletion _alp/Agents/EnergyModel/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@
}

f_resetAnnualValues();
traceln("Active asset flows in this model: %s", v_rapidRunData.assetsMetaData.activeAssetFlows);


v_isRapidRun = true;
Expand Down Expand Up @@ -1125,3 +1124,13 @@ EnergyCoop f_addAssetFlow(OL_AssetFlowCategories AC)
}
/*ALCODEEND*/}

List<GridConnection> f_getGridConnectionsCollectionPointer()
{/*ALCODESTART::1754908171225*/
return this.c_gridConnections;
/*ALCODEEND*/}

List<GridConnection> f_getPausedGridConnectionsCollectionPointer()
{/*ALCODESTART::1755014169405*/
return this.c_pausedGridConnections;
/*ALCODEEND*/}

32 changes: 32 additions & 0 deletions _alp/Agents/EnergyModel/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,36 @@
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="public" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>List&lt;GridConnection&gt;</ReturnType>
<Id>1754908171225</Id>
<Name><![CDATA[f_getGridConnectionsCollectionPointer]]></Name>
<X>1580</X>
<Y>920</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="public" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>List&lt;GridConnection&gt;</ReturnType>
<Id>1755014169405</Id>
<Name><![CDATA[f_getPausedGridConnectionsCollectionPointer]]></Name>
<X>1580</X>
<Y>940</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
</Functions>
13 changes: 0 additions & 13 deletions _alp/Agents/GCHouse/Code/AdditionalClassCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ public void f_removeTheJ_EA(J_EA j_ea){
f_removeTheJ_EA_house(j_ea);
}

/*@Override
public void f_operateFixedConsumptionAssets(){
f_operateFixedConsumptionAssets_overwrite();
}*/

@Override
public void f_operateFlexAssets(){
f_operateFlexAssets_overwrite();
Expand All @@ -25,12 +20,4 @@ public void f_manageCharging(){
f_manageCharging_overwrite();
}

/*@Override
public void f_chargeOnPrice(double a, double b){
f_chargeOnPrice_overwrite(a,b);
}*/

@Override
public void f_simpleCharging(){
f_simpleCharging_overwrite();
}
75 changes: 2 additions & 73 deletions _alp/Agents/GCHouse/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

f_manageHeating();

if( p_householdEV != null){
if( c_electricVehicles.size() > 0){
double availableCapacityFromBatteries = p_batteryAsset == null ? 0 : p_batteryAsset.getCapacityAvailable_kW();
double availableChargingCapacity = v_liveConnectionMetaData.contractedDeliveryCapacity_kW + availableCapacityFromBatteries - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY);
//f_maxPowerCharging( max(0, availableChargingCapacity));
Expand Down Expand Up @@ -218,7 +218,7 @@ else if (lastLoopsPriceLevel.equals("low") && powerAvailableAtLastLoop_kW > p_mi
double availableCapacityFromBatteries = p_batteryAsset == null ? 0 : p_batteryAsset.getCapacityAvailable_kW();
//double availableChargingCapacity = v_allowedCapacity_kW + availableCapacityFromBatteries - v_currentPowerElectricity_kW;
double availableChargingCapacity = v_liveConnectionMetaData.contractedDeliveryCapacity_kW + availableCapacityFromBatteries - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY);
v_vehicleSOC_fr = p_householdEV.getCurrentStateOfCharge_fr();
//v_vehicleSOC_fr = p_householdEV.getCurrentStateOfCharge_fr();

switch (p_chargingAttitudeVehicles) {
case SIMPLE:
Expand Down Expand Up @@ -341,60 +341,8 @@ else if ( v_batterySOC_fr < 0.6 && v_currentPowerElectricity_kW < 1 && v_current

double f_connectTo_J_EA_House(J_EA j_ea)
{/*ALCODESTART::1693300820997*/
/*
if (j_ea instanceof J_EAConversion) {
if (j_ea.energyAssetType == OL_EnergyAssetType.GAS_BURNER || j_ea instanceof J_EAConversionHeatPump || j_ea instanceof J_EAConversionHeatDeliverySet || j_ea instanceof J_EAConversionElectricHeater ) {
switch (p_heatingType) {
case HEATPUMP_AIR:
p_primaryHeatingAsset = (J_EAConversion)j_ea;
break;
case HEATPUMP_GASPEAK:
p_primaryHeatingAsset = p_primaryHeatingAsset == null && j_ea instanceof J_EAConversionHeatPump? (J_EAConversion)j_ea : p_primaryHeatingAsset;
p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && j_ea instanceof J_EAConversionGasBurner? (J_EAConversion)j_ea : p_secondaryHeatingAsset;
break;
case HEATPUMP_BOILERPEAK: // ambigue wat we met boiler bedoelen; eboiler of grootschalige DH_boiler = gasburner!
p_primaryHeatingAsset = p_primaryHeatingAsset == null && j_ea instanceof J_EAConversionHeatPump? (J_EAConversion)j_ea : p_primaryHeatingAsset;
p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && j_ea instanceof J_EAConversionGasBurner? (J_EAConversion)j_ea : p_secondaryHeatingAsset;
p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && j_ea instanceof J_EAConversionElectricHeater? (J_EAConversion)j_ea : p_secondaryHeatingAsset;
break;
case GASBURNER:
p_primaryHeatingAsset = p_primaryHeatingAsset == null && j_ea instanceof J_EAConversionGasBurner? (J_EAConversion)j_ea : p_primaryHeatingAsset;
p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && j_ea instanceof J_EAConversionGasCHP? (J_EAConversion)j_ea : p_secondaryHeatingAsset;
break;
case DISTRICTHEAT:
if( j_ea instanceof J_EAConversionHeatDeliverySet ){
p_primaryHeatingAsset = (J_EAConversion)j_ea;
//traceln("Assigning heat delivery set as primary heating asset for house!");
}
else {
p_secondaryHeatingAsset = (J_EAConversion)j_ea;
// set water/water heatpump source energy-asset

//if( j_ea instanceof J_EAConversionHeatPump && ((J_EAConversionHeatPump)j_ea).getAmbientTempType().equals("WATER") && p_primaryHeatingAsset instanceof J_EAConversionHeatDeliverySet ) {
//((J_EAConversionHeatPump)j_ea).p_linkedSourceEnergyAsset = p_primaryHeatingAsset;
//j_ea.updateAmbientTemperature( ((J_EAConversionHeatPump)j_ea).p_linkedSourceEnergyAsset.getCurrentTemperature() );
//}

}
break;
case LT_DISTRICTHEAT:
p_primaryHeatingAsset = (J_EAConversion)j_ea;
break;
default: throw new IllegalStateException("Invalid HeatingType: " + p_heatingType);
}
}
}
*/

if (j_ea instanceof J_EAEV) {
if (p_householdEV != null){
throw new RuntimeException(String.format("Exception: trying to assign 2 EVs to a household!! --> one of them will not charge! "));
}
p_householdEV = (J_EAEV)j_ea;
}
if (j_ea instanceof J_EAAirco) {
p_airco = (J_EAAirco)j_ea;
//c_electricHeatpumpAssets.add(j_ea);
}
/*ALCODEEND*/}

Expand All @@ -408,21 +356,6 @@ else if ( v_batterySOC_fr < 0.6 && v_currentPowerElectricity_kW < 1 && v_current
traceln("Placeholder function f_setEnergyLabel called! Nothing will happen.");
/*ALCODEEND*/}

double f_removeCurrentHeatingSystem()
{/*ALCODESTART::1726129903799*/
p_heatingType = OL_GridConnectionHeatingType.NONE;
p_primaryHeatingAsset.removeEnergyAsset();
if ( p_secondaryHeatingAsset != null){
p_secondaryHeatingAsset.removeEnergyAsset();
}
if ( p_tertiaryHeatingAsset != null){
p_tertiaryHeatingAsset.removeEnergyAsset();
}
if ( p_heatBuffer != null){
p_heatBuffer.removeEnergyAsset();
}
/*ALCODEEND*/}

double f_manageCookingTracker()
{/*ALCODESTART::1726334759211*/
// Add heat from cooking assets to house
Expand Down Expand Up @@ -482,12 +415,8 @@ else if ( v_batterySOC_fr < 0.6 && v_currentPowerElectricity_kW < 1 && v_current

double f_removeTheJ_EA_house(J_EA j_ea)
{/*ALCODESTART::1749722407831*/
if (j_ea instanceof J_EAEV) {
p_householdEV = null;
}
if (j_ea instanceof J_EAAirco) {
p_airco = null;
//c_electricHeatpumpAssets.remove(j_ea);
}
/*ALCODEEND*/}

Loading