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.
Comsol - Error in using a function to set the boundary condition dynamically in a program
Posted 23.07.2009, 05:33 GMT-4 Version 4.0 2 Replies
Please login with a confirmed email address before reporting spam
Hi,
I have encountered a problem in using self-written function to set the boundary condition of a heat conduction problem. The following is the part of generated code for setting the intial, boundary conditions and material properties:
...
str_qb = 'sin(t*x*y)';
bnd.g = {0,0.005,str_qb};
bnd.ind = [1,1,2,3,1,1];
appl.bnd = bnd;
clear equ
equ.init = 55;
equ.c = 0.0145;
equ.f = 0;
equ.da = 0.004108;
equ.ind = [1];
appl.equ = equ;
fem.appl{1} = appl;
fem.border = 1;
fem.units = 'SI';
...
Running the program, it works and I obtained the computation results!!!
However, after I commented "str_qb = 'sin(t*x*y)';" and replaced the code "bnd.g = {0,0.005,str_qb};" with "bnd.g = {0,0.005,'qb_fun(t,x,y)'};", where qb_fun(t,x,y) is a function defined by
--------------------------------
function VI = qb_fun(t,x,y)
VI = sin(t*x*y);
--------------------------------
, the program crashed after running. Error message is displayed as follows:
--------------------------
??? Java exception occurred:
Exception:
com.femlab.server.MlError: Error using ==> mtimes
Inner matrix dimensions must agree.
(rethrown as com.femlab.jni.FlNativeException)
Messages:
Error using ==> mtimes
Inner matrix dimensions must agree.
Error in callback
Stack trace:
at callback.cpp, row 113, ()
at com.femlab.solver.FlSolver.femTime(Native Method)
at com.femlab.solver.FemTime.run(SourceFile:69)
at com.femlab.server.FlRunner.run(SourceFile:120)
at com.femlab.server.MlProgressDlg.runAndWait(SourceFile:142)
at com.femlab.server.FlRunnable.runAndWait(SourceFile:69)
.
Error in ==> femsolver at 225
solobj.runAndWait(report, 'Solution Progress', loopTime);
Error in ==> femtime at 61
varargout = femsolver(mfilename,'FemTime',varargin{:});
Error in ==> fp_model at 85
fem.sol=femtime(fem, ...
-------------------------------
I am so confused with the result (I have only set the same boundary condition by means of different ways). I'd greatly appreciate it if some comsol expert can help me find the error. Thanks a lot.
Windson
I have encountered a problem in using self-written function to set the boundary condition of a heat conduction problem. The following is the part of generated code for setting the intial, boundary conditions and material properties:
...
str_qb = 'sin(t*x*y)';
bnd.g = {0,0.005,str_qb};
bnd.ind = [1,1,2,3,1,1];
appl.bnd = bnd;
clear equ
equ.init = 55;
equ.c = 0.0145;
equ.f = 0;
equ.da = 0.004108;
equ.ind = [1];
appl.equ = equ;
fem.appl{1} = appl;
fem.border = 1;
fem.units = 'SI';
...
Running the program, it works and I obtained the computation results!!!
However, after I commented "str_qb = 'sin(t*x*y)';" and replaced the code "bnd.g = {0,0.005,str_qb};" with "bnd.g = {0,0.005,'qb_fun(t,x,y)'};", where qb_fun(t,x,y) is a function defined by
--------------------------------
function VI = qb_fun(t,x,y)
VI = sin(t*x*y);
--------------------------------
, the program crashed after running. Error message is displayed as follows:
--------------------------
??? Java exception occurred:
Exception:
com.femlab.server.MlError: Error using ==> mtimes
Inner matrix dimensions must agree.
(rethrown as com.femlab.jni.FlNativeException)
Messages:
Error using ==> mtimes
Inner matrix dimensions must agree.
Error in callback
Stack trace:
at callback.cpp, row 113, ()
at com.femlab.solver.FlSolver.femTime(Native Method)
at com.femlab.solver.FemTime.run(SourceFile:69)
at com.femlab.server.FlRunner.run(SourceFile:120)
at com.femlab.server.MlProgressDlg.runAndWait(SourceFile:142)
at com.femlab.server.FlRunnable.runAndWait(SourceFile:69)
.
Error in ==> femsolver at 225
solobj.runAndWait(report, 'Solution Progress', loopTime);
Error in ==> femtime at 61
varargout = femsolver(mfilename,'FemTime',varargin{:});
Error in ==> fp_model at 85
fem.sol=femtime(fem, ...
-------------------------------
I am so confused with the result (I have only set the same boundary condition by means of different ways). I'd greatly appreciate it if some comsol expert can help me find the error. Thanks a lot.
Windson
2 Replies Last Post 30.07.2009, 07:01 GMT-4