CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > 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 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: 7
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: 180
Rep Power: 7
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: 7
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: 7
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: 180
Rep Power: 7
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: 180
Rep Power: 7
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: 7
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: 180
Rep Power: 7
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

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 16:28.