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.

stiffness matrix

Please login with a confirmed email address before reporting spam

hello,

maybe thats a stupid question. How can I see the stiffness matrix my solver is working with.

I know the matrix has a high dimension so I can't really look at it. But is it possible to see some "statistics", like symmetry, entries unequel 0 etc.?

I'm using Comsol 4.2

Thanks

8 Replies Last Post Mar 15, 2016, 5:14 p.m. EDT
Masoud Ghorbani Moghaddam

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Sep 13, 2011, 11:33 a.m. EDT
Hi Gustav,

You can get your stiffness Matrix as well as your Mass, Damping matrixes and also Load Vector from the livelink Matlab. Do not afraid to go and try the Livelink. It is really easy:

1) Run Your model in Comsol Gui.
2) Save it in Matlab File. It will save it as a .m file.(Under the file on your Comsol toolbar)
3) Open the Comsol with livelink in Matlab under Comsol in your Start Menu.
4) open the .m file you had saved before.
5) It is in function format. Remove the function in the first row of your Matlab Code.
6) Run the Matlab Code.
7) After the running was finished, go the command window and type:
MA=mphmatrix(model,'sol1','out',{'K','D','E','L'})
and run it. (K=Stiffness Matrix, D=Damping, E=Mass, L=Load)
8)Now you can get the information you want by typing:
MA.K or MA.E or ME.D or MA.L in the command window.

It is easy. Do not afraid to try it.

Hopefully it will be helpful,

Regards,
Masoud

Hi Gustav, You can get your stiffness Matrix as well as your Mass, Damping matrixes and also Load Vector from the livelink Matlab. Do not afraid to go and try the Livelink. It is really easy: 1) Run Your model in Comsol Gui. 2) Save it in Matlab File. It will save it as a .m file.(Under the file on your Comsol toolbar) 3) Open the Comsol with livelink in Matlab under Comsol in your Start Menu. 4) open the .m file you had saved before. 5) It is in function format. Remove the function in the first row of your Matlab Code. 6) Run the Matlab Code. 7) After the running was finished, go the command window and type: MA=mphmatrix(model,'sol1','out',{'K','D','E','L'}) and run it. (K=Stiffness Matrix, D=Damping, E=Mass, L=Load) 8)Now you can get the information you want by typing: MA.K or MA.E or ME.D or MA.L in the command window. It is easy. Do not afraid to try it. Hopefully it will be helpful, Regards, Masoud

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Sep 14, 2011, 1:54 a.m. EDT
hey Masoud,

thanks for your fast answer, but I don't have the livelink licence for matlab. Isn't there anyway to look at my sitffness matrix with default packages of Comsol?
hey Masoud, thanks for your fast answer, but I don't have the livelink licence for matlab. Isn't there anyway to look at my sitffness matrix with default packages of Comsol?

Masoud Ghorbani Moghaddam

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Sep 14, 2011, 10:28 a.m. EDT
Hi,

I do not think you can have access to those information from COMSOL without having the Livelink. At least I dont know it. Sorry.

Masoud
Hi, I do not think you can have access to those information from COMSOL without having the Livelink. At least I dont know it. Sorry. Masoud

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Oct 5, 2011, 10:48 a.m. EDT
Hi, Masoud,

I followed your suggesting untill the step 'RUN MATLAB CODE'. But when I typed 'MA=mphmatrix(model,'sol1','out',{'K','D','E','L'})' and ran it, there was an error as follows:

??? Error using ==> proputil at 9
A property/value list must contain an even number of elements.
Error in ==> D:\Program Files\MATLAB\R2009a\COMSOL40a\mli\mphmatrix.p>mphmatrix at 64


In addition, I have another question. There was not any error occured when I ran the M file before running the last code "MA=.....". Dose this mean my livelink Matlab work ?

Regards,
KAIPENG
Hi, Masoud, I followed your suggesting untill the step 'RUN MATLAB CODE'. But when I typed 'MA=mphmatrix(model,'sol1','out',{'K','D','E','L'})' and ran it, there was an error as follows: ??? Error using ==> proputil at 9 A property/value list must contain an even number of elements. Error in ==> D:\Program Files\MATLAB\R2009a\COMSOL40a\mli\mphmatrix.p>mphmatrix at 64 In addition, I have another question. There was not any error occured when I ran the M file before running the last code "MA=.....". Dose this mean my livelink Matlab work ? Regards, KAIPENG

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jun 8, 2015, 11:16 p.m. EDT

Hi Gustav,

You can get your stiffness Matrix as well as your Mass, Damping matrixes and also Load Vector from the livelink Matlab. Do not afraid to go and try the Livelink. It is really easy:

1) Run Your model in Comsol Gui.
2) Save it in Matlab File. It will save it as a .m file.(Under the file on your Comsol toolbar)
3) Open the Comsol with livelink in Matlab under Comsol in your Start Menu.
4) open the .m file you had saved before.
5) It is in function format. Remove the function in the first row of your Matlab Code.
6) Run the Matlab Code.
7) After the running was finished, go the command window and type:
MA=mphmatrix(model,'sol1','out',{'K','D','E','L'})
and run it. (K=Stiffness Matrix, D=Damping, E=Mass, L=Load)
8)Now you can get the information you want by typing:
MA.K or MA.E or ME.D or MA.L in the command window.

