<jupyter_start><jupyter_text>Create a simple solar system model<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from collections import namedtuple<jupyter_output><empty_output><jupyter_text>Define a planet class<jupyter_code>class planet():
    "A planet in our solar system"
    def _init_(self,semimajor,eccetricity):
        self.x   = np.zeros(2)
        self.v   = np.zeros(2)
        self.a_g = np.zeros(2)
        self.t  = 0.0
        self.dt = 0.0
        self.a  = semimajor
        self.e  = eccentricity
        self.istep  = 0
        self.name   = ""<jupyter_output><empty_output><jupyter_text>Define a dictionary with some constants<jupyter_code>solar_system = { "M_sun":1.0, "G":39.4784176043574320}<jupyter_output><empty_output><jupyter_text>Define some functions for setting circular velocity, and acceleration<jupyter_code>def SolarCircularVelocity(p):
    
    G = solar_system["G"]
    M = solar_system["M_sun"]
    r = ( p.x[0]**2 + p.x[1]**2 )**0.5
    
    return (G*M/r)*0.5

def SolarGravitationalAcceleration(p):
    
    G = solar_system["G"]
    M = solar_system["M_sun"]
    r = ( p.x[0]**2 + p.x[1]**2 )**0.5
    
    a_grav = -1.0*G*M/r**2
    
    if(p.x[0]==0.0):
        if(p.x[1]>0.0):
            theta = 0.5*np.pi
        else:
            theta = 1.5*np.pi
    else:
        theta = np.arctan2(p.x[1],p.x[0])
        
    return a_grav*np.cos(theta), a_grav*np.sin(theta)<jupyter_output><empty_output><jupyter_text>Compute the timestep<jupyter_code>def calc_dt(p):
    
    ETA_TIME_STEP = 0.0004
    
    eta = ETA_TIMME_STEP
    v = (p.v[0]**2 + p.v[1]**2)**0.5
    a = (p.a_g[0]**2 + p.a_g[1]**2)**0.5
    dt = eta * np.fmin(1./np.fabs(v),1./np.fabs(a)**0.5)
    
    return dt<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15582959641255606, 'fraction_numerical': 0.044282511210762335, 'mean_word_length': 2.8552915766738662, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 22, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '48441', 'license': 'MIT', 'n_tokens_mistral': 785, 'n_tokens_neox': 755, 'n_words': 118, 'path': 'astr-119.15.ipynb', 'repo_name': 'ShioMura/astr-119-session-15', 'size': '1784'}