Creating anew simulation

AMR: Adaptive mesh refinement
Root Grid

1 Child Grid

2 Child Grid

3 Child Grid

4 Child Grid

AMR: Adaptive mesh refinement

AMR: Adaptive mesh refinementlevel 0“Top Grid”“Root Grid”
parentlevel 1level 2

“Child Grid”
parent“Child Grid”

Initial Conditions
t = 0

Simulation box at starte.g. cosmology simulation
small density perturbations (changes)

Simulations
A cosmology simulation is 1 choice...

But other simulations do
not start at z = 50
e.g. galaxy discs, colliding
clouds, star formation ...

Running Enzo

Initial conditionchoices(1) enzo.C(2) InitializeNew.C
ProblemType = 1

ProblemType = ?

Your new simulation

HydroShockTubesInitialize.C(3)

ProblemType = 30

CosmologySimulationInitialize.C

(3)

(3)

Running Enzo

> cd enzo-dev/src/enzo> ls *Initialize*.CDifferent simulation initial conditions
SimulationInitialize.C
Grid_SimulationInitializeGrid.C
e.g.
ZeldovichPancakeInitialize.C
Grid_ZeldovichPancakeInitialize.C

NewSimulationInitialize.C
Read parameters

Set upempty grids
ProblemType = 12
StarParticleCreation = 1StarParticleFeedback = 1
StaticHierarchy = 0.
.
.

Enzovy,3⇢1e2enzo param.enzo

vx,1 ⇢2e1

Grid_NewSimulation InitializeGrid.C

e.g.

Rotating Cylinder

x-direction

z-direction

e.g.

Rotating Cylinder

on conival:
Copy:> cp -r /mnt/iscsi5/enzo_workshop/workshop2014/
new_simulation/ .

Read:> emacs -nw NewRotatingCylinderInitialize.C

NewRotatingCylinderInitialize.C

AHHHHHHHHH!!!!!

NewRotatingCylinderInitialize.C(called by InitializeNew.C)

Read parameters

Set up grid levels

2 choices for setting up initial grids

Adaptive meshes

Subgrids

Child grid location
based on parent gridproperties

Child grid location
based on fixed position⇢1 ⇢1 ⇢1 ⇢1 ⇢1⇢1 ⇢⇢11⇢1v⇢y,31 ⇢1⇢1 ⇢1 ⇢e21 ⇢1 ⇢1⇢1v⇢x,11 ⇢⇢21 ⇢1 ⇢1⇢1 ⇢e11 ⇢1 ⇢1 ⇢1(xl , yl , zl )
vy,3

⇢1
e2
vx,1 ⇢2e1(xr , yr , zr )

NewRotatingCylinderInitialize.C

Set defaults

Readproblem-specificparameters

Check we’ve notmissed any

Set ⇢, e, v̄ cells intop grid
Create AMR hierarchy
level 2level 1Top grid

Set ⇢, e, v̄ cells inchild grid
Largely identical for all problem types

Grid_NewRotatingCylinderInitializeGrid.C(called by NewRotatingCylinderInitialize.C)> emacs -nw Grid_NewRotatingCylinderInitializeGrid.C

Assign memory for ⇢, e, v̄ fields

Set ⇢, e, v̄ for each cell

Grid_NewRotatingCylinderInitializeGrid.C

Create ⇢, e, v̄ fields
Only do this on 1 processor

Assign memory for fields
Useful function forfinding fields

Loop over cells
set background values
Cell position⇢, e, v̄ inside cylinder

Set final field value

Add to Enzo
Now we must add this simulation to Enzo+Enzo(1) put files in code directory:> mv NewRotatingCylinderInitialize.C ~/enzo-dev/src/enzo/.
> mv Grid_NewRotatingCylinderInitializeGrid.C ~/enzo-dev/src/enzo/.

Add to Enzo(2) add to InitializeNew.C> cd ~/enzo-dev/src/enzo
emacs -nw InitializeNew.C

Add to Enzo(2) add to InitializeNew.C“function prototypes”
List of new simulations

Add to Enzo(2) add to InitializeNew.C> emacs NewRotatingCylinderInitialize.C

copy

NewRotatingCylinderInitialize.C

Add to Enzo(2) add to InitializeNew.C
In InitializeNew.C

paste

InitializeNew.C

Add to Enzo(2) add to InitializeNew.C

Give number to simulation

Add to Enzo(2) add to InitializeNew.C

add ~ line 453

Add to Enzo
(3) add to Grid.h> emacs Grid.h

Add to Enzo
(3) add to Grid.h

add ~ line 1824

Grid.hAdd to Enzo
(3) add to Make.config.objects> emacs Make.config.objects

Add to Enzo
(3) add to Make.config.objects

add ~ line 671

Make.config.objects

Add to Enzo
(3) add to Make.config.objects

add ~ line 491

Make.config.objects

Add to Enzo

Let’s run!
> make> cd> mkdir RotCylinder> cd RotCylinder> cp ~/new_simulation/NewRotatingCylinder.enzo .
> ~/enzo-dev/bin/enzo -d NewRotatingCylinder.enzo

Summary
Make the 2 new files (or copy from another test problem):
MyProblemInitialize.C
Grid_MyProblemInitializeGrid.C

Add prototype and call for non-Grid initialization routine inInitializeNew (make sure it has a unique ProblemType #).
/src/enzo/InitializeNew.C
Add definition of Grid initialization routine to Grid.h/src/enzo/Grid.h
Add the 2 new files to Make.config.objects (so they get compiled)/src/enzo/Make.config.objects

Challenge!
Let’s try making a change!
We’ll make a rotating sphere insteadPoints to watch
Using Zeus

(HydroMethod = 2)

Zeus uses a face-centered velocityvx⇢, e

r1r2vyvz

r3r4

It also uses internal energy, not total energy

Points to watchEnergy
BaryonField[TENum] is energy/mass
Particle Mass
ParticleMass[i] is particle mass / cell volume
GravitationalConstantGravitationalConstant = 4 pi G
Must be in code units if SelfGravity = 1

> ssh node0X> cd> cd new_simulation> emacs -nw NewRotatingCylinder.enzo(change ProblemType = 15)~/enzo-dev/bin/enzo -d NewRotatingCylinder.enzo