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

Can you check if my attached UDF is correct??

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 27, 2010, 15:29
Default Can you check if my attached UDF is correct??
  #1
Member
 
Sandeep
Join Date: Jul 2010
Posts: 48
Rep Power: 15
gandesk is on a distinguished road
Hi,

I am running a multiphase simulation with VOF model which has a droplet spreading on a solid substrate. In order to account for the transient surface tension effects of added surfactant to the droplet, I have written a UDF which defines the above effect and hooked it after compiling. Now my question is that why am I getting my results as if it is having very less surface tension than the defined trend in UDF. I want to make sure if fluent is using values defined from the UDF and is there a way to create a file while the case is running about the values of surface tension being used while the case is running? I hope my question is clear and really sorry to bother you with such a lengthy question. Please look at the UDF defined below:


#include "udf.h"
DEFINE_PROPERTY(dyn_surf_tension, cell, thread)
{
double dst;
double c_t = CURRENT_TIME;
if (c_t >= 0 || c_t < 5.000000e-002)
dst = 7.145500e-002;
if (c_t >= 5.000000e-002 || c_t < 7.050000e-001)
dst = 4.017570e-002;
if (c_t >= 7.050000e-002 || c_t < 9.950000e-002)
dst = 3.862980e-002;
if (c_t >= 9.950000e-002 || c_t < 1.000000e-001)
dst = 3.862690e-002;
else
dst = 3.862410e-002;
return dst;
}

Thanks and Regards
Sandeep K Gande
gandesk is offline   Reply With Quote

Old   December 28, 2010, 11:11
Default
  #2
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Gandesk,

If you're hooking the UDF to the surface tension property box, found under phase--->interaction, you should be OK. I've changed your "double" variable definition to "real," changed the syntax slightly, and posted below. See if it works for you:

Code:
#include "udf.h"
DEFINE_PROPERTY(dyn_surf_tension, cell, thread)
{
	real dst;
	real c_t = CURRENT_TIME;
	
	dst = 3.862410e-002;
	if (c_t >= 0 && c_t < 5.000000e-002)
	{
		dst = 7.145500e-002;
	}
	if (c_t >= 5.000000e-002 && c_t < 7.050000e-001)
	{
		dst = 4.017570e-002;
	}
	if (c_t >= 7.050000e-002 && c_t < 9.950000e-002)
	{
		dst = 3.862980e-002;
	}
	if (c_t >= 9.950000e-002 && c_t < 1.000000e-001)
	{
		dst = 3.862690e-002;
	}
	return dst;
}
Your function for surface tension is not smooth; that is, surface tension is being given a number of discrete values, rather than interpolating between known points over time. You might think about interpolating to see if that helps.

Otherwise, to check the value of UDF-controlled surface tension (or any other UDF-controlled value), simply add a user-defined memory and examine it. Steps:
1) Define--->User-Defined--->Memory. Change the number to 1
2) In the code above, add
Code:
C_UDMI(cell,thread,0)=dst;
before the return statement.
3) Run a few time steps in your simulation, stop it, then examine the contours of the User-Defined-Memory location 0 to see if the surface tension matches what you expect.

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   December 28, 2010, 19:36
Default
  #3
Member
 
Sandeep
Join Date: Jul 2010
Posts: 48
Rep Power: 15
gandesk is on a distinguished road
Hi computerguy,

Thank you very much for your reply. It looks like the code is working good now. I will mail back you after the complete simulation. I hope it works perfectly.

I have another quesion wrt define--> memory. Can we include the same code with different numbers if we use more than one udf and want to extract all those values.

Thanks

Sandeep
gandesk is offline   Reply With Quote

Old   December 28, 2010, 19:45
Default
  #4
Member
 
Sandeep
Join Date: Jul 2010
Posts: 48
Rep Power: 15
gandesk is on a distinguished road
Hi computer guy,

I forgot to mention about this following thing in my previous reply. I just have the surface tension values at thoses descrete points. How can i interpolate function. I did not understand what you meant. Could u pls explain me??

Thanks
Sandeep
gandesk is offline   Reply With Quote

Old   December 28, 2010, 19:46
Default
  #5
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Sandeep,

If I recall correctly, you can define up to 500 user defined memory locations. As such, if you have variables you want to track from UDF's, I find UDMI's a better way of getting the status of such variables instead of writing to console.

You address them as
Code:
C_UDMI(cell,thread,XXX)=your_value;
Where XXX is the memory location, and your_value is what you'd like to assign.

Glad it's working.

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   December 28, 2010, 19:54
Default
  #6
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Sandeep,

Interpolating is simply choosing values in between your discrete points. If you were given two points which make up a line (y=m*x+b), you could figure out the equation which describes the line, and thus describe, for any value of x, the value of y.

