You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compare optimal rotors of a 3-phase and a 5-phase machine on a common stator at nominal operation #45
The two machines on main (motors/synrm_3f_36s.py, motors/synrm_5f_40s.py) have different slots per pole per phase ($q=3$ vs $q=2$) and different slot geometry, so a 3φ/5φ comparison on them would be confounded by the winding. A common 60-slot stator pair exists on branch vs_5f (Design_60: 3φ, $q=5$; Design2_60: 5φ, $q=3$; same bore, same rotor family).
Port the pair to main as two anchors, motors/synrm_3f_60s.py and motors/synrm_5f_60s.py, following the existing motors/ layout — one small PR. Check that each solves and that both accept the same rotor.
Design both rotors for the same nominal operating point (nominal torque at nominal speed, no current or voltage limit active). Design variables: rotor geometry (HacklGenerator_SixLambdas) and the current — $(i_d, i_q)$ for 3φ, $(i^1_d, i^1_q, i^3_d, i^3_q)$ for 5φ. Objective: minimum Joule loss $\mathbf{i}^\top\mathbf{i}$ s.t. torque $\ge T^$ and ripple $\le$ cap, same $T^$ and cap for both machines. Method: the ICEM multi-objective BO with the current appended to the design vector.
Report for each machine: the optimal rotor (barrier plot), loss and ripple; for the 5φ machine also $|\mathbf{i}^3|/|\mathbf{i}^1|$ at the optimum.
Experiment files go under experiments/<name>-3f-vs-5f-nominal/; the current-in-the-design-vector part should go through the generic interface in CONTRIBUTING.md so it can be reused on other machines.
@haitao-ZCU If I remember correctly, the currents are currently passed to both motors in a different way (for 3-phase, they are hard-coded, for 5-phase, they are input parameters). If this is so, it should be unified because it will make the whole process simpler.
About "Test - 5-phase with id3=iq3=0 performs the same as 3-phase."
When I test whether 5f_60s (id3=iq3=0) performs the same as 3f_60s, I fond synrm_3f_60s.py and synrm_5f_60s.py still have different Nc (turns per coil): 68 vs 113, which carried over unchanged from the old 36s/40s anchors, but everything else geometric matches. The results are as follows.
Same rotor, same (Id, Iq), Id3=Iq3=0 on the 5-phase side:
current
Nc
3f TorAvg
5f(i3=0) TorAvg
diff
(1.5,1.5)
68 vs 113
8.28
15.91
92%
(3,3)
68 vs 113
16.33
28.25
73%
(1.5,1.5)
both 113
13.82 / 14.24
15.91 / 16.20
15.1% / 13.8%
(3,3)
both 113
24.86 / 26.24
28.25 / 30.21
13.6% / 15.1%
(last two rows across seeds 42/43)
when we use the same values of Nc, the gap drops to a steady ~14%, doesn't move with current or seed.
but I'm not sure whether we should use the same Nc value or not.
@haitao-ZCU I expected that they would result in the same torque. Either my understanding is wrong or there is something wrong in the code. Could you please try to reason which one happened?
@haitao-ZCU I need your input, not only to ask Claude to generate results. There is no point in comparing motors with different parameters (Nc) or in performing the sweep over the angles InitPos. From what I understand, there is an error in the computation of InitPos, which needs to be connected to the other parameters and cannot be arbitrary. Is it correct? If so, please fix that. I was probably wrong about the equivalence of the motors because the wiring of the slots to the phases is different in 3-phase and 5-phase machines. Anyway, please run the experiments again and report the error. It should be relatively small, though.
Hi, Lukas, I have went through the calculation of InitPos carefully and made a detailed mathematical derivation of InitPos. Now, I am confident that the correct value for the 5f 60s machine is -42deg, and I will use this value in the following calculations and tests instead of directly inheriting -45deg from the 5f 40s machine. This is the mathematical derivation process: https://github.com/AI-RICE/MachineDesign/blob/check-nc-effect/scripts/InitPos.pdf
I also checked the other three machines. The values are -30deg for 3f 36s, -30deg for 3f 60s, and -45deg for 5f 40s. So for 3f 60s, inheriting the value happened to give the correct result.
@haitao-ZCU Ok, good. In such a case, it should be implemented in the code so that people do not need to manually perform this computation. That means adding a new method which computes InitPos after all the variables are set. The implementation should also allow people to overwrite it if they need a different value.
Hi, yes, the Nc should be the same. I has an impact only for the voltage equation, so I tried to play around with it in 5f. For 3f vs 5f comparison, it should match. When we would consider differences in FW, we could relax it, but its effect is not too significant. @saxik13 may have an idea what would be a fair value.
I was not concerned with the InitPos since we were seeping through the angle and looking at the mean torque and ripple. These should be unaffected by InitPos (I hope). If you want only one angle comparison, then the position should match. Thanks for fixing.
I have implement the general function to compute InitPos, which will be uploaded with PR #49 later.
And I also use the same Nc to test 3f_60s and 5f_60s machines with seeds (42, 43). the results are as follows:
Same rotor, same (Id, Iq), Id3=Iq3=0 on the 5-phase side, Nc=113 on both:
@smidl Not yet. There is still some work on creating the two motor anchors. Also, Haitao may have found a bug with units, which needs to be verified with Honza first.
Nc must be different for the 3-phase and 5-phase machines, approximately in the ratio 3:5 (3-phase-to-5-phase). But the currents are in the reverse ratio 5:3.
Then the machines are designed for the same voltage levels and have approximately the same characteristics - they are comparable.
@saxik13@sadda
Thanks for the explanation.
I want to make sure whether I understand correctly about "Test - 5-phase with id3=iq3=0 performs the same as 3-phase.":
does this mean the test shouldn't force Nc to be equal between 3f_60s and 5f_60s (for example, keep each machine's own Nc 68 and 113), and set the currents in the 5:3 ratio, for example id=iq=5 for 3f_60s and id1=iq1=3, id3=iq3=0 for 5f_60s?
Exactly. The number of turns per coil Nc=68 was already adjusted to the 5-phase machine from original 3-phase Nc=113.
Then set the currents in this ratio and the results are comparable now
@saxik13 That makes more sense. I wanted to make sure that the code works ok and wanted to see that in the case of keeping the number of coils and current the same. But increasing the number of coils and keeping the current smaller makes more sense.
@sadda@saxik13
I have modified the test file, letting Nc to inherit from 3f_36s and 5f_40s respectively (namely 68 for 3f_60s, 113 for 5f_60s), the results are now as follows:
This would work for amplitude-invariant Park, but in that case, norm(i) is not a proxy for Joule losses, we would need to compensate for the phases. I mean it is fine for optimisation of one machine, but not for naively comparing 3f with 5f.
I see,
I have plotted the waveform of phase currents, and it is obvious that we use the amplitude-invariant Park, so comparing machines with different phase counts needs the factor (Rstat*n_phase/2). But for optimizing a single machine, this constant factor does not affect the results.
So, we can make amplitude-invariant Park the default project wise. May be worth testing that it really is that way even in Ansys etc.
Torque identity: $T_{dq}=\tfrac m2,p,\big[(\psi_{d1}i_{q1}-\psi_{q1}i_{d1})+3(\psi_{d3}i_{q3}-\psi_{q3}i_{d3})\big]$ (period mean) must match Moving1.Torque to a few percent. The $m/2$ assumes the amplitude-invariant dq transform in generic/transforms.py; state that in the test. (The expression exists, commented out, in synrm_5f_40s.py.)
Voltage identity: $V_{q1}-R_sI_{q1}=\omega\psi_{d1}$ and $V_{d1}-R_sI_{d1}=-\omega\psi_{q1}$ with $\omega=2\pi f$, period means, same tolerance; same for the 3rd harmonic with $3\omega$.
Activity
sadda commentedon Sep 21, 2026
@haitao-ZCU If I remember correctly, the currents are currently passed to both motors in a different way (for 3-phase, they are hard-coded, for 5-phase, they are input parameters). If this is so, it should be unified because it will make the whole process simpler.
haitao-ZCU commentedon Sep 21, 2026
@sadda
got it, I'll propose a PR to unify this, both of the currents should be parameterized.
haitao-ZCU commentedon Sep 23, 2026
@sadda
About "Test - 5-phase with id3=iq3=0 performs the same as 3-phase."
When I test whether 5f_60s (id3=iq3=0) performs the same as 3f_60s, I fond synrm_3f_60s.py and synrm_5f_60s.py still have different Nc (turns per coil): 68 vs 113, which carried over unchanged from the old 36s/40s anchors, but everything else geometric matches. The results are as follows.
Same rotor, same (Id, Iq), Id3=Iq3=0 on the 5-phase side:
(last two rows across seeds 42/43)
when we use the same values of Nc, the gap drops to a steady ~14%, doesn't move with current or seed.
but I'm not sure whether we should use the same Nc value or not.
the link of test file is https://github.com/AI-RICE/MachineDesign/blob/check-nc-effect/tests/test_synrm_60s_torque_i3_zero.py
sadda commentedon Sep 23, 2026
@haitao-ZCU I expected that they would result in the same torque. Either my understanding is wrong or there is something wrong in the code. Could you please try to reason which one happened?
haitao-ZCU commentedon Sep 25, 2026
@sadda
Hi, Lukas, I have tested many cases to find the problem, and summarized all these cases in the short report, but I still have two confusions, one is the value of "Nc", another one is the value of "InitPos" in 5f_60s machine, according to the project code ( it should be -42deg instead of -45deg, but I couldn't ensure that 100%, so I'd appreciate your suggestions).
this is the short report
https://github.com/AI-RICE/MachineDesign/blob/check-nc-effect/tests/zero_3rd_harmonic_current_test.pdf
this is the corresponding test code:
https://github.com/AI-RICE/MachineDesign/blob/check-nc-effect/tests/test_synrm_60s_torque_i3_zero.py
sadda commentedon Sep 25, 2026
@haitao-ZCU I need your input, not only to ask Claude to generate results. There is no point in comparing motors with different parameters (
Nc) or in performing the sweep over the anglesInitPos. From what I understand, there is an error in the computation ofInitPos, which needs to be connected to the other parameters and cannot be arbitrary. Is it correct? If so, please fix that. I was probably wrong about the equivalence of the motors because the wiring of the slots to the phases is different in 3-phase and 5-phase machines. Anyway, please run the experiments again and report the error. It should be relatively small, though.haitao-ZCU commentedon Sep 26, 2026
@sadda
Hi, Lukas, I have went through the calculation of InitPos carefully and made a detailed mathematical derivation of InitPos. Now, I am confident that the correct value for the 5f 60s machine is -42deg, and I will use this value in the following calculations and tests instead of directly inheriting -45deg from the 5f 40s machine. This is the mathematical derivation process:
https://github.com/AI-RICE/MachineDesign/blob/check-nc-effect/scripts/InitPos.pdf
I also checked the other three machines. The values are -30deg for 3f 36s, -30deg for 3f 60s, and -45deg for 5f 40s. So for 3f 60s, inheriting the value happened to give the correct result.
sadda commentedon Sep 29, 2026
@haitao-ZCU Ok, good. In such a case, it should be implemented in the code so that people do not need to manually perform this computation. That means adding a new method which computes
InitPosafter all the variables are set. The implementation should also allow people to overwrite it if they need a different value.haitao-ZCU commentedon Sep 29, 2026
@sadda
I agree with you on this point, I'll do it now.
smidl commentedon Sep 29, 2026
Hi, yes, the Nc should be the same. I has an impact only for the voltage equation, so I tried to play around with it in 5f. For 3f vs 5f comparison, it should match. When we would consider differences in FW, we could relax it, but its effect is not too significant. @saxik13 may have an idea what would be a fair value.
smidl commentedon Sep 29, 2026
I was not concerned with the InitPos since we were seeping through the angle and looking at the mean torque and ripple. These should be unaffected by InitPos (I hope). If you want only one angle comparison, then the position should match. Thanks for fixing.
haitao-ZCU commentedon Sep 29, 2026
@sadda
I have implement the general function to compute InitPos, which will be uploaded with PR #49 later.
And I also use the same Nc to test 3f_60s and 5f_60s machines with seeds (42, 43). the results are as follows:
Same rotor, same (Id, Iq), Id3=Iq3=0 on the 5-phase side, Nc=113 on both:
compute_initpos())compute_initpos())compute_initpos())sadda commentedon Sep 29, 2026
@haitao-ZCU Good, this seems to be much better.
smidl commentedon Sep 29, 2026
Agreed, but id3=0 is not where the fun is. @haitao-ZCU are you ready to move to joint optimization per point 2 of this issue?
sadda commentedon Sep 30, 2026
@smidl Not yet. There is still some work on creating the two motor anchors. Also, Haitao may have found a bug with units, which needs to be verified with Honza first.
saxik13 commentedon Sep 30, 2026
Nc must be different for the 3-phase and 5-phase machines, approximately in the ratio 3:5 (3-phase-to-5-phase). But the currents are in the reverse ratio 5:3.
Then the machines are designed for the same voltage levels and have approximately the same characteristics - they are comparable.
haitao-ZCU commentedon Sep 30, 2026
@saxik13 @sadda
Thanks for the explanation.
I want to make sure whether I understand correctly about "Test - 5-phase with id3=iq3=0 performs the same as 3-phase.":
does this mean the test shouldn't force Nc to be equal between 3f_60s and 5f_60s (for example, keep each machine's own Nc 68 and 113), and set the currents in the 5:3 ratio, for example id=iq=5 for 3f_60s and id1=iq1=3, id3=iq3=0 for 5f_60s?
saxik13 commentedon Sep 30, 2026
Exactly. The number of turns per coil Nc=68 was already adjusted to the 5-phase machine from original 3-phase Nc=113.
Then set the currents in this ratio and the results are comparable now
sadda commentedon Sep 30, 2026
@saxik13 That makes more sense. I wanted to make sure that the code works ok and wanted to see that in the case of keeping the number of coils and current the same. But increasing the number of coils and keeping the current smaller makes more sense.
haitao-ZCU commentedon Sep 30, 2026
@sadda @saxik13
I have modified the test file, letting Nc to inherit from 3f_36s and 5f_40s respectively (namely 68 for 3f_60s, 113 for 5f_60s), the results are now as follows:
smidl commentedon Oct 7, 2026
The ratio of the currents is in dq frame? What Park transform you assume? Power-invariant?
smidl commentedon Oct 7, 2026
This would work for amplitude-invariant Park, but in that case, norm(i) is not a proxy for Joule losses, we would need to compensate for the phases. I mean it is fine for optimisation of one machine, but not for naively comparing 3f with 5f.
haitao-ZCU commentedon Oct 8, 2026
I see,
I have plotted the waveform of phase currents, and it is obvious that we use the amplitude-invariant Park, so comparing machines with different phase counts needs the factor (Rstat*n_phase/2). But for optimizing a single machine, this constant factor does not affect the results.
smidl commentedon Oct 8, 2026
So, we can make amplitude-invariant Park the default project wise. May be worth testing that it really is that way even in Ansys etc.
Torque identity:$T_{dq}=\tfrac m2,p,\big[(\psi_{d1}i_{q1}-\psi_{q1}i_{d1})+3(\psi_{d3}i_{q3}-\psi_{q3}i_{d3})\big]$ (period mean) must match Moving1.Torque to a few percent. The $m/2$ assumes the amplitude-invariant dq transform in generic/transforms.py; state that in the test. (The expression exists, commented out, in synrm_5f_40s.py.)
Voltage identity:$V_{q1}-R_sI_{q1}=\omega\psi_{d1}$ and $V_{d1}-R_sI_{d1}=-\omega\psi_{q1}$ with $\omega=2\pi f$ , period means, same tolerance; same for the 3rd harmonic with $3\omega$ .