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

udf for pressure variation with time

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 30, 2014, 05:29
Default udf for pressure variation with time
  #1
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
i have been working on designing a udf for systolic and diastolic pressure variations. so far i have compiled it in C but fluent gives me error in line 5 . if anybody can detect that error
i have attached my udf .
regards
Attached Files
File Type: c Untitled1.c (412 Bytes, 46 views)
laraib is offline   Reply With Quote

Old   April 30, 2014, 09:42
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
So you meant pressure variation with space and not time?

There are typos in your udf, you didn't give any value to y, etc. Start with this example from UDF manual 15.0 and insert your else-if conditions:

2.3.19.3. Example 1 - Pressure Profile
Code:
/***********************************************************************
 UDF for specifying steady-state parabolic pressure profile boundary
 profile for a turbine vane
 ************************************************************************/
 #include "udf.h"
 DEFINE_PROFILE(pressure_profile,t,i)
 {
    real x[ND_ND];    /* this will hold the position vector */
    real y;
    face_t f;
    begin_f_loop(f,t)
      {
       F_CENTROID(x,f,t);
       y = x[1];
       F_PROFILE(f,t,i) = 1.1e5 - y*y/(.0745*.0745)*0.1e5;
      }
    end_f_loop(f,t)
 }
macfly is offline   Reply With Quote

Old   May 5, 2014, 04:41
Default
  #3
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
the pressure variation is with time and i gave the initial value for time = 0.005 sec even that didnt work. udf does not run after line 5. nd y is time .
laraib is offline   Reply With Quote

Old   May 5, 2014, 04:42
Default
  #4
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
i started off with the same example and derived the udf i have posted ..but now its not running
laraib is offline   Reply With Quote

Old   May 5, 2014, 08:09
Default
  #5
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Then you have to define y like this in your udf:

real y = CURRENT_TIME;
macfly is offline   Reply With Quote

Old   May 8, 2014, 05:30
Default
  #6
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
thank you so much . my udf runs now and is detected at the inlet pressure options.
but the solution does not initialize and gives errors that i am unable to comprehend
i have attached an image of the errors
kindly if u can have a look.
and secondly do i need to start my fluent via SDK? as it is already interpreting the udf .
Attached Images
File Type: jpg Untitled.jpg (31.0 KB, 21 views)
laraib is offline   Reply With Quote

Old   May 8, 2014, 07:52
Default
  #7
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
It's hard to say because I don't really know what you tried...

In the udf that you attached in your 1st post, it looks like you are using y for 2 things: position and time.

You should define y as position: real y; .... then inside the f_loop: y = x[1];

And define another variable as time: real t = CURRENT_TIME;

Good luck
macfly is offline   Reply With Quote

Old   May 8, 2014, 11:09
Default
  #8
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
i dont intend to give y two variables the equations i have used are with respect to time . so y is time not position . so i do not need to define y=x[1], as this represents position. if u can kindly let me know the changes i have to make to make y only time varying
regards
laraib is offline   Reply With Quote

Old   May 8, 2014, 11:17
Default
  #9
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
show us your udf please, not in an attached file, directly in a reply
macfly is offline   Reply With Quote

Old   May 10, 2014, 01:34
Default
  #10
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
# include "udf.h"
#DEFINE_PROFILE(pressure_profile,t,i)
{
real x[ND_ND]
real y= CURRENT_TIME;
face_t f;

}
begin_f_loop(f,t);
{
F_CENTROID(x,f,t);

if (y>0.005 && y<=0.4);
F_profile(f,t,i)=(-492.9*y^4+1224.3*y^3-1081.8*y^2+357.6*y+64.2);
else if (y>0.4 && y<=0.46);
F_profile(f,t,i)= (100*y+60);
else
F_profile(f,t,i)=(14195*y^4-11116*y^3+2087*y^2+106*y+70.9);
end_f_loop(f,t)
}

here is my udf. will appreciate any input
regards
laraib is offline   Reply With Quote

Old   May 10, 2014, 02:13
Default
  #11
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
inspect the braces compared to the example in post #2...
macfly is offline   Reply With Quote

Old   May 13, 2014, 05:32
Default
  #12
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
the udf runs in visual studio giving no errors or warnings. now i am going to download SDK. i hope fluent reads it this time
thank you for ur help
laraib is offline   Reply With Quote

