39 { |
39 { |
40 simulator_list *simulator; |
40 simulator_list *simulator; |
41 time_t now, last = (time_t)0; |
41 time_t now, last = (time_t)0; |
42 int seconds = 0; |
42 int seconds = 0; |
43 double k_room_air, sqm_room_air, thick_room_air, heat_transfer; |
43 double k_room_air, sqm_room_air, thick_room_air, heat_transfer; |
44 double t_change, vhc_air = 0.00121, vhc_water = 4.1796; |
44 double t_change, vhc_air = 1.21, vhc_water = 4179.6; |
45 |
45 |
46 syslog(LOG_NOTICE, "Thread my_simulator_loop started"); |
46 syslog(LOG_NOTICE, "Thread my_simulator_loop started"); |
47 if (debug) |
47 if (debug) |
48 fprintf(stdout, "Thread my_simulator_loop started\n"); |
48 fprintf(stdout, "Thread my_simulator_loop started\n"); |
49 |
49 |
65 * fridge. We use the volume air to roughly calculate the total area between |
65 * fridge. We use the volume air to roughly calculate the total area between |
66 * the in and outside. Calculate the effect and shift the air temperature towards |
66 * the in and outside. Calculate the effect and shift the air temperature towards |
67 * the room temperature. |
67 * the room temperature. |
68 */ |
68 */ |
69 sqm_room_air = (cbrtl(simulator->volume_air) * cbrtl(simulator->volume_air) * 6) / 100; /* square meters all fridge sides */ |
69 sqm_room_air = (cbrtl(simulator->volume_air) * cbrtl(simulator->volume_air) * 6) / 100; /* square meters all fridge sides */ |
70 thick_room_air = 0.02; /* 4 cm walls */ |
70 thick_room_air = 0.04; /* 4 cm walls */ |
71 k_room_air = 0.03; /* Polystrene */ |
71 k_room_air = 0.03; /* Polystrene */ |
72 heat_transfer=(k_room_air * sqm_room_air * (simulator->room_temperature - simulator->air_temperature)) / thick_room_air; |
72 heat_transfer=(k_room_air * sqm_room_air * (simulator->room_temperature - simulator->air_temperature)) / thick_room_air; |
73 if (heat_transfer != 0) |
73 if (heat_transfer != 0) |
|
74 // t_change = heat_transfer * vhc_air * (simulator->volume_air / 1000); |
74 t_change = vhc_air / (heat_transfer * (simulator->volume_air * 1000)); |
75 t_change = vhc_air / (heat_transfer * (simulator->volume_air * 1000)); |
75 else |
76 else |
76 t_change = 0.0; |
77 t_change = 0.0; |
77 simulator->air_temperature = simulator->air_temperature + t_change; |
78 simulator->air_temperature = simulator->air_temperature + t_change; |
78 if (debug) |
79 if (debug) |