 Hello everybody,

again, i would appreciate your kind help.
I would like to solve the adjoint equation of my following problem to get to the formoptimisation.

-\gamma\Delta\phi = 0 \text{ in } \Omega\\ \phi = 0 \text{ on } \Gamma_1\\ -\gamma \frac{\partial \phi}{\partial n} = 0 \text{ on } \Gamma_2 \text{ and } \Gamma_3\\ -\gamma \frac{\partial \phi}{\partial n} = -\frac{1}{|\Gamma_4}I_2(t) \text{ on } \Gamma_4

whereby $$\phi$$ is the potential, n is the outer normal and $$I_2(t)$$ is a current.
Defining V as

V:=\{v \in H^1|v=0 \text { on } \Gamma_1\}

and multiplying with the test function v and doing the integration yields for the weak formulation

\int_{\Omega} \gamma \nabla \phi \nabla v dx = \frac{1}{|\Gamma_4|}I_2(t)\int_{\Gamma_4} v(x) dx.

Now we are applying a little trick by saying v should be $$\phi$$ which yields now

\int_{\Omega} \gamma |\nabla \phi|^2 dx = \frac{1}{|\Gamma_4|}I_2(t)\int_{\Gamma_4} \phi(x) dx.

This would give an optimal control problem with the energy-functional like

\min_{\phi \in V} J(\phi) := \min_{\phi \in V}(\frac{1}{2}\int_{\Omega} \gamma |\nabla \phi |^2 dx - \frac{1}{|\Gamma_4|}I_2(t)\int_{\Gamma_4} \phi(x) dx)

under the constrains of the potential equation.
Ok. Now i approximate through the approach functions for the finite-dimensional problem like

\phi \approx \tilde{\phi} = \sum_i^{N} c_i(t) \phi_i(x)\\ \nabla\phi \approx \tilde{\nabla\phi} = \sum_i^{N} c_i(t) \nabla\phi_i(x).

and getting with $$\gamma$$ be a constant

\gamma[\sum_{i = 1}^{N} c_i(t) \int_\Omega \nabla \phi \nabla \phi_i dx] = \frac{1}{|\Gamma_4|}I_2(t)[\sum_{i = 1}^{N}c_i(t)\int_{\Gamma_4}\phi_i(x)dx]

where one can see the stiffness matrix.

I believe now my problem starts and i am really sorry if i am asking now stupid questions.
In matrix form it would be (maybe)

\gamma K c = g

and for the adjoint equation i would invert and transpose the stiffness matrix K. But then i only have stupid stuff on my LHS, or? Can someone tell me what i am doing wrong, please?

In case someone has the same problem. Just don’t take $$\gamma$$ as a constant and then you get for the stiffness matrix

\int_{\Omega} \nabla \phi \gamma(\cdot) \nabla \phi_i dx.

This is for me better and solved the problem.