New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Science and Computers I

by: Clement Bernier

Science and Computers I PHY 307

Marketplace > Syracuse University > Physics 2 > PHY 307 > Science and Computers I
Clement Bernier
GPA 3.64


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in Physics 2

This 25 page Class Notes was uploaded by Clement Bernier on Wednesday October 21, 2015. The Class Notes belongs to PHY 307 at Syracuse University taught by Staff in Fall. Since its upload, it has received 26 views. For similar materials see /class/225633/phy-307-syracuse-university in Physics 2 at Syracuse University.


Reviews for Science and Computers I


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/21/15
Lec2 mechanics and simple simulation Newton s laws Euler method 1D and 2D examples projectiles harmonic motion damping Simulation code and graphics More on functions Newton s laws One particle one dimension d1 IU gt v azFm dt First order form important Generalize to three dimensions and many par ticles later Definitions of velocity and acceleration Euler I What is meant by derivatives Nothing more than dz m 512t I dt It dt Chi gt0 dt Insert in first of Newton39s laws dtvt N 1t dt 51215 turning this around 1t dt 51215 dtvt If know 110 and use a small enough time step dt will give approx for 1t I dt Do same for vt dt Euler II Divide time into discrete steps 26 ndtn 01 Full algorithm xn1 ndtvn vn1 vn l thnm Note L n E xndt Start from some 120110 Generate 121111 then 122112 keep going Accurate to Odt Note F can be Ftxv Python no automatic scaling of window from Visual import no automatic scaling of window sceneautoscale0 size of window scenerange100 standard Python 3D object ballsphereradius05pos0800 ballvelvector000 dt001 tO loop over time for ever while 1 rate100 ttdt ballposballposballveldt ballvelballvelballposdt Comments Simple oscillator rate is a Python function whth controls the speed at which graphics is drawn to the screen A large argument means a faster simulation in real time sphere is a standard Python object It may have a number of attributes such as po sition color size etc You may also add attributes such as here velocity which is defined to be a vector Since VPython is a 3D environment we must work with vectors No automatic scaling of window to simula tion Fix size of window with range explic itly Indentation Structures like if while typically act on a group of Python commands You can tell which ones by the level of inden tation E9 in the last code the lines rate100 ttdt ballpos ballvel are all carried out in the while loop IDLE automatically idents codes that follows such a command Indentation II Such structures can be nested eg in the root program while ulgttol mul05 fmeXpmO5 if fmfugt00 um The statements m and iffmfugt00 are under control of the while command The statement um is separately under control of the if command Real oscillators Can add drag force f 2 km Python code line changes ballvelballvelballposO1ballveldt Notehere k 01 what happens larger k Damped oscillations overdamping Linear damping analytic solution possible but not in general But numerically easy to change to say f kv2 2D Motion Identical equations for all components eg 1234 and oxwy eg new equations for y motion dy v ddt y y 2 F dt ym Same Python code will automatically integrate them Just need to change initial conditions to have vytO 750 10 Drawing the path Nice with 2D3D problems to visualize the tra jectory Need the track attribute from Visual import no automatic scaling of window sceneautoscale0 scenerange100 use a standard Python 3D object to represent part ballsphereradius05pos0800 trackcurveradius01 ballvelvector550 dt001 tO while 1 rate100 ttdt ballposba11posballveldt ballvelba11velballposdt balltrackappendposballpos 11 Projectiles revisited Change force to form O 10 Gravity near Earth s surface ballsphereradius05posvector900 trackcurveradius01 ballvelvector330 dt001 t0 forcevectorO1000 true1 while true rate100 ttdt ballposba11posballveldt ballvelba11velforcedt balltrackappendposballpos if ballylt00 true0 12 General program for 1 particle damped 2d oscillator def forceposvelt result vector000 resultx10posxO1velx resulty10posyO1vely resultz0 return result ballsphere ballvelvector dt001 t0 while 1 ballposballposdtballVel ballvelballveldtforceba11posvelpost ballmass 13 Comments a mass is a user defined attribute a force function takes vector arguments and returns objects of type vector 0 return is keyword like if while etc 14 Lec2 IVIore mechanics Summary of Iec1 D gt 1 Python functions Drawing tracks Lissajou figures Better integrators than Euler leapfrog Summary 0 What is Computational Science Discipline concerned with solving math ematical models of physical systems us ing computers Small systems exact solutions Large systems simulations Model ing New types of phenomena not visi ble with few dof o Earliest origins in trying to predict motions in solar system mechanics gravity 0 Mechanics simplest method or algorithm to solve Newton s laws on computer Euler method Python code Create a code eulerpy Inside from visual import no automatic scaling of window sceneautoscale0 size of window scenerange100 standard Python 3D object ballsphereradius05pos0800 ballvelvector000 dt001 t0 loop over time for ever while1 rate100 ttdt ballposballposballveldt ballvelballvelballposdt General forces Nice to rewrite Python code to make it easier to keep the force definition separate from the Euler update from force import while1 rate100 ttdt ballposballposballveldt ballvelballvel forceballposballve1ballmassdt Need a new code in file forcepy Force function 2d oscillator def forceposvel result vector000 resultx10posx resulty10posy resultz0 return result Comments def force is followed by code defining what the function does Note indentation showing the lines of code inside the definition force function takes vector arguments and returns object result of type vector resultx gives x component of vector return iS keyword like import def while etc Drawing the path Nice with 2D3D problems to visualize the tra jectory Need the track attribute which adds an object of type curve which is standard in VPython ballsphereradius05pos0800 trackcurveradius01 ballvelvector550 dt001 t0 while 1 rate100 ttdt ballposballposballveldt ballvelballvelforcedt balltrackappendposballpos curve curve is really a list of coordinate points which can be dynamically added to Also knows how to plot itself to the screen Can be given attributes like radius color etc Like other standard prthon objects can be added as an attribute to SphereO Lissajou figures o Imagine using different harmonic springs in each direction What is resulting motion a Does motion close on finite length trajec tory When What condition is needed a Finite orbits termed Lissajou figures 10 Time step errors The Euler method we have used so far has its limitations solution accurate to 0dt only Why error per step 0dt2 Total steps Tdt Total error dtQTdt Tdt See this by computing energy E 12mv2 1213322 Compute error as function of dt Note calculate mean error over some finite period of time see code Can do better 11 Summary Functions Separate off code for particu lar force from code to integrate Newton s laws Easier to debug Less code to write when tackling new situation 2D3D Drawing tracks Playing with harmonic forces Better integrators leapfrog 14


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Allison Fischer University of Alabama

"I signed up to be an Elite Notetaker with 2 of my sorority sisters this semester. We just posted our notes weekly and were each making over $600 per month. I LOVE StudySoup!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.