| | 67 | |
| | 68 | == a note about flux boundary conditions == |
| | 69 | If we have a specified flux at a boundary - then the equation is just |
| | 70 | |
| | 71 | [[latex($\rho c_v \frac{\partial T}{\partial t} = -\nabla Q $)]] |
| | 72 | |
| | 73 | which can be discretized as |
| | 74 | |
| | 75 | [[latex($\rho_i c_v \left (T_i^{j+1}-T_i^j \right ) = -Q_{i+1/2} + Q_{i-1/2} $)]] |
| | 76 | |
| | 77 | which leads to a center coefficient of |
| | 78 | |
| | 79 | [[latex($A_0 = \rho c_v$)]] |
| | 80 | |
| | 81 | and a left right source term contribution |
| | 82 | |
| | 83 | [[latex($B_\pm = \mp \frac{\Delta t}{\Delta x} Q_{i\pm 1/2}$)]] |
| | 84 | |
| | 85 | and if the left boundary is a flux boundary, but the right side is normal, then we have to adjust the coefficients |
| | 86 | |
| | 87 | [[latex($A_+ = -\frac{\kappa \Delta t}{2 \Delta x^2}T_{i+1}^{j^n} $)]] |
| | 88 | |
| | 89 | and the center coefficient as |
| | 90 | |
| | 91 | [[latex($A_0 = \frac{\kappa \Delta t}{ 2\Delta x^2}T_{i}^{j^n} + \rho c_v$)]] |
| | 92 | |
| | 93 | and the RHS left and right contributions |
| | 94 | |
| | 95 | [[latex($B_+ = -\frac{\left (n - 1 \right ) \kappa \Delta t}{ 2 \left ( n+ 1 \right ) \Delta x^2} T_{i+1}^{j^{n+1}}$)]] |
| | 96 | |
| | 97 | [[latex($B_- = \frac{\Delta t}{\Delta x} Q_{i-1/2}$)]] |
| | 98 | |
| | 99 | and the RHS center term contribution as |
| | 100 | |
| | 101 | [[latex($B_0 = \frac{\left (n - 1 \right ) \kappa \Delta t}{ 2 \left ( n+ 1 \right ) \Delta x^2} T_{i}^{j^{n+1}} + \rho c_v T_i^j$)]] |
| | 102 | |
| | 103 | |
| | 104 | Of course - remembering that in AstroBEAR everything is negated... |
| | 105 | |
| | 106 | This is accomplished by |
| | 107 | {{{ |
| | 108 | source = source + ((ndiff-1.0)/(ndiff+1.0))*(T(0)*kx*T(0)**ndiff) |
| | 109 | source = source - ((ndiff-1.0)/(ndiff+1.0))*(T(p)*kx*T(p)**ndiff) |
| | 110 | stencil_fixed(0)=stencil_fixed(0)+kx*T(0)**ndiff |
| | 111 | stencil_fixed(p)=0.0 |
| | 112 | source = source - flb*dt_diff/dx |
| | 113 | }}} |