<jupyter_start><jupyter_text>10 ODE: Visualization of planetary motion (Students) Visualize the motion of the earth using vpython (based on *Computational Modelling*, <NAME> 2016, Ch 4, program 4.1 and updated for vpython-jupyter 2.x) *Complete the notebook.* (Full solutions will be posted after class.)<jupyter_code>import numpy as np
import vpython as vp

M_earth = 3.003467e-6
M_sun = 1.0

G_grav = 4*np.pi**2

def F_gravity(r, m=M_earth, M=M_sun):
    rr = np.sum(r*r)
    rhat = r/np.sqrt(rr)
    return -G_grav*m*M/rr * rhat

def vp_planet_orbit(r0=np.array([1.017, 0, 0]), v0=np.array([0, 6.179, 0]), mass=M_earth, dt=0.001):
    """Visualize 2D planetary motion with velocity verlet"""
    dim = len(r0)
    assert len(v0) == dim

    r = np.array(r0, copy=True)
    v = np.array(v0, copy=True)

    
    scene = vp.display(title="Earth around Sun", background=vp.color.black,
                      forward=vp.vec(0, 2, -1))
    planet = vp.sphere(pos=vp.vec(*r), radius=0.1, make_trail=True,
                      texture=vp.textures.earth,
                      up=vp.vec(0, 0, 1))
    sun = vp.sphere(pos=vp.vec(0, 0, 0), radius=0.2, color=vp.color.yellow,
                    emissive=True)
    sunlight = vp.local_light(pos=vp.vec(0, 0, 0), color=vp.color.yellow)
                       
    # start force evaluation for first step
    Ft = F_gravity(r, m=mass)
    while True:
        # IMPLEMENT Velocity Verlet integrator
        
        vp.rate(200)
        planet.pos = vp.vec(*r)
            

vp_planet_orbit()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1350832266325224, 'fraction_numerical': 0.040973111395646605, 'mean_word_length': 2.6518691588785046, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '115722', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 635, 'n_tokens_neox': 578, 'n_words': 138, 'path': '10_ODEs/10-ODE-visualize-planets-students.ipynb', 'repo_name': 'ASU-CompMethodsPhysics-PHY494/PHY494-resources-2018', 'size': '1564'}