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.

obtain temperature data over a line at a particular time

Please login with a confirmed email address before reporting spam

I would like to obtain a table of the temperature over a given line in my model at a given time. Is there a way to do this? I see that I can do the following, but these aren't quite what I'm looking for:

  1. In Derived Values I can obtain the Average, Integration, Max and Min of temperature for a line at a given time (ie, one value for the line at the specified time)
  2. In Derived Values I can obtain the temperature of a given point at a given time
  3. I can plot temperature along the line at a given time; this is close to what I want, but what I'm looking for is a table of values (like from Derived Values) for the temperature along the line at a given time.

Thank you for any help,

John


6 Replies Last Post Apr 27, 2018, 12:06 p.m. EDT
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 years ago Apr 26, 2018, 8:52 a.m. EDT
Updated: 6 years ago Apr 26, 2018, 10:08 a.m. EDT

Hi John,

After you do 3/ , you can right-click in the model tree node for the Line Graph in question and select Add Plot Data to Export from the drop-down menu. You will be asked to specify a file name for the file will be exported. You also have the option to get the data exported to the clipboard instead of to a file.

Best,

Jeff

[Edit: my last sentence is true of version 5.3a, but not of 4.4.]

-------------------
Jeff Hiller
Hi John, After you do 3/ , you can right-click in the model tree node for the Line Graph in question and select Add Plot Data to Export from the drop-down menu. You will be asked to specify a file name for the file will be exported. You also have the option to get the data exported to the clipboard instead of to a file. Best, Jeff [Edit: my last sentence is true of version 5.3a, but not of 4.4.]

Please login with a confirmed email address before reporting spam

Posted: 6 years ago Apr 26, 2018, 10:03 a.m. EDT

Jeff,

Nice to hear from you, thank you for the response! I should have posted with my question that this is for a MATLAB livelink API application. So, what I am looking for is a way to obtain this data via the API w/o the need to pop up a plot from COMSOL first. I have focused on trying to figure this out via the COMSOL UI first and then save the file as an ".m" file to see what API calls are involved.

Do you know a way to obtain this data via the API?

Best regards,

John

Jeff, Nice to hear from you, thank you for the response! I should have posted with my question that this is for a MATLAB livelink API application. So, what I am looking for is a way to obtain this data via the API w/o the need to pop up a plot from COMSOL first. I have focused on trying to figure this out via the COMSOL UI first and then save the file as an ".m" file to see what API calls are involved. Do you know a way to obtain this data via the API? Best regards, John

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 years ago Apr 26, 2018, 10:11 a.m. EDT

Sorry, John, but I don't have MATLAB to test this out and I don't know off hands (especially regarding 4.4). I would recommend you contact support@comsol.com . I am sure they know the answer.

Jeff

-------------------
Jeff Hiller
Sorry, John, but I don't have MATLAB to test this out and I don't know off hands (especially regarding 4.4). I would recommend you contact support@comsol.com . I am sure they know the answer. Jeff

Please login with a confirmed email address before reporting spam

Posted: 6 years ago Apr 26, 2018, 10:25 a.m. EDT

Thank you, Jeff, I appreciate the help!

Best regards,

John

Thank you, Jeff, I appreciate the help! Best regards, John

Gunnar Andersson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 years ago Apr 27, 2018, 2:33 a.m. EDT

If you have a plot, then you can retrieve the plot data using the API. I suggest that you try the following for a line graph containing one single line:

x = plot.getVertices(0, 0); y = plot.getData(0, 0, "Height");

I don't have access to MATLAB, but these API calls work in Java, and I don't see any reason why they wouldn't work from MATLAB.

If you have a plot, then you can retrieve the plot data using the API. I suggest that you try the following for a line graph containing one single line: x = plot.getVertices(0, 0); y = plot.getData(0, 0, "Height"); I don't have access to MATLAB, but these API calls work in Java, and I don't see any reason why they wouldn't work from MATLAB.

Please login with a confirmed email address before reporting spam

Posted: 6 years ago Apr 27, 2018, 12:06 p.m. EDT

Thank you, Gunnar.

Here's what I'm using to extract the temperature along a line selection (“boundaryline”) in the model at time 100.0 sec from dataset “dset1”. This is making COMSOL 4.4 API calls from MATLAB.

model.result().numerical().create('tempResult','Eval'); model.result().numerical('tempResult').set('expr','T'); model.result().numerical('tempResult').set('t','100.0'); model.result().numerical('tempResult').set('data','dset1'); model.result().numerical('tempResult').selection.named('boundaryline'); yvalue = model.result().numerical('tempResult').getData(); xvalue = model.result().numerical('tempResult').getCoordinates();

This seems to work, but I welcome feedback if something doesn't look right. Thanks!

John

Thank you, Gunnar. Here's what I'm using to extract the temperature along a line selection (“boundaryline”) in the model at time 100.0 sec from dataset “dset1”. This is making COMSOL 4.4 API calls from MATLAB. model.result().numerical().create('tempResult','Eval'); model.result().numerical('tempResult').set('expr','T'); model.result().numerical('tempResult').set('t','100.0'); model.result().numerical('tempResult').set('data','dset1'); model.result().numerical('tempResult').selection.named('boundaryline'); yvalue = model.result().numerical('tempResult').getData(); xvalue = model.result().numerical('tempResult').getCoordinates(); This seems to work, but I welcome feedback if something doesn't look right. Thanks! John

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.