CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

CG Motion Absolute coordinates

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 3, 2010, 09:36
Default
  #1
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
Almostafa,

First off, it looks like you could simplify your code down to just:

# include "udf.h"
# include "dynamesh_tools.h"
DEFINE_CG_MOTION(pump,dt,vel,omega,time,dtime)
{
real freq_t;
omega [2] = freq_t;
}

But I don't think it really matters if you do or not. What exactly is going wrong with your mesh? Perhaps you should make your own thread about it. Anyway, if you are using a Dynamic Mesh I believe you should just use triangular cells (or tetrahedral for 3D). That may be your issue.
montag dp is offline   Reply With Quote

Old   August 3, 2010, 09:51
Default rotation about z axis
  #2
Member
 
ahmad
Join Date: Jul 2010
Posts: 57
Rep Power: 15
almostafa67 is on a distinguished road
dear montag dp...
my udf really worked
but i faced new problem
small circle has been locked in its end points!(look at the images)
how can i tell fluent move small cylinder and let its end be free????
almostafa67 is offline   Reply With Quote

Old   August 3, 2010, 09:52
Default
  #3
Member
 
ahmad
Join Date: Jul 2010
Posts: 57
Rep Power: 15
almostafa67 is on a distinguished road
sorry forgot attach images
Attached Images
File Type: jpg problem.JPG (22.7 KB, 272 views)
File Type: jpg problem 2.JPG (8.9 KB, 212 views)
almostafa67 is offline   Reply With Quote

Old   August 3, 2010, 12:05
Default Ok, now really confused
  #4
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
I thought I had this right, but now I'm just more confused. I'm trying to just get motion about the x and y axes. I thought the Euler rate equations would help do this, but then I realized I'm still getting rotation about z. I didn't think it was a big deal because Fluent reported it to be less than 1 degree.

It looked like a lot more though, so I tried testing it again without the Euler angles in there. The motion looks exactly the same. But now Fluent reports there to be 0 angle about z after previewing mesh motion. I'm positive that when I tried this before without the Euler angles business it reported the z-angle to be about what it looked like ~20 degrees). I'm so confused.

And almostafa, I really think you'd get more responses if you just made your own thread instead of constantly changing the subject in mine. Your problem is not really even related to mine. I've helped you all I can, in this thread and my other thread and via PM. Please only post in my threads if you can help out with the problems I'm having.

EDIT: So, in all it seems my assumption about CG rotational speed being relative to the moving body axes at all times may be wrong. I really don't know. Perhaps the rotation is actually relative to the stationary frame at all times? In that case why is my wing rotating about the z-axis when I specify 0 rotational velocity about z? I'm very confused about this whole thing.

Last edited by montag dp; August 3, 2010 at 16:07.
montag dp is offline   Reply With Quote

Old   August 3, 2010, 16:24
Default
  #5
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
For reference, here is a copy of my code. The first would define flapping + pitching motion, assuming the rotations are defined relative to the stationary axes:

Code:
#include "udf.h"

DEFINE_CG_MOTION(wing, dt, vel, omega, time, dtime)
{
real a1, a2, w, pi;

pi = 3.141592654;

/* define motion variables */
  a1 = 30 * pi / 180; /* 30 degree flapping amplitude */
  a2 = 30 * pi / 180; /* 30 degree feathering amplitude */
  w = 2 * pi * 25; /* 25 Hz frequency */

/* define wing rotational motion in stationary coordinates */
  omega[0] = - a1 * w * cos(w*time);    /* flapping speed */             
  omega[1] = a2 * w * sin(w*time);    /* feathering speed */
  omega[2] = 0;                    
}
And here is the code for the case where I assume the angular rates are relative to the moving body axes at all times. Notice the transformation from body rates to reference frame rates in the omega[] terms:

Code:
#include "udf.h"

DEFINE_CG_MOTION(wing, dt, vel, omega, time, dtime)
{
real a1, a2, thxdot, thydot, thzdot, w, pi, thx, thy;

pi = 3.141592654; 

/* define motion variables */
  a1 = 30 * pi / 180; /* 30 degree flapping amplitude */
  a2 = 30 * pi / 180; /* 30 degree feathering amplitude */
  w = 2 * pi * 25; /* 25 Hz frequency */

/* define motion in reference axes */
  thx = DT_THETA (dt)[0] * pi/180;    /* flapping angle - set by orientation macro DT_THETA */
  thy = DT_THETA (dt)[1] * pi/180;    /* feathering angle - set by orientation macro DT_THETA */
  thxdot= - a1 * w * cos(w*time);    /* flapping speed */
  thydot = a2 * w * sin(w*time);    /* feathering speed */
  thzdot = 0;                /* yawing (spinning) speed */

/* define wing rotational motion in body coordinates */
  omega[0] = thxdot - thzdot * sin(thy);                
  omega[1] = thydot * cos(thx) + thzdot * cos(thy) * sin(thx);
  omega[2] = thzdot * cos(thy) * cos(thx) - thydot * sin(thx);                    
}
The issue is, the last I checked these two udfs actually gave me the same (incorrect) motion, hence the confusion. The real issue in all of this is I'm getting significant rotation about the reference z axis when none is desired. Please fill me in if you have any insight on this.

