fastoad.models.performances.mission.segments.base module
Base classes for simulating flight segments.
- class fastoad.models.performances.mission.segments.base.RegisterSegment(keyword='')[source]
Bases:
RegisterElement
Decorator for registering IFlightPart classes.
>>> @RegisterSegment("segment_foo") >>> class FooSegment(IFlightPart): >>> ...
Then the registered class can be obtained by:
>>> my_class = RegisterSegment.get_class("segment_foo")
- class fastoad.models.performances.mission.segments.base.SegmentDefinitions(*args, **kwargs)[source]
Bases:
object
Class that associates segment names (mission file keywords) and their implementation.
- classmethod add_segment(segment_name: str, segment_class: Type[IFlightPart])[source]
Adds a segment definition.
- Parameters:
segment_name – segment names (mission file keyword)
segment_class – segment implementation (derived of
FlightSegment
)
- classmethod get_segment_class(segment_name) Type[IFlightPart] | None [source]
Provides the segment implementation for provided name.
- Parameters:
segment_name –
- Returns:
the segment implementation (derived of
FlightSegment
)- Raises:
FastUnknownMissionSegmentError – if segment type has not been declared.
- class fastoad.models.performances.mission.segments.base.RegisteredSegment(*args, **kwargs)[source]
Bases:
IFlightPart
,ABC
Base class for classes that can be associated with a keyword in mission definition file.
When subclassing this class, the attribute “mission_file_keyword” can be set, so that the segment can be used in mission file definition with this keyword:
>>> class NewSegment(AbstractFlightSegment, mission_file_keyword="new_segment") >>> ...
Then in mission definition:
phases: my_phase: parts: - segment: new_segment
- class fastoad.models.performances.mission.segments.base.AbstractFlightSegment(name: str = '', target: ~fastoad.model_base.flight_point.FlightPoint = <object object>, isa_offset: float = 0.0)[source]
Bases:
IFlightPart
,ABC
Base class for flight path segment.
As a dataclass, attributes can be set at instantiation.
Important
compute_from()
is the method to call to achieve the segment computation.However, when subclassing, the method to overload is
compute_from_start_to_target()
. Generic reprocessing of start and target flight points is done incompute_from()
before callingcompute_from_start_to_target()
- target: FlightPoint = <object object>
A FlightPoint instance that provides parameter values that should all be reached at the end of
compute_from()
. Possible parameters depend on the current segment. A parameter can also be set toCONSTANT_VALUE
to tell that initial value should be kept during all segment.
- CONSTANT_VALUE = 'constant'
Using this value will tell to keep the associated parameter constant.
- abstract compute_from_start_to_target(start, target) DataFrame [source]
Here should come the implementation for computing flight points between start and target flight points.
- Parameters:
start –
target – Definition of segment target
- Returns:
a pandas DataFrame where column names match fields of
FlightPoint
- compute_from(start: FlightPoint) DataFrame [source]
Computes the flight path segment from provided start point.
Computation ends when target is attained, or if the computation stops getting closer to target. For instance, a climb computation with too low thrust will only return one flight point, that is the provided start point.
Important
When subclasssing, if you need to overload
compute_from()
, you should consider overridingcompute_from_start_to_target()
instead. Therefore, you will take benefit of the preprocessing of start and target flight points that is done incompute_from()
.- Parameters:
start – the initial flight point, defined for altitude, mass and speed (true_airspeed, equivalent_airspeed or mach). Can also be defined for time and/or ground_distance.
- Returns:
a pandas DataFrame where column names match fields of
FlightPoint
- complete_flight_point(flight_point: FlightPoint)[source]
Computes data for provided flight point.
Assumes that it is already defined for time, altitude, mass, ground distance and speed (TAS, EAS, or Mach).
- Parameters:
flight_point – the flight point that will be completed in-place
- static complete_flight_point_from(flight_point: FlightPoint, source: FlightPoint)[source]
Sets undefined values in flight_point using the ones from source.
The particular case of speeds is taken into account: if at least one speed parameter is defined, all other speed parameters are considered defined, because they will be deduced when needed.
- Parameters:
flight_point –
source –
- static consume_fuel(flight_point: FlightPoint, previous: FlightPoint, fuel_consumption: float = None, mass_ratio: float = None)[source]
This method should be used whenever fuel consumption has to be stored.
It ensures that “mass” and “consumed_fuel” fields will be kept consistent.
Mass can be modified using the ‘fuel_consumption” argument, or the ‘mass_ratio’ argument. One of them should be provided.
- Parameters:
flight_point – the FlightPoint instance where “mass” and “consumed_fuel” fields will get new values
previous – FlightPoint instance that will be the base for the computation
fuel_consumption – consumed fuel, in kg, between ‘previous’ and ‘flight_point’. Positive when fuel is consumed.
mass_ratio – the ratio flight_point.mass/previous.mass