about summary refs log tree commit diff
path: root/src/stage.py
diff options
context:
space:
mode:
authorBaitinq <you@example.com>2022-02-10 23:39:43 +0000
committerBaitinq <you@example.com>2022-02-10 23:39:43 +0000
commit9ebc639fb90a878e6b65800c689b89750b607b33 (patch)
tree8bc85900051de442743f9c802ac275a62cadaebd /src/stage.py
parentStarted preparation to implement proper altitude calculations and gravity (diff)
downloadOSLS-9ebc639fb90a878e6b65800c689b89750b607b33.tar.gz
OSLS-9ebc639fb90a878e6b65800c689b89750b607b33.tar.bz2
OSLS-9ebc639fb90a878e6b65800c689b89750b607b33.zip
Structured source files into src folder
Diffstat (limited to 'src/stage.py')
-rw-r--r--src/stage.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/stage.py b/src/stage.py
new file mode 100644
index 0000000..bb05eaf
--- /dev/null
+++ b/src/stage.py
@@ -0,0 +1,49 @@
+import math
+
+from engine import Engine
+from fuel import Fuel
+
+class Stage():
+    def __init__(self, name: str, stage_mass: int, engine: type[Engine], engine_number: int, max_engine_gimbaling_angle: int, fuel_type: type[Fuel], fuel_mass: int, drag_coefficient: float, cross_sectional_area: float):
+        self.name = name
+        self.stage_mass = stage_mass
+        self.engine = engine
+        self.engine_number = engine_number 
+        self.fuel_type = fuel_type
+        self.fuel_mass = fuel_mass
+        self.drag_coefficient = drag_coefficient
+        self.cross_sectional_area = cross_sectional_area
+        
+        self.max_engine_gimbaling_angle = max_engine_gimbaling_angle
+        self.gimbal = 0 #one thing is gimbal another is rocket angle (TODO TOODODODODODODOD)
+        self.throttle = 100
+        self.engines_on = False
+
+    def total_mass(self):
+        return (self.stage_mass + self.fuel_mass)
+
+    def current_thrust(self, g: float, heading: int) -> (float, float):
+        if(self.engines_on and self.fuel_mass > 0):
+            total_thrust = self.engine.thrust(self.throttle, g) * self.engine_number
+            #gimbal and heading components
+            thrust_x = (math.sin(math.radians(self.gimbal + heading)) * total_thrust)
+            thrust_y = (math.cos(math.radians(self.gimbal + heading)) * total_thrust)
+
+            return (thrust_x, thrust_y)
+        else:
+            return (0, 0)
+
+    def total_fuel_used(self, delta: int):
+        if(self.engines_on):
+            return self.engine.flow_rate(self.throttle) * self.engine_number * delta
+        else:
+            return 0
+
+    def convert_y_component_to_total_with_gimbal(self, y_value):
+        return math.fabs(y_value / math.cos(math.radians(self.gimbal)))
+
+    #total drag coefficient is just the upper stage
+    #engines on is just the lower stage
+    #thrust is just the lower stage
+    #fuel used is just lower stage
+    #when stage separation lower stage jetissoned
\ No newline at end of file