Note
Go to the end to download the full example code.
Rear Assembly: Swingarm Configuration 1#
#
# *U_SPRING_MOUNT
# / \
# . .
# / \
# /-------------- . ___________-----* SA_LEFT
# / / / /⁻\\
# / ___ .________/ /// \
# / sa_left_outer / / \
# / *----------/ * ___________-------* SA_RIGHT
# \ \ l_spring_mount / /⁻\\
# wheel center* _____________/ /// .
# \ \ / \
# \ *----------/
# \ SA_right_outer
# \
# \
# \---*----------
# Wheel center ground reference
#
Points Name |
Description |
Type |
|---|---|---|
wheel center |
Center of the Wheel |
mobile |
SA RIGHT |
Swingarm Right |
fixed |
SA LEFT |
Swingarm Left |
fixed |
sa right outer |
Swingarm right outer |
mobile |
sa left outer |
Swingarm left outer |
mobile |
U SPRING MOUNT |
Upper spring mount |
fixed |
l spring mount |
lower spring mount |
mobile |
Import necessary libraries#
import os
import numpy as np
from pymycar.MotorCycleKinematic import rear_bike_base_cantilever
data = {
# --- Front assembly ---
"wheel_center_front": np.array([650.0, 0.0, -520.0]),
"STEERING_AXIS_BOTTOM": np.array([650.0, 0.0, -100.0]),
"STEERING_AXIS_TOP": np.array([570.0, 0.0, 250.0]),
"fork_right_upper": np.array([570.0, -110.0, 250.0]),
"fork_left_upper": np.array([570.0, 110.0, 250.0]),
"fork_right_bottom": np.array([650.0, -120.0, -520.0]),
"fork_left_bottom": np.array([650.0, 120.0, -520.0]),
# --- Rear assembly ---
"wheel_center_rear": np.array([-600.0, 0.0, -520.0]),
"SA_RIGHT": np.array([-100.0, -90.0, -300.0]),
"SA_LEFT": np.array([-100.0, 90.0, -300.0]),
"sa_right_outer": np.array([-600.0, -110.0, -520.0]),
"sa_left_outer": np.array([-600.0, 110.0, -520.0]),
"U_SPRING_MOUNT": np.array([-150.0, 0.0, 50.0]),
"l_spring_mount": np.array([-420.0, 0.0, -350.0]),
}
# file_path = 'data.suspgeo'
# data = load_defined_geometry("double_whisbone_base/input_geometry.suspgeo")
Call the Solver#
solution, wheel_variables = rear_bike_base_cantilever(data,
max_height_increase=400,
max_height_decrease=400,
height_step=1.0,
save_to_txt=True,
result_folder_name="bike",
path = None)
import pyvista as pv
from pymycar.Cad.MotorCycle.rear_assembly import swingarm_cad_base
from pymycar.Cad.MotorCycle.frame import frame_cad_base
from pymycar.Cad.MotorCycle.rear_assembly import rear_suspension_cantilever
frame = frame_cad_base(data, index=None)
last_meshes = []
def plot_frame(plotter, data, index=None):
global last_meshes
if index is None:
index = data["index_reference"]
# swingarm, wheel_center1 = swingarm_cad_base(data, index)
swingarm = swingarm_cad_base(data, index)
suspension = rear_suspension_cantilever(data, index)
# Remove the last meshes
for mesh in last_meshes:
plotter.remove_actor(mesh)
# Add new meshes
last_meshes = [
# plotter.add_mesh(wheel_center1, color="black"),
plotter.add_mesh(frame, color="red"),
plotter.add_mesh(swingarm, color="blue"),
plotter.add_mesh(suspension, color="green"),
# plotter.add_mesh(lower_control_arm, color="pink"),
# plotter.add_mesh(direction, color="green"),
# plotter.add_mesh(wheel, color="black", opacity=0.5)
]
plotter = pv.Plotter()
def create_mesh(value):
res = np.abs(solution["wheel_center_rear"][:,2] - value).argmin()
plot_frame(plotter, solution, index=res)
plotter.add_slider_widget(create_mesh,
rng=[solution["wheel_center_rear"][0, 2], solution["wheel_center_rear"][-1, 2]],
value=solution["wheel_center_rear"][solution["index_reference"]][2],
title='Jounce')
plotter.show()

All specified files deleted successfully.
All specified folders and their contents deleted successfully.
Deleted folder and its contents: /home/docs/checkouts/readthedocs.org/user_builds/pymycar/checkouts/latest/examples/MotorcycleKinematics/bike
All specified folders and their contents deleted successfully.
/home/docs/checkouts/readthedocs.org/user_builds/pymycar/checkouts/latest/src/pymycar/CarKinematic/functions.py:89: RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last ten iterations.
initial_guess = fsolve(residual,
/home/docs/checkouts/readthedocs.org/user_builds/pymycar/checkouts/latest/src/pymycar/CarKinematic/functions.py:105: RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last ten iterations.
initial_guess = fsolve(residual, initial_guess, args=(wheel_center_z), fprime=jacobian,col_deriv=0,
/home/docs/checkouts/readthedocs.org/user_builds/pymycar/checkouts/latest/src/pymycar/CarKinematic/functions.py:105: RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last five Jacobian evaluations.
initial_guess = fsolve(residual, initial_guess, args=(wheel_center_z), fprime=jacobian,col_deriv=0,
Total running time of the script: (0 minutes 3.798 seconds)