Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Consistent Matlab/Comsol error!

Please login with a confirmed email address before reporting spam

Hey!

I've been trying to run a loop through the mode solver over multiple wavelengths. I would ideally like to have it run over both wavelengths and a varying geometry (say, a width increasing). I use matlab to maintain and update these loops. Comsol always sends an error into matlab which stops the loops, though, and the errors are never explicit. Here's an example:

??? Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: The following feature has encountered a problem
Messages:
The following feature has encountered a problem

Stack trace:
at com.comsol.solver.SolverOperation.addError(Unknown Source)
at com.comsol.solver.SolverOperation.execute(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.b(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.f(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.runAll(Unknown Source)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)
at com.comsol.server.internal.b.a(Unknown Source)
at com.comsol.server.internal.b.a(Unknown Source)
at com.comsol.server.internal.b$h.a(Unknown Source)
at com.comsol.server.internal.b$h.a(Unknown Source)
at com.comsol.server.internal.b$h$a.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)

at com.comsol.model.clientserver.ClientManagerImpl.a(Unknown Source)
at com.comsol.model.clientserver.ClientManagerImpl.runServerJob(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl$c.a(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl$c.execute(Unknown Source)
at com.comsol.model.clientserver.ClientManagerImpl$d.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: Exception:
com.comsol.util.exceptions.FlException: The following feature has encountered a problem
Messages:
The following feature has encountered a problem

at com.comsol.solver.SolverOperation.addError(Unknown Source)
at com.comsol.solver.SolverOperation.execute(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.b(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.f(Unknown Source)
at com.comsol.model.impl.SolverSequenceImpl.runAll(Unknown Source)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)
at com.comsol.server.internal.b.a(Unknown Source)
at com.comsol.server.internal.b.a(Unknown Source)
at com.comsol.server.internal.b$h.a(Unknown Source)
at com.comsol.server.internal.b$h.a(Unknown Source)
at com.comsol.server.internal.b$h$a.run(Unknown Source)
... 3 more

Error in ==> wgsim>sweepstudy at 376
model.sol('sol1').runAll;

Error in ==> wgsim at 148
sweepstudy;

Any help would be appreciated. It always crashes at random steps - sometimes it will loop several hundred times, sometimes it will crash at 60.

Thanks
Orad.

I'm running Comsol 4.0 and Matlab 2010b on OS10.6 (or on 64-bit Windows 7).

6 Replies Last Post Dec 17, 2011, 8:00 a.m. EST

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 4, 2011, 9:13 a.m. EST
Hi there
I am getting a similar message while using comsol 3.5 with matlab.
The error I get is as follow:

java.lang.ArrayIndexOutOfBoundsException: -1
(rethrown as com.femlab.util.FlException)

Stack trace:
at com.femlab.api.server.MeshCase.getCase(Unknown Source)
at com.femlab.api.client.Solver.solve(Unknown Source)
at com.femlab.api.client.SolveModel.solveNow(Unknown Source)
at com.femlab.api.client.SolveModel.solveNow(Unknown Source)
at com.femlab.api.client.ah.a(Unknown Source)
at com.femlab.gui.FlProgressThread.run(Unknown Source)
at com.femlab.util.i.run(Unknown Source)
at com.femlab.util.ae.run(Unknown Source)

I don't know what is causing such an error and comsol isn't great in describing the possible error.
Hi there I am getting a similar message while using comsol 3.5 with matlab. The error I get is as follow: java.lang.ArrayIndexOutOfBoundsException: -1 (rethrown as com.femlab.util.FlException) Stack trace: at com.femlab.api.server.MeshCase.getCase(Unknown Source) at com.femlab.api.client.Solver.solve(Unknown Source) at com.femlab.api.client.SolveModel.solveNow(Unknown Source) at com.femlab.api.client.SolveModel.solveNow(Unknown Source) at com.femlab.api.client.ah.a(Unknown Source) at com.femlab.gui.FlProgressThread.run(Unknown Source) at com.femlab.util.i.run(Unknown Source) at com.femlab.util.ae.run(Unknown Source) I don't know what is causing such an error and comsol isn't great in describing the possible error.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Feb 2, 2011, 5:20 a.m. EST
I'm getting exactly the same problem.
Is the any solutions?

or at least some idea of what exactly this error means? Is it memory related?
I'm getting exactly the same problem. Is the any solutions? or at least some idea of what exactly this error means? Is it memory related?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 25, 2011, 6:37 a.m. EDT
Hi,
this might be an old topic but I'm currently having the same problem with Comsol 4.2 and Matlab r2011a on Ubuntu 11.04. It seems to relate to the evaluation of an external Matlab function. The following lines causes my model to crash:
...
model.param.set('ComsolParam1', 123);
model.func.create('ComsolExtm1', 'MATLAB');
model.func('ComsolExtm1').setIndex('funcs', 'myMatlabFun', 0, 0);
model.func('ComsolExtm1').setIndex('funcs', 'mode', 0, 1);
model.param.set('ComsolRes', 'myMatlabFun(GlobalComsolParam1)');
...
model.param.set('Vol', 'ComsolRes[mV]');
...

Commenting out the lines and setting parameter 'Vol' to a fixed number and everything is fine.
The funny thing is that the very same code runs properly on another machine (Comsol 4.2, Matlab r2011a, Ubuntu 10.04), so the code itself should not be the problem.
Any ideas what causes Comsol to crash here?
Hi, this might be an old topic but I'm currently having the same problem with Comsol 4.2 and Matlab r2011a on Ubuntu 11.04. It seems to relate to the evaluation of an external Matlab function. The following lines causes my model to crash: ... model.param.set('ComsolParam1', 123); model.func.create('ComsolExtm1', 'MATLAB'); model.func('ComsolExtm1').setIndex('funcs', 'myMatlabFun', 0, 0); model.func('ComsolExtm1').setIndex('funcs', 'mode', 0, 1); model.param.set('ComsolRes', 'myMatlabFun(GlobalComsolParam1)'); ... model.param.set('Vol', 'ComsolRes[mV]'); ... Commenting out the lines and setting parameter 'Vol' to a fixed number and everything is fine. The funny thing is that the very same code runs properly on another machine (Comsol 4.2, Matlab r2011a, Ubuntu 10.04), so the code itself should not be the problem. Any ideas what causes Comsol to crash here?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 26, 2011, 4:12 p.m. EDT
Hey,

I never did solve this problem. I contacted Comsol support directly and they were really helpful at debugging the problem, but ultimately I ended up using a different software package to do the calculation I was trying. We never did figure out how to stop the simulation from crashing.

Good luck, please post your solution here!
Hey, I never did solve this problem. I contacted Comsol support directly and they were really helpful at debugging the problem, but ultimately I ended up using a different software package to do the calculation I was trying. We never did figure out how to stop the simulation from crashing. Good luck, please post your solution here!

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 18, 2011, 3:43 p.m. EST
I am getting the same error at model.sol('sol1').runAll ...
My model contains a solid mechanics physics with some pressure variables. In an optimization loop over these pressure values, the error occurs only at some specific values. When the pressure values are changed in my case, the error does not occur most of the times.

it might be a bug with Comsol of not being able to handle some particular condition, and would be great to know what is happening from the Comsol support team!


I am getting the same error at model.sol('sol1').runAll ... My model contains a solid mechanics physics with some pressure variables. In an optimization loop over these pressure values, the error occurs only at some specific values. When the pressure values are changed in my case, the error does not occur most of the times. it might be a bug with Comsol of not being able to handle some particular condition, and would be great to know what is happening from the Comsol support team!

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 17, 2011, 8:00 a.m. EST
Hi Hina,

Thank you for your valuable reply.

I am Kenneth from the institute of electrical engineering (IEE), Chinese academy of sciences (CAS).

The attached is my M file,
==========one line code is showing:======
model.param.set('J0', '1[A/m^2]', 'Current density in coil');
==========now, I want to use 3 to replace 1 =======
==========if I input the following code in MATLAB command window,the results is right=======
mod8=model;
mod8.param.set('J0', '3[A/m^2]', 'Current density in coil');
mod8.geom('geom1').run;
mod8.mesh('mesh1').run;
mod8.sol('sol1').runAll;
mod8.result.export('data1').run;
=========but I want to optimise the J0 'value for many times, so I define a variable 'hq' ,but lead to many errors==
mod8.param.set('J0', 'hq[A/m^2]', 'Current density in coil');
mod8.geom('geom1').run;
mod8.mesh('mesh1').run;
mod8.sol('sol1').runAll;
mod8.result.export('data1').run;
=========could you tell me how I can realize my object?=====
Thank you very much!

Kenneth
Hi Hina, Thank you for your valuable reply. I am Kenneth from the institute of electrical engineering (IEE), Chinese academy of sciences (CAS). The attached is my M file, ==========one line code is showing:====== model.param.set('J0', '1[A/m^2]', 'Current density in coil'); ==========now, I want to use 3 to replace 1 ======= ==========if I input the following code in MATLAB command window,the results is right======= mod8=model; mod8.param.set('J0', '3[A/m^2]', 'Current density in coil'); mod8.geom('geom1').run; mod8.mesh('mesh1').run; mod8.sol('sol1').runAll; mod8.result.export('data1').run; =========but I want to optimise the J0 'value for many times, so I define a variable 'hq' ,but lead to many errors== mod8.param.set('J0', 'hq[A/m^2]', 'Current density in coil'); mod8.geom('geom1').run; mod8.mesh('mesh1').run; mod8.sol('sol1').runAll; mod8.result.export('data1').run; =========could you tell me how I can realize my object?===== Thank you very much! Kenneth

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.