Пример #1
0
 def test_stage_mass_sum(self):
     stage0 = document.Stage("Booster")
     stage0.components = [
         document.Nosecone(document.Noseshape.CONE, 0, 0.7, 1.4),
         document.Bodytube("body", 0, 1),
         document.Bodytube("body", 24.1, 1),
     ]
     self.assertEqual(24.8, stage0.mass)
Пример #2
0
    def __init__(self, Isp, thrust, impulse, CD):
        """Take variables as input, build a rocket"""

        # Create an engine document
        engine = document.Engine('Motor')

        # Set our design
        engine.Isp = Isp
        engine.thrust_avg = thrust
        engine.I_total = impulse

        # volume of propellent needed
        prop_volume = engine.m_prop / self.prop_density

        # Solve for the radius/length of the fuel grain (assume solid, end burning)
        engine.diameter = 2 * (prop_volume / (2 * self.LD * pi))**(1 / 3.0)
        engine.length = engine.diameter * self.LD

        # Add a nose
        nose = document.Nosecone(
            document.Noseshape.TANGENT_OGIVE,  # Shape
            1.0,  # shape_parameter
            3.5,  # mass
            engine.diameter * self.Nose_LD,  # Length
            diameter=engine.diameter,
        )

        # Payload section
        payload = document.Bodytube(
            "Payload",  # Name
            3.5,  # mass
            0.33,  # length, fixed
            diameter=engine.diameter,
        )

        # Body section the size of the engine
        body = document.Bodytube(
            "Body",  # Name
            20.0,  # mass
            engine.length,
            diameter=engine.diameter,
        )

        body.components = [engine]

        # Rocket:
        rocket = document.Rocket("Rocket")
        rocket.aero_properties['CD'] = CD
        stage0 = document.Stage("Sustainer")
        stage0.components = [nose, payload, body]
        rocket.stages = [stage0]

        self.rocket = rocket
Пример #3
0
    def test_write_simple_JSBSimAircraft(self):
        rocket = rdoc.Rocket("Rocket")
        stage0 = rdoc.Stage("Sustainer")

        body = rdoc.Bodytube("body", 1, 0.2, diameter=0.33)
        engine = rdoc.Engine("test engine")
        engine.manufacturer = "Open Aerospace"
        engine.length = 0.1
        engine.diameter = 0.2
        engine.Isp = 169
        engine.m_prop = 1.0
        engine.thrust_avg = 1000

        body.components = [engine]

        stage0.components = [
            rdoc.Nosecone(rdoc.Noseshape.VONKARMAN, 1, 0.2, 1.0), body
        ]
        rocket.stages = [stage0]
        rocket.aero_properties['CD'] = [(0.1, 0.8), (0.5, 0.6), (1.0, 0.8)]
        str_file = writers.JSBSimAircraft.dump(rocket)

        # print(str_file)

        # smoke test
        self.assertGreater(len(str_file), 150)
Пример #4
0
    def _load_bodytube(self, tree):
        tube = rdoc.Bodytube('bodytube', 0, 0)

        # Read data
        for element in tree:
            if element.tag == 'name':
                tube.name = element.text
            if element.tag == 'length':
                tube.length = float(element.text)
            if element.tag == 'thickness':
                tube.thickness = float(element.text)
            if element.tag == 'finish':
                tube.surface_roughness = self._read_surface(element.text)
            if element.tag == 'material':
                tube.material_name = element.text
                tube.density = float(element.get('density', 0))
            if element.tag == 'color':
                tube.color = self._read_color(element)
            if element.tag == 'radius':
                if 'auto' not in element.text:
                    self.radius = float(element.text)

        if self.radius is not None:
            tube.diameter = self.radius * 2.0

        # Compute mass:
        r1 = self.radius
        r2 = r1 - tube.thickness
        tube.mass = tube.density * (pi * tube.length * (r1**2 - r2**2))

        return tube
