Skip to content

Commit 48fbadb

Browse files
committed
Heatpump control updates
1 parent 845a668 commit 48fbadb

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

_alp/Classes/Class.J_HeatingManagementHeatpumpOffPeak.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ public class J_HeatingManagementHeatpumpOffPeak implements I_HeatingManagement {
2626
private J_HeatingPreferences heatingPreferences;
2727

2828
// PI control gains
29-
private double P_gain_kWpDegC = 1*3;
30-
private double I_gain_kWphDegC = 0.1*3;
29+
private double P_gain_kWpDegC = 1*1;
30+
private double I_gain_kWphDegC = 0.1*2;
3131
private double I_state_hDegC = 0;
3232
private double timeStep_h;
3333

34+
//Temperature setpoint low pass filter
35+
private double filteredCurrentSetpoint_degC;
36+
private double setpointFilterTimeScale_h = 2.0; // Smooth in X hours
37+
3438
//Off peak management
3539
private double preHeatDuration_hr = 2; // Amount of hours that the heatpump has to reach the requiredTemperatureAtStartOfReducedHeatingInterval_degC
3640
private double requiredTemperatureAtStartOfReducedHeatingInterval_degC = 20; // Temperature setpoint in degrees Celsius that the heatpump will have in the preheatduration time
@@ -80,21 +84,25 @@ public void manageHeating() {
8084
//Get the current temperature setpoint dependend on day/night time and noheat/preheat interval settings
8185
double currentSetpoint_degC = heatingPreferences.getDayTimeSetPoint_degC();
8286
if(timeIsInPreheatInterval) { // During preheat interval, raise the setpoint temperature step by step, to prevent overreaction by the controller
83-
currentSetpoint_degC = heatingPreferences.getDayTimeSetPoint_degC() + (requiredTemperatureAtStartOfReducedHeatingInterval_degC - heatingPreferences.getDayTimeSetPoint_degC()) * (timeOfDay_h + timeStep_h - startTimePreheatTime_hr)/preHeatDuration_hr;
84-
87+
currentSetpoint_degC = this.requiredTemperatureAtStartOfReducedHeatingInterval_degC;
8588
}
8689
else if(timeIsInReducedHeatingInterval) {
8790
currentSetpoint_degC = heatingPreferences.getMinComfortTemperature_degC(); // -> prevents fast response during interval if min comfort is breached
8891
if(startTimeOfReducedHeatingInterval_hr == timeOfDay_h) {
8992
I_state_hDegC = 0; //Reset I state at the start of no heating interval to reset the controller, so no heating power at all.
93+
this.filteredCurrentSetpoint_degC = heatingPreferences.getMinComfortTemperature_degC();
9094
}
9195
}
9296
else if (timeOfDay_h < heatingPreferences.getStartOfDayTime_h() || timeOfDay_h >= heatingPreferences.getStartOfNightTime_h()) {
9397
currentSetpoint_degC = heatingPreferences.getNightTimeSetPoint_degC();
9498
}
95-
99+
100+
101+
//Smooth the setpoint signal
102+
this.filteredCurrentSetpoint_degC += 1/(this.setpointFilterTimeScale_h / this.timeStep_h) * (currentSetpoint_degC - this.filteredCurrentSetpoint_degC);
103+
96104
//Calculate the deltaT_degc
97-
double deltaT_degC = currentSetpoint_degC - building.getCurrentTemperature(); // Positive deltaT when heating is needed
105+
double deltaT_degC = this.filteredCurrentSetpoint_degC - building.getCurrentTemperature(); // Positive deltaT when heating is needed
98106

99107
//PI control
100108
I_state_hDegC = max(0,I_state_hDegC + deltaT_degC * timeStep_h); // max(0,...) to prevent buildup of negative integrator during warm periods.
@@ -284,7 +292,8 @@ public void initializeAssets() {
284292
}
285293
if(this.heatingPreferences == null) {
286294
heatingPreferences = new J_HeatingPreferences();
287-
}
295+
}
296+
this.filteredCurrentSetpoint_degC = heatingPreferences.getMinComfortTemperature_degC();
288297
this.isInitialized = true;
289298
}
290299

@@ -312,5 +321,4 @@ public J_HeatingPreferences getHeatingPreferences() {
312321
public String toString() {
313322
return super.toString();
314323
}
315-
316324
}

_alp/Classes/Class.J_HeatingManagementPIcontrol.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ public class J_HeatingManagementPIcontrol implements I_HeatingManagement {
3131
private J_HeatingPreferences heatingPreferences;
3232

3333
// PI control gains
34-
private double P_gain_kWpDegC = 1;
35-
private double I_gain_kWphDegC = 0.1;
34+
private double P_gain_kWpDegC = 1*1;
35+
private double I_gain_kWphDegC = 0.1*2;
3636
private double I_state_hDegC = 0;
3737
private double timeStep_h;
38+
39+
//Temperature setpoint low pass filter
40+
private double filteredCurrentSetpoint_degC;
41+
private double setpointFilterTimeScale_h = 2.0; // Smooth in X hours
42+
3843
/**
3944
* Default constructor
4045
*/
@@ -68,7 +73,11 @@ public void manageHeating() {
6873
currentSetpoint_degC = heatingPreferences.getNightTimeSetPoint_degC();
6974
}
7075

71-
double deltaT_degC = currentSetpoint_degC - building.getCurrentTemperature(); // Positive deltaT when heating is needed
76+
//Smooth the setpoint signal
77+
this.filteredCurrentSetpoint_degC += 1/(this.setpointFilterTimeScale_h / this.timeStep_h) * (currentSetpoint_degC - this.filteredCurrentSetpoint_degC);
78+
79+
80+
double deltaT_degC = this.filteredCurrentSetpoint_degC - building.getCurrentTemperature(); // Positive deltaT when heating is needed
7281

7382
I_state_hDegC = max(0,I_state_hDegC + deltaT_degC * timeStep_h); // max(0,...) to prevent buildup of negative integrator during warm periods.
7483
buildingHeatingDemand_kW = max(0,deltaT_degC * P_gain_kWpDegC + I_state_hDegC * I_gain_kWphDegC);
@@ -172,6 +181,7 @@ public void initializeAssets() {
172181
if(this.heatingPreferences == null) {
173182
heatingPreferences = new J_HeatingPreferences();
174183
}
184+
this.filteredCurrentSetpoint_degC = heatingPreferences.getMinComfortTemperature_degC();
175185
this.isInitialized = true;
176186
}
177187

0 commit comments

Comments
 (0)