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.

Is there a variable Ex in Electromagnetic Waves module?

Please login with a confirmed email address before reporting spam

Dear all,

By the question in the title, I mean a variable named exactly as Ex, without emw. prefix. Is it an internal variable?

I input such a variable by mistake in a model. COMSOL didn't report an error, but the results were totally wrong. After changing to emw.Ex, the results make much more sense.

Thanks!
--
Pu, ZHANG
DTU Fotonik

7 Replies Last Post Jul 22, 2015, 11:01 p.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 17, 2015, 1:34 p.m. EDT
Turning on equations view in the options allows you to see all sorts of pre defined stuff if you are interested.
Turning on equations view in the options allows you to see all sorts of pre defined stuff if you are interested.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 17, 2015, 8:21 p.m. EDT

Turning on equations view in the options allows you to see all sorts of pre defined stuff if you are interested.


Thanks, Chris!

I did that. However there the variables all have prefix emw. No Ex exists in the list. I'm afraid this one is a so-called internal variable.


--
Pu, ZHANG
DTU Fotonik
[QUOTE] Turning on equations view in the options allows you to see all sorts of pre defined stuff if you are interested. [/QUOTE] Thanks, Chris! I did that. However there the variables all have prefix emw. No Ex exists in the list. I'm afraid this one is a so-called internal variable. -- Pu, ZHANG DTU Fotonik

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 19, 2015, 4:49 a.m. EDT
Hi


indeed it's slightly tricky to avoid using existing variables in COMSOL, as COMSOL allows you to redefine many of them, therefore does not formally report any "error" since its allowed, but COMSOL assumes you know what you are doing.

Ex is the x component of E (not the gradient along x) of E.

Ex is the variable name, and is valid alone within the specified physics, the full name is root.comp1.emw.Ex (in V5.1 and for EMW Physics in Component 1)

But as its the dependent variable of EMW it's mostly used as Ex, so you should NOT use that name for any of your own variables.

My way to check if y name is already used is to define a dummy variable assigned to name of my variable and see if COMSOL proposes units for the name, then there is almost 100% chances that COMSOL has already defined a variable with that name

--
Good luck
Ivar
Hi indeed it's slightly tricky to avoid using existing variables in COMSOL, as COMSOL allows you to redefine many of them, therefore does not formally report any "error" since its allowed, but COMSOL assumes you know what you are doing. Ex is the x component of E (not the gradient along x) of E. Ex is the variable name, and is valid alone within the specified physics, the full name is root.comp1.emw.Ex (in V5.1 and for EMW Physics in Component 1) But as its the dependent variable of EMW it's mostly used as Ex, so you should NOT use that name for any of your own variables. My way to check if y name is already used is to define a dummy variable assigned to name of my variable and see if COMSOL proposes units for the name, then there is almost 100% chances that COMSOL has already defined a variable with that name -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 19, 2015, 5:09 a.m. EDT
Dear Ivar,

Thanks for the reply!

The trick to check out a variable would be useful!

There's a last question. I thought Ex would be equivalent to emw.Ex. Actually it turns out there is difference. In my model, I'd like to use the x component of the electric field. When I used Ex, something's wrong and the results didn't make any sense. After I changed it explicitly to emw.Ex, (this is also the only thing I changed), I obtain the correct results.

Does anyone have a clue? Or maybe I should mention I'm using it in a PDE module coupled with EMW module.

Thanks again!

Hi


indeed it's slightly tricky to avoid using existing variables in COMSOL, as COMSOL allows you to redefine many of them, therefore does not formally report any "error" since its allowed, but COMSOL assumes you know what you are doing.

Ex is the x component of E (not the gradient along x) of E.

Ex is the variable name, and is valid alone within the specified physics, the full name is root.comp1.emw.Ex (in V5.1 and for EMW Physics in Component 1)

But as its the dependent variable of EMW it's mostly used as Ex, so you should NOT use that name for any of your own variables.

My way to check if y name is already used is to define a dummy variable assigned to name of my variable and see if COMSOL proposes units for the name, then there is almost 100% chances that COMSOL has already defined a variable with that name

--
Good luck
Ivar





--
Pu, ZHANG
DTU Fotonik
Dear Ivar, Thanks for the reply! The trick to check out a variable would be useful! There's a last question. I thought Ex would be equivalent to emw.Ex. Actually it turns out there is difference. In my model, I'd like to use the x component of the electric field. When I used Ex, something's wrong and the results didn't make any sense. After I changed it explicitly to emw.Ex, (this is also the only thing I changed), I obtain the correct results. Does anyone have a clue? Or maybe I should mention I'm using it in a PDE module coupled with EMW module. Thanks again! [QUOTE] Hi indeed it's slightly tricky to avoid using existing variables in COMSOL, as COMSOL allows you to redefine many of them, therefore does not formally report any "error" since its allowed, but COMSOL assumes you know what you are doing. Ex is the x component of E (not the gradient along x) of E. Ex is the variable name, and is valid alone within the specified physics, the full name is root.comp1.emw.Ex (in V5.1 and for EMW Physics in Component 1) But as its the dependent variable of EMW it's mostly used as Ex, so you should NOT use that name for any of your own variables. My way to check if y name is already used is to define a dummy variable assigned to name of my variable and see if COMSOL proposes units for the name, then there is almost 100% chances that COMSOL has already defined a variable with that name -- Good luck Ivar [/QUOTE] -- Pu, ZHANG DTU Fotonik

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 20, 2015, 1:57 a.m. EDT
Hi

