From f53795458ddf252d08979820a98697cca9327834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Ri=C3=9F?= Date: Thu, 4 Feb 2010 19:09:28 +0100 Subject: ungewolltes schauspiel... --- House.cpp | 1 + Temparray.cpp | 95 ++++++++++++++++++++++++++++++++++++++++------------------- Temparray.h | 2 +- main.cpp | 4 +-- 4 files changed, 68 insertions(+), 34 deletions(-) diff --git a/House.cpp b/House.cpp index 9ea0a1e..c5dc37b 100644 --- a/House.cpp +++ b/House.cpp @@ -480,6 +480,7 @@ void House::controller(){ ++time; if(time > 23){ + std::cerr << day << std::endl; time = 0; ++day; } diff --git a/Temparray.cpp b/Temparray.cpp index d2379f2..f2c8fb8 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -113,6 +113,65 @@ void Temparray::calcTemp(){ } } } + for(int h = 0; h < 10; ++h) { + for(int i = 0; i < sx; ++i) { + for(int j = 0; j < sy; ++j) { + for(int k = 0; k < sz; ++k) { + for(int l = 0; l < 6; ++l) { + for(int m = 0; m < 4; m++) { + width = cubehole(i, j, k, l).getWidth(); + height = cubehole(i, j, k, l).getHeight(); + depth = cubehole(i, j, k, l).getDepth(); + innerwidth = cubehole(i, j, k, l).getInnerWidth(); + innerdepth = cubehole(i, j, k, l).getInnerDepth(); + + if(m % 2 == 0)area = (((depth - innerdepth)/2)*((width + innerwidth)/2)) + / 0.9 * meterperunit; + if(m % 2 == 1)area = (((width - innerwidth)/2)*((depth + innerdepth)/2)) + / 0.9 * meterperunit; + + if(m % 2 == 0)thermalresistance = ((depth - innerdepth)/2) + /0.9 * meterperunit /(conductivity * area); + if(m % 2 == 1)thermalresistance = ((width - innerwidth)/2) + /0.9 * meterperunit /(conductivity * area); + + if(m % 2 == 0)capacity = specificcapacity *((((depth - innerdepth)/2)* + ((width + innerwidth)/2)*height) + / 0.9 * meterperunit); + 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; + + if(input>=0){ + if(loadableenergy <= 0) + inputpower = 0; + else if (input >= loadableenergy) { + inputpower = loadableenergy; + input -= loadableenergy; + } + else if (input <= loadableenergy) { + inputpower = input; + input = 0; + } + if(inputpower > 0) { + factor = inputpower/loadableenergy; + temperaturenew(i, j, k, l, m) = + temperaturenew(i, j, k, l, m) + (probetemp-temperatureold(i, j, k, l, m)) + *thermalresistance*factor*(1-exp(-(1/tau12))); + } + } + } + } + } + } + } + } + for(int i = 0; i < sx; ++i) { for(int j = 0; j < sy; ++j) { for(int k = 0; k < sz; ++k) { @@ -124,32 +183,6 @@ void Temparray::calcTemp(){ innerwidth = cubehole(i, j, k, l).getInnerWidth(); innerdepth = cubehole(i, j, k, l).getInnerDepth(); - if(m % 2 == 0)area = (((depth - innerdepth)/2)*((width + innerwidth)/2)) - / 0.9 * meterperunit; - if(m % 2 == 1)area = (((width - innerwidth)/2)*((depth + innerdepth)/2)) - / 0.9 * meterperunit; - - if(m % 2 == 0)thermalresistance = ((depth - innerdepth)/2) - /0.9 * meterperunit /(conductivity * area); - if(m % 2 == 1)thermalresistance = ((width - innerwidth)/2) - /0.9 * meterperunit /(conductivity * area); - - if(m % 2 == 0)capacity = specificcapacity *((((depth - innerdepth)/2)* - ((width + innerwidth)/2)*height) - / 0.9 * meterperunit); - 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) = - temperaturenew(i, j, k, l, m) - ((temperatureold(i, j, k, l, m) - probetemp) - *(1-exp(-(1/tau12)))); - if(j > 0) { width2 = cubehole(i, j-1, k, l).getWidth(); height2 = cubehole(i, j-1, k, l).getHeight(); @@ -405,7 +438,7 @@ void Temparray::calcTemp(){ mergetemperature(); coloring(); // std::cerr << temperaturenew(2, 2, 2, 1, 2) << std::endl; -// std::cerr << temperaturenew(2, 2, 2, 2, 2) << std::endl; + std::cerr << temperaturenew(2, 2, 2, 2, 2) << std::endl; // std::cerr << temperaturenew(2, 2, 2, 3, 2) << "\n" << std::endl; // std::cerr << " " << temperatureold(2, 2, 2, 1, 2) << std::endl; // std::cerr << temperatureold(2, 2, 2, 2, 1) << " " << temperatureold(2, 2, 2, 2, 2) << " " << temperatureold(2, 2, 2, 2, 3) << std::endl; @@ -435,11 +468,11 @@ void Temparray::coloring() { for(int k=0; k= 25 ) b[m]=0; - else b[m]=(25-temperatureold(i, j, k, l, m))/25; - g[m]=fabs((25-temperatureold(i, j, k, l, m))/25); + if(temperatureold(i, j, k, l, m) >= 50 ) b[m]=0; + else b[m]=1/(50-temperatureold(i, j, k, l, m)); + g[m]=fabs(1/(50-temperatureold(i, j, k, l, m))); if(temperatureold(i, j, k, l, m) <= 25 ) r[m]=0; - else r[m]=(100-temperatureold(i, j, k, l, m))/25; + else r[m]=1/(100-temperatureold(i, j, k, l, m)); } cubehole(i, j, k, l).setColor(vmml::vec4f(r[0], g[0], b[0], 1.0), vmml::vec4f(r[1], g[1], b[1], 1.0), diff --git a/Temparray.h b/Temparray.h index 15eb696..ac96c04 100644 --- a/Temparray.h +++ b/Temparray.h @@ -30,7 +30,7 @@ class Temparray float *temparrayold, *temparraynew; Cubehole *cubearray; int sx, sy, sz; - float averagetemp, earthtemp, probetemp, input; + float averagetemp, earthtemp, probetemp, input, inputpower, factor; Cubehole& cubehole(int x, int y, int z, int line) { return cubearray[x*sy*sz*6 + y*sz*6 + z*6 + line]; diff --git a/main.cpp b/main.cpp index 45a9c88..f2c7ddb 100644 --- a/main.cpp +++ b/main.cpp @@ -11,8 +11,8 @@ #include #endif -//#define MIN_FRAME_DELTA 16 -#define MIN_FRAME_DELTA 41 +#define MIN_FRAME_DELTA 16 +//#define MIN_FRAME_DELTA 41 #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 640 -- cgit v1.2.3