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.

How to calculate total current with Matlab livelink?

Please login with a confirmed email address before reporting spam

I built a cylinder conductor (axial symmetry), bottom surface is grounded, top surface is connected to a voltage source, i want to calculate the total current passing through the conductor in Matlab.

From mphdoc,i found using code like: "[I, unit] = mphint2(model, 'ec.normJ', 'surface', 'selection', 6)" to evaluate the total currrent passing through selected boundary, but it make errors when run script.

Error using mphint2 mphnumerical (0): Java exception occurred: Exception: com.comsol.util.exceptions.FlException: java.lang.IllegalArgumentException: Illegal input vector illegal entity number Messages: java.lang.IllegalArgumentException: Illegal input vector illegal entity number Error in inttest (line 5) I = mphint2(model, 'ec.normJ','surface','selection',6);

I don't know how to fix it, please help me ......

P.S the simulation works well in COMSOL, and the current density is reasonable, but it goes wrong in livelink with matlab when using "I = mphint2(model, 'ec.normJ','surface','selection',6)"



1 Reply Last Post 20.07.2018, 22:34 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 20.07.2018, 22:34 GMT-4

The problem has already been solved. One day later, i found it should use line integration to calculate current, but there still a problem: the current that calculated by COMSOL (reasonable) is not consistent with which calculated by matlab.

after looking up in mphdoc, i found when using axial symmetry model, the Matlab script should be wrote as "[I,unit] = mphint2(model, 'ec.normJ','line','selection',6, 'intsurface','on');"

i hope this may provide some help for latecomers

The problem has already been solved. One day later, i found it should use line integration to calculate current, but there still a problem: the current that calculated by COMSOL (reasonable) is not consistent with which calculated by matlab. after looking up in mphdoc, i found when using axial symmetry model, the Matlab script should be wrote as "[I,unit] = mphint2(model, 'ec.normJ','line','selection',6, 'intsurface','on');" i hope this may provide some help for latecomers

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.