45
$\begingroup$

Being relatively new to finite element analysis, I was wondering how expert users assess Mathematica's capabilities in solving PDEs via the finite element method compared to other commercial tools (e.g. Comsol)? I have a feeling that in principle most things can be controlled and are documented well in Mathematica, and I have succeeded solving Stokes flow on a complicated imported vasculature geometry from experimental scans. However, it appears that the quasi standard in my particular community is Comsol. I wanted to understand if this is simply a cultural phenomenon (engineers tend to like Comsol), or if there are substantial benefits to Comsol except for the GUI, e.g. when it comes to meshing or performance of the solvers? I realise this is a very subjective question as there are probably no benchmarks yet (see this question), and given how things are going, I might end up providing some benchmarks myself in the next months.

I would be very interested to read your opinions.

$\endgroup$
  • 2
    $\begingroup$ Altho this question is rather on the soft side, I hope people don't close it; I have not used FEMLAB/Comsol in a long time, and I'm interested to hear from somebody who has both and can compare. $\endgroup$ – J. M. is away Aug 22 '17 at 12:15
  • 5
    $\begingroup$ I have never used Comsol ... but I know that Comsol is a PDE solver first, while Mathematica has only gotten FEM support recently. I would be quite surprised if Comsol didn't clearly outperform Mathematica for FEM ... $\endgroup$ – Szabolcs Aug 22 '17 at 12:16
  • 2
    $\begingroup$ acegen and AceFEM packages add a lot of advanced FEM functionality to Mathematica. They are predominantly oriented to solid mechanics and include element formulations with finite strain assumption, non-linear elasticity, plasticity, frictional contact, coupled fields, etc. They also simplify programming of your own custom FEM formulations. One big advantage is that you can use rich MMA functions for preprocessing and postprocessing. $\endgroup$ – Pinti Aug 23 '17 at 7:12
  • 1
    $\begingroup$ @Pinti, an expansion of that (perhaps comparing Mathematica + AceFEM vs. Comsol) could be a good answer to this question. $\endgroup$ – J. M. is away Aug 23 '17 at 11:24
  • 1
    $\begingroup$ @Alexander Erlich This is slightly off topic, but here you can find utility for importing Comsol mesh to ElementMesh. Please let me know, if you find it useful. $\endgroup$ – Pinti Mar 13 '18 at 13:54
41
$\begingroup$

I can give a specific opinion on the comparison. The specificity is that I am not at all a specialist in numerical methods, but rather a user in this area, a physicist who needs to solve equations.

First about strong features of Comsol with respect to Mathematica (MMA).

  • The strongest feature of Comsol is that it has a nonlinear solver, while MMA still does not. In MMA it can only be overcome for time dependent PDEs when the MethodOfLines can be used. A nonlinear FEM solver has been added in Version 12.0. An overview capabilities of the nonlinear solver can be found here, some of the examples are explained in more detail here. For the exact details of the implementation of the nonlinear solver look here. What may also be of interest are the verification tests for the nonlinear solver found here.

  • Further, Comsol has a number of solvers, and in addition to them a number of preconditioners. On one hand, this makes it more flexible, but on the other hand for a user like I am who has no idea on which solver/preconditioner to use in what case - it transforms the life into a nightmare.

  • Comsol is able to solve integral and integro-differential equations. This, however, requires to apply a trick that one can hardly find in its documentation.

  • Comsol has an automatic meshing system, so one does not need to program the mesh. In addition, there are ways to refine the mesh in some regions or at some boundaries. This makes it very convenient for engineering problems with a complex domain and many internal boundaries, especially in 3D. The last version offers a nice feature of defining the mesh according to a function. That is, one introduces a function depending on coordinates, that gives the spatial mesh size dependence.

    MMA, on the other hand, requires programming a mesh, except for some simple cases. However, for scientific, rather than engineering problems, with a rather simple domain, it may be even better since gives one more control.

    Comsol has tools to build a domain, though it requires some training and experience. This is, however, not a very strong advancement, since for engineering problems the domains built with those tools are not very realistic. On the other hand, the scientific problems rarely require complex domains. However, Comsol supports importing a CAD file.

  • Comsol organises yearly conferences. During these conferences, there is a group of Comsol engineers present in the lobby, whom anyone can ask any his question. Typically I went from them away with a good answer.

