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.

Livelink with matlab, exporting custom expression

Please login with a confirmed email address before reporting spam

Hi,

I'm using livelink with Matlab to create a simulator of dielectrophoresis force. I need to export an expression like this one: d(es.normE*es.normE,x). How can i do this?
I succeed in exporting es.normE thanks to mpheval() but i got a syntax error when using the aforementioned expression.

Thanks for your helps
Vladimir

5 Replies Last Post May 19, 2017, 4:11 a.m. EDT
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Apr 28, 2017, 11:34 a.m. EDT
Hi Vladimir

It works for me.

What version of Comsol are you using?

What is the exact error message?


--
Lars Gregersen
Comsol Denmark
Hi Vladimir It works for me. What version of Comsol are you using? What is the exact error message? -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Apr 29, 2017, 9:27 a.m. EDT
Updated: 8 years ago Apr 29, 2017, 9:27 a.m. EDT
Hi Lars,

I'm using COMSOL 5.2 (version: 220).

Here is the code:
pd=mpheval(model,'d(es.normE*es.normE,x) d(es.normE*es.normE,y)','selection','pointi');

Here is the message:
Error using mpheval (line 328)
mpheval (174): Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: Syntax error in expression
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Syntax error in expression

Syntax error in expression

Erreur de syntaxe dans une expression.
- Expression: d(es.normE*es.normE,x) d(es.normE*es.normE,y)
- Sous-expression: d(es.normE*
- Position: 2

Vladimir
Hi Lars, I'm using COMSOL 5.2 (version: 220). Here is the code: pd=mpheval(model,'d(es.normE*es.normE,x) d(es.normE*es.normE,y)','selection','pointi'); Here is the message: Error using mpheval (line 328) mpheval (174): Java exception occurred: Exception: com.comsol.util.exceptions.FlException: Syntax error in expression (rethrown as com.comsol.util.exceptions.FlException) (rethrown as com.comsol.util.exceptions.FlException) Messages: Syntax error in expression Syntax error in expression Erreur de syntaxe dans une expression. - Expression: d(es.normE*es.normE,x) d(es.normE*es.normE,y) - Sous-expression: d(es.normE* - Position: 2 Vladimir

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 2, 2017, 3:15 a.m. EDT
Hi

You are doing it wrong ;-)

If you wish to evaluate more than one expression you should put them in a cell array:

pd=mpheval(model, {'d(es.normE*es.normE,x)' 'd(es.normE*es.normE,y)'}, 'selection', 'pointi');


--
Lars Gregersen
Comsol Denmark
Hi You are doing it wrong ;-) If you wish to evaluate more than one expression you should put them in a cell array: pd=mpheval(model, {'d(es.normE*es.normE,x)' 'd(es.normE*es.normE,y)'}, 'selection', 'pointi'); -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 2, 2017, 5:15 a.m. EDT
Hi,

Ok, i'm confused because this command works well:
pd=mpheval(model,'V es.normE es.Ex es.Ey','selection','pointi');

I have another question. When i evaluate with pointi defined as follow:
model.selection.create('pointi','Ball');
model.selection('pointi').set('posx','L/2');
model.selection('pointi').set('r','8');
model.selection('pointi').set('entitydim',0);
model.selection('pointi').set('condition','inside');
this select only, if any, the geometrical point inside the Ball.

If i want to create a selection on all the mesh node inside pointi, should i create firstly a geometrical domain according to pointi ?
Hi, Ok, i'm confused because this command works well: pd=mpheval(model,'V es.normE es.Ex es.Ey','selection','pointi'); I have another question. When i evaluate with pointi defined as follow: model.selection.create('pointi','Ball'); model.selection('pointi').set('posx','L/2'); model.selection('pointi').set('r','8'); model.selection('pointi').set('entitydim',0); model.selection('pointi').set('condition','inside'); this select only, if any, the geometrical point inside the Ball. If i want to create a selection on all the mesh node inside pointi, should i create firstly a geometrical domain according to pointi ?

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 19, 2017, 4:11 a.m. EDT
Hi Vladimir


Ok, i'm confused because this command works well:
pd=mpheval(model,'V es.normE es.Ex es.Ey','selection','pointi');


Yes, this is a feature, but this feature only works with simple expressions and not when you are using functions with multiple parameters.


Selections work on the geometry level. Why do you need a selection of the interior mesh points?

--
Lars Gregersen
Comsol Denmark
Hi Vladimir [QUOTE] Ok, i'm confused because this command works well: pd=mpheval(model,'V es.normE es.Ex es.Ey','selection','pointi'); [/QUOTE] Yes, this is a feature, but this feature only works with simple expressions and not when you are using functions with multiple parameters. Selections work on the geometry level. Why do you need a selection of the interior mesh points? -- Lars Gregersen Comsol Denmark

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.