the équation is given by : \
-\epsilon u^{''}+ \lambda u^{'} = f \
the boundaries conditions are:\
u(1) = u(0) = 0 \
u is define in (0,1)
we have to find a numérical with finite élément P1 and P2
for P1 i have made this code :
‘’’ from future import print_function
import matplotlib.pyplot as plt
from fenics import *
import matplotlib.pyplot as plt
from dolfin import *
import numpy as np
from mshr import *
Parameters of the problem
nx = 10
epsilon = 0.1
lamda = 1.0
f = 1.0
Create mesh and define function space
mesh = UnitIntervalMesh(nx)
Q = FunctionSpace(mesh,“P”,1)
Define variational problem
plt.figure(figsize=(10, 5))
plot(mesh, title=“Maillage pour n = 10”)
Define the boundaries
u = TrialFunction(Q)
v = TestFunction(Q)
bord1 = ‘near(x[0], 0)’
bord2 = ‘near(x[0], 0)’
define boundary conditions
bcu_bord1 = DirichletBC(Q, Constant((0)), bord1)
bcu_bord2 = DirichletBC(Q, Constant((0)), bord2)
a = epsilon*inner(grad(u), grad(v))dx + lamdainner(u.dx(0), v)*dx
L = dot(f,v)*dx
solve the problem
bcu = [bcu_bord1, bcu_bord2]
w = Function(Q)
solve(a == L, w, bcu)
I want to plot the numérical solution of u but it doesnt work