lammps, flash and mesa - ubc physics & astronomyheyl/heyl_westgrid.pdf · lammps flash mesa...

27
LAMMPS FLASH MESA LAMMPS, FLASH and MESA Jeremy Heyl 22 June 2017 Westgrid Summer School Jeremy Heyl LAMMPS, FLASH and MESA

Upload: hoangtram

Post on 07-Feb-2018

254 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

LAMMPS, FLASH and MESA

Jeremy Heyl

22 June 2017

Westgrid Summer School

Jeremy Heyl LAMMPS, FLASH and MESA

Page 2: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

LAMMPS

I What is LAMMPS?

I LAMMPS is a classical molecular dynamics simulator.

I Serial or parallel.

I GPU or CPU

I Not just classical: PIMD, Lattice Boltzmann Fluid, . . .

I Adapted fromhttp://lammps.sandia.gov/tutorials.html

Jeremy Heyl LAMMPS, FLASH and MESA

Page 3: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

What is molecular dynamics?

Classical MD in a nutshell

Jeremy Heyl LAMMPS, FLASH and MESA

Page 4: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

LAMMPS?

Large-scale Atomic/Molecular Massively Parallel Simulatorhttp://lammps.sandia.gov

I Classical MD code

I Open source, portable C++

I 3-legged stool: soft matter, solids, mesoscale

I Particle simulator at varying length and time scales

I electrons atomistic coarse-grained continuum

I Spatial-decomposition of simulation domain for parallelism

I MD, non-equilibrium MD, energy minimization

I GPU and OpenMP enhanced

I Can be coupled to other scales: QM, kMC, FE, CFD, ...

Jeremy Heyl LAMMPS, FLASH and MESA

Page 5: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Why LAMMPS?

I Versatile: bio, materials, mesoscale; atomistic, coarse-grained,continuum; use with other codes, e.g. multiscale models

I Good parallel performance

I Easy to extend

I Well documented: extensive web site, 1300 page manual

Jeremy Heyl LAMMPS, FLASH and MESA

Page 6: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Getting Started

I Download the LAMMPS source code fromhttp://lammps.sandia.gov/download.html.

I Download VMD from http://www.ks.uiuc.edu/

Development/Download/download.cgi?PackageName=VMD

I Install ffmpeg if you don’t have it already fromhttps://ffmpeg.org/download.html

Jeremy Heyl LAMMPS, FLASH and MESA

Page 7: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Compiling LAMMPS

I Unpack the TARball: tar xfz lammps-stable.tar.gz

I Go to the source directory cd lammps-31Mar17/src

I Compile: make serial

Jeremy Heyl LAMMPS, FLASH and MESA

Page 8: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Your First Simulation

I LAMMPS comes with many example simulations in theexamples directory.

I Let’s first look at the one called obstacle.

I Copy it to a fresh direcory: cp -rp obstacle my obstacle

I Go to the new directory and run ../../src/lmp serial <

in.obstacle

I What new files are there?

Jeremy Heyl LAMMPS, FLASH and MESA

Page 9: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Visualising with VMD

I Open VMD.

I Select “File” and “New Molecule”

I Click “Load” and choose LAMMPS Trajectory for the format.

I Choose “dump.obstacle”

I Click on “Graphics” and “Representation” and choose“Drawing Method” “VDW”

I Select “Extensions”, “Visualization”, “Movie Maker”

I Choose FFMPEG.

Jeremy Heyl LAMMPS, FLASH and MESA

Page 10: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Make a Movie with FFMPEG

I Let’s change the input file so that an image is saved at eachstep.

I Uncomment at the following lines

#dump 2 all image 500 image.*.jpg type type &

# zoom 1.6 adiam 1.5

#dump_modify 2 pad 5

I And change jpg to pnm.

I Run it again.

I Run: ffmpeg -framerate 24 -pattern-type glob -i

’*.pnm’ out.mpg

Jeremy Heyl LAMMPS, FLASH and MESA

Page 11: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Input File

1. Units and atom style2. Create simulation box and atoms

I region, create box, create atoms, region commandsI lattice command vs box units

I read data commandI data file is a text fileI look at examples/micelle/data.micelleI see read data doc page for full syntax

3. Define groups

4. Attributes of atoms: mass, velocity

5. Pair style for atom interactions

6. Fixes for time integration and constraints

7. Computes for diagnostics

8. Output: thermo, dump, restart

9. Run or minimize

Jeremy Heyl LAMMPS, FLASH and MESA

Page 12: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Log File

I Contains what your inputfile does.

I Contains thermodynamicinformation.

I Let’s plot something (usingctioga2) http://ctioga2.

sourceforge.net

0.6

0.8

1.0

1.2

1.4

Pressure

0 5000 10000 15000 20000 25000

Time

ctioga2 --name pressure log.lammps@1:6 -x ’Time’ -y ’Pressure’

Jeremy Heyl LAMMPS, FLASH and MESA

Page 13: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Obstacle Input File

First Section - setup box and create atoms

# 2d LJ obstacle flow

dimension 2

boundary p s p

atom_style atomic

neighbor 0.3 bin

neigh_modify delay 5

# create geometry

lattice hex 0.7

region box block 0 40 0 10 -0.25 0.25

create_box 3 box

create_atoms 1 box

Jeremy Heyl LAMMPS, FLASH and MESA

Page 14: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Obstacle Input File

