Aleander Knebe, Universidad Autonoma de Madrid Adaptive Mesh Refinement
AMR codes
Poisson s equation ΔΦ( ) = 4πGρ( )
Poisson s equation F ( ) = m Φ( ) ΔΦ( ) = 4πGρ( ) particle approach F ( Gm i ) = i m j ( i j ) ( 3 i j ) i j grid approach ΔΦ( i, j,k ) = 4πGρ( i, j,k ) F ( i, j,k ) = m Φ( i, j,k ) ( i, j,k =position of centre of grid cell (i, j,k))
Poisson s equation weapon of choice: tree codes F ( ) = m Φ( ) ΔΦ( ) = 4πGρ( ) particle approach F ( Gm i ) = i m j ( i j ) ( 3 i j ) i j grid approach ΔΦ( i, j,k ) = 4πGρ( i, j,k ) F ( i, j,k ) = m Φ( i, j,k ) ( i, j,k =position of centre of grid cell (i, j,k))
Poisson s equation F ( ) = m Φ( ) ΔΦ( ) = 4πGρ( ) particle approach F ( Gm i ) = i m j ( i j ) ( 3 i j ) i j grid approach ΔΦ( i, j,k ) = 4πGρ( i, j,k ) F ( i, j,k ) = m Φ( i, j,k ) ( i, j,k =position of centre of grid cell (i, j,k)) weapon of choice: AMR codes
Particle-Mesh Method Particle-Mesh (PM) method ΔΦ( g k,l,m ) = 4πGρ( g k,l,m ) F ( g k,l,m ) = m Φ( g k,l,m ) 1. calculate mass density on grid 2. solve Poisson s equation on grid 3. differentiate potential to get forces 4. interpolate forces back to particles i ρ( g k,l,m ) Φ( g k,l,m ) F ( g k,l,m ) F ( g k,l,m ) F ( i )
Particle-Mesh Method numerically integrate Poisson s equation pure PM calculation
Particle-Mesh Method numerically integrate Poisson s equation density assignment schemes: interplay pure PM between calculation N and ε: Nε 3 =const. NGP = too crude CIC = common choice TSC = pretty smooth
Particle-Mesh Method numerically integrate Poisson s equation pure PM calculation overcoming the spatial resolution limitation?
Particle-Mesh Method numerically integrate Poisson s equation AMR calculation Yahagi & Yoshi (2001)
Particle-Mesh Method numerically integrate Poisson s equation AMR calculation...details now Yahagi & Yoshi (2001)
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration
Mesh Refinements types of mesh refinement r refinement: move or stretch the mesh p refinement: adjust the order of the method h refinement: change the mesh spacing
Mesh Refinements types of mesh refinement r refinement non-uniform mesh (refined region is known) = advantages: - simple to implement = disadvantages: - difference epression for non-constant zone spacing COSMOS code (Ricker 2000)
Mesh Refinements types of mesh refinement r refinement Lagragian mesh (mesh is tied to fluid) = advantages: - constant mass resolution - sharp resolution of contacts = disadvantages: - grid stretching causes numerical dissipation - grid tangling in rotational flows MMH code (Pen 1998)
Mesh Refinements types of mesh refinement r refinement Lagragian mesh (mesh is tied to fluid) = advantages: - constant mass resolution - sharp resolution of contacts = disadvantages: - grid stretching causes numerical dissipation - grid tangling in rotational flows usually used only in 1D (e.g. stellar evolution codes) MMH code (Pen 1998)
AMR Codes Mesh Refinements types of mesh refinement r refinement arbitrary Lagrangian-Eulerion mesh (mesh moves arbitrarily fluid) = advantages: - Lagrangian mesh where flow is irrotational - Eulerian where mesh distortion is problematic = disadvantages: - difficult to handle... DJEHUTY code (Dearborn et al. 2002)
Mesh Refinements types of mesh refinement p refinement not in this course...
Mesh Refinements types of mesh refinement h refinement nested grids (static meshes with different resolutions) = advantages: - easy to handle boundaries between meshes = disadvantages: - refined region should not move
Mesh Refinements types of mesh refinement h refinement adaptive mesh refinement (refined patches are created and destroyed as needed) = advantages: - fully fleible to problem = disadvantages: - serious book-keeping for grid hierarchy density field of simulated galay cluster AMIGA code (Doumler & Knebe 2010) adaptive grid hierarchy
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration
Adaptive Mesh Refinement adaptive mesh refinement improvements using finer grids double pancake test (Doumler & Knebe 2010)
Adaptive Mesh Refinement adaptive mesh refinement improvements using finer grids shock tube test (Teyssier 2002)
Adaptive Mesh Refinement adaptive mesh refinement improvements using finer grids grid level shock tube test (Teyssier 2002)
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density truncation error physics
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ()
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ()
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ() AMR level #4 AMR level #3 AMR level #2 AMR level #1 domain grid
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ() AMR level #4 AMR level #3 AMR level #2 AMR level #1 domain grid
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density: - refine regions of high density truncation error: physics:
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density: - refine regions of high density truncation error: - refine regions of large truncation errors i R k,l,m i = ΔΦ k,l,m ρ k,l,m ετ k,l,m with i [ ] ΔΦ k,l,m i Τ k,l,m = P Δ( RΦ k,l,m ) ( ) physics:
Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density: - refine regions of high density truncation error: - refine regions of large truncation errors i R k,l,m i = ΔΦ k,l,m ρ k,l,m ετ k,l,m with i [ ] ΔΦ k,l,m i Τ k,l,m = P Δ( RΦ k,l,m ) ( ) physics: - compare grid spacing against local critical wavelength π Δ < ε λ with λ = c s Gρ
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration
AMR for N-body gravity tends to clump matter together...
AMR for N-body gravity tends to clump matter together...
AMR for N-body gravity tends to clump matter together...
AMR for N-body gravity tends to clump matter together... introduce finer grids where needed and gain a factor of 2 in accuracy (in regions of interest)
AMR for N-body gravity tends to clump matter together... introduce finer grids where needed and gain a factor of 2 in accuracy (in regions of interest) factor 2 not mandatory, but most common choice
AMR for N-body gravity tends to clump matter together... introduce finer grids where needed periodic boundary conditions isolated boundary conditions
AMR for N-body gravity tends to clump matter together... introduce finer grids where needed...and update the grids where and when necessary
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration
AMR Codes generating refinements N-body simulations: number of particles per cell refinement criterion: 6 particles/cell AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell loop through given grid generating refinement by checking each individual cell N-body simulations: AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body
AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell stop when no more cell require splitting N-body simulations: AMR for N-body
AMR for N-body generating refinements N-body simulations: number of particles per cell Note: in this scheme we split the volume of a coarse cell into eight equal sub-cells => non-cospatial scheme refinement criterion: 6 particles/cell
AMR for N-body generating refinements interpolation between grids: f ( i ) = F( i ) + ʹ F ( i )Δ F = value on coarse grid f = value on fine grid
AMR for N-body generating refinements interpolation between grids: f ( i ) = F( i ) + ʹ F ( i )Δ co-spatial vs. non-cospatial F( i ) F( i ) f ( i ) = F( i ) f ( i+1/ 2 ) = F( i ) + F ʹ ( i ) Δ 2 f ( i 1/ 2 ) = F( i ) F ʹ ( i ) Δ 2 f ( i+1/ 2 ) = F( i ) + F ʹ ( i ) Δ 2
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration
AMR for N-body density assignment (co-spatial scheme)
AMR for N-body density assignment (co-spatial scheme)
AMR for N-body density assignment (co-spatial scheme) TSC mass assignment
AMR for N-body density assignment (co-spatial scheme) unproblematic:
AMR for N-body density assignment (co-spatial scheme) unproblematic:
AMR for N-body density assignment (co-spatial scheme) problematic:
AMR for N-body density assignment (co-spatial scheme) problematic:
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) transfer particles to refinement
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) density on coarse grid assign density on coarse grid
AMR for N-body density assignment (co-spatial scheme) density on coarse grid nodes with zero density
AMR for N-body density assignment (co-spatial scheme) density on coarse grid nodes carrying the density contribution from particles outside refinement => to be transferred to refinement nodes
AMR for N-body density assignment (co-spatial scheme) density on coarse grid remember nodes carrying the density contribution from particles outside refinement => to be transferred to refinement nodes
AMR for N-body density assignment (co-spatial scheme) density on coarse grid same nodes still missing density from particles on refinement edge => to be derived from refinement density
AMR for N-body density assignment (co-spatial scheme) density on coarse grid remember nodes still missing density from particles on refinement edge
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) density on refinement grid assign density on refinement grid
AMR for N-body density assignment (co-spatial scheme) density on refinement grid refinement nodes still missing the density contribution from particles outside refinement
AMR for N-body density assignment (co-spatial scheme) density on refinement grid remember refinement nodes still missing the density contribution from particles outside refinement
AMR for N-body density assignment (co-spatial scheme) density on refinement grid all refinement nodes carry information required by coarse nodes
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) density on coarse grid nodes carrying the density contribution from particles outside refinement
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) density on coarse grid all refinement nodes carry information required by coarse nodes
AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement
AMR for N-body density assignment (co-spatial scheme) density on refinement grid refinement nodes still missing the density contribution from particles outside refinement
AMR for N-body density assignment (co-spatial scheme) density finally correct on both levels
AMR for N-body density assignment (co-spatial scheme) density finally correct on both levels phew...
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration
AMR for N-body solving Poisson s equation 16 3 boundary values 32 3 boundary values 64 3 boundary values 128 3
AMR for N-body adaptive mesh refinement cover simulation with regular domain grid create AMR hierarchy: generate fine grid by comparing each node against some refinement criterion " recursive procedure assign density on all grids solve Poisson s equation on regular domain grid (FFT is fastest ) loop over all refinement levels: interpolate potential down from parent level rela potential until converged (keeping boundary values fied) " this will give the correct potential on all (refinement) grids
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration
AMR Codes Irregular Grids handling refinements refinement grids can have a highly irregular shape and consist of multiple spatially disjunctive blocks
AMR Codes Irregular Grids handling refinements how to manage and maneuver such irregular grids? refinement grids can have a highly irregular shape and consist of multiple spatially disjunctive blocks
Irregular Grids handling regular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 struct { N = 16 node[0].rho, =3 node[1].rho, =6, node[n-1].rho, =48 float rho; } node;
Irregular Grids handling regular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 struct { N = 16 float rho; } node; node[0].rho, =3 node[1].rho, =6, node[n-1].rho, =48 unique mapping between array inde i and spatial position possible
Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 struct { float rho; } node;
Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 node[0]. = 12 node[1]. = 15 node[2]. = 18 node[3]. = 21 node[4]. = 24 node[5]. = 27 node[6]. = 36 node[7]. = 39 node[8]. = 42 struct { long ; float rho; } node;
Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 node[0]. = 12 node[1]. = 15 node[2]. = 18 node[3]. = 21 node[4]. = 24 node[5]. = 27 node[6]. = 36 node[7]. = 39 node[8]. = 42 struct { long ; float rho; } node; no unique mapping between array inde i and spatial position possible
Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 node[0]. = 12 node[1]. = 15 node[2]. = 18 node[3]. = 21 node[4]. = 24 node[5]. = 27 node[6]. = 36 node[7]. = 39 node[8]. = 42 struct { long ; float rho; } node; no unique mapping between array inde i and spatial position possible generate a meta-structure storing the geometry of the grid
Irregular Grids handling irregular grids (1D) quad s = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { float rho; } node;
Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { float rho; } node;
Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { float rho; } node;
Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { this node is addressed via (QUAD.node)+0 float rho; } node;
Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { this node is addressed via (QUAD.node)+1 float rho; } node;
Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { this node is addressed via (QUAD.node)+2 float rho; } node;
Irregular Grids handling irregular grids (2D) quad s
Irregular Grids handling irregular grids (2D) quad s the memory for each quad array needs to be malloc() ed consecutively
Irregular Grids handling irregular grids (2D) quad s store grid structures as a consecutive memory block each grid points to the first yquad which in turns gives access to all nodes grid #1 grid #1 grid #2 grid #3
Irregular Grids handling irregular grids (2D) quad s store grid structures as a consecutive memory block each grid points to the first yquad which in turns gives access to all nodes grid #2 grid #1 grid #2 grid #3 (pointer, y=1, length=3, net) (pointer, y=1, length=3, NULL) +1 (pointer, =1, length=2, net) (pointer, =1, length=2, NULL) +2 +1 (pointer, =4, length=2, net) (pointer, =1, length=2, net) (pointer, =5, length=2, NULL) (pointer, =4, length=2, net) (pointer, =9, length=1, NULL) (pointer, =8, length=2, NULL) (pointer, =7, length=3, NULL)
Irregular Grids handling irregular grids (3D) quad s too complicated to sketch
Irregular Grids handling irregular grids (3D) quad s C-code eample of how to loop over all nodes attached to a grid for (zquad=grid.first_zquad; zquad = NULL; zquad=zquad->net) { for (yquad=zquad->first_yquad; yquad < yquad->pointer+yquad->length; yquad++) for (iyquad=yquad; iyquad = NULL; iyquad=iyquad->net) { for (quad=yquad->first_quad; quad < quad->pointer+quad->length; quad++) for (iquad=quad; iquad = NULL; iquad=iquad->net) { for (node=iquad->pointer; node < iquad->+iquad->length; node++) { /* the node is at your disposal */ density = node->density; potential = node->potential; forcex = node->force[x]; for(part=node->first_particle; part = NULL; part=part->net) /* use particle structure to access particle position, velocity, etc. */ }}} loc = location of first quad
Irregular Grids handling irregular grids quad s drawback: no direct access to neighbouring nodes?
Irregular Grids handling irregular grids FTT other schemes possible: struct { NODE *daughter; float rho; } node; Fully-Threaded-Tree (FTT) by Khokhlov, 1998, J. Comp. Phy. 143, 519 (used with Andrey Kravtsov s ART code )
Irregular Grids handling irregular grids FTT other schemes possible: struct { NODE *daughter; float rho; } node; each cell stores pointers to 1 st daughter daughters are malloc() ed consecutively Fully-Threaded-Tree (FTT) by Khokhlov, 1998, J. Comp. Phy. 143, 519 (used with Andrey Kravtsov s ART code )
Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration
Adaptive Leap-Frog Integration full set of equations collisionless matter (e.g. dark matter) d DM = v DM dt leap-frog integration d v DM = φ dt AMR solver Poisson s equation Δφ = 4πGρ tot collisional matter (e.g. gas) ideal gas equations ρ t + ρ v ( ) = 0 p = ( γ 1)ρε ( ρ v ) t + ρ v v + p + 1 2µ B2 " 1 1 B B µ = ρ ( φ) ρε = ρe 1 2 ρv 2 ( ρe) t + ρe + p + 1 2µ B2 v 1 µ v B [ ] B = ρ v ( φ) + ( Γ L) Mawell s equation B t = v B ( )
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy AMR grids particles Δφ = 4πGρ tot d DM dt d v DM dt = v DM = φ
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy move particles on fine grids with smaller time step to better resolve the dynamics, too AMR grids particles Δφ = 4πGρ tot d DM dt d v DM dt = v DM = φ
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: fine grid coarse grid
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: Drift-Kick-Drift variant of the leap-frog integrator: time synchronisation between different grid levels rather than leap-frogging
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: 1. fine grid step: Drift : Kick : Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt p n +1/ 2 = p n Φ n +1/ 4 n +1/ 2 = n +1/ 4 + t n +Δt / 2 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: 2. coarse grid step: Drift : Kick : Drift : n +1/ 2 = n + t n +Δt / 2 p n p n +1 = p n Φ n +1/ 2 t n n +1 = n +1/ 2 + p n +1 dt t n +Δt t n t n +Δt dt dt t n +Δt / 2
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: 3. fine grid step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 1. fine grid DKD step: Drift : Kick : Drift : n +1/ 4 = n + t n +Δt / 4 p n t n dt p n +1/ 2 = p n Φ n +1/ 4 n +1/ 2 = n +1/ 4 + t n +Δt / 2 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 1. fine grid DKD step: Drift : Kick : Drift : n +1/ 4 = n + t n +Δt / 4 p n t n dt p n +1/ 2 = p n Φ n +1/ 4 n +1/ 2 = n +1/ 4 + t n +Δt / 2 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 2. coarse grid DKD step: Drift : Kick : Drift : n +1/ 2 = n + t n +Δt / 2 p n t n p n +1 = p n Φ n +1/ 2 n +1 = n +1/ 2 + p n +1 dt t n +Δt t n t n +Δt dt dt t n +Δt / 2
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 2. coarse grid DKD step: Drift : Kick : Drift : n +1/ 2 = n + t n +Δt / 2 p n t n p n +1 = p n Φ n +1/ 2 n +1 = n +1/ 2 + p n +1 dt t n +Δt t n t n +Δt dt dt t n +Δt / 2
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 3. fine grid DKD step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + t n +3Δt / 4 p n dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 3. fine grid DKD step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + t n +3Δt / 4 p n dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 3. fine grid DKD step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + t n +3Δt / 4 p n dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4 what about particles crossing grid boundaries?
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries particles can cross boundary during any of these steps... 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 2. coarse-grid drift 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 2. coarse-grid drift do nothing as particle has reached t n+1 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 3. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 keep on drift ing as it will bring the particle to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 3. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 keep on drift ing as it will bring the particle to t n+1
Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. Drift : 2. Drift : n +1/ 4 = n + p n n +1/ 2 = n +1/ 4 + t n +Δt / 4 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 3. Drift : 4. Drift : n +3 / 4 = n +1/ 2 + p n n +1 = n +3 / 4 + p n +1 t n +3Δt / 4 all particles have now moved from t n to t n+1 and the refinements will be re-created... dt t n +Δt / 2 t n +Δt dt t n +3Δt / 4
Pseudo C-Code Step(dt, CurrentGrid) { NewGrid = Refine(CurrentGrid); if(newgrid) { Step(dt/2, NewGrid); } MoveParticles(dt, CurrentGrid); } if(newgrid) { Step(dt/2, NewGrid); DestroyGrid(NewGrid);}
AMIGA