I'm not sure why there should be any differences, the naming convention in COMSOL is rather standard within structured programming:
"Ex" is fully defined as "root.comp1.emw.Ex", but within the node and sub nodes of EMW Physics "Ex" is sufficient, particularly because its a dependent variable
But it you have another physics or another component (model) then you need the full names to allow COMSOL to find the correct path up and down the model set-up structural tree

A do also find COMSOL slightly inconsistent, as Ex could be though of as the "x" component of E, as well as the "x" derivative dE/dx, depending on which internal COMSOL convention you refer too, this is ambiguous, and can only be resolve if you understand the context, it's neither not fully coherent between all physics.
But I notice regularly that the naming of the internal variables evolve with the releases. so I believe COMSOL is consolidating this among all physics, it's only that it takes time, everything cannot be implemented in one go, as one need to check and validate all changes.

--
Good luck
Ivar
Hi I'm not sure why there should be any differences, the naming convention in COMSOL is rather standard within structured programming: "Ex" is fully defined as "root.comp1.emw.Ex", but within the node and sub nodes of EMW Physics "Ex" is sufficient, particularly because its a dependent variable But it you have another physics or another component (model) then you need the full names to allow COMSOL to find the correct path up and down the model set-up structural tree A do also find COMSOL slightly inconsistent, as Ex could be though of as the "x" component of E, as well as the "x" derivative dE/dx, depending on which internal COMSOL convention you refer too, this is ambiguous, and can only be resolve if you understand the context, it's neither not fully coherent between all physics. But I notice regularly that the naming of the internal variables evolve with the releases. so I believe COMSOL is consolidating this among all physics, it's only that it takes time, everything cannot be implemented in one go, as one need to check and validate all changes. -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 20, 2015, 2:20 a.m. EDT
Thanks for the explanation!

I guess using the full name should be error free.


Hi

I'm not sure why there should be any differences, the naming convention in COMSOL is rather standard within structured programming:
"Ex" is fully defined as "root.comp1.emw.Ex", but within the node and sub nodes of EMW Physics "Ex" is sufficient, particularly because its a dependent variable
But it you have another physics or another component (model) then you need the full names to allow COMSOL to find the correct path up and down the model set-up structural tree

A do also find COMSOL slightly inconsistent, as Ex could be though of as the "x" component of E, as well as the "x" derivative dE/dx, depending on which internal COMSOL convention you refer too, this is ambiguous, and can only be resolve if you understand the context, it's neither not fully coherent between all physics.
But I notice regularly that the naming of the internal variables evolve with the releases. so I believe COMSOL is consolidating this among all physics, it's only that it takes time, everything cannot be implemented in one go, as one need to check and validate all changes.

--
Good luck
Ivar





--
Pu, ZHANG
DTU Fotonik
Thanks for the explanation! I guess using the full name should be error free. [QUOTE] Hi I'm not sure why there should be any differences, the naming convention in COMSOL is rather standard within structured programming: "Ex" is fully defined as "root.comp1.emw.Ex", but within the node and sub nodes of EMW Physics "Ex" is sufficient, particularly because its a dependent variable But it you have another physics or another component (model) then you need the full names to allow COMSOL to find the correct path up and down the model set-up structural tree A do also find COMSOL slightly inconsistent, as Ex could be though of as the "x" component of E, as well as the "x" derivative dE/dx, depending on which internal COMSOL convention you refer too, this is ambiguous, and can only be resolve if you understand the context, it's neither not fully coherent between all physics. But I notice regularly that the naming of the internal variables evolve with the releases. so I believe COMSOL is consolidating this among all physics, it's only that it takes time, everything cannot be implemented in one go, as one need to check and validate all changes. -- Good luck Ivar [/QUOTE] -- Pu, ZHANG DTU Fotonik

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 22, 2015, 11:01 p.m. EDT
I think I find what I did wrongly.

In COMSOL 5 (I didn't notice such thing in earlier versions), Ex is by default an independent variable in Electromagnetic Waves module regardless of you using full-field or scattered-field formulation. For my case, I'm using scattered-field formulation, then actually one can see emw.relEx is assigned as Ex. This is kinda misleading with the name of Ex... I was assuming Ex to be emw.Ex, which is the total field.

Hope this point helps others avoid similar mistakes.
--
Pu, ZHANG
DTU Fotonik
I think I find what I did wrongly. In COMSOL 5 (I didn't notice such thing in earlier versions), Ex is by default an independent variable in Electromagnetic Waves module regardless of you using full-field or scattered-field formulation. For my case, I'm using scattered-field formulation, then actually one can see emw.relEx is assigned as Ex. This is kinda misleading with the name of Ex... I was assuming Ex to be emw.Ex, which is the total field. Hope this point helps others avoid similar mistakes. -- Pu, ZHANG DTU Fotonik

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.