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.

input matlab matrix into nodal points in comsol

Please login with a confirmed email address before reporting spam

Hi everyone,

I am currently using the structural mechanics model with the 3D transient stress-strain analysis
I have got this force field that I simulated in matlab (a force plane) which I want to introduce into my comsol model.
In the literature, I have found people quoting

"The numerical values of the forcing field are developed using Matlab°R and stored as a matrix. These are packaged in
a .txt file which allows them to be imported into commercially available FEM modeling software (Comsol Multiphysics°R 3.2, Comsol°R Inc, Stockholm, Sweden)"

can anyone know how to do this?

Many thanks

Brian

5 Replies Last Post 19 nov 2012, 01:30 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 5 lug 2010, 01:25 GMT-4
Hi

I suppose you should understand this as "any field in COMSOl can be used for an eqution/ a function so if you define your force as F(x,y) (instead of a constant like juts 10[N]) via a mapping function you should have a Force field ready

But try to make it sufficiently smooth so that the solver manages to follow

Good luck
Ivar
Hi I suppose you should understand this as "any field in COMSOl can be used for an eqution/ a function so if you define your force as F(x,y) (instead of a constant like juts 10[N]) via a mapping function you should have a Force field ready But try to make it sufficiently smooth so that the solver manages to follow Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 5 lug 2010, 04:04 GMT-4
Hi Ivar,

Thanks for your reply. What I have calculated using MATLAB is a force filed induced by focusing an ultrasound beam. I guess one way would be to do what you suggested but I would need to think about how to put it into equations.

But since I have it simulated in MATLAB, do you know how to save that matrix as a txt file and import into Comsol as the applied force?

Many thanks

Brian
Hi Ivar, Thanks for your reply. What I have calculated using MATLAB is a force filed induced by focusing an ultrasound beam. I guess one way would be to do what you suggested but I would need to think about how to put it into equations. But since I have it simulated in MATLAB, do you know how to save that matrix as a txt file and import into Comsol as the applied force? Many thanks Brian

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 12 nov 2010, 00:01 GMT-5
Hi Brian,

Did you ever figure this out? I am trying to do a very similar thing.

Thanks,
Hi Brian, Did you ever figure this out? I am trying to do a very similar thing. Thanks,

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 12 nov 2010, 00:55 GMT-5
a working way to do this is defines a GLOBAL matlab function F(x,y) and call it where you need in your model .
it it is very simple.
Just be CAREFUL in reading comsol guidelines about matlab function to be used by Comsol....EVERY word matters there and if these guidelines are not followed the call will not work properly ....
if you have a tabulated set of precalculated value matlab provides you with interp.... functions that are already vectorized...
so your functions should just call matlab interpolation funciton to work on your data file and return a calculated value fe each x,y

This work [ in 4.0a ].. I use it.[ almost] everyday..
but again be careful about coding of F it need to be a vectorized function as explained in the guidelines aforementionned
jf
a working way to do this is defines a GLOBAL matlab function F(x,y) and call it where you need in your model . it it is very simple. Just be CAREFUL in reading comsol guidelines about matlab function to be used by Comsol....EVERY word matters there and if these guidelines are not followed the call will not work properly .... if you have a tabulated set of precalculated value matlab provides you with interp.... functions that are already vectorized... so your functions should just call matlab interpolation funciton to work on your data file and return a calculated value fe each x,y This work [ in 4.0a ].. I use it.[ almost] everyday.. but again be careful about coding of F it need to be a vectorized function as explained in the guidelines aforementionned jf

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19 nov 2012, 01:30 GMT-5
Mr. Leon,

Are you saying that you can use MATLAB to find interpolated function for the force matrix? Then use that function in COMSOL? Thanks.

--
Austin Roth
Mr. Leon, Are you saying that you can use MATLAB to find interpolated function for the force matrix? Then use that function in COMSOL? Thanks. -- Austin Roth

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.