|
[Sponsors] |
[FLUENT] UDF NOT working in new version of Fluent |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 6, 2017, 10:28 |
[FLUENT] UDF NOT working in new version of Fluent
|
#1 |
New Member
Giorgio
Join Date: Jun 2016
Posts: 12
Rep Power: 9 |
Dear all,
I am working on simulating the motion of a leaflet by applying a rigid body motion by means of the DEFINE_CG_MOTION macro. I wrote a UDF for the movement; I compiled it and tested it in Fluent version 15.0 and it was perfectly reproducing what it was meant to do. Then, last week I had to upgrade the software and I had version 17.1 installed. When I compiled the UDF this time the motion is completely incorrect although I have used the same structure of the code. I have searched into the manual and compared the sections regarding the explanation of the macro. It seems that in the new version the software can call multiple times the UDF and that might lead to failure or incorrect updates of the velocity. I checked the example in the manual but I did not really understand it. Can anybody help me? I also upload the code that I wrote so that you can have a better idea of what I am doing. I really need some suggestions to integrate this concept in the code. Thank you in advance. F. |
|
February 6, 2017, 10:55 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
I don't know what caused your problem.
But still, I could see some cleaning-up to do in your code to make it simpler. And simpler usually means that there are fewer places to make mistakes. Code:
#include "udf.h" #include <math.h> #include <float.h> float quadratic(a,b,c,time) { return (a*time*time+b*time+c); } DEFINE_CG_MOTION(leaflet_1, dt, vel, omega, time, dtime) { real omega_1, omega_2, omega_3, ang_vel; const float tau = 0.866; const float timefrac=time/tau-(int)(time/tau); /* time = (i-1+timefrac) * tau ; time-(i-1)*tau = timefrac * tau */ float a,b,c; NV_S(vel, =, 0.0); NV_S(omega, =, 0.0); if (timefrac < 0.005773672055427) /*interval 1*/ { a=2159.567580764660; b=-2.407990408052271; c=-0.011976420486241; } else if (timefrac < 0.011547344110855) /*interval 2*/ { a=-9353.043658991941; b=112.7181219895138; c=-0.299791701480157; } else if (timefrac < 0.017321016166282)) /*interval 3*/ { a=35252.60705520311; b=-779.3948922943873; c=4.160773369939347; } else if (timefrac < 0.023094688221709) /*interval 4*/ ... } else if (timefrac < 1) /*interval 39*/ { a=-85.400423181754974; b=145.5055425427474; c=-61.973216494809272; } omega_1 = quadratic(a,b,c,timefrac*tau); omega_2 = quadratic(a,b,c,timefrac*tau+dtime); omega_3 = quadratic(a,b,c,timefrac*tau+dtime/2); omega[0] = (omega_1+omega_2+4*omega_3)/6; } |
|
February 6, 2017, 12:23 |
|
#3 |
New Member
Giorgio
Join Date: Jun 2016
Posts: 12
Rep Power: 9 |
Dear pakk,
thank you for your quick reply. I really liked the way you coded it. It is simpler and smoother and it was totally understandable. Unfortunately when I tried this new version in Fluent, it does not solve the problem. Actually, the motion becomes even more chaotic. I do not think it is a problem of the code because I have just written a similar function in matlab (since I am much more familiar with it rather than C language) keeping the same structure and it perfectly reproduces the behaviour of the angular velocity (a picture in the attachment). Do you have in mind any other suggestions? |
|
February 7, 2017, 04:46 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
I think you just messed up with the numbers.
If I used your numbers, I sort of see your graph, but with a lot of distortions, especially for t>0.3. You are putting in numbers for chaotic motion, so Fluent will give that to you! Your interpolation is a bit unusual. You use omega = a*t^2 + b*t + c on each interval. But to get nicer numbers a, b and c, you could use omega = a*(t-t0)^2+b*(t-t0)+c, where t0 is the start of the interval. |
|
February 10, 2017, 09:12 |
|
#5 |
Member
saurabh kumar gupta
Join Date: Jul 2016
Location: kanpur,india
Posts: 53
Rep Power: 9 |
Hi,
i am doing a simulation where blade will rotate. i have defined a udf but it is not compiling. it will be great if you look at it. #include "udf.h" #include "math.h" DEFINE_SDOF_PROPERTIES(Valve_6dof, prop, dt, time, dtime) { prop[SDOF_MASS] = 0.01467375; prop[SDOF_IZZ] = 0.00000000008995543548; prop[SDOF_IXX] = 0.00000000002266435548; prop[SDOF_IYY] = 0.00000000006729108; prop[SDOF_ZERO_TRANS_X] = TRUE; prop[SDOF_ZERO_TRANS_Y] = TRUE; prop[SDOF_ZERO_TRANS_Z] = TRUE; prop[SDOF_ZERO_ROT_X] = TRUE; prop[SDOF_ZERO_ROT_Y] = TRUE; prop[SDOF_ZERO_ROT_Z] = FALSE; Message("\n2d : Updated 6DOF properties "); } |
|
February 10, 2017, 11:45 |
|
#6 |
New Member
Giorgio
Join Date: Jun 2016
Posts: 12
Rep Power: 9 |
Dear rsaurabh,
first of all, I would like to point out that your question is not really related to this thread. Nevertheless, you should change the second line of your code: it is #include <math.h> and not with inverted commas. |
|
February 10, 2017, 14:13 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem in compiling fluent UDF lunched from MATLAB | cfdman10 | Fluent UDF and Scheme Programming | 16 | December 5, 2019 05:32 |
How to solve UDF compilation problems in Fluent. | pakk | Fluent UDF and Scheme Programming | 16 | September 10, 2018 02:48 |
A Problem of Fluent Interpreted UDF: parse error | knight | Fluent UDF and Scheme Programming | 25 | August 16, 2018 10:26 |
how to put udf inlet velocity and udf outlet pressure in fluent | raminostadi | Fluent UDF and Scheme Programming | 4 | July 3, 2017 06:43 |
Compiling UDF in Fluent 12 | jsm | FLUENT | 1 | July 22, 2009 07:40 |