|
[Sponsors] |
September 15, 2016, 16:21 |
Problem with UDF for CG Circular Motion
|
#1 |
New Member
Luthfilaudri Nadhira
Join Date: Sep 2016
Posts: 4
Rep Power: 10 |
Hi Everyone,
I am quite new in C++ programming, especially in UDF for Fluent. I have tried writing a UDF for circular motion for a solid body with radius "R" (0.05 meter) and constant rotational speed "rpm" (3000 rpm) on x-z plane in clockwise direction. Below is the UDF I wrote: =============================================== #include <stdio.h> #include <math.h> #include "udf.h" DEFINE_CG_MOTION(circl, dt, vel, omega, time, dtime) { real rpm, pi, R, theta; pi = 3.14159265; rpm = 2*pi*3000/60; R = 0.05; NV_S(vel, = , 0.0); NV_S(omega, = , 0.0); vel[0] = R*rpm*sin(rpm*time); vel[2] = -R*rpm*cos(rpm*time); theta = rpm*time*180/pi; Message("time:%f vel0:%f vel2:%f theta:%f \n", time, vel[0], vel[2], theta); } =============================================== The problem that I have is the preview motion of the UDF is different for different time step that I used. I believe that different time step should not change the trajectory of the motion, right? It should only affect the smoothness of the motion. I don't what is wrong with my UDF. Does anyone know what is the problem with my UDF? Thanks in advance! |
|
September 16, 2016, 03:08 |
|
#2 |
Member
Davoud Malekian
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Hello,
i give you an example here so maybe we can understand your motion better: assume that you want to calculate vel[0] for these time steps: 0.1s & 0.25s until you reach 1 second. the results are listed below: for time_step=0.1s *******************for time_step=0.25s 0.1s vel[0]=-129.9******************** 0.25s vel[0]=75 0.2s vel[0]=-129.9 0.3s vel[0]=0 0.4s vel[0]=129.9 0.5s vel[0]=129.9******************** 0.5s vel[0]=129.9 0.6s vel[0]=0 0.7s vel[0]=-129.9 0.8s vel[0]=-129.9********************0.75s vel[0]=150 0.9s vel[0]=0 1s vel[0]=129.9******************** 1s vel[0]=129.9 as you can see in the results, for the time_step=0.25 we didnt get any negative(minus) velocity nor zero velocity, but when the time_step is 0.1s we have zero and negative velocities, the only thing that can be said about your project is that by reducing the time_step your motion can be simulated more accurately but by increasing time_step your motion will be just an approximation of your real motion and it won't be that accurate(so many fluctuations and ... will be dismissed) and one more thing, i think(not sure) your code is ok. regards, |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CG Motion UDF Problem | leoarmas | Fluent UDF and Scheme Programming | 17 | February 14, 2023 09:59 |
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM | Rizwan | Fluent UDF and Scheme Programming | 40 | March 18, 2018 07:05 |
problem in definition of secondary phase volume fraction in UDF | hadii | FLUENT | 9 | July 20, 2016 05:46 |
UDF for Airfoil in Circular motion (2D) | sohail_27 | Fluent UDF and Scheme Programming | 4 | October 4, 2010 14:36 |
UDF PROBLEM | anant | FLUENT | 2 | January 17, 2007 01:15 |