Molecular dynamics simulation of hard discs. Goal. Simulate the motion of N moving particles that behave according to the laws of elastic collision.

Similar documents
momentum change per impact The average rate of change of momentum = Time interval between successive impacts 2m x 2l / x m x m x 2 / l P = l 2 P = l 3

(1) The size of a gas particle is negligible as compared to the volume of the container in which the gas is placed.

Vacuum Technology. Kinetic Theory of Gas. Dr. Philip D. Rack

CLASSICAL CONCEPT REVIEW 8

Chapter 7: Momentum and Impulse

Study the following diagrams of the States of Matter. Label the names of the Changes of State between the different states.

Physics 9e/Cutnell. correlated to the. College Board AP Physics 1 Course Objectives

Kinetic Molecular Theory and Gas Laws

cs2010: algorithms and data structures

PHYSICAL QUANTITIES AND UNITS

Kinetic Theory of Gases. Chapter 33. Kinetic Theory of Gases

Notes on Elastic and Inelastic Collisions

Online Courses for High School Students

Kinetic Theory of Gases

Tennessee State University

Chapter 9. particle is increased.

A. Kinetic Molecular Theory (KMT) = the idea that particles of matter are always in motion and that this motion has consequences.

Physics 125 Practice Exam #3 Chapters 6-7 Professor Siegel

1. The Kinetic Theory of Matter states that all matter is composed of atoms and molecules that are in a constant state of constant random motion

9. Momentum and Collisions in One Dimension*

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Q3.2.a The gravitational force exerted by a planet on one of its moons is 3e23 newtons when the moon is at a particular location.

Basics of Java Programming Input and the Scanner class

dictionary find definition word definition book index find relevant pages term list of page numbers

Topic 3b: Kinetic Theory

Conservation of Momentum Using PASCO TM Carts and Track to Study Collisions in One Dimension

Kinetic Theory: Atomic and Molecular Explanation of Pressure and Temperature

Lecture PowerPoints. Chapter 7 Physics: Principles with Applications, 6 th edition Giancoli

2.5 Physically-based Animation

Kinetic Theory & Ideal Gas

There is no such thing as heat energy

Catapult Engineering Pilot Workshop. LA Tech STEP

Statistical Mechanics, Kinetic Theory Ideal Gas. 8.01t Nov 22, 2004

Chapter #7 Giancoli 6th edition Problem Solutions

ENERGY CONSERVATION The First Law of Thermodynamics and the Work/Kinetic-Energy Theorem

Experiment 7 ~ Conservation of Linear Momentum

Thermodynamics: Lecture 8, Kinetic Theory

Science Standard Articulated by Grade Level Strand 5: Physical Science

Does Quantum Mechanics Make Sense? Size

THE IDEAL GAS LAW AND KINETIC THEORY

) and mass of each particle is m. We make an extremely small

Orbits of the Lennard-Jones Potential

Bounce! Name. Be very careful with the balls. Do not throw them DROP the balls as instructed in the procedure.

Work and Energy. Work = Force Distance. Work increases the energy of an object. Energy can be converted back to work.

An Introduction to Applied Mathematics: An Iterative Process

Kinetic Energy (A) stays the same stays the same (B) increases increases (C) stays the same increases (D) increases stays the same.

Name per due date mail box

COMPETENCY GOAL 1: The learner will develop abilities necessary to do and understand scientific inquiry.

Physics Notes Class 11 CHAPTER 6 WORK, ENERGY AND POWER

CS/COE

Chapter 7 Momentum and Impulse

Practice TEST 2. Explain your reasoning

LAB 4: MOMENTUM AND COLLISIONS

1.3 Conditionals and Loops

Problem Set #8 Solutions

APPLIED MATHEMATICS ADVANCED LEVEL

Ch 8 Potential energy and Conservation of Energy. Question: 2, 3, 8, 9 Problems: 3, 9, 15, 21, 24, 25, 31, 32, 35, 41, 43, 47, 49, 53, 55, 63

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection

Chapter 12 Kinetic Theory of Gases: Equipartition of Energy and Ideal Gas Law

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays:

