|
[Sponsors] |
April 30, 2014, 05:29 |
udf for pressure variation with time
|
#1 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
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 |
|
April 30, 2014, 09:42 |
|
#2 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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) } |
|
May 5, 2014, 04:41 |
|
#3 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
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 .
|
|
May 5, 2014, 04:42 |
|
#4 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
i started off with the same example and derived the udf i have posted ..but now its not running
|
|
May 5, 2014, 08:09 |
|
#5 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Then you have to define y like this in your udf:
real y = CURRENT_TIME; |
|
May 8, 2014, 05:30 |
|
#6 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
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 . |
|
May 8, 2014, 07:52 |
|
#7 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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 |
|
May 8, 2014, 11:09 |
|
#8 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
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 |
|
May 8, 2014, 11:17 |
|
#9 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
show us your udf please, not in an attached file, directly in a reply
|
|
May 10, 2014, 01:34 |
|
#10 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
# 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 |
|
May 10, 2014, 02:13 |
|
#11 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
inspect the braces compared to the example in post #2...
|
|
May 13, 2014, 05:32 |
|
#12 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
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 |
|
May 13, 2014, 09:09 |
|
#13 | |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Quote:
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. |
||
May 13, 2014, 12:56 |
|
#14 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
# 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) } |
|
May 13, 2014, 13:22 |
|
#15 | |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Quote:
|
||
May 14, 2014, 13:17 |
|
#16 |
Senior Member
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 14 |
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. |
|
May 16, 2014, 01:58 |
|
#17 |
New Member
laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 12 |
i have changed the braces as suggested by macfly. but still the problem previals that the solution does not initialize
|
|
|
|
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 |