Now about drawbacks.

  • Comsol has a rather poor post processing possibilities in comparison with MMA.

    Even more, Comsol is organized such, as if the plot obtained from the solution is regarded as a final result. However, if one needs this solution to be used in some further calculations, Comsol has very limited possibilities. For example, it can integrate the solution over a domain or a boundary, define its extremums or a mean value.

    Previously I used to solve a problem in Comsol (when MMA did not solve PDEs and also after it started since my equations are nonlinear) and to export the solutions into MMA to work with it further. Now, if I can, I prefer to solve the problem in MMA from the very beginning and to work in MMA further with the solution. This does not always work for nonlinear equations.

  • Comsol has no dynamic interactivity of MMA, which limits its possibilities. In MMA, in contrast, one can mesh and/or solve equations dynamically while, say, moving a slider. This I use sometimes. This possibility can be, however, limited if the solution requires too much time.

    Comsol has, however, a feature of a parametric sweep. That is, it solves the problem with a few parameters running according to predefined lists and one gets a set of solutions as the result.

  • Comsol has an awful help. It is not written for users. It is written for developers. I only rarely was able to find the answer to my questions in it.

    Comsol has lots of items in the menu, but their names are often given using some jargon. One does not understand, what they do when he sees them in menu. Given the incomprehensible help, without an external help one can hardly use all the power of Comsol, except for the case when he is a Comsol specialist.

    Lots of Comsol features are hidden somewhere in its multiple menus, but one (a) does not know about the existence of these features and (b) even if he knows that the feature exists he will often not find it without external help. I even do not compare it with the help of MMA.

  • Comsol has a model library. This is a gallery of solved problems in all areas covered by Comsol, and one can read a pdf file on it and download a working model. However, each such a text (containing several tens of pages) writes:

    "Press this button, type in this into that input field, now press that button and so on until the end".

    No explanation of why this button should be pressed, and what one goes to do when pressing this button, and why this should be in the input field. One needs to guess himself. To follow all these steps takes you, at least, half a day. And you get from this only 1-2 useful features. But you get them, and there is no other way to learn those features.

That are my impressions. I keep using both of them.

Edit: To address the question of @user21 on the Comsol pricing.

Comsol consists of a main body entitled "Comsol Multiphysics" and about 36 modules.

Multiphysics contains several basic things. One cannot run Comsol without this package. It generally enables one to simulate everything, provided the user is able to formulate all equations and boundary conditions (BCs) himself, though their implementation may require many skills and knowledge of the numeric methods and approaches from him.

However, the modules include specific equations and BCs dedicated to some field of physics or chemistry. Some of the BCs are common for differential equations, others may be only known to people making a simulation in this field, or in one of its specific domains.

To give one example, the Radio Frequency module contains such BCs as a Port for simulating a field coming from or scattered to infinity, or Perfect Electric Conductor BCs to simulate a thin metallic electrode as a 2D, rather than a 3D object or Impedance BCs to simulate such electrodes provided the thickness of the metal boundary exceeds the skin thickness. There are many other such specific BCs.

Some of the modules are necessary to support, say, CAD files import and such, or for combining Comsol with MatLab. The list of modules one finds here.

If one buys several modules, he is enabled to combine equations and BCs of one field with those of another field. It is because of this property Comsol is generally called "Multiphysics".

One buys separately the Multiphysics package and optionally one or several Modules. The prices vary. We have bought it recently and the current price for the Multiphysics (this includes the license for one computer) was about €9000, while the price of the modules varies between €5000 and €10000. Instead of the Multiphysics, we bought a license enabling multiple co-workers to work from the server which costs €20000.

Edit 2: Addressing the question of @Alexander Erlich. The way to import data from Comsol to MMA:

  1. After the result of a simulation has been obtained, go to Model Builder/Results/Export>Right Click and choose “Data” from the dynamic menu. The new item entitled “Data 1” (or “Data 2”, if Data 1 already existed and so on) appears under the node Model Builder/Results/Export. If there are several nodes entitled “Data N” the one freshly appeared will be marked.

  2. Go to the Settings page entitled “Data”.

  3. Specify where the data set is taken from (typically, the last solution chosen from the fall-down list. Specify how the time moment is selected (typically, from the Stored output times) and choose the time moment from which the solution to take.

  4. Under the "Expression" give the expression that should be calculated on the basis of the data. For example, if the function u(x,y) is the only dependent variable in the problem, and we want to have the data containing this function, we specify u. If we need, say, the square of its gradient, we specify ux^2+uy^2.

  5. Under Output specify a) Points to evaluate -> to “Take from data set”, b) Data format –> “Spread sheet” c) To specify the Fileneme, click on Browse and choose the trajectory and the filename in the dialog. The dialog offers extensions text, data, and CSV. Choose date.

  6. In the Advanced subsection uncheck “Include header”.

  7. One may and may not uncheck “Full precision”. If it is unchecked the file is much faster to operate in Mathematica. It is recommended.

  8. Press the button “Export” on the top of the Settings page. Done

The file may be imported into Mathematica in a usual way. One should take care

a) To export in the .dat or csv format and

b) To use the command Import (rather than ReadFile)

$\endgroup$
  • 1
    $\begingroup$ For reference, how long have you been using both software? $\endgroup$ – J. M. is away Aug 22 '17 at 14:20
  • 1
    $\begingroup$ Mathematica has had MeshRefinementFunction since Version 10.0. Any function of the list of vertices and area (in general measure) of the elements can be specified. $\endgroup$ – lastresort Aug 22 '17 at 14:23
  • 2
    $\begingroup$ @ J. M. I started about 10 years ago with the both, but Comsol I use intensivly only about last 5-6 years, and not all the time. It happens when I have a corresponding problem. The problems are of the engineering type, when they come from my job, but in addition I do some theoretical physics problems and then they are scientifically oriented. I think that I collected a considerable experience with Comsol, but stil do not feel myself a specialist. In contrast, last 10 years I use MMA daily. $\endgroup$ – Alexei Boulbitch Aug 22 '17 at 14:33
  • 3
    $\begingroup$ @AlexeiBoulbitch, I am curious about the price of COMSOL compared to Mathematica. $\endgroup$ – user21 Aug 22 '17 at 14:39
  • 4
    $\begingroup$ What about speed/performance? I would naïvely expect the great flexibility of Mathematica to come at a cost in performance ... but I do not have a good enough understanding of how FEM works to be able to judge how great this cost may be. $\endgroup$ – Szabolcs Aug 22 '17 at 14:59
