Changes between Version 16 and Version 17 of u/johannjc/scratchpad


Ignore:
Timestamp:
01/10/14 16:08:20 (11 years ago)
Author:
Jonathan
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • u/johannjc/scratchpad

    v16 v17  
    4040and the center coefficient as
    4141
    42 [[latex($A_0 =  2 \frac{\kappa \Delta t}{ 2\Delta x^2}T_{i\pm1}^{j^n}  + \rho c_v$)]]
     42[[latex($A_0 =  2 \frac{\kappa \Delta t}{ 2\Delta x^2}T_{i}^{j^n}  + \rho c_v$)]]
    4343
    4444and the RHS left and right contributions
     
    4646[[latex($B_\pm = -\frac{\left (n - 1 \right ) \kappa \Delta t}{ 2  \left ( n+ 1 \right ) \Delta x^2} T_{i\pm 1}^{j^{n+1}}$)]]
    4747
    48 and the RHS source term contribution as
     48and the RHS center term contribution as
    4949
    50 [[latex($B_0 = 2 \frac{\left (n - 1 \right ) \kappa \Delta t}{ 2  \left ( n+ 1 \right ) \Delta x^2} T_{i\pm 1}^{j^{n+1}} + \rho c_v T_i^j$)]]
     50[[latex($B_0 = 2 \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$)]]
    5151
    5252and finally in the code the values for [[latex($A$)]] and [[latex($B$)]] are negated:
     
    6565also 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$)]]
    6666
     67
     68== a note about flux boundary conditions ==
     69If 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
     73which 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
     77which leads to a center coefficient of
     78
     79[[latex($A_0 = \rho c_v$)]]
     80
     81and a left right source term contribution
     82
     83[[latex($B_\pm = \mp \frac{\Delta t}{\Delta x} Q_{i\pm 1/2}$)]]
     84
     85and 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
     89and 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
     93and 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
     99and 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
     104Of course - remembering that in AstroBEAR everything is negated...
     105
     106This 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}}}