# Design of Retaining Wall
http://structengblog.com/retaining-wall-analysis-ipython-sympy-possible-bim-integration/


```python
from sympy import *

init_printing()

ka, q, gs, z = symbols('k_a q gamma_s z') # soil properties and depth
gfq, gfg = symbols('gamma_fq gamma_fg') # partial load factors
pa, va, ma = symbols('p_a v_a m_a') # force effects

pressure = Eq(pa,ka*(gs*z*gfg + q*gfq))
pressure
```


```python
shear = Eq(va, Integral(pressure.rhs, z))
shear
```


```python
shear = shear.doit()
shear
```


```python
moment = Eq(ma, Integral(shear.rhs,z))
moment
```


```python
moment = moment.doit()
moment
```


```python
wallData = ({ka:0.3, gs:19, gfg:1.35, gfq:1.5, q:5, z:3.4})
designSliding = shear.subs(wallData).rhs
print('The ULS sliding force at the base of the wall = {:.2f} kN'.format(designSliding))


```

    The ULS sliding force at the base of the wall = 52.13 kN



```python
designMoment = moment.subs(wallData).rhs
print('The ULS overturning moment at the base of the wall = {:.2f} kNm'.format(designMoment))
```

    The ULS overturning moment at the base of the wall = 63.41 kNm



```python
# geometric properties of the wall
hs, ts, lb, tb, toe = symbols('h_s t_s l_b t_b toe')
gc = symbols('gamma_c') # unit weight of the wall
W, Mst, Ru = symbols('W M_st R_u') # resistances
mu = symbols('mu') # coeff of friction to base
stemWeight = gc*hs*ts
baseWeight = gc*lb*tb
soilLength = lb-(toe+ts)
soilWeight = hs*soilLength*gs
totalWeight = Eq(W,stemWeight+baseWeight+soilWeight)
totalWeight 
```


```python
slidingResistance = Eq(Ru, totalWeight.rhs*mu)
slidingResistance
```


```python
# lever arms to the elements
lab = lb/2
las = toe+ts/2
lau = lb - soilLength/2
stabilityMoment = Eq(Mst,stemWeight*las+baseWeight*lab + soilWeight*lau)
stabilityMoment
```


```python
wallGeo = ({gc:24, hs:3.15, ts:0.25, tb:0.25, toe:0.75, gs:19, mu:0.5})
slidingStability = slidingResistance.subs(wallGeo)
slidingStability
```


```python
baseLength1 = solve(slidingStability.rhs - designSliding, lb)[0]
print('The minimum base length to prevent sliding = {:.2f} m'.format(baseLength1))
```

    The minimum base length to prevent sliding = 2.21 m



```python
overturningStability = stabilityMoment.subs(wallGeo)
overturningStability
```


```python
baseLength2 = solve(overturningStability.rhs - designMoment, lb)[1]
print('The minimum base length to resist overturning = {:.2f} m'.format(baseLength2))
```

    The minimum base length to resist overturning = 1.53 m



```python
# by inspection of the above solutions adopt the following base length
baseLength = 2.3
```


```python
# Calculate the eccentricity of load from the centroid of the base
ec = symbols('e_c')
netMoment = stabilityMoment.rhs-moment.rhs
xBar = netMoment / totalWeight.rhs
eccentricity = Eq(ec,lb/2 - xBar)
eccentricity
```


```python
# amend the partial load factors to 1 for the force effectrs
wallData = ({ka:0.3, gs:19, gfg:1.0, gfq:1.0, q:5, z:3.4})
wallGeo = ({gc:24, hs:3.15, ts:0.25, tb:0.25, toe:0.75, gs:19, mu:0.5, lb: baseLength})
wallData.update(wallGeo)
actEc = eccentricity.subs(wallData)
actEc.evalf(3)
```


```python
# The kern of the foundation
kern = lb.subs(wallData)/6
kern.evalf(3)
```


```python
if actEc.rhs > kern:
    print('Tension occurs at the heel')
    qmax = 2*totalWeight.rhs.subs(wallData)/(3*xBar.subs(wallData))
    print('The maximum pressure = {:.2f} kPa'.format(qmax))
else:
    print('No tension occurs under the base')
    qmax = actEc.rhs*totalWeight.rhs.subs(wallData)*6/(lb.subs(wallData)**2)\
    +totalWeight.rhs.subs(wallData)/lb.subs(wallData)
    print('The maximum pressure = {:.2f} kPa'.format(qmax))
```

    No tension occurs under the base
    The maximum pressure = 62.00 kPa



```python
fck, fy = symbols('f_ck f_y')
ec, ecy, ecu = symbols('e_c, e_cy, e_cu')
fc = symbols('f_c')
conc_str = Eq(fc, 4.0/9*fck*(2*(ec/ecy)-(ec/ecy)**2))
conc_str
```


```python
conc_data = ({fck:25, ecy:0.002, ec:0.0025})
conc_stress = conc_str.rhs.subs(conc_data)
conc_stress
```


```python

```

9c68c94142affc728a3d6c20c940faca02684600
ipynb
Jupyter Notebook
ret_wall.ipynb
satish-annigeri/Notebooks
92a7dc1d4cf4aebf73bba159d735a2e912fc88bb
CC0-1.0
ret_wall.ipynb
satish-annigeri/Notebooks
92a7dc1d4cf4aebf73bba159d735a2e912fc88bb
CC0-1.0
ret_wall.ipynb
satish-annigeri/Notebooks
92a7dc1d4cf4aebf73bba159d735a2e912fc88bb
CC0-1.0
Qwen/Qwen-72B
1. YES
2. YES