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.

vector dot product

Please login with a confirmed email address before reporting spam

Hi,

I was wondering if we could evaluate vector dot products between vector fields? If yes, it would really help a lot in enhancing the way we can use field overlap integrals, among others, in postprocessing.

I am presently using 3.5a but if it is possible only in 4.0 then it might speed up my transition to 4.0.


7 Replies Last Post Jun 13, 2012, 2:41 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 21, 2010, 7:48 a.m. EDT
Hi,

you can enter any equation in the postprocessing. So if you have a vector field A=(Ax, Ay, Az) and a vector field B=(Bx, By, Bz) just enter the expression AxBx+AyBy+AzBz. You can also define an expression like dotproduct=AxBx+AyBy+AzBz and use it in postprocessing or anywhere else.

You are not restricted to the suggestions COMSOL gives you. You can use any variable, internal ones and the expressions you define yourself.

Regards
Edgar
Hi, you can enter any equation in the postprocessing. So if you have a vector field A=(Ax, Ay, Az) and a vector field B=(Bx, By, Bz) just enter the expression AxBx+AyBy+AzBz. You can also define an expression like dotproduct=AxBx+AyBy+AzBz and use it in postprocessing or anywhere else. You are not restricted to the suggestions COMSOL gives you. You can use any variable, internal ones and the expressions you define yourself. Regards Edgar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 21, 2010, 8:02 a.m. EDT
Thank you for your response Edgar. I wonder how I missed out on that? :)
Thank you for your response Edgar. I wonder how I missed out on that? :)

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: 1 decade ago Jun 21, 2010, 12:51 p.m. EDT
Hi

there are still some subtilities for complex values, check the "realdot()" operator, usefull among other for EM/RF fields, but also in other cases

Have fun Comsoling
Ivar
Hi there are still some subtilities for complex values, check the "realdot()" operator, usefull among other for EM/RF fields, but also in other cases Have fun Comsoling Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 23, 2010, 10:43 a.m. EDT
Thanks Ivar for suggestion. Seems useful, like always :)
Thanks Ivar for suggestion. Seems useful, like always :)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 31, 2011, 2:48 p.m. EDT

check the "realdot()" operator


the relevant section from 4.0a,

The Realdot Operator
• The expression realdot(a,b) treats complex numbers a and b as if they were real-valued vectors of length 2 and returns their dot product. You can also think of the operator call as a shorthand form of real(a*conj(b)). This expression, however, is not an analytical function of its complex arguments and therefore has no unique partial derivatives with respect to a and b.

• The difference between realdot(a,b) and real(a*conj(b)) is that the partial derivatives of the former with respect to a and b are defined as conj(b) and conj(a), respectively, while for the latter expression, the partial derivatives are real(conj(a)) and real(a).

• The difference between the partial derivative definitions is important during sensitivity analysis of frequency-response problems (scalar or vector Helmholtz equations).

• Common objective function quantities like power and energy must be redefined in terms of realdot(a,b) rather than real(a*conj(b)) for the sensitivity solver to compute correct derivatives. This applies also to the absolute value, abs(a), via the definition |a|^2 = realdot(a,a).
[QUOTE] check the "realdot()" operator [/QUOTE] the relevant section from 4.0a, The Realdot Operator • The expression realdot(a,b) treats complex numbers a and b as if they were real-valued vectors of length 2 and returns their dot product. You can also think of the operator call as a shorthand form of real(a*conj(b)). This expression, however, is not an analytical function of its complex arguments and therefore has no unique partial derivatives with respect to a and b. • The difference between realdot(a,b) and real(a*conj(b)) is that the partial derivatives of the former with respect to a and b are defined as conj(b) and conj(a), respectively, while for the latter expression, the partial derivatives are real(conj(a)) and real(a). • The difference between the partial derivative definitions is important during sensitivity analysis of frequency-response problems (scalar or vector Helmholtz equations). • Common objective function quantities like power and energy must be redefined in terms of realdot(a,b) rather than real(a*conj(b)) for the sensitivity solver to compute correct derivatives. This applies also to the absolute value, abs(a), via the definition |a|^2 = realdot(a,a).

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 12, 2012, 6:23 p.m. EDT
What if I have a parametric solution, and I want to calulate the dot product of the complex E, from two solutions?

Is the following expression right?


real= real ( with(1,Ex)*conj(with(2,Ex)) + with(1,Ey)*conj(with(2,Ey)) + with(1,Ez)*conj(with(2,Ez)) );
imaginary= imag ( with(1,Ex)*conj(with(2,Ex)) + with(1,Ey)*conj(with(2,Ey)) + with(1,Ez)*conj(with(2,Ez)) );
What if I have a parametric solution, and I want to calulate the dot product of the complex E, from two solutions? Is the following expression right? real= real ( with(1,Ex)*conj(with(2,Ex)) + with(1,Ey)*conj(with(2,Ey)) + with(1,Ez)*conj(with(2,Ez)) ); imaginary= imag ( with(1,Ex)*conj(with(2,Ex)) + with(1,Ey)*conj(with(2,Ey)) + with(1,Ez)*conj(with(2,Ez)) );

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: 1 decade ago Jun 13, 2012, 2:41 a.m. EDT
Hi

I believe so, or you could use the realdot() operator, but I do not believe your equation writing will be simpler

It is a pitty we cannot write out the vector product in a more compressed way

--
Good luck
Ivar
Hi I believe so, or you could use the realdot() operator, but I do not believe your equation writing will be simpler It is a pitty we cannot write out the vector product in a more compressed way -- Good luck Ivar

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.