Jim Freels
mechanical side of nuclear engineering, multiphysics analysis, COMSOL specialist
Please login with a confirmed email address before reporting spam
Posted:
3 years ago
5 oct. 2021, 18:26 UTC−4
First question: Have you looked at the capabilities, and/or considered just adding the equations you needed solved for your external calculation just using COMSOL itself ? That is the simplest way actually, if you take the time to do that. I would be surprised if your algorithm cannot be fit into COMSOL straight out.
If this is not possible (too complex, or have existing code already, etc.), COMSOL basically handles two different external programming languages to the user: MATLAB (requires a license), or JAVA (also requires a license, but can be free). From there, many additional languages can be linked into either MATLAB or JAVA, so the possibilities are many. For example, our group linked FORTRAN code into COMSOL via MATLAB. You will need to follow the COMSOL API in the documentation. MATLAB livelink is certainly an advantage for doing this if you want to go the MATLAB route, and I think a required purchase from COMSOL.
One quick recommendation just to give yourself an idea is to take a simple COMSOL model that you have running, and then save it as a MATLAB file and/or JAVA file using the "save as" selection from the file menu item (normally, if you just click save it defaults to the .mph file extension). Then go take a look at the resulting files using your favorite editor. This might give you a bit of an idea of what is involved.
COMSOL developers please chime in on this question.
-------------------
James D. Freels, Ph.D., P.E.
First question: Have you looked at the capabilities, and/or considered just adding the equations you needed solved for your external calculation just using COMSOL itself ? That is the simplest way actually, if you take the time to do that. I would be surprised if your algorithm cannot be fit into COMSOL straight out.
If this is not possible (too complex, or have existing code already, etc.), COMSOL basically handles two different external programming languages to the user: MATLAB (requires a license), or JAVA (also requires a license, but can be free). From there, many additional languages can be linked into either MATLAB or JAVA, so the possibilities are many. For example, our group linked FORTRAN code into COMSOL via MATLAB. You will need to follow the COMSOL API in the documentation. MATLAB livelink is certainly an advantage for doing this if you want to go the MATLAB route, and I think a required purchase from COMSOL.
One quick recommendation just to give yourself an idea is to take a simple COMSOL model that you have running, and then save it as a MATLAB file and/or JAVA file using the "save as" selection from the file menu item (normally, if you just click save it defaults to the .mph file extension). Then go take a look at the resulting files using your favorite editor. This might give you a bit of an idea of what is involved.
COMSOL developers please chime in on this question.
Henrik Sönnerlind
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
3 years ago
6 oct. 2021, 03:06 UTC−4
As I understand the question, you are only interested in having your own variables for postprocessing. Then, I agree with Jim, that it is unlikely that you need anything external. It will most probably be possible to add your own variables under Definitions->Variables.
In the more general case that you want your own material model that affects stiffness matrices and residuals, then there are several different approaches. Modifying things inside COMSOL would still be the first path to explore. Maybe adding distributed ODEs or states. If that does not suffice, the next option is to use an External Material. Then you program the material model in C (or any language that you can call from C). The code is compiled and linked into COMSOL Multiphysics.
-------------------
Henrik Sönnerlind
COMSOL
As I understand the question, you are only interested in having your own variables for postprocessing. Then, I agree with Jim, that it is unlikely that you need anything external. It will most probably be possible to add your own variables under Definitions->Variables.
In the more general case that you want your own material model that affects stiffness matrices and residuals, then there are several different approaches. Modifying things inside COMSOL would still be the first path to explore. Maybe adding distributed ODEs or states. If that does not suffice, the next option is to use an External Material. Then you program the material model in C (or any language that you can call from C). The code is compiled and linked into COMSOL Multiphysics.
Please login with a confirmed email address before reporting spam
Posted:
3 years ago
6 oct. 2021, 03:21 UTC−4
Thank all of you for your answers. The fact is that I need to calculate the cracking energy for each direction of the space and find the direction that maximizes its value. I'm not sure COMSOL manages such calculation involving loops. Does it ?
Anyway, I'll try to download the LiveLink option to see how it works !
I'll come back on this discussion to explain how I did or didn't manage to implement my algorithm.
Thank all of you for your answers. The fact is that I need to calculate the cracking energy for each direction of the space and find the direction that maximizes its value. I'm not sure COMSOL manages such calculation involving loops. Does it ?
Anyway, I'll try to download the LiveLink option to see how it works !
I'll come back on this discussion to explain how I did or didn't manage to implement my algorithm.
Henrik Sönnerlind
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
3 years ago
6 oct. 2021, 11:28 UTC−4
If you have that type of algorithm, you probably need programming.
You can for example use Global->Functions->External or Global->Functions->MATLAB. Using such functions, it would be possible for you to define variables in the domain that contain the results you are looking for.
-------------------
Henrik Sönnerlind
COMSOL
If you have that type of algorithm, you probably need programming.
You can for example use Global->Functions->External or Global->Functions->MATLAB. Using such functions, it would be possible for you to define variables in the domain that contain the results you are looking for.