Lars Gregersen
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
6 years ago
Jan 4, 2019, 4:21 a.m. EST
When Comsol calls your Matlab function it uses (long) vectors as arguments.
You should test that your functions work with vector arguments (of the same size) and that your function returns a vector of the same size as the input.
-------------------
Lars Gregersen
Comsol Denmark
When Comsol calls your Matlab function it uses (long) vectors as arguments.
You should test that your functions work with vector arguments (of the same size) and that your function returns a vector of the same size as the input.
Please login with a confirmed email address before reporting spam
Posted:
6 years ago
Jan 4, 2019, 2:59 p.m. EST
Thanks for the quick reply!
I understand what you're saying. I checked and made sure my function works given long vectors. In fact everything was working when I was using a 2D COMSOL model (attached), but since moving to a 3D model, I haven't gotten it to work.
I may be able to circumvent the problem by rewriting my code to avoid the use of logical operators, but I'd love to hear if you have any other, better ideas.
Thanks!
Tim
Thanks for the quick reply!
I understand what you're saying. I checked and made sure my function works given long vectors. In fact everything was working when I was using a 2D COMSOL model (attached), but since moving to a 3D model, I haven't gotten it to work.
I may be able to circumvent the problem by rewriting my code to avoid the use of logical operators, but I'd love to hear if you have any other, better ideas.
Thanks!
Tim
Please login with a confirmed email address before reporting spam
Posted:
6 years ago
Jan 4, 2019, 4:27 p.m. EST
It's working now!
I closed out of everything and opened it up to find things working. I don't know what all happened...I may have tried a bad boundary condition intially and COMSOL didn't register my correction until after I had saved and closed everything and opened it back up again.
Thanks for the help.
Tim
It's working now!
I closed out of everything and opened it up to find things working. I don't know what all happened...I may have tried a bad boundary condition intially and COMSOL didn't register my correction until after I had saved and closed everything and opened it back up again.
Thanks for the help.
Tim
Lars Gregersen
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
6 years ago
Jan 8, 2019, 4:43 a.m. EST
Note the "Clear Functions" button on the MATLAB node in the model. When clicking this button Matlab will reload the functions before using them. This picks up changed you have made to the files. Yes, Matlab should do this automatically, but sometimes it doesn't.
When working on your functions it may be beneficial to put a checkmark in "Clear functions automatically before solving" - unless your functions rely on not being reloaded too often; e.g. if they load a lot of data or perform very expensive calculations when initialising.
-------------------
Lars Gregersen
Comsol Denmark
Note the "Clear Functions" button on the MATLAB node in the model. When clicking this button Matlab will reload the functions before using them. This picks up changed you have made to the files. Yes, Matlab should do this automatically, but sometimes it doesn't.
When working on your functions it may be beneficial to put a checkmark in "Clear functions automatically before solving" - unless your functions rely on not being reloaded too often; e.g. if they load a lot of data or perform very expensive calculations when initialising.