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.

Livelink update values after Comsol iteration

Please login with a confirmed email address before reporting spam

Hi

I have seen a question that is repeated several times in the forum but has no clear answer to me.

So, using COMSOL through MATLAB script. After COMSOL has finished the calculation you might change some of the values of the solution applying either other solver or some script with MATLAB, and later you might want to update this new values into COMSOL, to run again the simulation.

So at each time loop being C your unknown:

1) C(t) --> Comsol --> C'(t+dt) --> Other programs --> C(t+dt)
2) C(t+dt) --> Comsol --> C'(t+2*dt) --> Other programs --> C(t+2*dt)
3)
.
.
.
n_iteration

So I wonder, what is the best way to update initial values in a COMSOL calculation through the livelink

Thanks

1 Reply Last Post 11.07.2017, 05:20 GMT-4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 11.07.2017, 05:20 GMT-4
Hi

There are several options

If you just wish to define initial values as scalars then simply include these values as parameters in your model. Use
model.param.set
to set the values in Comsol using the API.

If you have a set of values that are defined as a field (i.e. they vary over x, y and z) you can define an interpolation function in your model. Use the API to update the data values that are used by the interpolation function.

For advanced users there is an option of defining values as a field directly into the solution vector. This requires some tweaking of the model in order to make it work, but gives maximum control of exactly what data Comsol is using.


--
Lars Gregersen
Comsol Denmark
Hi There are several options If you just wish to define initial values as scalars then simply include these values as parameters in your model. Use model.param.set to set the values in Comsol using the API. If you have a set of values that are defined as a field (i.e. they vary over x, y and z) you can define an interpolation function in your model. Use the API to update the data values that are used by the interpolation function. For advanced users there is an option of defining values as a field directly into the solution vector. This requires some tweaking of the model in order to make it work, but gives maximum control of exactly what data Comsol is using. -- Lars Gregersen Comsol Denmark

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.