Source code for fastoad_cs25.models.aerodynamics.components.compute_reynolds

"""Computation of Reynolds number"""
#  This file is part of FAST-OAD_CS25
#  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/>.

import fastoad.api as oad
import numpy as np
from openmdao.core.explicitcomponent import ExplicitComponent
from stdatm import AtmosphereSI

from ..constants import SERVICE_REYNOLDS_COEFFICIENT


[docs] @oad.RegisterSubmodel( SERVICE_REYNOLDS_COEFFICIENT, "fastoad.submodel.aerodynamics.reynolds_coefficient.legacy", ) class ComputeReynolds(ExplicitComponent): """Computation of Reynolds number"""
[docs] def initialize(self): self.options.declare("low_speed_aero", default=False, types=bool) self.options.declare( "altitude_var_name_high_speed", default="data:mission:sizing:main_route:cruise:altitude_input", types=str, desc="Name of the variable to use for cruise altitude evaluation in Reynolds number " "computation.", )
[docs] def setup(self): if self.options["low_speed_aero"]: self.add_input("data:aerodynamics:aircraft:takeoff:mach", val=np.nan, units="unitless") self.add_output("data:aerodynamics:aircraft:low_speed:unit_reynolds", units="unitless") else: self.add_input("data:TLAR:cruise_mach", val=np.nan, units="unitless") self.add_input(self.options["altitude_var_name_high_speed"], val=np.nan, units="m") self.add_output("data:aerodynamics:aircraft:high_speed:unit_reynolds", units="unitless")
[docs] def setup_partials(self): self.declare_partials("*", "*", method="fd")
[docs] def compute(self, inputs, outputs, discrete_inputs=None, discrete_outputs=None): if self.options["low_speed_aero"]: mach = inputs["data:aerodynamics:aircraft:takeoff:mach"] altitude = 0.0 else: mach = inputs["data:TLAR:cruise_mach"] altitude = inputs[self.options["altitude_var_name_high_speed"]] atm = AtmosphereSI(altitude) atm.mach = mach reynolds = atm.unitary_reynolds if self.options["low_speed_aero"]: outputs["data:aerodynamics:aircraft:low_speed:unit_reynolds"] = reynolds else: outputs["data:aerodynamics:aircraft:high_speed:unit_reynolds"] = reynolds