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
4 changes: 2 additions & 2 deletions _alp/Agents/EnergyDataViewer/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
{/*ALCODESTART::1741792546539*/
//========== SUMMER WEEK ==========//
// Consumption
double summerWeekStartTime_h = energyModel.p_startHourSummerWeek - energyModel.p_runStartTime_h;
double summerWeekStartTime_h = energyModel.p_startOfSummerWeek_h - energyModel.p_runStartTime_h;
dsm_summerWeekConsumptionDataSets_kW = data.getRapidRunData().am_summerWeekConsumptionAccumulators_kW.getDataSetMap(summerWeekStartTime_h);
v_dataElectricityBaseloadConsumptionSummerWeek_kW = data.getRapidRunData().acc_summerWeekBaseloadElectricityConsumption_kW.getDataSet(summerWeekStartTime_h);
v_dataElectricityForHeatConsumptionSummerWeek_kW = data.getRapidRunData().acc_summerWeekHeatPumpElectricityConsumption_kW.getDataSet(summerWeekStartTime_h);
Expand Down Expand Up @@ -345,7 +345,7 @@

//========== WINTER WEEK ==========//
// Consumption
double winterWeekStartTime_h = energyModel.p_startHourWinterWeek - energyModel.p_runStartTime_h;
double winterWeekStartTime_h = energyModel.p_startOfWinterWeek_h - energyModel.p_runStartTime_h;
dsm_winterWeekConsumptionDataSets_kW = data.getRapidRunData().am_winterWeekConsumptionAccumulators_kW.getDataSetMap(winterWeekStartTime_h);
v_dataElectricityBaseloadConsumptionWinterWeek_kW = data.getRapidRunData().acc_winterWeekBaseloadElectricityConsumption_kW.getDataSet(winterWeekStartTime_h);
v_dataElectricityForHeatConsumptionWinterWeek_kW = data.getRapidRunData().acc_winterWeekHeatPumpElectricityConsumption_kW.getDataSet(winterWeekStartTime_h);
Expand Down
6 changes: 3 additions & 3 deletions _alp/Agents/EnergyModel/AOC.EnergyModel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ v_liveData.assetsMetaData = v_liveAssetsMetaData;]]></StartupCode>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<InterpolationMethod>LINEAR</InterpolationMethod>
<OutOfRangeBehaviour>NEAREST</OutOfRangeBehaviour>
<OutOfRangeBehaviour>REPEATING</OutOfRangeBehaviour>
<OutOfRangeCustomValue>0.0</OutOfRangeCustomValue>
<ApproximationOrder>1</ApproximationOrder>
<LoadFromDatabase>false</LoadFromDatabase>
Expand Down Expand Up @@ -350,7 +350,7 @@ v_liveData.assetsMetaData = v_liveAssetsMetaData;]]></StartupCode>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<InterpolationMethod>LINEAR</InterpolationMethod>
<OutOfRangeBehaviour>NEAREST</OutOfRangeBehaviour>
<OutOfRangeBehaviour>REPEATING</OutOfRangeBehaviour>
<OutOfRangeCustomValue>0.0</OutOfRangeCustomValue>
<ApproximationOrder>1</ApproximationOrder>
<LoadFromDatabase>false</LoadFromDatabase>
Expand Down Expand Up @@ -380,7 +380,7 @@ v_liveData.assetsMetaData = v_liveAssetsMetaData;]]></StartupCode>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<InterpolationMethod>LINEAR</InterpolationMethod>
<OutOfRangeBehaviour>NEAREST</OutOfRangeBehaviour>
<OutOfRangeBehaviour>REPEATING</OutOfRangeBehaviour>
<OutOfRangeCustomValue>0.0</OutOfRangeCustomValue>
<ApproximationOrder>1</ApproximationOrder>
<LoadFromDatabase>false</LoadFromDatabase>
Expand Down
17 changes: 14 additions & 3 deletions _alp/Agents/EnergyModel/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ null, roundToDecimal( a.v_electricityImported_kWh-a.v_electricityExported_kWh, 2
{/*ALCODESTART::1664952601107*/
b_isDaytime = t_h % 24 > 6 && t_h % 24 < 18;
b_isWeekday = (t_h+(v_dayOfWeek1jan-1)*24) % (24*7) < (24*5);
b_isSummerWeek = (t_h % 8760) >= p_startHourSummerWeek && (t_h % 8760) < p_startHourSummerWeek + 24*7;
b_isWinterWeek = (t_h % 8760) >= p_startHourWinterWeek && (t_h % 8760) < p_startHourWinterWeek + 24*7;
b_isSummerWeek = (t_h % 8760) >= p_startOfSummerWeek_h && (t_h % 8760) < p_startOfSummerWeek_h + 24*7;
b_isWinterWeek = (t_h % 8760) >= p_startOfWinterWeek_h && (t_h % 8760) < p_startOfWinterWeek_h + 24*7;
b_isLastTimeStepOfDay = t_h % 24 == (24-p_timeStep_h);
t_hourOfDay = t_h % 24; // Assumes modelrun starts at midnight.

Expand Down Expand Up @@ -1368,9 +1368,17 @@ null, roundToDecimal( a.v_electricityImported_kWh-a.v_electricityExported_kWh, 2

double f_runTimestep()
{/*ALCODESTART::1701162826549*/
// Update tijdreeksen in leesbare variabelen
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");
}

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

// Operate assets on each gridConnection
Expand Down Expand Up @@ -1464,6 +1472,9 @@ ArrayList<GridConnection> f_getGridConnections()

LocalDate localDate = LocalDate.of(p_year, 1, 1);
v_dayOfWeek1jan = DayOfWeek.from(localDate).getValue();
p_startOfWinterWeek_h = roundToInt(24 * (p_winterWeekNumber * 7 + (8-v_dayOfWeek1jan)%7)); // Week 49 is winterweek.
p_startOfSummerWeek_h = roundToInt(24 * (p_summerWeekNumber * 7 + (8-v_dayOfWeek1jan)%7)); // Week 18 is summerweek.


Date startDate = date();

Expand Down
52 changes: 45 additions & 7 deletions _alp/Agents/EnergyModel/Variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@
<Id>1731422704613</Id>
<Name><![CDATA[b_isSummerWeek]]></Name>
<X>680</X>
<Y>758</Y>
<Y>800</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -1486,7 +1486,7 @@
<Id>1731422714256</Id>
<Name><![CDATA[b_isWinterWeek]]></Name>
<X>680</X>
<Y>778</Y>
<Y>820</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand All @@ -1508,7 +1508,7 @@
<Id>1731422900385</Id>
<Name><![CDATA[b_isLastTimeStepOfDay]]></Name>
<X>680</X>
<Y>798</Y>
<Y>840</Y>
<Label>
<X>10</X>
<Y>0</Y>
Expand Down Expand Up @@ -1712,6 +1712,44 @@
<Type><![CDATA[J_ConnectionMetaData]]></Type>
</Properties>
</Variable>
<Variable Class="PlainVariable">
<Id>1744272354153</Id>
<Name><![CDATA[p_startOfWinterWeek_h]]></Name>
<X>680</X>
<Y>780</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[int]]></Type>
</Properties>
</Variable>
<Variable Class="PlainVariable">
<Id>1744272373654</Id>
<Name><![CDATA[p_startOfSummerWeek_h]]></Name>
<X>680</X>
<Y>760</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[int]]></Type>
</Properties>
</Variable>
<Variable Class="Parameter">
<Id>1658496701675</Id>
<Name><![CDATA[p_timeStep_h]]></Name>
Expand Down Expand Up @@ -2008,7 +2046,7 @@
</Variable>
<Variable Class="Parameter">
<Id>1699275323339</Id>
<Name><![CDATA[p_startHourWinterWeek]]></Name>
<Name><![CDATA[p_winterWeekNumber]]></Name>
<X>680</X>
<Y>578</Y>
<Label>
Expand All @@ -2023,7 +2061,7 @@
<UnitType>NONE</UnitType>
<SdArray>false</SdArray>
<DefaultValue Class="CodeValue">
<Code><![CDATA[8256]]></Code>
<Code><![CDATA[49]]></Code>
</DefaultValue>
<ParameterEditor>
<Id>1699275323337</Id>
Expand All @@ -2036,7 +2074,7 @@
</Variable>
<Variable Class="Parameter">
<Id>1699275323347</Id>
<Name><![CDATA[p_startHourSummerWeek]]></Name>
<Name><![CDATA[p_summerWeekNumber]]></Name>
<X>680</X>
<Y>598</Y>
<Label>
Expand All @@ -2051,7 +2089,7 @@
<UnitType>NONE</UnitType>
<SdArray>false</SdArray>
<DefaultValue Class="CodeValue">
<Code><![CDATA[3048]]></Code>
<Code><![CDATA[18]]></Code>
</DefaultValue>
<ParameterEditor>
<Id>1699275323345</Id>
Expand Down
6 changes: 4 additions & 2 deletions _alp/Classes/Class.J_EAProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class J_EAProfile extends zero_engine.J_EA implements Serializable {
//protected double outputTemperature_degC;
public double loadLoad_kWh = 0;
private double profileScaling_fr = 1;

private boolean enableProfileLooping = true;

/**
* Default constructor
Expand Down Expand Up @@ -76,7 +76,9 @@ public void f_updateAllFlows(double time_h) {
@Override
//public Pair<J_FlowsMap, Double> operate(double time_h) {
public void operate(double time_h) {
if ( (int)floor(time_h/profileTimestep_h) >= a_energyProfile_kWh.length ) {
if (enableProfileLooping && time_h >= a_energyProfile_kWh.length * profileTimestep_h) {
time_h = time_h % a_energyProfile_kWh.length * profileTimestep_h;
} else if ( (int)floor(time_h/profileTimestep_h) >= a_energyProfile_kWh.length ) {
traceln("Time out of upper bound for evaluating J_EAProfile power in profile asset %s!", this.energyAssetName);
// time_h = a_energyProfile_kWh.length * profileTimestep_h - 1;
throw new RuntimeException(String.format("Time out of upper bound for evaluating J_EAProfile power! Time is: %s", time_h));
Expand Down
4 changes: 2 additions & 2 deletions _alp/Classes/Class.J_LoadDurationCurves.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public void calculateLoadDurationCurves(double[] loadArray_kW) {
ds_previousLoadDurationCurveTotal_kW.add(i*energyModel.p_timeStep_h,ds_loadDurationCurveTotal_kW.getY(i));
}
// summer/winter
if (energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h > energyModel.p_startHourSummerWeek && energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h<= energyModel.p_startHourSummerWeek+24*7) {
if (energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h > energyModel.p_startOfSummerWeek_h && energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h<= energyModel.p_startOfSummerWeek_h+24*7) {
netLoadArraySummerweek_kW[i_summer]=-netLoadArrayAnnual_kW[i];
i_summer++;
}
if (energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h > energyModel.p_startHourWinterWeek && energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h<= energyModel.p_startHourWinterWeek+24*7) {
if (energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h > energyModel.p_startOfWinterWeek_h && energyModel.p_runStartTime_h + i*energyModel.p_timeStep_h<= energyModel.p_startOfWinterWeek_h+24*7) {
netLoadArrayWinterweek_kW[i_winter]=-netLoadArrayAnnual_kW[i];
i_winter++;
}
Expand Down