diff options
-rw-r--r-- | DisplayClass.cpp | 2 | ||||
-rw-r--r-- | House.cpp | 7 | ||||
-rw-r--r-- | House.h | 23 | ||||
-rw-r--r-- | Temparray.cpp | 149 | ||||
-rw-r--r-- | Temparray.h | 1 | ||||
-rw-r--r-- | main.cpp | 2 |
6 files changed, 124 insertions, 60 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp index b04c11c..8d79e74 100644 --- a/DisplayClass.cpp +++ b/DisplayClass.cpp @@ -68,7 +68,7 @@ void DisplayClass::renderScene(unsigned long delta) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Clean up matrix - glTranslatef(0.0, 0.0, -15.0); // Then set up transformation + glTranslatef(0.0, 0.0, -10.0); // Then set up transformation glRotatef(angle, 0.0, 1.0, 0.0); glRotatef(angle*2, 1.0, 0.0, 0.0); glRotatef(angle*3, 0.0, 0.0, 1.0); diff --git a/House.cpp b/House.cpp new file mode 100644 index 0000000..d6d28c9 --- /dev/null +++ b/House.cpp @@ -0,0 +1,7 @@ +#include "House.h" + +House::House (float inittemp0, int earthx0, int earthy0, int earthz0, float collectortemp0): + collectortemp(collectortemp0) { + Temparray temp0(inittemp0, earthx0, earthy0, earthz0); + temp = temp0; +} @@ -0,0 +1,23 @@ +#ifndef _HOUSE_H_ +#define _HOUSE_H_ + +#include "Temparray.h" +#include "Triangle.h" +#include <list> +#include <math.h> + +class House +{ + public: + House(float inittemp0, int earthx0, int earthy0, int earthz0, float collectortemp0); + std::list<Triangle> getTriangles(){ + std::list<Triangle> triangles = temp.getTriangles(); + return triangles; + } + + private: + Temparray temp; + float collectortemp; +}; + +#endif /* _HOUSE_H_ */ diff --git a/Temparray.cpp b/Temparray.cpp index 798bbc5..6385434 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -51,12 +51,10 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){ void Temparray::calcTemp(){ float conductivity = 0.7, specificcapacity = 1513; - float areasmall, area, areabig, distance, capacity, capacity2, capacity3, volume, thermalresistance, - thermalresistance2, tau12, tau21, tau13, tau31; + float areasmall, area, areabig, distance, capacity, capacity2, volume, thermalresistance, tau12, tau21; float meterperunit = 3.0; float width, height, depth, innerwidth, innerdepth; float width2, height2, depth2, innerwidth2, innerdepth2; - float width3, height3, depth3, innerwidth3, innerdepth3; for(int i = 0; i < sx; ++i) { for(int j = 0; j < sy; ++j) { @@ -65,63 +63,43 @@ void Temparray::calcTemp(){ for(int m = 0; m < 4; ++m) { width = cubehole(i, j, k, l).getWidth(); width2 = cubehole(i, j, k, l-1).getWidth(); - if(l!=5)width3 = cubehole(i, j, k, l+1).getWidth(); height = cubehole(i, j, k, l).getHeight(); height2 = cubehole(i, j, k, l-1).getHeight(); - if(l!=5)height3 = cubehole(i, j, k, l+1).getHeight(); depth = cubehole(i, j, k, l).getDepth(); depth2 = cubehole(i, j, k, l-1).getDepth(); - if(l!=5)depth3 = cubehole(i, j, k, l+1).getDepth(); innerwidth = cubehole(i, j, k, l).getInnerWidth(); innerwidth2 = cubehole(i, j, k, l-1).getInnerWidth(); - if(l!=5)innerwidth3 = cubehole(i, j, k, l+1).getInnerWidth(); innerdepth = cubehole(i, j, k, l).getInnerDepth(); innerdepth2 = cubehole(i, j, k, l-1).getInnerDepth(); - if(l!=5)innerdepth3 = cubehole(i, j, k, l+1).getInnerDepth(); if(m % 2 == 0) { - if(l!=5)areasmall = (((width3 + innerwidth3)/2)*height3) / 0.9 * meterperunit; area = (((width + innerwidth)/2)*height) / 0.9 * meterperunit; areabig = (((width2 + innerwidth2)/2)*height2) / 0.9 * meterperunit; thermalresistance = ((depth2 / 2 - (depth2 - innerdepth2)/4) - (depth / 2 - (depth - innerdepth)/4)) / 0.9 * meterperunit / (conductivity * ((area + areabig) / 2)); - if(l!=5)thermalresistance2 = ((depth / 2 - (depth - innerdepth)/4)- - (depth3 / 2 - (depth3 - innerdepth3)/4)) / 0.9 * meterperunit / - (conductivity * ((area + areasmall) / 2)); capacity = specificcapacity *((((depth - innerdepth)/2)*((width + innerwidth)/2)* height)/0.9*meterperunit); capacity2 = specificcapacity *((((depth2 - innerdepth2)/2)*((width2 + innerwidth2)/2)* height2)/0.9*meterperunit); - if(l!=5)capacity3 = specificcapacity *((((depth3 - innerdepth3)/2)*((width3 + innerwidth3)/2)* - height3)/0.9*meterperunit); } else if(m % 2 == 1) { - if(l!=5)areasmall = (((depth3 + innerdepth3)/2)*height3) / 0.9 * meterperunit; area = (((depth + innerdepth)/2)*height) / 0.9 * meterperunit; areabig = (((depth2 + innerdepth2)/2)*height2) / 0.9 * meterperunit; thermalresistance = ((width2 / 2 - (width2 - innerwidth2)/4) - (width / 2 - (width - innerwidth)/4)) / 0.9 * meterperunit / (conductivity * ((area + areabig) / 2)); - if(l!=5)thermalresistance2 = (width3 / 2 - (width3 - innerwidth3)/4) - - (width / 2 - (width - innerwidth)/4) / 0.9 * meterperunit / - (conductivity * ((area + areasmall) / 2)); - capacity = specificcapacity *((((depth - innerdepth)/2)*((width + innerwidth)/2)* + capacity = specificcapacity *((((depth + innerdepth)/2)*((width - innerwidth)/2)* height)/0.9*meterperunit); - capacity2 = specificcapacity *((((depth2 - innerdepth2)/2)*((width2 + innerwidth2)/2)* + capacity2 = specificcapacity *((((depth2 + innerdepth2)/2)*((width2 - innerwidth2)/2)* height2)/0.9*meterperunit); - if(l!=5) - capacity3 = specificcapacity *((((depth3 - innerdepth3)/2)*((width3 + innerwidth3)/2)* - height3)/0.9*meterperunit); } tau12 = capacity * thermalresistance; tau21 = capacity2 * thermalresistance; - if(l!=5)tau13 = capacity * thermalresistance2; - if(l!=5)tau31 = capacity3 * thermalresistance2; temperaturenew(i, j, k, l, m) = temperaturenew(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - @@ -129,14 +107,6 @@ void Temparray::calcTemp(){ temperaturenew(i, j, k, l-1, m) = temperaturenew(i, j, k, l-1, m) + ((temperatureold(i, j, k, l, m) - temperatureold(i, j, k, l-1, m))*(1-exp(-(1/tau21)))); - - if(l!=5)temperaturenew(i, j, k, l, m) = - temperaturenew(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - - temperatureold(i, j, k, l+1, m))*(1-exp(-(1/tau13)))); - if(l!=5)temperaturenew(i, j, k, l+1, m) = - temperaturenew(i, j, k, l+1, m) + ((temperatureold(i, j, k, l, m) - - temperatureold(i, j, k, l+1, m))*(1-exp(-(1/tau31)))); - } } } @@ -152,6 +122,47 @@ void Temparray::calcTemp(){ depth = cubehole(i, j, k, l).getDepth(); innerwidth = cubehole(i, j, k, l).getInnerWidth(); innerdepth = cubehole(i, j, k, l).getInnerDepth(); + if(j > 0) { + width2 = cubehole(i, j-1, k, l).getWidth(); + height2 = cubehole(i, j-1, k, l).getHeight(); + depth2 = cubehole(i, j-1, k, l).getDepth(); + innerwidth2 = cubehole(i, j-1, k, l).getInnerWidth(); + innerdepth2 = cubehole(i, j-1, k, l).getInnerDepth(); + + if(m % 2 == 0) { + area = (((width + innerwidth)/2) * ((depth-innerdepth)/2)) / 0.9 * meterperunit; + areabig = (((width2 + innerwidth2)/2) * ((depth2-innerdepth2)/2)) / 0.9 * meterperunit; + + thermalresistance = (height/2+height2/2) / 0.9 * meterperunit / + (conductivity * ((area + areabig) / 2)); + + capacity = specificcapacity *((((depth - innerdepth)/2)*((width + innerwidth)/2)* + height)/0.9*meterperunit); + capacity2 = specificcapacity *((((depth2 - innerdepth2)/2)*((width2 + innerwidth2)/2)* + height2)/0.9*meterperunit); + } + else if(m % 2 == 1) { + area = (((depth + innerdepth)/2) * ((width-innerwidth)/2)) / 0.9 * meterperunit; + areabig = (((depth2 + innerdepth2)/2) * ((width2-innerwidth2)/2)) / 0.9 * meterperunit; + + thermalresistance = (height/2+height2/2) / 0.9 * meterperunit / + (conductivity * ((area + areabig) / 2)); + + capacity = specificcapacity *((((depth + innerdepth)/2)*((width - innerwidth)/2)* + height)/0.9*meterperunit); + capacity2 = specificcapacity *((((depth2 + innerdepth2)/2)*((width2 - innerwidth2)/2)* + height2)/0.9*meterperunit); + } + tau12 = capacity * thermalresistance; + tau21 = capacity2 * thermalresistance; + + temperaturenew(i, j, k, l, m) = + temperaturenew(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - + temperatureold(i, j, k, l-1, m))*(1-exp(-(1/tau12)))); + temperaturenew(i, j, k, l-1, m) = + temperaturenew(i, j, k, l-1, m) + ((temperatureold(i, j, k, l, m) - + temperatureold(i, j, k, l-1, m))*(1-exp(-(1/tau21)))); + } if(m == 0) { area = (sqrt(pow((depth-innerdepth)/2, 2) + pow((width-innerwidth)/2, 2))* height) / @@ -165,18 +176,12 @@ void Temparray::calcTemp(){ height)/0.9*meterperunit); capacity2 = specificcapacity *((((width - innerwidth)/2)*((depth + innerdepth)/2)* height)/0.9*meterperunit); - + tau12 = capacity * thermalresistance; tau21 = capacity2 * thermalresistance; temperaturenew(i, j, k, l, m) = temperaturenew(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - - temperatureold(i, j, k, l, 3))*(1-exp(-(1/tau12)))); - temperaturenew(i, j, k, l, 3) = - temperaturenew(i, j, k, l, 3) + ((temperatureold(i, j, k, l, m) - - temperatureold(i, j, k, l, 3))*(1-exp(-(1/tau21)))); - temperaturenew(i, j, k, l, m) = - temperaturenew(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - temperatureold(i, j, k, l, 1))*(1-exp(-(1/tau12)))); temperaturenew(i, j, k, l, 1) = temperaturenew(i, j, k, l, 1) + ((temperatureold(i, j, k, l, m) - @@ -200,12 +205,6 @@ void Temparray::calcTemp(){ temperaturenew(i, j, k, l, 1) = temperaturenew(i, j, k, l, 1) - ((temperatureold(i, j, k, l, 1) - - temperatureold(i, j, k, l, 0))*(1-exp(-(1/tau12)))); - temperaturenew(i, j, k, l, 0) = - temperaturenew(i, j, k, l, 0) + ((temperatureold(i, j, k, l, 1) - - temperatureold(i, j, k, l, 0))*(1-exp(-(1/tau21)))); - temperaturenew(i, j, k, l, 1) = - temperaturenew(i, j, k, l, 1) - ((temperatureold(i, j, k, l, 1) - temperatureold(i, j, k, l, 2))*(1-exp(-(1/tau12)))); temperaturenew(i, j, k, l, 2) = temperaturenew(i, j, k, l, 2) + ((temperatureold(i, j, k, l, 1) - @@ -229,12 +228,6 @@ void Temparray::calcTemp(){ temperaturenew(i, j, k, l, 2) = temperaturenew(i, j, k, l, 2) - ((temperatureold(i, j, k, l, 2) - - temperatureold(i, j, k, l, 1))*(1-exp(-(1/tau12)))); - temperaturenew(i, j, k, l, 1) = - temperaturenew(i, j, k, l, 1) + ((temperatureold(i, j, k, l, 2) - - temperatureold(i, j, k, l, 1))*(1-exp(-(1/tau21)))); - temperaturenew(i, j, k, l, 2) = - temperaturenew(i, j, k, l, 2) - ((temperatureold(i, j, k, l, 2) - temperatureold(i, j, k, l, 3))*(1-exp(-(1/tau12)))); temperaturenew(i, j, k, l, 3) = temperaturenew(i, j, k, l, 3) + ((temperatureold(i, j, k, l, 2) - @@ -258,12 +251,6 @@ void Temparray::calcTemp(){ temperaturenew(i, j, k, l, 3) = temperaturenew(i, j, k, l, 3) - ((temperatureold(i, j, k, l, 3) - - temperatureold(i, j, k, l, 2))*(1-exp(-(1/tau12)))); - temperaturenew(i, j, k, l, 2) = - temperaturenew(i, j, k, l, 2) + ((temperatureold(i, j, k, l, 3) - - temperatureold(i, j, k, l, 2))*(1-exp(-(1/tau21)))); - temperaturenew(i, j, k, l, 3) = - temperaturenew(i, j, k, l, 3) - ((temperatureold(i, j, k, l, 3) - temperatureold(i, j, k, l, 0))*(1-exp(-(1/tau12)))); temperaturenew(i, j, k, l, 0) = temperaturenew(i, j, k, l, 0) + ((temperatureold(i, j, k, l, 3) - @@ -271,6 +258,52 @@ void Temparray::calcTemp(){ } } } + if(i > 0) { + width = cubehole(i, j, k, 0).getWidth(); + height = cubehole(i, j, k, 0).getHeight(); + depth = cubehole(i, j, k, 0).getDepth(); + innerwidth = cubehole(i, j, k, 0).getInnerWidth(); + innerdepth = cubehole(i, j, k, 0).getInnerDepth(); + + area = (((depth + innerdepth)/2)*height) / 0.9 * meterperunit; + + thermalresistance = ((width - innerwidth)/2) / 0.9 * meterperunit / + (conductivity * area); + + capacity = specificcapacity *((((depth - innerdepth)/2)*((width + innerwidth)/2)* + height)/0.9*meterperunit); + tau12 = capacity * thermalresistance; + + temperaturenew(i, j, k, 0, 3) = + temperaturenew(i, j, k, 0, 3) - ((temperatureold(i, j, k, 0, 3) - + temperatureold(i-1, j, k, 0, 1))*(1-exp(-(1/tau12)))); + temperaturenew(i-1, j, k, 0, 1) = + temperaturenew(i-1, j, k, 0, 1) + ((temperatureold(i, j, k, 0, 3) - + temperatureold(i-1, j, k, 0, 1))*(1-exp(-(1/tau12)))); + } + if(k > 0) { + width = cubehole(i, j, k, 0).getWidth(); + height = cubehole(i, j, k, 0).getHeight(); + depth = cubehole(i, j, k, 0).getDepth(); + innerwidth = cubehole(i, j, k, 0).getInnerWidth(); + innerdepth = cubehole(i, j, k, 0).getInnerDepth(); + + area = (((width + innerwidth)/2)*height) / 0.9 * meterperunit; + + thermalresistance = ((depth - innerdepth)/2) / 0.9 * meterperunit / + (conductivity * area); + + capacity = specificcapacity *((((depth - innerdepth)/2)*((width + innerwidth)/2)* + height)/0.9*meterperunit); + tau12 = capacity * thermalresistance; + + temperaturenew(i, j, k, 0, 0) = + temperaturenew(i, j, k, 0, 0) - ((temperatureold(i, j, k, 0, 0) - + temperatureold(i-1, j, k-1, 0, 2))*(1-exp(-(1/tau12)))); + temperaturenew(i, j, k-1, 0, 2) = + temperaturenew(i, j, k-1, 0, 2) + ((temperatureold(i, j, k, 0, 0) - + temperatureold(i, j, k-1, 0, 2))*(1-exp(-(1/tau12)))); + } } } } diff --git a/Temparray.h b/Temparray.h index 921de69..24cb95d 100644 --- a/Temparray.h +++ b/Temparray.h @@ -44,6 +44,7 @@ class Temparray for(int k=0; k<sz; k++){ for(int l=0; l<6; l++){ for(int m=0; m<4; m++){temperatureold(i, j, k, l, m)=temperaturenew(i, j, k, l, m);}}}}}} + void tempInit(float temp0, int x0, int y0, int z0){ for(int i=0; i<x0; i++){ for(int j=0; j<y0; j++){ @@ -12,7 +12,7 @@ #endif //#define MIN_FRAME_DELTA 16 -#define MIN_FRAME_DELTA 1000 +#define MIN_FRAME_DELTA 250 #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 640 |