Variational formulation using Lagrange multiplier

I tried to understand the implementation of lagrange multipler through

I don’t understand how the variational form takes c and d terms in bilinear form. Can you give some explanation of how you formed this equation. This seems to be different from general lagrange multiplier applications.

My major purpose is to solve the periodic homogenization problem using Lagrange multiplier.

If you’re familiar with Lagrange multipliers in the context of constrained minimization, the easiest way to derive the variational form from the linked example is by starting with the following energy functional for the Poisson equation with Neumann boundary conditions:

\mathcal{J}(u) = \frac{1}{2}\int_\Omega\vert\nabla u\vert^2\,d\Omega - \int_\Omega fu\,d\Omega - \int_{\Gamma_N}gu\,d\partial\Omega\text{ .}

If the Neumann boundary part \Gamma_N were only part of \partial\Omega, and there were another part where u was constrained to be zero, then the Poisson problem could be solved uniquely by minimizing this energy functional. However, when \Gamma_N = \partial\Omega, the solution is only defined up to a constant; under the compatibility condition

\int_\Omega f\,d\Omega = -\int_{\partial\Omega}g\,d\partial\Omega\text{ ,}

we can add a constant to u without changing \mathcal{J}(u). Thus, we want to add the constraint

\int_\Omega u\,d\Omega = 0\text{ ,}

to pin down this free constant. To do this using the method of Lagrange multipliers, you would seek a stationary point of the Lagrangian

\mathcal{L}(u,\lambda) = \mathcal{J}(u) + \lambda\int_\Omega u\,d\Omega\text{ .}

Taking a variation (i.e., the Gateaux derivative in the direction of an arbitrary function/multiplier pair (\delta u,\delta\lambda)) and setting it to zero, we get

\delta\mathcal{L}(u,\lambda) = \int_\Omega\nabla u\cdot\nabla\delta u\,d\Omega - \int_\Omega f\delta u\,d\Omega - \int_{\Gamma_N}g\delta u\,d\partial\Omega + \delta\lambda\int_\Omega u\,d\Omega + \lambda\int_\Omega\delta u\,d\Omega = 0\text{ .}

If \lambda and \delta\lambda are in \mathbb{R}, we can pull them inside the integrals over \Omega. Renaming \delta u\to v, \lambda\to c, and \delta\lambda \to d, we recover the formulation from the linked tutorial.

(I’ll add a brief note that you can also use multipliers to apply constraints to weak problems that do not correspond to minimization, by just directly adding the variations of the multiplier terms to a weak form (e.g., the pressure in the weak form of the incompressible Navier–Stokes equations, which acts as a Lagrange multiplier for the incompressibility constraint). But, for whatever reason, Lagrange multipliers are most frequently taught in the context of minimization problems.)