Open AndyYoon opened 11 months ago
Hi @AndyYoon. Parallel Motor-CAD instances will have diminishing returns at a certain point but 2 seems low. Just a few questions:
Hi @jgsdavies!
Hi @jgsdavies!
- I'm only building a EM/Thermal model, then utilizing "do_magnetic_thermal_calculation()".
- I do create a new file for every run, since I haven't figured out a way to keep the motorCAD file open between the for loops. Even without calling "quit()" at the end of a for loop, it seems like motorCAD closes once each loop is complete.
Creating a new file for every run is best practice to conflicts.
Restarting Motor-CAD is also currently best practice. If you want to try reusing the same instances here's some info:
The instance of Motor-CAD belongs to the Python object i.e. when the Python object leaves memory then the Motor-CAD instance will close. You can get around this by making Python object global or there's an experimental option which grabs any free Motor-CAD/launches a new one if it can't be found.
MotorCAD(reuse_parallel_instances=True)
# Free instance so another thread can reuse
mc.set_free()
- Motor type is BPM
Motor-CAD is not optimised for parallel computing. Improving this is something that we are putting a lot of development effort into currently. 2 instances seems low but it's tricky to diagnose this issue without the specific machine, file and script - I can't see anything obviously wrong with your method.
Definitely give this a go with 24R1 when it's released. This has some performance improvements. We're also hoping to provide a cloud based solution in a future release.
🔍 Before submitting the issue
🐞 Description of the bug
Background: I am attempting to generate 100's of random designs on MotorCAD and evaluating each one. I'm utilizing the 'multiprocessing' package in Python to vary the number of processes.
Issue: I do get about 1/2 reduction in evaluation time when num_process = 2. However, it doesn't seem like there's added benefit to running higher num_process. I was hoping to utilize all (or most) of the cores on my machine (e.g. 16) to reduce the evaluation time to (potentially) 1/16. Are these parallel instances sharing resources and essentially throttling the speed down?
📝 Steps to reproduce
RunMcad contains the pymotorcad run script
💻 Which operating system are you using?
Windows
📀 Which ANSYS version are you using?
MotorCAD 2023_2_2
🐍 Which Python version are you using?
3.10
📦 Installed packages