NameError: name 'replace' is not defined

I just updated to Ubuntu 18.04. The code that used to work normally now has the following error:

E_du = replace(E_u,{u:du})
NameError: name ‘replace’ is not defined

where,

elastic_energy = 0.5*inner(sigma(eps(u), alpha), eps(u))*dx

external_work = dot(body_force, u)*dx

dissipated_energy = Gc/c_w*(w(alpha)/ell + ell*dot(grad(alpha), grad(alpha)))dx #(w(alpha) + 0.5 * >ell**2 * w1dot ( grad ( alpha), grad ( alpha) )) * dx

total_energy = elastic_energy + dissipated_energy - external_work

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

Weak form of elasticity problem. This is the formal expression

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

for the tangent problem which gives us the equilibrium equations.

E_u = derivative(total_energy,u,v)
E_alpha = derivative(total_energy,alpha,beta)

Hessian matrix

E_alpha_alpha = derivative(E_alpha,alpha,dalpha)

Writing tangent problems in term of test and trial functions for matrix assembly

E_du = replace(E_u,{u:du})
E_dalpha = replace(E_alpha,{alpha:dalpha})

Thank you advance.

Try adding

from ufl import replace

before calling replace.

1 Like

Thank you very much!