CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   extract calculation result from udf (https://www.cfd-online.com/Forums/fluent-udf/168624-extract-calculation-result-udf.html)

anubhavd March 26, 2016 02:40

extract calculation result from udf
 
Hello
I have written a udf to calculate nucleation rate(function of temperature and concentration) taking temperature and concentration values from Ansys Fluent simulation.Now I need to extract the nucleation rate values.Can anyone suggest me how to extract this?

gewuzhizhi March 28, 2016 09:49

do you want to extract these parameters on a predefined plane? first get the plane IDfrom the Boundary condition GUI,then using F_T(f,t) to get temperature,etc. you can search face macro in the help.cell macro is similar

Bruno Machado March 30, 2016 06:35

Quote:

Originally Posted by anubhavd (Post 591724)
Hello
I have written a udf to calculate nucleation rate(function of temperature and concentration) taking temperature and concentration values from Ansys Fluent simulation.Now I need to extract the nucleation rate values.Can anyone suggest me how to extract this?

you can easily define a UDMI and get copy the values of your variable into it.

anubhavd March 30, 2016 06:52

Dear Bruno Machado
I am copying my udf code can you please suggest me how to call UDMI and extract the values. I need to extract "J" values at different locations to plot contour.

#include "udf.h"
#include "math.h"

DEFINE_SOURCE(decay_rate_of_zn_vapor,c,t,dS,eqn)
{

real x[ND_ND];
real source;
real r,sigma,rho,R,S1,m,n,A,beta,K,N1,G1,J,M,Z,Psat,P;
if(C_YI(c,t,0)>0)
{

C_CENTROID(x,c,t);
K=1.3807e-23;
R=8.3143;
m=0.065;
A=6.023e23;
sigma=0.83;
rho=6559-0.884*(C_T(c,t)-692.677);
P=C_R(c,t)*C_YI(c,t,0)*R*C_T(c,t);
if(C_T(c,t)>700)

Psat=pow(10.,((-6620./C_T(c,t))-(1.255*log10(C_T(c,t)))+14.465));
else
Psat=1000*(pow(10.,((-6850./C_T(c,t))-(0.755*log10(C_T(c,t)))+10.365)));

return Psat;

S1=P/Psat;
r=(2*sigma*m*2.303)/(rho*R*C_T(c,t)*log10(S1));
G1=(4*3.14*pow(r,2)*sigma)/3;
N1=P/(K*C_T(c,t));
M=m/A;
beta=N1*pow((K*C_T(c,t)/(2*3.14*M)),0.5);
Z=(M/(2*3.14*pow(r,2)*rho))*(pow((sigma/(K*C_T(c,t))),0.5));
J=4*3.14*pow(r,2)*beta*Z*N*exp(-G1/(K*C_T(c,t)));

source=-(4*3.14*pow(r,3)*rho*J)/3;

dS[eqn]=0.0;
}
else
source = dS[eqn] = 0;
printf("Temperature: %g\n",C_T(c,t));
return source;

}

Bruno Machado March 30, 2016 07:08

Quote:

Originally Posted by anubhavd (Post 592385)
Dear Bruno Machado
I am copying my udf code can you please suggest me how to call UDMI and extract the values. I need to extract "J" values at different locations to plot contour.

#include "udf.h"
#include "math.h"

DEFINE_SOURCE(decay_rate_of_zn_vapor,c,t,dS,eqn)
{

real x[ND_ND];
real source;
real r,sigma,rho,R,S1,m,n,A,beta,K,N1,G1,J,M,Z,Psat,P;
if(C_YI(c,t,0)>0)
{

C_CENTROID(x,c,t);
K=1.3807e-23;
R=8.3143;
m=0.065;
A=6.023e23;
sigma=0.83;
rho=6559-0.884*(C_T(c,t)-692.677);
P=C_R(c,t)*C_YI(c,t,0)*R*C_T(c,t);
if(C_T(c,t)>700)

Psat=pow(10.,((-6620./C_T(c,t))-(1.255*log10(C_T(c,t)))+14.465));
else
Psat=1000*(pow(10.,((-6850./C_T(c,t))-(0.755*log10(C_T(c,t)))+10.365)));

return Psat;

S1=P/Psat;
r=(2*sigma*m*2.303)/(rho*R*C_T(c,t)*log10(S1));
G1=(4*3.14*pow(r,2)*sigma)/3;
N1=P/(K*C_T(c,t));
M=m/A;
beta=N1*pow((K*C_T(c,t)/(2*3.14*M)),0.5);
Z=(M/(2*3.14*pow(r,2)*rho))*(pow((sigma/(K*C_T(c,t))),0.5));
J=4*3.14*pow(r,2)*beta*Z*N*exp(-G1/(K*C_T(c,t)));

source=-(4*3.14*pow(r,3)*rho*J)/3;

dS[eqn]=0.0;
}
else
source = dS[eqn] = 0;
printf("Temperature: %g\n",C_T(c,t));
return source;

}

in the Fluent, go to Define -> User define -> Memory and define 1 UDMI.
in your code, you can add the following line (where XXXXX is the variable you want to dump).

C_UDMI(c,t,0) = XXXXX;

Another tip to make you calculations quicker: i saw that you compute many times the temperature C_T(c,t) in your calculations. It is easier and quicker if you add a variable T (for example) to your list of variables and define it as your temperature

T = C_T(c,t);

then fluent wont compute many times the same variable.


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