Skip to content

Commit

Permalink
Merge pull request #488 from fast-aircraft-design/genericity-for-macr…
Browse files Browse the repository at this point in the history
…o-segments

Genericity for macro segments
  • Loading branch information
christophe-david committed Apr 24, 2023
2 parents 8c4f0b7 + ad88cce commit 425e327
Show file tree
Hide file tree
Showing 41 changed files with 830 additions and 684 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ exclude-protected=_asdict,
valid-classmethod-first-arg=cls

# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls
valid-metaclass-classmethod-first-arg=mcs


[DESIGN]
Expand Down
37 changes: 35 additions & 2 deletions src/fastoad/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# pylint: disable=unused-import
# flake8: noqa


# The comment below prevents PyCharm from "optimizing" (i.e. removing) these imports.
# noinspection PyUnresolvedReferences
from fastoad.cmd.api import (
get_plugin_information,
generate_notebooks,
Expand All @@ -32,35 +33,67 @@
write_xdsm,
)

# noinspection PyUnresolvedReferences
from fastoad.io.configuration import FASTOADProblemConfigurator

# noinspection PyUnresolvedReferences
from fastoad.openmdao.problem import FASTOADProblem

# noinspection PyUnresolvedReferences
from fastoad.io import DataFile

# noinspection PyUnresolvedReferences
from fastoad.openmdao.variables import Variable, VariableList

# noinspection PyUnresolvedReferences
from fastoad.model_base import Atmosphere, AtmosphereSI, FlightPoint

# noinspection PyUnresolvedReferences
from fastoad.module_management.service_registry import (
RegisterOpenMDAOSystem,
RegisterPropulsion,
RegisterSpecializedService,
RegisterSubmodel,
)

# noinspection PyUnresolvedReferences
from fastoad.model_base.propulsion import IOMPropulsionWrapper

# noinspection PyUnresolvedReferences
from fastoad.openmdao.validity_checker import ValidityDomainChecker

# noinspection PyUnresolvedReferences
from fastoad.model_base.datacls import MANDATORY_FIELD

# noinspection PyUnresolvedReferences
from fastoad.models.performances.mission.segments.base import (
IFlightPart,
AbstractFlightSegment,
RegisterSegment,
)

# noinspection PyUnresolvedReferences
from fastoad.models.performances.mission.segments.time_step_base import (
AbstractTimeStepFlightSegment,
AbstractManualThrustSegment,
AbstractFixedDurationSegment,
AbstractRegulatedThrustSegment,
AbstractFixedDurationSegment,
AbstractGroundSegment,
AbstractTakeOffSegment,
AbstractPolarModifier,
FlightSegment,
)

# noinspection PyUnresolvedReferences
from fastoad.gui.mission_viewer import MissionViewer

# noinspection PyUnresolvedReferences
from fastoad.gui.optimization_viewer import OptimizationViewer

# noinspection PyUnresolvedReferences
from fastoad.gui.variable_viewer import VariableViewer

