CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   CG Motion Absolute coordinates (https://www.cfd-online.com/Forums/fluent-udf/78578-cg-motion-absolute-coordinates.html)

montag dp July 26, 2010 16:43

CG Motion Absolute coordinates
 
I'm having a little trouble with the Define_CG_Motion macro. I'm trying to do a simulation of a wing that is both flapping and pitching. The flapping is a rotation about the x-axis and the pitching is a rotation about the z-axis.

The problem is, it seems that the coordinate system for the CG remains relative to the hooked zone at all times. This makes the wing rotate about the (absolute) y-axis as well if I just define an omega_x and omega_z, because as time advances the flapping motion rotates the wing's relative coordinate system.

Is there any way to define the CG location in absolute coordinates, or do I just have to re-work my functions to account for the rotation?

almostafa67 July 30, 2010 10:34

flapping and pitching
 
Hi, everybody...
I am having this same problem.but in my udf i want to rotate one of edges only about on coordinate,I've been working on it for two weeks but i didnt find any similar problem,if u found any solution for this kind of problems let me know please:)
thank you in advance
my email: almostafa67@gmail.com

montag dp July 30, 2010 10:45

I haven't had any luck either. I tried doing a coordinate transformation to transform rotations about the reference x, y, and z axes to rotations about the moving body x, y, and z axes. It gets the motion closer to what I want but still not right. Adding to the frustration is the fact that Fluent's "Display Zone Motion" doesn't work right, so I have to do "Preview Mesh Motion" every time just to check.

almostafa67 July 30, 2010 11:27

1 Attachment(s)
hi dear montag...
this the case that i want to simulate it, i hope that u could help me with this.

montag dp July 30, 2010 12:27

Another question. In the Fluent User's manual it says you can check a moving body's center of gravity position and orientation in the dynamic mesh box by pressing 'Update.' See here:

http://my.fit.edu/itresources/manual...ug/node455.htm

It would be useful if I could my motion UDF could check the orientation at each time step. Does anyone know how to do that within the UDF?

montag dp August 2, 2010 16:14

For posterity, I figured out how to solve my problem. Use the Euler rate transformations in the UDF in order to convert between body and stationary velocities. You'll also need to use the current zone orientation at each time step using the DT_THETA(dt) macro. Just be careful because it seems to return the orientation in degrees, not radians, so you must convert it to use in trig expressions.

almostafa67 August 3, 2010 02:03

rotation about z axis
 
2 Attachment(s)
hi dear montag dp...
i worked a lot on my case,but unfortunately see no progress,i sent you the image of the case that i simulated it in gambit and the udf file that i use to rotate small circle about center of bigger circle,(kind of peristaltic pump),would you be so kind as to think about it and explain your udf and if you have any have any advice for me to write my udf file...
the udf file that i use:
# include "udf.h"
# include "dynamesh_tools.h"
DEFINE_CG_MOTION(pump,dt,vel,omega,time,dtime)
{
Thread *t;

real freq_t;
NV_S(vel,=,0.0);
NV_S(omega,=,0.0);
if(!Data_Valid_P())
return;
freq_t = 4.0;
t= DT_THREAD((Dynamic_Thread*)dt);
vel[0] = 0.0;
vel[1] = 0.0;
vel [2] = 0.0;
omega [0] = 0.0;
omega [1] = 0.0;
omega [2] = freq_t;
}

Thank you in advance for any help you can provide.:)
looking forward to ur help...

montag dp August 3, 2010 09:36

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.

almostafa67 August 3, 2010 09:51

rotation about z axis
 
dear montag dp...
my udf really worked:D
but i faced new problem:o
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 August 3, 2010 09:52

2 Attachment(s)
sorry forgot attach images

montag dp August 3, 2010 12:05

Ok, now really confused
 
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.

montag dp August 3, 2010 16:24

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

davesmith_01 February 1, 2011 11:11

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

montag dp February 1, 2011 13:24

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

davesmith_01 February 1, 2011 13:37

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

montag dp February 1, 2011 13:41

Quote:

Originally Posted by davesmith_01 (Post 293141)
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 February 1, 2011 14:15

1 Attachment(s)
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.

davesmith_01 February 2, 2011 08:04

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.

aamer February 6, 2011 10:53

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 February 6, 2011 11:57

how to do coordinate transformation in udf
 
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

montag dp February 6, 2011 13:03

Quote:

Originally Posted by aamer (Post 293857)
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.

Sorry aamer, that pdf was given to me by Jakub K, as I said in the post. I don't have the book.

aamer February 8, 2011 02:04

Problem continues
 
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 ?????

montag dp February 8, 2011 12:45

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.

