Icepak - Modeling Thermostat behavior (Turn ON/OFF power based on temperature)


To turn ON/OFF the power for the source based on temperature, the following procedure can be used. This is a typical thermostat behavior where the source (power in W) needs to be turned OFF when
temperature of a specified surface reaches some specified limit.
1) Write out the Icepak case file using the "Do not start solver" option. Make sure you toggle on the transient power option for the Source object.

2) Now identify the zone ID for the temperature sensor. The zone ID for the sensor is located near the very end of the case file.

For ex., the zone ID for the wall source_1_1-side1-1 from the following section of a case file is 12.

;;; zone for source source_1_1 side 1, shadow faces, pids 17 and 0, facing -y
(39 (12 wall source_1_1-side1-1) (
(thermal-bc . 3)
(q (constant . 0.0))
(material . Steel-Oxidised-surface)


3) Now modify the UDF created by Icepak as shown in the folling UDF(test00.udf.c). In this UDf, a DEFINE_ADJUST function is created to determine the sensor face average temperature. Based on the predefined scut-off temperature (25C for this case) the power density profile for the source is changed as shown in DEFINE_PROFILE.

*******************************************************************************************************************************
Two Udfs are shown here to show the modification of the default udf

*************************************************** default udf created by icepak ******************************************

#include "udf.h"

#include "prop.h"

real fmod(real a, real b) { return (a - ((int)(a/b))*b); }

DEFINE_PROFILE(udf_func_1, thread, nv)
{
face_t f;
real x = RP_Get_Real("flow-time");
real xt = RP_Get_Real("physical-time-step");
real x_halfxt = x - 0.5 * xt ;
real xminus = x - 0.001 * xt ;
real x2;
real temp;

begin_f_loop (f, thread) {
if (x < 0.000000e+000) {
temp = 4.999995e+003;
} else if (xminus > 3.000000e+002) {
temp = 4.999995e+003;
} else {
if (x < 0.000000e+000) temp = 4.999995e+003;
if (xminus < 1.000000e+001 && xminus >= 0.000000e+000) temp = 4.999995e+003 * (0.000000e+000 + (x - 0.000000e+000) / 1.000000e+001 * 1.000000e+000);
if (xminus < 5.000000e+001 && xminus >= 1.000000e+001) temp = 4.999995e+003 * (1.000000e+000 + (x - 1.000000e+001) / 4.000000e+001 * -2.500000e-001);
if (xminus < 3.000000e+002 && xminus >= 5.000000e+001) temp = 4.999995e+003 * (7.500000e-001 + (x - 5.000000e+001) / 2.500000e+002 * -7.500000e-001);
if (x >= 3.000000e+002) temp = 4.999995e+003;

}
F_PROFILE(f,thread,nv) = temp;
}
end_f_loop (f, thread)
}

**************************************************************************************************************
************* Modified UDF **************************************************************************

#include "udf.h"

#include "prop.h"
#define SENSOR1_ID 12
#define H1_TEMP 298
real fmod(real a, real b) { return (a - ((int)(a/b))*b); }
real sensor1_temp;

DEFINE_ADJUST(avg_temp_adjust1, d)
{
Thread *t1;
face_t f1;
real sum_sensor1=0.0;
real count1 = 0.0;

t1 = Lookup_Thread(d, SENSOR1_ID);
/* Calculates average temperature on sensor-1 */
begin_f_loop (f1,t1)
sum_sensor1 = sum_sensor1 + F_T(f1,t1);
count1 = count1 + 1;
end_f_loop (f1,t1)
sensor1_temp = sum_sensor1/count1;
printf("Sensor Temp = %fn", sensor1_temp);
}

DEFINE_PROFILE(udf_func_1, thread, nv)
{
Thread *t1;
face_t f;


begin_f_loop(f, thread)
{
if(sensor1_temp <= H1_TEMP)
F_PROFILE(f, thread, nv) = 5e+3;
else
F_PROFILE(f, thread, nv) = 0.0;
}
end_f_loop(f, thread)
}

****************************************************************************************
*********************************************************************************


4) Lastly, we need to add the line

(udf/adjust-fcn "avg_temp_adjust1")
in the beginning section of the case file after the line
(temperature/secondary-gradient? #f)

Once the UDF and .cas files have been modified, you can start the solution by using "Reuse existing solver input files" option in the
Solve panel.





Show Form
No comments yet. Be the first to add a comment!