Source code for fastoad.models.performances.mission.segments.registered.speed_change

"""Classes for acceleration/deceleration segments."""
#  This file is part of FAST-OAD : A framework for rapid Overall Aircraft Design
#  Copyright (C) 2024 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/>.

from dataclasses import dataclass
from typing import List, Tuple

from fastoad.model_base import FlightPoint
from fastoad.models.performances.mission.exceptions import FastFlightSegmentIncompleteFlightPoint
from fastoad.models.performances.mission.segments.base import (
    RegisterSegment,
)
from fastoad.models.performances.mission.segments.time_step_base import (
    AbstractLiftFromWeightSegment,
    AbstractManualThrustSegment,
)


[docs]@RegisterSegment("speed_change") @dataclass class SpeedChangeSegment(AbstractManualThrustSegment, AbstractLiftFromWeightSegment): """ 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. """
[docs] def get_distance_to_target( self, flight_points: List[FlightPoint], target: FlightPoint ) -> float: if target.true_airspeed is not None: return target.true_airspeed - flight_points[-1].true_airspeed if target.equivalent_airspeed is not None: return target.equivalent_airspeed - flight_points[-1].equivalent_airspeed if target.mach is not None: return target.mach - flight_points[-1].mach raise FastFlightSegmentIncompleteFlightPoint( "No valid target definition for altitude change." )
[docs] def get_gamma_and_acceleration(self, flight_point: FlightPoint) -> Tuple[float, float]: acceleration = (flight_point.thrust - flight_point.drag) / flight_point.mass return 0.0, acceleration