Skip to content

Commit

Permalink
include engine_deterioration_factor in AircraftPerformanceGridParams
Browse files Browse the repository at this point in the history
  • Loading branch information
zebengberg committed Nov 20, 2024
1 parent b89b110 commit 5672476
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- Publish to PyPI using [trusted publishing](https://docs.pypi.org/trusted-publishers/using-a-publisher/).
- Update `pycontrails-bada` installation instructions.
- Floor the pycontrails version when running the docs workflow. This ensures that the [hosted documentation](https://py.contrails.org) references the last stable release.
- Move the `engine_deterioration_factor` from `PSFlightParams` to `AircraftPerformanceParams` so it can be used by both the PS model and BADA.
- Include `engine_deterioration_factor` in `AircraftPerformanceGridParams`.

## v0.54.2

Expand Down
19 changes: 12 additions & 7 deletions pycontrails/core/aircraft_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@


@dataclasses.dataclass
class AircraftPerformanceParams(ModelParams):
"""Parameters for :class:`AircraftPerformance`."""

#: Whether to correct fuel flow to ensure it remains within
#: the operational limits of the aircraft type.
correct_fuel_flow: bool = True
class CommonAircraftPerformanceParams:
"""Params for :class:`AircraftPerformanceParams` and :class`AircraftPerformanceGridParams`."""

#: Account for "in-service" engine deterioration between maintenance cycles.
#: Default value is set to +2.5% increase in fuel consumption.
Expand All @@ -49,6 +45,15 @@ class AircraftPerformanceParams(ModelParams):
# Predicting Fuel Consumption Impact in a Regional Aircraft. Aerospace, 11(6), p.426.
engine_deterioration_factor: float = 0.025


@dataclasses.dataclass
class AircraftPerformanceParams(ModelParams, CommonAircraftPerformanceParams):
"""Parameters for :class:`AircraftPerformance`."""

#: Whether to correct fuel flow to ensure it remains within
#: the operational limits of the aircraft type.
correct_fuel_flow: bool = True

#: The number of iterations used to calculate aircraft mass and fuel flow.
#: The default value of 3 is sufficient for most cases.
n_iter: int = 3
Expand Down Expand Up @@ -554,7 +559,7 @@ class AircraftPerformanceData:


@dataclasses.dataclass
class AircraftPerformanceGridParams(ModelParams):
class AircraftPerformanceGridParams(ModelParams, CommonAircraftPerformanceParams):
"""Parameters for :class:`AircraftPerformanceGrid`."""

#: Fuel type
Expand Down
5 changes: 3 additions & 2 deletions pycontrails/models/ps_model/ps_aircraft_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import numpy as np
import pandas as pd

from pycontrails.core.aircraft_performance import AircraftPerformanceParams
from pycontrails.physics import constants as c

#: Path to the Poll-Schumann aircraft parameters CSV file.
Expand Down Expand Up @@ -193,7 +194,7 @@ def _row_to_aircraft_engine_params(tup: Any) -> tuple[str, PSAircraftEngineParam

@functools.cache
def load_aircraft_engine_params(
engine_deterioration_factor: float = 0.025,
engine_deterioration_factor: float = AircraftPerformanceParams.engine_deterioration_factor,
) -> Mapping[str, PSAircraftEngineParams]:
"""
Extract aircraft-engine parameters for each aircraft type supported by the PS model.
Expand Down Expand Up @@ -254,7 +255,7 @@ def load_aircraft_engine_params(
}

df = pd.read_csv(PS_FILE_PATH, dtype=dtypes)
df["eta_1"] = df["eta_1"] * (1.0 - engine_deterioration_factor)
df["eta_1"] *= 1.0 - engine_deterioration_factor

return dict(_row_to_aircraft_engine_params(tup) for tup in df.itertuples(index=False))

Expand Down
12 changes: 10 additions & 2 deletions pycontrails/models/ps_model/ps_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def ps_nominal_grid(
q_fuel: float = JetA.q_fuel,
mach_number: float | None = None,
maxiter: int = PSGridParams.maxiter,
engine_deterioration_factor: float = PSGridParams.engine_deterioration_factor,
) -> xr.Dataset:
"""Calculate the nominal performance grid for a given aircraft type.
Expand All @@ -359,6 +360,9 @@ def ps_nominal_grid(
The Mach number. If None (default), the PS design Mach number is used.
maxiter : int, optional
Passed into :func:`scipy.optimize.newton`.
engine_deterioration_factor : float, optional
The engine deterioration factor,
by default :attr:`PSGridParams.engine_deterioration_factor`.
Returns
-------
Expand Down Expand Up @@ -428,7 +432,7 @@ def ps_nominal_grid(

air_pressure = level * 100.0

aircraft_engine_params = ps_model.load_aircraft_engine_params()
aircraft_engine_params = ps_model.load_aircraft_engine_params(engine_deterioration_factor)

try:
atyp_param = aircraft_engine_params[aircraft_type]
Expand Down Expand Up @@ -542,6 +546,7 @@ def ps_nominal_optimize_mach(
sin_a: ArrayOrFloat | None = None,
cos_a: ArrayOrFloat | None = None,
q_fuel: float = JetA.q_fuel,
engine_deterioration_factor: float = PSGridParams.engine_deterioration_factor,
) -> xr.Dataset:
"""Calculate the nominal optimal mach number for a given aircraft type.
Expand Down Expand Up @@ -580,6 +585,9 @@ def ps_nominal_optimize_mach(
specified if wind data is provided. Will be ignored if wind data is not provided.
q_fuel : float, optional
The fuel heating value, by default :attr:`JetA.q_fuel`.
engine_deterioration_factor : float, optional
The engine deterioration factor,
by default :attr:`PSGridParams.engine_deterioration_factor`.
Returns
-------
Expand All @@ -602,7 +610,7 @@ def ps_nominal_optimize_mach(
"""
dims = ("level",)
coords = {"level": level}
aircraft_engine_params = ps_model.load_aircraft_engine_params()
aircraft_engine_params = ps_model.load_aircraft_engine_params(engine_deterioration_factor)
try:
atyp_param = aircraft_engine_params[aircraft_type]
except KeyError as exc:
Expand Down

0 comments on commit 5672476

Please sign in to comment.