|
[Sponsors] |
Transient Heating with logical heat source UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 11, 2018, 00:53 |
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 |
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; } |
|
Tags |
define_adjust, define_source |
|
|
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 |