| 136 | == If the right boundary is a zero-slope boundary, we have == |
| 137 | [[latex($T_{i+1}^{j+1}=T_{i}^{j+1}$)]] |
| 138 | and |
| 139 | [[latex($T_{i+1}^{j}=T_{i}^{j}$)]] |
| 140 | |
| 141 | So now on the right boundary, the equation becomes |
| 142 | {{{ |
| 143 | #!latex |
| 144 | \setcounter{equation} 4 |
| 145 | \begin{eqnarray} |
| 146 | \rho_i c_v \left ( T_i^{j+1}-T_i^j \right ) & = & \frac{\kappa \Delta t}{2 \Delta x^2}\left (- T_{i}^{j^n} T_{i}^{j+1} + T_{i-1}^{j^n} T_{i-1}^{j+1} \right ) \\ |
| 147 | & - & \frac{\left (n - 1 \right ) \kappa \Delta t}{ 2 \left ( n+ 1 \right ) \Delta x^2} \left (- T_{i}^{j^{n+1}} + T_{i-1}^{j^{n+1}} \right ) |
| 148 | \end{eqnarray} |
| 149 | }}} |
| 150 | And the coeeficients becomes |
| 151 | |
| 152 | [[latex($A_+ = 0 $)]] |
| 153 | |
| 154 | [[latex($A_-=-\frac{\kappa \Delta t}{2 \Delta x^2}T_{i-1}^{j^n} $)]] |
| 155 | |
| 156 | [[latex($A_0=\frac{\kappa \Delta t}{2 \Delta x^2}T_{i}^{j^n}T_{i}^{j+1}+ \rho c_v$)]] |
| 157 | |
| 158 | and the RHS left and right contributions |
| 159 | |
| 160 | [[latex($B_+=0 $)]] |
| 161 | |
| 162 | [[latex($B_-=-\frac{\left (n - 1 \right ) \kappa \Delta t}{ 2 \left ( n+ 1 \right ) \Delta x^2} T_{i\pm 1}^{j^{n+1}}$)]] |
| 163 | |
| 164 | [[latex($B_0=\frac{\left (n - 1 \right ) \kappa \Delta t}{ 2 \left ( n+ 1 \right ) \Delta x^2} T_{i}^{j^n}+\rho C_vT_{i}^{j}$)]] |
| 165 | |
| 166 | Again in AstroBEAR everything is negated |
| 167 | |
| 168 | This is accomplished by |
| 169 | |
| 170 | {{{ |
| 171 | stencil_fixed(0) =stencil_fixed(0)+kx*info%q(iq(1),iq(2),iq(3),itemp)**ndiff ! store the stencil value to temp |
| 172 | !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)) |
| 173 | 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)) |
| 174 | stencil_fixed(p) = 0.0 ! zero out the stencil |
| 175 | }}} |
| 176 | |
| 177 | where the commented out line is the old-version which got the sign before the "kx" wrong. |
| 178 | |