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

float is required

0 votes

Hi
I have to solve MixedFunctionSpace instead of FunctionSapce example like d6_pD2.py.
But when i solve Convergence rates like

degree = int(sys.argv[1])
h = []
E = []
for nx in [4, 8, 16, 32, 64, 128, 264]:
    h.append(1.0/nx)
 E.append(compute(nx, nx, degree))
from math import log as ln
for i in range(1, ln(E)):
r = ln(E[i]/E[i-1])/ln(h[i]/h[i-1])
print 'h=%10.2E E=%8.2E r=%.2f' % (h[i], error, r)

i get error on float like given below

Solving linear variational problem.
Traceback (most recent call last):
File "d6_pD2.py", line 145, in
for i in range(1, ln(E)):
TypeError: a float is required

I searched in FEniCS and launchpad, but i couldn't get idea about this.

Anybody clarify this to me?

Thank you

asked Jan 27, 2014 by Manickam FEniCS Novice (450 points)

1 Answer

+4 votes
 
Best answer

Hi, the code in d6_p2D.py says

for i in range(1, len(E)):

and not ln(E). The former is length of the list E. The latter throws error because math.log(E) does not work with lists.

answered Jan 27, 2014 by MiroK FEniCS Expert (80,920 points)
selected Jan 28, 2014 by Garth N. Wells
...