Hello,
I’m new to FeniCS and I so might do some basic mistakes, so please forgive for those.
So I tried to use FeniCS in order to solve a differential equation in one dimension. I’m currently using this code:
from dolfin import *
from __future__ import print_function
from fenics import *
import matplotlib.pyplot as plt
#Definition of parameters
Rint = 300
Rext = 1000
Rratio = Rint/Rext
Omega = 60000
#Definition of the mesh
nx1 = 100
mesh1 = UnitIntervalMesh(nx1)
Hh1 = FunctionSpace(mesh1, 'P', 1)
#Definition of the boundaries
class DirichletBoundary1(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and (abs(x[0] - Rratio) < tol) or (x[0] < Rratio ) #Here I'm not quiet sure of the x[0] < Rratio, i just want to say that between 0 and Rratio on the x
abscissa I'm on the boundary..
class DirichletBoundary2(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and (abs(x[0] - 1) < tol)
bcD1 = DirichletBC(Hh1, Omega, DirichletBoundary1())
bcD2 = DirichletBC(Hh1, 0, DirichletBoundary2())
boundaries1 = MeshFunction("size_t", mesh1, mesh1.topology().dim()-1, 0)
ds1 = Measure("ds", domain=mesh1, subdomain_data=boundaries1)
#Definition of particular functions
ksi = Expression('exp(1/(Re*x[0]))', degree = 1, Re = Rext)
x2 = Expression('pow(x[0]*Re, 2), degree = 1, Re = Rext)
#Variational Form
u1 = TrialFunction(Hh1)
v1 = TrialFunction(Hh1)
l1 = 0
a1 = (-x2 * ksi * dot( grad(u1), grad(v1)) + ksi * dot(u1, v1))*dx
u1 = Function(Hh1)
bcs = [bcD1, bcD2]
solve(a1 == l1, u1, bcs)
So on the last line, i get an error :
(i cannot uppload more than one image, so i put the last lines, but at the begining it started to create a Non linear Problem from what i saw with the comments)
So I assumed that I should use NonlinearVariationnalSolver instead, but when I used it, it showed me a different error with a wrong type of argument…
Please can you help me in order to complete my numerical resolution ?
Thanks for taking the time to read me !