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

Force in UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 15, 2012, 03:56
Default Force in UDF
  #1
J14
New Member
 
Join Date: Nov 2012
Posts: 5
Rep Power: 4
J14 is on a distinguished road
Hey,

does anybody know who to include a force in an udf. I would like to write an iteration where the mass flow rate is raised if the force is to low and reduced if it is to high as a define force. By force i mean a force which takes place on a special part of my figure because of the fluid flow.

Another question is how can i write down an iteration in an udf.

I hope somebody can help me i tried to do this a long time and it does not work.

Thank you!
J14 is offline   Reply With Quote

Old   November 20, 2012, 02:43
Default
  #2
New Member
 
Join Date: Mar 2010
Posts: 25
Rep Power: 7
Dorit is on a distinguished road
Hi,

For monitoring the force over a given surface you could use the function Compute_Force_and_Moment inside your UDF. It gives you the forces in the x, y and z direction and moments around the x, y and z axis. The function should be applied to a surface that is already defined in the mesh that you import into Fluent, it shouldn't be a surface that you only create in Fluent.

Based on the resultant force/pressure/moment you could then calculate the new mass flow rate that you want. From there you can calculate the new inlet velocity that satisfies your updated mass flow rate. You can then change the inlet velocity using a DEFINE_PROFILE macro.

Not sure what you mean by writing down an iteration in a UDF.

Hope it helps,
Dorit
Dorit is offline   Reply With Quote

Old   November 20, 2012, 08:08
Default
  #3
J14
New Member
 
Join Date: Nov 2012
Posts: 5
Rep Power: 4
J14 is on a distinguished road
Alright thank you very much now i got an idea how i can solve my problem. Do you know exactly how to write/ inlcude a Compute_Force_And_Moment function into an udf, because i did not find any information about that. If you have an example which shows how to use the Compute_Force_And_Moment function that would be very helpful. Or do you know where i can find some information about using the Compute_Force_And_Moment function. As you see i am not very good in writing udfs.

Thank you very much for your help!

J14
J14 is offline   Reply With Quote

Old   November 20, 2012, 08:48
Default
  #4
New Member
 
Join Date: Mar 2010
Posts: 25
Rep Power: 7
Dorit is on a distinguished road
Yeah there's very little information on Compute_Force_And_Moment.

You could try something like this:
The UDF will need to be compiled & hooked to the velocity inlet (if that's what you're using).


#include "udf.h"

DEFINE_PROFILE(update_velocity,t_inlet,i)
{
/* get moment or force */
Domain *d = Get_Domain(1); /* for single phase flow*/
Thread *t_object = Lookup_Thread(d, Boundary_ID); /* you get Boundary_ID from the boundary condition panel in Fluent*/
real force[ND_ND], moment[ND_ND], cg[ND_ND]; /*initialise*/

Compute_Force_And_Moment (d,t_object,cg,force,moment,TRUE)

real force_x = force[0]; /* force components of surface "Boundary_ID" */
real force_y = force[1];
real force_z = force[2];
real moment_x = moment[0]; /* moment components */
real moment_y = moment[1];
real moment_z = moment[3];

/* use some equation to calculate new inlet velocity */
real v_new = ..........;

/* update inlet velocity */
face_t f;
begin_f_loop(f,t_inlet) /* loop over all faces at velocity inelt */
{
F_PROFILE(f,t_inlet,i) = v_new;
}
end_f_loop(f,t_inlet)

}
Dorit is offline   Reply With Quote

Old   November 20, 2012, 08:55
Default
  #5
New Member
 
Join Date: Mar 2010
Posts: 25
Rep Power: 7
Dorit is on a distinguished road
Actually you'll need to find a different macro I think, cause you're running an unsteady simulation right? If so, then you'll need something that's called at the start of every time step. Don't think DEFINE_PROFILE is continuously updated. But the moment stuff should still work.
Dorit is offline   Reply With Quote

Old   May 11, 2015, 07:17
Default Compute_Force_And_Moment problem
  #6
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
Hi,
I am using 'Compute_Force_And_Moment' to calculate lift and drag acting on cylinder. Here is my udf it shows parse error at line 13, but when I comment lines, containing function
"Compute_Force_And_Moment" and "v_new = 0.0*force[0];", it runs smoothly.
Please help me...


#include "udf.h"

DEFINE_PROFILE(update_velocity,t_inlet,i)
{
/* get moment or force */
Domain *d = Get_Domain(1); /* for single phase flow*/
face_t f;
Thread *t_object = Lookup_Thread(d,17); /* you get Boundary_ID from the boundary condition panel in Fluent*/
real force[3], moment[3], cg[ND_ND]; /*initialize*/
real force_y,v_new;
Compute_Force_And_Moment (d,t_object,cg,force,moment,TRUE)

v_new = 0.0*force[0]; // at this line parse error is coming!!

/* update inlet velocity */

begin_f_loop(f,t_inlet) /* loop over all faces at velocity inelt */
{
F_PROFILE(f,t_inlet,i) = v_new;
}
end_f_loop(f,t_inlet)

}

sarjerao is offline   Reply With Quote

