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

Error: Couldn't map 'v_1' to a float, returning ufl object without evaluation

0 votes

Hi Everyone,

I have the following Fenics code that I just started to run. I got the following error after I run the last line.

Couldn't map 'v_1' to a float, returning ufl object without evaluation

Can someone please help me fix this. Because eta will be substituted into my variational formulation. I don't understand why k_phi didn't give error but eta gave error. Thank you.

from dolfin import *
import math

mesh = RectangleMesh(Point(-1,-1),Point(1,1),200,200) #Domain[-1,1]*[-1,1]

V1= VectorFunctionSpace(mesh, 'CG', degree=2)
V2=VectorFunctionSpace(mesh, 'CG', degree=2)
Q1 = FunctionSpace(mesh, 'CG', degree=1 )
Q2 = FunctionSpace(mesh, 'CG', degree=1)
VQ = MixedFunctionSpace([V1,V2, Q1, Q2])

(U,u, phi,p)= TrialFunctions(VQ)
(m,n,q,r) = TestFunctions(VQ)
H= Function(VQ)

c = Constant (2/3)
xi0= Constant(1)
n = Constant(2)

alpha = Constant(25)
theta = Constant(1)

U0 = Expression(["x[1]", "x[1]"])
u0 = Expression(["x[1]", "x[1]"])
phi0= Constant(0.01)
p0 = Constant(0)

k_phi = (phi/phi0)**n

eta = math.exp(-alpha*(phi-phi0)) # This is where the error is

Couldn't map 'v_1' to a float, returning ufl object without evaluation

asked Nov 14, 2015 by Vivian FEniCS Novice (550 points)

1 Answer

+1 vote
 
Best answer

Try without math. - dolfin has its own exp function

answered Nov 14, 2015 by chris_richardson FEniCS Expert (31,740 points)
selected Nov 14, 2015 by Vivian

Thanks that works.

...