It is easy. Do not afraid to try it.

Hopefully it will be helpful,

Regards,
Masoud


I have testify mphmatrix and mphstate. However, i find K D E is not the matrix i want to extract for the future computation. for example, Null*K*Null' doesn't equal to Kc. Which Kc is the eliminated Stiffness Matrix. There is a special vector named "uscale" could you express in details for me? Thanks very much.
[QUOTE] Hi Gustav, You can get your stiffness Matrix as well as your Mass, Damping matrixes and also Load Vector from the livelink Matlab. Do not afraid to go and try the Livelink. It is really easy: 1) Run Your model in Comsol Gui. 2) Save it in Matlab File. It will save it as a .m file.(Under the file on your Comsol toolbar) 3) Open the Comsol with livelink in Matlab under Comsol in your Start Menu. 4) open the .m file you had saved before. 5) It is in function format. Remove the function in the first row of your Matlab Code. 6) Run the Matlab Code. 7) After the running was finished, go the command window and type: MA=mphmatrix(model,'sol1','out',{'K','D','E','L'}) and run it. (K=Stiffness Matrix, D=Damping, E=Mass, L=Load) 8)Now you can get the information you want by typing: MA.K or MA.E or ME.D or MA.L in the command window. It is easy. Do not afraid to try it. Hopefully it will be helpful, Regards, Masoud [/QUOTE] I have testify mphmatrix and mphstate. However, i find K D E is not the matrix i want to extract for the future computation. for example, Null*K*Null' doesn't equal to Kc. Which Kc is the eliminated Stiffness Matrix. There is a special vector named "uscale" could you express in details for me? Thanks very much.

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Jan 30, 2016, 5:01 a.m. EST
Hello,

Could anybody tell me if it is possible to modify the stiffness matrix (I need to add some terms) by using MatLab? I'm using LiveLink for MatLab, Comsol Multiphysics 5.2.

Thanks

Giulia

Hello, Could anybody tell me if it is possible to modify the stiffness matrix (I need to add some terms) by using MatLab? I'm using LiveLink for MatLab, Comsol Multiphysics 5.2. Thanks Giulia

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Mar 8, 2016, 6:13 p.m. EST

Hello,

Could anybody tell me if it is possible to modify the stiffness matrix (I need to add some terms) by using MatLab? I'm using LiveLink for MatLab, Comsol Multiphysics 5.2.

Thanks

Giulia


I am also interested in modifying the stiffness matrix and then re-running the model. How is this done?
[QUOTE] Hello, Could anybody tell me if it is possible to modify the stiffness matrix (I need to add some terms) by using MatLab? I'm using LiveLink for MatLab, Comsol Multiphysics 5.2. Thanks Giulia [/QUOTE] I am also interested in modifying the stiffness matrix and then re-running the model. How is this done?

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Mar 15, 2016, 5:14 p.m. EDT
Shuai,

First of all, Kc = Nullf'*K*Null (not Kc = Null*K*Null) even though it is often true that Nullf = Null.

I have found that if you construct the matrices NULLf and NULL using the following Matlab code this identity holds. Be sure you get 'Dc' if you are using damping. Here's a helpful link. www.comsol.com/blogs/implementing-the-weak-form-with-a-comsol-app/

MA = mphmatrix(model, 'sol1', 'out', {'K','Kc','Dc','Null','Nullf','uscale'})

NULL = [];
NULLf = [];
for ii = 1:length(MA.uscale)
NULL = [NULL; MA.uscale(ii)*MA.Null(ii,:)];
NULLf = [NULLf; MA.uscale(ii)*MA.Nullf(ii,:)];
end
Kc_comp5 = NULLf'*MA.K*NULL;
(NULLf'*MA.K*NULL - Kc)
max(max(NULLf'*MA.K*NULL - Kc))
Shuai, First of all, Kc = Nullf'*K*Null (not Kc = Null*K*Null) even though it is often true that Nullf = Null. I have found that if you construct the matrices NULLf and NULL using the following Matlab code this identity holds. Be sure you get 'Dc' if you are using damping. Here's a helpful link. http://www.comsol.com/blogs/implementing-the-weak-form-with-a-comsol-app/ MA = mphmatrix(model, 'sol1', 'out', {'K','Kc','Dc','Null','Nullf','uscale'}) NULL = []; NULLf = []; for ii = 1:length(MA.uscale) NULL = [NULL; MA.uscale(ii)*MA.Null(ii,:)]; NULLf = [NULLf; MA.uscale(ii)*MA.Nullf(ii,:)]; end Kc_comp5 = NULLf'*MA.K*NULL; (NULLf'*MA.K*NULL - Kc) max(max(NULLf'*MA.K*NULL - Kc))

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.