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
18 changes: 16 additions & 2 deletions _alp/Agents/EnergyCoop/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1449,15 +1449,29 @@ HashSet<GridConnection> f_getAllChildCustomerGridConnections_recursion(HashSet<G
double f_startAfterDeserialisation()
{/*ALCODESTART::1753348770752*/
v_liveData = new J_LiveData(this);
//v_liveConnectionMetaData = new J_ConnectionMetaData(this);
//v_liveAssetsMetaData = new J_AssetsMetaData(this);
v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_liveData.activeConsumptionEnergyCarriers= EnumSet.of(OL_EnergyCarriers.ELECTRICITY);

v_liveData.connectionMetaData = v_liveConnectionMetaData;
v_liveData.assetsMetaData = v_liveAssetsMetaData;

v_liveData.resetLiveDatasets(energyModel.p_runStartTime_h, energyModel.p_runStartTime_h + 24 * 7, energyModel.p_timeStep_h);

for (GridConnection gc : c_memberGridConnections) {
for (OL_EnergyCarriers EC : gc.v_liveData.activeProductionEnergyCarriers) {
f_addProductionEnergyCarrier(EC);
}
for (OL_EnergyCarriers EC : gc.v_liveData.activeConsumptionEnergyCarriers) {
f_addConsumptionEnergyCarrier(EC);
}
}

fm_currentProductionFlows_kW = new J_FlowsMap();
fm_currentConsumptionFlows_kW = new J_FlowsMap();
fm_currentBalanceFlows_kW = new J_FlowsMap();
fm_currentAssetFlows_kW = new J_ValueMap(OL_AssetFlowCategories.class);

/*ALCODEEND*/}

EnergyCoop f_addConsumptionEnergyCarrier(OL_EnergyCarriers EC)
Expand Down
1 change: 1 addition & 0 deletions _alp/Agents/EnergyCoop/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@
<ReturnType>double</ReturnType>
<Id>1753348770752</Id>
<Name><![CDATA[f_startAfterDeserialisation]]></Name>
<ExcludeFromBuild>true</ExcludeFromBuild>
<X>980</X>
<Y>70</Y>
<Label>
Expand Down
2 changes: 1 addition & 1 deletion _alp/Agents/EnergyCoop/Variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Properties SaveInSnapshot="true" AccessType="private" StaticVariable="false">
<Properties SaveInSnapshot="true" AccessType="public" StaticVariable="false">
<CollectionClass>ArrayList</CollectionClass>
<ElementClass>GridConnection</ElementClass>
<ValueElementClass>Object</ValueElementClass>
Expand Down
3 changes: 2 additions & 1 deletion _alp/Agents/EnergyModel/AOC.EnergyModel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ import com.anylogic.engine.markup.GISPoint;
import com.querydsl.core.types.dsl.TimeExpression;
//import zero_engine.J_EAStorageElectric;
//import zero_engine.J_EAConsumption;
]]></Import>

