Skip to content

Commit 14b7176

Browse files
committed
Revert NumPy 2.x / OpenMDAO 3.43 compatibility changes
1 parent 77675c3 commit 14b7176

2 files changed

Lines changed: 8 additions & 38 deletions

File tree

openconcept/aerodynamics/drag_jet_transport.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,6 @@ def compute(self, inputs, outputs):
578578
# Reynolds number
579579
Re = inputs["fltcond|Utrue"] * inputs["L"] / visc_kin
580580

581-
# During Newton iterations, Utrue can temporarily go negative, making Re
582-
# negative and causing log(negative) = NaN. Apply abs only for the real part so
583-
# complex-step derivative checking still propagates the imaginary part correctly.
584-
if np.isrealobj(Re):
585-
Re = np.abs(Re)
586-
else:
587-
Re = np.where(np.real(Re) < 0, -Re, Re)
588-
589581
# Skin friction coefficient assuming fully turbulent
590582
Cf = 0.523 / np.log(0.06 * Re) ** 2 # explicit fit of Spalding
591583

@@ -611,15 +603,14 @@ def compute_partials(self, inputs, J):
611603
dvkin_dT = dvdyn_dT / inputs["fltcond|rho"]
612604
dvkin_drho = -visc_dyn / inputs["fltcond|rho"] ** 2
613605

614-
# Reynolds number (absolute value of velocity to handle negative Utrue during Newton iterations)
606+
# Reynolds number
615607
U = inputs["fltcond|Utrue"]
616-
absU = np.abs(U)
617608
L = inputs["L"]
618-
Re = absU * L / visc_kin
619-
dRe_dT = -absU * L / visc_kin**2 * dvkin_dT
620-
dRe_drho = -absU * L / visc_kin**2 * dvkin_drho
621-
dRe_dU = np.sign(U) * L / visc_kin
622-
dRe_dL = absU / visc_kin
609+
Re = U * L / visc_kin
610+
dRe_dT = -U * L / visc_kin**2 * dvkin_dT
611+
dRe_drho = -U * L / visc_kin**2 * dvkin_drho
612+
dRe_dU = L / visc_kin
613+
dRe_dL = U / visc_kin
623614

624615
# Skin friction coefficient assuming fully turbulent
625616
Cf = 0.523 / np.log(0.06 * Re) ** 2 # explicit fit of Spalding

openconcept/examples/HybridTwin_thermal.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,7 @@ def setup(self):
6161
# any control variables other than throttle and braking need to be defined here
6262
controls = self.add_subsystem("controls", IndepVarComp(), promotes_outputs=["*"])
6363
controls.add_output("proprpm", val=np.ones((nn,)) * 2000, units="rpm")
64-
# mdot_coolant is a per-phase control vector of shape (nn,), where nn differs between
65-
# phases (e.g. nn=11 for climb/cruise/descent, nn=1 for engineoutclimb). If this were
66-
# promoted under its ac|propulsion|* name, all phases would expose the same promoted name
67-
# at the parent analysis level with different shapes, which OpenMDAO 3.43+ rejects.
68-
# Instead, give it a local name and wire it into the propulsion model via an explicit
69-
# connect() below, keeping it entirely within this group's scope.
70-
controls.add_output("phase_hx_mdot_coolant", val=0.1 * np.ones((nn,)), units="kg/s")
64+
controls.add_output("ac|propulsion|thermal|hx|mdot_coolant", val=0.1 * np.ones((nn,)), units="kg/s")
7165

7266
# assume TO happens on battery backup
7367
if flight_phase in ["climb", "cruise", "descent"]:
@@ -82,23 +76,9 @@ def setup(self):
8276
)
8377

8478
propulsion_promotes_outputs = ["fuel_flow", "thrust", "ac|propulsion|thermal|duct|area_nozzle"]
85-
# Explicitly list ac|propulsion|* inputs except mdot_coolant, which has a per-phase
86-
# (nn,) shape and is connected directly below to avoid analysis-level shape conflicts.
8779
propulsion_promotes_inputs = [
8880
"fltcond|*",
89-
"ac|propulsion|battery|specific_energy",
90-
"ac|propulsion|engine|rating",
91-
"ac|propulsion|generator|rating",
92-
"ac|propulsion|motor|rating",
93-
"ac|propulsion|propeller|diameter",
94-
"ac|propulsion|thermal|hx|channel_height",
95-
"ac|propulsion|thermal|hx|channel_length",
96-
"ac|propulsion|thermal|hx|channel_width",
97-
"ac|propulsion|thermal|hx|coolant_mass",
98-
"ac|propulsion|thermal|hx|n_long_cold",
99-
"ac|propulsion|thermal|hx|n_parallel",
100-
"ac|propulsion|thermal|hx|n_tall",
101-
"ac|propulsion|thermal|hx|n_wide_cold",
81+
"ac|propulsion|*",
10282
"throttle",
10383
"propulsor_active",
10484
"ac|weights*",
@@ -113,7 +93,6 @@ def setup(self):
11393
)
11494
self.connect("proprpm", ["propmodel.prop1.rpm", "propmodel.prop2.rpm"])
11595
self.connect("hybrid_factor.vec", "propmodel.hybrid_split.power_split_fraction")
116-
self.connect("phase_hx_mdot_coolant", "propmodel.ac|propulsion|thermal|hx|mdot_coolant")
11796

11897
# use a different drag coefficient for takeoff versus cruise
11998
if flight_phase not in ["v0v1", "v1v0", "v1vr", "rotate"]:

0 commit comments

Comments
 (0)