From 81ede7bbfcba5283c8a110283ef01a8350ef80c3 Mon Sep 17 00:00:00 2001 From: Guy De Spiegeleer Date: Tue, 21 Feb 2023 09:28:18 +0100 Subject: [PATCH] Fix incorrect automatic pulling of `fan_duct_core_cowl_slope` in `Turbofan` (#88) * fix inward fan_duct_core_slop bug def refactor structure folder * rename module duct instead of fan_duct * update HISTORY --------- Co-authored-by: Guy De Spiegeleer Co-authored-by: Adrien DELSALLE --- HISTORY.md | 1 + pyturbo/systems/channel/__init__.py | 6 ++++++ .../systems/{structures => channel}/channel.py | 3 +-- .../{structures => channel}/channel_aero.py | 0 .../{structures => channel}/channel_geom.py | 0 pyturbo/systems/duct/__init__.py | 3 +++ pyturbo/systems/duct/fan_duct.py | 16 ++++++++++++++++ .../fan_duct.py => duct/fan_duct_geom.py} | 12 ------------ pyturbo/systems/fan_module/fan_module.py | 2 +- pyturbo/systems/structures/__init__.py | 6 +----- .../systems/structures/intermediate_casing.py | 2 +- pyturbo/systems/turbofan/turbofan.py | 6 ++++-- pyturbo/systems/turbofan/turbofan_geom.py | 4 ++++ tests/test_structures.py | 2 +- 14 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 pyturbo/systems/channel/__init__.py rename pyturbo/systems/{structures => channel}/channel.py (83%) rename pyturbo/systems/{structures => channel}/channel_aero.py (100%) rename pyturbo/systems/{structures => channel}/channel_geom.py (100%) create mode 100644 pyturbo/systems/duct/__init__.py create mode 100644 pyturbo/systems/duct/fan_duct.py rename pyturbo/systems/{structures/fan_duct.py => duct/fan_duct_geom.py} (77%) diff --git a/HISTORY.md b/HISTORY.md index bfa3f36..7674c44 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -16,6 +16,7 @@ - Fix `TurbineAero` exit total pressure computation from polytropic efficiency - Fix some descriptions, especially related to gas models +- Fix incorrectly automatic pulling of `fan_duct_core_cowl_slope` in `Turbofan` ## 0.1.0 (2022-10-18) diff --git a/pyturbo/systems/channel/__init__.py b/pyturbo/systems/channel/__init__.py new file mode 100644 index 0000000..73b3848 --- /dev/null +++ b/pyturbo/systems/channel/__init__.py @@ -0,0 +1,6 @@ +from pyturbo.systems.channel.channel_aero import ChannelAero +from pyturbo.systems.channel.channel_geom import ChannelGeom + +from pyturbo.systems.channel.channel import Channel # isort: skip + +__all__ = ["ChannelAero", "ChannelGeom", "Channel"] diff --git a/pyturbo/systems/structures/channel.py b/pyturbo/systems/channel/channel.py similarity index 83% rename from pyturbo/systems/structures/channel.py rename to pyturbo/systems/channel/channel.py index d04b7c9..96857eb 100644 --- a/pyturbo/systems/structures/channel.py +++ b/pyturbo/systems/channel/channel.py @@ -1,7 +1,6 @@ from cosapp.systems import System -from pyturbo.systems.structures.channel_aero import ChannelAero -from pyturbo.systems.structures.channel_geom import ChannelGeom +from pyturbo.systems.channel import ChannelAero, ChannelGeom class Channel(System): diff --git a/pyturbo/systems/structures/channel_aero.py b/pyturbo/systems/channel/channel_aero.py similarity index 100% rename from pyturbo/systems/structures/channel_aero.py rename to pyturbo/systems/channel/channel_aero.py diff --git a/pyturbo/systems/structures/channel_geom.py b/pyturbo/systems/channel/channel_geom.py similarity index 100% rename from pyturbo/systems/structures/channel_geom.py rename to pyturbo/systems/channel/channel_geom.py diff --git a/pyturbo/systems/duct/__init__.py b/pyturbo/systems/duct/__init__.py new file mode 100644 index 0000000..9344101 --- /dev/null +++ b/pyturbo/systems/duct/__init__.py @@ -0,0 +1,3 @@ +from pyturbo.systems.duct.fan_duct import FanDuct + +__all__ = ["FanDuct"] diff --git a/pyturbo/systems/duct/fan_duct.py b/pyturbo/systems/duct/fan_duct.py new file mode 100644 index 0000000..96e92e1 --- /dev/null +++ b/pyturbo/systems/duct/fan_duct.py @@ -0,0 +1,16 @@ +# Copyright (C) 2022, twiinIT +# SPDX-License-Identifier: BSD-3-Clause + + +from cosapp.base import System + +from pyturbo.systems.channel import ChannelAero +from pyturbo.systems.duct.fan_duct_geom import FanDuctGeom + + +class FanDuct(System): + """Fan duct assembly system.""" + + def setup(self): + self.add_child(FanDuctGeom("geom"), pulling=["kp", "core_cowl_slope"]) + self.add_child(ChannelAero("aero"), pulling=["fl_in", "fl_out"]) diff --git a/pyturbo/systems/structures/fan_duct.py b/pyturbo/systems/duct/fan_duct_geom.py similarity index 77% rename from pyturbo/systems/structures/fan_duct.py rename to pyturbo/systems/duct/fan_duct_geom.py index 0831713..0b9f38d 100644 --- a/pyturbo/systems/structures/fan_duct.py +++ b/pyturbo/systems/duct/fan_duct_geom.py @@ -8,8 +8,6 @@ from pyoccad.create import CreateAxis, CreateBezier, CreateEdge, CreateRevolution, CreateTopology from pyturbo.systems.generic import GenericSimpleGeom -from pyturbo.systems.structures.channel import Channel -from pyturbo.systems.structures.channel_aero import ChannelAero from pyturbo.utils import rz_to_3d, slope_to_3d @@ -55,13 +53,3 @@ def _to_occt(self) -> Dict[str, TopoDS_Shape]: outer_shell = CreateRevolution.surface_from_curve(e2, CreateAxis.oz()) return CreateTopology.make_compound(inner_shell, outer_shell) - - -class FanDuct(Channel): - """Fan duct assembly system.""" - - def setup(self, geom_class=FanDuctGeom, aero_class=ChannelAero): - if geom_class is not None: - self.add_child(geom_class("geom"), pulling=["kp", "core_cowl_slope"]) - if aero_class is not None: - self.add_child(aero_class("aero"), pulling=["fl_in", "fl_out"]) diff --git a/pyturbo/systems/fan_module/fan_module.py b/pyturbo/systems/fan_module/fan_module.py index 791e9c2..1f33dce 100644 --- a/pyturbo/systems/fan_module/fan_module.py +++ b/pyturbo/systems/fan_module/fan_module.py @@ -1,12 +1,12 @@ import numpy as np from cosapp.systems import System +from pyturbo.systems.channel import Channel from pyturbo.systems.compressor import Booster, Fan from pyturbo.systems.fan_module.fan_module_geom import FanModuleGeom from pyturbo.systems.fan_module.spinner import SpinnerGeom from pyturbo.systems.mixers import MixerFluid, MixerShaft from pyturbo.systems.structures import IntermediateCasing -from pyturbo.systems.structures.channel import Channel from pyturbo.utils import JupyterViewable diff --git a/pyturbo/systems/structures/__init__.py b/pyturbo/systems/structures/__init__.py index 1499b18..4f6829c 100644 --- a/pyturbo/systems/structures/__init__.py +++ b/pyturbo/systems/structures/__init__.py @@ -1,8 +1,4 @@ -from pyturbo.systems.structures.channel import Channel -from pyturbo.systems.structures.channel_aero import ChannelAero -from pyturbo.systems.structures.channel_geom import ChannelGeom from pyturbo.systems.structures.core_cowl import CoreCowl -from pyturbo.systems.structures.fan_duct import FanDuct from pyturbo.systems.structures.intermediate_casing import IntermediateCasing -__all__ = ["ChannelAero", "ChannelGeom", "Channel", "IntermediateCasing", "FanDuct", "CoreCowl"] +__all__ = ["IntermediateCasing", "CoreCowl"] diff --git a/pyturbo/systems/structures/intermediate_casing.py b/pyturbo/systems/structures/intermediate_casing.py index 0fe8d18..f1c07c6 100644 --- a/pyturbo/systems/structures/intermediate_casing.py +++ b/pyturbo/systems/structures/intermediate_casing.py @@ -1,7 +1,7 @@ from cosapp.systems import System +from pyturbo.systems.channel import ChannelAero from pyturbo.systems.generic import GenericSimpleGeom -from pyturbo.systems.structures.channel_aero import ChannelAero class IntermediateCasing(System): diff --git a/pyturbo/systems/turbofan/turbofan.py b/pyturbo/systems/turbofan/turbofan.py index 057708e..02017cf 100644 --- a/pyturbo/systems/turbofan/turbofan.py +++ b/pyturbo/systems/turbofan/turbofan.py @@ -5,12 +5,14 @@ from OCC.Core.TopoDS import TopoDS_Shape from pyturbo.systems.atmosphere import Atmosphere +from pyturbo.systems.channel import Channel +from pyturbo.systems.duct import FanDuct from pyturbo.systems.fan_module import FanModule from pyturbo.systems.gas_generator import GasGenerator from pyturbo.systems.inlet import Inlet from pyturbo.systems.nacelle import Nacelle, Plug from pyturbo.systems.nozzle import Nozzle -from pyturbo.systems.structures import Channel, CoreCowl, FanDuct +from pyturbo.systems.structures import CoreCowl from pyturbo.systems.turbine import LPT from pyturbo.systems.turbofan.turbofan_aero import TurbofanAero from pyturbo.systems.turbofan.turbofan_geom import TurbofanGeom @@ -157,7 +159,7 @@ def setup(self): self.connect(self.trf.kp, self.plug.inwards, {"exit_hub": "trf_exit_hub_kp"}) self.connect(self.geom.secondary_nozzle_kp, self.fan_duct.kp) - self.connect(self.geom, self.fan_duct, ["core_cowl_slope"]) + self.connect(self.geom, self.fan_duct, {"fan_duct_core_cowl_slope": "core_cowl_slope"}) self.connect( self.geom, diff --git a/pyturbo/systems/turbofan/turbofan_geom.py b/pyturbo/systems/turbofan/turbofan_geom.py index e5cb915..8ef0d50 100644 --- a/pyturbo/systems/turbofan/turbofan_geom.py +++ b/pyturbo/systems/turbofan/turbofan_geom.py @@ -262,6 +262,7 @@ def setup(self): self.add_outward("sec_nozzle_exit_kp", np.ones(2), unit="m") self.add_outward("sec_nozzle_exit_hub_kp", C1Keypoint()) + self.add_outward("fan_duct_core_cowl_slope", unit="deg") self.add_outward("frd_mount", np.r_[0.9, 0.5], desc="forward engine mount") self.add_outward("aft_mount", np.r_[0.5, 3.0], desc="aftward engine mount") @@ -414,6 +415,9 @@ def compute(self): self.turbine_exit_tip_kp = self.turbine_kp.exit_tip self.sec_nozzle_exit_kp = self.secondary_nozzle_kp.exit_tip + # fan_duct + self.fan_duct_core_cowl_slope = self.core_cowl_slope + # mounts r = self.frd_mount_relative self.frd_mount = (1 - r) * self.fanmodule_kp.inlet_tip + r * self.fanmodule_kp.exit_tip diff --git a/tests/test_structures.py b/tests/test_structures.py index ede4464..ac16d1c 100644 --- a/tests/test_structures.py +++ b/tests/test_structures.py @@ -1,8 +1,8 @@ import numpy as np from cosapp.drivers import NonLinearSolver +from pyturbo.systems.channel import Channel from pyturbo.systems.structures import IntermediateCasing -from pyturbo.systems.structures.channel import Channel class TestChannel: