summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-02-01 20:36:16 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-02-01 20:36:16 +0100
commitce4aa5800b7a8efa3608f6fa9fa547d724ddf686 (patch)
tree5771e6dfeaf2c56ea8b63dc112000e413e0dfbfb
parent932a190de286e50797f474aacd0f207e87d29da1 (diff)
downloadc3d-ce4aa5800b7a8efa3608f6fa9fa547d724ddf686.tar
c3d-ce4aa5800b7a8efa3608f6fa9fa547d724ddf686.zip
...
-rw-r--r--DisplayClass.cpp9
-rw-r--r--DisplayClass.h4
-rw-r--r--House.cpp52
-rw-r--r--House.h7
-rw-r--r--Temparray.cpp6
-rw-r--r--Temparray.h7
6 files changed, 66 insertions, 19 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index 174e4ac..f60fc96 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -1,6 +1,4 @@
#include "DisplayClass.h"
-#include "gl.h"
-
DisplayClass::Renderer DisplayClass::render;
@@ -76,9 +74,10 @@ void DisplayClass::renderScene(unsigned long delta) {
// glRotatef(-angle*5, 1.0, 1.0, 1.0);
- static Temparray temp(20, x, y, z);
- triangles=temp.getTriangles();
- temp.calcTemp();
+// static Temparray temp(20, x, y, z);
+ static House house(20, x, y, z, 70, 300, 53.55, 0.82, 2.82, 0.0047, 40, 45, 1900, 3, 11500);
+ triangles=house.getTriangles();
+ house.controller();
//vmml::mat4f transform, inverseTransform;
//glGetFloatv(GL_MODELVIEW_MATRIX, transform.array);
diff --git a/DisplayClass.h b/DisplayClass.h
index 175a1dc..3ec767b 100644
--- a/DisplayClass.h
+++ b/DisplayClass.h
@@ -2,8 +2,10 @@
#define _DISPLAYCLASS_H_
//#include "Cubehole.h"
-#include "Temparray.h"
+//#include "Temparray.h"
#include "BSPTree.h"
+#include "gl.h"
+#include "House.h"
class DisplayClass
{
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;
}
diff --git a/House.h b/House.h
index 68eb237..aab0883 100644
--- a/House.h
+++ b/House.h
@@ -19,7 +19,8 @@ class House
float roofangle0, float watthoursperhuman, int humans, int heaterenergy0);
std::list<Triangle> getTriangles(){
- std::list<Triangle> triangles = temp.getTriangles();
+ std::list<Triangle> triangles;
+ triangles = temp.getTriangles();
return triangles;
}
@@ -28,12 +29,14 @@ class House
void calcdiff();
void calcneededenergy();
void calccollectoroutput(int day, int time, int month);
+ void calcprobeinput(int day, int time, int months);
+ void controller();
private:
Temparray temp;
Sun sun;
float collectortemp, latitude, radiation, eta0, k1, k2, watthoursperhuman, collectorarea,
- heaterenergy, roofangle, collectoroutput;
+ heaterenergy, roofangle, collectoroutput, probeinput;
float tempinside[24], tempoutside[12][24], efficiencyflat[100], efficiencyvacuum[100],
anglecorrectionflat[91], anglecorrectiontransversal[91],
anglecorrectionlongitudinal[91], tempdifference[12][24], neededenergy[12][24];
diff --git a/Temparray.cpp b/Temparray.cpp
index 83f91f0..d2379f2 100644
--- a/Temparray.cpp
+++ b/Temparray.cpp
@@ -55,6 +55,7 @@ void Temparray::calcTemp(){
float meterperunit = 3.0;
float width, height, depth, innerwidth, innerdepth;
float width2, height2, depth2, innerwidth2, innerdepth2;
+ float loadableenergy, unloadableenergy;
for(int i = 0; i < sx; ++i) {
for(int j = 0; j < sy; ++j) {
@@ -139,7 +140,10 @@ void Temparray::calcTemp(){
if(m % 2 == 1)capacity = specificcapacity *((((width - innerwidth)/2)*
((depth + innerdepth)/2)*height)
/ 0.9 * meterperunit);
-
+
+ loadableenergy = (probetemp - temperatureold(i, j, k, l, m))/thermalresistance/10;
+ unloadableenergy = (temperatureold(i, j, k, l, m)-21.5)/thermalresistance/10;
+
tau12 = capacity * thermalresistance;
temperaturenew(i, j, k, l, m) =
diff --git a/Temparray.h b/Temparray.h
index 67cb73b..15eb696 100644
--- a/Temparray.h
+++ b/Temparray.h
@@ -23,13 +23,14 @@ class Temparray
std::list<Triangle> getTriangles();
void coloring();
- void setprobetemp(float t){probetemp = t;};
+ void setprobetemp(float t){probetemp = t;}
+ void setinput(float input0){input = input0;}
private:
float *temparrayold, *temparraynew;
Cubehole *cubearray;
int sx, sy, sz;
- float averagetemp, earthtemp, probetemp;
+ float averagetemp, earthtemp, probetemp, input;
Cubehole& cubehole(int x, int y, int z, int line) {
return cubearray[x*sy*sz*6 + y*sz*6 + z*6 + line];
@@ -55,8 +56,6 @@ class Temparray
}
}
earthtemp=8;
- temperatureold(2, 2, 2, 2, 2) = 90;
- temperaturenew(2, 2, 2, 2, 2) = 90;
}
};