Dan
montag dp is offline   Reply With Quote

Old   February 1, 2011, 11:11
Default
  #6
New Member
 
Dave Smith
Join Date: Jul 2010
Posts: 27
Rep Power: 15
davesmith_01 is on a distinguished road
Hi
Have you found a solution to your problem I really need some help.

I dont unuderstand the rotational method in Fluent it does not make sense.

I am trying to model a flapping wing in 3D and I cant seem to understand whats wrong. I am very confused.

I choose to rotate about the x(flapping) and z(pitching) axis and set this up via UDF and even my profile coordinates and there is motion about the y axes all the time.

Then to make matters worse, if I rotate about the x(flapping), y(deviation), and z(pitching) axes at the same time the x axes rotation is fine, but the wing seems to rotate about the y axis in a way that it wants to and rotates about the z axis with some form of accuracy, basically I think the rotation axis in fluent maybe set in a certain way, but I dont understand what it is and how I can solve my problem(s).

Could someone please help with this, I have tried so many times to solve this but cannot do it.

Please help

Dave
davesmith_01 is offline   Reply With Quote

Old   February 1, 2011, 13:24
Default
  #7
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
Dave,

In the end I was able to get rotations in two axes to work as follows.

Nomenclature:
Phi: flapping angle (about global Z-axis)
theta: pitching angle (about global X-axis)

Definitions:
flapping velocity: dPhi = d(Phi)/dt (user selected, I use a sinusoid)
pitching velocity: dtheta = d(theta)/dt

Transformation to body coordinates:

body x-rotational velocity
omega[0] = dTheta*cos(Phi)

body y-rotational velocity
omega[1] = dTheta*sin(Phi)

body z-rotational velocity
omega[2] = dPhi

You should be able to use a similar approach if your axes are set up differently. Also, these are a simplified version assuming the stroke plane deviation is zero. If you include that you'll have a third velocity and the transformation will be more complicated, but I haven't worked that out. Actually, if you do work out the the three-rotation transformation, would you be so kind as to post it here? Thanks.

Dan
Danil Yusupov likes this.
montag dp is offline   Reply With Quote

Old   February 1, 2011, 13:37
Default
  #8
New Member
 
Dave Smith
Join Date: Jul 2010
Posts: 27
Rep Power: 15
davesmith_01 is on a distinguished road
Hi Dan

I can get the motion around two axes, thats ok, its adding a third axis which fluent has a problem with. I have thought about this many times and its really just geometry, but I think that fluent has not set up the rotations around an axis properly.

If the user sets a rotation about each axis this is what should occur, if a body is flat along the xz plane through the z axis and a rotation occurs about the x, y and z axis this should be simply possible as the rotations are around a fixed global axis, but this was not the case as fluent is coupling the motions about z and y axis always. I dont understand how it does that, because that seems to be more complex than the motion I am asking fluent to do.

I will let you know if I find a solution, please let me know if you find a solution friend.

Dave
davesmith_01 is offline   Reply With Quote

Old   February 1, 2011, 13:41
Default
  #9
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
Quote:
Originally Posted by davesmith_01 View Post
Hi Dan

I can get the motion around two axes, thats ok, its adding a third axis which fluent has a problem with. I have thought about this many times and its really just geometry, but I think that fluent has not set up the rotations around an axis properly.

If the user sets a rotation about each axis this is what should occur, if a body is flat along the xz plane through the z axis and a rotation occurs about the x, y and z axis this should be simply possible as the rotations are around a fixed global axis, but this was not the case as fluent is coupling the motions about z and y axis always. I dont understand how it does that, because that seems to be more complex than the motion I am asking fluent to do.

I will let you know if I find a solution, please let me know if you find a solution friend.

Dave
It certainly seems like it would be simplest if they just used a global coordinate system for the rotation, but it seems they have it defined based on the local body axes, which change orientation with time. That's why you need a transformation.

I was puzzled over this for a long time, and still am to some extent, because it seems like the required transformation is not the standard type that uses Euler angles. And oddly enough, there is no information anywhere in Fluent's documentation that I've been able to find about the correct transformation. Even talking with someone from a CFD consulting firm didn't help.
montag dp is offline   Reply With Quote

