Hello everyone,
I am using an UFL expression to define a variable that depends on two parameters. After some steps of the solution, I want to update one of the parameters with a location dependent field. I tried it with the following approach but it is throwing an error,
The minimal working code is as follows,
from fenics import *
from mshr import *
E = 210000.0
nu = 0.3
mu = Expression('E_1/(2.0*(1.0 + nu_1))', E_1 = E, nu_1 = nu,degree = 0)
#Define and plot mesh
domain = Rectangle(Point(0.0, 0.0), Point(100.0, 100.0))
mesh = generate_mesh(domain, 32)
# Define function space
V = VectorFunctionSpace(mesh, 'CG', 1)
V_alpha = FunctionSpace(mesh, 'CG', 1)
class Stiffness_function(UserExpression):
def __init__(self, E_sol, **kwargs):
super().__init__(**kwargs)
self.E_sol = E_sol
def eval(self, value, x):
x_c = x[0]
y_c = x[1]
value[0]= (self.E_c_sol(x_c,y_c))*sqrt(x_c**2 + y_c**2)
def value_shape(self):
return (1,)
for n in range(3):
if n == 2:
mu.E_1 = 150000.
else:
New_E = Stiffness_function(E_sol = E, element = V_alpha.ufl_element())
mu.E_1 = New_E
and the error is
Please guide me, how I can update this expression.
Thank you,
Manish