Physical processes by characteristic timescale Diffusive timescale t diff ~ L2 D largest Sound crossing timescale t sound ~ L a Flow timescale t flow ~ L u Free fall timescale Cooling timescale Reaction timescale t ff ~ 1 G t cool ~ X i t react ~min i X i ~ 1 max i j X j R ij smallest
Continuity equation source terms Multiple fluid components 1 2 3... N f = X 1 X 2 X 3... X N f =1} X i i i t i u =0 X i t u X i=0 Reactions that convert one fluid component into another N X i t u X = f i j=1 X i X j R ij Mass diffusion usually negligible in astrophysical settings t u = [ D ]
Importance of conservation in continuity equations The sum X i =1 is not always preserved by an update step: Interpolants: different flattening of the X i Source terms: not always guaranteed to preserve sum Solutions: Rescaling X i X i j X j Restricting X i min[1,max 0, X i ] Problem: no error control Solving only N f 1 equations N f 1 X N f =1 j =1 Problem: error tends to accumulate in the assumed fluid abundance X j Flatten all abundances when X i 1, otherwise none of them Problem: reduces spatial order, leads to numerical mixing
Momentum equation source terms Gravitational forces and viscosity u uu P= g D t = [G D ] For momentum equation these terms can be written as the divergence of a conserved flux. Can also have true momentum source terms: e.g., AGN jets modelled as pistons
Energy equation source terms Energy sources/sinks gravity, radiation E t t u P u= [ E P u]= u g Thermal conduction and viscous heating t u P u= [ K ] 1 2 D 2 D ij = u i x j u j x i 2 3 ij u Equation of state,t, X 1,..., X N f for ideal gases: Dalton's law of partial pressures P=P 1,T P 2, T... P N f, T
Unsplit methods Solve the advection, diffusion, and source terms together e.g., upwind differencing for advection, FTCS for diffusion, and FT for source: q i n 1 =q i n t q t where s = 1 if u i n < 0, s = 0 if u i n > 0 n x [ qu i s = qu x D 2 q x 2 n qu i s 1 D x n q i 1 n] 2 q n n i q i 1 i Advantage: Disadvantage: avoids errors introduced by operator splitting difficult to develop Godunov type methods and multidimensional methods; usually no exact solution to Riemann problem
Split (fractional step) methods Apply difference operators for each piece of physics in sequence. Consider D = D 1 + D 2 + D 3 First order (time): D[q] = D 1 [D 2 [D 3 [q]]] + O( t) Second order (time) Strang splitting: With operator splitting we cannot do better than the time accuracy of the splitting method, no matter what the accuracy of the component operators is. Solve the advection part of our equation with a standard CFD method, with the diffusion terms split off and solved with a parabolic solver, and the source terms split off and solved with an ordinary differential equation solver: q t D[q] = D 1 1/2 [D 2 1/2 [D 3 1/2 [D 3 1/2 [D 2 1/2 [D 1 1/2 [q]]]]]] + O( t 2 ) qu = x D 2 q x 2 { q qu = t x q t =D 2 q x 2 d q d t =
Stiffness Often have very different timescales for flow and source terms. e.g., thermonuclear runaway in a white dwarf (Type Ia supernova) nuclear burning timescale ( 12 C + 12 C) sound crossing timescale If we stick to explicit time integration schemes, we are forced to integrate on the shortest timescale in order to maintain numerical stability! Yet doing everything implicitly causes problems when shock waves are involved. So commonly we: t burn ~ 4 1018 ~ n 1 cm 3 sec ~ 10 12 sec t sound ~ R a ~ 6 108 cm 2 10 2 c ~ 1 sec Use explicit methods for longest timescale physics (advection, diffusion) Use implicit methods for shortest timescale physics (reactions, diffusion) Set timestep using explicit method and then sub cycle the implicit method
Sub cycling q(x,t) source term q n+1 q n+2 q n advection total t t n t n+1 t n+2 t n,1 t n,2 t n,3 t n,4 t n,5 t n,6 t n,7 Intervals t n between Intervals t n,m between determined by stability needs of explicit scheme determined by accuracy needs of implicit scheme; last interval set to make t n,mmax = t n+1 Cannot have t n max m t n,m causes advection and source terms to decouple
Explicit ODE methods Consider the system of linear ordinary differential equations with A symmetric and positive definite (all positive eigenvalues). The number of elements in the vector q is the number of simultaneous source term equations we are solving. One such system is solved for every zone in our grid. Forward Euler (explicit) differencing gives For stability, the timestep must satisfy d q dt = A q q m 1 = I A t q m 1 max t 1 t 2 max where max is the maximum eigenvalue of A.
Runge Kutta methods Explicit ODE integration schemes that achieve higher order than forward Euler by computing derivatives at intermediate points Combine with adaptive step size control for robust integration to modest accuracy (~ 10 4 ) either by halving t or by combining different orders to get error estimate ( embedding ) Second order Runge Kutta (midpoint method): k 1 = t f t m,q m q(t) k 2 = t f t m 1 2 t,qm 1 2 k 1 q m 1 =q m k 2 O t 3 Fourth order Runge Kutta method: k 1 = t f t m, q m k 2 = t f t m 1 2 t, qm 1 2 k 1 k 3 = t f t m 1 2 t, qm 1 2 k 2 k 4 = t f t m t, q m k 3 q m q m+1 t q m 1 =q m 1 6 k 1 1 3 k 2 1 3 k 3 1 6 k 4 O t 5 t m t m+1/2 t m+1 k 1 k 2 k 3 k 4
Bulirsch Stoer method Can also use midpoint method on successively smaller intervals t and use Richardson extrapolation to estimate solution at t 0. q(t) 2 steps q m 4 steps 6 steps steps m+1 q t m t m+1 t Advantage: much more efficient than Runge Kutta for large systems & high accuracy Disadvantage: not as robust for nonsmooth or singular source terms
Implicit and semi implicit ODE methods Backward Euler (implicit) differencing gives which is unconditionally stable, since for all eigenvalues and timesteps t. For nonlinear systems of equations we use Newton's method: q m 1 =q m A q m 1 t q m 1 = I A t 1 q m 1 t 1 1 d q dt =f q qm 1 =q m f q m 1 t q m 1 =q m t[ I t f q m] 1 f q m f/ q is the Jacobian matrix. This type of method is called semi implicit.
Rosenbrock methods Semi implicit generalization of Runge Kutta methods. Look for a solution of the form where f I t q m k i = t f qm s is the order of the method. q m 1 =q m i=1 s i 1 j=1 c i k i ij k j t f q m i 1 j=1 ij k j By combining third and fourth order methods, can obtain an estimate of truncation error to use for adaptive step size control. Method is not guaranteed to be stable (semi implicit), but fairly robust nevertheless, even for nonsmooth right hand sides (e.g., from tabular interpolation). For large vectors q (> 10 elements) and high accuracy (< 10 5 ), methods based on Richardson extrapolation are more efficient.
Intermission
Reaction networks example: diffuse gas + radiation Partially or fully ionized diffuse gas experiences several types of reaction: Photoionization: X + X + + e Recombination: X + + e X + Photon absorption: X + X* Photon emission: X* X + Stimulated emission: X* + X + 2 Collisional excitation: X + e X* + e Collisional ionization: X + e X + + 2e + Charge exchange: X + p X + + H Dielectronic recombination: X+ + e X* Bremsstrahlung: X + e X + e +... Again, we treat different elements and ionization states as different fluids: H 0, H +, H, He 0, He +, He ++,... Overall charge neutrality gives free electron number density: n e = i Z i n i In optically thin limit all radiation escapes; in optically thick limit it is absorbed; in other regimes we need to keep track of radiation field and do radiation transfer
Thermal and ionization equilibrium If we have local thermodynamic equilibrium conditions (necessary for a fluid approach!), the Boltzmann relation gives relative abundances of excited states: n i = n g U i e E / kt i i n i n U i g i E i = number density of atomic/ionic species in ith excited state = total number density of species = partition function for ith state = statistical weight for ith state = energy of ith state relative to ground state If we have ionization equilibrium conditions, we can use Saha equation to determine ionic abundances rather than following them separately: n i 1 n e n i = 2U i 1 U i 2 m kt e h 2 3 /2 e / kt i n i n e U i i = number density of ions in ionization state i = free electron number density = partition function for ionization state i = ionization energy of for ionization state i Then we just track the atomic abundances and use the Saha equation whenever we need an ionic abundance.
Collisional ionization equilibrium A common situation in the intergalactic medium is collisional ionization equilibrium, in which atoms are collisionally ionized and radiatively recombine. If the gas is optically thin, this causes a net loss of energy from the gas. Treat this situation using: One continuity equation for each element (or a single metallicity for all of them) Ionization fraction is a known function of temperature and abundances use to determine n e (needed for emissivity and equation of state) n X,i n X, i T, n H, n H, n He, n He, n He,... P= n e X,i n X, i kt Radiative cooling via a local energy sink term cooling rate is a known function of density, temperature, and abundances: d dt = T, n H,...
Radiative cooling rate for collisionally ionized gas Primordial abundances (from Black 1981) 22 total excitation ionization recombination bremsstrahlung (erg s 1 cm 3 ) 23 H H He + log /n H 2 24 He + H 25 He He He + 4 5 6 7 8 log T (K)
Photoionization equilibrium Another common situation: a source of ultraviolet photons ionizes nearby gas; medium is optically thick to recombination photons ( Strömgren sphere ) In the interior of the nebula the ionization state is set by the equilibrium between: Photoionization by photons from central source and from locally produced recombination photons Collisional ionization by local free electrons Recombination Neutral gas Ionized gas O star 5 pc The size of the nebula increases with time unless collisional processes produce radiation that can escape. 0.01 pc Inside cloud treat using: Ionic abundances from photoionization equilibrium given known external photon source: varying optical depth to known source, local recombination radiation produces local re ionization ( on the spot approximation) Net heating source term for energy equation includes collisional cooling effects Near the edge of the cloud finite optical depth to local recombination photons must be taken into account
Photoionization equilibrium 2 Case 1: no external radiation field, optically thin, collisional cooling only T decreases with time (( )) Case 2: known external radiation field, net photoionization energy input exceeds collisional cooling rate T increases with time Case 3: known external radiation field, collisional cooling rate exceeds net photoionization energy input T decreases with time (( )) Case 4: known external radiation field, net photoionization energy input balances collisional cooling thermal equilibrium (( ))
Cooling curves including photoionization Representative curves for uniform external J = 10 22 ( L / ) erg s 1 cm 2 sr 1 Hz 1 (N. Katz) At lower density, almost complete ionization so gas transparent to recombination photons, allowing them to act as a coolant At higher density, recombination photons are locally absorbed cooling occurs by collisionally excited line emission and bremsstrahlung n H = 2.89 10 6 cm 3 n H = 2.89 10 3 cm 3 22 22 (erg s 1 cm 3 ) 23 Heating 23 log /n H 2 24 24 25 4 5 6 7 8 log T (K) 25 Equilibrium temperature 4 5 6 7 8 log T (K)