Simulation of NH3 Decomposition (PFR)

General discussions about how to formulate a script for FlexPDE.

Simulation of NH3 Decomposition (PFR)

Postby Gunawan on Tue Oct 13, 2020 7:05 pm

Dear all

I'm Gunawan, I'm using Flex Pde 6 student version,
I try to run simulation based on the conditions below :

TITLE 'NH3 Decomposition Model'
! A <--> 0.5B + 1.5C ra

!Tube side:
{A : NH3
B : N2
C : H2}
!Shell side
{D : Argon
E : Hydrogen }

COORDINATES
Cartesian1 { default coordinate is 'X' }
SELECT
ngrid=1
errlim = 1e-3
penwidth = 3
VARIABLES
Fa (0.01)
Fe (0.01)

DEFINITIONS { parameter definitions }
Z = 1 !m
S = 314*10^(-4) ! m2
V = S*Z ! m3
l = 0 !m {axial position}
Delta= 6*10^(-6) !m
d = 0.01 ! m (tube diameter)
Rhob = 510 ! kg/m3
Epsilon = (4-2)/2 {mole amount change }
PtSweep = 1 ! atm (Shell side)
PtFeed = 36 ! atm (Tube side)
Tg = 873 !K
R = 8.314 ! J/molK
W = Rhob*V !kg
Betha = 0.674 {exponential constant}
k = 5.744*10^(19)*exp(-2.304*10^(5)/(R*Tg))! m3/kg.s
Keq = 1/10^(2250.322/Tg - 0.8534 -1.51049*l*log10(Tg) - 25.8987*10^(-5)*Tg + 14.8961*10^(-8)*Tg^2)
Fao = 2 ! mol/s
Fbo = 0 ! mol/s
Fco = 0 ! mol/s
Fdo = 2 ! mol/s
Feo = 0 ! mol/s
Xa = (Fao-Fa)/Fao
Fb = Fbo+(0.5*Fao*Xa)
Fc = Fco+(1.5*Fao*Xa)-Fe
Ft1 = Fa+Fb+Fc ! mol/s
Ft1o = Fao+Fbo+Fco ! mol/s
Qo = FT1o*R*Tg/PtFeed ! m3/s
tau = V/Qo !s
Q1 = Ft1*R*Tg/PtFeed ! m3
Fd= Fdo ! mol/s
Ft2 = Fd+Fe ! mol/s
Pao = (Fao*R*Tg)/Qo
Pbo = (Fbo*R*Tg)/Qo
Pco = (Fco*R*Tg)/Qo
Pdo = (Fdo*R*Tg)/Qo
Peo = (Feo*R*Tg)/Qo
Pa = Fa/Ft1*PtFeed ! atm
Pb = Fb/Ft1*PtFeed ! atm
Pc = Fc/Ft1*PtFeed ! atm
Pd = Fd/Ft2*PtSweep ! atm
Pe = Fe/Ft2*PtSweep ! atm
P1 = Fc/Ft1*PtFeed ! atm
P2 = Fe/Ft2*PtSweep ! atm
Qio = 3.2027*10^(-9)*exp(-6.38/R*Tg)
Qi = Qio*(P1^0.5 - P2^0.5)*S/Delta
ra = k*((Pa^2/Pc^3)^Betha- (Pb/Keq^2)*(Pc^3/Pa^2)^(1-Betha)) ! mol/kg.s {NH3 Decomposition rate}
rc = 1.5*ra {Hydrogen Production rate}
us = Q1/S ! m/s

EQUATIONS
Fa: dx(Fa+Qi) = S*Rhob*ra
Fe: dx(Fe + Qi) = 0
BOUNDARIES
region 1
start (0)
Point value (Fa) = Fao
Point value (Fe) = Feo
line to (Z)
point load(Fa) = 0
point load(Fe) = 0
PLOTS
elevation(Fa,Fe) from (0) to (Z) as "Flow rate (mol/s)" report (Fa) report (Fe) report (Xa) report (Qi) report (rc)
END


But this script can’t run, I don’t know how to solve it.
Please give me your suggestions or corrections.

Thanks in advanced
Gunawan
 
Posts: 3
Joined: Mon Oct 12, 2020 11:18 pm

Re: Simulation of NH3 Decomposition (PFR)

Postby moderator on Wed Oct 14, 2020 5:01 pm

First, I would suggest using FlexPDE7 Lite instead of version 6 student. Lite has replaced student and has similar restrictions.

FlexPDE reports the first obvious error, which is that one of your definitions evaluates to 0 and is causing a Divide By Zero error. In this kind of situation, with many layers deep in definitions, the best thing to do is start with just a small portion of your definitions and plot them, to make sure their values are reasonable (i.e. not 0 if you are going to divide by it later on).

When I do this, commenting out all definitions after P1 (which caused the divide by zero error in v7) I get an error message "A Scalar evaluation has encountered a Field value with no Location specified". You have defined Xa = (Fao-Fa)/Fao, but Fa is a variable, therefore a Field value. Fa is different at every point in the mesh. You need to tell FlexPDE where Fa should be evaluated. E.g. VAL(Fa, 0, 0) if you want it evaluated at (0,0).

You should do this same thing with all of your definitions to ensure you have provided expressions that are valid.
moderator
 
Posts: 865
Joined: Tue Jan 11, 2011 1:45 pm

Re: Simulation of NH3 Decomposition (PFR)

Postby Gunawan on Thu Oct 15, 2020 2:08 am

Dear Moderator

Thank you for your response, but I still don't understand how to make
evaluation of `Fa` in to the script.
Could you tell me more detail about that ? or could you give an example
script ?

Thank you for your attention
Gunawan
 
Posts: 3
Joined: Mon Oct 12, 2020 11:18 pm

Re: Simulation of NH3 Decomposition (PFR)

Postby moderator on Thu Oct 15, 2020 1:07 pm

See VAL in the Help index.

A variable has a different value at every position in the mesh (a field value). A simple definition has one value everywhere (scalar value). So in order to use a variable's value in a definition, you need to tell FlexPDE at which point in the mesh you want to take the value. This is the situation with your definition of Xa = (Fao-Fa)/Fao. Xa will be a scalar value, but FlexPDE doesn't know where to evaluate the field value Fa unless you tell it. Using VAL or EVAL.

If you intend Xa to be a field value then you would make it a variable.
moderator
 
Posts: 865
Joined: Tue Jan 11, 2011 1:45 pm

Re: Simulation of NH3 Decomposition (PFR)

Postby moderator on Thu Oct 15, 2020 1:19 pm

Let me clarify. A definition can be a field value without making it a variable, but you have stated an expression where you are subtracting a field value from a scalar value. That won't work unless you tell FlexPDE where to evaluate the field value.
moderator
 
Posts: 865
Joined: Tue Jan 11, 2011 1:45 pm

Re: Simulation of NH3 Decomposition (PFR)

Postby Gunawan on Fri Oct 16, 2020 5:58 am

Dear Moderator

Thank you very much for your explanation.
Then I will try to put val or eval into my script.

Regards
Gunawan
Gunawan
 
Posts: 3
Joined: Mon Oct 12, 2020 11:18 pm


Return to FlexPDE Discussion

Who is online

Users browsing this forum: No registered users and 10 guests

cron