# Variational formulation and boundary condition

**URL:** <https://community.freefem.org/t/variational-formulation-and-boundary-condition/1032>\
**Category:** General Discussion\
**Created:** [June 14, 2021, 10:27am UTC](https://community.freefem.org/t/variational-formulation-and-boundary-condition/1032 "2021-06-14T10:27:56Z")\
**Posts on this page:** 2\
**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 14, 2021, 10:27am UTC](https://community.freefem.org/t/variational-formulation-and-boundary-condition/1032/1 "2021-06-14T10:27:57Z")

</div>

Hi,  
We consider in 2D domain : [0,L] x[0,H], the system of equations:  
dV/dt = D\* Delta V - dV/dx - V  
dU/dt= V - alpha\* U  
with boundary conditions  
x=0,L: dV/dx = 0, y=0: dV/dy=- U + V; y=H: dV/dy=0  
and initial condition V(x,y,0)= V0

Question 1: this system is no linear. So to resolve it, we have to use arf and matrix? Or it is sufficient to use the variational formulation: problem ([U,V],[UH,VH])?

like this:

```auto
problem MainSys([V,VH],[U,UH],solver=LU)= int2d(Th)(V*VH/dt)-int2d(Th)(oldV*VH/dt)+int2d(Th)(U*UH/dt)-int2d(Th)(oldU*UH/dt)
+int2d(Th)(D*(dx(V)*dx(VH)+dy(V)*dy(VH)))
+int2d(Th)(dx(V)*Vh)+int2d(Th)(V*VH)
+int2d(Th)(alpha*U*UH)-int2d(Th)(V*UH);
-int1d(Th,1)(D*V*VH)+int1d(Th,1)(D*U*UH);

```

is it correct?  
Question 2: for boundary condition, we write it using \int 1d(Th,… or we have to use on(…?

Regards

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [June 16, 2021, 9:47am UTC](https://community.freefem.org/t/variational-formulation-and-boundary-condition/1032/2 "2021-06-16T09:47:49Z")

</div>

1. remove the kind of solver=LU by default the solver is better than LU
2. 

warning: V,VH are unknown and V,VH are test function but you want  
V,U unknot and VH,UH test fonction …

the formulation can be : ( not tested )  
problem MainSys([V,U],[VH,UH])=  
int2d(Th)(V_VH/dt)-int2d(Th)(oldV_VH/dt)  
+int2d(Th)(U_UH/dt)-int2d(Th)(oldU_UH/dt)  
+int2d(Th)(D\*(dx(V)_dx(VH)+dy(V)dy(VH)))  
+int2d(Th)(dx(V)Vh)+int2d(Th)(VVH)  
+int2d(Th)(alphaU_UH)-int2d(Th)(V_UH)  
-int1d(Th,1)(D_V_VH)  
+int1d(Th,1)(D_U\*UH);
