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

Zone motion udf error in Fluent

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2017, 08:26
Default Zone motion udf error in Fluent
  #1
New Member
 
Sigurd TH
Join Date: Feb 2016
Location: Edinburgh, United Kingdom
Posts: 8
Rep Power: 10
Sigurd is on a distinguished road
Hi!

I am trying to compile a udf for a rotating shaking flask, or an Orbitally Shaken Bioreactor for those of you familiar with those.

The code I am using is pretty basic I think, but it returns an error of:

udf_names.c(7) : error C2059: syntax error : '}'
udf_names.c(8) : warning C4034: sizeof returns 0

and this is the code I am using:

Code:
#include "udf.h"
#define pi 3.141592654
#define d_o 0.025 //shaking diamter [m]
 DEFINE_ZONE_MOTION(rotation,omega,axis,origin,velocity,time,dtime)
{
 real omega_o, theta, r_o;

 omega_o=pi*2; //angular velocity of shaker table [rad/s]
 *omega=-omega_o; //angular velocity of shake flask [rad/s]
 theta=omega_o*(time+dtime); //angular position of shake flask [radians]
 r_o=d_o/2; //shaking radius [m]
 
 origin[0]=r_o*cos(pi+theta);
 origin[1]=r_o*sin(pi+theta);
 origin[2]=0;
}
Any help would be greatly appreciated!

Thanks
Sigurd
Sigurd is offline   Reply With Quote

Old   October 24, 2018, 10:24
Default
  #2
New Member
 
Vincent Wiegmann
Join Date: Oct 2018
Posts: 3
Rep Power: 8
MandatoryMadness is on a distinguished road
Hi!


Sorry to revive this thread


I am currently working on a similar problem in Fluent. Have you found a solution for the shake flasks? My UDF code looks similar and can be compiled etc. but the movement of the mesh is not right.



This is the code:

#include "udf.h"
#define PI 3.14592654
DEFINE_ZONE_MOTION(rotation, omega, axis, origin, velocity, time, dtime)
{
real theta0, theta1, omegac, omegar, rdar, ox, oy;
omegar = -20.94;
omegac = -omegar;
rdar = 0.0125;
theta0 = PI;
theta1 = omegar*(time+dtime);
*omega = omegac;
origin [0] = rdar*cos(theta0+theta1);
origin [1] = rdar*sin(theta0+theta1);
origin[2] = (0,0);
}
MandatoryMadness is offline   Reply With Quote

Old   October 29, 2018, 10:38
Default
  #3
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Vincent,

Does that code really compile? "origin[2] = (0,0);" doesn't look like correct C to me.

Moving the origin is a rather mind-bending thing to do here. If you just want oscillatory rotation, the origin stays constant. If you want oscillatory rotation plus some other motion, you probably need to add some translation velocity. For the motion of a beaker on a tray, it could all be translation velocity.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   October 29, 2018, 13:29
Default
  #4
New Member
 
Vincent Wiegmann
Join Date: Oct 2018
Posts: 3
Rep Power: 8
MandatoryMadness is on a distinguished road
Hi Ed,



Thanks for the input! The code compiles fine, I will try another format just to make sure this is not the cause of the incorrect movement.



Unfortunately, this setup requires two motions. 1) The vessel rotating around the origin and 2) the vessel rotating around itself in the opposite direction - so effectively the vessel always faces the same direction during the rotation.



How would you add a translation velocity?



Many thanks and regards
Vince
MandatoryMadness is offline   Reply With Quote

Old   October 30, 2018, 08:42
Default
  #5
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Vince,

Well, I'll put it another way: what do you intend to be the result of "origin[2] = (0,0);"? It doesn't look familiar to me.

(Rotation about one axis + equal and opposite rotation about another axis) = no rotation, only translation. Look at the velocity argument in DEFINE_ZONE_MOTION.

