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

Controlling the UDF within the Minute

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By blackmask
  • 1 Post By blackmask

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2018, 03:18
Default Controlling the UDF within the Minute
  #1
New Member
 
Siddharth
Join Date: Nov 2016
Posts: 11
Rep Power: 10
siddhu23 is on a distinguished road
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)
}
transient
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.
siddhu23 is offline   Reply With Quote

Old   October 21, 2018, 00:38
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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)
}
siddhu23 likes this.
blackmask is offline   Reply With Quote

Old   October 22, 2018, 00:34
Default
  #3
New Member
 
Siddharth
Join Date: Nov 2016
Posts: 11
Rep Power: 10
siddhu23 is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
Thank you so much I will try this and let you know
siddhu23 is offline   Reply With Quote

Old   October 22, 2018, 06:11
Default
  #4
New Member
 
Siddharth
Join Date: Nov 2016
Posts: 11
Rep Power: 10
siddhu23 is on a distinguished road
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)
}
You can see the image for 1st one.

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).
Attached Images
File Type: jpg Capture11111112233.JPG (45.0 KB, 7 views)
siddhu23 is offline   Reply With Quote

Old   October 22, 2018, 06:24
Default
  #5
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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)
}
siddhu23 likes this.
blackmask is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 13:41.