|
[Sponsors] |
November 15, 2012, 03:56 |
Force in UDF
|
#1 |
New Member
Join Date: Nov 2012
Posts: 5
Rep Power: 14 |
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! |
|
November 20, 2012, 02:43 |
|
#2 |
New Member
Join Date: Mar 2010
Posts: 25
Rep Power: 16 |
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 |
|
November 20, 2012, 08:08 |
|
#3 |
New Member
Join Date: Nov 2012
Posts: 5
Rep Power: 14 |
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 |
|
November 20, 2012, 08:48 |
|
#4 |
New Member
Join Date: Mar 2010
Posts: 25
Rep Power: 16 |
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) } |
|
November 20, 2012, 08:55 |
|
#5 |
New Member
Join Date: Mar 2010
Posts: 25
Rep Power: 16 |
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.
|
|
May 11, 2015, 08:17 |
Compute_Force_And_Moment problem
|
#6 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
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) } |
|
May 11, 2015, 08:25 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
If you read Dorit's post above, it says:
"The UDF will need to be compiled" Did you do that, or did you interpret? |
|
May 11, 2015, 13:20 |
|
#8 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
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" |
|
May 12, 2015, 03:54 |
|
#9 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
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) Code:
Compute_Force_And_Moment (d,t_object,cg,force,moment,TRUE); |
||
May 12, 2015, 05:35 |
|
#10 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
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. |
|
May 12, 2015, 07:40 |
|
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
May 12, 2015, 07:54 |
|
#12 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
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! |
|
May 12, 2015, 07:57 |
|
#13 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
Actually I am simulating unsteady flow over cylinder, lift generated at previous time step is used to calculate inlet velocity at current time-step.
|
|
May 12, 2015, 08:12 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
May 12, 2015, 09:08 |
|
#15 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
Hey.... Problem solved.
Thank you very much. |
|
May 12, 2015, 09:20 |
|
#16 |
New Member
Shree
Join Date: May 2014
Posts: 10
Rep Power: 12 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ActuatorDiskExplicitForce in OF2.1. Help | be_inspired | OpenFOAM Programming & Development | 10 | September 14, 2018 12:12 |
UDF for defining a body force in Singel ROtating Reference Frame | teymourj | Fluent UDF and Scheme Programming | 9 | August 18, 2016 16:33 |
UDF in Fluent | Andrew | Fluent UDF and Scheme Programming | 5 | March 7, 2016 04:38 |
Force can not converge | colopolo | CFX | 13 | October 4, 2011 23:03 |
UDF force on a face | enry | Fluent UDF and Scheme Programming | 10 | March 23, 2011 11:48 |