40 #endif |
40 #endif |
41 { |
41 { |
42 simulator_list *simulator; |
42 simulator_list *simulator; |
43 time_t now, last = (time_t)0; |
43 time_t now, last = (time_t)0; |
44 int seconds = 0; |
44 int seconds = 0; |
45 double k_room_air, k_beer_air, sqm_room_air, sqm_beer_air, thick_room_air, thick_beer_air, air_heat_transfer, beer_heat_transfer; |
45 double k_room_air, sqm_room_air, thick_room_air, air_heat_transfer; |
46 double air_change, /* beer_change, */ vhc_air = 0.00121 /*, vhc_water = 4.1796 */; |
46 double air_change, vhc_air = 0.00121; |
47 |
47 |
48 syslog(LOG_NOTICE, "Thread my_simulator_loop started"); |
48 syslog(LOG_NOTICE, "Thread my_simulator_loop started"); |
49 if (debug) |
49 if (debug) |
50 fprintf(stdout, "Thread my_simulator_loop started\n"); |
50 fprintf(stdout, "Thread my_simulator_loop started\n"); |
51 |
51 |
117 } else { |
117 } else { |
118 simulator->s_cool_temp -= (simulator->s_cool_temp - simulator->air_temperature) / 25.0; |
118 simulator->s_cool_temp -= (simulator->s_cool_temp - simulator->air_temperature) / 25.0; |
119 } |
119 } |
120 |
120 |
121 /* |
121 /* |
122 * Calculate the extra beer temperatur rise to simulate the heat produced by the |
|
123 * fermentation process. Peak about one day after start and slowly decrease after |
|
124 * that. |
|
125 */ |
|
126 sqm_beer_air = (cbrtl(simulator->volume_beer) * cbrtl(simulator->volume_beer) * 6) / 100; /* Simple, the beer is in a cubic box */ |
|
127 thick_beer_air = 0.001; |
|
128 k_beer_air = 0.5; /* HDPE */ |
|
129 beer_heat_transfer=(k_beer_air * sqm_beer_air * (simulator->air_temperature - simulator->beer_temperature)) / thick_beer_air; |
|
130 /* beer_change = 0; */ |
|
131 |
|
132 /* |
|
133 * Calculate final temperature of the beer and the air. |
122 * Calculate final temperature of the beer and the air. |
134 */ |
123 */ |
135 // Cheap trick, just follow slowly the air temp. |
124 // Cheap trick, just follow slowly the air temp. |
136 simulator->beer_temperature += ((simulator->air_temperature - simulator->beer_temperature) / 500.0); |
125 simulator->beer_temperature += ((simulator->air_temperature - simulator->beer_temperature) / 500.0); |
137 simulator->air_temperature += ((simulator->beer_temperature - simulator->air_temperature) / 2500.0); |
126 simulator->air_temperature += ((simulator->beer_temperature - simulator->air_temperature) / 2500.0); |
138 |
127 |
139 syslog(LOG_NOTICE, "air=%.3f beer=%.3f heater=%.3f cooler=%.3f", simulator->air_temperature, simulator->beer_temperature, |
128 syslog(LOG_NOTICE, "air=%.3f beer=%.3f heater=%.3f cooler=%.3f", simulator->air_temperature, simulator->beer_temperature, |
140 simulator->s_heat_temp, simulator->s_cool_temp); |
129 simulator->s_heat_temp, simulator->s_cool_temp); |
141 |
130 |
142 if (debug) |
131 // if (debug) |
143 fprintf(stdout, "sqm_room_air=%f air=%f air_heat_transfer=%f air_change=%f sqm_beer_air=%f beer=%f beer_heat_transfer=%f\n", |
132 // fprintf(stdout, "sqm_room_air=%f air=%f air_heat_transfer=%f air_change=%f beer=%f\n", |
144 sqm_room_air, simulator->air_temperature, air_heat_transfer, air_change, |
133 // sqm_room_air, simulator->air_temperature, air_heat_transfer, air_change, simulator->beer_temperature); |
145 sqm_beer_air, simulator->beer_temperature, beer_heat_transfer); |
|
146 } |
134 } |
147 usleep(100000); |
135 usleep(100000); |
148 } |
136 } |
149 usleep(50000); |
137 usleep(50000); |
150 } |
138 } |