The code below has almost everything required in order to show the motion of a Satellite orbiting the Earth. The satellite is given an initial position of 10 Earth radii and an initial velocity of 2000 m/s that is perpendicular to the line between the Satellite and the Earth.
- Complete the code by adding one line for for each of the comments labeled A thru F inside the while loop.
- Try different initial speeds of 2500 m/s, 3000 m/s, 3400 m/s, and 3600 m/s.
- The flags
showVelocity
andshowForce
can be changed toTrue
orFalse
depending upon whether or not you want to show velocity and force vectors. The force vector is also shown with its components perpendicular and parallel to the velocity direction.
# # Starter code for modeling the motion of a satellite around the Earth. # # We will start the satellite at an initial position of 10 Earth radii and # with an initial velocity vector that is perpendicular to the line between # the satellite and Earth. # # This isn't a typical orbital radius for satellites. It is MUCH larger than # low Earth orbit and is nearly twice as large as the geosynchronous orbit # associated with communications satellites. Instead, consider this a demo # of the mechanics involved with the gravitational force. # Define the size of the scene scene = canvas(width=600, height=600) # The following boolean flags control whether a green velocity vector and # red force vectors (and its components) are shown. showVelocity = True # Set to True or False showForce = True # Set to True or False showComponents = False # Set to True or False # Define the Earth as a sphere and assign its attributes Earth = sphere(pos=vector(0,0,0), texture=textures.earth) Earth.radius = 6.4e6 # Set the radius of the Earth, in m Earth.m = 6.0e24 # Set the mass of the Earth, in kg # Define and object for the Satellite Satellite = sphere(make_trail=True, trail_type="points", trail_radius=0.5e6, interval=10, retain=100) Satellite.radius = 1.0e6 # Not realistic of course, helps us to see it Satellite.color = color.yellow Satellite.m = 15e3 # Mass of Satellite, in kg Satellite.pos = vector(-10*Earth.radius, 0,0) # Initial Position of Satellite Satellite.v = vector(0, 2.0e3, 0) # Initial Velocity of Satellite (also try speeds of 2.5e3, 3.0e3, 3.4e3 and 3.6e3) Satellite.p = Satellite.m * Satellite.v # Initial Momentum of Satellite # Create some arrow objects to represent Velocity and Force vectors if showForce: F_scale = 7500 # Adjustment to allow us to see the vector ForceVector = arrow(pos=Satellite.pos, axis=vector(0,0,0)*F_scale, color=color.red, shaftwidth=8e5) if showComponents: ForcePerpVector = arrow(pos=Satellite.pos, axis=vector(0,0,0)*F_scale, color=color.red, shaftwidth=5e5) ForceParaVector = arrow(pos=Satellite.pos, axis=vector(0,0,0)*F_scale, color=color.red, shaftwidth=5e5) if showVelocity: v_scale = 7500 # Adjustment to allow us to see the vector VelocityVector = arrow(pos=Satellite.pos, axis=Satellite.v*v_scale, color=color.green, shaftwidth=7e5, opacity=0.5) # Define necessary constants t = 0 # Initialize the time counter to 0 seconds dt = 60 # Time step (60 s = 1 minute) G = 6.7e-11 # Gravitational Constant, N m**2 / kg**2 while True: rate(100) # Since dt = 1 minute, we see 100 minutes of animation each real second. # A - Compute the position (r) of the Satellite relative to the Earth # B - Compute the unit vector direction pointing from Earth to Satellite (rhat) # C - Compute the magnitude of the force (Fmag) on the Satellite by the Earth # D - Compute the vector force (F) on the Satellite by the Earth F = vector(0,0,0) # E - Use Momentum Principle to Update the Satellite's Momentum # F - Update the Position of the Satellite # Update the Satellite's Force Vector if showForce: ForceVector.pos = Satellite.pos ForceVector.axis = F*F_scale # Calculate the parallel and perpendicular components of the Force if showComponents: p_hat = norm(Satellite.p) ForcePara = dot(F,p_hat)*p_hat ForcePerp = F - ForcePara # Show the Force Vector Components ForceParaVector.pos = Satellite.pos ForceParaVector.axis = ForcePara*F_scale ForcePerpVector.pos = Satellite.pos ForcePerpVector.axis = ForcePerp*F_scale # Update the Satellite's Velocity Vector if showVelocity: VelocityVector.pos = Satellite.pos VelocityVector.axis = (Satellite.p/Satellite.m)*v_scale
Questions
Start out using initial speed of 2.0e3 m/s
- Can you use the dots (trail markers) to tell where the satellite is moving the fastest? the slowest?
- What phrase describes the direction of the force on the satellite at all times?
- What phrase describes the direction of the velocity (and momentum) of the satellite at all times?
- What phrase describes the direction of the CHANGE in MOMENTUM of the satellite at all times?
- At what positions is the force on the satellite perpendicular to the momentum of the satellite?
- Set the
ShowComponents
flag toTrue
. Describe the relationship between the force on the satellite and the direction of the velocity when the satellite is speeding up? - Describe the relationship between the force on the satellite and the direction of the velocity when the satellite is slowing down?
- Set the initial velocity of the satellite to 2.5e3 m/s. Describe the orbit? At what positions is the force on the satellite perpendicular to the momentum of the satellite?
- Set the initial velocity of the satellite to 3.4e3 m/s and increase the rate to 1000 to speed the animation up. Observe the motion. Now try an initial velocity of 3.6e3 m/s and observe the motion. Do you notice a fundamental difference in the motion for these two initial conditions?