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.

How to simulate correctly the time-dependent problem in Comsol-Simulink environment?

Please login with a confirmed email address before reporting spam

I am trying to simulate the time-dependent problem in Comsol-Simulink. Two variables on every simulation step are entered into the S-function. On every simulation step the Comsol model integrated into the S-function executed and solved through the LiveLink mechanism. In Comsol model I need to use time-dependent solver.

It seems like on every Simulink simulation step, Comsol model in executed and calculated the number of simulation steps specified by the time-dependent solver, while the input variables are constant during this process. As I understand, I have to save somehow the solution of the Comsol model on every simulation step, and this solution should be used as an initial condition for the next step. Could someone help me to understand how to conduct simulation like this correctly. Thank you in advance.

1 Reply Last Post 27 gen 2017, 12:39 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 27 gen 2017, 12:39 GMT-5
Could anyone suggest, after running the Comsol simulation by the command: model.sol('sol1').runAll in the Outputs(block) of the level-2 S-function. I have the solution of my model. After that I have to use this solution as an initial condition for the next iteration step. I am trying to solve the solution with function:
U = mphgetu(model)
After that I have to update the S-function states, in the Update(block) of the S-Function with command:
model.sol('sol1').setU(U)
But this scheme does not work correctly.
The solution of this problem for stationary solver is very easy, however the time-dependent problem is much more complicated. The question is still open.
Or maybe my approach is incorrect at all?
Could anyone suggest, after running the Comsol simulation by the command: model.sol('sol1').runAll in the Outputs(block) of the level-2 S-function. I have the solution of my model. After that I have to use this solution as an initial condition for the next iteration step. I am trying to solve the solution with function: U = mphgetu(model) After that I have to update the S-function states, in the Update(block) of the S-Function with command: model.sol('sol1').setU(U) But this scheme does not work correctly. The solution of this problem for stationary solver is very easy, however the time-dependent problem is much more complicated. The question is still open. Or maybe my approach is incorrect at all?

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.