ufl.log.UFLException Compiling Problem

Hi everyone,

I am very new to Fenics and I am trying to run my program to simulate the heating of a metal block via a laser (including conduction and radiation). Specifically I am currently trying to separate the bi-linear and linear parts of the weak form of the differential equation:

#ENCODE BOUNDARY CONDITIONS (MAY NEED ALTERING)
boundary_conditions = {0: {'Robin':     (es, T_a4)},
                       1: {'Robin':     (es, T_a4)},
                       2: {'Robin':     (es, T_a4)},
                       3: {'Robin':     (es, T_a4)}}

#split the integrals up into those depending on T and those that don't

ds = Measure('ds', domain=mesh, subdomain_data = boundary_markers)
integrals_R = []
T = TrialFunction(V)
v = TestFunction(V)
T_n = interpolate(T_am, V)

for i in boundary_conditions:
    if 'Robin' in boundary_conditions[i]:
        integrals_R.append(es*(T**4 - T_a4)*v*ds(i))

#----------------------------------------

F = T*v*dx + dot(grad(T), grad(v))*dx + (1/kappa)*Q*v*ds(3) + (1/kappa)*sum(integrals_R)-T_n*v*dx
a = lhs(F)
L = rhs(F) 

With Q defined below

Q = Expression('2*A*t*Pmax/(pi*w*w)*exp(-2*pow(x[0]-2, 2)/(w*w))',degree=2, A=1, Pmax=200,w=1,x0=0, y0=0,t=0).

When I run this code, I get an error says:

File "test2D.py", line 109, in <module>
    a = lhs(F)
  File "/usr/local/lib/python3.6/dist-packages/ufl/formoperators.py", line 79, in lhs
    return compute_form_lhs(form)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/formtransformations.py", line 379, in compute_form_lhs
    return compute_form_with_arity(form, 2)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/formtransformations.py", line 345, in compute_form_with_arity
    return map_integrands(_transform, form)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/map_integrands.py", line 39, in map_integrands
    for itg in form.integrals()]
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/map_integrands.py", line 39, in <listcomp>
    for itg in form.integrals()]
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/map_integrands.py", line 46, in map_integrands
    return itg.reconstruct(function(itg.integrand()))
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/formtransformations.py", line 341, in _transform
    e, provides = pe.visit(e)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 110, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 110, in <listcomp>
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 110, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 110, in <listcomp>
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 110, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 110, in <listcomp>
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 114, in visit
    r = h(o)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/formtransformations.py", line 145, in sum
    part, term_provides = self.visit(term)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/transformer.py", line 114, in visit
    r = h(o)
  File "/usr/local/lib/python3.6/dist-packages/ufl/algorithms/formtransformations.py", line 73, in expr
    error("Found Argument in %s, this is an invalid expression." % ufl_err_str(x))
  File "/usr/local/lib/python3.6/dist-packages/ufl/log.py", line 172, in error
    raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Found Argument in <Power id=140430134395792>, this is an invalid expression.

What is causing this error and how can it be fixed?

Thanks in advance

The error occurs because the given residual F is nonlinear in the TrialFunction, due to the presence of T**4 in the Robin BC, so it cannot be separated into bilinear and linear forms. This would need to be solved as a nonlinear problem.

Ok, thank you for clearing that up