Hi everyone,
I’ve have implemented flux boundary conditions as follows:
#Define Problem
u = TrialFunction(V)
v = TestFunction(V)
#Variables
D = Constant(1.71*pow(10,-5)) # mm^2/s
sim_time = 61 # seconds
time_steps = 122
dt = sim_time/time_steps
tol = 1E-14
#Define Boundary Conditions
k1 = Constant(0.009221) # per second
A1 = Constant(0.24) # micro-gram per mm^2
Flux = Expression('t<30+1e-9 ? k1*A1*exp(-1*k1*t) : 0', degree = 1, k1=k1, A1=A1, t=0)
u_D = Constant(0)
boundaryconditions = {
1 : {"Neumann" : 0},
2 : {"Neumann" : 0},
3 : {"Neumann" : 0},
4 : {"Neumann" : 0},
5 : {"Neumann" : 0},
6 : {"Neumann" : 0},
7 : {"Neumann" : Flux},
8 : {"Neumann" : 0},
9 : {"Neumann" : 0},
10 : {"Neumann" : 0}
}
ds = Measure('ds', domain=mesh, subdomain_data=mf)
integrals_N = []
for i in boundaryconditions:
if "Neumann" in boundaryconditions[i]:
if boundaryconditions[i]["Neumann"] != 0: #if not zero flux
g = boundaryconditions[i]["Neumann"]
integrals_N.append(D*dt*v*g*ds(i))
F = u*v*dx + D*dt*dot(grad(u),grad(v))*dx -sum(integrals_N) - v*u_n*dx
a,L = lhs(F),rhs(F)
#Solving Problem
u = Function(V)
t = -1*dt
for i in range(time_steps):
t+=dt
Flux.t = t
solve(a==L,u,bcs)
vtkfile<<(u,t)
u_n.assign(u)
The problems I’m having are:
- The flux does not seem to be implemented uniformly? Does this have to do with a curved surface?
- How do I minimize the negative values? To make it more obvious I’ve scaled the same image to exclude the negative values.
Any help will be greatly appreciated.