From 0c90985b20e3d39d6d761614f4c73e0eefc54170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Ri=DF?= Date: Mon, 18 Jan 2010 23:20:00 +0100 Subject: Temparray verfeinert/House.cpp und House.h angefangen. --- Temparray.cpp | 149 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 58 deletions(-) (limited to 'Temparray.cpp') 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,16 +176,10 @@ 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)))); @@ -198,12 +203,6 @@ void Temparray::calcTemp(){ tau12 = capacity * thermalresistance; tau21 = capacity2 * thermalresistance; - 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)))); @@ -227,12 +226,6 @@ void Temparray::calcTemp(){ tau12 = capacity * thermalresistance; tau21 = capacity2 * thermalresistance; - 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)))); @@ -256,12 +249,6 @@ void Temparray::calcTemp(){ tau12 = capacity * thermalresistance; tau21 = capacity2 * thermalresistance; - 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)))); @@ -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)))); + } } } } -- cgit v1.2.3