Created
August 22, 2012 00:06
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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