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

metal hydride reactor simulation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 28, 2017, 03:28
Default metal hydride reactor simulation
  #1
New Member
 
suraj godase
Join Date: Jul 2017
Location: Maharashtra, India
Posts: 4
Rep Power: 9
srj007 is on a distinguished road
Dear all,
i am going to simulate tube in tube type simple metal hydride reactor tank in ANSYS FLUENT 15.I am using udf as follows, i got error as
"fatal signal (segmentation fault)''
i am using LaNi5 alloy, please help me for removing the error occurred.

#include"udf.h"

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

/* Properties of Metal Alloy [LaNi5] */
#define rho_m 8200 /* Density in kg/m^3 */
#define Cp_m 419 /* Sp heat in J/kg-K */
#define K_m 1.2 /* Thermal conductivity in W/m-K */
#define por 0.5 /* Porosity */
#define NA 6 /* Number of atoms in Mischmetal alloy */
#define M_m 434 /* molecular weight of mischmetal alloy in g/mol */
#define rho_ss 8323 /* Density of MH @ saturation kg/m^3 */
#define rho_s 8200 /* Density of MH kg/m^3 */
#define E_a 21170 /* Activation energy in J/mol H2 */
#define per 1e-8 /* Permeability */
#define DELTA_S 108 /* Entropy of Formation J/mol H2-K */
#define DELTA_H 28000 /* Enthalpy of Formation J/mol H2 */
#define wt 0.015 /* Hydrogen weight Storage Capacity 1.5% of Mischmetal */

/* Properties of Hydrogen */
#define K_g 0.127 /* Thermal Conductivity in W/m-K */
#define Cp_g 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 g/mol */

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

/* Initialization of cell property of scalar i.e. 'x' */
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)
}
}

/* Energy Equation HEAT SOURCE term */
DEFINE_SOURCE(heat_generation,c,t,dS,eqn)
{
real c_a;
real q_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;
q_a= ((1000*c_a*(DELTA_H/M_g)));
dS[eqn]=0;
C_UDMI(c,t,0)=q_a; /* Memory allocation for storing 'heat generation' */
return q_a;

}

/* UDS for solving Kinetic equation i.e. 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 SOURCE term */
/* 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.718,((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(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)); /* Derivative of SOURCE w.r.t. DEPENDENT variable */
}
else
{
rate = 0;
dS[eqn] = 0;
}

C_UDMI(c,t,2) = rate;
return rate;

}
srj007 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
Hydrogen storage by metal hydride longbk FLUENT 12 August 1, 2023 21:13
Simulating liquid metal in Fluent Shamoon Jamshed FLUENT 10 April 30, 2016 09:01
simulating liquid metal in Fluent Shamoon Jamshed FLUENT 0 October 11, 2014 12:15
Need Help Simulating Hydrogen Storage in Metal Hydride jehadyam CFD Freelancers 0 January 29, 2013 17:41
Liquid Metal Combustion in an enclosed geometry snh FLUENT 0 September 11, 2012 03:50


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