import com.anylogic.cloud.util.DateUtils;]]></Import>
<Implements>I_EnergyData</Implements>
<StartupCode><![CDATA[v_liveData = new J_LiveData(this);
v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
Expand Down
107 changes: 96 additions & 11 deletions _alp/Agents/EnergyModel/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,13 @@

double f_runTimestep()
{/*ALCODESTART::1701162826549*/
t_h = p_runStartTime_h + v_timeStepsElapsed * p_timeStep_h;// + v_hourOfYearStart);// % 8760;

// Reduce startdate after one year, loop all dat
if(t_h-p_runStartTime_h!=0.0 && (t_h-p_runStartTime_h) % 8760 == 0.0) {
Date startDate = getExperiment().getEngine().getStartDate();
startDate.setYear(startDate.getYear()-1);
getExperiment().getEngine().setStartDate(startDate);
traceln("Reduced anylogic date by one year, looping all data");
if(t_h-p_runStartTime_h!=0.0 && (t_h-p_runStartTime_h) % (p_runEndTime_h - p_runStartTime_h) == 0.0) {
f_loopSimulation();
}

//Update t_h
t_h = p_runStartTime_h + v_timeStepsElapsed * p_timeStep_h;

// Update tijdreeksen in leesbare variabelen
f_updateTimeseries(t_h);

Expand Down Expand Up @@ -1037,17 +1034,75 @@ EnergyCoop f_addProductionEnergyCarrier(OL_EnergyCarriers EC)

double f_startAfterDeserialisation()
{/*ALCODESTART::1753963201170*/

// Reconstruct the LiveData class
v_liveData = new J_LiveData(this);
v_liveConnectionMetaData = new J_ConnectionMetaData(this);
v_liveAssetsMetaData = new J_AssetsMetaData(this);
v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_liveData.activeConsumptionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);

//v_liveConnectionMetaData = new J_ConnectionMetaData(this);
//v_liveAssetsMetaData = new J_AssetsMetaData(this);
v_liveData.connectionMetaData = v_liveConnectionMetaData;
v_liveData.assetsMetaData = v_liveAssetsMetaData;

v_liveData.resetLiveDatasets(p_runStartTime_h, p_runStartTime_h, p_timeStep_h);

fm_currentProductionFlows_kW = new J_FlowsMap();
fm_currentConsumptionFlows_kW = new J_FlowsMap();
fm_currentBalanceFlows_kW = new J_FlowsMap();
fm_currentAssetFlows_kW = new J_ValueMap(OL_AssetFlowCategories.class);

// Reconstruct the LiveData class in the EnergyCoops
for (EnergyCoop ec : pop_energyCoops) {
ec.v_liveData = new J_LiveData(ec);
ec.v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
ec.v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
ec.v_liveData.activeConsumptionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);

ec.v_liveData.connectionMetaData = ec.v_liveConnectionMetaData;
ec.v_liveData.assetsMetaData = ec.v_liveAssetsMetaData;

ec.v_liveData.resetLiveDatasets(p_runStartTime_h, p_runStartTime_h, p_timeStep_h);

ec.fm_currentProductionFlows_kW = new J_FlowsMap();
ec.fm_currentConsumptionFlows_kW = new J_FlowsMap();
ec.fm_currentBalanceFlows_kW = new J_FlowsMap();
ec.fm_currentAssetFlows_kW = new J_ValueMap(OL_AssetFlowCategories.class);
}

// Reconstruct the LiveData class in the GridConnections and add EnergyCarriers
List<GridConnection> allGridConnections = new ArrayList<>(c_gridConnections);
allGridConnections.addAll(c_pausedGridConnections);
for (GridConnection gc : allGridConnections) {
gc.v_liveData = new J_LiveData(gc);
gc.v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
gc.v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
gc.v_liveData.activeConsumptionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);

gc.v_liveData.connectionMetaData = gc.v_liveConnectionMetaData;
gc.v_liveData.assetsMetaData = gc.v_liveAssetsMetaData;

gc.v_liveData.resetLiveDatasets(p_runStartTime_h, p_runStartTime_h, p_timeStep_h);

gc.fm_currentProductionFlows_kW = new J_FlowsMap();
gc.fm_currentConsumptionFlows_kW = new J_FlowsMap();
gc.fm_currentBalanceFlows_kW = new J_FlowsMap();
gc.fm_currentAssetFlows_kW = new J_ValueMap(OL_AssetFlowCategories.class);

for (J_EA j_ea : gc.c_energyAssets) {
gc.f_addEnergyCarriersAndAssetCategoriesFromEA(j_ea);
}
}

//v_liveData.activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY, OL_EnergyCarriers.HEAT, OL_EnergyCarriers.METHANE, OL_EnergyCarriers.DIESEL);
//v_liveData.activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY, OL_EnergyCarriers.HEAT);
//v_liveData.activeConsumptionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY, OL_EnergyCarriers.HEAT, OL_EnergyCarriers.METHANE, OL_EnergyCarriers.DIESEL);
//for (J_EA j_ea : c_energyAssets) {
//v_liveData.activeProductionEnergyCarriers.addAll(j_ea.activeProductionEnergyCarriers);
//v_liveData.activeConsumptionEnergyCarriers.addAll(j_ea.activeConsumptionEnergyCarriers);
//}


/*ALCODEEND*/}

Pair<J_DataSetMap, J_DataSetMap> f_getPeakWeekDataSets()
Expand Down Expand Up @@ -1145,3 +1200,33 @@ List<GridConnection> f_getPausedGridConnectionsCollectionPointer()
}
/*ALCODEEND*/}

Date f_getDate()
{/*ALCODESTART::1758012535712*/
Date startDate = getExperiment().getEngine().getStartDate();
long startDateUnixTime_ms = startDate.getTime();
long runtime_ms = (long) (v_timeStepsElapsed * p_timeStep_h * 60 * 60 * 1000);
Date date = new Date();
date.setTime(startDateUnixTime_ms + runtime_ms);
return date;
/*ALCODEEND*/}

