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

UDF for 2d translational motion

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 2 Post By Marion
  • 1 Post By Hkn
  • 1 Post By Papes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 24, 2012, 02:26
Default UDF for 2d translational motion
  #1
New Member
 
Join Date: Jun 2012
Posts: 11
Rep Power: 14
ThinkQuick is on a distinguished road
Hi all,

I am relatively new to ANSYS Fluent and am trying to impose a simple UDF to move a disturbance through a fluid. I only require the disturbance to move in the x direction with a constant velocity.

Could anyone please point me in the right direction about how to write this UDF?

Thanks
ThinkQuick is offline   Reply With Quote

Old   July 25, 2012, 05:26
Default Profiles instead
  #2
Senior Member
 
Marion
Join Date: Jul 2012
Location: France
Posts: 122
Rep Power: 15
Marion is on a distinguished road
This is a udf for X-velocity (3D)

#include<udf.h>
DEFINE_CG_MOTION(velo_needle, dt, cg_vel, cg_omega, time, dtime)
{

cg_vel[0] = -0.6;
/* x-velocity*/
cg_vel[1] = 0.0;
cg_vel[2] = 0.0;
NV_S (cg_omega, =, 0.0);
/* no angular motion */
/* Messages in Fluent TUI */

Message(
" \n");
Message(
"velocity \n");
Message(
"%5.6f\t\n",cg_vel[0]);
Message(
" \n");
}

However, Fluent support advised me to use profiles files for this kind of motion (i.e. non force driven motions)... It's easier since you do not have to compile your udf or have to keep the files together, etc.

Since I discovered the use of profiles for transient motions my life has changed

Marion.
Marion is offline   Reply With Quote

Old   July 25, 2012, 21:49
Default
  #3
New Member
 
Join Date: Jun 2012
Posts: 11
Rep Power: 14
ThinkQuick is on a distinguished road
Quote:
Originally Posted by eng_s_sadeghi View Post
Hello,
May you please send me a sample paper to know what exactly you want to model? Please take a look at my website and feel free to email me for any questions.
Hi Saeed, I have emailed you.
Thanks.

Marion:
'Fluent support advised me to use profiles files for this kind of motion'

Thanks for the reply. Do you have any resources on using profiles to specify translation?

Its pretty frustrating it seems like a relatively simply problem to move an object at a constant velocity in one dimension however the simulation is becoming difficult and cumbersome.
ThinkQuick is offline   Reply With Quote

Old   July 26, 2012, 07:43
Default
  #4
Senior Member
 
Marion
Join Date: Jul 2012
Location: France
Posts: 122
Rep Power: 15
Marion is on a distinguished road
Have you tried the udf I gave you yesterday and it is not working? Maybe you have an issue with compiling udfs?
For the profile files, there is a section about this in the user guide, but here is a copy of a recent reply I posted on this forum:

For the profile:
you have to write it like this and save it as filename.prof:
disp_needle 2 10 0
time x
0.00000E+00 0.00000E+00
1.00000E-06 -1.20000E-07
2.00000E-06 -2.40000E-07
3.00000E-06 -3.60000E-07
4.00000E-06 -4.80000E-07
5.00000E-06 -6.00000E-07
6.00000E-06 -7.20000E-07
7.00000E-06 -8.40000E-07
8.00000E-06 -9.60000E-07
9.00000E-06 -1.08000E-06

where
*disp_needle--> name of the profile
*2 --> number of columns
*10 --> number of points
*0 --> for periodicity - 0=not periodic and 1=periodic

once you've created this file, within Fluent TUI you type
file
rtt
filename.prof
(make sure everything is in your working directory)

and then in the fluent dynamic mesh panel, choose disp_needle in the drop down list under "profile/udf".

As it is displacement vs. time the 1st column has to be time. the 2nd column can be displacement (x,y,z) velocity (v_x, v_y, v_z) , etc...

I hope this helps,

Marion.
nhanhothithanh and Papes like this.
Marion is offline   Reply With Quote

Old   May 9, 2013, 21:27
Default Simple UDF motion
  #5
New Member
 
cguerrero
Join Date: May 2013
Location: Perú
Posts: 1
Rep Power: 0
XthianGA is on a distinguished road
Like Carlos, I'm trying to impose a simple UDF for moving a body through a fluid. I require only your body moving in the X direction with a constant speed, this movement is caused by fluid entering the duct. Carlos, you could help in achieving this UDF, or guide in performing the same.

I leave a picture

Like you I would like to learn the use of profiles for transient motions .
Thanks !!
Attached Images
File Type: jpg Sin título.jpg (82.5 KB, 341 views)
XthianGA is offline   Reply With Quote

Old   April 9, 2015, 18:46
Default
  #6
Member
 
sanjeet Limbu
Join Date: Mar 2015
Posts: 91
Rep Power: 11
sanjeetlimbu is on a distinguished road
I am trying to use profile by entering the velocity_y and time data points from matlab using step time as 0.000041667s. To get the rigid body motion as needed.
I use the layering - dynamic mesh type

