Skip to content

Commit a13e21b

Browse files
committed
Merge branch 'python-kin-refactor' of https://github.com/LonghornRacingElectric/simulation_toolkit into python-kin-refactor
2 parents 10b6c6c + 66300b2 commit a13e21b

File tree

7 files changed

+158
-2
lines changed

7 files changed

+158
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ git config --global user.email "you@example.com"
115115
116116
Go to the [OpenModelica Website](https://openmodelica.org/). Under "Download", pick your specified operating system. Installation varies across machines, but reach out to code owners if you run into any issues. Note that this process is easiest on Windows and probably most difficult on MacOS (need to install via a Docker container).
117117
118+
##### Arch
119+
1. Run the following commands in terminal
120+
```shell
121+
yay -S openmodelica
122+
yay -S openmodelica-omlibraries
123+
```
124+
Make sure the second checkbox is checked
125+
<center>
126+
<img src="./src/_4_ico/Modelica_Setting.png" width="75%">
127+
</center>
118128
### Dependencies (docker):
119129
120130
Docker isn't required to run workflows locally, but it is highly recommended. Docker containers give a unified runtime environment, making debugging easier with fewer runtime issues.

src/_2_misc_studies/DIL_tires.ipynb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,22 @@
55
"execution_count": 43,
66
"id": "a7b1a216",
77
"metadata": {},
8-
"outputs": [],
8+
"outputs": [
9+
{
10+
"ename": "KeyError",
11+
"evalue": "'STRUCTURAL'",
12+
"output_type": "error",
13+
"traceback": [
14+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
15+
"\u001b[31mKeyError\u001b[39m Traceback (most recent call last)",
16+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 3\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mmatplotlib\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mpyplot\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mplt\u001b[39;00m\n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mnumpy\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mnp\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m tire = \u001b[43mMF52\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtire_name\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfile_path\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m../../src/_1_model_inputs/Modified_Round_8_Hoosier_R25B_16x7p5_10_on_7in_12psi_PAC02_UM2.tir\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
17+
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/Github/simulation_toolkit/.venv/lib/python3.12/site-packages/LHR_tire_toolkit/MF52.py:19\u001b[39m, in \u001b[36mMF52.__init__\u001b[39m\u001b[34m(self, tire_name, file_path)\u001b[39m\n\u001b[32m 16\u001b[39m \u001b[38;5;28mself\u001b[39m._tire_params = _Processor(name = tire_name, file_path = file_path)\n\u001b[32m 18\u001b[39m \u001b[38;5;28mself\u001b[39m._init_coeffs()\n\u001b[32m---> \u001b[39m\u001b[32m19\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_init_consts\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
18+
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/Github/simulation_toolkit/.venv/lib/python3.12/site-packages/LHR_tire_toolkit/MF52.py:34\u001b[39m, in \u001b[36mMF52._init_consts\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 32\u001b[39m \u001b[38;5;28mself\u001b[39m._operating_conds = \u001b[38;5;28mself\u001b[39m._tire_params.get_parameters(\u001b[33m\"\u001b[39m\u001b[33mTYRE_CONDITIONS\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 33\u001b[39m \u001b[38;5;28mself\u001b[39m._vertical_coeffs = \u001b[38;5;28mself\u001b[39m._tire_params.get_parameters(\u001b[33m\"\u001b[39m\u001b[33mVERTICAL\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m---> \u001b[39m\u001b[32m34\u001b[39m \u001b[38;5;28mself\u001b[39m.structural = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_tire_params\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_parameters\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mSTRUCTURAL\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
19+
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/Github/simulation_toolkit/.venv/lib/python3.12/site-packages/tire_model/file_processing/_process_tir.py:12\u001b[39m, in \u001b[36m_Processor.get_parameters\u001b[39m\u001b[34m(self, parameter)\u001b[39m\n\u001b[32m 11\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mget_parameters\u001b[39m(\u001b[38;5;28mself\u001b[39m, parameter: \u001b[38;5;28mstr\u001b[39m) -> \u001b[38;5;28mdict\u001b[39m:\n\u001b[32m---> \u001b[39m\u001b[32m12\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_tire\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m1\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[43mparameter\u001b[49m\u001b[43m]\u001b[49m\n",
20+
"\u001b[31mKeyError\u001b[39m: 'STRUCTURAL'"
21+
]
22+
}
23+
],
924
"source": [
1025
"from LHR_tire_toolkit.MF52 import MF52\n",
1126
"\n",
@@ -271,7 +286,7 @@
271286
"name": "python",
272287
"nbconvert_exporter": "python",
273288
"pygments_lexer": "ipython3",
274-
"version": "3.13.7"
289+
"version": "3.13.5"
275290
}
276291
},
277292
"nbformat": 4,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from LHR_tire_toolkit.MF52 import MF52
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
# Load tire model
6+
tire = MF52(
7+
tire_name="",
8+
file_path="./src/_1_model_inputs/Modified_Round_8_Hoosier_R25B_16x7p5_10_on_7in_12psi_PAC02_UM2.tir"
9+
)
10+
11+
FZNOMIN = tire.get_FNOMIN()
12+
13+
# Sweeps
14+
kappa_sweep = np.linspace(-0.10, 0.10, 100)
15+
gamma_sweep = np.linspace(-4, 0, 5) * np.pi / 180
16+
17+
Fx_lst_lst = []
18+
19+
for gamma in gamma_sweep:
20+
Fx_lst = []
21+
for kappa in kappa_sweep:
22+
Fx = tire.tire_eval(FZ=FZNOMIN, alpha=1e-6, kappa=kappa, gamma=gamma)[0]
23+
Fx_lst.append(Fx)
24+
25+
Fx_lst_lst.append(Fx_lst)
26+
27+
# Create 3D plot
28+
fig = plt.figure(figsize=(10, 7))
29+
ax = fig.gca()
30+
31+
for Fx_vals, gamma_val in zip(Fx_lst_lst, gamma_sweep):
32+
print(Fx_vals)
33+
ax.plot(kappa_sweep, Fx_vals, label=rf"$\gamma = {gamma_val * 180 / np.pi}$")
34+
35+
ax.grid()
36+
ax.set_xlim([0, max(kappa_sweep)])
37+
ax.set_ylim([0, max(Fx_lst_lst[0]) * 1.125])
38+
ax.legend()
39+
40+
ax.set_title(r"$ F_{x} \: vs \: \kappa$" + f" at Fz = {FZNOMIN}")
41+
ax.set_xlabel(r"Slip Ratio, $\kappa$")
42+
ax.set_ylabel(r"Longitudinal Force, $F_{x}$ ($N$)")
43+
plt.show()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from LHR_tire_toolkit.MF52 import MF52
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
# Load tire model
6+
tire = MF52(
7+
tire_name="",
8+
file_path="./src/_1_model_inputs/Round_8_Hoosier_R25B_16x7p5_10_on_7in_12psi_PAC02_UM2.tir"
9+
)
10+
11+
FZNOMIN = tire.get_FNOMIN()
12+
13+
# Sweeps
14+
alpha_sweep = np.linspace(-20, 20, 100) * np.pi / 180 # Slip angle (rad)
15+
gamma_sweep = np.linspace(-4, 0, 5) * np.pi / 180 # Camber angle (rad)
16+
17+
Fy_lst_lst = []
18+
19+
for gamma in gamma_sweep:
20+
Fy_lst = []
21+
for alpha in alpha_sweep:
22+
Fy = tire.tire_eval(FZ=FZNOMIN, alpha=alpha, kappa=0, gamma=gamma)[1]
23+
Fy_lst.append(Fy)
24+
25+
Fy_lst_lst.append(Fy_lst)
26+
27+
28+
# Create 3D plot
29+
fig = plt.figure(figsize=(10, 7))
30+
ax = fig.gca()
31+
32+
for Fy_vals, gamma_val in zip(Fy_lst_lst, gamma_sweep):
33+
ax.plot(alpha_sweep * 180 / np.pi, Fy_vals, label=rf"$\gamma = {gamma_val * 180 / np.pi}$")
34+
35+
ax.grid()
36+
ax.set_xlim([0, max(alpha_sweep) * 180 / np.pi])
37+
ax.set_ylim([0, max(Fy_lst_lst[0]) * 1.125])
38+
ax.legend()
39+
40+
ax.set_title(r"$ F_{y} \: vs \: \alpha$" + f" at Fz = {FZNOMIN}")
41+
ax.set_xlabel(r"Slip Angle, $\alpha$ ($deg$)")
42+
ax.set_ylabel(r"Lateral Force, $F_{y}$ ($N$)")
43+
plt.show()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from LHR_tire_toolkit.MF52 import MF52
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
# Load tire model
6+
tire = MF52(
7+
tire_name="",
8+
file_path="./src/_1_model_inputs/Modified_Round_8_Hoosier_R25B_16x7p5_10_on_7in_12psi_PAC02_UM2.tir"
9+
)
10+
11+
# Sweeps
12+
Fz_sweep = np.linspace(100, 1600, 50) # vertical load [N]
13+
alpha_sweep = np.linspace(-30, 30, 50) * np.pi / 180 # slip angle [deg]
14+
15+
# Create meshgrid
16+
Alpha, Fz = np.meshgrid(alpha_sweep, Fz_sweep)
17+
18+
# Compute pneumatic trail
19+
pneu_trail = np.zeros_like(Alpha)
20+
for i in range(Fz.shape[0]):
21+
for j in range(Fz.shape[1]):
22+
pneu_trail[i, j] = tire.get_pneu_trail(FZ=Fz[i, j], alpha=Alpha[i, j])
23+
24+
# Plot
25+
fig = plt.figure(figsize=(10, 7))
26+
ax = fig.add_subplot(111, projection="3d")
27+
surf = ax.plot_surface(Alpha * 180 / np.pi, Fz, pneu_trail, cmap="viridis")
28+
29+
ax.set_xlabel("Slip Angle α [deg]")
30+
ax.set_ylabel("Vertical Load Fz [N]")
31+
ax.set_zlabel("Pneumatic Trail [m]")
32+
ax.set_title("Pneumatic Trail vs Slip Angle & Vertical Load")
33+
34+
fig.colorbar(surf, shrink=0.5, aspect=10, label="Pneumatic Trail [m]")
35+
plt.show()

src/_2_misc_studies/tire_eval.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from LHR_tire_toolkit.MF52 import MF52
2+
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
6+
tire = MF52(tire_name="", file_path="./src/_1_model_inputs/Modified_Round_8_Hoosier_R25B_16x7p5_10_on_7in_12psi_PAC02_UM2.tir")
7+
8+
tire_load = tire.tire_eval(FZ=600, alpha = 5 * np.pi / 180, kappa = 0.15, gamma = 0)
9+
10+
print(tire_load)

src/_4_ico/Modelica_Setting.png

173 KB
Loading

0 commit comments

Comments
 (0)