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.
Solving same model in COMSOL and Matlab yields different results
Posted 2 avr. 2012, 15:55 UTC−4 Low-Frequency Electromagnetics, LiveLink for MATLAB Version 4.2a 8 Replies
Please login with a confirmed email address before reporting spam
I have a model created in COMSOL with mostly ellipsoids containing cylinders inside (different material), then joined with each other. Originally it gave me a hard time in meshing because I did not know how to "smooth out" the contact edges where the meshing gets extremely fine, so that it either threw meshing problem or divergent linear solution problem. With trial-and-error for a long time in every possible way, I simplified the model and perhaps marginally resolved the issue. At least, when I directly compute from COMSOL, it never complains.
Problem:
However, as I scripted it into Matlab because I needed to run different cases (where surface potential at some terminal differs), I got "divergence in linear solution," which threw me something like "java util exception."
What I did was simply save the working, solvable model as m-file, and called it from Matlab console, exactly same thing! But Matlab would not cooperate. And this error occurs only at some of the cases that I tried to run. e.g., case 1~4 passed, case 5, takes much longer than usual, then boom - error messages in red.
And also, even for the cases that did run, the solution was different from what was obtained by directly running from COMSOL. By "different," I mean off by more than 20% in some cases, which is way beyond the error margin that I am used to when running COMSOL.
Help:
Did anyone have similar experience? Different solution when running from COMSOL, than running through Matlab?
What differences may occur even though I simply save the COMSOL model as m-file?
Thank you.
Please login with a confirmed email address before reporting spam
Try to make a model that's stable and doesn't have convergence issues. If the problem "marginally" converges, you might sometimes even see difference from running it in COMSOL twice.
Upload your model and maybe we can come up with better meshing.
Please login with a confirmed email address before reporting spam
Attachments:
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
i do have a lot of difficulty with the meshing..
Attachments:
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
First of all, how did you find those two problems? I went into the selection list and went through all of them to double check for any unexpected small edges... and got rid of the two mentioned by "merging vertices," although it really isnt my original intention to create those two small parts and against the whole point of "automating creating the model."
However, the problem remains. i guess i really do not see any problem in meshing or else if running through COMSOL interface. but as soon as run it in Matlab, same old red errors occur.
I attached more error descriptions. Feel free to take a look.
P.S. the Matlab .m file needs AC/DC module to run. just thought it would be nice to see what code produced the error..
Attachments:
Please login with a confirmed email address before reporting spam
Exception:
com.comsol.util.exceptions.FlException: Failed to find a solution
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
The following feature has encountered a problem
The following feature has encountered a problem
Failed to find a solution
Divergence of the linear iterations
Returned solution is not converged
- Feature: Stationary Solver 1 (sol1/s1)
- Error: Failed to find a solution.
Stack trace:
at com.comsol.solver.SolverOperation.addError(Unknown Source)
at com.comsol.solver.SolverOperation.execute(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.a(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.g(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.runAll(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)
at com.comsol.server.internal.a.a(Unknown Source)
at com.comsol.server.internal.a.a(Unknown Source)
at com.comsol.server.internal.a$a.a(Unknown Source)
at com.comsol.server.internal.a$a.a(Unknown Source)
at com.comsol.server.internal.a$a$a.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Exception:
com.comsol.util.exceptions.FlException: Failed to find a solution
Messages:
The following feature has encountered a problem
Failed to find a solution
Divergence of the linear iterations
Returned solution is not converged
- Feature: Stationary Solver 1 (sol1/s1)
- Error: Failed to find a solution.
... 17 more
at com.comsol.model.clientserver.ClientManagerImpl.a(Unknown Source)
at com.comsol.model.clientserver.ClientManagerImpl.runServerJob(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl$ak.a(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl$ak.execute(Unknown Source)
at com.comsol.model.clientserver.ClientManagerImpl$e.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Exception:
com.comsol.util.exceptions.FlException: Failed to find a solution
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
The following feature has encountered a problem
The following feature has encountered a problem
Failed to find a solution
Divergence of the linear iterations
Returned solution is not converged
- Feature: Stationary Solver 1 (sol1/s1)
- Error: Failed to find a solution.
at com.comsol.solver.SolverOperation.addError(Unknown Source)
at com.comsol.solver.SolverOperation.execute(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.a(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.g(Unknown Source)
at com.comsol.model.internal.impl.SolverSequenceImpl.runAll(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)
at com.comsol.server.internal.a.a(Unknown Source)
at com.comsol.server.internal.a.a(Unknown Source)
at com.comsol.server.internal.a$a.a(Unknown Source)
at com.comsol.server.internal.a$a.a(Unknown Source)
at com.comsol.server.internal.a$a$a.run(Unknown Source)
... 3 more
Caused by: Exception:
com.comsol.util.exceptions.FlException: Failed to find a solution
Messages:
The following feature has encountered a problem
The following feature has encountered a problem
Failed to find a solution
Divergence of the linear iterations
Returned solution is not converged
- Feature: Stationary Solver 1 (sol1/s1)
- Error: Failed to find a solution.
... 17 more
Error in ==> finger at 249
model.sol('sol1').runAll;
Please login with a confirmed email address before reporting spam
First of all, how did you find those two problems?
Just looking at your mesh, I noticed that it was very fine around those points. I zoomed in and spotted two extra edges.
I'm not sure what's the problem with running your model with Matlab. Hard to tell without AC/DC module :) But looking at your .m file, why don't you do it through COMSOL interface using parametric sweep? It should be easy enough to implement.
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.
Suggested Content
- FORUM Differences in the results of the same model in 3D and 2D.
- KNOWLEDGE BASE COMSOL Software Architecture
- FORUM Differences In The Results Of The Same Model In 3D And 2D axisymmetric.
- BLOG A Practical Implementation of Multiphysics Topology Optimization
- BLOG New Method for Performing Topology Optimization of FSI Problems