summaryrefslogtreecommitdiffstats
path: root/House.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'House.cpp')
-rw-r--r--House.cpp52
1 files changed, 46 insertions, 6 deletions
diff --git a/House.cpp b/House.cpp
index 3d9744a..d514b44 100644
--- a/House.cpp
+++ b/House.cpp
@@ -426,7 +426,7 @@ float x=0;
}
for(int i=0; i<12; ++i) {
for(int j=0; j<24; ++j) {
- neededenergy[i][j] = tempdifference[i][j]/x*1000*heaterenergy+watthoursperhuman*humans;
+ neededenergy[i][j] = tempdifference[i][j]/x*1000*heaterenergy+(watthoursperhuman*humans/24);
}
}
}
@@ -445,17 +445,57 @@ void House::calccollectoroutput(int day, int time, int month) {
collectoroutput = efficiencyvacuum[(int)(collectortemp-tempoutside[month][time]+0.5)]
*anglecorrectiontransversal[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)]
*anglecorrectionlongitudinal[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)]
- *100;
-
+ /**100*/;
else if(collectorstatus == LONGITUDINAL)
collectoroutput = efficiencyvacuum[(int)(collectortemp-tempoutside[month][time]+0.5)]
*anglecorrectionlongitudinal[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)]
*anglecorrectiontransversal[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)]
- *100;
-
+ /**100*/;
else if(collectorstatus == FLAT)
collectoroutput = efficiencyflat[(int)(collectortemp-tempoutside[month][time]+0.5)]
*anglecorrectionflat[(int)(fabs(sun.azimutangle(day, time)/2)+0.5)]
*anglecorrectionflat[(int)(fabs(roofangle-sun.elevationangle(day, time))+0.5)]
- *100;
+ /**100*/;
+
+ collectoroutput = collectoroutput*collectorarea*radiation;
+}
+
+void House::calcprobeinput(int day, int time, int month) {
+ static float E;
+ calccollectoroutput(day, time, month);
+ if(time == 0) E = neededenergy[month][time];
+ if(E>=collectoroutput && collectoroutput>0) {E -= collectoroutput; collectoroutput=0;}
+ else if(E<collectoroutput && collectoroutput>0) {collectoroutput -= E; E=0;}
+
+ if(E==0) probeinput = collectoroutput;
+ else probeinput = 0;
+}
+
+void House::controller(){
+ static int day=0, time=0, month=0;
+ calcprobeinput(day, time, month);
+ temp.setprobetemp(collectortemp);
+ temp.setinput(probeinput);
+ temp.calcTemp();
+
+ ++time;
+ if(time > 23){
+ time = 0;
+ ++day;
+ }
+ if(day > 364)
+ day = 0;
+
+ if (day>=0 && day<=30) month = 0;
+ if (day>=31 && day<=58) month = 1;
+ if (day>=59 && day<=89) month = 2;
+ if (day>=90 && day<=119) month = 3;
+ if (day>=120 && day<=150) month = 4;
+ if (day>=151 && day<=180) month = 5;
+ if (day>=181 && day<=211) month = 6;
+ if (day>=212 && day<=242) month = 7;
+ if (day>=243 && day<=272) month = 8;
+ if (day>=273 && day<=303) month = 9;
+ if (day>=304 && day<=333) month = 10;
+ if (day>=334 && day<=364) month = 11;
}