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

UDF ramping inlet velocity for steady simulation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 7, 2024, 11:12
Default UDF ramping inlet velocity for steady simulation
  #1
New Member
 
F. Lang
Join Date: Sep 2019
Location: Germany
Posts: 3
Rep Power: 7
F. Lang is on a distinguished road
Hello everyone,
I am trying to define a UDF to ramp up an inlet velocity for a steady simulation after a set amount of iterations.
However I am getting a parse error when trying to access the iteration number via nres:
Code:
 int current_iter = (nres == 0) ? (0) : ((int) count2[nres - 1]);
Quote:
ERROR ./AppData/Local/Temp/udf-veloRamp.c.6332.0.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.14000.1.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.14368.2.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.21128.3.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.17820.4.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.10796.5.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.13712.6.c: line 18: parse error
ERROR ./AppData/Local/Temp/udf-veloRamp.c.9300.7.c: line 18: parse error
What is my mistake? Is there a better way to get the iteration number?

Thanks





Full UDF-code below:
Code:
  /******************************************************************
  UDF for specifying ramping velocity profile BC
  *******************************************************************/
  
  #include "udf.h"
  DEFINE_PROFILE(velocity_magnitude, t, i)
  {
          real start_velocity,end_velocity;
          int ramp_start,ramp_end;
          real line_slope,line_intercept;       
          face_t f;
  
          start_velocity=0.0;            // starting & end velocity [m/s] 
          end_velocity=10.0;
          ramp_start=10;                 // ramp start & end timestep [-]
          ramp_end=1000;
  
          int current_iter = (nres == 0) ? (0) : ((int) count2[nres - 1]);      // current iteration
  
          line_slope = (end_velocity-start_velocity)/(ramp_end-ramp_start);
          line_intercept = start_velocity-line_slope*ramp_start;
  
          begin_f_loop(f,t)
                 {
                         if (current_iter<ramp_start)                                                                               // velocity before ramp [m/s]
                         {
                                 F_PROFILE(f,t,i) = 0.0;
                         }
                         else if (current_iter>=ramp_start && current_iter<=ramp_end)                // ramping velocity
                         {
                                 F_PROFILE(f,t,i) = line_slope*current_iter+line_intercept;
                         }
                         else
                         {
                                 F_PROFILE(f,t,i) = end_velocity;
                         }
                 }
          end_f_loop(f,t)
  }
F. Lang is offline   Reply With Quote

Old   June 21, 2024, 18:33
Default
  #2
New Member
 
hasnaa hasnaa
Join Date: Jun 2024
Posts: 5
Rep Power: 2
hasnaaoub is on a distinguished road
I am doing a CFD study on an electric car.
Currently, I am in the setup phase. I tried to integrate solar radiation using a function in the "User Defined" interface with C code. I tried to use the "Interpreted" extension, but I still encounter an error. When I try to use the "Compiled" extension, another error occurs.

Can you send me an example of a udf function that you have already used in your studies and that can be used in ansys?

Thank you in advance for your he
Attached Images
File Type: jpg Figure 1.jpg (82.6 KB, 4 views)
File Type: jpg Figure 2.jpg (135.2 KB, 3 views)
File Type: jpg Figure 3.jpg (126.7 KB, 2 views)
hasnaaoub is offline   Reply With Quote

Reply

Tags
fluent - udf, inlet bc, velocity bc


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
Ramping velocity inlet for ship simulation antoineh OpenFOAM Running, Solving & CFD 6 July 5, 2024 05:44
Problem using UDF for velocity inlet panasonic18 Fluent UDF and Scheme Programming 2 June 13, 2018 03:59
Udf to measure radius of inlet as it changes - FSI simulation DamR Fluent UDF and Scheme Programming 0 December 28, 2016 03:54
3D velocity inlet UDF zumaqiong Fluent UDF and Scheme Programming 2 October 24, 2016 05:44
UDF: Change boundary condition. Velocity inlet to pressure inlet at time "t" jpina FLUENT 10 April 11, 2015 15:19


All times are GMT -4. The time now is 02:36.