```
In [1]:
```%pylab inline

```
```

```
In [2]:
```from sg2lib import *

```
In [3]:
```gamma = 1
Sx = 2
Fs = array([[1, gamma], [0, 1]])
Fp = array([[Sx, 0], [0, 1/Sx]])

To divide simple shear deformation with $\gamma$=1 to `n`

incremental steps

```
In [4]:
```n = 10
Fsi = array([[1, gamma/n], [0, 1]])
print('Incremental deformation gradient:')
print(Fsi)

```
```

`allclose`

numpy function

```
In [5]:
```array_equal(matrix_power(Fsi, n), Fs)

```
Out[5]:
```

```
In [6]:
```Fpi = array([[Sx**(1/n), 0], [0, Sx**(-1/n)]])
print('Incremental deformation gradient:')
print(Fpi)

```
```

```
In [7]:
```allclose(matrix_power(Fpi, n), Fp)

```
Out[7]:
```

```
In [8]:
```u,s,v = svd(Fs @ Fp)
print('Axial ratio of finite strain resulting from simple shear superposed on pure shear: {}'.format(s[0]/s[1]))
u,s,v = svd(Fp @ Fs)
print('Axial ratio of finite strain resulting from pure shear superposed on simple shear: {}'.format(s[0]/s[1]))

```
```

Lets try to split those deformation to two increments and mutually mix them:

```
In [9]:
```Fsi = array([[1, gamma/2], [0, 1]])
Fpi = array([[Sx**(1/2), 0], [0, Sx**(-1/2)]])
u,s,v = svd(Fsi @ Fpi @ Fsi @ Fpi)
print('Axial ratio of finite strain of superposed increments starting with pure shear: {}'.format(s[0]/s[1]))
u,s,v = svd(Fpi @ Fsi @ Fpi @ Fsi)
print('Axial ratio of finite strain of superposed increments starting with simple shear: {}'.format(s[0]/s[1]))

```
```

```
In [10]:
```n = 100
Fsi = array([[1, gamma/n], [0, 1]])
Fpi = array([[Sx**(1/n), 0], [0, Sx**(-1/n)]])
u,s,v = svd(matrix_power(Fsi @ Fpi, n))
print('Axial ratio of finite strain of superposed increments starting with pure shear: {}'.format(s[0]/s[1]))
u,s,v = svd(matrix_power(Fpi @ Fsi, n))
print('Axial ratio of finite strain of superposed increments starting with simple shear: {}'.format(s[0]/s[1]))

```
```

```
In [11]:
```arp = []
ars = []
ninc = range(1, 201)
for n in ninc:
Fsi = array([[1, gamma/n], [0, 1]])
Fpi = array([[Sx**(1/n), 0], [0, Sx**(-1/n)]])
u,s,v = svd(matrix_power(Fsi @ Fpi, n))
arp.append(s[0]/s[1])
u,s,v = svd(matrix_power(Fpi @ Fsi, n))
ars.append(s[0]/s[1])
figure(figsize=(16, 4))
semilogy(ninc, arp, 'r', label='Pure shear first')
semilogy(ninc, ars, 'g', label='Simple shear first')
legend()
xlim(1, 200)
xlabel('Number of increments')
ylabel('Finite strain axial ratio');

```
```

```
In [12]:
```from scipy.linalg import expm, logm

Spatial velocity gradient could be obtained as matrix logarithm of deformation gradient

```
In [13]:
```Lp = logm(Fp)
Ls = logm(Fs)

```
In [14]:
```L = Lp + Ls

```
In [15]:
```F = expm(L)
u,s,v = svd(F)
sar = s[0]/s[1]
print('Axial| ratio of finite strain of simultaneous pure shear and simple shear: {}'.format(sar))

```
```

Lets overlay it on previous diagram

```
In [16]:
```arp = []
ars = []
ninc = range(1, 201)
for n in ninc:
Fsi = array([[1, gamma/n], [0, 1]])
Fpi = array([[Sx**(1/n), 0], [0, Sx**(-1/n)]])
u,s,v = svd(matrix_power(Fsi @ Fpi, n))
arp.append(s[0]/s[1])
u,s,v = svd(matrix_power(Fpi @ Fsi, n))
ars.append(s[0]/s[1])
figure(figsize=(16, 4))
semilogy(ninc, arp, 'r', label='Pure shear first')
semilogy(ninc, ars, 'g', label='Simple shear first')
legend()
xlim(1, 200)
axhline(sar)
xlabel('Number of increments')
ylabel('Finite strain axial ratio');

```
```

```
In [17]:
```L = logm(Fs)

```
In [18]:
```D = (L + L.T)/2
W = (L - L.T)/2

Check that decomposition give total spatial velocity gradient

```
In [19]:
```allclose(D + W, L)

```
Out[19]:
```

Visualize spatial velocity gradients for rate of deformation tensor

```
In [20]:
```vel_field(D)

```
```

Visualize spatial velocity gradients for spin tensor

```
In [21]:
```vel_field(W)

```
```