wiki:ThermalConduction

Version 5 (modified by Baowei Liu, 10 years ago) ( diff )

Thermal Conduction Solver

!!Update 5.22.2015

In the newer version of the code, the unit of temperature in the code or Info%q(iTemp) was changed to Kelvin from C.U.. However the following equations and source code keep the same except the term "gamma7*rho" has to be changed to function getdEdT() which gives C.U energy/Kelvin.. and no gamma7 appears…

Before temperature unit was changed to Kelvin

The equation we are trying to solve in AstroBEAR is

which can be "Laplacetasized" as

For backward euler we evaluate the RHS at time although we still have to linearize

So we can Taylor expand about

now if we substitute that back into the discretized form of equation 2 we get

Normal CK scheme

We can identify the left and right coefficients as

and the center coefficient as

and the RHS left and right contributions

and the RHS center term contribution as

and finally in the code the values for and are negated:

    kx = kappa1*dt_diff/(dx**2)
    CALL getTemp(Info,i,j,k,T)
    stencil_fixed(0) = -2.0*REAL(nDim,8)*kx*T(0)**ndiff
    DO l = 1, 2*nDim
       stencil_fixed(l) = kx*T(l)**ndiff
    END DO
    source = ((ndiff)/(ndiff+1.0))*dot_product(T(0:2*nDim),stencil_fixed(0:2*nDim)) - T(0)*gamma7*Info%q(i,j,k,1)
    stencil_fixed(0) = stencil_fixed(0) - gamma7*Info%q(i,j,k,1)

also note that the equation is multipled by the mean molecular weight… which is why and

a note about flux boundary conditions

If we have a specified flux at a boundary - then the equation is just

which can be discretized as

which leads to a center coefficient of

and a left right source term contribution

Now if the left boundary is a flux boundary, but the right side is normal, then we have to adjust the coefficients

and the center coefficient as

and the RHS left and right contributions

and the RHS center term contribution as

Of course - remembering that in AstroBEAR everything is negated…

This is accomplished by

     source = source + (ndiff/(ndiff+1.0))*(T(0)*kx*T(0)**ndiff)
     source = source - (ndiff/(ndiff+1.0))*(T(p)*kx*T(p)**ndiff)
     stencil_fixed(0)=stencil_fixed(0)+kx*T(0)**ndiff
     stencil_fixed(p)=0.0
     source = source - flb*dt_diff/dx

If the right boundary is a zero-slope boundary, we have

and

So now on the right boundary, the equation becomes

And the coeeficients becomes

and the RHS left and right contributions

Again in AstroBEAR everything is negated

This is accomplished by

stencil_fixed(0) =stencil_fixed(0)+kx*info%q(iq(1),iq(2),iq(3),itemp)**ndiff ! store the stencil value to temp
ource = source -(ndiff)/(ndiff+1.0)*(stencil_fixed(p)*info%q(ip(1),ip(2),ip(3),itemp)+kx*info%q(iq(1),iq(2),iq(3),itemp)**(ndiff+1))
stencil_fixed(p) = 0.0 ! zero out the stencil

2nd order in Time CK scheme

Now to make the scheme 2nd order in time we can set and we get

Where we can identify the left and right coefficients as

and the center coefficient as

and the RHS left and right contributions

and the RHS center term contribution as

and finally in the code the values for and are negated:

    kx = (0.5*kappa1*dt_diff/(dx**2))
    CALL getTemp(Info,i,j,k,T)
    stencil_fixed(0) = -2.0*REAL(nDim,8)*kx*T(0)**ndiff
    DO l = 1, 2*nDim
       stencil_fixed(l) = kx*T(l)**ndiff
    END DO  
    source = ((ndiff-1.0)/(ndiff+1.0))*dot_product(T(0:2*nDim),stencil_fixed(0:2*nDim)) - T(0)*gamma7*Info%q(i,j,k,1)
    stencil_fixed(0) = stencil_fixed(0) - gamma7*Info%q(i,j,k,1)

also note that the equation is multipled by the mean molecular weight… which is why and

a note about flux boundary conditions

If we have a specified flux at a boundary - then the equation is just

which can be discretized as

which leads to a center coefficient of

and a left right source term contribution

Now if the left boundary is a flux boundary, but the right side is normal, then we have to adjust the coefficients

and the center coefficient as

and the RHS left and right contributions

and the RHS center term contribution as

Of course - remembering that in AstroBEAR everything is negated…

This is accomplished by

     source = source + ((ndiff-1.0)/(ndiff+1.0))*(T(0)*kx*T(0)**ndiff)
     source = source - ((ndiff-1.0)/(ndiff+1.0))*(T(p)*kx*T(p)**ndiff)
     stencil_fixed(0)=stencil_fixed(0)+kx*T(0)**ndiff
     stencil_fixed(p)=0.0
     source = source - flb*dt_diff/dx

If the right boundary is a zero-slope boundary, we have

and

So now on the right boundary, the equation becomes

And the coeeficients becomes

and the RHS left and right contributions

Again in AstroBEAR everything is negated

This is accomplished by

stencil_fixed(0) =stencil_fixed(0)+kx*info%q(iq(1),iq(2),iq(3),itemp)**ndiff ! store the stencil value to temp
!source = source -((ndiff-1.0)/(ndiff+1.0))*(stencil_fixed(p)*info%q(ip(1),ip(2),ip(3),itemp)-kx*info%q(iq(1),iq(2),iq(3),itemp)**(ndiff+1))
source = source -((ndiff-1.0)/(ndiff+1.0))*(stencil_fixed(p)*info%q(ip(1),ip(2),ip(3),itemp)+kx*info%q(iq(1),iq(2),iq(3),itemp)**(ndiff+1))
stencil_fixed(p) = 0.0 ! zero out the stencil

where the commented out line is the old-version which got the sign before the "kx" wrong.

Limiting case

In the limit of with a flux from the left boundary:

our equation becomes

and the total energy

or

Note: See TracWiki for help on using the wiki.