Beispiel #1
0
    def __init__(self, name):
        super(SolarSystemApp, self).__init__(name)

        self.solar_system_widget = SolarSystem(self.default_width,
                                               self.default_height)
        self.use_default_layout(self.solar_system_widget)
        pass
Beispiel #2
0
    def test_period_graph_update(self, beeman, plot, show):
        try:
            system = SolarSystem(3600, 10.175 * 10**3, Options.NORMAL_RUN,
                                 "CelestialObjects")

            Animation.periods_graph(100, system)
        except ZeroDivisionError as err:
            self.assertEqual(100, beeman.call_count)
Beispiel #3
0
def main():
    """
    Main function
    """
    system = SolarSystem(3600, 11.5517 * 10**3, Options.PROBE_RUN,
                         "CelestialObjects")
    animate = Animation(system)
    animate.plot()
Beispiel #4
0
 def test_plot_show(self, mock):
     """Test to prove that plt.show is called in plot() method.
     Uses mocking
     """
     self.system_probe = SolarSystem(3600, 10000, Options.PROBE_RUN,
                                     "CelestialObjects")
     animate = Animation(self.system_probe)
     animate.plot()
     mock.assert_called()
Beispiel #5
0
 def test_scatterplot_show(self, mock):
     """Test used to prove that plt.show() is called once in scatter_plot method
     uses mocking
     """
     self.system_probe = SolarSystem(3600, 10000, Options.PROBE_RUN,
                                     "CelestialObjects")
     animate = Animation(self.system_probe)
     animate.scatter_plot(100)
     mock.assert_called_once()
Beispiel #6
0
 def energy_graph_comparisson(updates):
     """Function used to generate a comparison graph between Euler's method and Beeman's
     to show conservation (or not conservation) of energy in both methods
     """
     system = SolarSystem(3600, 10.175 * 10**3, Options.NORMAL_RUN,
                          "CelestialObjects")
     energy_1 = [system.get_energy()]
     system2 = SolarSystem(3600, 10.175 * 10**3, Options.NORMAL_RUN,
                           "CelestialObjects")
     energy_2 = [system2.get_energy()]
     iterate = updates
     iterations = [i * 3600 for i in range(iterate + 1)]
     for i in range(iterate):
         energy_1.append(system.update_beeman())
         energy_2.append(system2.update_euler())
     plt.xlabel('time(s)')
     plt.ylabel('Energy [J]')
     plt.plot(iterations, energy_1, iterations, energy_2)
     plt.show()
Beispiel #7
0
 def test_Adding_Planet(self):
     """Test used to check that the method add_planet can add a planet correctly into a system.
     """
     self.write.add_planet("test",1,1,1,"blue","test")
     system = SolarSystem(1,1,Options.PROBE_RUN,"test")
     self.assertEqual(len(system.celestial_bodies),7)
     self.assertEqual(system.celestial_bodies[len(system.celestial_bodies)-1].name,"test")
     self.assertEqual(system.celestial_bodies[len(system.celestial_bodies)-1].mass,1)
     self.assertEqual(system.celestial_bodies[len(system.celestial_bodies)-1].orbital_radius,1)
     self.assertEqual(system.celestial_bodies[len(system.celestial_bodies)-1].type_of_object,"Planet")
Beispiel #8
0
 def test_animate_update(self, mock, mock2):
     """Test used to prove that update beeman is calld in the animate method
     Uses mocking.
     """
     self.system_probe = SolarSystem(3600, 10000, Options.PROBE_RUN,
                                     "CelestialObjects")
     animate = Animation(self.system_probe)
     animate.plot()
     animate.init()
     animate.animate(0)
     mock.assert_called()
Beispiel #9
0
 def test_scatterplot_update(self, mock, mock2):
     """Test used to prove that update_beeman() is called 100 times in scatter_plot method
     if the parameter passed to scatter_plot is 100.
     uses mocking
     """
     self.system_probe = SolarSystem(3600, 10000, Options.PROBE_RUN,
                                     "CelestialObjects")
     animate = Animation(self.system_probe)
     animate.scatter_plot(100)
     mock.assert_called()
     self.assertEqual(mock.call_count, 100)
Beispiel #10
0
    def test_plot_animate(self, mock, mock2):
        """Test used to check that a FunCAnimator is used in plot()
        Uses mocking

        """
        mock.return_value = None
        self.system_probe = SolarSystem(3600, 10000, Options.PROBE_RUN,
                                        "CelestialObjects")
        animate = Animation(self.system_probe)
        animate.plot()
        mock.assert_called()
Beispiel #11
0
def search_velocity_to_mars(updates, tries, velocity):
    """Function used to searc for the optimal velocity for the probe to approach mars
    it will do it by try and error over different values.

    Returns:
        (float,float): tuple of distance the minimum distance found and the speed needed to
        accomplish it.
    """
    start_velocity = velocity
    system = SolarSystem(3600, start_velocity, Options.PROBE_RUN,
                         "CelestialObjects")
    min_v = 0
    increment = 0.001
    minimum = system.distance_to_mars()
    for i in range(tries):
        system = SolarSystem(3600, start_velocity + i * increment,
                             Options.PROBE_RUN, "CelestialObjects")
        for j in range(updates):
            system.update_beeman()
            if minimum >= system.distance_to_mars():
                minimum = system.distance_to_mars()
                min_v = start_velocity + i * increment
    return (minimum, min_v)