Physics Momentum and Impulse Car Safety Engineering (egg drop) Conservation of Momentum

Indiana's Academic Standards 2010 ICP Indiana's Academic Standards 2016 ICP. map) that describe the relationship acceleration, velocity and distance.

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

DO PHYSICS ONLINE FROM QUANTA TO QUARKS QUANTUM (WAVE) MECHANICS

Chapter 11 Data Structures

Momentum Crash Course

STUDY PACKAGE. Available Online :

Salem Community College Course Syllabus. Course Title: Physics I. Course Code: PHY 101. Lecture Hours: 2 Laboratory Hours: 4 Credits: 4

Basic Principles in Microfluidics

PS-6.2 Explain the factors that determine potential and kinetic energy and the transformation of one to the other.

Viscoelasticity of Polymer Fluids.

Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets

Motion of a Leaky Tank Car

Candidate Number. General Certificate of Education Advanced Level Examination June 2010

10.1 Quantitative. Answer: A Var: 50+

F N A) 330 N 0.31 B) 310 N 0.33 C) 250 N 0.27 D) 290 N 0.30 E) 370 N 0.26

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright /6/11 12:33 PM!

Chapter 15 Collision Theory

TEACHER BACKGROUND INFORMATION THERMAL ENERGY

Practice Exam Three Solutions

PHY231 Section 2, Form A March 22, Which one of the following statements concerning kinetic energy is true?

Building Java Programs

DISTANCE DEGREE PROGRAM CURRICULUM NOTE:

Laws of Collision / demonstration track

Newton s Laws of Motion

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

ch 15 practice test Multiple Choice Identify the letter of the choice that best completes the statement or answers the question.

Wave Function, ψ. Chapter 28 Atomic Physics. The Heisenberg Uncertainty Principle. Line Spectrum

A uranium nucleus (at rest) undergoes fission and splits into two fragments, one heavy and the other light. Which fragment has the greater speed?

Conservation of Momentum and Energy

10.7 Kinetic Molecular Theory Kinetic Molecular Theory. Kinetic Molecular Theory. Kinetic Molecular Theory. Kinetic Molecular Theory

Forces. Definition Friction Falling Objects Projectiles Newton s Laws of Motion Momentum Universal Forces Fluid Pressure Hydraulics Buoyancy

Lab 8: Ballistic Pendulum

Losing energy in classical, relativistic and quantum mechanics

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

Chapter 8 Conservation of Linear Momentum. Conservation of Linear Momentum

Lab 7: Rotational Motion

Mobile App Tutorial Animation with Custom View Class and Animated Object Bouncing and Frame Based Animation

Gas Laws. Heat and Temperature

Transcription:

Molecular dynamics simulation of hard discs Goal. Simulate the motion of N moving particles that behave according to the laws of elastic collision. 1

Time-driven simulation Discretize time in quanta of size dt. Update the position of each particle after every dt units of time, and check for overlaps. If overlap, roll back the clock to the time of the collision, update the velocities of the colliding particles, and continue the simulation. t t + dt t + 2 dt (collision detected) t + Δt (roll back clock) 2

Time-driven simulation Main drawbacks. ~ N 2 / 2 overlap checks per time quantum. Simulation is too slow if dt is very small. May miss collisions if dt is too large. (if colliding particles fail to overlap when we are looking) dt too small: excessive computation dt too large: may miss collisions 3

Event-driven simulation Change state only when something interesting happens. Between collisions, particles move in straight-line trajectories. Focus only on times when collisions occur. Maintain PQ of collision events, prioritized by time. Delete min = get next collision. Collision prediction. Given position, velocity, and radius of a particle, when will it collide next with a wall or another particle? Collision resolution. If collision occurs, update colliding particle(s) according to laws of elastic collisions. prediction (at time t) particles hit unless one passes intersection point before the other arrives (see Exercise 3.6.X) resolution (at time t + dt) velocities of both particles change after collision (see Exercise 3.6.X) 4

