# Zero Flux Boundary conditions

Hi,
How do I apply zero flux boundary conditions to this problem? I tried using 0*test_function but this did not to work:

``````real g = 0.0;

varf Cequation(c, v) =
int2d(Mesh)(c/dt*v)
+ int2d(Mesh)(cold/dt*v)
+ int2d(Mesh)(-c*log((clogvalue/Kc) + epsilon)*v)
+ int1d(Mesh, wall)(g*v);
;
``````

where wall is my boundary.

Thanks

For me this work, but what is the other Boundary condition

Thank you so much for your quick response!

I have a mesh with 4 borders. My plan was to put a zero flux boundary on all 4 of the boundaries. â€śwallâ€ť is the name of all the boundaries. Do I need to implement another boundary condition besides this?

``````real L = 1.0;
int meshSize = 10;
int edge = 1;

mesh Mesh;
border b1(t =-1.,1.){x=L*t; y = -L; label=wall;};
border b2(t=-1.,1.){x=L; y=L*t; label=wall;};
border b3(t=0.,2.){x=L-L*t; y=L; label =wall;};
border b4(t=0.,2.){x=-L;y=L-L*t; label=wall;};

Mesh = buildmesh(b1(meshSize) + b2(meshSize) + b3(meshSize) + b4(meshSize));

``````

I appreciate you must be busy but here is my code if you have time to look at it. The initial conditions are set to steady state values so for each time step, the values should not change. However at the moment they do. I am pretty sure this is due to the boundary conditions:
System_of_PDEs.edp (6.0 KB)

Thank you.

At least there should be a â€ś-â€ť sign on the line containing `cold`.

1 Like

Thank you! Iâ€™ve corrected this now but I am still having issues with the boundary conditions I think. Starting with the ICs equal to the steady state values still result in a change in the variables when they should remain constant over time.

I only have the 1 boundary condition (no flux boundary) applied to each of the borders of my mesh. since I have 2nd order PDEs do I require another?

Did you correct also the â€ś-â€ť on the other unknowns?

would you mind clarifying what you mean? do you mean changing all the lines refering to old variables which is the variable value for the previous time step in my other varfs?

If so then yes I did this but I still seem to be having issues. I appreciate you must be very busy but if you have time to have a look at my full code that would be great. I am pretty new to freeFEM so it is likely something simple I am missing.

I also have multiple varf problems by the way. In each of those problems I defined the boundary condition the same way with int1d (Mesh, wall) (g*vn) where real g = 0.0

I found the following errors:
â€“ line 211, replace â€śPbn =â€ť by â€śPbc =â€ť
â€“ You use variational formulations to get systems of the form `Ax+b=0`
then you solve them by setting `x=A^-1*b`. Thus you miss a minus sign.
â€“ You define your matrices before the time loop, this is a problem because the value of the quantities needed to compute the matrices do not have yet their correct values.

To correct the two previous problems (and simplify) you can put your definitions into the time loop and use `solve` instead of `varf`. This gives
System_of_PDEs.edp (5.1 KB)

Thank you so much for explaining and fixing the problem! I really appreciate it!

My code now stays at the spatially homogenous steady states when they are inputted as the initial conditions. However when putting in initial condition above or bellow these values, the system does not tend towards the steady state even though it is a stable steady state. ( I know this from other simulations using different techniques).

Any idea why this might be happening?

I think you need first to be sure of the signs of the zero order terms in each system to solve. It looks like if they were all reversed.

Thank you again! I reversed the signs and the model is now working.