# Specifying equation of motion in Fluent (UDF)

 Register Blogs Members List Search Today's Posts Mark Forums Read August 6, 2019, 02:00 Specifying equation of motion in Fluent (UDF) #1 New Member   Join Date: Jul 2019 Posts: 9 Rep Power: 4 I have a 2-d plate hinged at (0,0). It is free to rotate about the z-axis, due to the fluid forces. The motion is purely rotational about z-axis following the equation of motion as below. M is the moment of the previous time step about the z-axis due to fluid forces. the theta is the rotation angle about z-axis. Please help me in writing the UDF. θ(t)=M(e^(-0.823t)) {(0.0001709(e^0.823t))-(0.000017177 sin⁡(8.19t))-(0.0001709 cos⁡(8.19t)) }   August 6, 2019, 02:13 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,989 Rep Power: 30  ansys fluent customization manual chapter -> DEFINE_GRID_MOTION best regards   August 6, 2019, 04:38 #3 New Member   Join Date: Jul 2019 Posts: 9 Rep Power: 4 I am unable to write the udf. Could you help me in writing the code?   August 6, 2019, 04:39 #4 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,989 Rep Power: 30  why you are unable? best regards   August 6, 2019, 07:39 #5 New Member   Join Date: Jul 2019 Posts: 9 Rep Power: 4 I have been trying for a long time. But I am not sure that I fully understand the functioning and the variables in the macros. Can you please help?   August 7, 2019, 00:37 #6 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,989 Rep Power: 30  show you code best regards   August 7, 2019, 02:31 #7 New Member   Join Date: Jul 2019 Posts: 9 Rep Power: 4 @AlexanderZ The equation of motion is: θ(t)=M(e^(-0.823t)) {(0.0001709(e^0.823t))-(0.000017177 sin⁡(8.19t))-(0.0001709 cos⁡(8.19t)) } M is the moment about the z-axis. All other dof are arrested. The domains are created similar to the link below (the airfoil replaced by flat plate): https://www.youtube.com/watch?v=G0zAHv0rEa8 The fluid flow over the flat plate generates moment about z-axis of the plate (origin). this moment should rotate the inner domain with fine mesh , as rigid body, according to the equation of motion above. On rotation, the effective angle of attack of plate changes, and hence the fluid forces and moments. This changes the moment about the z-axis which further rotates the domain (hence the plate AOA). The moment is fed into the equation of motion at the beginning of every time-step. The time step iteration should end with the rotation of the inner domain as rigid body. This process continues, until the end of time. In dynamic mesh options, I would specify the inner domain as passive 6dof udf rigid motion (i.e., no deformation in the inner domain mesh) and the plate as sdof udf rigid motion and the outer boundary as deforming zone #include "udf.h" DEFINE_CG_MOTION (rotational_motion, dt, cg_vel, cg omega, time, dtime) { Domain *d =Get Domain(1); Thread *t_object = Lookup_Thread(d, 2); real moment [ND_ND], cg[ND_ND], force [ND_ND]; Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE) real moment_z= moment ; \* To compute the moment at the beginning of the time step and feed into the equation of motion */ real i1 = exp(-0.823*time); real i2 = cos (8.19*time); real i3 = 48870 sin(8.19*time); real i4 = 2.893 pow(10,-8); real omega = -i4 * moment_z * i1 * (i2-i3); cg_vel=0.0; cg_vel =0.0; cg_ve1=0.0; cg omega -0.0 ; cg omega (1)-0.0; cg omega =real omega; }   August 8, 2019, 01:27 #8 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,989 Rep Power: 30  Code: `moment [ND_ND]` means that it is array, which has 2 elements in case of 2D solver and 3 elements in case of 3D solver In case of 3D it has indexes 0,1,2 -> so if you want moment in z direction you should use moment, but not moment try this code, explain your results: Code: ```#include "udf.h" DEFINE_CG_MOTION (rotational_motion, dt, cg_vel, cg omega, time, dtime) { Domain *d =Get Domain(1); Thread *t_object = Lookup_Thread(d, 2); real moment [ND_ND], cg[ND_ND], force [ND_ND]; real i1, i2, i3,i4,omega,moment_z; Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE) moment_z= moment ; \* To compute the moment at the beginning of the time step and feed into the equation of motion */ i1 = exp(-0.823*time); i2 = cos (8.19*time); i3 = 48870 sin(8.19*time); i4 = 2.893 pow(10,-8); omega = -i4 * moment_z * i1 * (i2-i3); cg_vel=0.0; cg_vel =0.0; cg_ve1=0.0; cg omega -0.0 ; cg omega (1)-0.0; cg omega =real omega; }``` best regards   August 8, 2019, 02:17 #9 New Member   Join Date: Jul 2019 Posts: 9 Rep Power: 4 Thanks for your reply! Do you have any idea why such error pops up when I try to compile the above udf The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64). The system cannot find the file specified. Please help!   August 8, 2019, 07:43 #10
Senior Member

Alexander
Join Date: Apr 2013
Posts: 1,989
Rep Power: 30  Quote:
 The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64). The system cannot find the file specified.
first of all, you've started fluent in @d mode, buy your UDF uses z-axis, which is not exists in 2D

second isseu -> you are not compiling UDF, but try to load it. Click button build instead of load (make it in 3D, or change UDF)

best regards   August 10, 2019, 10:49 #11 New Member   Join Date: Jul 2019 Posts: 9 Rep Power: 4 Hello, There is no error in compilation now. Thanks to you. Now the problem is the moment about the z-axis doesn't load after each time step iteration. If I omit the moment part in the previous udf, then I can see my udf running properly in the zone motion in dynamic mesh tab. But with the moment part in the udf, the motion is not updated. Can you help? #include "udf.h" DEFINE_CG_MOTION (rotational_motion, dt, cg_vel, cg omega, time, dtime) { real i1, i2, i3,i4,omega; i1 = exp(-0.823*time); i2 = cos (8.19*time); i3 = 48870 sin(8.19*time); i4 = 2.893 pow(10,-8); omega = -i4 * i1 * (i2-i3); cg_vel=0.0; cg_vel =0.0; cg_ve1=0.0; cg omega -0.0 ; cg omega (1)-0.0; cg omega =real omega; }   August 11, 2019, 19:16 #12 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,989 Rep Power: 30  it seem that this part of code computes momentum Code: ```Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE) moment_z= moment ; \* To compute the moment at the beginning of the time step and feed into the equation of motion */``` if nothing works when these lines are in your code, then it means, that moment  is zero so you got zero in Compute_Force_And_Moment function (this function was made by you) check it best regards  Tags equation of motion, fluent - udf, grid motion Thread Tools Search this Thread Show Printable Version Email this Page Search this Thread: Advanced Search Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules Similar Threads Thread Thread Starter Forum Replies Last Post maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 02:18 Albert Lee FLUENT 0 July 1, 2018 08:21 Qureshi FLUENT 7 March 23, 2017 07:37 Schmitt pierre-Louis FLUENT 26 September 1, 2016 10:29 Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20

All times are GMT -4. The time now is 22:55.