From ee602eebe0f70be50c5ea7c656a62bcda6d2bdd8 Mon Sep 17 00:00:00 2001 From: haitao-ZCU Date: Wed, 15 Jul 2026 16:02:54 +0200 Subject: [PATCH 1/3] fix: convert units directly in extract_results --- motors/motor2.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/motors/motor2.py b/motors/motor2.py index 0162493..1f34021 100644 --- a/motors/motor2.py +++ b/motors/motor2.py @@ -333,14 +333,15 @@ def set_variables(self, m2d: Maxwell2d, Id1, Iq1, Id3, Iq3): m2d.variable_manager["Iq3"] = f"{Iq3}A" def extract_results(self, solutions): - # TODO: this works only because torque is the last one in the array - out = np.zeros(len(self.solution_expressions)) - for i, expr in enumerate(self.solution_expressions): + out = {} + for expr in self.solution_expressions: data = solutions.data_real(expr) val = float(np.mean(data[:-1])) - if expr.startswith("L_"): + if expr.startswith("Ld") or expr.startswith("Lq"): val /= 1e9 + elif expr.startswith("I_"): + val /= 1e3 - out[i] = val + out[expr] = val return out From 524dcbcc6f99a7a6d9aa90fc184b3d5f7b2780c5 Mon Sep 17 00:00:00 2001 From: Lukas Adam Date: Wed, 15 Jul 2026 19:39:49 +0200 Subject: [PATCH 2/3] Returning whole array --- motors/motor2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/motors/motor2.py b/motors/motor2.py index 1f34021..27ee297 100644 --- a/motors/motor2.py +++ b/motors/motor2.py @@ -335,13 +335,13 @@ def set_variables(self, m2d: Maxwell2d, Id1, Iq1, Id3, Iq3): def extract_results(self, solutions): out = {} for expr in self.solution_expressions: - data = solutions.data_real(expr) - val = float(np.mean(data[:-1])) + val = solutions.data_real(expr) if expr.startswith("Ld") or expr.startswith("Lq"): val /= 1e9 elif expr.startswith("I_"): val /= 1e3 + # TODO: possibly assign val[:-1]. check whether values are identical out[expr] = val return out From 6ea9a923e1bdf8afaf969dda058070fd44ddef87 Mon Sep 17 00:00:00 2001 From: Lukas Adam Date: Wed, 15 Jul 2026 19:41:37 +0200 Subject: [PATCH 3/3] Ruff --- motors/motor2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/motors/motor2.py b/motors/motor2.py index 27ee297..40c5bd6 100644 --- a/motors/motor2.py +++ b/motors/motor2.py @@ -1,4 +1,3 @@ -import numpy as np from ansys.aedt.core import Maxwell2d from machine_design.designs.computation import ComputationBase