Complex solver despite real input

Hello,

I am dealing with Maxwell equations and want to have a vector-valued electical field whose components are complex values [Ex,Ey,Ez]. The imaginary part of each of the three components corresponds to the phase phi, which is equal for all three components of the vector [Ex+1i*phi, Ey+1i*phi, Ez+1i*phi]. This allows to formulate the problem depending on four real inputs Ex,Ey,Ez,phi but requires a complex solver due to appearing imaginary i’s within the integrals. They appear due to the product rule as (dx(Ex)+1i*Ex*dx(phi))*exp(1i*phi). Is it possible to define a complex solver without complex inputs and correspondingly non-complex fespace? And how do I have to deal with the separation of Ex*dx(phi), since from my understanding Ex and dx(phi) are not allowed as product in a single integral?

Thanks in advance!

I think you can just define the two groups of FE spaces, once corresponding to real parts, and the other to imaginary ones, and work out the complex operations by hand, i.e., exp(1iphi)=cos(phi) + 1isin(phi).

Thanks for the reply. I’m not sure how to incorporate this, since the problem is formulated on the mesh object, hence a differentiation of the fespaces is solely via the components of the unknown and test function possible. Is this sufficient for including inmaginary i in the problem definition despite the real inputs?
Defining two separate real problems with real and imaginary components is possible, unfortunately, the angle phi would still be required in the imaginary part, though being real in reality. Thus I would get the components [Exreal+i*Eximaginary, Eyreal+i*Eyimaginary, Ezreal+i*Ezimaginary] from the two individual real-valued problems problemreal([Exreal,Eyreal,Ezreal,phireal],[vxreal,vyreal,vzreal,psireal])=..., and problemimaginary([Eximaginary,Eyimaginary,Ezimaginary,phireal],[vximaginary,vyimaginary,vzimaginary,psireal])=... but in analogy to the E-components I can not derive the angle phi.

I am not sure I understand the problem. With the finite element method, you can describe linear operations thus create their discrete version, matrices. The phase appears nonlinearly in the problem. It is hard to understand the problem only by the arguments of the variational form.

I described my problem in this post
already and it appeared to be too difficult or off-topic for most, so I didnt get a reply. Thus, I reduced my question and formulated it more generally. In the betweentime i tried to approach my problem differently and do not want to use the unknown and test function as complex since the real valued components are of interest and the imaginary argument is equal for all spatial components.

I am still unsure I understand the problem. I think you should define everything as complex variables. I you have to set some term to be real, specify the real part, and set the imaginary part of that complex variable to zero. I think if your math is correct, you will get the result you want, i.e., the real part will be nonzero, and the imaginary part will differ from zero only up to rounding precision (ofc, if discretization/solver are set properly).