# Variational formulation

**URL:** <https://community.freefem.org/t/variational-formulation/481>\
**Category:** General Discussion\
**Created:** [June 21, 2020, 9:23am UTC](https://community.freefem.org/t/variational-formulation/481 "2020-06-21T09:23:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aicha](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aicha](https://community.freefem.org/u/Aicha)\
**Post date:** [June 21, 2020, 9:23am UTC](https://community.freefem.org/t/variational-formulation/481/1 "2020-06-21T09:23:08Z")

</div>

Hi

i have a question please.

We consider the following equation:

L\*(du/dt - \Delta u + c(x,y) . \nabla u + w q\_{\delta}(x/\eps,y/eps) u) = L\*f(x,t), x \in [0,1], t \in [0,1],

where L is real fixed and esp is positif fixed.

with initial condition: u(x,0)=0 and with periodic boundary conditions, and c(x,y)=(y,-x).

I try to write the variational formulation associated to this problem. Please is it correct to write

mesh Th=square(N,N,[x,y]);

fespace Vh(Th,P1,periodic=[[2,y],[4,y],[1,x],[3,x]]);

fespace Wh(Th,P2,periodic=[[2,y],[4,y],[1,x],[3,x]]);

Vh uh=0.0;

Vh wh=0.0;

Vh vh;

Vh fh;

Vh oldU=0.0;

Vh oldW=0.0;

problem het(uh,vh,init=t) =

```
int2d(Th)(L*(dx(uh)*dx(vh)+dy(uh)*dy(vh))*dt)

 +int2d(Th)(L*(y*dx(uh)*vh - x*dy(uh)*vh))

+int2d(Th)(L*uh*vh)

-int2d(Th)(L*oldU*vh)

+int2d(Th)(qdelta(x/eps,y/eps,w)*uh*vh*dt)

-int2d(Th)(fh*vh*dt)

;

```

Thank you in advance to the help.

Regards
