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

Density UDF

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 20, 2014, 22:28
Default Density UDF
  #1
Member
 
le hoang anh
Join Date: Oct 2012
Posts: 96
Rep Power: 13
lehoanganh07 is on a distinguished road
Hi,
I made simple code to calculate liquid density as Tammannn equation:
(p+pc)=k*rho*(t+t0)

this is the code:
#include "udf.h"
#define pc 1944610000
#define t0 3836.94
#define ck 472.26
DEFINE_PROPERTY(liq_rho,c,t)
{
real temp=C_T(c,t);
real p =C_P(c,t);
real rhol;
rhol=(p+pc)/ck/(temp+t0);
return rhol;
}

When I interpret and loaded the UDF file above in the density option, but the file was not loaded as in the picture below. And I got this warning

cpp -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/src" -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v140\fluent\fluent14.0.0/multiport/src" -I. -DUDF
ONFIG_H="<udfconfig.h>" "C:\Users\Ledinhanh07\Desktop\liquid_density.c "
temp definition shadows previous definition
.entry
liq_rho:
.local.int c (r0)
.local.pointer t (r1)
0 .local.end
0 save
.local.double temp (r3)
1 ld.pointer t (r1)
3 push.int 328
5 pointer.incr
6 push.int 1688
8 pointer.incr
9 slda.pointer
10 ld.int c (r0)
12 push.int 8
14 mul.int
15 pointer.incr
16 slda.double
.local.double p (r4)
17 ld.pointer t (r1)
19 push.int 328
21 pointer.incr
22 push.int 0
24 pointer.incr
25 slda.pointer
26 ld.int c (r0)
28 push.int 8
30 mul.int
31 pointer.incr
32 slda.double
.local.double rhol (r5)
33 push.double 0
35 ld.double p (r4)
37 push.double 1.94461e+09
39 add.double
40 push.double 472.26
42 div.double
43 ld.double temp (r3)
45 push.double 3836.94
47 add.double
48 div.double
49 sto.double rhol (r5)
51 pop.double
52 ld.double rhol (r5)
54 ret.double
55 restore
56 ret.v

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

The pictures as in order: 1. interpret UDF
2. load the UDF in the density panel
3. the UDF name: liq_rho is loaded
4. but when I check again, the file liq_rho dissapare

Anyone can help me?
Attached Images
File Type: png 1.png (12.9 KB, 20 views)
File Type: jpg 2.jpg (43.6 KB, 17 views)
File Type: png 3.png (21.6 KB, 14 views)
File Type: png 4.png (19.4 KB, 12 views)
lehoanganh07 is offline   Reply With Quote

Old   July 21, 2014, 03:42
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 21
blackmask will become famous soon enough
See whether this code works
Code:
#include "udf.h"
#define pc 1944610000
#define t0 3836.94
#define ck 472.26
DEFINE_PROPERTY(liq_rho,c,t)
{
    if (NULLP(THREAD_STORAGE(t, SV_P)) || NULLP(THREAD_STORAGE(t, SV_T)))
        return 1073; /* fault-safe value for rho */
    return ( C_P(c,t)+pc )/( C_T(c,t)+t0 )/ck;
}
blackmask is offline   Reply With Quote

Old   July 22, 2014, 02:44
Default
  #3
Member
 
le hoang anh
Join Date: Oct 2012
Posts: 96
Rep Power: 13
lehoanganh07 is on a distinguished road
Thank blackmask,

I try your code, but still got the trouble. I dont know why I could not load the UDF for water density.
lehoanganh07 is offline   Reply With Quote

Old   August 17, 2014, 10:36
Default
  #4
New Member
 
walied
Join Date: Aug 2014
Posts: 16
Rep Power: 11
walied123 is on a distinguished road
hello every body...........need for help
i try to make an UDF for changing density as a function of coordinates(say z coordinate) but it didnot work in fluent.
this is my UDF.
#include "udf.h"
DEFINE_PROPERTY(ANODE_DENSITY, thread, position)
{
float x[ND_ND]; /* this will hold the position vector */
float t,air,anode,electrolyte,po,va,ve,n,z,a,r,l,p,d,w,y ,u,POROSITY;
cell_t c;
t= 0.00008; /* ANODE THICKNESS */
air=1.28;
anode=4500.;
electrolyte=6010.;
n=2;
z=5;
w=(n+z)/n;
y=n/(n+z);
r=pow(w,n);
l=pow(y,z);
a=r/(1-l);
begin_c_loop(c,thread)
{
C_CENTROID(x, c, thread);
va=x[3]/t;
ve=1-va;
u=x[3]/t;
p= pow(u,n);
d= pow(u,z);
POROSITY = (a*p*(1-d));
po= ((va*anode)+(ve*electrolyte));
C_R(c, thread, position) =po*(1-POROSITY)+air*POROSITY;
}
end_c_loop(c, thread)
}
walied123 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
conductivity, viscosity, and density udf mdakbari Fluent UDF and Scheme Programming 3 December 12, 2018 13:08
UDF for solid density gghazal Fluent UDF and Scheme Programming 3 November 13, 2012 04:10
UDF: Density Cell Gradient Vector Macros matteo FLUENT 0 December 1, 2007 13:14
UDF to change density in species transport Karthik FLUENT 6 December 8, 2004 19:19
UDF : derivate of density D.Stratmann FLUENT 2 February 2, 2001 04:02


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