diff options
-rw-r--r-- | House.cpp | 450 | ||||
-rw-r--r-- | House.h | 20 | ||||
-rw-r--r-- | Sun.h | 11 | ||||
-rw-r--r-- | Temparray.cpp | 44 | ||||
-rw-r--r-- | Temparray.h | 4 |
5 files changed, 319 insertions, 210 deletions
@@ -2,14 +2,17 @@ House::House(float inittemp0, int earthx0, int earthy0, int earthz0, float collectortemp0, float radiation0, float latitude0, float eta00, float k10, float k20, float collectorarea0, - float watthoursperhuman0, int humans0): + float roofangle0, float watthoursperhuman0, int humans0, int heaterenergy0): collectortemp(collectortemp0), latitude(latitude0), radiation(radiation0), eta0(eta00), k1(k10), k2(k20), watthoursperhuman(watthoursperhuman0), humans(humans0), - collectorarea(collectorarea0){ + collectorarea(collectorarea0), heaterenergy(heaterenergy0), roofangle(roofangle0){ Temparray temp0(inittemp0, earthx0, earthy0, earthz0); + Sun sun0(latitude); + sun = sun0; temp = temp0; calcefficiency(); calctemp(); + calcneededenergy(); } void House::calcefficiency() { @@ -139,196 +142,196 @@ void House::calcefficiency() { } efficiencyvacuum[i] = a*(i-ioffset)+b; } - anglecorrectionfactortransversal[0] = 1; - anglecorrectionfactortransversal[1] = 0.998; - anglecorrectionfactortransversal[2] = 0.996; - anglecorrectionfactortransversal[3] = 0.994; - anglecorrectionfactortransversal[4] = 0.992; - anglecorrectionfactortransversal[5] = 0.99; - anglecorrectionfactortransversal[6] = 0.988; - anglecorrectionfactortransversal[7] = 0.986; - anglecorrectionfactortransversal[8] = 0.984; - anglecorrectionfactortransversal[9] = 0.982; - anglecorrectionfactortransversal[10] = 0.98; - anglecorrectionfactortransversal[11] = 0.98; - anglecorrectionfactortransversal[12] = 0.98; - anglecorrectionfactortransversal[13] = 0.98; - anglecorrectionfactortransversal[14] = 0.98; - anglecorrectionfactortransversal[15] = 0.98; - anglecorrectionfactortransversal[16] = 0.982; - anglecorrectionfactortransversal[17] = 0.984; - anglecorrectionfactortransversal[18] = 0.986; - anglecorrectionfactortransversal[19] = 0.988; - anglecorrectionfactortransversal[20] = 0.99; - anglecorrectionfactortransversal[21] = 0.992; - anglecorrectionfactortransversal[22] = 0.994; - anglecorrectionfactortransversal[23] = 0.996; - anglecorrectionfactortransversal[24] = 0.998; - for(int i=25; i<61; i++) anglecorrectionfactortransversal[i] = 1; - anglecorrectionfactortransversal[61] = 1.003; - anglecorrectionfactortransversal[62] = 1.006; - anglecorrectionfactortransversal[63] = 1.009; - anglecorrectionfactortransversal[64] = 1.012; - anglecorrectionfactortransversal[65] = 1.015; - anglecorrectionfactortransversal[66] = 1.022; - anglecorrectionfactortransversal[67] = 1.029; - anglecorrectionfactortransversal[68] = 1.036; - anglecorrectionfactortransversal[69] = 1.043; - anglecorrectionfactortransversal[70] = 1.05; - anglecorrectionfactortransversal[71] = 1.07; - anglecorrectionfactortransversal[72] = 1.09; - anglecorrectionfactortransversal[73] = 1.11; - anglecorrectionfactortransversal[74] = 1.13; - anglecorrectionfactortransversal[75] = 1.15; - anglecorrectionfactortransversal[76] = 1.175; - anglecorrectionfactortransversal[77] = 1.205; - anglecorrectionfactortransversal[78] = 1.240; - anglecorrectionfactortransversal[79] = 1.280; - anglecorrectionfactortransversal[80] = 1.285; - anglecorrectionfactortransversal[81] = 1.265; - anglecorrectionfactortransversal[82] = 1.20; - anglecorrectionfactortransversal[83] = 1.07; - anglecorrectionfactortransversal[84] = 0.95; - anglecorrectionfactortransversal[85] = 0.8; - anglecorrectionfactortransversal[86] = 0.64; - anglecorrectionfactortransversal[87] = 0.48; - anglecorrectionfactortransversal[88] = 0.32; - anglecorrectionfactortransversal[89] = 0.16; - anglecorrectionfactortransversal[90] = 0; + anglecorrectiontransversal[0] = 1; + anglecorrectiontransversal[1] = 0.998; + anglecorrectiontransversal[2] = 0.996; + anglecorrectiontransversal[3] = 0.994; + anglecorrectiontransversal[4] = 0.992; + anglecorrectiontransversal[5] = 0.99; + anglecorrectiontransversal[6] = 0.988; + anglecorrectiontransversal[7] = 0.986; + anglecorrectiontransversal[8] = 0.984; + anglecorrectiontransversal[9] = 0.982; + anglecorrectiontransversal[10] = 0.98; + anglecorrectiontransversal[11] = 0.98; + anglecorrectiontransversal[12] = 0.98; + anglecorrectiontransversal[13] = 0.98; + anglecorrectiontransversal[14] = 0.98; + anglecorrectiontransversal[15] = 0.98; + anglecorrectiontransversal[16] = 0.982; + anglecorrectiontransversal[17] = 0.984; + anglecorrectiontransversal[18] = 0.986; + anglecorrectiontransversal[19] = 0.988; + anglecorrectiontransversal[20] = 0.99; + anglecorrectiontransversal[21] = 0.992; + anglecorrectiontransversal[22] = 0.994; + anglecorrectiontransversal[23] = 0.996; + anglecorrectiontransversal[24] = 0.998; + for(int i=25; i<61; i++) anglecorrectiontransversal[i] = 1; + anglecorrectiontransversal[61] = 1.003; + anglecorrectiontransversal[62] = 1.006; + anglecorrectiontransversal[63] = 1.009; + anglecorrectiontransversal[64] = 1.012; + anglecorrectiontransversal[65] = 1.015; + anglecorrectiontransversal[66] = 1.022; + anglecorrectiontransversal[67] = 1.029; + anglecorrectiontransversal[68] = 1.036; + anglecorrectiontransversal[69] = 1.043; + anglecorrectiontransversal[70] = 1.05; + anglecorrectiontransversal[71] = 1.07; + anglecorrectiontransversal[72] = 1.09; + anglecorrectiontransversal[73] = 1.11; + anglecorrectiontransversal[74] = 1.13; + anglecorrectiontransversal[75] = 1.15; + anglecorrectiontransversal[76] = 1.175; + anglecorrectiontransversal[77] = 1.205; + anglecorrectiontransversal[78] = 1.240; + anglecorrectiontransversal[79] = 1.280; + anglecorrectiontransversal[80] = 1.285; + anglecorrectiontransversal[81] = 1.265; + anglecorrectiontransversal[82] = 1.20; + anglecorrectiontransversal[83] = 1.07; + anglecorrectiontransversal[84] = 0.95; + anglecorrectiontransversal[85] = 0.8; + anglecorrectiontransversal[86] = 0.64; + anglecorrectiontransversal[87] = 0.48; + anglecorrectiontransversal[88] = 0.32; + anglecorrectiontransversal[89] = 0.16; + anglecorrectiontransversal[90] = 0; - for(int i=0; i<25; ++i) anglecorrectionfactorlongitudinal[i] = 1; - anglecorrectionfactorlongitudinal[26] = 0.999; - anglecorrectionfactorlongitudinal[27] = 0.998; - anglecorrectionfactorlongitudinal[28] = 0.997; - anglecorrectionfactorlongitudinal[29] = 0.996; - anglecorrectionfactorlongitudinal[30] = 0.995; - anglecorrectionfactorlongitudinal[31] = 0.992; - anglecorrectionfactorlongitudinal[32] = 0.989; - anglecorrectionfactorlongitudinal[33] = 0.986; - anglecorrectionfactorlongitudinal[34] = 0.983; - anglecorrectionfactorlongitudinal[35] = 0.98; - anglecorrectionfactorlongitudinal[36] = 0.978; - anglecorrectionfactorlongitudinal[37] = 0.976; - anglecorrectionfactorlongitudinal[38] = 0.974; - anglecorrectionfactorlongitudinal[39] = 0.972; - anglecorrectionfactorlongitudinal[40] = 0.97; - anglecorrectionfactorlongitudinal[41] = 0.968; - anglecorrectionfactorlongitudinal[42] = 0.966; - anglecorrectionfactorlongitudinal[43] = 0.964; - anglecorrectionfactorlongitudinal[44] = 0.962; - anglecorrectionfactorlongitudinal[45] = 0.96; - anglecorrectionfactorlongitudinal[46] = 0.958; - anglecorrectionfactorlongitudinal[47] = 0.956; - anglecorrectionfactorlongitudinal[48] = 0.954; - anglecorrectionfactorlongitudinal[49] = 0.952; - anglecorrectionfactorlongitudinal[50] = 0.95; - anglecorrectionfactorlongitudinal[51] = 0.948; - anglecorrectionfactorlongitudinal[52] = 0.946; - anglecorrectionfactorlongitudinal[53] = 0.944; - anglecorrectionfactorlongitudinal[54] = 0.942; - anglecorrectionfactorlongitudinal[55] = 0.94; - anglecorrectionfactorlongitudinal[56] = 0.938; - anglecorrectionfactorlongitudinal[57] = 0.936; - anglecorrectionfactorlongitudinal[58] = 0.934; - anglecorrectionfactorlongitudinal[59] = 0.932; - anglecorrectionfactorlongitudinal[60] = 0.93; - anglecorrectionfactorlongitudinal[61] = 0.922; - anglecorrectionfactorlongitudinal[62] = 0.914; - anglecorrectionfactorlongitudinal[63] = 0.906; - anglecorrectionfactorlongitudinal[64] = 0.898; - anglecorrectionfactorlongitudinal[65] = 0.89; - anglecorrectionfactorlongitudinal[66] = 0.88; - anglecorrectionfactorlongitudinal[67] = 0.87; - anglecorrectionfactorlongitudinal[68] = 0.86; - anglecorrectionfactorlongitudinal[69] = 0.85; - anglecorrectionfactorlongitudinal[70] = 0.84; - anglecorrectionfactorlongitudinal[71] = 0.824; - anglecorrectionfactorlongitudinal[72] = 0.808; - anglecorrectionfactorlongitudinal[73] = 0.792; - anglecorrectionfactorlongitudinal[74] = 0.776; - anglecorrectionfactorlongitudinal[75] = 0.76; - anglecorrectionfactorlongitudinal[76] = 0.735; - anglecorrectionfactorlongitudinal[77] = 0.71; - anglecorrectionfactorlongitudinal[78] = 0.685; - anglecorrectionfactorlongitudinal[79] = 0.66; - anglecorrectionfactorlongitudinal[80] = 0.635; - anglecorrectionfactorlongitudinal[81] = 0.583; - anglecorrectionfactorlongitudinal[82] = 0.531; - anglecorrectionfactorlongitudinal[83] = 0.479; - anglecorrectionfactorlongitudinal[84] = 0.427; - anglecorrectionfactorlongitudinal[85] = 0.375; - anglecorrectionfactorlongitudinal[86] = 0.3; - anglecorrectionfactorlongitudinal[87] = 0.225; - anglecorrectionfactorlongitudinal[88] = 0.15; - anglecorrectionfactorlongitudinal[89] = 0.075; - anglecorrectionfactorlongitudinal[90] = 0; + for(int i=0; i<25; ++i) anglecorrectionlongitudinal[i] = 1; + anglecorrectionlongitudinal[26] = 0.999; + anglecorrectionlongitudinal[27] = 0.998; + anglecorrectionlongitudinal[28] = 0.997; + anglecorrectionlongitudinal[29] = 0.996; + anglecorrectionlongitudinal[30] = 0.995; + anglecorrectionlongitudinal[31] = 0.992; + anglecorrectionlongitudinal[32] = 0.989; + anglecorrectionlongitudinal[33] = 0.986; + anglecorrectionlongitudinal[34] = 0.983; + anglecorrectionlongitudinal[35] = 0.98; + anglecorrectionlongitudinal[36] = 0.978; + anglecorrectionlongitudinal[37] = 0.976; + anglecorrectionlongitudinal[38] = 0.974; + anglecorrectionlongitudinal[39] = 0.972; + anglecorrectionlongitudinal[40] = 0.97; + anglecorrectionlongitudinal[41] = 0.968; + anglecorrectionlongitudinal[42] = 0.966; + anglecorrectionlongitudinal[43] = 0.964; + anglecorrectionlongitudinal[44] = 0.962; + anglecorrectionlongitudinal[45] = 0.96; + anglecorrectionlongitudinal[46] = 0.958; + anglecorrectionlongitudinal[47] = 0.956; + anglecorrectionlongitudinal[48] = 0.954; + anglecorrectionlongitudinal[49] = 0.952; + anglecorrectionlongitudinal[50] = 0.95; + anglecorrectionlongitudinal[51] = 0.948; + anglecorrectionlongitudinal[52] = 0.946; + anglecorrectionlongitudinal[53] = 0.944; + anglecorrectionlongitudinal[54] = 0.942; + anglecorrectionlongitudinal[55] = 0.94; + anglecorrectionlongitudinal[56] = 0.938; + anglecorrectionlongitudinal[57] = 0.936; + anglecorrectionlongitudinal[58] = 0.934; + anglecorrectionlongitudinal[59] = 0.932; + anglecorrectionlongitudinal[60] = 0.93; + anglecorrectionlongitudinal[61] = 0.922; + anglecorrectionlongitudinal[62] = 0.914; + anglecorrectionlongitudinal[63] = 0.906; + anglecorrectionlongitudinal[64] = 0.898; + anglecorrectionlongitudinal[65] = 0.89; + anglecorrectionlongitudinal[66] = 0.88; + anglecorrectionlongitudinal[67] = 0.87; + anglecorrectionlongitudinal[68] = 0.86; + anglecorrectionlongitudinal[69] = 0.85; + anglecorrectionlongitudinal[70] = 0.84; + anglecorrectionlongitudinal[71] = 0.824; + anglecorrectionlongitudinal[72] = 0.808; + anglecorrectionlongitudinal[73] = 0.792; + anglecorrectionlongitudinal[74] = 0.776; + anglecorrectionlongitudinal[75] = 0.76; + anglecorrectionlongitudinal[76] = 0.735; + anglecorrectionlongitudinal[77] = 0.71; + anglecorrectionlongitudinal[78] = 0.685; + anglecorrectionlongitudinal[79] = 0.66; + anglecorrectionlongitudinal[80] = 0.635; + anglecorrectionlongitudinal[81] = 0.583; + anglecorrectionlongitudinal[82] = 0.531; + anglecorrectionlongitudinal[83] = 0.479; + anglecorrectionlongitudinal[84] = 0.427; + anglecorrectionlongitudinal[85] = 0.375; + anglecorrectionlongitudinal[86] = 0.3; + anglecorrectionlongitudinal[87] = 0.225; + anglecorrectionlongitudinal[88] = 0.15; + anglecorrectionlongitudinal[89] = 0.075; + anglecorrectionlongitudinal[90] = 0; - for(int i=0; i<25; ++i) anglecorrectionfactorflat[i] = 1; - anglecorrectionfactorflat[26] = 0.999; - anglecorrectionfactorflat[27] = 0.998; - anglecorrectionfactorflat[28] = 0.997; - anglecorrectionfactorflat[29] = 0.996; - anglecorrectionfactorflat[30] = 0.995; - anglecorrectionfactorflat[31] = 0.992; - anglecorrectionfactorflat[32] = 0.989; - anglecorrectionfactorflat[33] = 0.986; - anglecorrectionfactorflat[34] = 0.983; - anglecorrectionfactorflat[35] = 0.98; - anglecorrectionfactorflat[36] = 0.982; - anglecorrectionfactorflat[37] = 0.974; - anglecorrectionfactorflat[38] = 0.966; - anglecorrectionfactorflat[39] = 0.958; - anglecorrectionfactorflat[40] = 0.95; - anglecorrectionfactorflat[41] = 0.946; - anglecorrectionfactorflat[42] = 0.942; - anglecorrectionfactorflat[43] = 0.938; - anglecorrectionfactorflat[44] = 0.934; - anglecorrectionfactorflat[45] = 0.93; - anglecorrectionfactorflat[46] = 0.924; - anglecorrectionfactorflat[47] = 0.918; - anglecorrectionfactorflat[48] = 0.912; - anglecorrectionfactorflat[49] = 0.906; - anglecorrectionfactorflat[50] = 0.90; - anglecorrectionfactorflat[51] = 0.89; - anglecorrectionfactorflat[52] = 0.88; - anglecorrectionfactorflat[53] = 0.87; - anglecorrectionfactorflat[54] = 0.86; - anglecorrectionfactorflat[55] = 0.85; - anglecorrectionfactorflat[56] = 0.837; - anglecorrectionfactorflat[57] = 0.824; - anglecorrectionfactorflat[58] = 0.811; - anglecorrectionfactorflat[59] = 0.798; - anglecorrectionfactorflat[60] = 0.785; - anglecorrectionfactorflat[61] = 0.77; - anglecorrectionfactorflat[62] = 0.755; - anglecorrectionfactorflat[63] = 0.74; - anglecorrectionfactorflat[64] = 0.725; - anglecorrectionfactorflat[65] = 0.71; - anglecorrectionfactorflat[66] = 0.693; - anglecorrectionfactorflat[67] = 0.676; - anglecorrectionfactorflat[68] = 0.659; - anglecorrectionfactorflat[69] = 0.642; - anglecorrectionfactorflat[70] = 0.625; - anglecorrectionfactorflat[71] = 0.605; - anglecorrectionfactorflat[72] = 0.585; - anglecorrectionfactorflat[73] = 0.565; - anglecorrectionfactorflat[74] = 0.545; - anglecorrectionfactorflat[75] = 0.525; - anglecorrectionfactorflat[76] = 0.501; - anglecorrectionfactorflat[77] = 0.477; - anglecorrectionfactorflat[78] = 0.453; - anglecorrectionfactorflat[79] = 0.429; - anglecorrectionfactorflat[80] = 0.405; - anglecorrectionfactorflat[81] = 0.371; - anglecorrectionfactorflat[82] = 0.337; - anglecorrectionfactorflat[83] = 0.303; - anglecorrectionfactorflat[84] = 0.269; - anglecorrectionfactorflat[85] = 0.235; - anglecorrectionfactorflat[86] = 0.188; - anglecorrectionfactorflat[87] = 0.141; - anglecorrectionfactorflat[88] = 0.094; - anglecorrectionfactorflat[89] = 0.047; - anglecorrectionfactorflat[90] = 0; + for(int i=0; i<25; ++i) anglecorrectionflat[i] = 1; + anglecorrectionflat[26] = 0.999; + anglecorrectionflat[27] = 0.998; + anglecorrectionflat[28] = 0.997; + anglecorrectionflat[29] = 0.996; + anglecorrectionflat[30] = 0.995; + anglecorrectionflat[31] = 0.992; + anglecorrectionflat[32] = 0.989; + anglecorrectionflat[33] = 0.986; + anglecorrectionflat[34] = 0.983; + anglecorrectionflat[35] = 0.98; + anglecorrectionflat[36] = 0.982; + anglecorrectionflat[37] = 0.974; + anglecorrectionflat[38] = 0.966; + anglecorrectionflat[39] = 0.958; + anglecorrectionflat[40] = 0.95; + anglecorrectionflat[41] = 0.946; + anglecorrectionflat[42] = 0.942; + anglecorrectionflat[43] = 0.938; + anglecorrectionflat[44] = 0.934; + anglecorrectionflat[45] = 0.93; + anglecorrectionflat[46] = 0.924; + anglecorrectionflat[47] = 0.918; + anglecorrectionflat[48] = 0.912; + anglecorrectionflat[49] = 0.906; + anglecorrectionflat[50] = 0.90; + anglecorrectionflat[51] = 0.89; + anglecorrectionflat[52] = 0.88; + anglecorrectionflat[53] = 0.87; + anglecorrectionflat[54] = 0.86; + anglecorrectionflat[55] = 0.85; + anglecorrectionflat[56] = 0.837; + anglecorrectionflat[57] = 0.824; + anglecorrectionflat[58] = 0.811; + anglecorrectionflat[59] = 0.798; + anglecorrectionflat[60] = 0.785; + anglecorrectionflat[61] = 0.77; + anglecorrectionflat[62] = 0.755; + anglecorrectionflat[63] = 0.74; + anglecorrectionflat[64] = 0.725; + anglecorrectionflat[65] = 0.71; + anglecorrectionflat[66] = 0.693; + anglecorrectionflat[67] = 0.676; + anglecorrectionflat[68] = 0.659; + anglecorrectionflat[69] = 0.642; + anglecorrectionflat[70] = 0.625; + anglecorrectionflat[71] = 0.605; + anglecorrectionflat[72] = 0.585; + anglecorrectionflat[73] = 0.565; + anglecorrectionflat[74] = 0.545; + anglecorrectionflat[75] = 0.525; + anglecorrectionflat[76] = 0.501; + anglecorrectionflat[77] = 0.477; + anglecorrectionflat[78] = 0.453; + anglecorrectionflat[79] = 0.429; + anglecorrectionflat[80] = 0.405; + anglecorrectionflat[81] = 0.371; + anglecorrectionflat[82] = 0.337; + anglecorrectionflat[83] = 0.303; + anglecorrectionflat[84] = 0.269; + anglecorrectionflat[85] = 0.235; + anglecorrectionflat[86] = 0.188; + anglecorrectionflat[87] = 0.141; + anglecorrectionflat[88] = 0.094; + anglecorrectionflat[89] = 0.047; + anglecorrectionflat[90] = 0; } void House::calctemp() { @@ -389,3 +392,70 @@ void House::calctemp() { tempinside[22] = 20; tempinside[23] = 18; } + +void House::calcdiff() { + for(int i=0; i < 12; ++i) { + for(int j=0; j < 24; ++j) { + tempdifference[i][j] = tempinside[j] - tempoutside[i][j]; + } + } +} + +void House::calcneededenergy() { +float x=0; + calcdiff(); + for (int i=0; i<12; ++i) { + for (int j=0; j<24; ++i) { + if (tempdifference>0) { + switch (i) { + case 0: x+= tempdifference[i][j]*31; break; + case 1: x+= tempdifference[i][j]*28; break; + case 2: x+= tempdifference[i][j]*31; break; + case 3: x+= tempdifference[i][j]*30; break; + case 4: x+= tempdifference[i][j]*31; break; + case 5: x+= tempdifference[i][j]*30; break; + case 6: x+= tempdifference[i][j]*31; break; + case 7: x+= tempdifference[i][j]*31; break; + case 8: x+= tempdifference[i][j]*30; break; + case 9: x+= tempdifference[i][j]*31; break; + case 10: x+= tempdifference[i][j]*30; break; + case 11: x+= tempdifference[i][j]*31; break; + } + } + } + } + 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; + } + } +} +// maxenergiebedarf := 0; +// for i:= 1 to 365 do +// begin +// for j:=1 to 24 do +// begin +// if energiebedarf[i,j]>maxenergiebedarf then +// maxenergiebedarf := energiebedarf[i,j]; +// end; +// end; + +void House::calccollectoroutput(int day, int time, int month) { + if(collectorstatus == TRANSVERSAL) + 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; + + 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; + + 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; +} @@ -7,12 +7,17 @@ #include <list> #include <math.h> +#define TRANSVERSAL 0 +#define LONGITUDINAL 1 +#define FLAT 2 + class House { public: House(float inittemp0, int earthx0, int earthy0, int earthz0, float collectortemp0, float radiation0, float latitude0, float eta00, float k10, float k20, float collectorarea0, - float watthoursperhuman, int humans); + float roofangle0, float watthoursperhuman, int humans, int heaterenergy0); + std::list<Triangle> getTriangles(){ std::list<Triangle> triangles = temp.getTriangles(); return triangles; @@ -20,14 +25,19 @@ class House void calcefficiency(); void calctemp(); + void calcdiff(); + void calcneededenergy(); + void calccollectoroutput(int day, int time, int month); private: Temparray temp; - float collectortemp, latitude, radiation, eta0, k1, k2, watthoursperhuman, collectorarea; + Sun sun; + float collectortemp, latitude, radiation, eta0, k1, k2, watthoursperhuman, collectorarea, + heaterenergy, roofangle, collectoroutput; float tempinside[24], tempoutside[12][24], efficiencyflat[100], efficiencyvacuum[100], - anglecorrectionfactorflat[91], anglecorrectionfactortransversal[91], - anglecorrectionfactorlongitudinal[91]; - int humans; + anglecorrectionflat[91], anglecorrectiontransversal[91], + anglecorrectionlongitudinal[91], tempdifference[12][24], neededenergy[12][24]; + int humans, collectorstatus; }; #endif /* _HOUSE_H_ */ @@ -7,10 +7,13 @@ class Sun { public: Sun(float latitude0): latitude(latitude0){}; + Sun(){}; + + void setlatitude(float latitude0){latitude=latitude0;}; float declination(int day) {return 23.4*sin(2*M_PI*(284+day)/365);} - float hourangle(float time) {return 15*(time-12);} - float evelationangle(int day, float time) { + float hourangle(int time) {return 15*(time-12);} + float elevationangle(int day, int time) { return asin(sin(declination(day)*M_PI/180)* sin(latitude*M_PI/180)* cos(hourangle(time)*M_PI/180)* @@ -18,15 +21,15 @@ class Sun cos(latitude*M_PI/180)) *180/M_PI; } - float azimutangle(int day, float time){ + float azimutangle(int day, int time){ float tau, sin_tau, cos_tau, sin_phi, cos_phi, tan_dec; + tan_dec = tan(declination(day)*M_PI/180); tau = hourangle(time)*M_PI/180; sin_tau = sin(tau); cos_tau = cos(tau); sin_phi = sin(latitude*M_PI/180); cos_phi = cos(latitude*M_PI/180); - tan_dec = tan(declination(day)*M_PI/180); return atan2(sin_tau, cos_tau*sin_phi-tan_dec*cos_phi)/180*M_PI; } diff --git a/Temparray.cpp b/Temparray.cpp index 83008cc..83f91f0 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -122,6 +122,30 @@ 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(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); + + 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(); @@ -158,10 +182,10 @@ void Temparray::calcTemp(){ 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)))); + temperatureold(i, j-1, k, l, m))*(1-exp(-(1/tau12)))); + temperaturenew(i, j-1, k, l, m) = + temperaturenew(i, j-1, k, l, m) + ((temperatureold(i, j, k, l, m) - + temperatureold(i, j-1, k, l, m))*(1-exp(-(1/tau21)))); } if(m == 0) { @@ -262,7 +286,7 @@ void Temparray::calcTemp(){ if(m % 2 == 1)area = (((width - innerwidth)/2)*((depth + innerdepth)/2)) / 0.9 * meterperunit; - thermalresistance = 3 + (height/2 / 0.9 * meterperunit /(conductivity * area)); + thermalresistance = (3 + height/2) / 0.9 * meterperunit /(conductivity * area); if(m % 2 == 0)capacity = specificcapacity *((((depth - innerdepth)/2)* ((width + innerwidth)/2)*height) @@ -314,7 +338,7 @@ void Temparray::calcTemp(){ area = (((depth + innerdepth)/2)*height) / 0.9 * meterperunit; - thermalresistance = 3 + ((width - innerwidth)/4) / 0.9 * meterperunit / + thermalresistance = (3 + (width - innerwidth)/4) / 0.9 * meterperunit / (conductivity * area); capacity = specificcapacity *((((depth + innerdepth)/2)*((width - innerwidth)/2)* @@ -360,7 +384,7 @@ void Temparray::calcTemp(){ area = (((width + innerwidth)/2)*height) / 0.9 * meterperunit; - thermalresistance = 3 + ((depth - innerdepth)/4) / 0.9 * meterperunit / + thermalresistance = (3 + (depth - innerdepth)/4) / 0.9 * meterperunit / (conductivity * area); capacity = specificcapacity *((((width + innerwidth)/2)*((depth - innerdepth)/2)* @@ -379,9 +403,9 @@ void Temparray::calcTemp(){ // 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, 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; - std::cerr << " " << temperatureold(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; +// std::cerr << " " << temperatureold(2, 2, 2, 3, 2) << "\n" << std::endl; } std::list<Triangle> Temparray::getTriangles(){ diff --git a/Temparray.h b/Temparray.h index ba4e8e8..67cb73b 100644 --- a/Temparray.h +++ b/Temparray.h @@ -22,12 +22,14 @@ class Temparray } std::list<Triangle> getTriangles(); void coloring(); + + void setprobetemp(float t){probetemp = t;}; private: float *temparrayold, *temparraynew; Cubehole *cubearray; int sx, sy, sz; - float averagetemp, earthtemp; + float averagetemp, earthtemp, probetemp; Cubehole& cubehole(int x, int y, int z, int line) { return cubearray[x*sy*sz*6 + y*sz*6 + z*6 + line]; |