A= Expression(‘0.5*(1+tanh(100*(cos(0.4pi )/sin(0.4pi )- cos(pi0.1phi )/sin(pi0.1phi))))+1’,degree=2,pi=pi, phi=phi, element = V.ufl_element())
This is how phi is defined.
q,dq = Function(V),TestFunction(V)
pii,phi, qe = split(q)
I am a newbie may be I am asking very basic. The phi in the argument of cos and sin generating this error. phi is a function. I want to know how to insert phi in the expression.
Please add a full minimal working code example that reproduces the error message, and make sure that you use 3x` encapsulation to ensure appropriate formatting.
Whether this is more readable is perhaps subjective, but the following eliminates the redundant lines that differ only by index and is easier to generalize to arbitrary dimension:
# Works:
#expr1 = Expression("v[0]",v=v,degree=1)
#expr2 = Expression("v[1]",v=v,degree=1)
d=2
expr = [Expression("v["+str(i)+"]",v=v,degree=1)
for i in range(0,d)]
# Verify (should print 1 and 2):
#print(assemble(expr1*dx(domain=mesh)))
#print(assemble(expr2*dx(domain=mesh)))
for i in range(0,d):
print(assemble(expr[i]*dx(domain=mesh)))