Using Conditional function inside a Project function

The problem is that you try to assign a function (the result of the projection), to a float.
The initial kappa has to be a function.
This is illustrated in the minimal example below. Please note the following:

  1. Your proposed example is not minimal, and contains alot of variables not required to reproduce the error. The example below should be used as a guideline for further inquires.
  2. To represent kappa, I am using a DG space, as kappa is discontinuous. If you decide to use a CG space, you will get transfer regions at the switch of the material.
from dolfin import *
from ufl import as_tensor

kappa_s = 138.0       #conductivity [W/m K]
kappa_l = 80.0       #conductivity [W/m K]

mesh = UnitSquareMesh(10,10)

Space = FunctionSpace(mesh, 'P', 1)
T = project(Expression("x[0]+0.1*x[1]", degree=2), Space)

kappa_space = FunctionSpace(mesh, "DG", 0)
kappa = project(kappa_s,kappa_space)
kappa_s = as_tensor(kappa_s,())
kappa_l = as_tensor(kappa_l,())
Tmelting = 0.5
print(kappa.vector().get_local())
kappa.assign(project(conditional(gt(T, Tmelting), kappa_l, kappa_s), kappa_space))
print(kappa.vector().get_local())