The Magnetics solver is able to run in parallel. It can use shared memory parallel (SMP), e.g. running with parallel threads on one computer (node) and also distributed memory parallel (DMP), e.g. running spread over several nodes in a cluster. The combination of both SMP and DMP is also possible and very efficient, e.g. running on a cluster while each node uses parallel threads. The DMP feature is possible since version 860. In the following sections we explain how to set up and run that way. In the following, we will often use the file name of the model to be solved. Therefore we call this ’modelname’. The modelname is the core of the solver input file name. Such solver input files result if in NX or Simcenter the solve option ’Write Solver Input File’ is run. File extensions are ’.pro’, ’.msh’ and others. If the model for example is the tutorial ’Team24’ with the transient solution, then the ’modelname’ will be ’Team24-transient’.
If running on one computer, SMP is automatically active.
If running on one computer, DMP can be activated quite simple as follows:
Right click on a Magnetics solution and chose ’Edit Solver Parameters...’
In register ’Cluster’, at ’Parallel Solution via MPI’, activate ’Enable’
In the field ’Config Parameters’, key in ’mpiexec -n 2’.
The value 2 in the above example will activate two parallel processes on this computer. The value can be set as desired, but the recommendation is not to use more that the available number of processors or cores on the computer. Best performance for DMP can be expected if the computer has more than one processor.
To run DMP on a computer cluster proceed as follows.
All computers (nodes) must have a Windows operating system. We recommend the version Windows 10 or 11. Possible are also Windows 7 and Windows Server.
The nodes must be connected over a network. That network should be of very high performance because of the necessary communication between the processes. If the network is not of high performance, the solve time will be very slow.
On each node there must be the same user defined. For this example the user name is ’mpiuser’. The password for this user must be the same on all nodes. Administrator rights are required for that user.
On each node there must be a work-directory (wdir) defined at the same path. In this example we use ’C:\workdir\Magnetics’. These directories have to be shared in the network. The mpiuser needs to have read and write permission. Into this directory some files from the MAGNETICS installation folder must be copied. These are
Magnetics.exe
MagneticsSolveR.exe
MagneticsSolveC.exe
libgcc_s_seh-1.dll
libwinpthread-1.dll
msmpi.dll
On each node the user ’mpiuser’ must log in. This can easily be done by remote desktop connection. Using a command shell (CMD) the command ’smpd’ must be started with two arguments. The first argument is ’-p’ and defines the network port through which the solve processes will communicate. Choose a free port there, we will use 19020. The second argument is ’-d’ and defines the log verbosity. We recommend 3. So, the whole command is this:
smpd -p 19020 -d 3
Be aware that this smpd process is quite sensitive. In several cases it will hang and must be stopped and restarted. Also take care to use the correct CMD shell. It must be the CMD from the Windows operating system and NOT the NX command prompt.
One node will be defined to be the master node. On that master node we will have the solver input files and we will execute the solve command (mpiexec.exe). The master node will spread all child processes to the remaining slave nodes. The master node will have the highest load because several routines that cannot run in parallel will run on the master node.
The following solver input files must be copied to the master node work dir:
modelname.pro (problem definition file)
modelname.msh (mesh file)
modelname.Vec.msh (stranded coil directions, only if stranded coils are present)
modelname.mpi (cluster configuration file, see below)
A cluster configuration file (modelname.mpi) must be in the work
directory of the master node. The entries are these:
mpiexec -hosts NumNodes Node_1 NumProcessesOnNode_1 Node_2
NumProcessesOnNode_2 ... -p NetworkPort -wdir NameOfSharedWorkdir
NumNodes: The total number of nodes in the cluster.
Node_1 (Node_2, ...) The host name of the first (second, ...) node.
NumProcessesOnNode_1 (NumProcessesOnNode_2, ...) The number of processes on the first (second, ...) node.
NetworkPort: The port number, as already used for the previously defined smpd processes.
NameOfSharedWorkdir: The name of the shared network directory of the master node.
An example for that modelname.mpi file text content follows. Here, we use the two nodes ’Gaius’ and ’Caligula’, each running one process while ’Gaius’ is the master node:
mpiexec -hosts 2 Gaius 1 Caligula 1 -p 19020 -wdir \\Gaius\workdir\Magnetics
To start the whole parallel solve process the command ’Magnetics.exe’, following some arguments must be executed in a command shell on the master node. The arguments are explained below
Magnetics.exe modelname
-solve solutionname (the solution name is found in the resolution section of the pro file. It can be for instance ’Magnetodynamic_Frequency3D’.
-bin: for binary write of results. Ascii for readable write.
Machine1 NumProcessesOn1: The name of the first node following the number of processes to be started on this node.
Machine2 NumProcessesOn2: Same as above for the next node. And so on.
-p PortNumber: The network port number for the communication. Use the same as already given with the smpd command.
-wdir: The name of the shared network folder, that is the same on all nodes.
An example for that CMD command is this:
Magnetics.exe Team24_sim1-Transient -solve Magnetodynamic_Transient3D -bin
The parallel solve will start. On each node the Windows firewall will probably block the new process ’MagneticsSolveC.exe’ or ’MagneticsSolveR.exe’. The execution must then be allowed. On the master node there will be the result files available after finish.
SMP will automatically be active on each node of a cluster solve.