Simulation Time-stepping and Monte Carlo Methods Random Number Generation Shirley Moore CS 1401 Spring 2013 March 26, 2013.

Slides:



Advertisements
Similar presentations
Agenda 1) Warm-Up 5 min 2) Vocab. Words 10 min 3) Projectile Motion Intro. 15 min 4) Pre-Lab Vectors 15 min 5) Vector Lab 30 min Spring scale.
Advertisements

Chapter 5 Projectile Motion and Satellites. Projectile Motion Describe the motion of an object in TWO dimensions Describe the motion of an object in TWO.
Air resistance is a form of friction that acts to slow down any object moving in the air. Air resistance is a force that gets larger as an object moves.
What is Projectile Motion?. Projectile Motion Two-dimensional motion of an object –V–Vertical –H–Horizontal.
Linear Impulse & Linear Momentum
Frank L. H. WolfsDepartment of Physics and Astronomy, University of Rochester Physics 121. Tuesday, January 29, This is where your instructor grew.
Unit 8 POE Ballistic Device
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 13.
Physics Chapter 6 Forces. Newton’s Laws of Motion 1 st Law (Law of inertia) –An object moving at constant velocity keeps moving at that velocity unless.
Motion occurs when an object changes position.
Simulation of Random Walk How do we investigate this numerically? Choose the step length to be a=1 Use a computer to generate random numbers r i uniformly.
AGENDA 31-OCT Binder check today! Binder check today! Notes - Projectile Motion Notes - Projectile Motion CW - Plotting Projectile Motion Activity &
Chapters 7 & 8 Rotational Motion and The Law of Gravity.
Kinetic Energy, Work, Power, and Potential Energy
Kinetic Energy, Work, Power, and Potential Energy
Chapter 3 – 2D Motion Definitions Projectile motion.
Projectile Motion I 9/30/13. Bellwork What is free fall? The motion of an object under the influence of the gravitational force only (no air resistance)
Roll and Fall Playing with the Laws of Motion Games Fundamentals © by Jarek Francik Kingston University, London
Some Uses of Probability Randomized algorithms –for CS in general –for games and robotics in particular Testing Simulation Solving probabilistic problems.
PHYS 1441 – Section 002 Lecture #7 Wednesday, Feb. 6, 2013 Dr. Jaehoon Yu What is the Projectile Motion? How do we solve projectile motion problems? Maximum.
Free Fall Motion Notes Day 4.
Motion. Some Motion Terms Distance & Displacement Velocity & Speed Acceleration Uniform motion Scalar.vs. vector.
Two Dimensional Kinematics. Position and Velocity Vectors If an object starts out at the origin and moves to point A, its displacement can be represented.
Chapter 6 Forces In Motion
Thursday, Sept. 11, 2014PHYS , Fall 2014 Dr. Jaehoon Yu 1 PHYS 1443 – Section 004 Lecture #6 Thursday, Sept. 11, 2014 Dr. Jaehoon Yu Motion in.
Projectile Motion Notes and Practice Vocabulary Projectile Trajectory Gravity Acceleration due to gravity (g) Terminal Velocity Horizontal Component.
Chapter 2 Motion Motion. Motion Want to describe bodies in motion and how they behave in time Want to describe bodies in motion and how they behave in.
Physics 215 – Fall 2014Lecture Welcome back to Physics 215 Today’s agenda: Relative motion.
Vectors and Linear Motion. Vector Quantities: Have a magnitude And direction ex: meters, velocity, acceleration Scalar Quantities: Have only a magnitude.
Linear Impulse & Linear Momentum Lecture VIII. Introduction From Newton ’ s 2 nd Law:  F = m a = m v. = d/dt (m v) The term m v is known as the linear.
Physics 2048 Spring 2008 Lecture #4 Chapter 4 motion in 2D and 3D.
Chapter 3 Nonlinear Motion Scalar quantity a quantity that has magnitude but not direction.
Ch. 6: Circular Motion & Other Applications of Newton’s Laws
CS177 RECITATION WEEK 7 Input and Output (Text & Graphical)
Physical Science Chapter 6 Forces & Motion Section 1 Gravity and Motion Objs fall to the ground at the same rate because the acceleration due to G is.
Monday, Sept. 13, 2004PHYS , Fall 2004 Dr. Jaehoon Yu 1 1.Motion in two dimension Motion under constant acceleration Projectile motion Heights.
Motion in Two Dimensions Chapter 6. Motion in Two Dimensions  In this chapter we’ll use what we learned about resolving vectors into their x- and y-components.
Projectile Motion Projectile motion: a combination of horizontal motion with constant horizontal velocity and vertical motion with a constant downward.
Computer Science 320 Reduction. Estimating π Throw N darts, and let C be the number of darts that land within the circle quadrant of a unit circle Then,
Introduction to Methods Shirley Moore CS 1401 Spring 2013 cs1401spring2013.pbworks.com April 1, 2013.
2.1 Functions. Functions in Mathematics f x y z f (x, y, z) Domain Range.
Projectiles Motion in Two Dimensions Chapter 7. Projectile An object launched into the air by a force Trajectory The path followed by a projectile.
Iterative Structures (Loops) CS 1401 Spring 2013 Shirley Moore, Instructor February 28, 2013.
Kinematics Kinematics is the branch of physics that describes the motion of points, bodies (objects) and systems of bodies (groups of objects) without.
Monday, Mar. 10, 2008 PHYS , Spring 2008 Dr. Jaehoon Yu 1 PHYS 1441 – Section 002 Lecture #14 Monday, Mar. 10, 2008 Dr. Jaehoon Yu Uniform Circular.
Gravity and Motion. Galileo’s Story Gravity and Acceleration Objects fall to the ground at the same rate because the acceleration due to gravity is the.
Gravity Chapter Gravity Law of Universal Gravitation- all objects in the universe attract each other through gravitational force Law of Universal.
ForcesGravityNet ForcesFree Body Diagrams Misc Forces and Motion FINAL JEOPARDY Go To Score Card.
Lecture 12 Chapter 8: Solve 2D motion problems with friction
PHYS 1441 – Section 002 Lecture #7
Motion In Two-Dimensional
PHYS 1443 – Section 001 Lecture #4
Recall projectile motion:
Chapter 4 motion in 2D and 3D
Last Time: Vectors Introduction to Two-Dimensional Motion Today:
PHYS 1443 – Section 003 Lecture #3
Projectile Motion A projectile is an object moving in two or three dimensions only under the influence of gravity.
PHYS 1441 – Section 002 Lecture #8
PHYS 1441 – Section 002 Lecture #7
Chapter 4 motion in 2D and 3D
Introduction to projectile motion MANDATORY experiment
How to draw, read, and work with free body diagrams.
PHYS 1443 – Section 001 Lecture #5
Chapter 4 motion in 2D and 3D
Physics 2048 Spring 2008 Lecture #4 Chapter 4 motion in 2D and 3D.
Coverage of the 1st Long test
Velocity and Acceleration
Introduction to 2D Projectile Motion
Vector addition allows us to consider movement in 2-D
Presentation transcript:

