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.

User defined functions from Matlab for COMSOL simulation

Please login with a confirmed email address before reporting spam

Hi,

I am trying to model turbulent flow as well as time-dependent species equation in a certain domain, where the species concentrations at some of the boundaries vary with time (NOT known in analytical form or as data Table). These boundary conditions need to be obtained through a completely separate procedure at each time step. I already have that part coded up in Fortran (which can be easily rewritten as m code). I am looking for a way to couple these two domains. At each time step, I want the comsol simulation to call my subroutine (.m or .c code), obtain the numerical values of those boundary conditions, solve the problem in its domain, and if a certain convergence criterion is satisfied, then moves on to next time step (and if not, calls the subroutine again in the same time-step). First, I need to know if this is feasible in comsol, and if so, what is the procedure? Is there any documentation (or possibly webinar) that I can look at?

An alternative would be to write the entire program in matlab, where comsol simulation is called at every time-step (reverse procedure!). I am using version 3.4, but should be able to use 4.0 as well.

Any help or comment is really appreciated!
Sam

1 Reply Last Post 26 janv. 2015, 14:32 UTC−5
COMSOL Moderator

Hello Sam Bey

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 9 years ago 26 janv. 2015, 14:32 UTC−5
Hi , I have the exact same issue. I need to do some operations on my COMSOL data at every step and feed the data back to COMSOL. I want to do this in non-MATLAB ways, i.e., using either C or Fortran. I am wondering how did you solve this issue?


Thanks and regards,
Souvik.

--
MuRG@Mac
Hi , I have the exact same issue. I need to do some operations on my COMSOL data at every step and feed the data back to COMSOL. I want to do this in non-MATLAB ways, i.e., using either C or Fortran. I am wondering how did you solve this issue? Thanks and regards, Souvik. -- MuRG@Mac

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.