Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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