

Exercise material of the MSc-level course **Numerical Methods in Geotechnical Engineering**.
Held at Technische Universität Bergakademie Freiberg.

Comments to:

*Prof. Dr. Thomas Nagel  
Chair of Soil Mechanics and Foundation Engineering  
Geotechnical Institute  
Technische Universität Bergakademie Freiberg.*

https://tu-freiberg.de/en/soilmechanics


# Exercise on the least squares method

You're given a CPT data set consisting of cone resistance $q_\text{c}$ and frictional resistance $f_\text{s}$ measurements. Your first task is to check the results by plotting them and to compute as well as plot the friction ratio $R_\text{f}$.


```python
import numpy as np #numerical methods
#import sympy as sp #symbolic operations
import matplotlib.pyplot as plt #plotting
import pandas as pd

#Some plot settings
plt.style.use('seaborn-deep')
plt.rcParams['lines.linewidth']= 2.0
plt.rcParams['lines.color']= 'black'
plt.rcParams['legend.frameon']=True
plt.rcParams['font.family'] = 'serif'
plt.rcParams['legend.fontsize']=14
plt.rcParams['font.size'] = 14
plt.rcParams['axes.spines.right'] = False
plt.rcParams['axes.spines.top'] = False
plt.rcParams['axes.spines.left'] = True
plt.rcParams['axes.spines.bottom'] = True
plt.rcParams['axes.axisbelow'] = True
plt.rcParams['figure.figsize'] = (8, 6)
```


```python
CPT_data = pd.read_csv('Data/CPT_2015.csv')
```


```python
z = CPT_data.Teufe[1:].to_numpy(dtype=float)
qc = CPT_data.qc[1:].to_numpy(dtype=float)
fs = CPT_data.fs[1:].to_numpy(dtype=float)
with np.errstate(divide='ignore',invalid='ignore'):
    Rf = np.divide(fs,qc)
```


```python
fig, ax = plt.subplots(figsize=(18,6))
ax.plot(z, qc, label='$q_\\mathrm{c}$ / MPa')
ax.plot(z, fs, label='$f_\\mathrm{s}$ / MPa')

ax2 = ax.twinx()
ax2.spines["right"].set_visible(True)
ax2.plot(z,Rf* 100., color='red', label = '$R_\\mathrm{f}$')

ax.set_xlabel('$z$ / m')
ax.set_ylabel('$q_\\mathrm{c}$, $f_\\mathrm{s}$ / MPa')
ax2.set_ylabel('$R_\\mathrm{f}$ / %')

fig.legend(loc='upper center',ncol=3)
fig.tight_layout()
```

You're also given data on the relationship between $q_\text{c}$ and $I_\text{D}$. The data is valid only for $z > 2$ m as well as above the phreatic surface. Your task is now to find a functional relationship $I_\text{D}(q_\text{c})$ in order to estimate the $I_\text{D}$ distribution in the above soil profile investigated with cone prenetration testing.


```python
ID_data = pd.read_csv('Data/qc_ID.csv')
```


```python
ID_data
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>qc</th>
      <th>ID</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>MPa</td>
      <td>NaN</td>
    </tr>
    <tr>
      <th>1</th>
      <td>3</td>
      <td>0.025327</td>
    </tr>
    <tr>
      <th>2</th>
      <td>6</td>
      <td>0.189061</td>
    </tr>
    <tr>
      <th>3</th>
      <td>9</td>
      <td>0.407843</td>
    </tr>
    <tr>
      <th>4</th>
      <td>12</td>
      <td>0.361879</td>
    </tr>
    <tr>
      <th>...</th>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>67</th>
      <td>11</td>
      <td>0.510890</td>
    </tr>
    <tr>
      <th>68</th>
      <td>15</td>
      <td>0.538081</td>
    </tr>
    <tr>
      <th>69</th>
      <td>19</td>
      <td>0.634794</td>
    </tr>
    <tr>
      <th>70</th>
      <td>23</td>
      <td>0.719363</td>
    </tr>
    <tr>
      <th>71</th>
      <td>27</td>
      <td>0.761487</td>
    </tr>
  </tbody>
</table>
<p>72 rows × 2 columns</p>
</div>




```python
qc_ID = ID_data.qc[1:].to_numpy(dtype=float)
ID = ID_data.ID[1:].to_numpy(dtype=float)
```


```python
fig, ax = plt.subplots()
ax.plot(qc_ID, ID,ls='',marker='o')

ax.set_xlabel('$q_\\mathrm{c}$ / MPa')
ax.set_ylabel('$I_\\mathrm{D}$')

fig.tight_layout()
```

12abc15d098b76adf7e3a0a2f2771e91286366d8
ipynb
Jupyter Notebook
Least_Squares_Exercise.ipynb
dominik-kern/Numerical_Methods_Introduction
09a0d6bd0ddbfc6e7f94b65516d9691766ed46ae
MIT
Least_Squares_Exercise.ipynb
dominik-kern/Numerical_Methods_Introduction
09a0d6bd0ddbfc6e7f94b65516d9691766ed46ae
MIT
Least_Squares_Exercise.ipynb
dominik-kern/Numerical_Methods_Introduction
09a0d6bd0ddbfc6e7f94b65516d9691766ed46ae
MIT
Qwen/Qwen-72B
1. YES
2. YES