# HG changeset patch # User Michiel Broek # Date 1431976746 -7200 # Node ID df0261bb3febde689f4da3b7cfa51f27a959fde8 # Parent 2f9bbbcd24075877ae4bea24870a4c8f8017f044 Version 0.3.3, still not for production. Fixed warnings when the simulator code is compiled. Slowed the simulator air temperature change 60 times. More realistic temperature changes for the heater and cooler elements. Improved logic in the simulator. diff -r 2f9bbbcd2407 -r df0261bb3feb configure --- a/configure Sun May 17 23:23:25 2015 +0200 +++ b/configure Mon May 18 21:19:06 2015 +0200 @@ -2034,7 +2034,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.3.2" +VERSION="0.3.3" COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved" CYEARS="2014-2015" diff -r 2f9bbbcd2407 -r df0261bb3feb configure.ac --- a/configure.ac Sun May 17 23:23:25 2015 +0200 +++ b/configure.ac Mon May 18 21:19:06 2015 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.3.2" +VERSION="0.3.3" COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved" CYEARS="2014-2015" AC_SUBST(PACKAGE) diff -r 2f9bbbcd2407 -r df0261bb3feb thermferm/simulator.c --- a/thermferm/simulator.c Sun May 17 23:23:25 2015 +0200 +++ b/thermferm/simulator.c Mon May 18 21:19:06 2015 +0200 @@ -43,7 +43,7 @@ time_t now, last = (time_t)0; int seconds = 0; 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; - double air_change, beer_change, vhc_air = 0.00121, vhc_water = 4.1796; + double air_change, /* beer_change, */ vhc_air = 0.00121 /*, vhc_water = 4.1796 */; syslog(LOG_NOTICE, "Thread my_simulator_loop started"); if (debug) @@ -79,7 +79,7 @@ thick_room_air = 0.04; /* 4 cm walls */ k_room_air = 0.03; /* Polystrene */ air_heat_transfer=(k_room_air * sqm_room_air * (simulator->room_temperature - simulator->air_temperature)) / thick_room_air; - air_change = air_heat_transfer / (vhc_air * ((simulator->volume_air - simulator->volume_beer) * 1000)); + air_change = (air_heat_transfer / (vhc_air * ((simulator->volume_air - simulator->volume_beer) * 1000))) / 60.0; simulator->air_temperature += air_change; /* @@ -88,11 +88,16 @@ * Finally, calculate the new air and plate temperature. */ if (SIMheating) { - if (simulator->s_heat_temp < simulator->heater_temp) + if (simulator->s_heat_temp < simulator->heater_temp) { simulator->s_heat_temp += 0.05; + if (simulator->s_heat_temp > simulator->air_temperature) + simulator->air_temperature += ((simulator->s_heat_temp - simulator->air_temperature) / 100.0); + } } else { - if (simulator->s_heat_temp > simulator->room_temperature) - simulator->s_heat_temp -= 0.05; + /* + * Follow the air temperature + */ + simulator->s_heat_temp -= (simulator->s_heat_temp - simulator->air_temperature) / 25.0; } /* @@ -101,16 +106,15 @@ * Finsally, calculate the new air and plate temperature. */ if (SIMcooling) { - if (simulator->s_cool_temp > simulator->cooler_temp) + if (simulator->s_cool_temp > simulator->cooler_temp) { simulator->s_cool_temp -= 0.05; + if (simulator->s_cool_temp < simulator->air_temperature) + simulator->air_temperature -= ((simulator->air_temperature - simulator->s_cool_temp) / 100.0); + } } else { - if (simulator->s_cool_temp < simulator->room_temperature) - simulator->s_cool_temp += 0.05; + simulator->s_cool_temp -= (simulator->s_cool_temp - simulator->air_temperature) / 25.0; } - simulator->air_temperature += ((simulator->s_heat_temp - simulator->air_temperature) / 50.0); - simulator->air_temperature -= ((simulator->air_temperature - simulator->s_cool_temp) / 50.0); - /* * Calculate the extra beer temperatur rise to simulate the heat produced by the * fermentation process. Peak about one day after start and slowly decrease after @@ -120,13 +124,14 @@ thick_beer_air = 0.001; k_beer_air = 0.5; /* HDPE */ beer_heat_transfer=(k_beer_air * sqm_beer_air * (simulator->air_temperature - simulator->beer_temperature)) / thick_beer_air; - beer_change = 0; + /* beer_change = 0; */ /* * Calculate final temperature of the beer and the air. */ // Cheap trick, just follow slowly the air temp. simulator->beer_temperature += ((simulator->air_temperature - simulator->beer_temperature) / 200.0); + simulator->air_temperature += ((simulator->beer_temperature - simulator->air_temperature) / 1000.0); syslog(LOG_NOTICE, "air=%.3f beer=%.3f heater=%.3f cooler=%.3f", simulator->air_temperature, simulator->beer_temperature, simulator->s_heat_temp, simulator->s_cool_temp);