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.
Single Shot
Posted 5 oct. 2022, 08:18 UTC−4 Battery Design, LiveLink for MATLAB, Studies & Solvers Version 6.0 6 Replies
Please login with a confirmed email address before reporting spam
Hi, I want to use a Comsol model in Matlab where I want to update a parameter after each iteration. Is there any way to use a study that calculates only a single time element and then updates the parameter in Matlab and then calculates the next single time element.
Thanks in advance
Please login with a confirmed email address before reporting spam
Johannes,
parameters cannot be updated during a solution process, but you can define a variable according to your needs. The variable will then be calculated in each time step and you can refer to it in the model, e.g. in boundary conditions. Depending on your requirements you may not need Matlab for that.
Cheers Edgar
-------------------Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Please login with a confirmed email address before reporting spam
Edgar,
is there any way to calculate the solution in Matlab using state space extraction, as I am currently designing a controller for the model and my company has only given the "LiveLink for Simulink" license to the license bool for the coming quarter, so this will not be available until November.
Johannes
Attachments:
Please login with a confirmed email address before reporting spam
Dear Johannes,
To implement such a control system the easiest is to use LiveLink for Simulink, which enables cosimulation between COMSOL Multiphysics and Simulink. You can benefit the Simulink interface to implement the control system and solve the physical problem in COMSOL.
Alternatively you can implement the control system entirely in COMSOL as it is described in the Application Library model: https://www.comsol.com/model/process-control-using-a-pid-controller-866
Please login with a confirmed email address before reporting spam
Thank you for your expertise
The problem with this controller lib is that I am not using a PID controller. In my case I would use a state space controller and so I want to extract the states or use this single shot. As I said, the license is requested but not solved yet. Maybe you have an idea how to extract the SS model, because when I extract that the first time it works, but on the second run the Matlab console gives the following error message and I don't always want to remove that manually.
Error using mphstate
Solution already contains an active StateSpace node.
Error in State_Space_MJ1 (line 25)
M = mphstate(model2,'sol1','out', {'MA' 'MB' 'Mc' 'C' 'D' 'x0', 'Null', 'ud'},...`
Please login with a confirmed email address before reporting spam
Dear Johannes,
the error message indicates that between the two runs the state-space node remain active in the COMSOL model. When calling MPHSTATE. make sure you set the property 'keepfeature' to 'off' to avoid this issue. I would rather recommend you to use a reduced order model (ROM) from which you can also extract state-space matrices (with the function MPHREDUCTION), as this approach provides more efficient matrices to work with.
If you still have issue the best is to continue the discussion via the COMSOL support, feel free to address the question to me.
Best regards,
Please login with a confirmed email address before reporting spam
It works for me now, thank you very much.
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.
Suggested Content
- BLOG Happy Birthday, Angelo Moriondo
- KNOWLEDGE BASE Reverse Proxy Setup for Model Manager Server
- KNOWLEDGE BASE Understanding the Fully Coupled vs. Segregated approach and Direct vs. Iterative Linear Solvers
- KNOWLEDGE BASE What hardware do you recommend for COMSOL Multiphysics®?
- FORUM Single Nanoholes
