forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.2.2.1.py
22 lines (22 loc) · 929 Bytes
/
7.2.2.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sympy import Matrix,fraction
from sympy.solvers.inequalities import reduce_rational_inequalities
import sympy as sp
Ee,Nu = sp.symbols("E nu", real = True)
G = Ee/2/(1 + Nu)
Cc = Matrix([[1/Ee,-Nu/Ee,-Nu/Ee,0,0,0],
[-Nu/Ee,1/Ee, -Nu/Ee,0,0,0],
[-Nu/Ee, -Nu/Ee, 1/Ee,0, 0, 0],
[0, 0, 0, 1/G, 0, 0],
[0, 0, 0, 0, 1/G, 0],
[0, 0, 0, 0, 0, 1/G]])
print("C =",Cc)
eigensystem = Cc.eigenvects()
eigenvalues = [i[0] for i in eigensystem]
print("eigenvalues =",eigenvalues)
# I have not found an algorithm where sympy can solve multiple values in inequalities
n1,d1 = fraction(eigensystem[0][0])
n2,d2 = fraction(eigensystem[1][0])
n3,d3 = fraction(eigensystem[2][0])
s_Nu = reduce_rational_inequalities([[n1>0,n2>0,n3>0]], Nu)
s_Ee = reduce_rational_inequalities([[1/d1>0,1/d2>0,1/d3>0]], Ee)
print("Inequalities for Eigenvalues to be positive:",s_Nu,s_Ee)