CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Transient Heating with logical heat source UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 11, 2018, 00:53
Default Transient Heating with logical heat source UDF
  #1
New Member
 
Taiwan, New Taipei
Join Date: Jun 2018
Location: Taipei, Taiwan
Posts: 6
Rep Power: 8
suraj9735 is on a distinguished road
Hello Everyone!

I am trying to write a UDF to heat my plate. When the average temperature of my particular cell thread reach to 453K, I want the source term should OFF for the next 100 seconds and repeat the same logic...

But the plot of average temperature doesn't follow the logic...

Could you please tell me what's wrong with the next 100 seconds OFF logic?


*******my_code**********

/********************/
/* User-Defined Function */
/*******************/
#include "udf.h"
int last_ts = -1; /* Global variable. Time step is never <0 */
real temp_avg = 0.;
real time_heat_flux_zero = 0.;

DEFINE_ADJUST(my_adjust,d)
{
real n = 0.;
real temp_sum = 0.;
int ID=13;
Thread *t=Lookup_Thread(d,ID);
cell_t c;

int curr_ts;
curr_ts = N_TIME;
if (last_ts != curr_ts)
{
last_ts = curr_ts;

/* things to be done only on first iteration of each time step
can be from here....... */

begin_c_loop(c,t)
temp_sum +=C_T(c,t);
n=n+1;

end_c_loop(c,t)

temp_avg=temp_sum/n;

if (temp_avg > 453)
{
time_heat_flux_zero = CURRENT_TIMESTEP + 100.0;

}
if(time_heat_flux_zero > 0.0)
{
time_heat_flux_zero -= CURRENT_TIMESTEP;
}


}
}


DEFINE_SOURCE(my_heat_source, c, t, dS, eqn)


{


real source;
if (time_heat_flux_zero > 0.01)
/* If the temperature is low, Cartridge heater OFF */


{source = 0.;


}
else

{
source = 31830988.62;

/* Otherwise, Cartridge Heater ON */



}
dS[eqn] = 0;
printf("source: %g\n", source);


return source;
}
Attached Images
File Type: jpg Capture.jpg (41.7 KB, 10 views)
Attached Files
File Type: c source7.c (1.2 KB, 1 views)
suraj9735 is offline   Reply With Quote

Reply

Tags
define_adjust, define_source


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 04:04
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51


All times are GMT -4. The time now is 20:47.