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.
expression
Posted 20 juil. 2010, 04:15 UTC−4 6 Replies
Please login with a confirmed email address before reporting spam
I am doing an electrostatic simulation and I would like to plot the intensity of the electric field ||E|| (surface), as well as the Gradient of this intensity squared (arrows or streamlines).
Is there a way to defined such a quantity globally (like in "derived values" / "global evaluation") such that it is then available for selection in the "add expression" / "replace expression" button-menus in the Expression secion of the Surface-, Arrow- etc. nodes in a plot group?
Please login with a confirmed email address before reporting spam
what about defining a variable (global variable in 3.5a) and use this ?
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
What is puzzling me is I have seen on some forum discussions, that other people who are plotting field intensity are discussing about a predefined expression "normE". I have displacement intensity "normD" in my expression list but NOT normE! Is that not strange?
Please login with a confirmed email address before reporting spam
Regarding es.normE: It was missing as a predefined variable in 4.0 but is available in 4.0a. You should have received an upgrade to 4.0a or should get one anyday now.
In 4.0, you can define it yourself as a variable using the same expression as in 4.0a:
sqrt(realdot(es.Ex,es.Ex)+realdot(es.Ey,es.Ey)+realdot(es.Ez,es.Ez))
The variable becomes available for plotting and evaluation after re-computing or updating the solution.
You find the variable in the list of predefined expressions but under Definitions (not Electrostatics). If you provide a description, COMSOL uses that and it appears among the other expressions in alphabetical order; otherwise the variable name appears within parentheses.
For plots that take vector inputs you must use the defined variables directly in the edit fields for the vector components. There is no support for grouping user-defined variables and declare them as components of a vector quantity.
Best regards,
Magnus Ringh
COMSOL
Please login with a confirmed email address before reporting spam
Excellent, this is exactly what I was looking for. But there is still a problem. If I use the variable (dubbed normE) as a plot expression I get an error "failed to evaluate variable" a screenshot of the error message dialog is attached. If I replace "normE" by "sqrt(realdot(es.Ex,es.Ex)+realdot(es.Ey,es.Ey)+realdot(es.Ez,es.Ez))" in the expression field the plot works without error.
Another thing is maybe unimportant but still... if I define an expression in a plot then comsol automatically computes the corresponding unity (V/m etc.). But when I define a Variable under "global definitions" it doesn't. Is this a hint that it doesn't recognize the names (es.Ez etc.) used in defining the variable?
Too bad that comsol does not allow the grouping of user-defined vector component variables. This would be a fine feature to add.
Attachments:
Please login with a confirmed email address before reporting spam
Regarding the error, my guess is that you have defined the variable as a global variable under Global Definitions instead of a local (to the active model) variable under, for example, Model 1>Definitions. It is possible, but then you need the syntax mod1.es.Ex etc. to access these quantities.
Regarding grouping of vector components: That is something that we will look into. In the current version, you can press Ctrl+Space in the edit fields for each vector component to access user-defined variables. At least it saves some typing.
Best regards,
Magnus Ringh
COMSOL
Please login with a confirmed email address before reporting spam
Thank you Magnus!! If I had only known this before, it would have saved me countless hors.
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.
Suggested Content
- KNOWLEDGE BASE Failed to Evaluate Variable
- FORUM Expression
- BLOG Using the Expression Operator in COMSOL Multiphysics®
- KNOWLEDGE BASE Initial guess leads to undefined function value
- FORUM mathematical expression
