CS 294-73 Software Engineering for Scientific Computing. http://www.cs.berkeley.edu/~colella/cs294fall2013. Lecture 16: Particle Methods; Homework #4



Similar documents
Finite Difference Approach to Option Pricing

Notes for AA214, Chapter 7. T. H. Pulliam Stanford University

Numerical Analysis An Introduction

AN INTRODUCTION TO NUMERICAL METHODS AND ANALYSIS

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 10

Interactive simulation of an ash cloud of the volcano Grímsvötn

PSTricks. pst-ode. A PSTricks package for solving initial value problems for sets of Ordinary Differential Equations (ODE), v0.7.

Homework 2 Solutions

Numerical Methods for Engineers

ABSTRACT FOR THE 1ST INTERNATIONAL WORKSHOP ON HIGH ORDER CFD METHODS

Numerical Analysis Introduction. Student Audience. Prerequisites. Technology.

Lecture 8 : Dynamic Stability

Discrete mechanics, optimal control and formation flying spacecraft

SIXTY STUDY QUESTIONS TO THE COURSE NUMERISK BEHANDLING AV DIFFERENTIALEKVATIONER I

16.1 Runge-Kutta Method

Numerical methods for American options

440 Geophysics: Heat flow with finite differences

Figure 1 - Unsteady-State Heat Conduction in a One-dimensional Slab

On computer algebra-aided stability analysis of dierence schemes generated by means of Gr obner bases

APPLIED MATHEMATICS ADVANCED LEVEL

User Guide Thank you for purchasing the DX90

Stability Analysis for Systems of Differential Equations

Chapter 3: Mathematical Models and Numerical Methods Involving First-Order Differential Equations

Solving ODEs in Matlab. BP205 M.Tremont

Fast solver for the three-factor Heston-Hull/White problem. F.H.C. Naber tw

5 Numerical Differentiation

A QUICK GUIDE TO THE FORMULAS OF MULTIVARIABLE CALCULUS

Numerical Solution of Differential Equations

The integrating factor method (Sect. 2.1).

Numerical Methods for Differential Equations

Dynamics. Basilio Bona. DAUIN-Politecnico di Torino. Basilio Bona (DAUIN-Politecnico di Torino) Dynamics / 30

Lecture. S t = S t δ[s t ].

5.4 The Heat Equation and Convection-Diffusion

Does Black-Scholes framework for Option Pricing use Constant Volatilities and Interest Rates? New Solution for a New Problem

3.2 Sources, Sinks, Saddles, and Spirals

Time domain modeling

MAT 242 Test 2 SOLUTIONS, FORM T

Dynamical Systems Analysis II: Evaluating Stability, Eigenvalues

Lecture 6 Black-Scholes PDE

Modeling of Earth Surface Dynamics and Related Problems Using OpenFOAM

Chapter 5. Methods for ordinary differential equations. 5.1 Initial-value problems

Code: MATH 274 Title: ELEMENTARY DIFFERENTIAL EQUATIONS

Computer programming course in the Department of Physics, University of Calcutta

SOLVING LINEAR SYSTEMS

GEC320 COURSE COMPACT. Four hours per week for 15 weeks (60 hours)

7 Gaussian Elimination and LU Factorization

Numerical Resolution Of The Schrödinger Equation

Numerical Solution of Differential Equations

A Brief Review of Elementary Ordinary Differential Equations

To give it a definition, an implicit function of x and y is simply any relationship that takes the form:

The Fourth International DERIVE-TI92/89 Conference Liverpool, U.K., July Derive 5: The Easiest... Just Got Better!

1 Finite difference example: 1D implicit heat equation

Separable First Order Differential Equations

Modeling Rotor Wakes with a Hybrid OVERFLOW-Vortex Method on a GPU Cluster

Integration. Topic: Trapezoidal Rule. Major: General Engineering. Author: Autar Kaw, Charlie Barker.

Outline Servo Control

Definition and Properties of the Production Function: Lecture

Numerical Matrix Analysis

