Hello Anders Gudmarsson
Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.
If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2013年1月31日 GMT+1 16:19
Hi Anders,
Were you able to solve this problem?
Hi,
I am trying to do the following
parfor k=1:20
model2 = mphload('micromodel');
end
This should initiate several parallel comsol instances in matlab. However, I get the following error
Error using parallel function
Undefined variable "ModelUtil" or "ModelUtil.load"
However if I do this in serial:
parfor k=1:20
model2 = mphload('micromodel');
end
it works fine.
Thanks,
Hi Anders, Were you able to solve this problem? Hi, I am trying to do the following parfor k=1:20 model2 = mphload('micromodel'); end This should initiate several parallel comsol instances in matlab. However, I get the following error Error using parallel function Undefined variable "ModelUtil" or "ModelUtil.load" However if I do this in serial: parfor k=1:20 model2 = mphload('micromodel'); end it works fine. Thanks,
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2013年2月5日 GMT+1 16:14
Hi Hamsa,
Yes I managed to find a solution to this problem.
To connect the matlab workers to comsol i use the system command below to start a server for each worker. Then i use the mphstart command to connect my parallel functions to the comsol servers by specifying the ports.
comsolPort = 2036;
system( ['comsol -np 1 server -silent -port ' num2str(comsolPort) ' &'] );
mphstart( comsolPort )
import com.comsol.model.*
import com.comsol.model.util.*
I hope this will help you.
Regards,
Anders
Hi Hamsa, Yes I managed to find a solution to this problem. To connect the matlab workers to comsol i use the system command below to start a server for each worker. Then i use the mphstart command to connect my parallel functions to the comsol servers by specifying the ports. comsolPort = 2036; system( ['comsol -np 1 server -silent -port ' num2str(comsolPort) ' &'] ); mphstart( comsolPort ) import com.comsol.model.* import com.comsol.model.util.* I hope this will help you. Regards, Anders
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2013年2月5日 GMT+1 18:03
Hi Anders,
Thanks for your reply. I am able to launch comsol on the workers, however, they are not able to finish off normally. Somhow they end up crashing.
Can you tell me if you use labBarriers, LabSend and LabReceive commands to communicate from the parent process to the worker processes?
Also, would I be right in making the parent do the writing to the files etc. and just get the data from the child processes?
Thanks,
Hi Anders, Thanks for your reply. I am able to launch comsol on the workers, however, they are not able to finish off normally. Somhow they end up crashing. Can you tell me if you use labBarriers, LabSend and LabReceive commands to communicate from the parent process to the worker processes? Also, would I be right in making the parent do the writing to the files etc. and just get the data from the child processes? Thanks,
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2013年2月8日 GMT+1 18:33
Hi Anders,
I'm having the same problem you started with, but I'm not quite following how you solved it.
Could you please upload some sample code that show how you fixed the problem? I'd really appreciate it.
Thanks,
-jfb
Hi Anders, I'm having the same problem you started with, but I'm not quite following how you solved it. Could you please upload some sample code that show how you fixed the problem? I'd really appreciate it. Thanks, -jfb
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2013年2月13日 GMT+1 10:50
Hi,
Here is a sample code of my solution to this problem.
I use the system command to start comsol and then i call my comsol functions in the parfor loop.
matlabpool open 2
comsolPort = 2036;
system( ['comsol -np 1 server -silent -port ' num2str(comsolPort) ' &'] );
pause( 6 )
comsolPort = 2037;
system( ['comsol -np 1 server -silent -port ' num2str(comsolPort) ' &'] );
pause( 6 )
parfor i = 1:2
if i == 1
y_acc_amp_final{i}=Torsion(dataT,f_range);
else
x_acc_amp_final{i}=Long(dataT,f_range);
end
end
matlabpool close
In my comsol functions i use the mphstart command to connect the functions to the opened comsol ports.
cd('C:\Program Files\COMSOL43\mli')
mphstart(2036)
I hope this may be helpful.
Regards,
Anders
Hi, Here is a sample code of my solution to this problem. I use the system command to start comsol and then i call my comsol functions in the parfor loop. matlabpool open 2 comsolPort = 2036; system( ['comsol -np 1 server -silent -port ' num2str(comsolPort) ' &'] ); pause( 6 ) comsolPort = 2037; system( ['comsol -np 1 server -silent -port ' num2str(comsolPort) ' &'] ); pause( 6 ) parfor i = 1:2 if i == 1 y_acc_amp_final{i}=Torsion(dataT,f_range); else x_acc_amp_final{i}=Long(dataT,f_range); end end matlabpool close In my comsol functions i use the mphstart command to connect the functions to the opened comsol ports. cd('C:\Program Files\COMSOL43\mli') mphstart(2036) I hope this may be helpful. Regards, Anders
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2013年2月13日 GMT+1 19:00
Hi,
Thanks so much for your help! I got it working.
Thanks again,
-jfb
Hi, Thanks so much for your help! I got it working. Thanks again, -jfb
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2014年3月13日 GMT+1 07:56
Hi,
I'm trying to implement the solution suggested here.
I'm able to get the different servers up and connect them to the workers but I'm now stuck when I try to use mphload (in order load my model).
Should I load my model in the parent process or should I load it for each worker?
if so how can I specify to which server mphload should load the model?
Your help is appreciated in advance!
Thanks
Michael
Hi, I'm trying to implement the solution suggested here. I'm able to get the different servers up and connect them to the workers but I'm now stuck when I try to use mphload (in order load my model). Should I load my model in the parent process or should I load it for each worker? if so how can I specify to which server mphload should load the model? Your help is appreciated in advance! Thanks Michael
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2014年7月3日 GMT+2 20:22
Hi
I had problems inside MATLAB's parfor loop.
parfor idx = 1:2
import com.comsol.model.*
import com.comsol.model.util.*
model = ModelUtil.create('Model');
end
Error: MATLAB cannot determine whether "ModelUtil" refers to a function or variable.
See Parallel for Loops in MATLAB, "Unambiguous Variable Names".
Could you please kindly advise how you solved this?
Best regards, and thanks in advance!
Alvin
Hi I had problems inside MATLAB's parfor loop. parfor idx = 1:2 import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); end Error: MATLAB cannot determine whether "ModelUtil" refers to a function or variable. See Parallel for Loops in MATLAB, "Unambiguous Variable Names". Could you please kindly advise how you solved this? Best regards, and thanks in advance! Alvin
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2014年7月3日 GMT+2 20:38
Hi Hamsa,
Did you solve the problem? I have exactly the same problem.
Error: MATLAB cannot determine whether "ModelUtil" refers to a function or variable.
See Parallel for Loops in MATLAB, "Unambiguous Variable Names".
Could you please kindly help?? Really desperate.
Thanks a lot
Alvin
Hi Hamsa, Did you solve the problem? I have exactly the same problem. Error: MATLAB cannot determine whether "ModelUtil" refers to a function or variable. See Parallel for Loops in MATLAB, "Unambiguous Variable Names". Could you please kindly help?? Really desperate. Thanks a lot Alvin
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
2014年7月18日 GMT+2 17:43
Hi Anders,
I'm trying to use Comsol with the optimization tool from Matlab to estimate some parameters of my Comsol model using genetic algorithms. Could you please, give me some tips how to do it? I'm not trying to do parallel processing, it's just the first part of your text, which I think you are dealing well with that, right?
Could you please help me with that?
Thank you.
Marco
Hi Anders, I'm trying to use Comsol with the optimization tool from Matlab to estimate some parameters of my Comsol model using genetic algorithms. Could you please, give me some tips how to do it? I'm not trying to do parallel processing, it's just the first part of your text, which I think you are dealing well with that, right? Could you please help me with that? Thank you. Marco
Please login with a confirmed email address before reporting spam
Posted:
8 years ago
2016年12月3日 GMT+1 07:31
Hi Anders
Is your problem solved? I am in exactly the same situation as you.
Regards
Jia
Hi Anders Is your problem solved? I am in exactly the same situation as you. Regards Jia
Please login with a confirmed email address before reporting spam
Posted:
7 years ago
2017年5月23日 GMT+2 10:37
You could start multiple comsol servers. but then you need multiple licenses, do you have that? In that case, you could start multiple servers. The effect is this is rather small however if is it is all on the same node (computer) because comsol on itself is already nicely parallelized. If you have multiple nodes, however, having multiple server instances might greatly improve performance. However, I don't think Matlab supports distributed memory parallelism out of the box, so you have to try something with MPI
You could start multiple comsol servers. but then you need multiple licenses, do you have that? In that case, you could start multiple servers. The effect is this is rather small however if is it is all on the same node (computer) because comsol on itself is already nicely parallelized. If you have multiple nodes, however, having multiple server instances might greatly improve performance. However, I don't think Matlab supports distributed memory parallelism out of the box, so you have to try something with MPI