22
$\begingroup$

I have not specifically used COMSOL, but can speak to other FEA and CFD solvers that I use including ANSYS, LS_DYNA, ABAQUS, Fluent, CFX, etc.

If you are doing engineering simulation of anything other than very simple problems (like the kinds you program in college classes) then a commercial package is vital.

Speed is probably the least important difference, though these vendors do invest a huge amount in improving performance for parallel processors, and I think you would see a large difference if you compared them to Mathematica on a cluster.

The big differences are the all the physics, constitutive models for material behavior, turbulence models, adaptive meshing algorithms and thousands of other details that are built into the FEA/CFD software that make it possible to simulate real world behavior, and the thousands of validation cases to make sure all those models represent reality.

I have used these packages to simulate boat crashes, rubber seals, multiphase flow of steel with phase change and hundreds of other problems that I couldn't practically use Mathematica for.

Most of these packages support user defined features, so you can extend their functionality with your own programming.

Some of the issues noted for COMSOL, like poor documentation and help, are not issues with other software. However they are all specialist tools. I typically figure that a new graduate with a master's in an engineering analysis field needs about 5 years working with experienced mentors to become proficient and 10 years or more before they are ready to work independently on challenging problems.

The cost ranges, but the high-end software are about an order of magnitude more expensive than Mathematica.

$\endgroup$
  • 2
    $\begingroup$ Totally agree with your comments. My experience is mainly with Star-ccm+ (CFD). In general, this is comparing companies with the same age (20 years or more) with hundreds of programmers, but one working exclusively on solving a specific physical problem (ansys, cd-adapco, etc.), and the other, working on a generic computational software (Mathematica...). There's obvious no comparison possible... (not now, and quite difficult to imagine in the "near" future). Besides what you already mentioned (although I reinforce the notion of hundreds of cores clusters, etc.), I would add that Mathematica... $\endgroup$ – P. Fonseca Aug 24 '17 at 9:43
  • 2
    $\begingroup$ ...meshing capabilities are extremely primitive for CFD applications (prism layers, overset mesh, easy specification of special meshing regions, like with a set of block regions, GUI input, that is, no CAD related tools, etc.). And unfortunately, there's still no notion of feature lines, like sharp angles, etc., which is actually fundamental for simple 3D printing (e.g. union of a cone with a ball, like an ice-cream, and then mesh it... there's no especial treatment of the sharp angles/feature lines, and we end up with good surfaces but wiggling edges...) $\endgroup$ – P. Fonseca Aug 24 '17 at 9:43
  • $\begingroup$ @P. Fonseca I completely agree about meshing capabilities, the same applies to structural applications. We have also had problems in MMA with accuracy for thin 3D objects like spherical plates, where the surfaces pass through each other. $\endgroup$ – David Creech Aug 24 '17 at 14:27
18
$\begingroup$

I have used both Mathematica and Comsol Multiphysics (formerly FEMLAB) for decades to solve practical problems. Mathematica is my go-to mathematics application because of versatility. I go to Comsol when: 1. There is a geometry more complicated than a box, cylinder, or sphere. Comsol uses consecutive solid geometry to build up shapes including the ability to import from CAD programs. New features in Mathematica allow building up more complicated structures, but it requires building an expression for the shape rather than constructing it out of geometric operations. 2. I need access to the material property database in Comsol. Mathematica has some chemical properties but is weak on things like diffusion, thermal conductivity, and viscosity.
3. I need problem specific tools that Comsol can provide, such as turbulence, electromagnetic modeling, or multiphysics. Multiphysics is essentially the coupling of different phenomena, for example thermal conductivity coupled with fluid flow.

Mathematica is considerably less expensive than Comsol Multiphysics, and has a notebook interface that makes constructing reports much easier. I will often import Comsol results into Mathematica for post processing.

Mathematica DOES solve non-linear problems; I have used it in modeling chemical reaction systems which can be very nonlinear. Mathematica does use state-of-the-art solvers for general problems, but Comsol has some more sophisticated solvers for many disciplines: fluid flow and electromagnetics in particular. The new FEM functions in Mathematica appear to have mesh construction tools that are just as good as Comsol, but I have not tried them extensively.

$\endgroup$
  • 1
    $\begingroup$ The comment about not having non-linear solvers referred to FEM only. In practice this means that we are limited to linear problem if we want a non-rectangular domain. (And here is a workaround) $\endgroup$ – Szabolcs Aug 23 '17 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.