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

Sloshing of water tank

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 1, 2014, 12:56
Default
  #21
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Quote:
Originally Posted by darkluix88 View Post
This one probably is the better solution, applying the force to the centroid of the mass of fluid in tank.
Can you help me to create a simple UDF with the DEFINE_SOURCE macro?
For example, I want to use a simple sinusoidal velocity to the fluid: v=-omega*A*sin(omega*t + phase)
Because I'm a newbie and I don't understand some commands as C_R(c,t) or C_U(c,t), or the "con" variable.
You will not apply a force to the centroid of the mass: you define the source (which is in this case expressed in N/m3) in one or more zones and every cell in that zone(s) is subjected to that source.
So first thing is to calculate the function source you want to apply inside the tank, something like source=f(time, other variables you want to include), expressed in N/m3.
Then, I suggest to read the fluent udf manual and look at examples.
Macros such as C_R(c,t) and C_U(c,t) are described in the udf user manual.
ghost82 is offline   Reply With Quote

Old   November 2, 2014, 05:30
Default
  #22
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Thanks for the help and I'm sorry for the too many questions that I ask you
Ok, I'm reading the manual and approaching to create the source file udf but I'm probably getting wrong...actually my code is this one for example:

#include "udf.h"
#define w 1
#define a 0.1
#define ph 0

DEFINE_SOURCE(xmom_src,c,t,dS,eqn)
{
real source;
real time=RP_Get_Real("flow-time");

if (time < 5)
{
source = -w*a*sin((w*time) + ph);
dS[eqn] = -w*w*a*cos((w*time) + ph);
}
else
source = 0;

return source;
}

I've set as constants the initial phase (0), omega (1) and amplitude (0.1) and the time step size as 5 seconds.
Which corrections have I to add for my purpose?
darkluix88 is offline   Reply With Quote

Old   November 2, 2014, 08:27
Default
  #23
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
The "source" in your udf must have unit N/m3 (force/volume): did you check it?
dS[eqn] is derivative of "source" in respect to the dependent variable of the transport equation (v(x)): did you check it?
Even if time >5 you have to assign dS[eqn].

What do you mean by "initial phase"?
ghost82 is offline   Reply With Quote

Old   November 2, 2014, 09:04
Default
  #24
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
How can I convert a sinusoidal velocity to N/m3? The only parameters known are these ones: amplitude, phase and pulsation (or frequency, is the same).
The initial phase is the delay/advance ("ritardo/anticipo") regarding the start position of the sine curve.
darkluix88 is offline   Reply With Quote

Old   November 2, 2014, 09:24
Default
  #25
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Answers to your questions are partially in the post I reported.

More into details N/m3 is a force in respect to a volume and it's expressed in SI units as (kg*m/s2)*(1/m3).
This is the same as multiply acceleration (m/s2) by density (kg/m3).
If you have the velocity you can calculate the function for acceleration: accelaration is the variation of the velocity in respect to time, in other words simply d(velocity)/d(time).
Then calculate dS as I wrote.

So what you have to do is to define two udf: one for x momentum source, with acceleration function that multiply density (C_R(c,t));
one for y momentum source, with gravity force that multiply density.

Otherwise, only one udf for x momentum source, but enbable in fluent gui gravity in (-)y direction.
ghost82 is offline   Reply With Quote

Old   November 2, 2014, 12:19
Default
  #26
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Okok, now I've understood how to approach the problem better!
So, at first I've to convert the physical quantity that I want to apply in momentum as N/m3, next I define the variable "source" as the quantity previously calculated, and at last "dS[eqn]" represent the derivative of the "source" respect to the velocity...is it right?
I've modified the udf code as this one:

#include "udf.h"
#define w 1
#define a 0.1
#define ph 0

DEFINE_SOURCE(xmom_src,c,t,dS,eqn)
{
real source;
real time=RP_Get_Real("flow-time");

if (time < 5)
{
source = (-w*w*a*cos((w*time) + ph))*C_R(c,t);
dS[eqn] = w*cot((w*time) + ph)*C_R(c,t);
}
else
source = dS[eqn] = 0.;

return source;
}

Are there errors in the formulas?
The input quantity is the same sinusoidal velocity: v(t)=-w*a*sin((w*t)+ph)...thanks for the help
darkluix88 is offline   Reply With Quote

Old   November 2, 2014, 12:32
Default
  #27
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Equation for x momentum source seems correct to me.
dS[eqn] is dS/d(vx) so in my opinion it should be 0.

Quote:
source = dS[eqn] = 0.;
Not sure you can do it in C; if not, write 2 lines instead of one.

Last edited by ghost82; November 3, 2014 at 04:45.
ghost82 is offline   Reply With Quote

Old   November 2, 2014, 12:50
Default
  #28
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Ah okok, I thought that dS[eqn] was different to 0 because, being the source (acceleration)*(density) and acceleration = (velocity/time), it contains the velocity expression inside of it...essentially I have multiplied and divided the source expression for " sin((w*time) + ph) " to point out the velocity expression.
darkluix88 is offline   Reply With Quote

Old   November 2, 2014, 15:19
Default
  #29
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Maybe you are right, but I'm not 100% sure. Maybe someone else knows.
If it is right, use 1/tan instead of cot.
__________________
Google is your friend and the same for the search button!

Last edited by ghost82; November 3, 2014 at 04:17.
ghost82 is offline   Reply With Quote

Old   November 3, 2014, 04:22
Default
  #30
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
I've tried this type of udf and it works! Only I've explouted the cotangent expression because in udf cotangent command isn't detectedby fluent. Thanks for your help
Now I wanna use for example angular velocity, but I think that this approach "cell to cell" isn't optimal in this case, because effects as centrifugal and coriolis forces are neglected...

