diff options
Diffstat (limited to 'src/simulation.py')
-rw-r--r-- | src/simulation.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/simulation.py b/src/simulation.py index 106c5a1..8968da5 100644 --- a/src/simulation.py +++ b/src/simulation.py @@ -36,11 +36,14 @@ class Simulation(): fuel_used = current_stage.fuel_mass current_stage.fuel_mass -= fuel_used print("Fuel remaining: " + str(current_stage.fuel_mass)) + + g = self.body.g(G=self.universe.G, height=self.rocket_altitude()) + print("g: " + str(g)) force_x = 0 force_y = 0 if fuel_used > 0: - total_thrust = current_stage.current_thrust(self.body.g(self.universe.G, self.rocket_altitude()), self.heading) + total_thrust = current_stage.current_thrust(g, self.heading) force_x = total_thrust[0] force_y = total_thrust[1] @@ -51,27 +54,24 @@ class Simulation(): print("ROCKET TOTAL MASS: " + str(self.rocket.total_mass())) #calculate downwards force by drag and gravity - g = self.body.g(G=self.universe.G, height=self.rocket_altitude()) - print("g: " + str(g)) - - gravitational_force = g * self.rocket.total_mass() - print("Gravity: " + str(gravitational_force)) + gravitational_force_y = g * self.rocket.total_mass() + print("Gravity Y: " + str(gravitational_force_y)) #Remove gravity from force - force_y -= gravitational_force + force_y -= gravitational_force_y curr_atmospheric_density = self.body.atmosphere.density_at_height(self.rocket_altitude(), g) print("Atmosphere density: " + str(curr_atmospheric_density)) #TODO: cross sectional area and drag coef for x should b different - drag_force_x = (1/2) * curr_atmospheric_density * (self.speed_x ** 2) * self.rocket.s_drag_coefficient() * self.rocket.s_cross_sectional_area() + drag_force_x = (1/2) * curr_atmospheric_density * (self.speed_x ** 2) * self.rocket.rocket_x_drag_coefficient() * self.rocket.rocket_x_cross_sectional_area() #drag goes against speed if force_x < 0: drag_force_x *= -1 print("Drag X: " + str(drag_force_x)) #https://www.grc.nasa.gov/www/k-12/airplane/drageq.html - drag_force_y = (1/2) * curr_atmospheric_density * (self.speed_y ** 2) * self.rocket.s_drag_coefficient() * self.rocket.s_cross_sectional_area() + drag_force_y = (1/2) * curr_atmospheric_density * (self.speed_y ** 2) * self.rocket.rocket_y_drag_coefficient() * self.rocket.rocket_y_cross_sectional_area() #drag goes against speed if force_y < 0: drag_force_y *= -1 |