aamer February 9, 2011 03:01

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....

montag dp February 9, 2011 12:11

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.

quantum.tejas February 13, 2011 21:58

Hi Dan

I am having the same problem. So do you say the Eulerian angle transformations do not work in FLUENT?The 3rd angle is causing problems for me.Phi(sweep) and alpha (AoA) do not have any problems. When I add theta (elevation) to the equations, FLUENT is doing random motions of the wing.Do you have any suggestions?

montag dp February 13, 2011 22:23

I've been able to do two rotations as well. All I know about the problem is in my last few posts. The Euler rate transformations seem to work in 2 axes but I haven't tried them in 3.

quantum.tejas February 13, 2011 22:49

If it is not too much trouble, could you try 3 angles and let me know?Because I know my Eulerian transformations are correct. But I have no idea as to how FLUENT is reading my omega components. It is terribly confusing.

montag dp February 13, 2011 22:51

Sorry, I'm afraid I don't have more time to troubleshoot this problem in Fluent. I only have the transformation in a simplified version for 2 rotations (assuming the third is 0). Did you say you can get two rotations working at the same time, or independently?

quantum.tejas February 13, 2011 22:56

Thats alright. I have been able to run 2 angles at the same time. The motion, therefore will be in the stroke plane. ( 0 deg in my case). The wing sweeps through the plane (phi) and rotates as well (alpha). The problem comes when there is a 3rd angle and its components. (theta: elevation angle)

montag dp February 13, 2011 22:59

Sounds like the same thing I'm doing then, except I'm just keeping it to two rotations. I wish you luck. Maybe try going through that pdf I posted on the previous page that someone sent me? I haven't looked through it in detail but apparently he was able to do 3 rotations.

quantum.tejas February 13, 2011 23:06

yeah.But that pdf seems a tad unclear with the notations and all that. I was wondering if there is a local global angle( transformation) to the solution of this problem.

davesmith_01 February 14, 2011 05:43

the motion does not work in three axes, you can only rotate about two axes in fluent, hence the reason why many people have used their own codes (written in fortran mainly) to do this as fluent has limited capabilities. Many papers say that personal codes are alot better as fluent is limited.

quantum.tejas February 14, 2011 05:47

Hi Dave

Thanks for the reply. I have been fighting with this problem for so long. I needed that answer.Is there any particular reason FLUENT cannot do it? If it is not too much trouble, could you direct me to the papers where they have said FLUENT is not suitable for 3 angles. I need to prove it to my advisor. :)

davesmith_01 February 14, 2011 12:34

I cannot remember the names of the journals exactly. They said something like commercial software cannot do this. All of the CFD work for this has been done by codes written in fortran etc which can also do many other things, but they have more capabilites and the users have written the codes hence know everything that it can do.

quantum.tejas February 16, 2011 04:33

Hi Dave

Thanks for that. I wanted to confirm something. When i use alpha and phi, it works fine. when i add theta to this or use combinations of theta and phi and theta and alpha it behaves oddly. Is this normal? phi being sweep, alpha is pitch around wing axis and theta elevation above sweep plane.

Thanks

aamer February 17, 2011 03:39

Hi Quantum tejas.....

can you please paste the transformations here ( that you have written for the three motions in fluent). i am working on a similar issue, though my problem is slightly different as it is just restriced to sweep at constant angle of attack (with no rolling).

secondly you have mentioned third motion as elevation. but i think elevation and pitching is same thing. did you mean rolling as the third motion ?

aamer February 17, 2011 04:44

boundary condition for solid body motion
 
Dear Montaq Dp...

Thanks for the thorough discussion on the subject.

for a case of "static" wing in a "moving air", the boundary condition like velocity inlet, outflow and symmetry in 3 D wing are ok. But if the wing is itself doing motion like flapping or sweeping in a "still" air then how the boundary conditions are given. (considering that the wing is moving with a velocity that corresponds to incompressable flow).

i understand that symmetry condition will still hold for the wing but what boundary conditions can be given in the front, in the rear, top and bottom.

aamer March 5, 2011 05:17

Issue of boundary condition
 
Dear Montaq Dp.....

i saw your flapping motion on you tube..... it looks like you moved the wing in still air, so that means that no velocity was given at the inlet.... will you be kind enough to tell me what boundary condition did you use at front, rear, and on the sides......

i couldnt find much detail regarding how to give boundary condition for the case where you are moving a rigid body in still air.... my case is incompressible. and i am using an O type mesh.

montag dp March 8, 2011 18:35

I just use those same boundary conditions. It seems to work okay. I don't think it's extremely important what you use for the boundaries if there is no inlet velocity.


All times are GMT -4. The time now is 23:00.