pysph: a python framework for sph

42
PySPH: A Python framework for SPH Prabhu Ramachandran Chandrashekhar P. Kaushik Department of Aerospace Engineering and Department of Computer Science and Engineering IIT Bombay SciPy 2010 Austin, TX, June 30 – July 1, 2010

Upload: others

Post on 12-Sep-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PySPH: A Python framework for SPH

PySPH: A Python framework forSPH

Prabhu RamachandranChandrashekhar P. Kaushik

Department of Aerospace Engineering andDepartment of Computer Science and Engineering

IIT Bombay

SciPy 2010Austin, TX, June 30 – July 1, 2010

Page 2: PySPH: A Python framework for SPH

Outline

Introduction

PySPH

Architecture

Page 3: PySPH: A Python framework for SPH

Outline

Introduction

PySPH

Architecture

Page 4: PySPH: A Python framework for SPH

SPH examples

Page 5: PySPH: A Python framework for SPH

SPH examples

Page 6: PySPH: A Python framework for SPH

3D

Page 7: PySPH: A Python framework for SPH

Parallel?

Page 8: PySPH: A Python framework for SPH

Smoothed Particle HydrodynamicsI Particle based, LagrangianI Gingold and Monaghan (1977),

Lucy (1977)

I PDEsI Complex problemsI Moving geometriesI Free surface problemsI . . .

Page 9: PySPH: A Python framework for SPH

Smoothed Particle HydrodynamicsI Particle based, LagrangianI Gingold and Monaghan (1977),

Lucy (1977)

I PDEsI Complex problemsI Moving geometriesI Free surface problemsI . . .

Page 10: PySPH: A Python framework for SPH

SPH basics

I The SPH approximation

f (r) =∫

f (r ′)W (r − r ′, h)dr ′

I W (r − r ′, h): kernel, compact supportI h: size of the kernel

Page 11: PySPH: A Python framework for SPH

SPH basics

Page 12: PySPH: A Python framework for SPH

SPH basics

neighbors

kh

Nearest

Page 13: PySPH: A Python framework for SPH

SPH basics . . .

I Derivatives: transferred to the kernelI Lagrangian

I PDE → ODE

Page 14: PySPH: A Python framework for SPH

Scale-up for larger problemsrequires parallelization

Page 15: PySPH: A Python framework for SPH

Motivation

Reproducible and open research

Page 16: PySPH: A Python framework for SPH

Outline

Introduction

PySPH

Architecture

Page 17: PySPH: A Python framework for SPH

PySPH

I SPH + Parallel + PythonI pysph.googlecode.comI Open Source (BSD)

Page 18: PySPH: A Python framework for SPH

Requirements and installation

I Python, setuptoolsI numpy, Cython-0.12,

mpi4py-1.2I Mayavi-3.x (optional)I Standard Python package

install

Page 19: PySPH: A Python framework for SPH

High-level solver outline

Page 20: PySPH: A Python framework for SPH

Serial Dam break

so l ve r = FSFSolver ( t ime_step =0.0001 ,t o t a l _ s i m u l a t i o n _ t i m e =10. ,ke rne l=CubicSpline2D ( ) )

# create the two e n t i t i e s .dam_wall = So l i d (name= ’ dam_wall ’ )dam_f lu id = F lu i d (name= ’ dam_f lu id ’ )

# The p a r t i c l e s f o r the wa l l .rg = RectangleGenerator ( . . . )dam_wall . add_par t i c l es ( rg . g e t _ p a r t i c l e s ( ) )so l ve r . add_en t i t y ( dam_wall )

Page 21: PySPH: A Python framework for SPH

Serial Dam break . . .

# P a r t i c l e s f o r the l e f t column of f l u i d .rg = RectangleGenerator ( . . . )dam_f lu id . add_par t i c l es ( rg . g e t _ p a r t i c l e s ( ) )so l ve r . add_en t i t y ( dam_f lu id )

# s t a r t the so l ve r .so l ve r . so lve ( )

Page 22: PySPH: A Python framework for SPH

Parallel Dam break

so l ve r = Para l le lFSFSolver (t ime_step =0.0001 ,t o t a l _ s i m u l a t i o n _ t i m e =10. ,ke rne l=CubicSpline2D ( ) )

# Load p a r t i c l e s i n proc wi th rank 0 .

Page 23: PySPH: A Python framework for SPH

Outline

Introduction

PySPH

Architecture

Page 24: PySPH: A Python framework for SPH

Software architecture

I Particle kernelI SPH kernelI Solver frameworkI Serial and Parallel solvers

Page 25: PySPH: A Python framework for SPH

Software architecture

Solver Framework

NNPS

SPH

Cell Manager

Particle Arrays

Solvers

(Python & Cython)(Cython)

(Cython)

(Cython)

(Cython)

C−Arrays (Cython)

Page 26: PySPH: A Python framework for SPH

Particle kernel

I C-arrays: numpy-like but faster andresizable

I ParticleArray: arrays of propertiesI NNPS (Nearest Neighbor Particle

Search)I Cell, CellManagerI Caching

Page 27: PySPH: A Python framework for SPH

SPH kernel

I SPH particle interaction: interactionbetween 2 SPH particles

I SPH summation: interaction of allparticles

Page 28: PySPH: A Python framework for SPH

Solver framework

I Entities (made of particles)I Solver components (do various things)I Component manager (checks

property requirements)I IntegratorI Basic Solver

Page 29: PySPH: A Python framework for SPH

Parallel solver

I Parallel cell managerI Parallel solver components

Page 30: PySPH: A Python framework for SPH

Parallel solver

CellManager

Processor 1 Processor 2

Particles

Solver components

Particles

Solver components

Parallel case

ParallelCellManager ParallelCellManager

Serial case

Particles

Solver components

Page 31: PySPH: A Python framework for SPH

Challenges

I Particles move all overI Fixed partitioning will not workI Scale upI Automatic load balancing?

Page 32: PySPH: A Python framework for SPH

Terminology: Cell

Cells

Particles

Page 33: PySPH: A Python framework for SPH

Terminology: Region

Region 2

P1 P2

Region 1

Page 34: PySPH: A Python framework for SPH

P2

O

(−1,−1,0)

(1,1,0)

(1,−1,0)

(2,0,0)

P1

P3

P4

Terminology: Domain decomposition

Page 35: PySPH: A Python framework for SPH

Approach

I Domain decomposition: CellsI Cells: dynamically created/destroyedI Processors manage RegionsI Cells moved to balance load

Page 36: PySPH: A Python framework for SPH

Load Balancing

Donate CellsI Boundary cellsI Cells with least number of local

neighbors

Page 37: PySPH: A Python framework for SPH

Load balancing

Page 38: PySPH: A Python framework for SPH

Efficiency

Page 39: PySPH: A Python framework for SPH

Efficiency

Page 40: PySPH: A Python framework for SPH

Current capabilities

I Fully automatic, load balanced,parallel framework

I Relatively easy to scriptI Good performanceI Relatively easy to extend

I Free surface flows

Page 41: PySPH: A Python framework for SPH

Immediate improvements

I Solver framework redesignI More documentationI Reduce dependency on TVTK for

easier installationI Improved testing on various platformsI Gas dynamics (coming soon)I Solid mechanics (next year)

Page 42: PySPH: A Python framework for SPH

Thank you!