"""Classes for acceleration/deceleration segments."""
# This file is part of FAST : A framework for rapid Overall Aircraft Design
# Copyright (C) 2020 ONERA & ISAE-SUPAERO
# FAST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
from typing import Tuple, List
from fastoad.base.flight_point import FlightPoint
from .base import ManualThrustSegment
_LOGGER = logging.getLogger(__name__) # Logger for this module
[docs]class SpeedChangeSegment(ManualThrustSegment):
"""
Computes a flight path segment where speed is modified with no change in altitude.
The target must define a speed value among true_airspeed, equivalent_airspeed
and mach.
"""
def _get_distance_to_target(self, flight_points: List[FlightPoint]) -> bool:
if self.target.true_airspeed:
return self.target.true_airspeed - flight_points[-1].true_airspeed
elif self.target.equivalent_airspeed:
return self.target.equivalent_airspeed - flight_points[-1].equivalent_airspeed
elif self.target.mach:
return self.target.mach - flight_points[-1].mach
def _get_gamma_and_acceleration(self, mass, drag, thrust) -> Tuple[float, float]:
acceleration = (thrust - drag) / mass
return 0.0, acceleration