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.

COMSOL with matlab cannot use "model.sol('sol1').run; "

Please login with a confirmed email address before reporting spam

DERA All, I use COMSOL with matlab to run my model with a for-loop (change some parameters every time) . About three month ago, I can use "model.sol('sol1').run; " to run my model. However, today, it is useless, and, the problem described by Matlab is bellow:

错误使用 test_para (line 25)
Java exception occurred:
Exception:
    com.comsol.util.exceptions.FlException: No current feature assigned
Messages:
    No current feature assigned
Stack trace:
    at com.comsol.model.dbmodel.SolverSequenceDb.current(SourceFile:196)
    at com.comsol.model.method.SolverSequenceMethod.doRun(SourceFile:2711)
    at com.comsol.model.dbmodel.SolverSequenceDb.run(SourceFile:186)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.comsol.bridge.command.b.a(SourceFile:145)
    at com.comsol.bridge.command.b.run(SourceFile:90)
    at com.comsol.bridge.command.i.execute(SourceFile:45)
    at com.comsol.bridge.command.j.d(SourceFile:711)
    at com.comsol.bridge.command.j.a(SourceFile:699)
    at com.comsol.bridge.command.j$3.a(SourceFile:600)
    at com.comsol.bridge.command.j$3.call(SourceFile:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

And here is my code:

import com.comsol.model.*
import com.comsol.model.util.*
fp = fopen('run_log.txt','a+');
for x1 = 0.8 : 0.05 : 0.9
    for x2 = 1 : 0.5 : 2     
        for x3 = 0.1 : 0.5 : 2.1
            disp(strcat('f = ',num2str(x1)));
            fprintf(fp, '%s\n',strcat('f = ',num2str(x1)));
            disp(strcat('ra = ',num2str(x2)));
            fprintf(fp, '%s\n',strcat('ra = ',num2str(x2)));
            disp(strcat('ha = ',num2str(x3)));
            fprintf(fp, '%s\n',strcat('ha = ',num2str(x3)));
            disp(datetime)
            fprintf(fp, '%s\n',datetime);            
            model = mphload("curve_threePointMem.mph");
            model.param.set('f',num2str(x1));
            model.param.set('ra',num2str(x2));
            model.param.set('ha',num2str(x3));         
            model.sol('sol1').run;
            coefficient = mphglobal(model,'Alpha');
            total = 0;
            for i = 1 : 59
                total = total + (coefficient(i) + coefficient(i + 1));
            end
            z = -(0.5 * total) / 59;
            disp(strcat('Average Absorption Coefficient= ',num2str(-z)));
            fprintf(fp, '%s\n',strcat('Average Absorption Coefficient= ',num2str(-z)));
            disp("-----------------------------");
            fprintf(fp, '%s\n',"-----------------------------");
        end
    end
end
fclose(fp);

my version is COMSOL Multiphysics 5.4.0.388


2 Replies Last Post Mar 16, 2020, 10:48 p.m. EDT
Sinéad Mannion Plasma Physics

Please login with a confirmed email address before reporting spam

Posted: 5 years ago Mar 16, 2020, 12:05 p.m. EDT
Updated: 5 years ago Mar 16, 2020, 12:06 p.m. EDT

Hiya,

Try model.study('std1').run

Hope this helps

Sinéad

Hiya, Try model.study('std1').run Hope this helps Sinéad

Please login with a confirmed email address before reporting spam

Posted: 5 years ago Mar 16, 2020, 10:48 p.m. EDT

Dear Sinéad Mannion, It seems useful to use model.study('std1').run, but are their functions the same? And do you know why the problem occur? I was confused because three month ago it is useful. Thank you very much!

Dear Sinéad Mannion, It seems useful to use model.study('std1').run, but are their functions the same? And do you know why the problem occur? I was confused because three month ago it is useful. Thank you very much!

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.