When I see the zone motion - preview it work 254mm distance in 60millisec(30 millisec it move remaining 30 ms it zero velocity.)

But when i try mesh motion - preview - it moves little bit only.. not 254mmm for same time steps.

can you tell what may be issue with mesh notion


. I tried the UDF but it shows error: warning unable to read the udf file

#include "udf.h"
DEFINE_CG_MOTION(oscillate, dt, vel, omega, time, dtime)
{
Thread *t;
face_t f; /* define the variables */

t = DT_THREAD(dt); /* get the thread pointer for which the motion is defined */

/* if (!Data_Valid_P())
/* return; /* check if the values of the variables are accessible before you compute the function */

begin_f_loop(f, t) /* loop over each face in the zone to create an array of data */
{
if (time <= 0.02)
vel[0] = (673* time); /* define the velocity of the moving zone---*/
else if (0.02 < time < 0.027)
vel[0] = 14;
else if (0.027 < time < 0.03)
vel[0] = 3 - 2800*(time-0.03);
else if (0.03 < time)
vel[0] = 0;
}
end_f_loop(f, t)
}
Attached Images
File Type: jpg velocity and distance vs time(milisec).jpg (19.6 KB, 145 views)
File Type: jpg Referance mesh needed.jpg (35.9 KB, 216 views)
sanjeetlimbu is offline   Reply With Quote

Old   December 24, 2016, 01:55
Default
  #7
New Member
 
Prasad Mahajan
Join Date: Dec 2016
Posts: 1
Rep Power: 0
prasadmahajan21 is on a distinguished road
Quote:
Originally Posted by Marion View Post
Have you tried the udf I gave you yesterday and it is not working? Maybe you have an issue with compiling udfs?
For the profile files, there is a section about this in the user guide, but here is a copy of a recent reply I posted on this forum:

For the profile:
you have to write it like this and save it as filename.prof:
disp_needle 2 10 0
time x
0.00000E+00 0.00000E+00
1.00000E-06 -1.20000E-07
2.00000E-06 -2.40000E-07
3.00000E-06 -3.60000E-07
4.00000E-06 -4.80000E-07
5.00000E-06 -6.00000E-07
6.00000E-06 -7.20000E-07
7.00000E-06 -8.40000E-07
8.00000E-06 -9.60000E-07
9.00000E-06 -1.08000E-06

where
*disp_needle--> name of the profile
*2 --> number of columns
*10 --> number of points
*0 --> for periodicity - 0=not periodic and 1=periodic

once you've created this file, within Fluent TUI you type
file
rtt
filename.prof
(make sure everything is in your working directory)

and then in the fluent dynamic mesh panel, choose disp_needle in the drop down list under "profile/udf".

As it is displacement vs. time the 1st column has to be time. the 2nd column can be displacement (x,y,z) velocity (v_x, v_y, v_z) , etc...

I hope this helps,

Marion.
If we have to give displacement, velocity, and time then do we have to make three columns?
prasadmahajan21 is offline   Reply With Quote

Old   March 5, 2018, 14:18
Default
  #8
New Member
 
SunP
Join Date: Feb 2018
Posts: 7
Rep Power: 8
Papes is on a distinguished road
velocity is implied by displacement.
or what direction of the velocity.
Papes is offline   Reply With Quote

Old   March 5, 2018, 16:10
Default profile cannot be read
  #9
New Member
 
SunP
Join Date: Feb 2018
Posts: 7
Rep Power: 8
Papes is on a distinguished road
Quote:
Originally Posted by Marion View Post
Have you tried the udf I gave you yesterday and it is not working? Maybe you have an issue with compiling udfs?
For the profile files, there is a section about this in the user guide, but here is a copy of a recent reply I posted on this forum:

For the profile:
you have to write it like this and save it as filename.prof:
disp_needle 2 10 0
time x
0.00000E+00 0.00000E+00
1.00000E-06 -1.20000E-07
2.00000E-06 -2.40000E-07
3.00000E-06 -3.60000E-07
4.00000E-06 -4.80000E-07
5.00000E-06 -6.00000E-07
6.00000E-06 -7.20000E-07
7.00000E-06 -8.40000E-07
8.00000E-06 -9.60000E-07
9.00000E-06 -1.08000E-06

where
*disp_needle--> name of the profile
*2 --> number of columns
*10 --> number of points
*0 --> for periodicity - 0=not periodic and 1=periodic

once you've created this file, within Fluent TUI you type
file
rtt
filename.prof
(make sure everything is in your working directory)

and then in the fluent dynamic mesh panel, choose disp_needle in the drop down list under "profile/udf".

As it is displacement vs. time the 1st column has to be time. the 2nd column can be displacement (x,y,z) velocity (v_x, v_y, v_z) , etc...

I hope this helps,

Marion.

