CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   udf for pressure variation with time (https://www.cfd-online.com/Forums/fluent-udf/134474-udf-pressure-variation-time.html)

laraib April 30, 2014 04:29

udf for pressure variation with time
 
1 Attachment(s)
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

macfly April 30, 2014 08:42

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


laraib May 5, 2014 03:41

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 May 5, 2014 03:42

i started off with the same example and derived the udf i have posted ..but now its not running

macfly May 5, 2014 07:09

Then you have to define y like this in your udf:

real y = CURRENT_TIME;

laraib May 8, 2014 04:30

1 Attachment(s)
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 :confused:
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 .

macfly May 8, 2014 06:52

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

laraib May 8, 2014 10:09

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

macfly May 8, 2014 10:17

show us your udf please, not in an attached file, directly in a reply

laraib May 10, 2014 00:34

# 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

macfly May 10, 2014 01:13

inspect the braces compared to the example in post #2...

laraib May 13, 2014 04:32

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

macfly May 13, 2014 08:09

Quote:

Originally Posted by laraib (Post 490955)
# 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.

laraib May 13, 2014 11:56

# 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)
}

macfly May 13, 2014 12:22

Quote:

Originally Posted by laraib (Post 491588)
# 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.

Kokemoor May 14, 2014 12:17

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.

laraib May 16, 2014 00:58

i have changed the braces as suggested by macfly. but still the problem previals that the solution does not initialize :confused:


All times are GMT -4. The time now is 04:25.