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 force and equilibrium position

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By flotus1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 11, 2013, 10:51
Default UDF for force and equilibrium position
  #1
New Member
 
Luca Gorasso
Join Date: Oct 2011
Location: Harbin, China
Posts: 24
Rep Power: 15
elcino is on a distinguished road
Send a message via Skype™ to elcino
Good morning all,

my problem looks simple but UDFs makes me. I have a cylinder, with a pressure profile around it while the simulation is converged.

1. I want to get simply the force on x and y direction, supposing that z is the width direction. I've understood that I have to loop around cells, multiply area for pressure for every cell but then how to understand the inclination of the cell to get the components of the force?

2. More complex, I want to calculate force on x and y to let the cylinder stay in an equilibrium position. So every iteration I have to loop around find the force, then move the cylinder, any idea of how to do that?

3. I want to print a .txt file with some quantities that are interesting like mass flows, forces, maximum pressure and maximum temperature and average temperature and viscosity in a format as follow:

mass_flow_out=10
mass_flow_in=10
force_x=10
force_y=20
max_P=100
max_T=30
ave_T=22
ave_nu=0.02

just a txt with this. How to do it? not how to calculate, just how to print it out!

Thanks for your time and attention.

P.S. Can someone clearly tell me what is the meaning of this error message: "Temperature definition shadows previous definition"?
elcino is offline   Reply With Quote

Old   March 14, 2013, 07:04
Default
  #2
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
I think you will need the macro ‘DEFINE_ADJUST’ which is executed before every iteration.

1. Look for C_NNODES, C_NFACES and C_NFACE. These macros are for information about the nodes and faces in a cell. I think the information about nodes and faces can be exploited to get the correct force components and thus the information you seek.
vasava is offline   Reply With Quote

Old   March 14, 2013, 07:23
Default what if?
  #3
New Member
 
Luca Gorasso
Join Date: Oct 2011
Location: Harbin, China
Posts: 24
Rep Power: 15
elcino is on a distinguished road
Send a message via Skype™ to elcino
To answer to the first issue. What if I do like this:

1) Ask the center of the face with F_CENTROID(position,f,t) of every cell, then I will have x=position[0]; and y=position[1];

2) Because the x,y,z system of the cylinder is in the center I can calculate with Pitagora simply the angle between the face and the cylinder axes.

3) Then i calculate the force normal to the face which is just area*pressure so something like F_P(f,t)*F_AREA(... here i don't know).

4) Then with cos and sin i can calculate the components.

5) I'll do it for every cell in a loop and I will sum them: Fx+=F_P(f,t)*F_AREA(... here i don't know)*cos(angle);

Somebody thinks can work?

for the second issue, I know that is not a transient simulation so every time that it converges it as to calculate the force and move the cylinder in another position, since the position converge to an equilibrium. I can do it as well in matlab with batch mode loop but i fluent I have the advantage that the solver uses the previous solution and this, because the movement is little, i mean the equilibrium position is very near to the initial guess, will make the loop convergence faster.

To write the file, third issue, i can do it, is not hard, but before i have to fix the problems above.

Thanks all!!
elcino is offline   Reply With Quote

Old   March 14, 2013, 08:44
Default
  #4
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Keep in mind that the shear stresses contribute to the drag force too.
elcino and vasava like this.
flotus1 is offline   Reply With Quote

Old   March 17, 2013, 02:04
Default Answer
  #5
New Member
 
Luca Gorasso
Join Date: Oct 2011
Location: Harbin, China
Posts: 24
Rep Power: 15
elcino is on a distinguished road
Send a message via Skype™ to elcino
Good morning all,

I've solved my self my issues but still have some questions.

Solution:

1) For the force calculation there are two ways, the first is to let Fluent plot the report and read it with the matlab read utilities, or is possible to calculate the force using the scheme proposed above, in my previous post. Some of you are right, this WILL NOT INCLUDE viscous forces. But in my case viscous forces are negligible, lower the 0,1% of the global force! Hence, the procedure is:

a) find the centroid of the face
b) calculate the inclination
c) multiply the force (area*pressure) on that face for the sin cos of the inclination
d) loop over all the faces

Pay attention to the sign of sin cos functions!!!!

2) To write the file is the usual procedure fopen!

FILE *fout;


DEFINE_ON_DEMAND(plot)

{

Thread *t;
Domain *d;
cell_t c;
face_t f;
d = Get_Domain(1);

fout = fopen("results.txt", "w");
fprintf(fout, "%g \n",flow); /* Mass flow */
fclose(fout);

}

Where flow must be a global variable defined outside the functions

3) Is not correct and possible use the CG_MOTION to find the equilibrium position, is better (especially to manage the mesh quality) do it with a batch mode cycle with matlab and gambit, is not that hard!

I'm still asking:

What is the meaning of "Temperature definition shadows previous definition"?

And how to obtain the viscous moment? Why fluent do not give the opportunity to obtain a data that he calculates easily like, let's say, viscous moment. And a so complex procedure is needed??? Is frustrating that ones didn't think to the possibility to ask a data and store it without write every time a specific UDF!

Thank you all!

Bye!

Zhai jian!

Ciao!
elcino is offline   Reply With Quote

Old   March 17, 2013, 04:32
Default
  #6
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Quote:
What is the meaning of "Temperature definition shadows previous definition"?
Something similar happened in a case where I accidentally tried to write on a variable that was read-only in the context I used it.
If you post your whole UDF, we can surely find the error.

Quote:
And how to obtain the viscous moment?
Almost the same way you did it with the pressure force.
Only this time it is the wall shear stress vector projected onto the direction you want to evaluate.
flotus1 is offline   Reply With Quote

Old   March 17, 2013, 04:38
Default Ok
  #7
New Member
 
Luca Gorasso
Join Date: Oct 2011
Location: Harbin, China
Posts: 24
Rep Power: 15
elcino is on a distinguished road
Send a message via Skype™ to elcino
Thanks Flotus1,

I got it, i guess is when u try to use as a variable something like "temp" which is already used... solution: do not use temp or press or whatever, use other names like t_emp, and the message disappear!

For the second, got it too, i know that i can do it but is terribly boring. And by the way, how to ask the wall shear stress components on face? i saw something like that in the forum and I've tried to use it but i got a segmentation error.

By the way with report works fine.

Thanks again
elcino 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
equilibrium constant in fluent ashishpande FLUENT 1 May 30, 2014 06:43
How can i check that my UDF is being used in fluent istead of its internal data chemkin Fluent UDF and Scheme Programming 4 June 8, 2012 09:07
Chemical Equilibrium Simulation using Fluent enigma ANSYS 2 October 27, 2011 09:02
HELP: udf compiling mistake Siyu FLUENT 2 June 26, 2006 07:58
equilibrium mass fraction Neser25 CFX 0 May 31, 2006 08:46


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