Home > Uncategorized > VPython Feedback

VPython Feedback

Most of you have turned in some type of numerical calculation and I think I have returned a score for all of them.  However, I don’t always give very detailed feedback.  Here are some things I would like to point out after looking at your code (the plural “your” – for the whole class).

  • I think I was pretty clear that you should either create a screencast where you go over your code (and run it) or you should show the code to me in person.  Some of you instead just sent me the code.  I really shouldn’t even count this as a submission, but if you did this you need to turn it in correctly.
  • I pointed this out in class, but still there were a couple of problems with it.  I want you to create a numerical calculation and not a calculator.  What’s the difference?  I will describe this below.
  • Remember that you have to update the position of the object in order for it to move.
  • If you want 5 points for your project, it needs to model something that you couldn’t easily do on paper.  Two relatively simple examples are three masses interacting gravitationally and a ball thrown the the air with air resistance.
  • If you deal with things like the Earth and the moon, you have to be careful.  If you use a time step of 0.01 seconds, you are going to have to wait a month for the code to make the moon orbit the Earth.  A 12 hour time step would probably be small enough.
  • How do you know if your time step is small enough?  One method is to run your code and look a the results.  Next, make the time step half as big and run it again.  If you get about the same result, then your first time step was probably small enough.
  • Collisions are very difficult – but some of you tried to do some type of collision program.  Really, there is one type of “collision” that you would be able to model – a proton colliding with another proton.  Why is this one easy?  Well, there is always a force between the two protons (the Coulomb force) that is relatively simple to calculate.  As the two protons get closer, this force gets MUCH stronger.  The result is that the two particle will “bounce” off each other without even touching.  Hard sphere collisions are way more complicated – maybe we can talk about that later.
  • Don’t forget there is a difference between REAL gravity and the gravity on the surface of the Earth.  If you are dealing with the moon and the Earth, use the real gravitational formula, not the “mg” one.

Now for an example.

Projectile Motion Calculator

Suppose I wanted to calculate where an object would land after being shot at some angle on a flat surface.  I could write the following code (this is just pseudo code).

  • Start with the initial velocity and the angle (and the initial position).  Find the x-velocity and the y-velocity.
  • Use the kinematic equations and the y-velocity to calculate the the time the object is in the air.
  • Use this time and the kinematic equations to find the final x-position.

This would give you a nice answer, but it’s just a calculation.

Projectile Motion Numerical Calculation

If you start with the same initial conditions, here is what the numerical calculation would look like:

  • Calculate the force on the object (this would just be the gravitational force)
  • Use this force to find the new momentum of the object after some short time interval.
  • Use the momentum to find the new position of the object after some short time interval.
  • Update time.
  • Repeat until the object gets back down to the ground.

It might seem more complicated to do this problem numerically – however, the idea is very useful (especially for more complicated problems).

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: