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.

Import a matrix from mpheval operator.

Please login with a confirmed email address before reporting spam

Hi, I'd like to ask a question!

I got the matrix (V=mpheval(model,'V')) using the Livelink.
and I modified value of some points in V matrix.
But when I import to COMSOL, It didn't be reflected.

If you have any experience or helps could you give me any suggestion?


3 Replies Last Post Sep 13, 2017, 4:50 a.m. EDT
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Sep 11, 2017, 7:41 a.m. EDT
Hi Min

This is not how Matlab works.

You use mpheval to extract values from a Comsol model and you can continue to work on the data in Matlab.

There is no way that Comsol can know if you change a value in Matlab. If you wish a Comsol model to be affected you must send the new values to Comsol using one or more commands.
There is currently no feature that will send the output from mpheval to a Comsol. If you really need to change values in a model on the mesh level then you have to use the Comsol API (look for setU in the programming reference manual).

You will probably find it easier using an interpolation function instead.

--
Lars Gregersen
Comsol Denmark
Hi Min This is not how Matlab works. You use mpheval to extract values from a Comsol model and you can continue to work on the data in Matlab. There is no way that Comsol can know if you change a value in Matlab. If you wish a Comsol model to be affected you must send the new values to Comsol using one or more commands. There is currently no feature that will send the output from mpheval to a Comsol. If you really need to change values in a model on the mesh level then you have to use the Comsol API (look for setU in the programming reference manual). You will probably find it easier using an interpolation function instead. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Sep 12, 2017, 9:49 a.m. EDT
Thanks for you reply Lars.
I'm simulating with parametric sweep.
In my model, each parameter result is based on previous step of parameter.
(Voltage parameter sweep,
V1 result came from V0
V2 result came from V1
....
Vn result came from Vn-1
It is because of changed variables.(material parameter)

However, once simulation got finished in Livelink, I couldn't make my variables be affected from prvious step result. It represents result all of the parameter step without having no chance to edit my variables.
That's why I've trying with mpheval.

In Parametric sweep how can I modify my variables depending on at specific step result?and get next step result with previous result?
Thanks for you reply Lars. I'm simulating with parametric sweep. In my model, each parameter result is based on previous step of parameter. (Voltage parameter sweep, V1 result came from V0 V2 result came from V1 .... Vn result came from Vn-1 It is because of changed variables.(material parameter) However, once simulation got finished in Livelink, I couldn't make my variables be affected from prvious step result. It represents result all of the parameter step without having no chance to edit my variables. That's why I've trying with mpheval. In Parametric sweep how can I modify my variables depending on at specific step result?and get next step result with previous result?

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Sep 13, 2017, 4:50 a.m. EDT
Updated: 7 years ago Sep 13, 2017, 4:50 a.m. EDT

You have two choices:

1 - You can extract the values from one simulation using mphgetu and put it back in again using setU as described earlier. This requires that the geometry and mesh doesn't change and that you set up the solver such that it uses the current value (instead of using the initial value settings).

2 - Define two physics in your model (I'm assuming that you only have one now?). Solve the first physics. Use the result of this simulation as initial value for the second physics and so on.

But I still don't think that all of this is necessary. If you wish to change material parameters you can just make the material parameters depend on the parameter value. I would recommend that you send your model to support where somene can have a look.

-------------------
Lars Gregersen
Comsol Denmark
You have two choices: 1 - You can extract the values from one simulation using mphgetu and put it back in again using setU as described earlier. This requires that the geometry and mesh doesn't change and that you set up the solver such that it uses the current value (instead of using the initial value settings). 2 - Define two physics in your model (I'm assuming that you only have one now?). Solve the first physics. Use the result of this simulation as initial value for the second physics and so on. But I still don't think that all of this is necessary. If you wish to change material parameters you can just make the material parameters depend on the parameter value. I would recommend that you send your model to support where somene can have a look.

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.