Numpy error in size_optimal_motor

204 views
Skip to first unread message

Yash Thummar

unread,
Dec 12, 2022, 2:55:17 AM12/12/22
to SUAVE FORUM
Hello, 
I am facing some NumPy error in size_optimal_motor.
Here is the error:

Designing propeller

 Optimum motor design failed. Using slack constraints

 Slack contraints failed. Using one constraint
Traceback (most recent call last):
  File "c:\Users\ADMIN\OneDrive\Projects\capstone_project\Download\Pra\TitltW_Vali\Vahana.py", line 447, in <module>
    main()
  File "c:\Users\ADMIN\OneDrive\Projects\capstone_project\Download\Pra\TitltW_Vali\Vahana.py", line 30, in main    
    vehicle = vehicle_setup()
  File "c:\Users\ADMIN\OneDrive\Projects\capstone_project\Download\Pra\TitltW_Vali\Vahana.py", line 305, in vehicle_setup
    propeller_motor                         = size_optimal_motor(propeller_motor,prop)
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Propulsion\electric_motor_sizing.py", line 153, in size_optimal_motor
    opt_params = optimize_kv(io, v , omeg,  etam ,  Q)
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Propulsion\electric_motor_sizing.py", line 203, in optimize_kv
    sol = minimize(objective, [10], args=(v , omeg,  etam , Q , io) , method='SLSQP', bounds=bnds, tol=1e-6, constraints= torque_con)
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\scipy\optimize\_minimize.py", line 684, in minimize
    bounds = standardize_bounds(bounds, x0, meth)
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\scipy\optimize\_minimize.py", line 947, in standardize_bounds
    bounds = new_bounds_to_old(bounds.lb, bounds.ub, x0.shape[0])
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\scipy\optimize\_constraints.py", line 397, in new_bounds_to_old
    lb = np.broadcast_to(lb, n)
  File "<__array_function__ internals>", line 180, in broadcast_to
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\lib\stride_tricks.py", line 412, in broadcast_to
    return _broadcast_to(array, shape, subok=subok, readonly=True)
  File "C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\lib\stride_tricks.py", line 348, in _broadcast_to
    it = np.nditer(
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,)  and requested shape (1,)

Currently, I am using SUAVE 2.5.2 and Numpy 1.23.5 and Also try with numpy 1.20.3 but still facing this error.
And I also attached this vehicle file.

Looking for the solution for this error.

Thank you in advance,
Yash 
Vahana.py

Emilio

unread,
Dec 20, 2022, 12:47:35 AM12/20/22
to SUAVE FORUM
I see what's going wrong. I'll make an issue. 


However, what is probably at the root source is a funky rotor design. The earlier optimization processes should converge. This line is backup to a backup plan. Check the numbers you're inputting. Ideally you should not see either of these two lines:

Optimum motor design failed. Using slack constraints

 Slack contraints failed. Using one constraint


-Emilio

Yash Thummar

unread,
Dec 24, 2022, 9:45:02 AM12/24/22
to SUAVE FORUM
Actually, this line  Optimum motor design failed. Using slack constraints  is getting in the terminal at the top. 

So what can I do now? Do I remove that constraint line from the root source or something? Any idea? 

Before I reinstall the SUAVE, this vehicle code file worked fine. But now I am facing a problem and unfortunately, I don't have a proper Idea of what dependency version I had at that time.

Thank you.

Emilio

unread,
Jan 4, 2023, 7:43:57 PM1/4/23
to SUAVE FORUM
Hi,
That's probably okay. Just not ideal. How does the rest of the file run?

-Emilio

Yash Thummar

unread,
Jan 8, 2023, 1:47:39 AM1/8/23
to SUAVE FORUM
Thanks for your reply and sorry for my late response.

Actually, I managed the results somehow by creating a new script with some different motor parameters but this one is still unfortunately not working.

Sergen Sakaoğlu

unread,
Nov 23, 2023, 2:56:55 AM11/23/23
to SUAVE FORUM
Hello,

I'm facing the same issue, are there any possible solutions to the problem "Optimum motor design failed. Using slack constraints"

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

8 Ocak 2023 Pazar tarihinde saat 09:47:39 UTC+3 itibarıyla Yash Thummar şunları yazdı:
Reply all
Reply to author
Forward
0 new messages