NUMERICAL ANALYSIS PROGRAMS

Similarity and Diagonalization. Similar Matrices

GPU Computing with CUDA Lecture 2 - CUDA Memories. Christopher Cooper Boston University August, 2011 UTFSM, Valparaíso, Chile

Reaction diffusion systems and pattern formation

N 1. (q k+1 q k ) 2 + α 3. k=0

Starting algorithms for partitioned Runge-Kutta methods: the pair Lobatto IIIA-IIIB

Derive 5: The Easiest... Just Got Better!

ECG590I Asset Pricing. Lecture 2: Present Value 1

Syllabus for MTH 311 Numerical Analysis

Package fastghquad. R topics documented: February 19, 2015

Today. Keyframing. Procedural Animation. Physically-Based Animation. Articulated Models. Computer Animation & Particle Systems

OpenFOAM Optimization Tools

SOFA an Open Source Framework for Medical Simulation

Lecture 5 Rational functions and partial fraction expansion

Ordinary Differential Equations

On using numerical algebraic geometry to find Lyapunov functions of polynomial dynamical systems

Vector Spaces; the Space R n

arxiv: v1 [quant-ph] 3 Mar 2016

2.2 Creaseness operator

Applied mathematics and mathematical statistics

Scalar versus Vector Quantities. Speed. Speed: Example Two. Scalar Quantities. Average Speed = distance (in meters) time (in seconds) v =

Numerical Methods. Numerical Methods. for Engineers. for Engineers. Steven C. Chapra Raymond P. Canale. Chapra Canale. Sixth Edition.

ECON20310 LECTURE SYNOPSIS REAL BUSINESS CYCLE

Short rate models: Pricing bonds in short rate models

Solving DEs by Separation of Variables.

Review of Vector Analysis in Cartesian Coordinates

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Geometric Constraints

Equilibria and Dynamics of. Supply Chain Network Competition with Information Asymmetry. and Minimum Quality Standards

A First Course in Elementary Differential Equations. Marcel B. Finan Arkansas Tech University c All Rights Reserved

Pricing Options with Discrete Dividends by High Order Finite Differences and Grid Stretching

Introduction to the Finite Element Method

Pricing Barrier Options under Local Volatility

ORDINARY DIFFERENTIAL EQUATIONS

Rigid body dynamics using Euler s equations, Runge-Kutta and quaternions.

Python. Python. 1 Python. M.Ulvrova, L.Pouilloux (ENS LYON) Informatique L3 Automne / 25

General Theory of Differential Equations Sections 2.8, , 4.1

Heavy Parallelization of Alternating Direction Schemes in Multi-Factor Option Valuation Models. Cris Doloc, Ph.D.

Transcription:

CS 294-73 Software Engineering for Scientific Computing http://www.cs.berkeley.edu/~colella/cs294fall2013 Lecture 16: Particle Methods; Homework #4

Discretizing Time-Dependent Problems From here on in, we will have occasion to solve timeevolution equations. Abstractly, these take the form of ordinary differential equations. In particle dynamics, this is how the problem is stated. {x k, v k,w k } N k=1 dx k = v k dt dv k = F (x k ) dt F (x) = X k 0 w k 0(r )(x x k 0) 2!

Discretizing Time-Dependent Problems We can convert discretizations of partial differential equations to systems of ordinary differential equations by discretizing in space first, which then leads to a system of ODEs for the spatially discretized variables. 3!

Particle Discretizations of PDE Particle discretizations fall into the latter category, since they start with a particular spatial discretization of the Lagrangian form of the equations. 4!

Discretizing ODEs To discretize ODEs, we replace derivatives by difference approximations. We will focus here on one-step methods: q is the order of accuracy of the method: Q n = Q(n Δt) + (Δt) p. Closely related to quadrature formulas for approximating integrals. 5!