Collision system: event-driven simulation main loop Initialization. two particles on a collision course Fill PQ with all potential particle-wall collisions. Fill PQ with all potential particle-particle collisions. potential since collision is invalidated if some other collision intervenes third particle interferes: no collision An invalidated event Main loop. Delete the impending event from PQ (min priority = t). If the event has been invalidated, ignore it. Advance all particles to time t, on a straight-line trajectory. Update the velocities of the colliding particle(s). Predict future particle-wall and particle-particle collisions involving the colliding particle(s) and insert events onto PQ. 5

Particle collision simulation: example 1 % java CollisionSystem 100 6

Particle collision simulation: example 2 % java CollisionSystem < billiards.txt 7

Particle collision simulation: example 3 % java CollisionSystem < brownian.txt 8

Particle collision simulation: example 4 % java CollisionSystem < diffusion.txt 9

2.4 PRIORITY QUEUES Algorithms API and elementary implementations binary heaps heapsort event-driven simulation ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu

Molecular dynamics simulation of hard discs Goal. Simulate the motion of N moving particles that behave according to the laws of elastic collision. 11

Molecular dynamics simulation of hard discs Goal. Simulate the motion of N moving particles that behave according to the laws of elastic collision. Hard disc model. Moving particles interact via elastic collisions with each other and walls. Each particle is a disc with known position, velocity, mass, and radius. No other forces. temperature, pressure, diffusion constant motion of individual atoms and molecules Significance. Relates macroscopic observables to microscopic dynamics. Maxwell-Boltzmann: distribution of speeds as a function of temperature. Einstein: explain Brownian motion of pollen grains. 12

Warmup: bouncing balls Time-driven simulation. N bouncing balls in the unit square. public class BouncingBalls { public static void main(string[] args) { int N = Integer.parseInt(args[0]); Ball[] balls = new Ball[N]; for (int i = 0; i < N; i++) balls[i] = new Ball(); while(true) { StdDraw.clear(); for (int i = 0; i < N; i++) { balls[i].move(0.5); balls[i].draw(); } StdDraw.show(50); } } main simulation loop } % java BouncingBalls 100 13

