Please login with a confirmed email address before reporting spam
Xueyuan,
I've been working on doing the same as you. I've been able to get this to work by following hints on this comsol forum - https://www.comsol.com/forum/thread/33446/parallel-computing-matlab-comsol. They start Comsol servers within a parfor loop, and then connect each individual parfor worker to a server with the "mphstart" function.
I hope this helps. If you need an example, please let me know.
Alex
Dear Alex
I am in exactly the same situation as Xueyuan. May I ask how are you solved the problem? In addition to the url that you mentioned, another url - http://cn.comsol.com/forum/thread/38557/parallel-computing-with-matlab-livelink-and-comsol?last=2013-07-20T17:37:08Z mentioned a similar solution. But for me, there are still mistakes. For example, when i used the code in the runfile,:
core=2;
pp=parpool(core);
comsolPort1 = 2036;
system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort1) ' &'] );
pause(1)
comsolPort2 = 2037;
system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort2) ' &'] );
pause(1)
and the next code in my function contains my Comsol model :
cd('D:\COMSOL\COMSOL55\Multiphysics\mli')
comsolPort=[2036 2037];
t = getCurrentTask()
labit=t.ID
mphstart(comsolPort(labit))
The calculation of the first round can be performed, but an error will be reported when the second round begins:
Error using mphstart
Already connected to a server
I thought the first-round model was still occupying ports, so I added the statement "Modelutil.disconnect;", but the calculation again prompted an error:
Error using mphstart
A connection to COMSOL could not be established. Please check that a COMSOL server is started prior to calling mphstart
I'm confused. Is there anything else to deal with ? Could you please kindly share your solution here? Looking forward to your reply very much, Thank you!
Kind regards,
Weikai Xu
>Xueyuan,
>
>I've been working on doing the same as you. I've been able to get this to work by following hints on this comsol forum - https://www.comsol.com/forum/thread/33446/parallel-computing-matlab-comsol. They start Comsol servers within a parfor loop, and then connect each individual parfor worker to a server with the "mphstart" function.
>
>I hope this helps. If you need an example, please let me know.
>
>Alex
Dear Alex
I am in exactly the same situation as Xueyuan. May I ask how are you solved the problem? In addition to the url that you mentioned, another url - http://cn.comsol.com/forum/thread/38557/parallel-computing-with-matlab-livelink-and-comsol?last=2013-07-20T17:37:08Z mentioned a similar solution. But for me, there are still mistakes. For example, when i used the code in the runfile,:
core=2;
pp=parpool(core);
comsolPort1 = 2036;
system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort1) ' &'] );
pause(1)
comsolPort2 = 2037;
system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort2) ' &'] );
pause(1)
and the next code in my function contains my Comsol model :
cd('D:\COMSOL\COMSOL55\Multiphysics\mli')
comsolPort=[2036 2037];
t = getCurrentTask()
labit=t.ID
mphstart(comsolPort(labit))
The calculation of the first round can be performed, but an error will be reported when the second round begins:
Error using mphstart
Already connected to a server
I thought the first-round model was still occupying ports, so I added the statement "Modelutil.disconnect;", but the calculation again prompted an error:
Error using mphstart
A connection to COMSOL could not be established. Please check that a COMSOL server is started prior to calling mphstart
I'm confused. Is there anything else to deal with ? Could you please kindly share your solution here? Looking forward to your reply very much, Thank you!
Kind regards,
Weikai Xu