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.

Mon, 18 May 2015 21:19:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 18 May 2015 21:19:06 +0200
changeset 365
df0261bb3feb
parent 364
2f9bbbcd2407
child 366
7b698d012a0c

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.

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/simulator.c file | annotate | diff | comparison | revisions
--- 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"
 
--- 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)
--- 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);

mercurial