So how can I resolve this problem?

If I would use newly the Dynamic mesh, is it possible applicate the force/movement (translational or angular) to the tank, and so to the water, without deforming the cells?
Essentially: the water inside the tank moves, but the initial quad-cells of the tank don't deform. It would be a more precise model
darkluix88 is offline   Reply With Quote

Old   November 3, 2014, 04:33
Default
  #31
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Yes, I just commented the above post for cot

Why are you saying centrfugal and coriolis forces are neglected?
As far as I know these forces are automatically calculated: you have to define the center and the axis of rotation in the fluid zones.
ghost82 is offline   Reply With Quote

Old   November 3, 2014, 05:01
Default
  #32
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Exactly, I didn't notice it!

So are considered all the forces related to the movement imposed? I thought that the effect of coriolis (as centrifugal/centripetal effects) should be an effect regarding the entire structure, not the single cells...but I'm not sure of this.
So applying this method to rotational method is reliable? For the udf setting, I can use the same structure of previous code changing constants, source and dS[eqn] terms, right?

To have a complete control of the problem, is it possible to apply the dynamic mesh to move the tank without deforming the cell's geometry?
darkluix88 is offline   Reply With Quote

Old   November 3, 2014, 05:11
Default
  #33
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Quote:
So are considered all the forces related to the movement imposed?
Yes, I think so..

Quote:
So applying this method to rotational method is reliable?
Try it

Quote:
For the udf setting, I can use the same structure of previous code changing constants, source and dS[eqn] terms, right?
Yes

Quote:
To have a complete control of the problem, is it possible to apply the dynamic mesh to move the tank without deforming the cell's geometry?
If you look at the sketch I posted some posts above the cells of the tank will not be deformed; new/old layers of cells will be added/removed outside of the tank, but you are not interested in the outer domain, so you can fill the outer domain with air and assign a P inlet/P outlet condition.

However I think the best solution is to apply sources to momentum equation.
ghost82 is offline   Reply With Quote

Old   November 3, 2014, 05:38
Default
  #34
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Okok, I will try this approach to various cases and I'll let you know

Now I've understood, but I've to set a particular condition to avoid the cell's deformation with this scheme or it's automatic after created the outer domain?
Are static also the upper and bottom walls of the outer domain, or only its left and right walls as in the sketch?
Another idea: is it possible to extend the outer domain also up and down respect to the tank? So simultaneously I could apply more velocity vectors (for example) in different directions without the problem of cell's deformation.

darkluix88 is offline   Reply With Quote

Old   November 3, 2014, 05:43
Default
  #35
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Quote:
Originally Posted by darkluix88 View Post
Okok, I will try this approach to various cases and I'll let you know

Now I've understood, but I've to set a particular condition to avoid the cell's deformation with this scheme or it's automatic after created the outer domain?
Are static also the upper and bottom walls of the outer domain, or only its left and right walls as in the sketch?
Another idea: is it possible to extend the outer domain also up and down respect to the tank? So simultaneously I could apply more velocity vectors (for example) in different directions without the problem of cell's deformation.

To avoid deformation you have to set rigid body motion to the interior of the tank also (not only the walls), so you will apply motion to walls and to interior of the tank.
You can extend outer domain the way you want.
ghost82 is offline   Reply With Quote

Old   November 6, 2014, 17:30
Default
  #36
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Hi ghost82, I ve tried these days applying dynamic mesh with walls as rigid body and also the default_interior as rigid body, but it doesn't run.
In fact the tank moves but the fluid inside remain at the initial relax position with no sloshing...how can I resolve the problem? Thanks for the help
darkluix88 is offline   Reply With Quote

Old   November 6, 2014, 17:32
Default
  #37
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
I have to try, not soon, but I'll let you know.
You can try to set as rigid body not the default interior but the fluid zone name.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   November 6, 2014, 17:38
Default
  #38
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
I obtain the same result....ok thanks, for now I post newly the question because I have to go on with my thesis
darkluix88 is offline   Reply With Quote

Old   November 10, 2014, 16:58
Default
  #39
Member
 
Join Date: Sep 2014
Posts: 43
Rep Power: 11
darkluix88 is on a distinguished road
Hi ghost82, returning to the momentum source method to simulate sloshing, how can I write the udf for the rotation source, defining the centre of rotation and the axis? For example, if I want apply the rotation to the centroid of the tank, which commands I've to use?
darkluix88 is offline   Reply With Quote

Old   November 11, 2014, 08:36
Default
  #40
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
Hi!
I think that if you want to simulate rotation around a central axis of a 2d rectangle you are assuming a cilindrical tank.
If this is not your case I think you have to simulate a 3d geometry.
I think there's no need to write udf if your tank rotates at a constant angular velocity (here you simulate steady state solution): assuming your rectangle is centered in xy plane, set up your case with gravity in -y direction and you're ready to go.
If you want to do a transient simulation then angular velocity starts from 0 rad/s and reach xx rad/s, so you have equation for angular velocity in respect to time; so, follow what you have done for translational motions.

This is for axisymmetric:
http://aerojet.engr.ucdavis.edu/flue...ug/node399.htm
__________________
Google is your friend and the same for the search button!
ghost82 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
water sloshing in oscillating tank (problem using udf Define_ZONE_MOTION) Tamsu Fluent UDF and Scheme Programming 8 November 24, 2021 00:11
Filling Tank with Water leff CFX 7 August 21, 2017 07:47
Simple Water Tank Transient 88phil88 CFX 5 March 17, 2014 03:48
Mixture and Decay of a tracer in a Water Tank Jeffrey1992 CFX 2 July 27, 2012 13:31
uptodate water distribution network fredius,magige,tanzanian,(e.a) Main CFD Forum 0 January 27, 2002 07:10


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