Question about Silane udf usr_rates.f

Hello guys,

I’ve been trying to study the 2D silane pyrolisis code in detail and have some questions. It would be great if someone can help me with them. Thanks!

In the usr_rates.f file, line 92 to line 96 defined the concentration of SiH4, H2, and etc. to be 0:

! Initialize partial pressures and concentrations.
c_SiH4 = ZERO; p_SiH4 = ZERO;
c_SiH2 = ZERO; p_SiH2 = ZERO;
c_H2 = ZERO; p_H2 = ZERO;
c_Si2H6 = ZERO;

However, wasn’t this already set up in the initial condition in the .mfx file?

ic_x_g(2,1) = 0.0 !SiH4
ic_x_g(2,2) = 0.0 !SiH2
ic_x_g(2,3) = 0.0 !H2
ic_x_g(2,4) = 0.0 !Si2H6

Do we have to declare it again?

Thanks,
Jack

I’m pretty sure these are different variables, Jack. ic_x_g is an MFiX field variable and c_O2 etc are variables in your module

usr_rates.f:DOUBLE PRECISION c_O2 ! Oxygen concentration (mol/cm^3)

ic_mod.f:      DOUBLE PRECISION :: IC_X_g(DIMENSION_IC, DIM_N_g)

So they both need to be initialized, I believe.

I see. Thanks Charles. I also realized that the initialization in usr_rates.f happens every time loop, and the IC condition only happens once at the beginning of the simulation. Is that right?

That’s right, “IC” is Initial Condition, so that is applied only at t=0.

It’s not strictly necessary to initialize all the variables in usr_rates.f, especially if your code is simple. But I recommend it, it’s good practice. For example, in the Spouted Bed example,

  DOUBLE PRECISION c_O2        ! Oxygen

without setting it to 0, and further down:

      IF(Pg_CO .GT. ZERO .AND. Pg_O2 .GT. ZERO) THEN
! Compute gas phase concentrations of O2, CO, and water vapor.
         c_O2  = RO_g(IJK)*X_g(IJK,O2)/MW_g(O2)

If that IF statement is not executed, c_O2 is never set to any particular value at all, since it was not initialized to 0, it will be essentially random, leading to unpredictable/unreproducible behavior. (In this case it doesn’t really matter because c_O2 is not referenced outside that IF block. But it could be an issue in a different setting.)

– Charles

2 Likes