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
8 changes: 4 additions & 4 deletions _alp/Agents/EnergyCoop/AOC.EnergyCoop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
</Parameter>
</Parameters>
<Implements>I_EnergyData</Implements>
<StartupCode><![CDATA[v_activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_activeConsumptionEnergyCarriers= EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
<StartupCode><![CDATA[v_liveData = new J_LiveData(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 = new J_LiveData(this);
v_liveConnectionMetaData = new J_ConnectionMetaData(this);
v_liveAssetsMetaData = new J_AssetsMetaData(this);
v_liveData.connectionMetaData = v_liveConnectionMetaData;
Expand Down
67 changes: 37 additions & 30 deletions _alp/Agents/EnergyCoop/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@

for (GridConnection GC : c_customerGridConnections) { // Take 'behind the meter' production and consumption!
if(GC.v_isActive){
for (OL_EnergyCarriers energyCarrier : v_activeEnergyCarriers) {
for (OL_EnergyCarriers energyCarrier : v_liveData.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));
Expand Down Expand Up @@ -562,27 +562,28 @@

double f_initialize()
{/*ALCODESTART::1669042410671*/

v_liveConnectionMetaData.contractedDeliveryCapacityKnown = true;
v_liveConnectionMetaData.contractedFeedinCapacityKnown = true;
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.assetsMetaData.activeAssetFlows.clear();

//Get energy carriers and capacities boolean
for(GridConnection GC:c_memberGridConnections){
v_liveConnectionMetaData.contractedDeliveryCapacity_kW += GC.v_liveConnectionMetaData.contractedDeliveryCapacity_kW;
v_liveConnectionMetaData.contractedFeedinCapacity_kW += GC.v_liveConnectionMetaData.contractedFeedinCapacity_kW;
v_activeEnergyCarriers.addAll(GC.v_activeEnergyCarriers);
v_activeProductionEnergyCarriers.addAll(GC.v_activeProductionEnergyCarriers);
v_activeConsumptionEnergyCarriers.addAll(GC.v_activeConsumptionEnergyCarriers);
v_liveData.activeEnergyCarriers.addAll(GC.v_liveData.activeEnergyCarriers);
v_liveData.activeProductionEnergyCarriers.addAll(GC.v_liveData.activeProductionEnergyCarriers);
v_liveData.activeConsumptionEnergyCarriers.addAll(GC.v_liveData.activeConsumptionEnergyCarriers);
v_liveData.assetsMetaData.activeAssetFlows.addAll(GC.v_liveData.assetsMetaData.activeAssetFlows);

if(!GC.v_liveConnectionMetaData.contractedDeliveryCapacityKnown){
v_liveConnectionMetaData.contractedDeliveryCapacityKnown = false;

}

if(!GC.v_liveConnectionMetaData.contractedFeedinCapacityKnown){
v_liveConnectionMetaData.contractedFeedinCapacityKnown = false;

}
}

Expand All @@ -592,15 +593,9 @@
acc_totalCustomerFeedIn_kW = new ZeroAccumulator(true, energyModel.p_timeStep_h, 8760);

//========== LIVE WEEK DATASETS ==========//
v_liveData.dsm_liveDemand_kW.createEmptyDataSets(v_activeConsumptionEnergyCarriers, roundToInt(168/energyModel.p_timeStep_h));
v_liveData.dsm_liveSupply_kW.createEmptyDataSets(v_activeProductionEnergyCarriers, roundToInt(168/energyModel.p_timeStep_h));
v_liveData.dsm_liveAssetFlows_kW.createEmptyDataSets(v_liveData.assetsMetaData.activeAssetFlows, (int)(168 / energyModel.p_timeStep_h));

// Initializing Live Data Class
v_liveData.activeConsumptionEnergyCarriers = v_activeConsumptionEnergyCarriers;
v_liveData.activeProductionEnergyCarriers = v_activeProductionEnergyCarriers;
v_liveData.activeEnergyCarriers = v_activeEnergyCarriers;

v_liveData.dsm_liveDemand_kW.createEmptyDataSets(v_liveData.activeConsumptionEnergyCarriers, roundToInt(168/energyModel.p_timeStep_h));
v_liveData.dsm_liveSupply_kW.createEmptyDataSets(v_liveData.activeProductionEnergyCarriers, roundToInt(168/energyModel.p_timeStep_h));
v_liveData.dsm_liveAssetFlows_kW.createEmptyDataSets(v_liveData.assetsMetaData.activeAssetFlows, roundToInt(168/energyModel.p_timeStep_h));

/*ALCODEEND*/}

Expand Down Expand Up @@ -760,7 +755,7 @@
acc_totalCustomerDelivery_kW.reset();
acc_totalCustomerFeedIn_kW.reset();

v_rapidRunData.resetAccumulators(energyModel.p_runEndTime_h - energyModel.p_runStartTime_h, energyModel.p_timeStep_h, v_activeEnergyCarriers, v_activeConsumptionEnergyCarriers, v_activeProductionEnergyCarriers); //f_initializeAccumulators();
v_rapidRunData.resetAccumulators(energyModel.p_runEndTime_h - energyModel.p_runStartTime_h, energyModel.p_timeStep_h, v_liveData.activeEnergyCarriers, v_liveData.activeConsumptionEnergyCarriers, v_liveData.activeProductionEnergyCarriers); //f_initializeAccumulators();

/*ALCODEEND*/}

Expand Down Expand Up @@ -1336,10 +1331,10 @@ HashSet<GridConnection> f_getAllChildCustomerGridConnections_recursion(HashSet<G
double batteryStoredEnergyLiveWeek_MWh = 0;

for (GridConnection gc : gcList){
for (OL_EnergyCarriers EC_consumption : gc.v_activeConsumptionEnergyCarriers) {
for (OL_EnergyCarriers EC_consumption : gc.v_liveData.activeConsumptionEnergyCarriers) {
fm_demand_kW.addFlow( EC_consumption, gc.v_liveData.dsm_liveDemand_kW.get(EC_consumption).getY(i));
}
for (OL_EnergyCarriers EC_production : gc.v_activeProductionEnergyCarriers) {
for (OL_EnergyCarriers EC_production : gc.v_liveData.activeProductionEnergyCarriers) {
fm_supply_kW.addFlow( EC_production, gc.v_liveData.dsm_liveSupply_kW.get(EC_production).getY(i));
}
for (OL_AssetFlowCategories AC : gc.v_liveAssetsMetaData.activeAssetFlows) {
Expand All @@ -1354,10 +1349,10 @@ HashSet<GridConnection> f_getAllChildCustomerGridConnections_recursion(HashSet<G
batteryStoredEnergyLiveWeek_MWh += gc.v_liveData.data_batteryStoredEnergyLiveWeek_MWh.getY(i);
}

for (OL_EnergyCarriers EC_consumption : v_activeConsumptionEnergyCarriers) {
for (OL_EnergyCarriers EC_consumption : v_liveData.activeConsumptionEnergyCarriers) {
v_liveData.dsm_liveDemand_kW.get(EC_consumption).add(timeAxisValue, roundToDecimal(fm_demand_kW.get(EC_consumption), 3));
}
for (OL_EnergyCarriers EC_production : v_activeProductionEnergyCarriers) {
for (OL_EnergyCarriers EC_production : v_liveData.activeProductionEnergyCarriers) {
v_liveData.dsm_liveSupply_kW.get(EC_production).add(timeAxisValue, roundToDecimal(fm_supply_kW.get(EC_production), 3));
}

Expand Down Expand Up @@ -1477,9 +1472,9 @@ HashSet<GridConnection> f_getAllChildCustomerGridConnections_recursion(HashSet<G

EnergyCoop f_addConsumptionEnergyCarrier(OL_EnergyCarriers EC)
{/*ALCODESTART::1754380102233*/
if (!v_activeConsumptionEnergyCarriers.contains(EC)) {
v_activeEnergyCarriers.add(EC);
v_activeConsumptionEnergyCarriers.add(EC);
if (!v_liveData.activeConsumptionEnergyCarriers.contains(EC)) {
v_liveData.activeEnergyCarriers.add(EC);
v_liveData.activeConsumptionEnergyCarriers.add(EC);

DataSet dsDemand = new DataSet( (int)(168 / energyModel.p_timeStep_h) );

Expand All @@ -1494,9 +1489,9 @@ EnergyCoop f_addConsumptionEnergyCarrier(OL_EnergyCarriers EC)

EnergyCoop f_addProductionEnergyCarrier(OL_EnergyCarriers EC)
{/*ALCODESTART::1754380102235*/
if (!v_activeProductionEnergyCarriers.contains(EC)) {
v_activeEnergyCarriers.add(EC);
v_activeProductionEnergyCarriers.add(EC);
if (!v_liveData.activeProductionEnergyCarriers.contains(EC)) {
v_liveData.activeEnergyCarriers.add(EC);
v_liveData.activeProductionEnergyCarriers.add(EC);

DataSet dsSupply = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
double startTime = v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMin();
Expand Down Expand Up @@ -1547,9 +1542,9 @@ EnergyCoop f_addAssetFlow(OL_AssetFlowCategories AC)
v_rapidRunData = new J_RapidRunData(this);
v_rapidRunData.assetsMetaData = v_liveAssetsMetaData.getClone();

EnumSet<OL_EnergyCarriers> activeEnergyCarriers_rapidRun = EnumSet.copyOf(v_activeEnergyCarriers);
EnumSet<OL_EnergyCarriers> activeConsumptionEnergyCarriers_rapidRun = EnumSet.copyOf(v_activeConsumptionEnergyCarriers);
EnumSet<OL_EnergyCarriers> activeProductionEnergyCarriers_rapidRun = EnumSet.copyOf(v_activeProductionEnergyCarriers);
EnumSet<OL_EnergyCarriers> activeEnergyCarriers_rapidRun = EnumSet.copyOf(v_liveData.activeEnergyCarriers);
EnumSet<OL_EnergyCarriers> activeConsumptionEnergyCarriers_rapidRun = EnumSet.copyOf(v_liveData.activeConsumptionEnergyCarriers);
EnumSet<OL_EnergyCarriers> activeProductionEnergyCarriers_rapidRun = EnumSet.copyOf(v_liveData.activeProductionEnergyCarriers);

//Need to do this, for if the sliders have changed, otherwise potential errors/missing data
boolean storeTotalAssetFlows = true;
Expand Down Expand Up @@ -1581,6 +1576,18 @@ ArrayList<GridConnection> f_getMemberGridConnectionsCollectionPointer()
return this.c_memberGridConnections; // This should NOT be a copy, it should be a pointer!!
/*ALCODEEND*/}

double f_addMembers(List<GridConnection> gcList)
{/*ALCODESTART::1756290844166*/
c_memberGridConnections.addAll(gcList);
f_initialize();
/*ALCODEEND*/}

double f_removeMembers(List<GridConnection> gcList)
{/*ALCODESTART::1756301338833*/
c_memberGridConnections.removeAll(gcList);
f_initialize();
/*ALCODEEND*/}

double f_aggregatorBatteryManagement_EnergyCoop()
{/*ALCODESTART::1756207893357*/
if(p_aggregatorBatteryManagement != null){
Expand Down
40 changes: 40 additions & 0 deletions _alp/Agents/EnergyCoop/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,26 @@
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="default" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
<Id>1756290844166</Id>
<Name><![CDATA[f_addMembers]]></Name>
<X>990</X>
<Y>340</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Parameter>
<Name><![CDATA[gcList]]></Name>
<Type><![CDATA[List<GridConnection>]]></Type>
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="default" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
Expand All @@ -721,6 +741,26 @@
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="default" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
<Id>1756301338833</Id>
<Name><![CDATA[f_removeMembers]]></Name>
<X>990</X>
<Y>360</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Parameter>
<Name><![CDATA[gcList]]></Name>
<Type><![CDATA[List<GridConnection>]]></Type>
</Parameter>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="default" StaticFunction="false">
<ReturnModificator>VOID</ReturnModificator>
<ReturnType>double</ReturnType>
Expand Down
60 changes: 0 additions & 60 deletions _alp/Agents/EnergyCoop/Variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1213,66 +1213,6 @@
<Type><![CDATA[double]]></Type>
</Properties>
</Variable>
<Variable Class="PlainVariable">
<Id>1732886770078</Id>
<Name><![CDATA[v_activeEnergyCarriers]]></Name>
<X>75</X>
<Y>860</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Properties SaveInSnapshot="true"
Constant="false"
AccessType="public"
StaticVariable="false">
<Type><![CDATA[EnumSet<OL_EnergyCarriers>]]></Type>
</Properties>
</Variable>
<Variable Class="PlainVariable">
<Id>1740059065414</Id>
<Name><![CDATA[v_activeConsumptionEnergyCarriers]]></Name>
<X>89.6</X>
<Y>897.4</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Properties SaveInSnapshot="true"
Constant="false"
AccessType="public"
StaticVariable="false">
<Type><![CDATA[EnumSet<OL_EnergyCarriers>]]></Type>
<InitialValue Class="CodeValue">
<Code><![CDATA[EnumSet.of(OL_EnergyCarriers.ELECTRICITY);]]></Code>
</InitialValue>
</Properties>
</Variable>
<Variable Class="PlainVariable">
<Id>1740059065416</Id>
<Name><![CDATA[v_activeProductionEnergyCarriers]]></Name>
<X>89.6</X>
<Y>877.4</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Properties SaveInSnapshot="true"
Constant="false"
AccessType="public"
StaticVariable="false">
<Type><![CDATA[EnumSet<OL_EnergyCarriers>]]></Type>
</Properties>
</Variable>
<Variable Class="PlainVariable">
<Id>1740152681807</Id>
<Name><![CDATA[v_cumulativeIndividualSelfconsumptionElectricity_fr]]></Name>
Expand Down
27 changes: 14 additions & 13 deletions _alp/Agents/EnergyDataViewer/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,20 +422,21 @@
v_dataElectricityV2GProductionYear_kW = data.getRapidRunData().acc_dailyAverageV2GProduction_kW.getDataSet(startTime_h);
v_dataElectricityCHPProductionYear_kW = data.getRapidRunData().acc_dailyAverageCHPElectricityProduction_kW.getDataSet(startTime_h);
*/
DataSet totalBatteryStorage = data.getRapidRunData().ts_dailyAverageBatteriesStoredEnergy_MWh.getDataSet(startTime_h);
v_dataBatterySOCYear_fr.reset();
for (int i = 0; i < totalBatteryStorage.size(); i++) {
// Get the x and y values from the source dataset
double x = totalBatteryStorage.getX(i);
double y = totalBatteryStorage.getY(i);

// Modify the y value (e.g., divide it by 2)
double SOC = v_batteryStorageCapacityInstalled_MWh > 0 ? y / v_batteryStorageCapacityInstalled_MWh : 0;

// Add the new x and y values to the target dataset
v_dataBatterySOCYear_fr.add(x, SOC);
if (data.getRapidRunData().ts_dailyAverageBatteriesStoredEnergy_MWh != null) {
DataSet totalBatteryStorage = data.getRapidRunData().ts_dailyAverageBatteriesStoredEnergy_MWh.getDataSet(startTime_h);
v_dataBatterySOCYear_fr.reset();
for (int i = 0; i < totalBatteryStorage.size(); i++) {
// Get the x and y values from the source dataset
double x = totalBatteryStorage.getX(i);
double y = totalBatteryStorage.getY(i);

// Modify the y value (e.g., divide it by 2)
double SOC = v_batteryStorageCapacityInstalled_MWh > 0 ? y / v_batteryStorageCapacityInstalled_MWh : 0;

// Add the new x and y values to the target dataset
v_dataBatterySOCYear_fr.add(x, SOC);
}
}

/*ALCODEEND*/}

double f_addTimeStepLiveDataSetsGC(I_EnergyData data)
Expand Down
9 changes: 4 additions & 5 deletions _alp/Agents/EnergyModel/AOC.EnergyModel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ import com.querydsl.core.types.dsl.TimeExpression;
//import zero_engine.J_EAConsumption;
]]></Import>
<Implements>I_EnergyData</Implements>
<StartupCode><![CDATA[v_activeEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_activeProductionEnergyCarriers = EnumSet.of(OL_EnergyCarriers.ELECTRICITY);
v_activeConsumptionEnergyCarriers= EnumSet.of(OL_EnergyCarriers.ELECTRICITY);

v_liveData = new J_LiveData(this);
<StartupCode><![CDATA[v_liveData = new J_LiveData(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;
Expand Down
Loading