Old   May 11, 2015, 07:25
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 670
Rep Power: 9
pakk is on a distinguished road
If you read Dorit's post above, it says:
"The UDF will need to be compiled"

Did you do that, or did you interpret?
pakk is offline   Reply With Quote

Old   May 11, 2015, 12:20
Default
  #8
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
Yes I tried both options "compiled and interpreted ". problem still exist.

In 'interpreted' it gives parse error at "v_new = 0.0*force[0];" .

whereas in 'compiled case' it shows "'nmake' is not recognized as an internal or external command,", when I build it and during loading it gives "The UDF library you are trying to load (libudf2) is not compiled for 2ddp on the curent platform (win64).The system cannot find the file specified. F:\Newfolder\libudf2\win64\2ddp\libudf.dll"
sarjerao is offline   Reply With Quote

Old   May 12, 2015, 02:54
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 670
Rep Power: 9
pakk is on a distinguished road
Quote:
Originally Posted by sarjerao View Post
in 'compiled case' it shows "'nmake' is not recognized as an internal or external command,"
This means that Fluent can not find your compiler. You will not be able to compile anything.

You need to have a compiler installed, Ansys suggests to use Microsoft SDK, which is available for free. There are other threads on this forum (you can probably find them by searching for "nmake not recognized"), which explain how to get a proper installation.

The problem might also be that you miss a semicolon, so try to change
Code:
Compute_Force_And_Moment (d,t_object,cg,force,moment,TRUE)
into
Code:
Compute_Force_And_Moment (d,t_object,cg,force,moment,TRUE);
But probably, you will not be able to use Compute_Force_And_Moment without compiling, so you should install and configure a compiler.
pakk is offline   Reply With Quote

Old   May 12, 2015, 04:35
Default
  #10
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
Now, I compiled my udf by accessing fluent from "Visual studio command promp(2010)". but it gives following error messenge:

Copied F:\Newfolder\velocityprofile1.c to libudf3\src
(system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf3\win64\2ddp\makefile" ")
1 file(s) copied.
(chdir "libudf3")()
(chdir "win64\2ddp")()
# Generating ud_io1.h
velocityprofile1.c
# Generating udf_names.c because of makefile velocityprofile1.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj velocityprofile1.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library libudf.lib and object libudf.exp
velocityprofile1.obj : error LNK2019: unresolved external symbol __imp__Compute_Force_And_Moment referenced in function _update_velocity
velocityprofile1.obj : error LNK2019: unresolved external symbol __imp__Lookup_Thread referenced in function _update_velocity
velocityprofile1.obj : error LNK2019: unresolved external symbol __imp__Get_Domain referenced in function _update_velocity
libudf.dll : fatal error LNK1120: 3 unresolved externals


Done.
sarjerao is offline   Reply With Quote

Old   May 12, 2015, 06:40
Default
  #11
Senior Member
 
Join Date: Nov 2013
Posts: 670
Rep Power: 9
pakk is on a distinguished road
For some reason, your compiler is not properly configured. It can not find the functions defined by Fluent.

Even the "Get_Domain" function can not be found. It probably has something to do with compiler settings/configuration of Fluent, but I can not tell what to change or even where to change something.
pakk is offline   Reply With Quote

Old   May 12, 2015, 06:54
Default
  #12
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
Is it due to function (Compute_Force_And_Moment) can only be used in dynamic meshing?
because....
Now, I tried it on another system with SDK installed. running fluent through sdk. It compiles as well load udf smoothly without any error. but when I initialize the case it gives "Access Violation error "
any help!
sarjerao is offline   Reply With Quote

Old   May 12, 2015, 06:57
Default
  #13
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
Actually I am simulating unsteady flow over cylinder, lift generated at previous time step is used to calculate inlet velocity at current time-step.
sarjerao is offline   Reply With Quote

Old   May 12, 2015, 07:12
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 670
Rep Power: 9
pakk is on a distinguished road
So there is your problem: when you initialize, there is no "previous time step".

You could change the UDF to detect that, or more pragmatic: first initialize, and then attach this profile boundary condition.
pakk is offline   Reply With Quote

Old   May 12, 2015, 08:08
Default
  #15
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
Hey.... Problem solved.
Thank you very much.
sarjerao is offline   Reply With Quote

Old   May 12, 2015, 08:20
Default
  #16
New Member
 
Shree
Join Date: May 2014
Posts: 10
Rep Power: 3
sarjerao is on a distinguished road
It works fine in fluent running on SDK.
For initialisation error : Initially I am running few time step without udf and then introduce my udf for velocity correction.
sarjerao is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActuatorDiskExplicitForce in OF2.1. Help be_inspired OpenFOAM Programming & Development 8 July 3, 2014 10:54
UDF in Fluent Andrew Fluent UDF and Scheme Programming 4 March 16, 2012 04:35
Force can not converge colopolo CFX 13 October 4, 2011 22:03
UDF for defining a body force in Singel ROtating Reference Frame teymourj FLUENT 2 July 28, 2011 17:45
UDF force on a face enry Fluent UDF and Scheme Programming 10 March 23, 2011 11:48


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