By the way, I think there is a typo in the original code, which I've propagated in my code. The actual code (I think) should be:
Code:
#include "udf.h"
DEFINE_PROPERTY(dyn_surf_tension, cell, thread)
{
	real dst;
	real c_t = CURRENT_TIME;
	
	dst = 3.862410e-002;
	if (c_t >= 0 && c_t < 5.000000e-002)
	{
		dst = 7.145500e-002;
	}
	if (c_t >= 5.000000e-002 && c_t < 7.050000e-002)
	{
		dst = 4.017570e-002;
	}
	if (c_t >= 7.050000e-002 && c_t < 9.950000e-002)
	{
		dst = 3.862980e-002;
	}
	if (c_t >= 9.950000e-002 && c_t < 1.000000e-001)
	{
		dst = 3.862690e-002;
	}
	return dst;
}
ComputerGuy is offline   Reply With Quote

Old   December 28, 2010, 21:17
Default
  #7
Member
 
Sandeep
Join Date: Jul 2010
Posts: 48
Rep Power: 15
gandesk is on a distinguished road
Computer guy,

thanks for correcting me once again and really appreciate for your inputs. I have another question running a job which has UDF s in it parallelly. When I try to run it parallelly the follwing message is popping up in the log file.

Opening library "libudf"...
Primitive Error at Node 0: open_udf_library: No such file or directory


Could you help me what could be the reason

Actuallty I am try to run on a high performance linux cluster and I have used the following qsub commands

#PBS -N test21
#PBS -l walltime=90:00:00
#PBS -l nodes=4pn=4
#PBS -l software=fluent:fluentpar+16
#PBS -m abe
#PBS -S /bin/bash
#PBS -o /nfs/03/ucn0987/FLUENT/Test21/1.out
#PBS -j oe
set echo on
hostname
module load fluent
cd /nfs/03/ucn0987/FLUENT/Test21
rm -f pnodes
cat $PBS_NODEFILE | sort > pnodes
export ncpus=`cat pnodes | wc -l`
fluent 2ddp -t$ncpus -pinfiniband.ofed -cnf=pnodes -g < 3input



Thanks

Sandeep

Sandeep
gandesk is offline   Reply With Quote

Old   December 29, 2010, 11:05
Default
  #8
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Sandeep,

I don't believe there's anything in the code I've written which is incompatible with parallel usage. Are you compiling or interpreting the code?

The steps you should go through are:
1) Define --> User-defined --> Functions --> Compiled
2) Source files --> Add --> Your_Udf.c
3) Click "Build"
4) If there are no errors, click "Load"

If you already have a libudf loaded, go to:
1) Define --> User-defined --> Functions --> Managed
2) Select libudf
3) Click unload, then repeat steps 1-4 above

If your udf compiles OK, and the steps I've laid out don't throw an error, I'm not sure what the problem is.

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   March 6, 2017, 14:57
Default kindly check UDF and suggest better one
  #9
New Member
 
invincible
Join Date: Dec 2016
Posts: 17
Rep Power: 9
osamaajaz is on a distinguished road
The two UDF below are for dynamic mesh in which BODY A will move from POINT 1 to POINT 2 and then back to POINT 1, picture for that is attached here.
kindly check and tell me errors. Suggest the better one with faster speed
if wrong! how can i correct it?

UDF 1
#include "udf.h"
DEFINE_CG_MOTION(move,dt,vel,omega,time,dtime)
{
vel[1] = 0.0315*sin(0.21*time);

}

DEFINE_CG_MOTION(ball1,dt,vel,omega,time,dtime)
{
if (time>0 && time<1)
vel[1]=0;
else if (time>1 && time<2)
vel[1]=0.009;
else if (time>15 && time<16)
vel[1]=-0.0005;
else if (time>16 && time<17)
vel[1]=-0.0137;
else
vel[1]=-0.00;

}

DEFINE_CG_MOTION(ball2,dt,vel,omega,time,dtime)
{
if (time>0 && time<1)
vel[1]=-0.005;
else if (time>1 && time<16)
vel[1]=0.0315*sin(0.21*time);
else if (time>16 && time<17.58)
vel[1]=0.007;
else
vel[1]=0.0315*sin(0.21*time);
}



UDF 2
#include "udf.h"
DEFINE_CG_MOTION(move,dt,vel,omega,time,dtime)
{
vel[1] = 0.0942*sin(0.628*time);
}

DEFINE_CG_MOTION(ball1,dt,vel,omega,time,dtime)
{
if (time>0 && time<1)
vel[1]=0.018*time;
else if (time>5 && time<5.1)
vel[1]=-0.0005;
else if (time>5.1 && time<5.5)
vel[1]=-0.035;
else

vel[1]=-0.00;
}

DEFINE_CG_MOTION(ball2,dt,vel,omega,time,dtime)
{
if (time>0 && time<0.4)
vel[1]=-0.01;
else if (time>0.4 && time<5.5)
vel[1]=0.0942*sin(0.628*time);
else if (time>5.5 && time<6.17)
vel[1]=-0.0028;
else

vel[1]=0.0942*sin(0.628*time);
}
Attached Images
File Type: png 2222.png (6.9 KB, 9 views)
osamaajaz is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access only one phase in multiphase model by UDF wersoe Fluent UDF and Scheme Programming 1 January 4, 2017 08:11
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
UDF programming fullmonty FLUENT 5 June 30, 2011 03:40
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 08:21
I need UDF help. S.Whitney FLUENT 0 October 15, 2007 12:29


All times are GMT -4. The time now is 15:02.