
[Sponsors] 
February 9, 2014, 11:55 
Hydrogen storage by metal hydride

#1 
New Member
Long Nguyen
Join Date: Sep 2013
Posts: 11
Rep Power: 12 
Dear all,
I have been conducting the project related to modeling the hydrogen storage 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. The amount of absorbed hydrogen is represented by "sink term" which is covered in my UDF. Here is my UDF code: #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 500000.0 /* Inlet pressure in pascals */ #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 8394.0 /* Density in kg/m^3 */ #define Cp_m 419.0 /* Sp heat in J/kgK */ #define K_m 1.6 /* Thermal conductivity in W/mK */ #define por 0.5 /* Porosity */ #define NA 6.0 /* Number of atoms in Mischmetal alloy [MmNi4.6Al0.4] */ #define M_m 434.0 /* molecular weight of mischmetal alloy [MmNi4.6Al0.4] in g/mol; [LaNi5 = 434] */ #define rho_ss 8394.0 /* Density of MH @ saturation kg/m^3 */ #define rho_s 8280.0 /* Density of MH kg/m^3 */ #define E_a 21179.6 /* Activation energy in J/mol H2 */ #define per 1.0e8 /* Permeability */ #define DELTA_S 107.2 /* Entropy of Formation J/mol H2K */ #define DELTA_H 30780.0 /* Enthalpy of Formation J/mol H2 */ #define wt 0.013 /* Hydrogen weight Storage Capacity 1.3% of Mischmetal */ #define A_vantHoff 17.738 #define B_vantHoff 3704.6 /* Properties of Hydrogen */ #define K_g 0.127 /* Thermal Conductivity in W/mK */ #define Cp_g 14283 /* Sp heat in J/kgK */ #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/molK */ #define k_a 59.187 /* Reaction Constant for absorption in (sec)^1 */ real x_t_temporary; real rate_temporary; real heat_rate_temporary; ////////////////////////////////////////////////////////////////////////////////////////////////// DEFINE_INIT(my_init_fuc,d) { cell_t c; Thread *t; thread_loop_c(t,d) { begin_c_loop_all(c,t) { C_UDMI(c,t,0) = x_i; C_UDMI(c,t,1) = 0.0; C_UDMI(c,t,2) = 0.0; } end_c_loop_all(c,t) } } DEFINE_SOURCE(mass_source_edited1,c,t,dS,eqn) { real tp; real rate; real P_eq; real cond; int curr_N_timestep; real curr_timestep_size; real curr_rho; real x_t; real dxdt; real P_g = C_P(c,t); real vol = C_VOLUME(c,t); tp = C_T(c,t); P_eq = pow(10,5)*exp((DELTA_S/R_u)(DELTA_H/(R_u*tp))); cond = P_g/P_eq; curr_N_timestep = N_TIME; //Number of timestep curr_timestep_size = CURRENT_TIMESTEP; //current timestep size if(cond > 1.0) { x_t = 1.0  exp((1)*(rho_ssrho_s)*(1por)*k_a*exp(E_a/(R_u*tp))*((P_g/P_eq)1)*CURRENT_TIME); dxdt = (x_t  C_UDMI(c,t,0))/curr_timestep_size; if(CURRENT_TIME > 0) { rate = dxdt*(rho_ssrho_s)*(1por); } dS[eqn] = 0.0; } else { rate = 0.0; dS[eqn] = 0.0; } x_t_temporary = x_t; rate_temporary = rate; return rate; } DEFINE_SOURCE(heat_source_edited1,c,t,dS,eqn) { real heat_rate; real tp; real rate; real P_eq; real cond; int curr_N_timestep; real curr_timestep_size; real x_t; real dxdt; real P_g = C_P(c,t); real vol = C_VOLUME(c,t); tp = C_T(c,t); P_eq = pow(10,5)*exp((DELTA_S/R_u)(DELTA_H/(R_u*tp))); cond = P_g/P_eq; curr_N_timestep = N_TIME; curr_timestep_size = CURRENT_TIMESTEP; if(cond > 1.0) { x_t = 1.0  exp((1)*(rho_ssrho_s)*(1por)*k_a*exp(E_a/(R_u*tp))*((P_g/P_eq)1)*CURRENT_TIME); dxdt = (x_t  C_UDMI(c,t,0))/curr_timestep_size; if(CURRENT_TIME > 0) { rate = dxdt*(rho_ssrho_s)*(1por); heat_rate = (1000.0*DELTA_H/M_g)*(rate); } dS[eqn] = 0.0; } else { heat_rate = 0.0; dS[eqn] = 0.0; } heat_rate_temporary = heat_rate; return heat_rate; } DEFINE_EXECUTE_AT_END(ThisRunsAtEndOfTimestep) { Domain *d; Thread *t; cell_t c; d = Get_Domain(1); thread_loop_c(t,d) { if(FLUID_THREAD_P(t)) { begin_c_loop(c,t) { C_UDMI(c,t,0) = x_t_temporary; C_UDMI(c,t,1) = rate_temporary; C_UDMI(c,t,2) = heat_rate_temporary; } end_c_loop(c,t) } } } I tried to run this UDF many times but it seems not working... Anyone could help me? Regards, 

February 9, 2014, 20:06 

#2 
New Member
Long Nguyen
Join Date: Sep 2013
Posts: 11
Rep Power: 12 
Somebody help me !!


October 23, 2015, 02:02 
udf for hydrogen storage based metal hydride

#3 
New Member
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 10 
Dear longbk,
I am new user of CFD online. I am working on hydrogen storage based on metal hydride for my M.Tech. Dissertation, help me in that. in your UDF you model heat_genration and hydrogen_concentration w.r.t time on porous model. my question is in fluent you model the porous zone ?why? thanking you. Regards, 

