CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Hydrogen storage by metal hydride (https://www.cfd-online.com/Forums/fluent/129617-hydrogen-storage-metal-hydride.html)

longbk February 9, 2014 11:55

Hydrogen storage by metal hydride
 
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/kg-K */
#define K_m 1.6 /* Thermal conductivity in W/m-K */
#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.0e-8 /* Permeability */
#define DELTA_S 107.2 /* Entropy of Formation J/mol H2-K */
#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/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 */

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_ss-rho_s)*(1-por)*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_ss-rho_s)*(1-por);
}
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_ss-rho_s)*(1-por)*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_ss-rho_s)*(1-por);
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,

longbk February 9, 2014 20:06

Somebody help me !!

krushna October 23, 2015 02:02

udf for hydrogen storage based metal hydride
 
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,

longbk October 23, 2015 03:25

Quote:

Originally Posted by krushna (Post 569843)
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,

Dear krushna,
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

krushna October 23, 2015 04:32

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,

longbk October 23, 2015 11:14

Quote:

Originally Posted by krushna (Post 569877)
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,

Hi krushna,
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

krushna October 26, 2015 01:38

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

kxkhoo June 2, 2022 06:50

Quote:

Originally Posted by longbk (Post 569860)
Dear krushna,
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

Hi Long,

I'm trying your code for my simulation. I have some questions about your implementation, where may I contact you to discuss this?

AlexanderZ June 3, 2022 03:33

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

kxkhoo June 3, 2022 08:57

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 pressure-inlet 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^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 LaNi5 */
#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)
}
}

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("physical-time-step");
q_a= ((rho_ss-rho_s)*(1-por)*(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("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;

}

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.

kxkhoo June 3, 2022 09:00

https://imgur.com/a/yhLHT1T
The mesh of the domain for reference

https://imgur.com/a/yhLHT1T

daeyeobe April 25, 2023 06:05

Quote:

Originally Posted by kxkhoo (Post 829127)
Hi Long,

I'm trying your code for my simulation. I have some questions about your implementation, where may I contact you to discuss this?

Hi, have you sorted your problem? I want to ask some questions.

mopolot August 1, 2023 20:13

Quote:

Originally Posted by kxkhoo (Post 829187)
https://imgur.com/a/yhLHT1T
The mesh of the domain for reference

https://imgur.com/a/yhLHT1T

Hi,
Did you manage to get this work? If yes, what was the problem?


All times are GMT -4. The time now is 11:18.