You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two question regarding simple algebra with GridFunction and Vector
I am solving a nonlinear schrodinger equation, and trying to compute the norm of the wavefunction for further computation.
I split the wave function into real and imag component as GridFunction R,I
To calculate norm R*R+I*I, I understand that GridFunction can do *= and +=,
but a series of algebraic operation, such as R*R+I*I does not seem to work.
Currently, Im using a stupid way norm = I; norm *= I norm2 += R norm2 *= R norm += norm2
I wonder is there a smarter way to compute norm.
My problem requires using exponential-type time integrator to solve the schrodinger equation,
where the exponential operator is something like exp(i * phi). Since MFEM does not handle complex value directly,
I need to split the exponential operator into cos and sine form.
My question is then, how could we perform sine or cosine calculation on GridFunction and Vector?
Sorry for the long questions, but I hope my explanation of my concern is clear.
Thanks in advance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I have two question regarding simple algebra with
GridFunction
andVector
I am solving a nonlinear schrodinger equation, and trying to compute the norm of the wavefunction for further computation.
I split the wave function into real and imag component as
GridFunction R,I
To calculate norm
R*R+I*I
, I understand thatGridFunction
can do*=
and+=
,but a series of algebraic operation, such as
R*R+I*I
does not seem to work.Currently, Im using a stupid way
norm = I;
norm *= I
norm2 += R
norm2 *= R
norm += norm2
I wonder is there a smarter way to compute norm.
My problem requires using exponential-type time integrator to solve the schrodinger equation,
where the exponential operator is something like
exp(i * phi)
. Since MFEM does not handle complex value directly,I need to split the exponential operator into cos and sine form.
My question is then, how could we perform sine or cosine calculation on
GridFunction
andVector
?Sorry for the long questions, but I hope my explanation of my concern is clear.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions