From 1959590c8130a36ba9a85206aff808f658af54c4 Mon Sep 17 00:00:00 2001 From: smidl Date: Fri, 19 Jun 2026 14:40:15 +0200 Subject: [PATCH] Fix Design2 (5-phase): drop unsupported ddt() output vars; restore rotor_r_min/max Two bugs prevented the 5-phase Design2 from running end-to-end in ANSYS Maxwell 2D (verified on v242 / pyaedt 0.11.2): 1. Terminal-voltage output variables V_A..V_E used Lew*ddt(InputCurrent(..)). Maxwell's output-variable parser does not support ddt(); creating these fails with "abnormal script termination". That broke V_A..V_E and every dependent variable (V_AC.., Vterm_*, V_d1/q1/d3/q3). Because solution_expressions lists V_d1..V_q3, get_solution_data then failed for the whole batch and compute() returned None. The dropped term is the end-winding leakage voltage Lew*ddt(I); Lew=0, so removing it is physically identical. If Lew!=0 is ever needed, compute that drop in post-processing. 2. set_derived_params was stubbed `pass`, leaving rotor_r_min/rotor_r_max unset, so any BarrierGenerator(design, ..) failed (it reads those attrs). The base implementation derives them from the inherited shaft/gap diameters, which Design2 already defines, so defer to super(). Validated on bayes (ANSYS v242): build now produces 0 output-variable errors (was ~22); a solid rotor solves to ~0 Nm and a HacklGenerator_OneLambda barrier rotor solves to ~35.7 Nm at 7.1/7.1 A dq1 current. Co-Authored-By: Claude Opus 4.8 (1M context) --- machine_design/design2.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/machine_design/design2.py b/machine_design/design2.py index 8b982db..17e4fdf 100644 --- a/machine_design/design2.py +++ b/machine_design/design2.py @@ -38,7 +38,11 @@ def set_oper_params(self): } def set_derived_params(self): - pass + # Derive rotor_r_min/max from the (inherited) shaft and stator-gap + # diameters; the BarrierGenerators require these. Previously stubbed + # `pass`, which left them unset and broke barrier generation for the + # 5-phase design. + super().set_derived_params() def set_solution_expressions(self): self.solution_expressions = [ @@ -102,11 +106,17 @@ def set_output_vars(self): "Vind_q1": "(InducedVoltage(PhaseA)*sin0_1 + InducedVoltage(PhaseB)*sin1_1 + InducedVoltage(PhaseC)*sin2_1 + InducedVoltage(PhaseD)*sin3_1 + InducedVoltage(PhaseE)*sin4_1) * 2/5", "Vind_d3": "(InducedVoltage(PhaseA)*cos0_3 + InducedVoltage(PhaseB)*cos1_3 + InducedVoltage(PhaseC)*cos2_3 + InducedVoltage(PhaseD)*cos3_3 + InducedVoltage(PhaseE)*cos4_3) * 2/5", "Vind_q3": "(InducedVoltage(PhaseA)*sin0_3 + InducedVoltage(PhaseB)*sin1_3 + InducedVoltage(PhaseC)*sin2_3 + InducedVoltage(PhaseD)*sin3_3 + InducedVoltage(PhaseE)*sin4_3) * 2/5", - "V_A": "InducedVoltage(PhaseA) + Rstat*InputCurrent(PhaseA) + Lew*ddt(InputCurrent(PhaseA))", - "V_B": "InducedVoltage(PhaseB) + Rstat*InputCurrent(PhaseB) + Lew*ddt(InputCurrent(PhaseB))", - "V_C": "InducedVoltage(PhaseC) + Rstat*InputCurrent(PhaseC) + Lew*ddt(InputCurrent(PhaseC))", - "V_D": "InducedVoltage(PhaseD) + Rstat*InputCurrent(PhaseD) + Lew*ddt(InputCurrent(PhaseD))", - "V_E": "InducedVoltage(PhaseE) + Rstat*InputCurrent(PhaseE) + Lew*ddt(InputCurrent(PhaseE))", + # NOTE: Maxwell's output-variable parser does not support ddt(); an + # expression containing it fails with "abnormal script termination", + # which previously broke V_A..V_E and every dependent (V_AC.., Vterm_*, + # V_d1/q1/d3/q3). The dropped term is Lew*ddt(I) (end-winding leakage + # voltage); Lew=0 here so it is identically zero. If Lew!=0 is ever + # needed, compute that drop in post-processing, not as an output var. + "V_A": "InducedVoltage(PhaseA) + Rstat*InputCurrent(PhaseA)", + "V_B": "InducedVoltage(PhaseB) + Rstat*InputCurrent(PhaseB)", + "V_C": "InducedVoltage(PhaseC) + Rstat*InputCurrent(PhaseC)", + "V_D": "InducedVoltage(PhaseD) + Rstat*InputCurrent(PhaseD)", + "V_E": "InducedVoltage(PhaseE) + Rstat*InputCurrent(PhaseE)", "V_AC": "V_A - V_C", "V_BD": "V_B - V_D", "V_CE": "V_C - V_E",