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

udf not running iteration

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 27, 2015, 03:04
Default udf not running iteration
  #1
New Member
 
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 11
krushna is on a distinguished road
Dear All,
I am working on hydrogen absorption based on metal hydride. In my case, hydrogen is injected into the reactor, then hydrogen will react with metal (porous material) to form metal hydride at that time heat is generated which is kept out by using heat exchanger.

I was runing UDF many times but it not work(iteration not starting)


Any one COuld help me?

Here is my UDF code:
#include"udf.h"

/* Input Boundary Conditions */
#define T_i 300.0 /* Inlet temp in K */
#define T_f 298.0 /* Coolant fluid temp in Kelvin [K] */
#define P_i 10e5 /* Inlet pressure in pascals */
#define h_o 1000 /* Heat transfer coeff in W/m^2-K */
#define x_i 0 /* Initial value of H/M for reaction to START */
#define x_f 1 /* Final value of H/M for reaction to STOP @ saturation */

/* Properties of Misc Metal */
#define rho_m 8400 /* Density in kg/m^3 */
#define C_pm 419 /* Sp heat in J/kg-K */
#define K_m 3.0728 /* Thermal conductivity in W/m-K */
#define por 0.5 /* Porosity */
#define rho_ss 8518 /* Density of MH @ saturation kg/m^3 */
#define rho_s 8400 /* Density of MH kg/m^3 */
#define E_a 21170 /* Activation energy in J/mol H2 */
#define per 1e-8 /* Permeability */
#define DELTA_S 107.2 /* Entropy of Formation J/mol H2-K */
#define DELTA_H 28000 /* Enthalpy of Formation J/mol H2 */

/* Properties of Hydrogen */
#define K_g 0.1272 /* Thermal Conductivity in W/m-K */
#define C_pg 14283 /* Sp heat in J/kg-K */
#define rho_g 0.0838 /* Density in kg/m^3 */
#define M_g 2.016 /* Molecular weight in kg/mol */

/* CONSTANTS */
#define R_u 8.314 /* Universal gas Constant J/mol-K */
#define k_a 75 /* Reaction Constant for absorption in (sec)^-1 */

/* Initialization of cell property of scalar i.e. 'initial value of x to solve UDS_SOURCE'*/
DEFINE_INIT(my_init_fuc,d)
{
cell_t c;
Thread*t;
thread_loop_c(t,d)
{
begin_c_loop_all(c,t)
{
C_UDSI(c,t,0)= 0;
}
end_c_loop_all(c,t)
}
}

/*UDF for solving Energy Equation HEAT SOURCE term */
DEFINE_SOURCE(heat_generation,c,t,ds,eqn)
{
real q_a;
real physical_dt;

physical_dt = RP_Get_Real("physical-time-step");
q_a= 1000*(rho_ss-rho_s)*(1-por)*(DELTA_H/M_g)*(C_UDSI(c,t,0)-C_UDSI_M1(c,t,0))/physical_dt;
ds[eqn]=0;
C_UDMI(c,t,0)=q_a; /* Memory allocation for storing 'heat generation' */
return q_a;

}
/* Continuity Equation SOURCE term */
/* Not required in CONDUCTION model */
DEFINE_SOURCE(continuity_source,c,t,ds,eqn)
{
real c_a;
real physical_dt;
physical_dt = RP_Get_Real("physical-time-step");

c_a= (rho_ss-rho_s)*(1-por)*(C_UDSI(c,t,0)-C_UDSI_M1(c,t,0))/physical_dt;
ds[eqn]=0;
//C_UDMI(c,t,1)=c_a; /* Memory allocation for storing 'mass of Hydrogen stored' */
return c_a;

}

/* UDS for solving Kinetic equation by using unsteady equation i.e. by using Unsteady eq solving dx/dt eqn */
DEFINE_UDS_UNSTEADY(uds_time,c,t,i,apu,su)
{
real physical_dt;
real vol;
real rho;
real phi_old;
physical_dt = RP_Get_Real("physical-time-step");
vol = C_VOLUME(c,t);
rho = 1; /* for varying density use rho = C_R_M1(c,t); */
*apu = -rho*vol/physical_dt;
phi_old = C_STORAGE_R(c,t,SV_UDSI_M1(0));
*su = rho*vol*phi_old/physical_dt;
}

/* Kinetic Equation(dx/dt eq) SOURCE term for this define User Define Scalar i.e. 'x' */
/* Convection & Diffusion part are zero */
DEFINE_SOURCE(uds_source,c,t,ds,eqn)
{
real tp;
real rate;
real P_eq;
real cond;
real x_now;

tp = C_T(c,t);
P_eq = pow(2.72,((DELTA_S/R_u)-(DELTA_H/(R_u*tp))))*pow(10,5);
cond = P_i/P_eq;

if(cond>1)
{
rate = k_a*pow(2.72,(-E_a/(R_u*tp)))*((P_i/P_eq)-1)*((C_UDSI_M1(c,t,0) - x_f)/(x_i - x_f));
ds[eqn] = k_a*pow(2.72,(-E_a/(R_u*tp)))*((P_i/P_eq)-1)*(1/(x_i - x_f));
}
else
{
rate = 0;
ds[eqn] = 0;
}

C_UDMI(c,t,2)=rate; /* Memory allocation for storing 'rate' */
return rate;

}

Regards,
krushna
krushna is offline   Reply With Quote

Old   November 2, 2015, 16:46
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Which part of the iteration is not working, or does Fluent not even begin an iteration? Add a message in each macro to check if each macro is called. For example, add:

Code:
Message0("DEFINE_SOURCE macro is now starting...\n");
`e` is offline   Reply With Quote

Old   November 3, 2015, 00:26
Default
  #3
New Member
 
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 11
krushna is on a distinguished road
thank you for your help
regards
krushna
krushna is offline   Reply With Quote

Old   November 3, 2015, 01:32
Default
  #4
New Member
 
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 11
krushna is on a distinguished road
Dear 'e',
thank you for you solution, In my case, hydrogen is injected into the reactor, then hydrogen will react with metal (porous material) to form metal hydride at that time heat is generated which is kept out by using heat ex-changer. but coolant flow is started before hydrogen injection. so, i run steady cold flow simulation and then transient simulation with energy generation initialize by read .dat file of cold flow simulation.
problem is how to initialize the reactor side.
please give me solution.
thanking you,
regards,
krushna
krushna is offline   Reply With Quote

Old   November 3, 2015, 03:58
Default
  #5
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Does the usual initialisation procedure not work (uniform initial conditions)? You could also patch the values if they're non-uniform.
`e` is offline   Reply With Quote

Old   November 3, 2015, 04:37
Default
  #6
New Member
 
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 11
krushna is on a distinguished road
ok thank you
krushna is offline   Reply With Quote

Old   February 25, 2017, 17:50
Default
  #7
ZKR
New Member
 
Zakaria AOUCHETTE
Join Date: Feb 2017
Posts: 2
Rep Power: 0
ZKR is on a distinguished road
hi, i'm working with the same case, i have trouble with creating UDF, please how to create it?

Last edited by ZKR; March 6, 2017 at 19:12.
ZKR is offline   Reply With Quote

Reply


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
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
error while running the udf sugumaran Fluent UDF and Scheme Programming 0 August 26, 2010 16:29
ITERATION in udf slek Main CFD Forum 0 July 8, 2010 22:09
Statically Compiling OpenFOAM Issues herzfeldd OpenFOAM Installation 21 January 6, 2009 10:38
UDF to switch on energy equation after X iteration mat w FLUENT 6 December 5, 2005 08:35


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