# An error while trying to use periodic boundaries

**URL:** <https://community.freefem.org/t/an-error-while-trying-to-use-periodic-boundaries/1168>\
**Category:** General Discussion\
**Created:** [August 23, 2021, 8:16am UTC](https://community.freefem.org/t/an-error-while-trying-to-use-periodic-boundaries/1168 "2021-08-23T08:16:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pouyan25](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@Pouyan25](https://community.freefem.org/u/Pouyan25)\
**Post date:** [August 23, 2021, 8:16am UTC](https://community.freefem.org/t/an-error-while-trying-to-use-periodic-boundaries/1168/1 "2021-08-23T08:16:45Z")

</div>

Hi guys,

i have atoruble while trying to use perodic boundries. I am trying to solve the diffusion equation for a rectangle shpae in 2D and now when i try to use the boundry condition I recieve an error which says:

Assertion fail : (hmn \> 1.0e-20)  
line :1030, in file lgfem.cpp

any idea or suggestion?

thanks a lot in advance

for better insight into the problem I post also my simple code:

// Mesh  
border a(t=-1, 1){x=t; y=-1; label=1;};  
border b(t=-1, 1){x=1; y=t; label=2;};  
border c(t=0, 2){x=1-t; y=1; label=3;};  
border d(t=0, 2){x=-1; y=1-t; label=4;};

int n = 50;

mesh Th = buildmesh(a(n) + b(n) + c(n) + d(n));  
plot(Th, wait=true);

//FE Space  
fespace Vh(Th, P2, periodic=[[3,y] , [1,y]]);  
Vh u, v, u0;

// Initial condition  
u = 0;

//data  
real C1 = 1;  
real C2 = 0;  
real dt = 0.01;  
real T = 3;

real D = 1;

// Variational Problem  
macro F(u, v) D\*( dx(u)\*dx(v) + dy(u)\*dy(v))//eom

problem diffusion(u, v)  
= int2d(Th)(u_v / dt)  
+ int2d(Th)(F(u, v))  
- int2d(Th)(u0_v/dt)  
+ on(4, u=C1)  
+ on(2, u=C2)  
;

// Time loop

int M = int(T / dt) + 1;  
for (int i=1; i\<M; i++){  
u0 = u; // update from previous step time  
diffusion; // Solve the linear system

```
plot(u, wait=0, fill=1, value=1, cmm="Solution at Time " + i * dt); // plot the solution at each time step

```

}
