Skip to content

Commit

Permalink
Added nose, tube and wings, slight engine changes
Browse files Browse the repository at this point in the history
  • Loading branch information
luca7084 committed Jul 6, 2023
1 parent 0ce620b commit 912b0a4
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 7 deletions.
3 changes: 2 additions & 1 deletion rocket_twin/systems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from rocket_twin.systems.ground import Ground
from rocket_twin.systems.physics import Dynamics
from rocket_twin.systems.tank import Pipe, Tank
from rocket_twin.systems.structure import Nose, Tube, Wings

from rocket_twin.systems.rocket import Rocket # isort: skip
from rocket_twin.systems.station import Station # isort: skip

__all__ = ["Clock", "Engine", "Tank", "Rocket", "Pipe", "Dynamics", "Station", "Ground"]
__all__ = ["Clock", "Engine", "Tank", "Rocket", "Pipe", "Dynamics", "Station", "Ground", "Nose", "Tube", "Wings"]
11 changes: 8 additions & 3 deletions rocket_twin/systems/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Engine(System):
Inputs
------
force_command: float,
External control, which inputs the % of the maximum force the engine outputs
external control, which inputs the % of the maximum force the engine outputs
w_out [kg/s]: float,
rate of fuel consumption
Outputs
------
Expand All @@ -21,15 +23,18 @@ class Engine(System):

def setup(self):

self.add_inward("force_max", 100.0, desc="Maximum engine force", unit="N")
#self.add_inward("force_max", 100.0, desc="Maximum engine force", unit="N")
self.add_inward(
"force_command", 1.0, desc="Ratio of command force to maximum force", unit=""
)
self.add_inward("isp", 100., desc="Specific impulsion in vacuum", unit='s')
self.add_inward("w_out", 0., desc="Fuel consumption rate", unit='kg/s')
self.add_inward("g_0", 9.80665, desc="Gravity at Earth's surface", unit='m/s**2')

self.add_outward("weight", 1.0, desc="weight", unit="kg")
self.add_outward("cg", 1.0, desc="Center of Gravity", unit="m")
self.add_outward("force", 1.0, desc="Thrust force", unit="N")

def compute(self):

self.force = self.force_max * self.force_command
self.force = self.isp * self.g_0 * self.w_out * self.force_command
13 changes: 10 additions & 3 deletions rocket_twin/systems/rocket/rocket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cosapp.base import System

from rocket_twin.systems import Dynamics, Engine, Tank
from rocket_twin.systems import Dynamics, Engine, Tank, Nose, Tube, Wings


class Rocket(System):
Expand All @@ -16,24 +16,31 @@ class Rocket(System):
"""

def setup(self):
self.add_child(Nose('nose'))
self.add_child(Tube('tube'))
self.add_child(Wings('wings'))
self.add_child(Engine("engine"), pulling=["force_command"])
self.add_child(Tank("tank"), pulling=["w_in", "w_command"])
self.add_child(
Dynamics(
"dyn",
forces=["thrust"],
weights=["weight_eng", "weight_tank"],
centers=["engine", "tank"],
weights=["weight_eng", "weight_tank", "weight_nose", "weight_tube", "weight_wings"],
centers=["engine", "tank", "nose", "tube", "engine"],
),
pulling=["a"],
)

self.connect(self.tank.outwards, self.engine.inwards, ['w_out'])
self.connect(
self.engine.outwards,
self.dyn.inwards,
{"force": "thrust", "weight": "weight_eng", "cg": "engine"},
)
self.connect(self.tank.outwards, self.dyn.inwards, {"weight": "weight_tank", "cg": "tank"})
self.connect(self.nose.outwards, self.dyn.inwards, {'weight' : 'weight_nose', 'cg' : 'nose'})
self.connect(self.tube.outwards, self.dyn.inwards, {'weight' : 'weight_tube', 'cg' : 'tube'})
self.connect(self.wings.outwards, self.dyn.inwards, {'weight' : 'weight_wings', 'cg' : 'wings'})

self.add_inward("flying", False, desc="Whether the rocket is flying or not", unit="")

Expand Down
5 changes: 5 additions & 0 deletions rocket_twin/systems/structure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from rocket_twin.systems.structure.nose import Nose
from rocket_twin.systems.structure.tube import Tube
from rocket_twin.systems.structure.wings import Wings

__all__ = ['Nose', 'Tube', 'Wings']
20 changes: 20 additions & 0 deletions rocket_twin/systems/structure/nose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from cosapp.base import System

class Nose(System):
"""Model of a rocket nose.
Inputs
------
Outputs
------
weight [kg]: float,
nose weight
cg [m]: float,
nose center of gravity
"""

def setup(self):

self.add_outward('weight', 0., desc="Weight", unit='kg')
self.add_outward('cg', 0., desc="Center of gravity", unit='m')
20 changes: 20 additions & 0 deletions rocket_twin/systems/structure/tube.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from cosapp.base import System

class Tube(System):
"""Model of a rocket tube.
Inputs
------
Outputs
------
weight [kg]: float,
tube weight
cg [m]: float,
tube center of gravity
"""

def setup(self):

self.add_outward('weight', 0., desc="Weight", unit='kg')
self.add_outward('cg', 0., desc="Center of gravity", unit='m')
20 changes: 20 additions & 0 deletions rocket_twin/systems/structure/wings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from cosapp.base import System

class Wings(System):
"""Model of the wings of a rocket.
Inputs
------
Outputs
------
weight [kg]: float,
wings weight
cg [m]: float,
wings center of gravity
"""

def setup(self):

self.add_outward('weight', 0., desc="Weight", unit='kg')
self.add_outward('cg', 0., desc="Center of gravity", unit='m')

0 comments on commit 912b0a4

Please sign in to comment.