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.

Possible Inconsistency Between mpheval and mphmatrix?

Please login with a confirmed email address before reporting spam

Using livelink with MATLAB, I am trying to get a handle on how the various state matrices/vectors are handled. Right now I'm confused by what seems to be a discrepancy using the attached extremely simple heat transfer model. In Matlab, I enter the following lines:

>> model = mphload('mcbee15.mph');
>> dat=mpheval(model, {'x' 'y' 'T'});
>> solution=mphgetu(model);

I then compare the node 'x' value (col 1), the node 'y' value (col 2), and the node 'T' value (col 3) as given to me by the mpheval command. Column 4 is the output of 'T' from the mphgetu command. I expected columns 3 and 4 to match up perfectly, but they are completely different permutations of the same 'T' values.

>> [dat.d1',dat.d2',dat.d3',solution]

ans =

0.7500 0 1.0000 1.0000
1.0000 0 1.0000 0.8621
0.7500 0.2500 0.8621 0.7453
1.0000 0.2500 0.8621 0.6672
0.7500 0.5000 0.7453 0.6398
1.0000 0.5000 0.7453 1.0000
0.7500 0.7500 0.6672 1.0000
1.0000 0.7500 0.6672 1.0000
0.7500 1.0000 0.6398 1.0000
1.0000 1.0000 0.6398 0.8621
0.5000 0 1.0000 0.7453
0.5000 0.2500 0.8621 0.6672
0.2500 0 1.0000 0.6398
0.2500 0.2500 0.8621 0.8621
0 0 1.0000 0.8621
0 0.2500 0.8621 0.8621
0.5000 0.7500 0.6672 0.7453
0.5000 1.0000 0.6398 0.6672
0 0.5000 0.7453 0.6398
0.2500 0.5000 0.7453 0.7453
0.2500 0.7500 0.6672 0.7453
0.2500 1.0000 0.6398 0.6672
0 0.7500 0.6672 0.6398
0 1.0000 0.6398 0.6672
0.5000 0.5000 0.7453 0.6398


Can anyone please explain the discrepancy? Also, which one of these would represent the coefficient vector that would be pre multiplied by the non-reduced stiffness matrix? Does dat.p truely give me the x,y coordinates of each node or am I missing something?

Thanks much!



1 Reply Last Post Nov 1, 2011, 5:17 a.m. EDT
COMSOL Moderator

Hello Brian McBee

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 1, 2011, 5:17 a.m. EDT
I have noted the same difference. You can get the coordinates of the solution vector that is retrieved by mphgetu using

xmi = mphxmeshinfo(model);
solCoords = xmi.dofs.coords;

The node index retrieved by
nodeNum = xmi.dofs.nodes;
indicates that the nodes are not sorted.

If you want to get derived variables in the same node order as the solution vector you need to use mphinterp at the coordinates of the respective nodes.

[~,loc] = unique(nodeNum);
out_COMSOL.theta = mphinterp(model,'dl.theta',...
'coord',solCoords(:,loc))';

At least, that's how I do it...
If there is a more elegant way, please let me know.
I have noted the same difference. You can get the coordinates of the solution vector that is retrieved by mphgetu using xmi = mphxmeshinfo(model); solCoords = xmi.dofs.coords; The node index retrieved by nodeNum = xmi.dofs.nodes; indicates that the nodes are not sorted. If you want to get derived variables in the same node order as the solution vector you need to use mphinterp at the coordinates of the respective nodes. [~,loc] = unique(nodeNum); out_COMSOL.theta = mphinterp(model,'dl.theta',... 'coord',solCoords(:,loc))'; At least, that's how I do it... If there is a more elegant way, please let me know.

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.