Beispiel #12
0
 def test_beeman(self):
     """Test used to check that Beeman's method works appropiatley.
     """
     planetA = CelestialBody("B",1,1,1,"Planet",1,10000,"blue")
     star = CelestialBody("A",1,1,1,"Star",0,10000,"blue")
     planetB = CelestialBody("B",1,2,1,"Planet",1,10000,"blue")
     planetB.position = np.array([-1.0,0.0])
     planetB.velocity = np.array([0.0,-planetA.velocity[1]])
     system = SolarSystem(3600,1000,Options.NORMAL_RUN,"CelestialObjects")
     system.celestial_bodies = [star,planetA,planetB]
     system.update_initial_acceleration()
     for i in range(100):
         system.update_beeman()
     self.assertEqual(0.0,star.acceleration[0])
     self.assertEqual(0.0,star.acceleration[1])
def main():

    t = 0
    dt = 1
    s = SolarSystem(2.50e+11, "Solar System", dt, 3)

    # Data info
    # initial conditions obtained from date: A.D. 2020 - Jul - 18
    # vector ephemeris data is obtained from: https://ssd.jpl.nasa.gov/horizons.cgi#top
    # km/s converted to m/s

    s.add_body(
        Particle(1.9890e+30, -8.115575219749061E+05, 1.023358542970559E+06,
                 1.030475383803935E+04, -1.367124428632311E+01,
                 -7.255536346983386E0, 3.953653246527174E-01, 7.000E+06,
                 "Sun"))
    # #
    s.add_body(
        Particle(6.4190e+23, 1.700911233235551E+08, -1.154793014669231E+08,
                 -6.623490315706909E+06, 1.455681174959298E+04,
                 2.208572786142721E+04, 1.059053211570298E+03, 4.000E+05,
                 "Mars"))
    #
    #
    # s.add_body(Particle(5.9740e+24, 6.478846194962674E+07, -1.361379609312382E+08, 1.655851550595462E+04,
    #                     2.638665577941761E+04, 1.273331100378729E+04, -1.385515264764159E00, 5.000E+06, "Earth"))

    # s.add_body(Particle(1.8982E+27, 2.925974889403378E+08, -7.120923141565894E+08, -3.592415407148212E+06,
    #                     1.192504812263601E+04, 5.588195368858322E+03, -2.898746577296276E+02, 8.000E+06, "Jupiter"))

    # s.add_body(Particle(7.34767309E+22, 6.484283712254966E+07, -1.357523313359251E+08, 1.235756001138687E+04,
    #                     2.538303859564986E+04, 1.282111106220561E+04, 9.061949758449295E+01, 5.000E+04, "Moon (Earth)"))

    while t < 25000:

        vpy.rate(100)
        s.net_forces()
        s.acceleration()
        s.velocity()
        t += dt

    s.plot()
from solar_system import SolarSystem
from solar_time import UniversalTime

ss = SolarSystem()

ut = UniversalTime(year=2020, month=3, day=14, hour=0, minute=0, second=0)

ss.plot_planets(ut, [0, 1, 2, 3])
Beispiel #15
0
 def test_period_graph_plot(self, plot, show):
     system = SolarSystem(1000000, 10.175 * 10**3, Options.NORMAL_RUN,
                          "CelestialObjects")
     system.celestial_bodies = system.celestial_bodies[0:2]
     Animation.periods_graph(10, system)
     show.assert_called_once()
Beispiel #16
0
    vx0 = vars.vx0
    vy0 = vars.vy0
    a = vars.a
    e = vars.e
    theta0 = vars.theta0
    psi0 = vars.psi0
    radius = vars.radius
    m_star = vars.m_star
    m = vars.m

    G = vars.G

    names = ['Matsat','sunsun', 'Dum','og', 'Deilig', 'Juba', 'juba', 'Pizzatryne', 'Verdens ende']
    sun_name = 'pleb'

    fullmugg = SolarSystem()
    sunsun = Sun(m_star, 0.001, np.array([0,0]), np.array([0,0]), 100000, 'sunsun')
    fullmugg.addSun(sunsun)

    masses = np.concatenate((np.array([m_star]), m))

    radius = np.concatenate((np.array([vars.radius_star]), radius))
    x0 = np.concatenate((np.array([0]), x0))
    y0 = np.concatenate((np.array([0]), y0))
    vx0 = np.concatenate((np.array([0]), vx0))
    vy0 = np.concatenate((np.array([0]), vy0))

    initial_rocket_mass = 1.456e+05/1.989e30
    m_sat = 1100/1.989e30

    m_rock = np.array([m_sat])
Beispiel #17
0
 def test_WrittingFile(self):
     """Test used to check that the method write_file works correctly.
     """
     system = SolarSystem(1,1,Options.PROBE_RUN,"test")
     self.assertEqual(len(system.celestial_bodies),6)