Changes between Version 3 and Version 4 of ThermalConduction


Ignore:
Timestamp:
01/31/14 10:42:37 (11 years ago)
Author:
Baowei Liu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ThermalConduction

    v3 v4  
    4040}}}
    4141
    42 
    43 
     42== Normal CK scheme ==
     43We can identify the left and right coefficients as
     44
     45[[latex($A_\pm = -\frac{\kappa \Delta t}{\Delta x^2}T_{i\pm1}^{j^n} $)]]
     46
     47and the center coefficient as
     48
     49[[latex($A_0 =  2 \frac{\kappa \Delta t}{ \Delta x^2}T_{i}^{j^n}  + \rho c_v$)]]
     50
     51and the RHS left and right contributions
     52
     53[[latex($B_\pm = -\frac{n \kappa \Delta t}{ \left ( n+ 1 \right ) \Delta x^2} T_{i\pm 1}^{j^{n+1}}$)]]
     54
     55and the RHS center term contribution as
     56
     57[[latex($B_0 = 2 \frac{n \kappa \Delta t}{ \left ( n+ 1 \right ) \Delta x^2} T_{i}^{j^{n+1}} + \rho c_v T_i^j$)]]
     58
     59and finally in the code the values for [[latex($A$)]] and [[latex($B$)]] are negated:
     60
     61{{{
     62    kx = kappa1*dt_diff/(dx**2)
     63    CALL getTemp(Info,i,j,k,T)
     64    stencil_fixed(0) = -2.0*REAL(nDim,8)*kx*T(0)**ndiff
     65    DO l = 1, 2*nDim
     66       stencil_fixed(l) = kx*T(l)**ndiff
     67    END DO
     68    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)
     69    stencil_fixed(0) = stencil_fixed(0) - gamma7*Info%q(i,j,k,1)
     70}}}
     71
     72also note that the equation is multipled by the mean molecular weight... which is why [[latex($c_v \rightarrow c_v \times  \chi = \gamma_7$)]] and [[latex($\kappa \rightarrow \kappa \times \chi = \kappa_1$)]]
     73
     74
     75== a note about flux boundary conditions ==
     76If we have a specified flux at a boundary - then the equation is just
     77
     78[[latex($\rho c_v \frac{\partial T}{\partial t} = -\nabla Q $)]]
     79
     80which can be discretized as
     81
     82[[latex($\rho_i c_v \left (T_i^{j+1}-T_i^j \right ) = \frac{-\Delta t}{\Delta x} \left ( Q_{i+1/2} - Q_{i-1/2} \right ) $)]]
     83
     84which leads to a center coefficient of
     85
     86[[latex($A_0 = \rho c_v$)]]
     87
     88and a left right source term contribution
     89
     90[[latex($B_\pm = \mp \frac{\Delta t}{\Delta x} Q_{i\pm 1/2}$)]]
     91
     92=== Now if the left boundary is a flux boundary, but the right side is normal, then we have to adjust the coefficients ===
     93
     94[[latex($A_+ = -\frac{\kappa \Delta t}{\Delta x^2}T_{i+1}^{j^n} $)]]
     95
     96[[latex($A_- = 0 $)]]
     97
     98and the center coefficient as
     99
     100[[latex($A_0 =  \frac{2\kappa \Delta t}{ \Delta x^2}T_{i}^{j^n}  + \rho c_v$)]]
     101
     102and the RHS left and right contributions
     103
     104[[latex($B_+ = -\frac{n \kappa \Delta t}{ 2  \left ( n+ 1 \right ) \Delta x^2} T_{i+1}^{j^{n+1}}$)]]
     105
     106[[latex($B_-  =  \frac{\Delta t}{\Delta x} Q_{i-1/2}$)]]
     107
     108and the RHS center term contribution as
     109
     110[[latex($B_0 = \frac{2n \kappa \Delta t}{ \left ( n+ 1 \right ) \Delta x^2} T_{i}^{j^{n+1}} + \rho c_v T_i^j$)]]
     111
     112
     113Of course - remembering that in AstroBEAR everything is negated...
     114
     115This is accomplished by
     116{{{
     117     source = source + (ndiff/(ndiff+1.0))*(T(0)*kx*T(0)**ndiff)
     118     source = source - (ndiff/(ndiff+1.0))*(T(p)*kx*T(p)**ndiff)
     119     stencil_fixed(0)=stencil_fixed(0)+kx*T(0)**ndiff
     120     stencil_fixed(p)=0.0
     121     source = source - flb*dt_diff/dx
     122}}}
     123
     124== If the right boundary is a zero-slope boundary, we have ==
     125[[latex($T_{i+1}^{j+1}=T_{i}^{j+1}$)]]
     126and
     127[[latex($T_{i+1}^{j}=T_{i}^{j}$)]]
     128
     129So now on the right boundary, the equation becomes
     130{{{
     131#!latex
     132\setcounter{equation} 4
     133\begin{eqnarray}
     134\rho_i c_v \left ( T_i^{j+1}-T_i^j \right ) & =  & \frac{\kappa \Delta t}{\Delta x^2}\left (- T_{i}^{j^n}  T_{i}^{j+1} + T_{i-1}^{j^n}  T_{i-1}^{j+1} \right ) \\
     135 & - & \frac{n\kappa \Delta t}{ \left ( n+ 1 \right ) \Delta x^2} \left (-  T_{i}^{j^{n+1}} + T_{i-1}^{j^{n+1}} \right ) 
     136\end{eqnarray}
     137}}}
     138And the coeeficients becomes
     139
     140[[latex($A_+ = 0 $)]]
     141
     142[[latex($A_-=-\frac{\kappa \Delta t}{\Delta x^2}T_{i-1}^{j^n} $)]]
     143
     144[[latex($A_0=\frac{\kappa \Delta t}{\Delta x^2}T_{i}^{j^n}+ \rho c_v$)]]
     145
     146and the RHS left and right contributions
     147
     148[[latex($B_+=0 $)]]
     149
     150[[latex($B_-=-\frac{n \kappa \Delta t}{ \left ( n+ 1 \right ) \Delta x^2} T_{i\pm 1}^{j^{n+1}}$)]]
     151
     152[[latex($B_0=\frac{n \kappa \Delta t}{ \left ( n+ 1 \right ) \Delta x^2} T_{i}^{j^n}+\rho C_vT_{i}^{j}$)]]
     153
     154Again in AstroBEAR everything is negated
     155
     156This is accomplished by
     157
     158{{{
     159stencil_fixed(0) =stencil_fixed(0)+kx*info%q(iq(1),iq(2),iq(3),itemp)**ndiff ! store the stencil value to temp
     160ource = 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))
     161stencil_fixed(p) = 0.0 ! zero out the stencil
     162}}}
     163
     164== 2nd order in Time CK scheme ==
    44165Now to make the scheme 2nd order in time we can set [[latex($T_i^{j+1}=\frac{T_i^{j}+T_i^{j+1}}{2}$)]] and we get
    45166
     
    154275[[latex($A_-=-\frac{\kappa \Delta t}{2 \Delta x^2}T_{i-1}^{j^n} $)]]
    155276
    156 [[latex($A_0=\frac{\kappa \Delta t}{2 \Delta x^2}T_{i}^{j^n}T_{i}^{j+1}+ \rho c_v$)]]
     277[[latex($A_0=\frac{\kappa \Delta t}{2 \Delta x^2}T_{i}^{j^n}+ \rho c_v$)]]
    157278
    158279and the RHS left and right contributions