Warmup: bouncing balls public class Ball { private double rx, ry; // position private double vx, vy; // velocity private final double radius; // radius public Ball(...) { /* initialize position and velocity */ } } Missing. Check for balls colliding with each other. check for collision with walls public void move(double dt) { if ((rx + vx*dt < radius) (rx + vx*dt > 1.0 - radius)) { vx = -vx; } if ((ry + vy*dt < radius) (ry + vy*dt > 1.0 - radius)) { vy = -vy; } rx = rx + vx*dt; ry = ry + vy*dt; } public void draw() { StdDraw.filledCircle(rx, ry, radius); } Physics problems: when? what effect? CS problems: which object does the check? too many checks? 14

Time-driven simulation Discretize time in quanta of size dt. Update the position of each particle after every dt units of time, and check for overlaps. If overlap, roll back the clock to the time of the collision, update the velocities of the colliding particles, and continue the simulation. t t + dt t + 2 dt (collision detected) t + Δt (roll back clock) 15

Time-driven simulation Main drawbacks. ~ N 2 / 2 overlap checks per time quantum. Simulation is too slow if dt is very small. May miss collisions if dt is too large. (if colliding particles fail to overlap when we are looking) dt too small: excessive computation dt too large: may miss collisions 16

Event-driven simulation Change state only when something interesting happens. Between collisions, particles move in straight-line trajectories. Focus only on times when collisions occur. Maintain PQ of collision events, prioritized by time. Delete min = get next collision. Collision prediction. Given position, velocity, and radius of a particle, when will it collide next with a wall or another particle? Collision resolution. If collision occurs, update colliding particle(s) according to laws of elastic collisions. prediction (at time t) particles hit unless one passes intersection point before the other arrives (see Exercise 3.6.X) resolution (at time t + dt) velocities of both particles change after collision (see Exercise 3.6.X) 17

Particle-wall collision Collision prediction and resolution. Particle of radius s at position (rx, ry). Particle moving in unit box with velocity (vx, vy). Will it collide with a vertical wall? If so, when? resolution (at time t + dt) velocity after collision = ( v x, v y ) position after collision = ( 1 s, r y + v y dt) s prediction (at time t) dt time to hit wall = distance/velocity = (1 s r x )/v x (r x, r y ) v y wall at x = 1 v x 1 s r x Predicting and resolving a particle-wall collision 18

Particle-particle collision prediction Collision prediction. Particle i: radius s i, position (rxi, ryi), velocity (vxi, vyi). Particle j: radius s j, position (rxj, ryj), velocity (vxj, vyj). Will particles i and j collide? If so, when? (vx i ', vy i ') m i (vx j ', vy j ') s i (vx i, vy i ) (rx i, ry i ) (rx i ', ry i ') i time = t time = t + Δt (vx j, vy j ) σ j j 19

Particle-particle collision prediction Collision prediction. Particle i: radius s i, position (rxi, ryi), velocity (vxi, vyi). Particle j: radius s j, position (rxj, ryj), velocity (vxj, vyj). Will particles i and j collide? If so, when? t = v r + d v v v r 0, d<0, d = ( v r) 2 ( v v) ( r r s 2 ), s = s i + s j Δv = (Δvx, Δvy) = (vx i vx j, vy i vy j ) Δr = (Δrx, Δry) = (rx i rx j, ry i ry j ) Δv Δv = (Δvx) 2 + (Δvy) 2 Δr Δr = (Δrx) 2 + (Δry) 2 Δv Δr = (Δvx)(Δrx)+ (Δvy)(Δry) Important note: This is physics, so we won t be testing you on it! 20

Particle-particle collision resolution Collision resolution. When two particles collide, how does velocity change? vx i " = vx i + Jx / m i vy i " = vy i + Jy / m i vx " j = vx j Jx / m j vy j " = vy vx j " Jy / m j Newton's second law (momentum form) Jx = J rx s, Jy = J ry s, J = 2 m i m j ( v r) s (m i + m j ) impulse due to normal force (conservation of energy, conservation of momentum) Important note: This is physics, so we won t be testing you on it! 21

Particle data type skeleton public class Particle { private double rx, ry; // position private double vx, vy; // velocity private final double radius; // radius private final double mass; // mass private int count; // number of collisions public Particle(... ) {... } public void move(double dt) {... } public void draw() {... } public double timetohit(particle that) { } public double timetohitverticalwall() { } public double timetohithorizontalwall() { } predict collision with particle or wall public void bounceoff(particle that) { } public void bounceoffverticalwall() { } public void bounceoffhorizontalwall() { } resolve collision with particle or wall } http://algs4.cs.princeton.edu/61event/particle.java.html 22

Collision system: event-driven simulation main loop Initialization. two particles on a collision course Fill PQ with all potential particle-wall collisions. Fill PQ with all potential particle-particle collisions. potential since collision is invalidated if some other collision intervenes third particle interferes: no collision An invalidated event Main loop. Delete the impending event from PQ (min priority = t). If the event has been invalidated, ignore it. Advance all particles to time t, on a straight-line trajectory. Update the velocities of the colliding particle(s). Predict future particle-wall and particle-particle collisions involving the colliding particle(s) and insert events onto PQ. 23

Event data type Conventions. Neither particle null particle-particle collision. One particle null particle-wall collision. Both particles null redraw event. private static class Event implements Comparable<Event> { private final double time; // time of event private final Particle a, b; // particles involved in event private final int counta, countb; // collision counts of a and b public Event(double t, Particle a, Particle b) {... } create event public int compareto(event that) { return this.time - that.time; } ordered by time } public boolean isvalid() {... } valid if no intervening collisions (compare collision counts) 24

Particle collision simulation: example 1 % java CollisionSystem 100 25

Particle collision simulation: example 2 % java CollisionSystem < billiards.txt 26

Particle collision simulation: example 3 % java CollisionSystem < brownian.txt 27

Particle collision simulation: example 4 % java CollisionSystem < diffusion.txt 28