Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
30 août 2012, 05:26 UTC−4
Hi,
You have clear instructions on how to extract matrices if you read pages 143-146 from the livelinkformatlabusersguide.
For example, if you have a filename.mph file, load it into matlab and then use the following commands. The MA (or you can give whatever name) strucutre will hold all that you ask for.
% load the model
model = mphload('filename'); %this is the mph file name without the .mph extension
model.study('std1').run;
model.sol('sol1').feature('s1').active(false);
MA = mphmatrix(model,'sol1','out',{'K','Kc','L','Lc','M','Null','Nullf','ud','uscale'});
Suresh
Hi,
You have clear instructions on how to extract matrices if you read pages 143-146 from the livelinkformatlabusersguide.
For example, if you have a filename.mph file, load it into matlab and then use the following commands. The MA (or you can give whatever name) strucutre will hold all that you ask for.
% load the model
model = mphload('filename'); %this is the mph file name without the .mph extension
model.study('std1').run;
model.sol('sol1').feature('s1').active(false);
MA = mphmatrix(model,'sol1','out',{'K','Kc','L','Lc','M','Null','Nullf','ud','uscale'});
Suresh
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
3 sept. 2012, 07:56 UTC−4
Hi Mr. Suresh
Thank you for the reply. I can now extract the mass and stiffness matrices from Comsol to Matlab. The instructions in Comsol help is also helpful.
The problem I face now is the size of the mass and the stiffness matrices. When I model a simpel 2D beam fixed in one end and pined in the other, I get a matrices of size 66x66 !! Although I build the beam as to elements between to nodes.
So how is the mass and stiffness matrices I extract is coupled to the nodes in my model, because I am only interested in the values of these matrices in the nodes I introduce in my model.
I use this Matlab code
model = mphload('Test1'); %this is the mph file name without the .mph extension
str = mphmatrix(model,'sol1','Out',{'K','E'}); %E er massematrice
M=str.E;
K=str.K;
[rm,cm]=size(M)
[rk,ck]=size(K)
Hi Mr. Suresh
Thank you for the reply. I can now extract the mass and stiffness matrices from Comsol to Matlab. The instructions in Comsol help is also helpful.
The problem I face now is the size of the mass and the stiffness matrices. When I model a simpel 2D beam fixed in one end and pined in the other, I get a matrices of size 66x66 !! Although I build the beam as to elements between to nodes.
So how is the mass and stiffness matrices I extract is coupled to the nodes in my model, because I am only interested in the values of these matrices in the nodes I introduce in my model.
I use this Matlab code
model = mphload('Test1'); %this is the mph file name without the .mph extension
str = mphmatrix(model,'sol1','Out',{'K','E'}); %E er massematrice
M=str.E;
K=str.K;
[rm,cm]=size(M)
[rk,ck]=size(K)
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
3 sept. 2012, 16:38 UTC−4
Hi,
You now pose a difficult question. I suggest that you speak to COMSOL support, they will give you correct answer.
The system matrix is typically nxn matrix where n is the total number of degrees of freedom in the entire domain. Of course if you have only one degree of freedom per node then the number of nodes must coincide with the degrees of freedom. I gave up pursuing the route of modifying system matrices because this meant a lot of work and understanding needed.
You can try to use the mphxmeshinfo command which gives you all the mesh data, dofs, coordinates, etc.
My best suggestion is that you construct just a one element problem to understand how the system matrix and the load vector looks and compare it with your manual derivation. It was easy to understand, but as I said I did not go beyond this point.
Suresh
Hi,
You now pose a difficult question. I suggest that you speak to COMSOL support, they will give you correct answer.
The system matrix is typically nxn matrix where n is the total number of degrees of freedom in the entire domain. Of course if you have only one degree of freedom per node then the number of nodes must coincide with the degrees of freedom. I gave up pursuing the route of modifying system matrices because this meant a lot of work and understanding needed.
You can try to use the mphxmeshinfo command which gives you all the mesh data, dofs, coordinates, etc.
My best suggestion is that you construct just a one element problem to understand how the system matrix and the load vector looks and compare it with your manual derivation. It was easy to understand, but as I said I did not go beyond this point.
Suresh
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
4 sept. 2012, 09:56 UTC−4
Dear Suresh
Thank you for taking time to answer my question.
I just made a simple cantilever beam, using Structural Mechanics/beam with only one element. I get 48x48 matrix, does make since to me, but I will right support.
Best regards
Dear Suresh
Thank you for taking time to answer my question.
I just made a simple cantilever beam, using Structural Mechanics/beam with only one element. I get 48x48 matrix, does make since to me, but I will right support.
Best regards
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
4 sept. 2012, 16:48 UTC−4
Hello Suresh,
Thank you for telling us how to extracting matrices
I have a problem. According to the COMSOL document, we can manually use a linear solver to obtain solution "U", but how to put this "U" back to COMSOL?
Now I'm running a parametric sweep model, in COMSOL 3.5a, I just need following lines:
plist = [fem.sol.plist nvec(ii)];
u_tot = [fem.sol.u u_end];
fem.sol = femsol(u_tot,'pname','n','plist',plist);
What's equivalent to those lines above in COMSOL v4.3?
Thanks a lot
Dan
Hello Suresh,
Thank you for telling us how to extracting matrices
I have a problem. According to the COMSOL document, we can manually use a linear solver to obtain solution "U", but how to put this "U" back to COMSOL?
Now I'm running a parametric sweep model, in COMSOL 3.5a, I just need following lines:
plist = [fem.sol.plist nvec(ii)];
u_tot = [fem.sol.u u_end];
fem.sol = femsol(u_tot,'pname','n','plist',plist);
What's equivalent to those lines above in COMSOL v4.3?
Thanks a lot
Dan
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
5 sept. 2012, 02:09 UTC−4
Hi,
You can take a look at one of my early responses in this link below:
www.comsol.com/community/forums/general/thread/17744/
I think you will find there how I put back U into next time step. It should be similar. If there is a better, let me know, so that I can update my code.
Suresh
Hi,
You can take a look at one of my early responses in this link below:
http://www.comsol.com/community/forums/general/thread/17744/
I think you will find there how I put back U into next time step. It should be similar. If there is a better, let me know, so that I can update my code.
Suresh