@@ -632,33 +632,33 @@ def test_Optimization_problem(self):
632632 # Objective functions
633633
634634 def harm1 (output ):
635- """Return the first torque harmonic opposite (opposite to be maximized)"""
635+ """Return the average torque opposite (opposite to be maximized)"""
636636 N = output .simu .input .time .num
637637 x = output .mag .Tem [:, 0 ]
638638 sp = np .fft .rfft (x )
639639 sp = 2 / N * np .abs (sp )
640640 return - sp [0 ] / 2
641641
642642 def harm2 (output ):
643- """Return the second torque harmonic """
643+ """Return the first torque harmonic """
644644 N = output .simu .input .time .num
645645 x = output .mag .Tem [:, 0 ]
646646 sp = np .fft .rfft (x )
647647 sp = 2 / N * np .abs (sp )
648648 return sp [1 ]
649649
650650 objs = {
651- "First torque harmonic opposite " : OptiObjFunc (
652- description = "Maximization of the first torque harmonic " , func = harm1
651+ "Opposite average torque (Nm) " : OptiObjFunc (
652+ description = "Maximization of the average torque" , func = harm1
653653 ),
654- "Second torque harmonic" : OptiObjFunc (
655- description = "Minimization of the second torque harmonic" , func = harm2
654+ "First torque harmonic (Nm) " : OptiObjFunc (
655+ description = "Minimization of the first torque harmonic" , func = harm2
656656 ),
657657 }
658658
659659 # Design variables
660660 my_vars = {
661- "sta slot W " : OptiDesignVar (
661+ "design var 1 " : OptiDesignVar (
662662 name = "output.simu.machine.stator.slot.W0" ,
663663 type_var = "interval" ,
664664 space = [
@@ -667,7 +667,7 @@ def harm2(output):
667667 ],
668668 function = lambda space : random .uniform (* space ),
669669 ),
670- "rot magnet W " : OptiDesignVar (
670+ "design var 2 " : OptiDesignVar (
671671 name = "output.simu.machine.rotor.slot.magnet[0].Wmag" ,
672672 type_var = "interval" ,
673673 space = [
@@ -716,35 +716,34 @@ def harm2(output):
716716 out2 = [pm ["output" ], pm ["fitness" ]]
717717
718718 # Rename machine to modify the title
719- out1 [0 ].simu .machine .name = (
720- "Machine that maximizes the first torque harmonic ("
721- + str (abs (out1 [1 ][0 ]))
722- + "Nm)"
719+ name1 = "Machine that maximizes the average torque ({:.3f} Nm)" .format (
720+ abs (out1 [1 ][0 ])
723721 )
724- out2 [0 ].simu .machine .name = (
725- "Machine that minimizes the second torque harmonic ("
726- + str (abs (out1 [1 ][1 ]))
727- + "Nm)"
722+ out1 [0 ].simu .machine .name = name1
723+ name2 = "Machine that minimizes the first torque harmonic ({:.4f}Nm)" .format (
724+ abs (out1 [1 ][1 ])
728725 )
726+ out2 [0 ].simu .machine .name = name2
729727
730728 # plot the machine
731729 out1 [0 ].simu .machine .plot ()
732730 fig = plt .gcf ()
733731 fig .savefig (
734- join (save_path , "fig_21_Topology_to_maximize_first_torque_harmonic .png" ),
732+ join (save_path , "fig_21_Topology_to_maximize_average_torque .png" ),
735733 format = "png" ,
736734 )
737735 fig .savefig (
738- join (save_path , "fig_21_Topology_to_maximize_first_torque_harmonic .svg" ),
736+ join (save_path , "fig_21_Topology_to_maximize_average_torque .svg" ),
739737 format = "svg" ,
740738 )
741739
742740 out2 [0 ].simu .machine .plot ()
743741 fig = plt .gcf ()
744742 fig .savefig (
745- join (save_path , "fig_21_Topology_to_minimize_second_torque_harmonic.png" )
743+ join (save_path , "fig_21_Topology_to_minimize_first_torque_harmonic.png" ),
744+ format = "png" ,
746745 )
747746 fig .savefig (
748- join (save_path , "fig_21_Topology_to_minimize_second_torque_harmonic .svg" ),
747+ join (save_path , "fig_21_Topology_to_minimize_first_torque_harmonic .svg" ),
749748 format = "svg" ,
750749 )
0 commit comments