October 23, 2015, 03:25 

#4  
New Member
Long Nguyen
Join Date: Sep 2013
Posts: 11
Rep Power: 12 
Quote:
Actually, I finished this project at the end of 2014. For your inquiry, the material used for hydrogen absorption in my model is LaNi5  such a porous powder. When hydrogen is injected into the reactor filled with LaNi5 powder, the absorption occurs. In details, this process includes many steps, but we supposed that the chemical reaction step is dominant. I hope my answer could meet your desire. If you want to ask more, you can contact me through my facebook: https://www.facebook.com/long.nguyen.182940 Rgds, Long Nguyen 

October 23, 2015, 04:32 

#5 
New Member
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 10 
Dear Long,
thank you for reply. i am working on miscmetal MmNi4.6Al0.4 using ANSYS Fluent so i modeled coolant zone(Fluid) and porous zone(Fluid) only and UDF apply on porous zone. is that right process. can i model porous zone as solid? regards, 

October 23, 2015, 11:14 

#6  
New Member
Long Nguyen
Join Date: Sep 2013
Posts: 11
Rep Power: 12 
Quote:
Yes, that's right. As I know, Solid zone does not have any porous option. If you set the cell zone condition as a solid zone, it means that there is only solid in your cell zone (porosity equals zero). You should take a look at this link http://imechanica.org/files/fluent_1...conditions.pdf Rgds, Long Nguyen 

October 26, 2015, 01:38 

#7 
New Member
krushna shekde
Join Date: Oct 2015
Posts: 9
Rep Power: 10 
Dear Long Nguyen,
Thanks for your reply, now i am set my problem in fluent but i don't know how to calculate Time Step and No. of Iteration my absorption time is 375s please help me for this also send me calculation methods. regards, Krushna 

June 2, 2022, 06:50 

#8  
New Member
kxkhoo
Join Date: Jun 2022
Posts: 3
Rep Power: 3 
Quote:
I'm trying your code for my simulation. I have some questions about your implementation, where may I contact you to discuss this? 

June 3, 2022, 03:33 

#9 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 
you may try to ask your questions here:
describe the case you want to simulate, show code you are using, attach compilation log, describe problems you've faced in details
__________________
best regards ****************************** press LIKE if this message was helpful 

June 3, 2022, 08:57 

#10 
New Member
kxkhoo
Join Date: Jun 2022
Posts: 3
Rep Power: 3 
My simulation is very similar to Long's, I'm trying to simulate a 2D axisymmetric metal hydride reactor where the gaseous hydrogen enters the domain with a pressureinlet boundary condition. Inside the domain there is coil heat exchanger with a static temperature boundary condition set to 293K.
My UDF compiles and runs with no error but the simulation outputs no results. There is no temperature contour, no reaction fraction the residuals for the energy is almost constant when the solution is being iterated. This is my UDF code: #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 143000 /* Inlet pressure in pascals */ #define h_o 1000 /* Heat transfer coeff in W/m^2K */ #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 LaNi5 */ #define rho_m 8400 /* Density in kg/m^3 */ #define C_pm 419 /* Sp heat in J/kgK */ #define K_m 3.0728 /* Thermal conductivity in W/mK */ #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 1e8 /* Permeability */ #define DELTA_S 107.2 /* Entropy of Formation J/mol H2K */ #define DELTA_H 28000 /* Enthalpy of Formation J/mol H2 */ /* Properties of Hydrogen */ #define K_g 0.1272 /* Thermal Conductivity in W/mK */ #define C_pg 14283 /* Sp heat in J/kgK */ #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/molK */ #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) } } DEFINE_PROFILE(pressure_inlet, t, i) /*Linear pressure inlet boundary condition*/ { real pressure_profile; face_t f; real time = CURRENT_TIME; /*Time variable*/ begin_f_loop(f, t) { if (time < 100) { pressure_profile = P_i + (6570 * time); } else { pressure_profile = 800000; } F_PROFILE(f, t, i) = pressure_profile; } end_f_loop(f, 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("physicaltimestep"); q_a= ((rho_ssrho_s)*(1por)*(DELTA_H/M_g)*(C_UDSI(c,t,0)C_UDSI_M1(c,t,0))/(physical_dt*1000)); 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("physicaltimestep"); c_a= (rho_ssrho_s)*(1por)*(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("physicaltimestep"); 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; } The pressure inlet profile is just to model an initial pressure of 0.143MPa which increases linearly for a 100s and eventually becomes constant at 0.8MPa. I'm not sure if the code for the heat/mass source equations are entirely correct so if anyone is more of an expert on this please help point out my mistakes. 

June 3, 2022, 09:00 

#11 
New Member
kxkhoo
Join Date: Jun 2022
Posts: 3
Rep Power: 3 
Last edited by kxkhoo; June 3, 2022 at 09:01. Reason: linking image 

April 25, 2023, 06:05 

#12 
New Member
Lee
Join Date: Apr 2023
Posts: 2
Rep Power: 0 

August 1, 2023, 20:13 

#13  
New Member
Join Date: Mar 2019
Posts: 1
Rep Power: 0 
Quote:
Did you manage to get this work? If yes, what was the problem? 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF for Hydrogen Storage in Porous Media  er.mkumar  Fluent UDF and Scheme Programming  11  February 18, 2023 15:44 
Hydrogen Storage in Porous Media  er.mkumar  FLUENT  1  August 17, 2013 08:30 
Need Help Simulating Hydrogen Storage in Metal Hydride  jehadyam  CFD Freelancers  0  January 29, 2013 16:41 
Liquid Metal Combustion in an enclosed geometry  snh  FLUENT  0  September 11, 2012 02:50 
Hydrogen storage on Fluent  karl fisher  FLUENT  0  September 3, 2010 04:23 