Пример #5
0
    def test_rocket_length_sum(self):
        stage0 = document.Stage("Booster")
        stage0.components = [
            document.Nosecone("", 1, 0.7, 1.2),
            document.Bodytube("body", 0, 1),
            document.Bodytube("body", 24.1, 1),
        ]
        stage1 = document.Stage("Booster")
        stage1.components = [
            document.Bodytube("body", 4.87, 1),
            document.Fin('fin', 1, 1, 1, sweepangle=45.0, mass=0.1),
        ]

        rocket = document.Rocket("Rocket")
        rocket.stages = [stage0, stage1]

        self.assertAlmostEqual(rocket.length, 5.2)
Пример #6
0
    def test_rocket_length_sum_0(self):
        # just rocket
        rocket = document.Rocket("Rocket")
        self.assertEqual(rocket.length, 0)

        # rocket and a stage
        stage0 = document.Stage("sustainer")
        rocket.stages = [stage0]
        self.assertEqual(rocket.length, 0)

        # zero length components in rocket
        stage0.components = [
            document.Nosecone("", 1, 0.7, 0),
            document.Bodytube("body", 0, 0),
            document.Bodytube("body", 24.1, 0)
        ]
        self.assertEqual(rocket.length, 0)
Пример #7
0
 def test_spec_a_rocket(self):
     rocket = document.Rocket("Rocket")
     stage0 = document.Stage("Booster")
     stage0.components = [
         document.Nosecone(document.Noseshape.VONKARMAN, 1, 0.7, 1.2),
         document.Bodytube("body", 1.2, 0.5),
     ]
     rocket.stages = [stage0]
Пример #8
0
    def test_color(self):
        tube = document.Bodytube("body", 24.1, 1)

        # As string:
        tube.color = "Brown"
        self.assertEqual(tube.color, "Brown")

        # As tuple:
        tube.color = (240, 12, 0)
        self.assertEqual(tube.color, (240, 12, 0))
Пример #9
0
    def test_write_document_smoke(self):
        rocket = rdoc.Rocket("Rocket")
        stage0 = rdoc.Stage("Sustainer")
        stage0.components = [
            rdoc.Nosecone(rdoc.Noseshape.VONKARMAN, 1, 0.2, 1.0),
            rdoc.Bodytube("body", 1, 0.2),
        ]
        rocket.stages = [stage0]
        str_file = writers.Document().dump(rocket)

        # print("Output:")
        # print(str_file)

        self.assertGreater(len(str_file), 10)
Пример #10
0
    def test_write_simple_svg(self):
        rocket = rdoc.Rocket("Rocket")
        stage0 = rdoc.Stage("Sustainer")
        stage0.components = [
            rdoc.Nosecone(rdoc.Noseshape.VONKARMAN, 1, 0.2, 1.0, diameter=0.2),
            rdoc.Bodytube("body", 1, 1.2, diameter=0.2),
        ]
        rocket.stages = [stage0]
        str_file = writers.SVG.dump(rocket)

        # print("Output:")
        # print(str_file)
        # with open("testdraw.svg", "w") as testwrite:
        #     testwrite.write(str_file)

        self.assertGreater(len(str_file), 10)
Пример #11
0
    def test_component_name_slug(self):

        # replace spaces with dashes
        c = document.Bodytube("My Rocket Tube", 1, 1)
        self.assertEqual(c.name_slug, "my-rocket-tube")
Пример #12
0
    def test_no_color(self):
        tube = document.Bodytube("body", 24.1, 1)

        # No color defined
        self.assertEqual(tube.color, None)
Пример #13
0
"""

# Build a rocket
# Nosecone
nose = document.Nosecone(
    document.Noseshape.TANGENT_OGIVE,  # Shape
    1.0,  # shape_parameter
    3.5,  # mass [kg]
    1.0,  # length [m]
    diameter=0.28,  # diameter [m] ~8 inches
)

# Payload section
payload = document.Bodytube(
    "Payload",  # Name
    10.0,  # mass [kg]
    0.5,  # length [m]
    diameter=0.28,  # diameter [m] ~8 inches
)

# Body section
body = document.Bodytube(
    "Body",  # Name
    30.0,  # mass
    2.0,  # length [m]
    diameter=0.28,  # diameter [m] ~8 inches
)


def rocket():

    # parametric thrust curve: