| 42 | | |
| 43 | | |
| | 42 | == Normal CK scheme == |
| | 43 | We 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 | |
| | 47 | and 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 | |
| | 51 | and 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 | |
| | 55 | and 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 | |
| | 59 | and 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 | |
| | 72 | also 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 == |
| | 76 | If 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 | |
| | 80 | which 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 | |
| | 84 | which leads to a center coefficient of |
| | 85 | |
| | 86 | [[latex($A_0 = \rho c_v$)]] |
| | 87 | |
| | 88 | and 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 | |
| | 98 | and 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 | |
| | 102 | and 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 | |
| | 108 | and 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 | |
| | 113 | Of course - remembering that in AstroBEAR everything is negated... |
| | 114 | |
| | 115 | This 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}$)]] |
| | 126 | and |
| | 127 | [[latex($T_{i+1}^{j}=T_{i}^{j}$)]] |
| | 128 | |
| | 129 | So 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 | }}} |
| | 138 | And 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 | |
| | 146 | and 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 | |
| | 154 | Again in AstroBEAR everything is negated |
| | 155 | |
| | 156 | This is accomplished by |
| | 157 | |
| | 158 | {{{ |
| | 159 | stencil_fixed(0) =stencil_fixed(0)+kx*info%q(iq(1),iq(2),iq(3),itemp)**ndiff ! store the stencil value to temp |
| | 160 | 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)) |
| | 161 | stencil_fixed(p) = 0.0 ! zero out the stencil |
| | 162 | }}} |
| | 163 | |
| | 164 | == 2nd order in Time CK scheme == |