Closed n1ck94 closed 3 years ago
@n1ck94 which version of sympy is installed in your conda environment?
Sympy version 1.6.2
@n1ck94 unforunately, escript only supports sympy version 1.1 and lower. Could you please try installing sympy version 1.1 in your conda environment and see if this resolves your error?
Ok thanks. The conda specifications indicate that escript requires python versions 2.7 or 3.8 but sympy version 1.1 is only compatible with python version <3.8. Leaving only python version 2.7. Is this correct? I'm currently trying to install escript via conda in a python 2.7 environment but it's getting stuck on "Solving Environment". Is it only for later python versions that escript can be installed via conda?
With python version 2.7.18, sympy version 1.1.1 and escript version 5.4 I'm still getting the IndexError as I mentioned above when I run the plain_strain.py example script (copied below):
from esys.escript import *
from esys.finley import Rectangle
mydomain = Rectangle(l0=1.,l1=1.,n0=10, n1=10)
u = Symbol('u',(2,), dim=2)
q = Symbol('q', (2,2))
sigma = Symbol('sigma',(2,2))
theta = Symbol('theta')
q[0,0]=cos(theta)
q[0,1]=-sin(theta)
q[1,0]=sin(theta)
q[1,1]=cos(theta)
x = Function(mydomain).getX()
q=q.subs(theta,(3.14/4)*whereNonNegative(x[1]-.30)*whereNegative(x[1]-.70))
epsilon0 = symmetric(grad(u))
epsilon = matrixmult(matrixmult(q,epsilon0),q.transpose(1))
c00 = 10
c01 = 8; c11 = 10
c05 = 0; c15 = 0; c55 = 1
sigma[0,0] = c00*epsilon[0,0]+c01*epsilon[1,1]+c05*2*epsilon[1,0]
sigma[1,1] = c01*epsilon[0,0]+c11*epsilon[1,1]+c15*2*epsilon[1,0]
sigma[0,1] = c05*epsilon[0,0]+c15*epsilon[1,1]+c55*2*epsilon[1,0]
sigma[1,0] = sigma[0,1]
sigma0=matrixmult(matrixmult(q.transpose(1),sigma),q)
x=mydomain.getX()
gammaD=whereZero(x[1])*[1,1]
yconstraint = FunctionOnBoundary(mydomain).getX()[1]
p = NonlinearPDE(mydomain, u, debug=NonlinearPDE.DEBUG0)
p.setValue(X=sigma0,q=gammaD,y=[-50,0]*whereZero(yconstraint-1),r=[1,1])
v = p.getSolution(u=[0,0])
The error output is as follows:
Traceback (most recent call last):
File "esNLTest.py", line 19, in <module>
q=q.subs(theta,(3.14/4)*whereNonNegative(x[1]-.30)*whereNegative(x[1]-.70))
File "escriptcore/py_src/symbolic/symbol.py", line 412, in subs
IndexError: too many indices for array
Are the package version I have installed correct? Thanks.
Not sure if it is meant to or not but Sympy isn't being installed when installing escript via conda install -c conda-forge esys-escript. So upon attempting to solve a PDE with the NonlinearPDE class the following RuntimeError is raised:
this is easily fixed by installing Sympy however.
Running the following code
which was extracted from LaunchPad question 256021 (nonlinear pde with nonconstant coefficients) raises the following AttributeError:
Running the 'plain_strain.py' example script from the escript user guide raises the following IndexError
Not sure of a fix/work around for the AttributeError and IndexError so any assistance is appreciated.