double f_loopSimulation()
{/*ALCODESTART::1758619562148*/
v_timeStepsElapsed = 0;
f_clearAllLiveDatasets();
traceln("The simulation has been looped.");
/*ALCODEEND*/}

double f_clearAllLiveDatasets()
{/*ALCODESTART::1758619851984*/
//Energy Model
v_liveData.clearLiveDatasets();

//Energy Coops
pop_energyCoops.forEach(EC -> EC.v_liveData.clearLiveDatasets());

//GridConnections
c_gridConnections.forEach(GC -> GC.v_liveData.clearLiveDatasets());
c_pausedGridConnections.forEach(GC -> GC.v_liveData.clearLiveDatasets());
/*ALCODEEND*/}

78 changes: 63 additions & 15 deletions _alp/Agents/EnergyModel/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
<Id>1716890117265</Id>
<Name><![CDATA[f_getActiveGridConnections]]></Name>
<X>1640</X>
<Y>370</Y>
<Y>500</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand Down Expand Up @@ -274,7 +274,7 @@
<Id>1716897568717</Id>
<Name><![CDATA[f_getConnectionOwners]]></Name>
<X>1640</X>
<Y>410</Y>
<Y>540</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -290,7 +290,7 @@
<Id>1716899946694</Id>
<Name><![CDATA[f_getTopLevelGridCapacity_kW]]></Name>
<X>1640</X>
<Y>430</Y>
<Y>560</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -306,7 +306,7 @@
<Id>1717058801652</Id>
<Name><![CDATA[f_getEnergyAssets]]></Name>
<X>1640</X>
<Y>450</Y>
<Y>580</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -322,7 +322,7 @@
<Id>1718289616227</Id>
<Name><![CDATA[f_getGridNodesTopLevel]]></Name>
<X>1640</X>
<Y>500</Y>
<Y>620</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -338,7 +338,7 @@
<Id>1718289761647</Id>
<Name><![CDATA[f_getGridNodesNotTopLevel]]></Name>
<X>1640</X>
<Y>520</Y>
<Y>640</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand Down Expand Up @@ -408,7 +408,7 @@
<Id>1727167397666</Id>
<Name><![CDATA[f_getPausedGridConnections]]></Name>
<X>1640</X>
<Y>390</Y>
<Y>520</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand Down Expand Up @@ -476,7 +476,7 @@
<Id>1739958854535</Id>
<Name><![CDATA[f_addEnergyCoop]]></Name>
<X>1640</X>
<Y>180</Y>
<Y>280</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -496,7 +496,7 @@
<Id>1739972940581</Id>
<Name><![CDATA[f_removeEnergyCoop]]></Name>
<X>1640</X>
<Y>200</Y>
<Y>300</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -516,7 +516,7 @@
<Id>1740056275008</Id>
<Name><![CDATA[f_addConsumptionEnergyCarrier]]></Name>
<X>1640</X>
<Y>240</Y>
<Y>340</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -536,7 +536,7 @@
<Id>1741710906926</Id>
<Name><![CDATA[f_updateActiveAssetsMetaData]]></Name>
<X>1640</X>
<Y>80</Y>
<Y>180</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -552,7 +552,7 @@
<Id>1746021439807</Id>
<Name><![CDATA[f_addProductionEnergyCarrier]]></Name>
<X>1640</X>
<Y>260</Y>
<Y>360</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand Down Expand Up @@ -636,7 +636,7 @@
<Id>1754379679149</Id>
<Name><![CDATA[f_addAssetFlow]]></Name>
<X>1640</X>
<Y>280</Y>
<Y>380</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -656,7 +656,7 @@
<Id>1754908171225</Id>
<Name><![CDATA[f_getGridConnectionsCollectionPointer]]></Name>
<X>1640</X>
<Y>560</Y>
<Y>680</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -672,7 +672,7 @@
<Id>1755014169405</Id>
<Name><![CDATA[f_getPausedGridConnectionsCollectionPointer]]></Name>
<X>1640</X>
<Y>580</Y>
<Y>700</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -698,4 +698,52 @@
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="public" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>Date</ReturnType>
<Id>1758012535712</Id>
<Name><![CDATA[f_getDate]]></Name>
<X>1640</X>
<Y>470</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="default" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
<Id>1758619562148</Id>
<Name><![CDATA[f_loopSimulation]]></Name>
<X>1640</X>
<Y>70</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="default" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
<Id>1758619851984</Id>
<Name><![CDATA[f_clearAllLiveDatasets]]></Name>
<X>1660</X>
<Y>90</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>
Loading