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.

Reading simulation results through VBA code in excel

Please login with a confirmed email address before reporting spam

Hello,

I am trying to extract the results of a COMSOL optimization through VBA code in Excel with no luck. To my knowledge the simulation runs but i can't access the results. I am new both to VBA and Livelink but I expected the procedure to be straight forward which unfortunately it is not. I want to read the optimized parameter as well as a few other probe values that are in the component definitions and are evaluated in the study, back into Excel. The relevant VBA code is this:

'Get data from Excel cells
Iact = Sheets("Data_acc.geom").Range("B" & ActiveCell.Row).Value / 1000
Disp = Sheets("Data_acc.geom").Range("F" & ActiveCell.Row).Value / 1000000000

'Set data to COMSOL parameters and run the optimization study
Call model.param.set("Iact", Str(Iact))
Call model.param.set("Disp_target", Str(Disp))
Call modelutil.ShowProgress(True)
Call model.get_study("std7").Run

'Extract results <- problem here
Set res_CTE = model.result().numerical().Create("res_CTE", "Global")
Call res_CTE.set("expr", "CTE_3CSIC")
Call res_CTE.set("data", "dset1")
results_CTE=res_CTE.getData(0) <- this line doesnt work

CTE_3CSIC is the optimized parameter. I have looked up the LiveLink For Excel Users Guide as well as the COMSOL API reference but couldnt find the proper way to do this. Any help is greatly appreciated.

0 Replies Last Post May 4, 2015, 8:00 a.m. EDT
COMSOL Moderator

Hello Sotiris Thomas

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.

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.