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/)
-   -   Airfoil AoA steped increment (https://www.cfd-online.com/Forums/fluent-udf/198084-airfoil-aoa-steped-increment.html)

van_Attre January 26, 2018 03:46

Airfoil AoA steped increment
 
Dear All,

I am fairly new to Fluent and UDF, therefore i would like to request some help on the following matter.

I intend to perform a simulation on a 2D airfoil. The airfoil will remain stationary until the solution approaches convergence. After that it should update the angle of attack by 1 degree every, let's say t = c/U, where c is the chord length and U the freestream velocity. The range of angles of attack would be from -180 to 180 degrees. However it is ok for each simulation to go from 0 until the extreme angle.

I have tried to create a '' for loop'' however it seems that something like that doesn't work.
Also regarding the rotation function: can i simply use axis rotation equations?
x'=x\cos \theta +y\sin \theta
y'=-x\sin \theta +y\cos \theta .}

These also didn't seem to work, but i'm guessing it's more of a coding issue.

Thank you in advance for all the help on the matter.

Best regards

pakk January 26, 2018 04:39

If you use these equations, you will rotate around the origin x=y=0, which may or may not be what you want.

Furthermore: be aware that in the code, the angle should not be in degrees but in in radians.

Having said that: your problems are most likely a coding problem, and it is nearly impossible to give further advise without seeing your code.

van_Attre January 26, 2018 04:45

I've tried two options. The first was just to try if i could make the axis move:


#include "udf.h"
DEFINE_ZONE_MOTION(fmotion,omega,axis,origin,veloc ity,time,dtime)
{

if (flow_time >= 0.10)
{

origin[0] = 0.5;
origin[1] = 0.0;
origin[2] = 0.0;
axis[0] = axis[0] + (axis[0]*cos(0.0175)-axis[1]*sin(0.0175));
axis[1] = axis[1] + (axis[1]*sin(0.0175)+axis[1]*cos(0.0175));
axis[2] = 1.0;

}
else
{
*omega = 0.0;
}

return;
}


The second try regards the loop it:

#include "udf.h"
DEFINE_ZONE_MOTION(fmotion,omega,axis,origin,veloc ity,time,dtime)
{
for( dtime = 10; dtime = 1000; dtime = 10 )
{

origin[0] = 0.5;
origin[1] = 0.0;
origin[2] = 0.0;
axis[0] = axis[0] + (axis[0]*cos(0.0175)-axis[1]*sin(0.0175));
axis[1] = axis[1] + (axis[1]*sin(0.0175)+axis[1]*cos(0.0175));
axis[2] = 1.0;
}


return;
}

Without further due, thank you very much.

pakk January 26, 2018 06:35

I think you were successfully rotating the axis. (With a minor detail: you take the wrong components of the axis in updating the y-component.)

But this does not have the effect that you want. "Axis" does not mean the axis of your coordinate system, but the axis around which you want to rotate. You never asked Fluent to rotate anything, so it keeps the default rotation of 0 degree. If you rotate 0 degree, it does not matter in which direction the rotation axis points.

It looks like you want to rotate around the z-axis, so:
Code:

axis[0] = 0.0;   
    axis[1] = 0.0;   
    axis[2] = 1.0;

And you want a rotational speed of 0.0175:
Code:

*omega = 0.0175;
All I did to learn this was look at the Fluent manual. It even looks like the default example for DEFINE_ZONE_MOTION does (up to some different constants) exactly what you need!

van_Attre January 26, 2018 07:49

Yes, that seems like aplausible solution. However by setting omega it will generate a constant rotational speed and increment of the angle of attack. As i explained in my first post i intend to have a sequenced update of the angle. Below i've posted a picture to ilustrate more cleared what i mean.

https://imgur.com/hfGRG6O

https://imgur.com/hfGRG6O

pakk January 26, 2018 08:30

Then set omega to zero for 0.099 seconds, and to (0.0175/0.001) for 0.001 seconds.

van_Attre January 26, 2018 08:47

What about the code crtucture? Is it a loop? And what macro would be the best to consider the steps?

pakk January 26, 2018 09:30

No loops are required, I don't even see what you want to loop over...

You want something like this:

Code:

if (time<0.099) {
 *omega = 0.0;
} else if (time<0.1) {
 *omega = (0.0175/0.001);
} else if (time<0.199) {
 *omega = 0.0;
} else if (time<0.2) {
 *omega = (0.0175/0.001);
} else ... /*and go on as many times as you need */

The following is shorter but might be more complex to understand:

Code:

if ((1000*time)%100<99) {
 *omega = 0.0;
 } else {
 *omega = (0.0175/0.001);
 }

Use this only if you understand it, because you can not fix code that you don't understand.


All times are GMT -4. The time now is 18:50.