# noinspection PyUnresolvedReferences
from fastoad.gui.analysis_and_plots import (
aircraft_geometry_plot,
drag_polar_plot,
Expand Down
8 changes: 4 additions & 4 deletions src/fastoad/models/performances/mission/mission.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Definition of aircraft mission."""

# This file is part of FAST-OAD : A framework for rapid Overall Aircraft Design
# Copyright (C) 2022 ONERA & ISAE-SUPAERO
# Copyright (C) 2023 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
Expand All @@ -21,9 +21,9 @@
from scipy.optimize import root_scalar

from fastoad.model_base import FlightPoint
from fastoad.models.performances.mission.base import FlightSequence
from fastoad.models.performances.mission.routes import RangedRoute
from fastoad.models.performances.mission.segments.cruise import CruiseSegment
from .base import FlightSequence
from .routes import RangedRoute
from .segments.registered.cruise import CruiseSegment


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@
from ...segments.base import AbstractFlightSegment, RegisterSegment


# Rationale:
# The way we parse the mission definition file answers several needs:
# - Producing an executable mission instance, able to compute the mission simulation.
# - Allowing to replace variables in the mission definition by their values, knowing the
# name can be contextual: a same phase definition can be used in 2 different routes or missions
# and variable names in this phase may depend on the parent.
# - Allowing to know all the needed variables before knowing their values, hence before
# building the mission instance.
#
# Therefore, we have first the structure_builders package, that will provide classes to parse the
# definition file to create a global structure of the mission, ready to implement. This structure
# will be able to provide the actual names of the variables used in the mission, but does not
# have to know their values.
#
# Then we can use the MissionBuilder below to build the mission instance and provide information
# on the mission, once variable values have been supplied.


class MissionBuilder:
"""
This class builds and computes a mission from a provided definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@

from fastoad.model_base.datacls import MANDATORY_FIELD
from fastoad.model_base.propulsion import IPropulsion
from fastoad.models.performances.mission.base import FlightSequence
from fastoad.models.performances.mission.segments.altitude_change import AltitudeChangeSegment
from fastoad.models.performances.mission.segments.base import (
AbstractFlightSegment,
RegisteredSegment,
)
from fastoad.models.performances.mission.segments.hold import HoldSegment
from fastoad.models.performances.mission.segments.mass_input import MassTargetSegment
from fastoad.models.performances.mission.segments.speed_change import SpeedChangeSegment
from fastoad.models.performances.mission.segments.start import Start
from fastoad.models.performances.mission.segments.taxi import TaxiSegment
from fastoad.models.performances.mission.segments.transition import DummyTransitionSegment
from fastoad.openmdao.variables import Variable
from ..input_definition import InputDefinition
from ..mission_builder import MissionBuilder
from ...exceptions import FastMissionFileMissingMissionNameError
from ...schema import MissionDefinition
from ....base import FlightSequence
from ....segments.base import AbstractFlightSegment, RegisteredSegment
from ....segments.registered.altitude_change import AltitudeChangeSegment
from ....segments.registered.hold import HoldSegment
from ....segments.registered.mass_input import MassTargetSegment
from ....segments.registered.speed_change import SpeedChangeSegment
from ....segments.registered.start import Start
from ....segments.registered.taxi import TaxiSegment
from ....segments.registered.transition import DummyTransitionSegment

DATA_FOLDER_PATH = pth.join(pth.dirname(__file__), "data")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from fastoad.module_management.service_registry import RegisterPropulsion
from .base import BaseMissionComp
from ..polar import Polar
from ..segments.cruise import BreguetCruiseSegment
from ..segments.registered.cruise import BreguetCruiseSegment

_LOGGER = logging.getLogger(__name__) # Logger for this module

Expand Down
8 changes: 4 additions & 4 deletions src/fastoad/models/performances/mission/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Classes for computation of routes (i.e. assemblies of climb, cruise and descent phases).
"""
# This file is part of FAST-OAD : A framework for rapid Overall Aircraft Design
# Copyright (C) 2022 ONERA & ISAE-SUPAERO
# Copyright (C) 2023 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
Expand All @@ -23,9 +23,9 @@

from fastoad.model_base import FlightPoint
from fastoad.model_base.datacls import MANDATORY_FIELD
from fastoad.models.performances.mission.base import FlightSequence, IFlightPart
from fastoad.models.performances.mission.segments.base import AbstractFlightSegment
from fastoad.models.performances.mission.segments.cruise import CruiseSegment
from .base import FlightSequence, IFlightPart
from .segments.base import AbstractFlightSegment
from .segments.registered.cruise import CruiseSegment


@dataclass
Expand Down
23 changes: 0 additions & 23 deletions src/fastoad/models/performances/mission/segments/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
"""
Classes for simulating flight segments.
Be sure to import this package before interpreting a mission input file.
"""
# This file is part of FAST-OAD : A framework for rapid Overall Aircraft Design
# Copyright (C) 2023 ONERA & ISAE-SUPAERO
# FAST is free software: you can redistribute it and/or modify
Expand All @@ -15,21 +10,3 @@
# 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/>.

# pylint: disable=unused-import
# flake8: noqa

# With these imports, importing only the current package ensures to have all
# these segments available when interpreting a mission input file
from . import (
altitude_change,
cruise,
ground_speed_change,
hold,
mass_input,
speed_change,
start,
takeoff,
taxi,
transition,
)

0 comments on commit 425e327

Please sign in to comment.