Second Section - define potential and groups

# LJ potentials

pair style lj/cut 1.12246

pair coeff * * 1.0 1.0 1.12246

# define groups

region 1 block INF INF INF 1.25 INF INF

group lower region 1

region 2 block INF INF 8.75 INF INF INF

group upper region 2

group boundary union lower upper

group flow subtract all boundary

set group lower type 2

set group upper type 3

Jeremy Heyl LAMMPS, FLASH and MESA

Page 15: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Obstacle Input File

Third Section - set velocities and fixes

# initial velocities

mass * 1.0

compute mobile flow temp

velocity flow create 1.0 482748 temp mobile

fix 1 all nve

fix 2 flow temp/rescale 200 1.0 1.0 0.02 1.0

fix_modify 2 temp mobile

# Poiseuille flow

velocity boundary set 0.0 0.0 0.0

fix 3 lower setforce 0.0 0.0 0.0

fix 4 upper setforce 0.0 NULL 0.0

fix 5 upper aveforce 0.0 -0.5 0.0

fix 6 flow addforce 1.0 0.0 0.0

Jeremy Heyl LAMMPS, FLASH and MESA

Page 16: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Obstacle Input File

Fourth Section - the voids

# 2 obstacles

region void1 sphere 10 4 0 3

delete atoms region void1

region void2 sphere 20 7 0 3

delete atoms region void2

fix 7 flow indent 100 sphere 10 4 0 4

fix 8 flow indent 100 sphere 20 7 0 4

fix 9 all enforce2d

Jeremy Heyl LAMMPS, FLASH and MESA

Page 17: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

The Obstacle Input File

Fifth Section - do it

# run

timestep 0.003

thermo 1000

thermo_modify temp mobile

#dump 1 all atom 100 dump.obstacle

dump 1 all image 500 image.*.jpg type type &

zoom 1.6 adiam 1.5

dump_modify 1 pad 5

run 25000

Jeremy Heyl LAMMPS, FLASH and MESA

Page 18: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

A Third Obstacle

Add a third obstacle

region void3 sphere 30 3 0 1

delete atoms region void3

fix 8a flow indent 100 sphere 30 3 0 2

Jeremy Heyl LAMMPS, FLASH and MESA

Page 19: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Hands-on Time

I Work in groups of two or three

I Pick one or two examples from the examples directory or fromthe internet.

I Work through the example and try changing parameters.

I Ask questions.

I Make some movies using FFMPEG or VMD.

I What did you learn?

I Present your work in a 2-3 minute presentation.

Jeremy Heyl LAMMPS, FLASH and MESA

Page 20: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

FLASH

It’s not just for astrophysics.

I Hydrodynamics

I Magnetohydrodynamics

I Equation of State: Ideal gas; Degenerate Ionized Plasma;Multimaterial

I Radiation Transfer: Multigroup Flux-limited Diffusion

I Diffusion and Conduction: Implicit with AMR

I Laser Energy Deposition: Geometric Optics with InverseBrensstrahlung

I Opacity: Constant; Multimaterial Tabular

I Particles: Tracer; Massive; Sink; Charged

I Gravity: Constant; PointMass; Planar; Self Gravity

I Magnetic Resistivity, Conductivity

Jeremy Heyl LAMMPS, FLASH and MESA

Page 21: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

FLASH Infrastructure

I Driver: Split; Unsplit

I Grid: Uniform Grid; AMR (PARAMESH); AMR (Chombo)

I GridParticles: Lagrangian Framework

I GridSolvers: Multigrid; Multipole; Barnes-Hut Tree; PFFT;Direct Solvers for Uniform Grid

I IO: HDF5 ; PnetCDF

I Multispecies

Jeremy Heyl LAMMPS, FLASH and MESA

Page 22: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Flames

Jeremy Heyl LAMMPS, FLASH and MESA

Page 23: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Supersonic Flow around an Obstacle

https://doi.org/10.1016/j.compfluid.2014.12.008

Jeremy Heyl LAMMPS, FLASH and MESA

Page 24: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Combustion

https://doi.org/10.1016/j.compfluid.2014.09.051

Jeremy Heyl LAMMPS, FLASH and MESA

Page 25: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

MESA

MESA simulates stars. What it is in for you if you’re not intostars?

I Large nuclear reaction network

I Neutrinos

I Numeric algorithms

I Equations of state

I Opacities

I All documented in the code with citations.

Jeremy Heyl LAMMPS, FLASH and MESA

Page 26: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Jeremy Heyl LAMMPS, FLASH and MESA

Page 27: LAMMPS, FLASH and MESA - UBC Physics & Astronomyheyl/heyl_westgrid.pdf · LAMMPS FLASH MESA LAMMPS I What is LAMMPS? ... 1300 page manual Jeremy Heyl LAMMPS, FLASH and MESA. LAMMPS

LAMMPSFLASHMESA

Numerical Treasure Chest

I The real treasure if you are not an astrophysicist is in the filemesa-r9793/num/public/num lib.f.

I Safe root findingI Explicit ODEs solvers (non-stiff)I Implicit ODEs solvers (stiff)I Linear algebraI Newton-Raphson SolverI Minimization with and without constraintsI Random number generatorsI Quicksort, binary search

I Everything documented, referenced and with tips for usingthem.

Jeremy Heyl LAMMPS, FLASH and MESA