Old   February 1, 2011, 14:15
Default
  #10
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
Actually, here's something that someone sent me. This guy did a flapping simulation of a dragonfly in fluent, which you should be able to find easily on youtube. I asked him how he did his coordinate transformations and he responded with the attached pdf. It is quite detailed and allows for three-axis rotation.

Thanks to Jakub K. for this.
Attached Files
File Type: pdf dh_algo.pdf (91.4 KB, 858 views)
Danil Yusupov likes this.
montag dp is offline   Reply With Quote

Old   February 2, 2011, 08:04
Default
  #11
New Member
 
Dave Smith
Join Date: Jul 2010
Posts: 27
Rep Power: 15
davesmith_01 is on a distinguished road
Thanks for the attachment, will have a look through.

It is very odd if they have chosen a time dependent axis system, I dont think they have configured the dynamics correctly. A global coordinate system would be the best possible one to use.

Anyway, I will let you know if I progress in this rather weird problem, please let me know if you find any more information.
davesmith_01 is offline   Reply With Quote

Old   June 2, 2012, 06:30
Default
  #12
Member
 
Satish Gupta
Join Date: Jun 2012
Posts: 30
Rep Power: 13
Rahul123 is on a distinguished road
I am new at using fluent.I want rotational motion in a rectangular cylinder(2-D).Can anyone help me with the UDF.thanks in advance
Rahul123 is offline   Reply With Quote

Old   February 6, 2011, 10:53
Default
  #13
Member
 
Aamer Shahzad
Join Date: Mar 2010
Posts: 58
Rep Power: 16
aamer is on a distinguished road
Dear Montag Dp...

in the pdf that you have given in your comments. it mentions an ebook in tht.... will u be kind enough, to send me that ebook.... i want to understand the tranformations in more detail..... my email is aamer58@gmail.com. looking forward to your help.
aamer is offline   Reply With Quote

Old   February 6, 2011, 11:57
Question how to do coordinate transformation in udf
  #14
Member
 
Aamer Shahzad
Join Date: Mar 2010
Posts: 58
Rep Power: 16
aamer is on a distinguished road
Hello all.....

i am a student of cfd and trying to sweep a simple wing from 0 to pi radians (azimuth angle) and assuming a constant angle of attack. When i make a 2D airfoil in gambit, it is in x-y plane. now if i want to make a wing out of it, i have to extend it in z direction. so the wing is formed in such away that its span is in z direction and airfoil in x-y plane. but in fluent, in order to mimic insect sweeping, i want the same wing to transform its axes in such away that its span is in x direction and airfoil is in y-z plane....... How can this coordinate transformation be achieved in UDF ????

@dear montag Dp...... looking at your previous threads, i think your guidance can serve the purpose. .....

thanks
aamer is offline   Reply With Quote

Old   February 8, 2011, 02:04
Question Problem continues
  #15
Member
 
Aamer Shahzad
Join Date: Mar 2010
Posts: 58
Rep Power: 16
aamer is on a distinguished road
dear montag dp....

can you please comment on the problem that i highlighted in previous thread i.e the problem that i am facing in sweeping a wing?????

also , can you tell me any email or other contact of MR. jakub, so that i can request him for the ebook..... or if i can get the title and author of that ebook ?????
aamer is offline   Reply With Quote

Old   February 8, 2011, 12:45
Default
  #16
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
Aamer,

To do a simple wing sweep depends on how exactly you want to do the sweep. If it will be a constant speed, I believe you can use a moving mesh or rotating reference frame approach, but I don't know much about that. If you want the speed to vary, you will have to use dynamic meshing and the define_cg_motion macro.

To do this, you create C code like the ones I have posted in this thread where you write your rotational velocity functions. In Fluent, you go to Define>User-defined>Functions>compiled and select your C code. You must have a C compiler to do this. Then, you enable Dynamic meshing and select whichever zones you want to move and apply your macro to those zones.

I will let Jakub know about this thread and hopefully he will be able to share the e-book with you. For a simple sweep in one dimension, you wouldn't need the coordinate transformation, though.
montag dp is offline   Reply With Quote

Old   February 9, 2011, 03:01
Default
  #17
Member
 
Aamer Shahzad
Join Date: Mar 2010
Posts: 58
Rep Power: 16
aamer is on a distinguished road
Dear montag dp...

thanks for the reply.....
let me be elaborative, why i beleive that i need transformation.
i am assuming coordinates of fluent (i.e. x axis in horizontal, y axis in vertical, and z axis in azimuth direction). my wing has to sweep in z direction (i.e about y axis). it has to start from rest and acheive a constant rotational velocity when it reaches pi/9 radians, after that if has to move with constant rotational velocity till it covers pi radians. so the motion is purely semi circle in azimuth. i have used define CG motion and dynamic mesh, and ihave written the udf for sweep.

