Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

Extract mass matrix using matlab

Please login with a confirmed email address before reporting spam

Hi,

how to extract mass matrix from comsol/matlab, for a 3D > Solid Mechanics > Eigenfrequency Analysis model? Can't find it in documentation.

Thanks,

5 Replies Last Post 07.05.2011, 06:48 GMT-4
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.03.2011, 11:32 GMT-4
Hi

Search for "state space" or "mphstate()"

By the way the doc is slightly misleading, here is a code that works for the doc (I received it from Remi of COMSOL support)

%%%%%%%%%%%%%%
% Load the heat_convection_2d.mph model
model = mphload('heat_convection_2d.mph');
% Set the temperature condition with a constant parameter
model.param.set('T0','373');
model.physics('ht').feature('temp1').set('T0', 1, 'T0');
% Add a point probe at [0.3;0.8]
pdom1 = model.probe.create('pdom1', 'DomainPoint');
pdom1.model('mod1'); pdom1.setIndex('coords2','0.8',0,0);
pdom1.setIndex('coords2','0.3',0,0);
% Extract matrix data
M = mphstate(model,'sol1','out',{'MA' 'MB' 'C' 'D'},...
'input','T0', 'output', 'mod1.ppb1');
%%%%%%%%%%%%%%

At least this works OK for 4.1 ;)
--
Good luck
Ivar
Hi Search for "state space" or "mphstate()" By the way the doc is slightly misleading, here is a code that works for the doc (I received it from Remi of COMSOL support) %%%%%%%%%%%%%% % Load the heat_convection_2d.mph model model = mphload('heat_convection_2d.mph'); % Set the temperature condition with a constant parameter model.param.set('T0','373'); model.physics('ht').feature('temp1').set('T0', 1, 'T0'); % Add a point probe at [0.3;0.8] pdom1 = model.probe.create('pdom1', 'DomainPoint'); pdom1.model('mod1'); pdom1.setIndex('coords2','0.8',0,0); pdom1.setIndex('coords2','0.3',0,0); % Extract matrix data M = mphstate(model,'sol1','out',{'MA' 'MB' 'C' 'D'},... 'input','T0', 'output', 'mod1.ppb1'); %%%%%%%%%%%%%% At least this works OK for 4.1 ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 01.04.2011, 12:19 GMT-4
Hi Ivar,

Did you verify that the solution you get from using the state space matrices is the same as the solution you get from the COMSOL GUI?

V/R,
Andrew Wang
Hi Ivar, Did you verify that the solution you get from using the state space matrices is the same as the solution you get from the COMSOL GUI? V/R, Andrew Wang

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 03.05.2011, 11:02 GMT-4
Hi Andrew

I have not worked on it since last week -- I will hopefully get it done within a couple of days and then will let you know.

However, for the simple 2D heat-transfer problem (non-coupled, single physics problem), I believe it should give more or less the same results. But I will update once I have implemented it.

Madu
Hi Andrew I have not worked on it since last week -- I will hopefully get it done within a couple of days and then will let you know. However, for the simple 2D heat-transfer problem (non-coupled, single physics problem), I believe it should give more or less the same results. But I will update once I have implemented it. Madu

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 06.05.2011, 16:40 GMT-4
I worked this example in MATLAB (LiveLink), literally cutting and pasting from Ivar's example. MATLAB throws no errors, but the 'C' matrix is empty which is something I would not expect considering the probe. Also, I slightly modified the example by asking for the 'A' and 'B' matrices vice the 'MA' and 'MC' matrices. In these cases, I get the following error:

??? Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: Unknown property
Messages:
Unknown property
- Property: A

Does someone on this Forum know if there are some bugs in the code? If so, has anyone heard when a fix is due out?

Thanks to all who take the time to answer this forum! You are doing a great service to us 'new-to-COMSOL' folks.
I worked this example in MATLAB (LiveLink), literally cutting and pasting from Ivar's example. MATLAB throws no errors, but the 'C' matrix is empty which is something I would not expect considering the probe. Also, I slightly modified the example by asking for the 'A' and 'B' matrices vice the 'MA' and 'MC' matrices. In these cases, I get the following error: ??? Java exception occurred: Exception: com.comsol.util.exceptions.FlException: Unknown property Messages: Unknown property - Property: A Does someone on this Forum know if there are some bugs in the code? If so, has anyone heard when a fix is due out? Thanks to all who take the time to answer this forum! You are doing a great service to us 'new-to-COMSOL' folks.

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.05.2011, 06:48 GMT-4
Hi

I have not fully amnaged to get it eitherworkin under v4.1, so I'm waiting for 4.2. But there was another thread the last days, I believe using JAVA describing how to (or what is Matlab ?, I'm looking at to many threads here ;)
oups it was the next thread in the list, here is the link

www.comsol.eu/community/forums/general/thread/13667/#p49298

--
Good luck
Ivar
Hi I have not fully amnaged to get it eitherworkin under v4.1, so I'm waiting for 4.2. But there was another thread the last days, I believe using JAVA describing how to (or what is Matlab ?, I'm looking at to many threads here ;) oups it was the next thread in the list, here is the link http://www.comsol.eu/community/forums/general/thread/13667/#p49298 -- Good luck Ivar

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.