summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--House.cpp17
-rw-r--r--House.h2
-rw-r--r--Sun.h4
-rw-r--r--Temparray.cpp20
-rw-r--r--Temparray.h4
5 files changed, 34 insertions, 13 deletions
diff --git a/House.cpp b/House.cpp
index fb0f848..bf1724c 100644
--- a/House.cpp
+++ b/House.cpp
@@ -13,6 +13,7 @@ House::House(float inittemp0, int earthx0, int earthy0, int earthz0, float colle
calcefficiency();
calctemp();
calcneededenergy();
+ collectorstatus = TRANSVERSAL;
}
void House::calcefficiency() {
@@ -461,26 +462,26 @@ void House::calccollectoroutput(int day, int time, int month) {
}
void House::calcprobeinput(int day, int time, int month) {
- static float E;
+ /*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;
+ else if(E<collectoroutput && collectoroutput>0) {collectoroutput -= E; E=0;}*/
+ calccollectoroutput(day, time, month);
+ std::cout << collectoroutput << std::endl;
+ collectoroutput-=neededenergy[month][time];
}
void House::controller(){
- static int day=0, time=0, month=0;
+ static int day=90, time=0, month=0;
calcprobeinput(day, time, month);
temp.setprobetemp(collectortemp);
- temp.setinput(probeinput);
+ temp.setinput(collectoroutput);
temp.calcTemp();
++time;
if(time > 23){
- //std::cerr << day << std::endl;
+// std::cerr << day << " " << temp.getaverage() << std::endl;
time = 0;
++day;
}
diff --git a/House.h b/House.h
index aab0883..12cd725 100644
--- a/House.h
+++ b/House.h
@@ -36,7 +36,7 @@ class House
Temparray temp;
Sun sun;
float collectortemp, latitude, radiation, eta0, k1, k2, watthoursperhuman, collectorarea,
- heaterenergy, roofangle, collectoroutput, probeinput;
+ heaterenergy, roofangle, collectoroutput;
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/Sun.h b/Sun.h
index 9e6f144..a242e5f 100644
--- a/Sun.h
+++ b/Sun.h
@@ -11,8 +11,8 @@ class Sun
void setlatitude(float latitude0){latitude=latitude0;};
- float declination(int day) {return 23.4*sin(2*M_PI*(284+day)/365);}
- float hourangle(int time) {return 15*(time-12);}
+ float declination(int day) {return 23.4*sin(2*M_PI*(284+day+1)/365);}
+ float hourangle(int time) {return 15*(time+1/*-12*/);}
float elevationangle(int day, int time) {
return asin(sin(declination(day)*M_PI/180)*
sin(latitude*M_PI/180)*
diff --git a/Temparray.cpp b/Temparray.cpp
index ddbcc25..0686ef0 100644
--- a/Temparray.cpp
+++ b/Temparray.cpp
@@ -154,7 +154,7 @@ void Temparray::calcTemp(){
inputpower = loadableenergy;
input -= loadableenergy;
}
- else if (input <= loadableenergy) {
+ else if (input < loadableenergy) {
inputpower = input;
input = 0;
}
@@ -165,6 +165,24 @@ void Temparray::calcTemp(){
*thermalresistance*factor*(1-exp(-(1/tau12)));
}
}
+ if (input < 0){
+ if(unloadableenergy <= 0)
+ inputpower = 0;
+ else if (input > unloadableenergy) {
+ inputpower = unloadableenergy;
+ input -= unloadableenergy;
+ }
+ else if (input <= unloadableenergy) {
+ inputpower = input;
+ input = 0;
+ }
+ if(inputpower > 0) {
+ factor = inputpower/unloadableenergy;
+ temperaturenew(i, j, k, l, m) =
+ temperaturenew(i, j, k, l, m) + (21.5-temperatureold(i, j, k, l, m))
+ *thermalresistance*factor*(1-exp(-(1/tau12)));
+ }
+ }
}
}
}
diff --git a/Temparray.h b/Temparray.h
index 0886c9d..409b780 100644
--- a/Temparray.h
+++ b/Temparray.h
@@ -25,6 +25,8 @@ class Temparray
void setprobetemp(float t){probetemp = t;}
void setinput(float input0){input = input0;}
+
+ float getaverage(){return averagetemp;}
private:
float *temparrayold, *temparraynew;
@@ -73,7 +75,7 @@ class Temparray
}
}
averagetemp = tempcache/times;
- std::cerr << averagetemp << std::endl;
+// std::cerr << averagetemp << std::endl;
}
};