The required initial position of wing is such that its chord is in y-z plane and its span is on x axis....(this is how insect starts sweeping)
i made a 2D chord in gambit, for validation purpose. so the chord was in x-y plane. now as my ultimate aim was to make a wing, so i swept it in Z direction. hence i got a wing which has chord in X-Y plane and span is on Z axis.....So this is my wing initial position which is picked by udf for sweep. but as i already said that the initial position of the wing that i want should have chord in Y-Z plane and span on X axis. Inorder to get correct sweep, i have to some how rotate my wing by 90 degree. i believe that this can be acheived, if i do coordiante transformation in udf.......

what is your opinion on this issue..... do you have any other idea , how to handle this problem...

my second question is that in your udf you have mentioned that you used a sinosoid for defining phi..... what function did you use for defining theta.... can you give more details of your final explanation related to flapping udf.... may be, it helps me in using the same concept for sweeping...

looking forward to your expert opinion....

Last edited by aamer; February 9, 2011 at 05:45.
aamer is offline   Reply With Quote

Old   February 9, 2011, 12:11
Default
  #18
Member
 
Join Date: Jul 2010
Posts: 38
Rep Power: 15
montag dp is on a distinguished road
Aamer, if I'm understanding you right, your problem actually has a very simple solution. Since your wing is starting in the wrong orientation, you can just go to Mesh>Rotate and rotate your entire mesh as desired before starting the simulation so that the initial orientation will be correct. Doesn't seem like a big problem to me, though. Couldn't you just rotate it about the z-axis instead of the y-axis if the orientation is different?

As for your second question, I've been using a few different functions for the feathering rotation. The basic function is just a sinusoid:

thdot = Afeath*w*sin(w*t)

I'm also experimenting with another function to relegate the feathering rotation more to the ends of the flapping strokes.
montag dp is offline   Reply With Quote

Old   March 16, 2012, 05:56
Default
  #19
Member
 
sheth roh
Join Date: Jul 2011
Posts: 56
Rep Power: 14
sheth is on a distinguished road
Hey JG, I finally got it working. Thanks for all your help. The constants in equation were not the issue, even with the constants it went well. The wing just bends slightly so I think I need to set dynamic parameters so it doesn't happen.

For those who are trying here is what to follow:
1. Use Euler angles to define angles (Theta, Phi... etc in Euler Angles)
2. Orient Geometry As it shall be at time t=0.
3. In dynamic mesh, when you define dynamic zone, mention CG properly (Very IMP), In my case I wrote the Cg position x,y,z and I didn't mention the cg orientation when defining dynamic mesh zones.
4. Follow the order X, Y, and then Z, i.e. The first rotation will be about X axis, second will be about Y axis, and third will be about Z axis.
5. The UDF that JR has provided works perfectly, its in this thread itself, so many thanks to JG for that.
6. If your motion is not proper, then play with positive negative sign, I had to do this in my case also. Try changing signs of equations, and you may get proper motion.
lev likes this.
sheth is offline   Reply With Quote

Old   September 22, 2012, 09:15
Exclamation importance of CG motion
  #20
Member
 
Aamer Shahzad
Join Date: Mar 2010
Posts: 58
Rep Power: 16
aamer is on a distinguished road
Quote:
Originally Posted by sheth View Post
Hey JG, I finally got it working. Thanks for all your help. The constants in equation were not the issue, even with the constants it went well. The wing just bends slightly so I think I need to set dynamic parameters so it doesn't happen.

For those who are trying here is what to follow:
1. Use Euler angles to define angles (Theta, Phi... etc in Euler Angles)
2. Orient Geometry As it shall be at time t=0.
3. In dynamic mesh, when you define dynamic zone, mention CG properly (Very IMP), In my case I wrote the Cg position x,y,z and I didn't mention the cg orientation when defining dynamic mesh zones.
4. Follow the order X, Y, and then Z, i.e. The first rotation will be about X axis, second will be about Y axis, and third will be about Z axis.
5. The UDF that JR has provided works perfectly, its in this thread itself, so many thanks to JG for that.
6. If your motion is not proper, then play with positive negative sign, I had to do this in my case also. Try changing signs of equations, and you may get proper motion.
Hello.....

hope you are doing fine. you wrote that mentioning CG position and orientation is important. Will you please tell how to give CG position and orientation correctly.
aamer is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Specify radial mesh motion in CFX Jonas CFX 2 April 23, 2008 02:54
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 14:09
tank motion on boat Tim FLUENT 0 May 23, 2007 11:50
large scale mesh motion sb FLUENT 1 April 27, 2007 22:23


All times are GMT -4. The time now is 11:17.