I write a profile, but it doesn't work, motion profile not recognizeit can you help? thank you.
what I wrote as below:

disp_piston 2 20 1
time x
0 0
1 0.1
2 0.2
3 0.3
4 0.4
5 0.5
6 0.6
7 0.7
8 0.8
9 0.9
10 1
11 0.9
12 0.8
13 0.7
14 0.6
15 0.5
16 0.4
17 0.3
18 0.2
19 0.1
Attached Images
File Type: png profile cannot be read.PNG (41.6 KB, 51 views)
Papes is offline   Reply With Quote

Old   March 6, 2018, 10:01
Default
  #10
New Member
 
SunP
Join Date: Feb 2018
Posts: 7
Rep Power: 8
Papes is on a distinguished road
Quote:
Originally Posted by Papes View Post
I write a profile, but it doesn't work, motion profile not recognizeit can you help? thank you.
what I wrote as below:

disp_piston 2 20 1
time x
0 0
1 0.1
2 0.2
3 0.3
4 0.4
5 0.5
6 0.6
7 0.7
8 0.8
9 0.9
10 1
11 0.9
12 0.8
13 0.7
14 0.6
15 0.5
16 0.4
17 0.3
18 0.2
19 0.1
It's format more like in Fluent 17.0:

((moveVel transient 3 0)

(time 0 1 2)

(v_x 0.05 0.05 0.05)

)
Papes is offline   Reply With Quote

Old   October 13, 2018, 11:41
Default
  #11
Hkn
New Member
 
Hakan COSANAY
Join Date: May 2016
Posts: 11
Rep Power: 10
Hkn is on a distinguished road
Quote:
Originally Posted by Papes View Post
It's format more like in Fluent 17.0:

((moveVel transient 3 0)

(time 0 1 2)

(v_x 0.05 0.05 0.05)

)

I am asking one point with profiles, I seen three point for continuation of profile. Does ansys make its own calculation for the continuation of the profile? For example my time step is 1e-7 and my velocity is fix for 0.05.(total time is 13 s) Should I use time when writing the profile or time step?
And is it necessary write in the three point for continuation time/velocity
golukumar40gaon likes this.
Hkn is offline   Reply With Quote

Old   October 17, 2018, 10:01
Default
  #12
New Member
 
SunP
Join Date: Feb 2018
Posts: 7
Rep Power: 8
Papes is on a distinguished road
Quote:
Originally Posted by Hkn View Post
I am asking one point with profiles, I seen three point for continuation of profile. Does ansys make its own calculation for the continuation of the profile? For example my time step is 1e-7 and my velocity is fix for 0.05.(total time is 13 s) Should I use time when writing the profile or time step?
And is it necessary write in the three point for continuation time/velocity

The profile you write should be smaller than your time step. so it gives enough velocity information. The data is much more than three.

((moveVel transient 5 0) %% red 5 is you give 5 data; Bule 0 means not periodic, if you make it 1, that will be periodic.

(time 0.00000005 0.00000001 0.00000015 0.00000002 0.00000025) %% smaller than your time step

(v_x 0.05 0.05 0.05 0.05 0.05) %% define your velocity

)

example of 5 time points, fix velocity 0.05, periodic by define 0.

But I don't understand, if your velocity is fixed, why you need a transient profile? I use it to define the changing velocity/pressure.

Another suggestion, you can define cycle/periodic if your total time is periodic.
maria94 likes this.
Papes is offline   Reply With Quote

Old   January 27, 2021, 13:24
Default
  #13
New Member
 
maria
Join Date: Nov 2019
Posts: 5
Rep Power: 7
maria94 is on a distinguished road
Quote:
Originally Posted by Papes View Post
The profile you write should be smaller than your time step. so it gives enough velocity information. The data is much more than three.

((moveVel transient 5 0) %% red 5 is you give 5 data; Bule 0 means not periodic, if you make it 1, that will be periodic.

(time 0.00000005 0.00000001 0.00000015 0.00000002 0.00000025) %% smaller than your time step

(v_x 0.05 0.05 0.05 0.05 0.05) %% define your velocity

)

example of 5 time points, fix velocity 0.05, periodic by define 0.

But I don't understand, if your velocity is fixed, why you need a transient profile? I use it to define the changing velocity/pressure.

Another suggestion, you can define cycle/periodic if your total time is periodic.
Hi, if I use "periodic", should I add some about my periodicity?

((movevel transient 5 1) of course ,

and then in addition to time and vel_x?

Thank you!
maria94 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
CG Motion UDF Problem leoarmas Fluent UDF and Scheme Programming 17 February 14, 2023 09:59
Grid motion with UDF fivos Fluent UDF and Scheme Programming 5 June 30, 2018 09:50
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Fluent UDF Discontinuous Motion lequi7 Fluent UDF and Scheme Programming 2 November 4, 2011 00:18
UDF error CG Motion Alex FLUENT 0 March 22, 2006 18:40


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