Simulation Time-stepping and Monte Carlo Methods Random Number Generation Shirley Moore CS 1401 Spring 2013 March 26, 2013

Agenda Announcements Time-stepping simulation Lab 5 Wrapup Using random number methods Monte Carlo simulation Assignments for Tuesday, April 2 Review and practice for Exam 2 Fun and review! Google Blockly Maze

Announcements Two talks this Thursday at 12:00 and 1:00 (see course website for details) Exam 2 on Thursday, practice and review in class and lab today Unit 3 plan on course website

What is Computer Simulation? Modeling real-world phenomena with computational algorithms – Normally requires some assumptions and approximations/simplifications Aside: Are You Living In a Computer Simulation? ORIGINAL Nick Bostrom. Philosophical Quarterly, 2003, Vol. 53, No. 211, pp , argument.comAre You Living In a Computer Simulation? ORIGINAL Nick Bostrom. Philosophical Quarterly, 2003, Vol. 53, No. 211, pp Types of computer simulations – Time-stepping simulations – Monte Carlo simulations

Time-Stepping Simulations Simulate continuous time with a loop Each iteration of the loop is called a time-step and models an interval of time (e.g., 1 second, 0.01 second, 1 hour, 1 day, etc.) – Relevant physical quantities are updated each time stamp according to physical laws Examples – Lab 5 Project Motion Simulation – Climate Change Simulation

2D Projectile Motion Simulation In each time step (i.e., loop iteration), the statements in the loop body calculate approximately what happens to the projectile: – The projectile MOVES (changes position where position is given by x,y coordinates) because its velocity (with components in the horizontal x and vertical y directions) is not zero. – The projectile’s vertical velocity CHANGES because of the effect of gravity.

How does position change during one time step? Change in a given direction is velocity in that direction multiplied by the time step. – e.g., If you are driving a car north at 40 miles an hour (velocity), then in 15 minutes = 0.25 hour (time step), your have gone 40 * 0.25 = 10 miles, so position  position + 40 * 0.25 For the projectile motion simulation x  x + vx * dt y  y + vy * dt

How does the velocity change during one time step? Horizontal velocity doesn’t change – Newton’s First Law of Motion – Our model simplifies away air friction Vertical velocity is reduced by effect of gravity – Newton’s Second Law of Motion – Again simplifying away air friction – Near Earth’s surface, gravity makes free falling objects accelerate at a rate of -9.8 (meters per second) per second i.e., -9.8 is the change in velocity that occurs each second So, vy  vy + (-.9.8) * dt

Simulation Errors What are sources of error in our projectile motion simulation? – Model simplifications – Computational approximations

Climate Change Simulation Climate change as simulated by the NCAR CCSM: Community Earth System Model (CESM) (formerly CCSM): Very, Very Simple Climate Model: tml tml

Projectile Motion Calculations Calculations inside the loop body t = t + dt

Random Number Generation Math.random() is a Java method that returns a (pseudo)-random double value d such that 0.0 <= d < 1.0 How can you use this method to generate a random integer in a given range – e.g., 1 to 6? Write a loop that randomly tosses a 6-sided die.

Monte Carlo Simulation Example // Estimate π using Monte Carlo simulation public class MonteCarloSimulation { public static void main(String[] args) { final int NTRIALS = ; int nHits = 0; double x, y; // Randomly generate NTRIALS points in 2x2 square // centered at origin and count how many // land inside unit circle. Ratio of circle area to // square area is π/4. for (int i = 0; i < NTRIALS; i++) { x = Math.random() * 2.0 – 1; y = Math.random() * 2.0 – 1; if (x*x + y*y <= 1.0) nHits++; } double pi = 4.0 * (nHits/NTRIALS); System.out.println(“PI is “ + pi); } Actually, the above program has a bug and will always output 0.0. Can you find the bug and fix it?