Skip to content
Data_structure.py 4.38 KiB
Newer Older
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Sun May 12 19:51:18 2019

@author: MAC
"""

import Engineering_tools as et

RETROGRADE_ORBIT = 90

class Rocket():

    def __init__(self, stage1, stage2, payload, launch_coordinates):
        """stage1 and stage2 are instances of the class Stage,
        payload is an instance of the class Payload,
        launch_coordinates = {latitude(deg), longitude(deg)}
        
        :param stage1: [description]
        :type stage1: [type]
        :param stage2: [description]
        :type stage2: [type]
        :param payload: [description]
        :type payload: Payload
        :param launch_coordinates: [description]
        :type launch_coordinates: [type]
        """
        
        self.stage1 = stage1
        self.stage2 = stage2
        self.payload = payload
        self.injection_velocity = et.final_target_vel(self.payload.perigee_altitude,
                                                      self.payload.target_orbit.a)
        self.launch_coordinates = launch_coordinates
        if self.payload.target_orbit.i > RETROGRADE_ORBIT: # retrograade orbit
            self.initial_velocity = et.initial_vel(self.launch_coordinates['latitude'],retrograde=True)
        else:
            self.initial_velocity = et.initial_vel(self.launch_coordinates['longitude'])
        
    def target_Vc(self, p_losses):
        """Compute the target critical velocity losses : velocity losses approximation (m.s-1)
        
        :param p_losses: [description]
        :type p_losses: [type]
        """
        
        self.target_Vc = self.injection_velocity - self.initial_velocity + p_losses
        
    def __str__(self):
        return 'Rocket'
    
class Stage():
    
    def __init__(self, stage_number, number_of_engines = 9, avionics_mass=0):
        """
        stage_number : 1 or 2
        
        """
        self.stage_number = stage_number
        self.number_of_engines = number_of_engines
        self.avionics_mass = 0
    
    def tank_mass(self):
        pass
        
    def __str__(self):
        return 'Stage'
        
class Payload():

    def __init__(self, mass, target_orbit):
        """ Payload
        
        :param mass: [description]
        :type mass: [type]
        :param target_orbit: [description]
        :type target_orbit: TargetOrbit
        """

        self.mass = mass
        self.target_orbit = target_orbit
        self.perigee_altitude = target_orbit.a * (1 - target_orbit.e)
        
    def __str__(self):
        return 'Payload'

    
class Engine():
    """
    """
    
    cycle_type=''
    
    def __init__(self, oxidiser, fuel, thermo_cycle, exit_section_area):
        """
        """
        self.oxidiser = oxidiser
        self.fuel = fuel
        self.thermo_cycle = thermo_cycle
        self.exit_section_area = exit_section_area
        
    def __str__(self):
        return 'Engine'

class TargetOrbit():

    def __init__(self, a, e, i, capital_omega, small_omega, nu):
        """[summary]
        
        :param a: semi_major axis (m)
        :type a: [type]
        :param e: eccentricity (adimentional)
        :type e: [type]
        :param i: inclination (deg)  
        :type i: [type]
        :param capital_omega: argument of the ascending node (deg)
        :type capital_omega: [type]
        :param small_omega: argument of the perigee (deg)
        :type small_omega: [type]
        :param nu: [description]
        :type nu: [type]
        """
        self.a = a
        self.e = e
        self.i = i
        self.capital_omega = capital_omega
        self.small_omega = small_omega
        self.nu = nu

    def __str__(self):
        return ("TargetOrbit object\n"
                "Semi major axis : {}\n"
                "Exccentricity : {}\n"
                "Inclination : {}\n"
                "Argument of ascending node : {}\n"
                "Argument of periapsis : {}\n"
                "nu ? : {}\n").format(self.a,self.e,self.i,self.capital_omega,self.small_omega,self.nu)


if __name__ == '__main__':

    v_semiMajorAxis = 400000 # 400 km
    v_eccentricity = 15
    v_inclination = 20
    v_ascendingNode = 5
    v_perigee = 5
    v_nu = 0

    v_targetOrbit = TargetOrbit(v_semiMajorAxis, v_eccentricity, v_inclination, v_ascendingNode, v_perigee, v_nu)
    print(v_targetOrbit)
    v_payload =  Payload(400, v_targetOrbit)


    Rocket(Stage(1), Stage(2), v_payload, {'latitude':47,'longitude':2})
Vivien's avatar
Vivien committed