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.

Matlab LiveLink - Comsol Multiphysics- obtaining stresses of a beam Model

Please login with a confirmed email address before reporting spam

Hello, I'm having issues reading the results of a beam model I solved with Comsol inside my MATLAB algorythm.

My algorythm:

mphopen('PRUEBA')

% mesh info [meshstats,meshdata] = mphmeshstats(model,'mesh1'); coord=meshdata.vertex; nnodos=size(coord,2); conect=meshdata.elem{2}; nelem=size(conect,2);

% Resultados of stress, shear, and transformation to global system. stress=mpheval(model,'beam.sn','dataset','dset1');

The mesh part works fine, I get the coordinates and conection I want, but it gives me a struct with empty fields whenever I try to ask for shear and stress:

struct with fields:

expr: {'beam.sn'}
  d1: [1×0 double]
   p: [3×0 double]
   t: [4×0 int32]
  ve: [0×1 int32]
unit: {'N/m^2'}

Also tried mphiterp just in case:

shear=mphinterp(model,'beam.txymax','dataset','dset1','coord',coord); Error using mphinterp mphinterp (0): Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is 1-by-0.

I saved my comsol file and it works fine, I have values of stress and displacement, but I don't know why I can't read them on COMSOL.

Best Regards



1 Reply Last Post 2021年11月4日 GMT-4 09:45
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 2021年11月4日 GMT-4 09:45
Updated: 3 years ago 2021年11月8日 GMT-5 10:06

Hi Santiago

mpheval and mphinterp assumes you wish to extract data from domains.

For beams you want to extract data from edges. Hence you have to use the edim option.

Hence this is how you use mpheval:

data=mpheval(model,'beam.sn',"edim","edge")

You propably want to use mphinterp in most cases. Here is how to extract data from edge number 3:

c = mphgetcoords(model,'geom1','edge',3)
v = linspace(0,1,10) % 10 points along the edge.
coord = v.*c(:,1)+(1-v).*c(:,2) % lerp (linear interpolation)
dat = mphinterp(model,'beam.sn','edim','edge','coord',coord)
-------------------
Lars Gregersen
Comsol Denmark
Hi Santiago mpheval and mphinterp assumes you wish to extract data from domains. For beams you want to extract data from edges. Hence you have to use the edim option. Hence this is how you use mpheval: data=mpheval(model,'beam.sn',"edim","edge") You propably want to use mphinterp in most cases. Here is how to extract data from edge number 3: c = mphgetcoords(model,'geom1','edge',3) v = linspace(0,1,10) % 10 points along the edge. coord = v.*c(:,1)+(1-v).*c(:,2) % lerp (linear interpolation) dat = mphinterp(model,'beam.sn','edim','edge','coord',coord)

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.