|
[Sponsors] |
October 20, 2018, 03:18 |
Controlling the UDF within the Minute
|
#1 |
New Member
Siddharth
Join Date: Nov 2016
Posts: 11
Rep Power: 10 |
Hi Folks,
I am siddhu. I having a code for controlling the heatflux 5min the given value and next 5min will be zero. Code:
#include "udf.h" DEFINE_PROFILE(5min_ON_5min_OFF,thread,position) { face_t f; int i,i_step; real time,heat_flux,t1_sec,t2_sec; i_step = 6; t1_sec=300; t2_sec=300; heat_flux = 12345; time=CURRENT_TIME; begin_f_loop(f,thread) { for (i=0;i<=i_step;i++) { if (time>=(i*(t1_sec+t2_sec)) && time < (i*(t1_sec+t2_sec)+t1_sec)) F_PROFILE(f,thread,position)=heat_flux; if (time >= (i*(t1_sec+t2_sec)+t1_sec) && time < (i*(t1_sec+t2_sec)+t1_sec+t2_sec)) F_PROFILE(f,thread,position)=0.0; } } end_f_loop(f,thread) } Time step size : 60 Number of time step : 60 This code working. Now I want write a UDF for turn the heatflux ON and OFF for 85 times for each one minute. I am will run this transient Time step size : 60 Number of time step : 60 Can you anyone please write the UDF for this condition. Please refer the CODE I have given. |
|
October 21, 2018, 00:38 |
|
#2 |
Senior Member
|
FYR.
Code:
#include "udf.h" DEFINE_PROFILE(five_min_ON_five_min_OFF,thread,position) { face_t f; int i_repeat, n_repeats; real time, heat_flux, t1_sec, t2_sec, i_sec; real hf; t1_sec=300; t2_sec=300; n_repeats = 85; heat_flux = 12345; time=CURRENT_TIME; /** * time = i_repeat*(t1_sec + t2_sec) + i_sec; * where i_repeat is the largest integer s.t. * 0 < i_sec < t1_sec + t2_sec * The heat flux is then determined by comparing * i_sec and t1_sec. */ i_repeat = time/(t1_sec+t2_sec); if (n_repeats <= i_repeat) return; i_sec = time - i_repeat*(t1_sec+t2_sec); if (i_sec < t1_sec) { hf = heat_flux; } else { hf = 0.0; } begin_f_loop(f,thread) { F_PROFILE(f,thread,position) = hf; } end_f_loop(f,thread) } |
|
October 22, 2018, 00:34 |
|
#3 | |
New Member
Siddharth
Join Date: Nov 2016
Posts: 11
Rep Power: 10 |
Quote:
|
||
October 22, 2018, 06:11 |
|
#4 |
New Member
Siddharth
Join Date: Nov 2016
Posts: 11
Rep Power: 10 |
1st
Code:
#include "udf.h" DEFINE_PROFILE(5min_ON_5min_OFF,thread,position) { face_t f; int i,i_step; real time,heat_flux,t1_sec,t2_sec; i_step = 6; t1_sec=300; t2_sec=300; heat_flux = 12345; time=CURRENT_TIME; begin_f_loop(f,thread) { for (i=0;i<=i_step;i++) { if (time>=(i*(t1_sec+t2_sec)) && time < (i*(t1_sec+t2_sec)+t1_sec)) F_PROFILE(f,thread,position)=heat_flux; if (time >= (i*(t1_sec+t2_sec)+t1_sec) && time < (i*(t1_sec+t2_sec)+t1_sec+t2_sec)) F_PROFILE(f,thread,position)=0.0; } } end_f_loop(f,thread) } i want to write UDF for 2nd case. Please write a code for that(2nd case). Each and every minute need to turn the fulx ON 85 time and 85 time OFF(170 times triggering in one minute). |
|
October 22, 2018, 06:24 |
|
#5 |
Senior Member
|
You only need to adjust the time intervals and number of repeats.
Code:
#include "udf.h" DEFINE_PROFILE(ON_OFF,thread,position) { face_t f; int i_repeat, n_repeats; real time, heat_flux, t1_sec, t2_sec, i_sec; real hf; t1_sec=1.0/170; t2_sec=1.0/170; n_repeats = 85*60; heat_flux = 12345; time=CURRENT_TIME; /** * time = i_repeat*(t1_sec + t2_sec) + i_sec; * where i_repeat is the largest integer s.t. * 0 < i_sec < t1_sec + t2_sec * The heat flux is then determined by comparing * i_sec and t1_sec. */ i_repeat = time/(t1_sec+t2_sec); if (n_repeats <= i_repeat) return; i_sec = time - i_repeat*(t1_sec+t2_sec); if (i_sec < t1_sec) { hf = heat_flux; } else { hf = 0.0; } begin_f_loop(f,thread) { F_PROFILE(f,thread,position) = hf; } end_f_loop(f,thread) } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf for one dimensional linear motion based on force | maccheese | Fluent UDF and Scheme Programming | 2 | September 1, 2019 03:18 |
Save output of udf in another udf! | JuanJoMex | FLUENT | 0 | February 8, 2018 13:43 |
UDF Compilation Error - Loading Library - COMMON Problem! Help! | robtheslob | Fluent UDF and Scheme Programming | 8 | July 24, 2015 01:53 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |