I’m trying to run the following code
from fenics import *
from dolfin import *
num_steps=2
x0=y0=0.0
xe=ye=1.0
mesh = RectangleMesh(Point(x0, y0), Point(xe, ye), num_steps, num_steps)
V = FunctionSpace(mesh, ‘CG’, 1)
u_D = Constant(‘1.0’)
def boundary_d(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary_d)
u = TrialFunction(V)
v = TestFunction(V)
u = Function(V)
f=Constant(‘0.0’)
F=dot(grad(u), grad(v))* dx-f* v*dx
a, L = lhs(F), rhs(F)
solve(a == L, u, bc)
and get an error
Form has no parts with arity 2.
Traceback (most recent call last):
File “/home/s_g/eclipse-workspace/geo/geo04.py”, line 30, in
solve(a == L, u, bc)
File “/usr/lib/python3/dist-packages/dolfin/fem/solving.py”, line 220, in solve
_solve_varproblem(*args, **kwargs)
File “/usr/lib/python3/dist-packages/dolfin/fem/solving.py”, line 242, in _solve_varproblem
form_compiler_parameters=form_compiler_parameters)
File “/usr/lib/python3/dist-packages/dolfin/fem/problem.py”, line 59, in init
cpp.fem.LinearVariationalProblem.init(self, a, L, u._cpp_object, bcs)
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
*** fenics-support@googlegroups.com
*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.
*** -------------------------------------------------------------------------
*** Error: Unable to define linear variational problem a(u, v) == L(v) for all v.
*** Reason: Expecting the left-hand side to be a bilinear form (not rank 0).
*** Where: This error was encountered inside LinearVariationalProblem.cpp.
*** Process: 0
*** DOLFIN version: 2019.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------
I’m running code under Ubuntu 18.04 LTS (from WIndows 10). dolfin-version reports 2019.1.0. Could you please advise what I’m doing wrong? Thank you!