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.

Comsol - Matlab - FFT

Please login with a confirmed email address before reporting spam

Bonjour à tous,

J'utilise COMSOL depuis 1 an et je me suis mise à utiliser Matlab depuis quelques mois interfacé avec COMSOL.
J'ai utilisé l'interface graphique de COMSOL pour déterminer dans un premier temps la solution d'une équation intégrale. Le résultat est une fonction Ez(x,y,z) qui dépend des trois variables d'espace. Jusque là aucun problème. J'enregistre ensuite mon travail pour obtenir le fichier M-file que j'ouvre ensuite dans Matlab. Je retrouve alors dans ce fichier l'ensemble des procédures que j'ai utilisées dans l'interface graphique de COMSOL sous forme de ligne de code. A l'aide de Matlab, je souhaiterais maintenant déterminer la transformée de Fourier suivant z (z--->q) de Ez(x,y,z) (--->Ez(x,y,q)) puis visualiser le résultat. Voici donc comment je procède :

A la suite du M-file généré par COMSOL j'écris :

>> Eq = int(Ez*exp(i*z*q) , z , -inf , +inf); % afin de calculer cette intégrale i.e. la TF de Ez suivant z
>>postplot(fem , 'tridata', 'Eq');

Malheureusement, un long message d'erreur me fait comprendre que ces lignes de code sont fausses...c'est pourtant ce que j'écrirais si j'avais à utiliser Matlab indépendamment de comsol !

Je suis un peu perdue avec la documentation de COMSOL à propos de Matlab...très peu d'exemples sont traités et je ne peux donc pas me faire la main pour comprendre un peu mieux comment se fait le couplage matlab-comsol.

Quelqu'un a t-il une idée pour déterminer cette transformée de Fourier et visualiser le résultat ? Je continue à chercher mais je commence un peu à perdre espoir d'y arriver...

Stéphanie

3 Replies Last Post 23 dic 2010, 12:18 GMT-5
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 dic 2010, 04:55 GMT-5
Hi Stéphanie

Stick to English then you would get far more replies ;)

For V3.5a ,the variables of COMSOL are all compacted in the "fem" striucture, so you must first "extract" them via the postinterp(), and/or posteval() functions.

There are several discussions around data retrieval and matlab interfacingm on the forum, try a search with "posteval()" or other keywords

For the rest it's really taking the time to learn. Pls be aware that the matlab inerface changes quite a lot in V4 so you must re-learn again for the new version, probably worth to check if jumping straight to v4.1 is not worth the effort.

--
Good luck
Ivar
Hi Stéphanie Stick to English then you would get far more replies ;) For V3.5a ,the variables of COMSOL are all compacted in the "fem" striucture, so you must first "extract" them via the postinterp(), and/or posteval() functions. There are several discussions around data retrieval and matlab interfacingm on the forum, try a search with "posteval()" or other keywords For the rest it's really taking the time to learn. Pls be aware that the matlab inerface changes quite a lot in V4 so you must re-learn again for the new version, probably worth to check if jumping straight to v4.1 is not worth the effort. -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 dic 2010, 10:35 GMT-5
Hi Ivar,

Thank you for your answer.

Unfortunately, the solution by using the function postinterp( ) does not work in my case. This function need the full coordinates at the point(s) where I want my output-function (fft or integration or derivative...). My geometry is really complex and obviously I have not these coordinates at the boundary. Moreover, my post-function have to be found somewhere at the boundary of my geometry.

For example : the output of my eigen-equation is an eigen-function u(x,y,z) defined at the boundary of my geometry. If I want the derivative of u with respect to x at the point (0,1,2), I should type :

>> postinterp(fem , 'ux' , [0 ; 1 ; 2]) % (0;1;2) is a point at the surface of my geometry

ok...

This method does not work if I have not these coordinates (like it is the case in my true problem)...How can I do to get ux (or the fft) somewhere at the boundary of my geometry if I do not know the coordinates of these points ?

In attachement the M.file allowing to obtain the function u using eigen-solver.

Thank you

Stéphanie C

Hi Ivar, Thank you for your answer. Unfortunately, the solution by using the function postinterp( ) does not work in my case. This function need the full coordinates at the point(s) where I want my output-function (fft or integration or derivative...). My geometry is really complex and obviously I have not these coordinates at the boundary. Moreover, my post-function have to be found somewhere at the boundary of my geometry. For example : the output of my eigen-equation is an eigen-function u(x,y,z) defined at the boundary of my geometry. If I want the derivative of u with respect to x at the point (0,1,2), I should type : >> postinterp(fem , 'ux' , [0 ; 1 ; 2]) % (0;1;2) is a point at the surface of my geometry ok... This method does not work if I have not these coordinates (like it is the case in my true problem)...How can I do to get ux (or the fft) somewhere at the boundary of my geometry if I do not know the coordinates of these points ? In attachement the M.file allowing to obtain the function u using eigen-solver. Thank you Stéphanie C


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 dic 2010, 12:18 GMT-5
Hi

I usually cut my geometry with "internal" extra boundaries where I need to do measurements, like this I can use lines, boundaries etc to define my traces and data retrieve points. This I do on my CAD (even complex ones) as I also do it often to impove the meshing process.

But I know that it is not possible in all cases. Chec the forum you are not the first one with this demand (fft yes, I believe, but retrieving arbitrary data points no)

--
Good luck
Ivar
Hi I usually cut my geometry with "internal" extra boundaries where I need to do measurements, like this I can use lines, boundaries etc to define my traces and data retrieve points. This I do on my CAD (even complex ones) as I also do it often to impove the meshing process. But I know that it is not possible in all cases. Chec the forum you are not the first one with this demand (fft yes, I believe, but retrieving arbitrary data points no) -- Good luck Ivar

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.