Discretizing ODEs To discretize ODEs, we replace derivatives by difference approximations. We will focus here on one-step methods: q is the order of accuracy of the method: Q n = Q(n Δt) + (Δt) q. Closely related to quadrature formulas for approximating integrals. Essential question: for what choices of stable? Answer: check for are various methods Stability region is given in terms of. In the general case, s are the eigenvalues of the matrix. 6!

Discretizing ODEs Some simple examples: Forward Euler: stable if Backward Euler: stable if, Trapezoidal rule: 7!

Discretizing ODEs Generally, use implicit methods if there are modes for which, and the time step for an explicit method would be much smaller than the one required to resolve the effective dynamics. For particles, we typically use explicit methods., 8!

Discretizing ODEs Fourth-order Runge-Kutta: Generalizes Simpson s rule for integrals. 9!

Programming ODE Methods Generic programming: only want to do it once.! template <class X, class F, class dx> class RK4! {!!public: void advance(double a_time, double a_dt, X& a_state);!!protected:!!dx m_k;!!dx m_delta;!!f m_f;! };! 10!

Programming ODE Methods Generic programming: only want to do it once.! template <class X, class F, class dx>! void RK4<X,F,dX>::advance(double a_time, double a_dt, X& a_state)! {!!m_delta.init(a_state);! m_k.init(a_state);! m_f(m_k, a_time, a_dt, a_state, m_k); // compute k1!!// F::operator()(dX,Real,X,dX);! m_delta.increment(sixth, m_k); m_k*=half;! m_f(m_k, a_time+half*a_dt, a_dt, a_state, m_k); // compute k2 m_delta.increment(third, m_k); m_k*=half;!!m_f(m_k, a_time+half*a_dt, a_dt, a_state, m_k); // conpute k3 m_delta.increment(third, m_k);!!m_f(m_k, a_time+a_dt, a_dt, a_state, m_k); // compute k4 m_delta.increment(sixth, m_k);! a_state.increment(m_delta);! }! 11!

Discretizing ODEs Fourth-order Runge-Kutta: Generalizes Simpson s rule for integrals. 12!

Programming ODE Methods Generic programming: only want to do it once.! template <class X, class F, class dx>! void RK4<X,F,dX>::advance(double a_time, double a_dt, X& a_state)! {!!m_delta.init(a_state);! m_k.init(a_state);! m_f(m_k, a_time, a_dt, a_state, m_k); // compute k1 m_delta.increment(sixth, m_k); m_k*=half;! m_f(m_k, a_time+half*a_dt, a_dt, a_state, m_k); // compute k2 m_delta.increment(third, m_k); m_k*=half;!!m_f(m_k, a_time+half*a_dt, a_dt, a_state, m_k); // conpute k3 m_delta.increment(third, m_k);!!m_f(m_k, a_time+a_dt, a_dt, a_state, m_k); // compute k4 m_delta.increment(sixth, m_k);! a_state.increment(m_delta);! }! 13!

Programming Assignment 4 An experiment: PIC methods for vorticity, but regularized using the theory. Algorithmic issues Software / implementation. 14!

Regularized particle methods Particle method for vorticity transport in 2D. α < 1 essential for stability. 15!

Regularized particle methods 16!

Test Problem 17!

Particle-in-cell Methods The velocity induced by a single particle on itself is zero. 18!

Particle-in-cell Methods 19!

Particle-in-cell Methods Difficulty with particle-in-cell methods: marginally stable for long-time integration. 20!

Regularized PIC Conjecture: problem with PIC is that the regularization corresponds to alpha = 1. 21!

Division of Labor I will provide an implementation of Hockney s algorithm for computing as well as the templated RK4 class. You will implement the rest of the particle method: Deposition of charge and calculation of velocity field. The template classes X, dx, F appropriate to the PIC method. 22!

Bin Sorting class Particle{...} // Describes a single particle: position, vorticity.! vector<particle> particles;! // This is your persistent data representation of particles.! RectMDArray<vector<int> >;! // Whenever you evaluate the forces, step one will be to binsort. Each! // element of the vector contains the index into element of the! // vector<particle> particles contained in that bin.! 23!