Skip to content

Instantly share code, notes, and snippets.

@emwdx
Created August 22, 2012 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emwdx/3420672 to your computer and use it in GitHub Desktop.
Save emwdx/3420672 to your computer and use it in GitHub Desktop.
Simple script for generating position vs. time data for a constant velocity particle.
# Written by Evan Weinberg
# This program creates a table of values of a particle moving at constant velocity as a function of time.
# The velocity, position, and time at the beginning of the interval can all be set in the lines below.
velocity = -1.5
initial_x = 18
delta_t = 0.1
total_T = 10
current_x = initial_x
current_time = 0
total_steps = total_T*1./delta_t
current_step = 0
while(current_step<=total_steps):
print "Time: %s Current Position: %s" % (current_time, current_x)
current_time += delta_t
current_x = current_x + velocity*delta_t
current_step += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment