This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Error: float returned non-float

+1 vote

Hello, I have a problem and I don't know how to solve it. I would highly appreciate it if anybody could help me!!

Error Message

b = Constant((0.0, rho*g, 0.0))
float returned non-float (type NotImplementedType)

Code

p = Point(0.0, 0.0, 0.0)
q = Point(2.0, 0.5, 1.0)
mesh = BoxMesh(p, q, 20, 10, 10)

rho = 1.0conditional(x[1] < 0.5q[1], 7850.0, 7140.0)
g = 9.81

b = Constant((0.0, -rho*g, 0.0))

asked Apr 12, 2017 by Ulla FEniCS Novice (210 points)

1 Answer

+1 vote

rho is not a constant (i.e. not a float or an int). rho is a conditional expression. Try the following instead:

b = as_vector((0.0, -rho*g, 0.0))

in the future also please take care to format the code in your questions carefully.

answered Apr 12, 2017 by nate FEniCS Expert (17,050 points)
...