Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Finite difference method help (bvp)

  1. Jan 23, 2010 #1
    Hi, I'm currently writing a code to solve a steady-state boundary problem across multiple layers of a system. The system involves diffusion-reaction of various species in a porous medium. I am simply using central finite differences to model this setup, which says that essentially -div*J+Q = 0. (I take J to be mole flux of a species and Q to be the rate of creation of that species per volume). It is one dimensional, so basically, my equations typically look something like this:

    [tex] J = vC - D_i\frac{dc}{dx} [/tex]

    [tex] -\frac{dJ}{dx} + Q_i = 0 [/tex]

    [tex]-v\frac{dC}{dx}+D_i\frac{d^2C}{dx^2}+Q_i=0[/tex]

    or, in terms of central differences

    [tex]-v\frac{C_{j+1}-C_{j-1}}{h_i}+D_i\frac{C_{j+1}-2C_{j}+C_{j-1}}{h_i ^2} +Q_i = 0 [/tex]

    where the i's designate which phase/region I am in. So I have written this set of equations in various regions of my problem. At the interfaces of these regions, I know I am supposed to say that the fluxes and concentrations of the species are continuous. Take the interface in the following example to be located at some point j, and let phase 1 lie to the left and phase 2 lie to the right. I want to write something like this at point j:

    [tex]A(J_{j-1/2} - J_{j+1/2}) + Q_{overall}dV = 0[/tex]

    So here is what I am thinking for the centered finite differences:

    [tex](v\frac{C_j+C_{j-1}}{2}-D_{i=1}\frac{C_j-C_{j-1}}{h_{i=1}})
    -(v\frac{C_{j+1}+C_{j}}{2}-D_{i=2}\frac{C_{j+1}-C_{j}}{h_{i=2}})+Q_{i=1}\frac{h_{i=1}}{2}+Q_{i=2}\frac{h_{i=2}}{2}=0[/tex]

    Again, Q is rate of rxn per unit volume, so I am weighing according to the step size h between phases. I'd just like to check if this is the correct way of imposing the continuity of fluxes between phases. I bring this up because a code I am looking at from a former grad student in my research group has somewhat different looking fd's. He neglected the terms involving the v's, but his other terms still look different:

    [tex](D_{i=1}\frac{C_j-C_{j-1}}{h_{i=1} ^2})
    -(D_{i=2}\frac{C_{j+1}-C_{j}}{h_{i=2} ^2})+\frac{Q_{i=1}+Q_{i=2}}{2}=0[/tex]

    the two h's are not necessarily equal, so I am not clear about this way of doing it and how it makes sense. If the two h's -are- equal, then my way reduces to his way. If my way is wrong, could someone please explain why? Thanks. I will be on for a while so if anything in my post needs clarification just ask.
     
    Last edited: Jan 23, 2010
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Finite difference method help (bvp)
Loading...