Old   May 13, 2014, 09:09
Default
  #13
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by laraib View Post
# include "udf.h"
#DEFINE_PROFILE(pressure_profile,t,i)
{
real x[ND_ND]
real y= CURRENT_TIME;
face_t f;

} what's that brace for???
begin_f_loop(f,t);
{
F_CENTROID(x,f,t);

if (y>0.005 && y<=0.4);
F_profile(f,t,i)=(-492.9*y^4+1224.3*y^3-1081.8*y^2+357.6*y+64.2);
else if (y>0.4 && y<=0.46);
F_profile(f,t,i)= (100*y+60);
else
F_profile(f,t,i)=(14195*y^4-11116*y^3+2087*y^2+106*y+70.9);
} missing brace here
end_f_loop(f,t)
}

here is my udf. will appreciate any input
regards


I don't know about running UDFs in VS, but I can tell you that it's preferable to follow the UDF Manual syntax if you want your udf to work.
macfly is offline   Reply With Quote

Old   May 13, 2014, 12:56
Default
  #14
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
# include "udf.h"
#DEFINE_PROFILE(pressure_profile,t,i)
{
real x[ND_ND]
real y= CURRENT_TIME;
face_t f;

} this brace is closure for the parameters above.its correct in syntax
begin_f_loop(f, t);
{
F_CENTROID(x, f, t);

if (y > 0.005 && y <= 0.4);
F_profile(f, t, i) = (-492.9*y ^ 4 + 1224.3*y ^ 3 - 1081.8*y ^ 2 + 357.6*y + 64.2);
else if (y > 0.4 && y <= 0.46);
F_profile(f, t, i) = (100 * y + 60);
else
F_profile(f, t, i) = (14195 * y ^ 4 - 11116 * y ^ 3 + 2087 * y ^ 2 + 106 * y + 70.9);
}brace not required here otherwise it gives errors
end_f_loop(f,t)
}
laraib is offline   Reply With Quote

Old   May 13, 2014, 13:22
Default
  #15
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by laraib View Post
# include "udf.h"
#DEFINE_PROFILE(pressure_profile,t,i)
{
real x[ND_ND]
real y= CURRENT_TIME;
face_t f;

} this brace is closure for the parameters above.its correct in syntax No, because the corresponding opening brace opens the body of the DEFINE_PROFILE function, not some parameters declaration. And it's probably useless and a bad programming practice to define parameters within braces, think I've never seen that.
begin_f_loop(f, t);
{
F_CENTROID(x, f, t);

if (y > 0.005 && y <= 0.4);
F_profile(f, t, i) = (-492.9*y ^ 4 + 1224.3*y ^ 3 - 1081.8*y ^ 2 + 357.6*y + 64.2);
else if (y > 0.4 && y <= 0.46);
F_profile(f, t, i) = (100 * y + 60);
else
F_profile(f, t, i) = (14195 * y ^ 4 - 11116 * y ^ 3 + 2087 * y ^ 2 + 106 * y + 70.9);
}brace not required here otherwise it gives errors You need to read the UDF Manual, the set of commands in looping macros are always within braces.
end_f_loop(f,t)
}
Last post from me, good luck.
macfly is offline   Reply With Quote

Old   May 14, 2014, 13:17
Default
  #16
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 14
Kokemoor is on a distinguished road
Macfly is right about the braces. The variable declarations and the f_loop are both part of the define macro. Closing your brace after the variable declarations says that the macro ends here, and your loop isn't part of anything.

Using Visual Studio to decide whether your code will run or not won't tell you anything useful; UDFs are not programs, they are chunks of code that Fluent uses to compile libraries.
Kokemoor is offline   Reply With Quote

Old   May 16, 2014, 01:58
Default
  #17
New Member
 
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12
laraib is on a distinguished road
i have changed the braces as suggested by macfly. but still the problem previals that the solution does not initialize
laraib 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
Transient simulation not converging skabilan OpenFOAM Running, Solving & CFD 14 December 17, 2019 00:12
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 14:12
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58
calling result of a UDF into current time step Komon Fluent UDF and Scheme Programming 1 April 1, 2012 20:53
Modeling in micron scale using icoFoam m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 01:36


All times are GMT -4. The time now is 14:48.