A couple of very minor comments while I'm here: You will find that M_PI is already defined for pi. You can try to finesse the time for evaluating functions -- time, or time+dtime, or something in between -- but in general it's easier to stick with time.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   January 21, 2020, 10:53
Default Query related to zone motion
  #6
New Member
 
Tanuj Srivastava
Join Date: Mar 2019
Posts: 15
Rep Power: 7
S_Tanuj is on a distinguished road
I am trying to give the zone motion using UDF. Below is the code attached. Though it shows no error on compilation, zone does not seem to rotate as per code. Geometry is simple 2-D closed-loop pipe and origin is at the bottom. Is there anything wrong in UDF?

#include "udf.h"
#define Freq 0.1
#define angular_freq 2.0*M_PI*Freq
#define tetmax 15.0*M_PI/180

DEFINE_ZONE_MOTION(shm, omega, axis, origin, velocity, time, dtime)
{
*omega = tetmax*angular_freq*cos(angular_freq*time);

velocity[0] = 0.0;
velocity[1] = 0.0;
velocity[2] = 0.0;

omega[0] = 0.0;
omega[1] = 0.0;
omega[2] = *omega;

}
S_Tanuj is offline   Reply With Quote

Old   January 22, 2020, 02:14
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
remove * before omega
was:
Code:
 *omega
to be:
Code:
 omega
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 22, 2020, 02:23
Default
  #8
New Member
 
Tanuj Srivastava
Join Date: Mar 2019
Posts: 15
Rep Power: 7
S_Tanuj is on a distinguished road
Earlier I did the same but there was error because of not including "*", and the error was-

zone_motion.c
..\..\src\zone_motion.c(8) : error C2440: '=' : cannot convert from 'double' to 'real *'
..\..\src\zone_motion.c(16) : error C2440: '=' : cannot convert from 'real *' to 'real'

After including "*", it easily compiled.
S_Tanuj is offline   Reply With Quote

Old   January 22, 2020, 04:04
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"
#define Freq 0.1
#define angular_freq 2.0*M_PI*Freq
#define tetmax 15.0*M_PI/180

DEFINE_ZONE_MOTION(shm, omega, axis, origin, velocity, time, dtime)
{
velocity[0] = 0.0;
velocity[1] = 0.0;
velocity[2] = 0.0;

omega[0] = 0.0;
omega[1] = 0.0;
omega[2] = tetmax*angular_freq*cos(angular_freq*time);
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 30, 2020, 03:34
Default
  #10
New Member
 
Tanuj Srivastava
Join Date: Mar 2019
Posts: 15
Rep Power: 7
S_Tanuj is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
Code:
#include "udf.h"
#define Freq 0.1
#define angular_freq 2.0*M_PI*Freq
#define tetmax 15.0*M_PI/180

DEFINE_ZONE_MOTION(shm, omega, axis, origin, velocity, time, dtime)
{
velocity[0] = 0.0;
velocity[1] = 0.0;
velocity[2] = 0.0;

omega[0] = 0.0;
omega[1] = 0.0;
omega[2] = tetmax*angular_freq*cos(angular_freq*time);
}

The code shoes no error BUT using frame motion in "cell zone boundary condition" motions is NOT OBSERVED. What could be the reason for this. Though mass flow rate fluctuate which point out towards effect of UDF.
S_Tanuj is offline   Reply With Quote

Reply

Tags
fluent, udf, zone motion


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
[Commercial meshers] Fluent3DMeshToFoam simvun OpenFOAM Meshing & Mesh Conversion 50 January 19, 2020 16:33
[Resolved] GPU on Fluent Daveo643 FLUENT 4 March 7, 2018 09:02
[ANSYS Meshing] Problem UDF for sinusoidal wall motion - FLUENT avd28 ANSYS Meshing & Geometry 0 August 21, 2015 15:46
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 13:25
Incorrect CG motion UDF on Zone ... (assuming no motion) Irenedea Fluent UDF and Scheme Programming 0 March 21, 2014 03:45


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