## Finding expressions for elastic moduli

I want to find more expressions to fill in the gaps in [my matrix](http://www.subsurfwiki.org/wiki/Template:Elastic_modulus):


```python
from IPython.display import Image
Image("data/moduli.png")
```

We can use [`sympy`](http://docs.sympy.org/dev/tutorial/basic_operations.html) to help!


```python
import sympy
sympy.__version__
```




    '1.0'




```python
sympy.init_printing(use_latex='mathjax')
```

We must define our symbols. We'll use `alpha` and `beta` for Vp and Vs.


```python
alpha, beta, gamma = sympy.symbols("alpha, beta, gamma")
lamda, mu, E, K, M, rho = sympy.symbols("lamda, mu, E, K, M, rho")
nu = sympy.symbols("nu")
```

## Expression for Vp (alpha) in terms of K, E


```python
from sympy import sqrt
alpha_expr = sqrt((mu * (E - 4*mu)) / (rho * (E - 3*mu)))
alpha_expr
```




$$\sqrt{\frac{\mu \left(E - 4 \mu\right)}{\rho \left(E - 3 \mu\right)}}$$




```python
print(sympy.latex(alpha_expr))
```

    \sqrt{\frac{\mu \left(E - 4 \mu\right)}{\rho \left(E - 3 \mu\right)}}



```python
mu_expr = (3 * K * E) / (9 * K - E)
```


```python
subs = alpha_expr.subs(mu, mu_expr)
subs
```




$$\sqrt{3} \sqrt{\frac{E K \left(- \frac{12 E K}{- E + 9 K} + E\right)}{\rho \left(- E + 9 K\right) \left(- \frac{9 E K}{- E + 9 K} + E\right)}}$$




```python
print(sympy.latex(subs))
```

    \sqrt{3} \sqrt{\frac{E K \left(- \frac{12 E K}{- E + 9 K} + E\right)}{\rho \left(- E + 9 K\right) \left(- \frac{9 E K}{- E + 9 K} + E\right)}}



```python
from sympy import simplify
simplify(subs)
```




$$\sqrt{3} \sqrt{\frac{K \left(E + 3 K\right)}{\rho \left(- E + 9 K\right)}}$$




```python
print(sympy.latex(simplify(subs)))
```

    \sqrt{3} \sqrt{\frac{K \left(E + 3 K\right)}{\rho \left(- E + 9 K\right)}}


## Expression for Vs (beta) in terms of K, E


```python
beta_expr = sqrt(mu/rho)
simplify(beta_expr.subs(mu, mu_expr))
```




$$\sqrt{3} \sqrt{- \frac{E K}{\rho \left(E - 9 K\right)}}$$




```python
simpl = simplify(beta_expr.subs(mu, mu_expr))
```


```python
print(sympy.latex(simpl))
```

    \sqrt{3} \sqrt{- \frac{E K}{\rho \left(E - 9 K\right)}}


## Expression for Vp/Vs (gamma) in terms of K, E


```python
gamma_expr = sqrt((K + (4*mu/3)) / mu)
simpl = simplify(gamma_expr.subs(mu, mu_expr))
simpl
```




$$\sqrt{\frac{1}{E} \left(E + 3 K\right)}$$




```python
print(sympy.latex(simpl))
```

    \sqrt{\frac{1}{E} \left(E + 3 K\right)}


## Expression for Vp/Vs (gamma) in terms of E, mu

Not totally sure why I have to use that hacky way to get the terms to cnacel properly. 


```python
gamma_emu_expr = alpha_expr / beta_expr
simpl = sqrt(gamma_emu_expr**2)
simpl
```




$$\sqrt{\frac{E - 4 \mu}{E - 3 \mu}}$$




```python
print(sympy.latex(simpl))
```

    \sqrt{\frac{E - 4 \mu}{E - 3 \mu}}


## Expression for Vp/Vs (gamma) in terms of PR, mu


```python
e_expr = 2 * mu * (1 + nu)
```


```python
simplify(sqrt(gamma_emu_expr.subs(E, e_expr)**2))
```




$$\sqrt{2} \sqrt{\frac{\nu - 1}{2 \nu - 1}}$$




```python
print(sympy.latex(simplify(sqrt(gamma_emu_expr.subs(E, e_expr)**2))))
```

    \sqrt{2} \sqrt{\frac{\nu - 1}{2 \nu - 1}}


## Expression for Vp in terms of E, lamda


```python
vp_expr = sympy.Eq(alpha, sqrt(mu*(E - 4*mu) / (rho*(E - 3*mu))))
vp_expr
```




$$\alpha = \sqrt{\frac{\mu \left(E - 4 \mu\right)}{\rho \left(E - 3 \mu\right)}}$$




```python
alpha_expr = sqrt(mu*(E - 4*mu) / (rho*(E - 3*mu)))
```


```python
mu_expr = (rho * alpha**2 - lamda)/2
```


```python
new_expr = simplify(vp_expr.subs(mu, mu_expr))
```


```python
new_expr.subs(alpha, alpha_expr)
```




$$\sqrt{\frac{\mu \left(E - 4 \mu\right)}{\rho \left(E - 3 \mu\right)}} = \sqrt{\frac{\left(- \lambda + \frac{\mu \left(E - 4 \mu\right)}{E - 3 \mu}\right) \left(E + 2 \lambda - \frac{2 \mu \left(E - 4 \mu\right)}{E - 3 \mu}\right)}{\rho \left(2 E + 3 \lambda - \frac{3 \mu \left(E - 4 \mu\right)}{E - 3 \mu}\right)}}$$



OK, I give up. Trying Wolfram Alpha...


```python
vp_wolfram = simplify(sqrt(-lamda/rho+sqrt(9*lamda**2+E**2+2*lamda*E)/rho+E/rho)/sqrt(2))**2
sqrt(vp_wolfram)
```




$$\frac{\sqrt{2}}{2} \sqrt{\frac{1}{\rho} \left(E - \lambda + \sqrt{E^{2} + 2 E \lambda + 9 \lambda^{2}}\right)}$$



That's better!


```python
print(sympy.latex(sqrt(vp_wolfram)))
```

    \frac{\sqrt{2}}{2} \sqrt{\frac{1}{\rho} \left(E - \lambda + \sqrt{E^{2} + 2 E \lambda + 9 \lambda^{2}}\right)}


Another for Wolfram Alpha: Vs

    solve V = sqrt((a/(2*((y-2 r V^2)/(2 r V^2))*r)) - (a/r)) for V


```python
simplify(sqrt(sqrt(9*lamda**2+2*lamda*E+E**2)/rho-(3*lamda)/rho+E/rho)/2)**2
```




$$\frac{1}{4 \rho} \left(E - 3 \lambda + \sqrt{E^{2} + 2 E \lambda + 9 \lambda^{2}}\right)$$



Another for Wolfram Alpha: Gamma, or Vp/Vs

    solve G = sqrt(((4/3)*a - 2*((y*G^2 - y)/3))/(a - ((y*G^2 - y)/3))) for G


```python
simplify(sqrt(sqrt(9*lamda**2+2*lamda*E+E**2)/E+(3*lamda)/E+3)/sqrt(2))**2
```




$$\frac{1}{2 E} \left(3 E + 3 \lambda + \sqrt{E^{2} + 2 E \lambda + 9 \lambda^{2}}\right)$$



## Expression for Vs (beta) in terms of nu, K


```python
mu_expr = 3*K*(1 - 2*nu)/(2 + 2*nu)
simpl = simplify((sqrt(mu/rho)).subs(mu,mu_expr)**2)
simpl
```




$$- \frac{3 K \left(2 \nu - 1\right)}{2 \rho \left(\nu + 1\right)}$$




```python
print(sympy.latex(simpl))
```

    - \frac{3 K \left(2 \nu - 1\right)}{2 \rho \left(\nu + 1\right)}


## Expression for Vp (alpha) in terms of nu, K


```python
vp_expr = sqrt(lamda * (1 - nu) / (rho * nu))
l_expr = 3 * K * nu / (1 + nu)
vp_expr.subs(lamda, l_expr)
```




$$\sqrt{3} \sqrt{\frac{K \left(- \nu + 1\right)}{\rho \left(\nu + 1\right)}}$$




```python

```

a982a074def8e388ff2e03b008ce30cbdd1560fa
ipynb
Jupyter Notebook
notebooks_dev/Elastic_modulus_expressions.ipynb
mycarta/in-bruges
5aff5111a61f86145c688c64b7b032b8058cbe56
Apache-2.0
2020-02-27T17:13:33.000Z
2021-03-07T23:13:48.000Z
notebooks_dev/Elastic_modulus_expressions.ipynb
mycarta/in-bruges
5aff5111a61f86145c688c64b7b032b8058cbe56
Apache-2.0
notebooks_dev/Elastic_modulus_expressions.ipynb
mycarta/in-bruges
5aff5111a61f86145c688c64b7b032b8058cbe56
Apache-2.0
2019-03-03T23:42:16.000Z
2019-06-01T21:01:06.000Z
Qwen/Qwen-72B
1. YES
2. YES