engineeringkit.mechanical_engineering#
Moments of inertia and the parallel-axis theorem, work, kinetic energy,
power and flywheels, and Lagrange’s equations by numerical differentiation;
gear trains, the Lewis bending stress with Barth’s factor and the
Euler-Eytelwein belt-friction law; Coulomb’s square-thread power screw,
Petroff’s journal-bearing torque, the Sommerfeld number and long-bearing
eccentricity, the Lundberg-Palmgren \(L_{10}\) life, shafts in combined
bending and torsion (static and Goodman), helical springs with the Wahl
factor and preloaded bolted joints; the slider-crank, Grashof’s condition,
four-bar loop closure, velocity and acceleration analysis and Freudenstein
synthesis, cam displacement laws and Denavit-Hartenberg forward kinematics;
the damped oscillator (scipy.integrate.solve_ivp), the forced
magnification factor and phase, transmissibility, normal modes
(scipy.linalg.eigh) and modal superposition, Rayleigh’s and Dunkerley’s
frequency bounds, Frahm and Den Hartog vibration absorbers and Holzer’s
torsional method (scipy.optimize.brentq); the Jeffcott rotor and
one- and two-plane balancing.
engineeringkit.mechanical_engineering: dynamics, machines, mechanisms and vibration.
Moments of inertia, work, energy and power, and Lagrange’s equations; gear trains, Lewis’s gear-tooth bending stress and the Euler-Eytelwein belt-friction law; Coulomb’s power screw, Petroff’s and Sommerfeld’s journal bearings, the Lundberg-Palmgren rolling-bearing life, shafts in combined bending and torsion, helical springs with Wahl’s factor and preloaded bolted joints; the slider-crank, Grashof’s condition, four-bar velocity and acceleration analysis, Freudenstein’s synthesis, cam displacement laws and Denavit-Hartenberg forward kinematics; the damped and forced oscillator, normal modes and modal superposition, Rayleigh’s and Dunkerley’s estimates, the tuned vibration absorber, Holzer’s torsional method, the Jeffcott rotor and the balancing of rotating masses. Models are hand-written closed forms; SciPy’s ODE integrator and root finder are used where they are the standard tool.
- class engineeringkit.mechanical_engineering.BalanceResult(mass_radius, angle, plane_positions)[source]#
Bases:
objectCorrection masses that balance a set of rotating masses on a shaft.
- Parameters:
mass_radius (ndarray)
angle (ndarray)
plane_positions (ndarray)
- angle: ndarray#
Angular position of each correction [rad], in (-pi, pi].
- Type:
ndarray
- mass_radius: ndarray#
Correction mass times its radius in each correction plane [kg m].
- Type:
ndarray
- plane_positions: ndarray#
Axial positions of the correction planes [m]; empty for static (one-plane) balance.
- Type:
ndarray
- class engineeringkit.mechanical_engineering.BoltedJoint(bolt_stiffness, member_stiffness, preload, load)[source]#
Bases:
objectA preloaded bolt and the members it clamps, carrying an external separating load.
Built by
engineeringkit.mechanical_engineering.bolted_joint(). Bolt and members act as springs in parallel under the external load \(P\): the bolt takes the share \(CP\) of it, with joint constant \(C = k_b/(k_b + k_m)\), and the members lose the rest of their clamping force until they separate.- Parameters:
bolt_stiffness (float)
member_stiffness (float)
preload (float)
load (float)
- property bolt_load: float#
Bolt tension \(F_i + CP\) [N]; once the members separate it carries the whole load \(P\).
- Type:
float
- bolt_stiffness: float#
\(k_b\) [N/m].
- Type:
float
- property joint_constant: float#
\(C = k_b/(k_b + k_m)\) [-].
- Type:
float
- load: float#
External separating load \(P\) [N].
- Type:
float
- load_factor(proof_load)[source]#
Factor on the external load before the bolt reaches its proof load.
- Parameters:
proof_load (float) – \(F_p = S_p A_t\) [N], positive and above the preload.
- Returns:
\(n_L = (F_p - F_i)/(CP)\) [-].
- Return type:
float
- property member_load: float#
Member compression \(F_i - (1 - C)P\) [N], zero once separated.
- Type:
float
- member_stiffness: float#
\(k_m\) [N/m].
- Type:
float
- preload: float#
Initial clamping force \(F_i\) [N].
- Type:
float
- property separation_load: float#
External load \(P_0 = F_i/(1 - C)\) at which the members part [N].
- Type:
float
- class engineeringkit.mechanical_engineering.CamMotion(theta, displacement, velocity, acceleration, jerk, law)[source]#
Bases:
objectFollower displacement and its derivatives with respect to cam angle over one rise.
- Parameters:
theta (ndarray)
displacement (ndarray)
velocity (ndarray)
acceleration (ndarray)
jerk (ndarray)
law (str)
- acceleration: ndarray#
\(d^2s/d\theta^2\) [m/rad^2]; multiply by \(\omega^2\) for m/s^2.
- Type:
ndarray
- displacement: ndarray#
Follower lift [m].
- Type:
ndarray
- jerk: ndarray#
\(d^3s/d\theta^3\) [m/rad^3]; multiply by \(\omega^3\) for m/s^3.
- Type:
ndarray
- law: str#
Name of the displacement law.
- Type:
str
- summary()[source]#
Law, lift [m] and peak absolute velocity, acceleration and jerk per radian of cam.
- Return type:
dict
- theta: ndarray#
Cam angle from the start of the rise [rad].
- Type:
ndarray
- velocity: ndarray#
\(ds/d\theta\) [m/rad]; multiply by \(\omega\) for m/s.
- Type:
ndarray
- class engineeringkit.mechanical_engineering.FourBarMotion(theta2, theta3, theta4, omega3, omega4, alpha3, alpha4)[source]#
Bases:
objectPositions, angular velocities and angular accelerations of a four-bar linkage.
- Parameters:
theta2 (ndarray)
theta3 (ndarray)
theta4 (ndarray)
omega3 (ndarray)
omega4 (ndarray)
alpha3 (ndarray)
alpha4 (ndarray)
- alpha3: ndarray#
Coupler angular acceleration [rad/s^2].
- Type:
ndarray
- alpha4: ndarray#
Output angular acceleration [rad/s^2].
- Type:
ndarray
- omega3: ndarray#
Coupler angular velocity [rad/s].
- Type:
ndarray
- omega4: ndarray#
Output angular velocity [rad/s].
- Type:
ndarray
- plot(ax=None)[source]#
Plot output angular velocity and acceleration against crank angle; return
(fig, ax).
- summary()[source]#
Peak absolute output angular velocity [rad/s] and acceleration [rad/s^2].
- Return type:
dict
- theta2: ndarray#
Input crank angle [rad].
- Type:
ndarray
- theta3: ndarray#
Coupler angle [rad].
- Type:
ndarray
- theta4: ndarray#
Output link angle [rad].
- Type:
ndarray
- class engineeringkit.mechanical_engineering.HolzerResult(frequencies, mode_shapes)[source]#
Bases:
objectNatural frequencies and mode shapes of a free-free torsional chain.
- Parameters:
frequencies (ndarray)
mode_shapes (ndarray)
- frequencies: ndarray#
Nonzero natural frequencies in increasing order [rad/s].
- Type:
ndarray
- mode_shapes: ndarray#
Disk twist amplitudes, one row per mode, largest entry 1 [-].
- Type:
ndarray
- class engineeringkit.mechanical_engineering.JeffcottResult(omega, amplitude, phase, critical_speed, eccentricity)[source]#
Bases:
objectSteady synchronous whirl of an unbalanced disk on a flexible shaft.
- Parameters:
omega (ndarray)
amplitude (ndarray)
phase (ndarray)
critical_speed (float)
eccentricity (float)
- amplitude: ndarray#
Whirl radius of the shaft centre [m].
- Type:
ndarray
- critical_speed: float#
\(\sqrt{k/m}\) [rad/s].
- Type:
float
- eccentricity: float#
Distance from shaft centre to disk mass centre [m].
- Type:
float
- omega: ndarray#
Spin speeds [rad/s].
- Type:
ndarray
- phase: ndarray#
Angle by which the whirl lags the unbalance [rad], in [0, pi].
- Type:
ndarray
- class engineeringkit.mechanical_engineering.MDOFResult(t, displacement, velocity)[source]#
Bases:
objectTime history of a system with several (generalised) coordinates.
- Parameters:
t (ndarray)
displacement (ndarray)
velocity (ndarray)
- displacement: ndarray#
Coordinates at each sample, shape
(len(t), n)[m or rad].- Type:
ndarray
- t: ndarray#
Time samples [s].
- Type:
ndarray
- velocity: ndarray#
Coordinate rates at each sample, shape
(len(t), n)[m/s or rad/s].- Type:
ndarray
- class engineeringkit.mechanical_engineering.ModalResult(frequencies, mode_shapes)[source]#
Bases:
objectNatural frequencies and mass-normalised mode shapes of an undamped M-K system.
- Parameters:
frequencies (ndarray)
mode_shapes (ndarray)
- frequencies: ndarray#
Natural frequencies in increasing order [rad/s]; zero for rigid-body modes.
- Type:
ndarray
- mode_shapes: ndarray#
One row per mode, scaled so \(\phi^T M \phi = 1\) and the largest entry is positive.
- Type:
ndarray
- class engineeringkit.mechanical_engineering.SDOFResult(t, displacement, velocity)[source]#
Bases:
objectTime history of a single-degree-of-freedom oscillator.
- Parameters:
t (ndarray)
displacement (ndarray)
velocity (ndarray)
- animate(interval=30)[source]#
Animate the mass; see
engineeringkit.visualizers.animate_displacement().- Parameters:
interval (float, optional) – Delay between frames [ms], positive.
- Returns:
(fig, animation).- Return type:
tuple
- displacement: ndarray#
Displacement at each sample [m].
- Type:
ndarray
- property history: ndarray#
Displacement and velocity as columns, shape
(len(t), 2).- Type:
ndarray
- t: ndarray#
Time samples [s].
- Type:
ndarray
- velocity: ndarray#
Velocity at each sample [m/s].
- Type:
ndarray
- class engineeringkit.mechanical_engineering.SliderCrankMotion(theta, position, velocity, acceleration, rod_angle, rod_angular_velocity, rod_angular_acceleration)[source]#
Bases:
objectSlider and connecting-rod motion of an in-line slider-crank.
- Parameters:
theta (ndarray)
position (ndarray)
velocity (ndarray)
acceleration (ndarray)
rod_angle (ndarray)
rod_angular_velocity (ndarray)
rod_angular_acceleration (ndarray)
- acceleration: ndarray#
Slider acceleration [m/s^2].
- Type:
ndarray
- plot(ax=None)[source]#
Plot slider velocity and acceleration against crank angle on twin axes; return
(fig, ax).
- position: ndarray#
Slider position from the crank axis [m].
- Type:
ndarray
- rod_angle: ndarray#
Connecting-rod angle to the line of stroke [rad].
- Type:
ndarray
- rod_angular_acceleration: ndarray#
Second rate of change of
rod_angle[rad/s^2].- Type:
ndarray
- rod_angular_velocity: ndarray#
Rate of change of
rod_angle[rad/s].- Type:
ndarray
- theta: ndarray#
Crank angle from top dead centre [rad].
- Type:
ndarray
- velocity: ndarray#
Slider velocity [m/s].
- Type:
ndarray
- class engineeringkit.mechanical_engineering.TunedMassDamper(primary_mass, primary_stiffness, absorber_mass, absorber_stiffness, absorber_damping, mass_ratio, frequency_ratio, damping_ratio)[source]#
Bases:
objectA primary mass-spring system carrying a damped vibration absorber.
Built by
engineeringkit.mechanical_engineering.tuned_mass_damper(). The primary mass \(m_1\) on stiffness \(k_1\) is driven by a harmonic force; the absorber \(m_2\) is attached to it through \(k_2\) and a dashpot \(c_2\).- Parameters:
primary_mass (float)
primary_stiffness (float)
absorber_mass (float)
absorber_stiffness (float)
absorber_damping (float)
mass_ratio (float)
frequency_ratio (float)
damping_ratio (float)
- absorber_damping: float#
\(c_2\) [N s/m].
- Type:
float
- absorber_mass: float#
\(m_2\) [kg].
- Type:
float
- absorber_stiffness: float#
\(k_2\) [N/m].
- Type:
float
- amplification(r)[source]#
Primary amplitude over static deflection, \(|X_1| k_1 / F_0\).
- Parameters:
r (float or array_like) – Forcing frequency over \(\omega_1\) [-], nonnegative.
- Returns:
Amplification [-].
- Return type:
float or ndarray
- damping_ratio: float#
\(c_2 / (2 m_2 \omega_1)\) [-], Den Hartog’s convention.
- Type:
float
- frequency_ratio: float#
Absorber natural frequency over primary natural frequency [-].
- Type:
float
- mass_ratio: float#
\(\mu = m_2/m_1\) [-].
- Type:
float
- plot(r=None, ax=None)[source]#
Plot amplification with and without the absorber; return
(fig, ax).- Parameters:
r (array_like, optional) – Forcing frequency ratios [-]; 0.5 to 1.5 if omitted.
ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.
- Returns:
(fig, ax).- Return type:
tuple
- property primary_frequency: float#
\(\omega_1 = \sqrt{k_1/m_1}\) [rad/s].
- Type:
float
- primary_mass: float#
\(m_1\) [kg].
- Type:
float
- primary_stiffness: float#
\(k_1\) [N/m].
- Type:
float
- engineeringkit.mechanical_engineering.angular_momentum(I, omega)[source]#
Angular momentum \(H = I\omega\) about a fixed axis.
- Parameters:
I (float or array_like) – Moment of inertia [kg m^2], positive.
omega (float or array_like) – Angular speed [rad/s].
- Returns:
Angular momentum [kg m^2/s].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> angular_momentum(2.0, 3.0) 6.0
- engineeringkit.mechanical_engineering.balance_rotating_masses(masses, radii, angles, positions=None, planes=None)[source]#
Correction masses for static (one-plane) or dynamic (two-plane) balance.
Without
positionsandplanesone correction cancels the force, \(m_c r_c e^{i\theta_c} = -\sum m_i r_i e^{i\theta_i}\). With them, corrections \(U_L\) and \(U_R\) at \(z_L\) and \(z_R\) cancel force and couple: moments about plane \(L\) give\[U_R = -\frac{\sum m_i r_i (z_i - z_L) e^{i\theta_i}}{z_R - z_L}, \qquad U_L = -\sum m_i r_i e^{i\theta_i} - U_R\]- Parameters:
masses (array_like) – Rotating masses [kg], nonnegative.
radii (array_like) – Their radii [m], nonnegative.
angles (array_like) – Their angular positions [rad].
positions (array_like, optional) – Their axial positions [m]; give with
planesfor dynamic balance.planes (array_like, optional) – Axial positions \((z_L, z_R)\) of the two correction planes [m], distinct.
- Returns:
Correction mass-radius product [kg m] and angle [rad] in each plane.
- Return type:
Notes
The rotor is rigid: the corrections hold at every speed below the first bending critical speed. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
Dalby, The Balancing of Engines (Edward Arnold, London, 1902).
Examples
>>> result = balance_rotating_masses([2.0], [0.1], [np.pi / 2]) >>> round(float(result.mass_radius[0]), 12), round(float(result.angle[0]), 12) (0.2, -1.570796326795)
- engineeringkit.mechanical_engineering.barth_velocity_factor(pitch_line_velocity, profile='cut')[source]#
Barth’s dynamic factor \(K_v\) for spur gears running at speed.
profile
\(K_v\)
cast
\((3.05 + V)/3.05\)
cut
\((6.1 + V)/6.1\)
hobbed
\((3.56 + \sqrt V)/3.56\)
ground
\(\sqrt{(5.56 + \sqrt V)/5.56}\)
- Parameters:
pitch_line_velocity (float or array_like) – \(V\) [m/s], nonnegative.
profile ({"cast", "cut", "hobbed", "ground"}, optional) – How the tooth profile was made.
- Returns:
\(K_v\) [-], one at rest.
- Return type:
float or ndarray
Notes
The constants are the SI forms of Barth’s 1900-era empirical fits, as in Shigley’s equation 14-4. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> float(barth_velocity_factor(6.1)) 2.0
- engineeringkit.mechanical_engineering.bearing_l10_life(C, P, p=3)[source]#
Lundberg-Palmgren rating life \(L_{10} = (C/P)^p\) of a rolling bearing.
- Parameters:
C (float or array_like) – Basic dynamic load rating [N], positive.
P (float or array_like) – Equivalent dynamic load [N], positive.
p (float, optional) – Life exponent [-], positive: 3 for ball bearings, 10/3 for roller bearings.
- Returns:
Revolutions that 90% of a large group of identical bearings complete before the first sign of fatigue.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
G. Lundberg and A. Palmgren, “Dynamic capacity of rolling bearings,” Acta Polytech. Mech. Eng. Ser. 1, no. 3 (1947).
Examples
>>> bearing_l10_life(2.0, 1.0) 8000000.0
- engineeringkit.mechanical_engineering.belt_speed(diameter, rpm)[source]#
Linear speed \(v = \pi D n / 60\) of a belt on a pulley.
- Parameters:
diameter (float or array_like) – Pitch diameter of the pulley [m], positive.
rpm (float or array_like) – Pulley speed [rev/min].
- Returns:
Belt speed [m/s].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata, except the speed in rev/min; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(belt_speed(1.0, 60.0)), 6) 3.141593
- engineeringkit.mechanical_engineering.belt_tension_ratio(mu, wrap_angle, groove_angle=None)[source]#
Euler-Eytelwein ratio of tight-side to slack-side tension at the point of slip.
\[\frac{T_1}{T_2} = \exp\!\left(\frac{\mu\theta}{\sin(\beta/2)}\right)\]- Parameters:
mu (float or array_like) – Coulomb friction coefficient between belt and pulley [-], nonnegative.
wrap_angle (float or array_like) – Angle of contact \(\theta\) [rad], nonnegative.
groove_angle (float, optional) – Included angle \(\beta\) of a V-belt groove [rad] in (0, pi). Omit for a flat belt or rope on a drum (\(\sin(\beta/2) = 1\)).
- Returns:
\(T_1/T_2\) [-], at least one.
- Return type:
float or ndarray
Notes
The belt is massless (no centrifugal tension) and inextensible. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
L. Euler, “Remarques sur l’effect du frottement dans l’équilibre,” Mém. Acad. Sci. Berlin 18 (1762, published 1769) 265-278; J. A. Eytelwein, Handbuch der Statik fester Körper (Berlin, 1808).
Examples
>>> round(float(belt_tension_ratio(0.3, np.pi)), 4) 2.5663
- engineeringkit.mechanical_engineering.bergstrasser_factor(C)[source]#
Bergsträsser’s factor \(K_B = (4C + 2)/(4C - 3)\), a simpler fit to the same stress.
- Parameters:
C (float or array_like) – Spring index [-], greater than one.
- Returns:
\(K_B\) [-], 0.7% to 1.5% below
wahl_factor()for \(3 \le C \le 12\).- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(bergstrasser_factor(6.0)), 4) 1.2381
- engineeringkit.mechanical_engineering.bolt_stiffness(E, shank_area, shank_length, thread_area, thread_length)[source]#
Axial stiffness of a bolt’s unthreaded shank and threaded length in series.
\[k_b = \frac{A_d A_t E}{A_d l_t + A_t l_d}\]- Parameters:
E (float) – Young’s modulus of the bolt [Pa], positive.
shank_area (float) – Major-diameter area \(A_d\) [m^2], positive.
shank_length (float) – Unthreaded length within the grip \(l_d\) [m], nonnegative.
thread_area (float) – Tensile-stress area \(A_t\) [m^2], positive.
thread_length (float) – Threaded length within the grip \(l_t\) [m], nonnegative.
- Returns:
\(k_b\) [N/m].
- Return type:
float
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(bolt_stiffness(200e9, 1e-4, 0.0, 1e-4, 0.05) / 1e6, 6) 400.0
- engineeringkit.mechanical_engineering.bolted_joint(bolt_stiffness, member_stiffness, preload, load)[source]#
Share an external separating load between a preloaded bolt and its members.
- Parameters:
bolt_stiffness (float) – \(k_b\) [N/m], positive (see
bolt_stiffness()).member_stiffness (float) – \(k_m\) [N/m], positive (see
member_stiffness()).preload (float) – Initial tension \(F_i\) [N], nonnegative.
load (float) – External tensile load on the joint \(P\) [N], positive.
- Returns:
Joint constant, bolt and member loads, separation load and
load_factor(proof_load).- Return type:
Notes
The members are assumed to stay in contact, and the load to act at the interfaces under the head and nut, until separation. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> joint = bolted_joint(1e9, 3e9, 20e3, 8e3) >>> joint.joint_constant, joint.bolt_load, joint.member_load (0.25, 22000.0, 14000.0)
- engineeringkit.mechanical_engineering.cam_follower_motion(theta, lift, rise_angle, law='cycloidal')[source]#
Follower displacement, velocity, acceleration and jerk over a cam rise.
With \(u = \theta/\beta\), the laws are
law
\(s/L\)
uniform\(u\)
parabolic\(2u^2\) then \(1 - 2(1 - u)^2\)
harmonic\((1 - \cos\pi u)/2\)
cycloidal\(u - \sin(2\pi u)/2\pi\)
polynomial_345\(10u^3 - 15u^4 + 6u^5\)
polynomial_4567\(35u^4 - 84u^5 + 70u^6 - 20u^7\)
- Parameters:
theta (float or array_like) – Cam angle from the start of the rise [rad], in [0,
rise_angle].lift (float) – Total rise \(L\) [m], positive.
rise_angle (float) – Cam angle \(\beta\) over which the rise happens [rad], positive.
law (str, optional) – One of the names above.
- Returns:
\(s\) [m] and \(ds/d\theta\), \(d^2s/d\theta^2\), \(d^3s/d\theta^3\) [m/rad^k]. The return from \(L\) to zero is \(L - s\).
- Return type:
Notes
The jumps in acceleration (parabolic) or velocity (uniform) where a law meets a dwell are not represented as impulses. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> motion = cam_follower_motion([0.0, np.pi / 4, np.pi / 2], 0.01, np.pi / 2) >>> np.round(motion.displacement, 6).tolist() [0.0, 0.005, 0.01]
- engineeringkit.mechanical_engineering.centripetal_force(m, v, r)[source]#
Force \(m v^2 / r\) that holds a mass on a circular path.
- Parameters:
m (float or array_like) – Mass [kg], positive.
v (float or array_like) – Tangential speed [m/s].
r (float or array_like) – Path radius [m], positive.
- Returns:
Force directed toward the centre [N].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> centripetal_force(2.0, 3.0, 1.0) 18.0
- engineeringkit.mechanical_engineering.damped_frequency(k, m, c)[source]#
Damped natural frequency \(\omega_d = \omega_n\sqrt{1 - \zeta^2}\).
- Parameters:
k (float or array_like) – Stiffness [N/m], positive.
m (float or array_like) – Mass [kg], positive.
c (float or array_like) – Viscous damping coefficient [N s/m], nonnegative.
- Returns:
Frequency of the decaying oscillation [rad/s]; zero at or above critical damping, where the motion does not oscillate.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(damped_frequency(4.0, 1.0, 0.4)), 6) 1.989975
- engineeringkit.mechanical_engineering.damping_ratio(c, k, m)[source]#
Damping ratio \(\zeta = c / (2\sqrt{km})\), the fraction of critical damping.
- Parameters:
c (float or array_like) – Viscous damping coefficient [N s/m], nonnegative.
k (float or array_like) – Stiffness [N/m], positive.
m (float or array_like) – Mass [kg], positive.
- Returns:
Damping ratio [-]; one is critical damping.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> float(damping_ratio(4.0, 4.0, 1.0)) 1.0
- engineeringkit.mechanical_engineering.dh_transform(a, alpha, d, theta)[source]#
Denavit-Hartenberg homogeneous transform from one link frame to the next.
\[\begin{split}T = R_z(\theta)\,T_z(d)\,T_x(a)\,R_x(\alpha) = \begin{bmatrix} \cos\theta & -\sin\theta\cos\alpha & \sin\theta\sin\alpha & a\cos\theta \\ \sin\theta & \cos\theta\cos\alpha & -\cos\theta\sin\alpha & a\sin\theta \\ 0 & \sin\alpha & \cos\alpha & d \\ 0 & 0 & 0 & 1 \end{bmatrix}\end{split}\]- Parameters:
a (float) – Link length along the new x axis [m].
alpha (float) – Link twist about the new x axis [rad].
d (float) – Joint offset along the old z axis [m].
theta (float) – Joint angle about the old z axis [rad].
- Returns:
4 by 4 transform; its upper-left 3 by 3 block is a rotation matrix.
- Return type:
ndarray
Notes
Uses the original (distal) convention. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
J. Denavit and R. S. Hartenberg, “A kinematic notation for lower-pair mechanisms based on matrices,” J. Appl. Mech. 22 (1955) 215-221.
Examples
>>> dh_transform(1.0, 0.0, 0.0, np.pi / 2).round(12)[:2, 3].tolist() [0.0, 1.0]
- engineeringkit.mechanical_engineering.disk_inertia(m, r)[source]#
Moment of inertia \(\tfrac12 m r^2\) of a uniform disk about its axis.
- Parameters:
m (float or array_like) – Mass [kg], positive.
r (float or array_like) – Radius [m], positive.
- Returns:
Moment of inertia [kg m^2].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> disk_inertia(2.0, 1.0) 1.0
- engineeringkit.mechanical_engineering.dunkerley_frequency(masses, flexibility)[source]#
Dunkerley’s lower bound \(1/\omega^2 \approx \sum_i m_i a_{ii}\) on the fundamental frequency.
Each term \(m_i a_{ii} = 1/\omega_i^2\) is the inverse square of the frequency the shaft would have with mass \(i\) alone on it.
- Parameters:
masses (array_like) – Lumped masses [kg], positive.
flexibility (array_like) – Influence coefficients \(a_{ij}\) [m/N]: deflection at station \(i\) per unit force at \(j\), symmetric
(n, n).
- Returns:
Estimated fundamental frequency [rad/s], never above the true one.
- Return type:
float
Notes
The sum is the trace of the dynamic matrix \(A M\), the sum of every \(1/\omega_r^2\), so the estimate is close when the higher modes are well separated from the first. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
S. Dunkerley, “On the whirling and vibration of shafts,” Phil. Trans. R. Soc. Lond. A 185 (1894) 279-360.
Examples
>>> round(dunkerley_frequency([1.0, 1.0], [[2 / 3, 1 / 3], [1 / 3, 2 / 3]]), 12) 0.866025403784
- engineeringkit.mechanical_engineering.flywheel_energy(I, w1, w2)[source]#
Energy a flywheel releases slowing from \(\omega_1\) to \(\omega_2\).
\[\Delta E = \tfrac12 I (\omega_1^2 - \omega_2^2)\]- Parameters:
I (float or array_like) – Moment of inertia [kg m^2], positive.
w1 (float or array_like) – Initial and final angular speeds [rad/s].
w2 (float or array_like) – Initial and final angular speeds [rad/s].
- Returns:
Energy released [J]; negative if the flywheel speeds up.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> flywheel_energy(2.0, 3.0, 1.0) 8.0
- engineeringkit.mechanical_engineering.forward_kinematics(dh_table)[source]#
Frames of a serial chain from its Denavit-Hartenberg table.
- Parameters:
dh_table (array_like) – Shape
(n, 4): one row[a, alpha, d, theta]per joint (lengths [m], angles [rad]).- Returns:
Shape
(n + 1, 4, 4): the base frame (identity) followed by the cumulative transform \(T_1 T_2 \cdots T_k\) of each link. The last frame’s column[:3, 3]is the end-effector position.- Return type:
ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> frames = forward_kinematics([[1.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, np.pi / 2]]) >>> frames[-1][:2, 3].round(12).tolist() [1.0, 1.0]
- engineeringkit.mechanical_engineering.fourbar_grashof(lengths)[source]#
Grashof’s condition \(s + l \le p + q\) for a four-bar chain.
- Parameters:
lengths (array_like) – The four link lengths [m], positive, in any order.
- Returns:
True if the shortest link \(s\) can rotate fully relative to the others. Which link is grounded then decides crank-rocker, double crank or double rocker. If False, no link rotates fully.
- Return type:
bool
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
Grashof, Theoretische Maschinenlehre, vol. 2 (Voss, Leipzig, 1883).
Examples
>>> fourbar_grashof([1.0, 2.0, 2.0, 3.0]) True
- engineeringkit.mechanical_engineering.fourbar_kinematics(a, b, c, d, theta2, omega2, alpha2=0.0, crossed=False)[source]#
Angles, angular velocities and angular accelerations of a four-bar linkage.
Differentiating the loop closure \(a e^{i\theta_2} + b e^{i\theta_3} = d + c e^{i\theta_4}\) gives
\[i b\omega_3 e^{i\theta_3} - i c\omega_4 e^{i\theta_4} = -i a\omega_2 e^{i\theta_2}\]and, once more,
\[i b\alpha_3 e^{i\theta_3} - i c\alpha_4 e^{i\theta_4} = -(i\alpha_2 - \omega_2^2) a e^{i\theta_2} + b\omega_3^2 e^{i\theta_3} - c\omega_4^2 e^{i\theta_4},\]each a pair of real linear equations. The velocity solution is \(\omega_4/\omega_2 = a\sin(\theta_3 - \theta_2)/(c\sin(\theta_3 - \theta_4))\).
- Parameters:
a (float) – Input, coupler, output and ground link lengths [m], positive, as for
fourbar_output_angle().b (float) – Input, coupler, output and ground link lengths [m], positive, as for
fourbar_output_angle().c (float) – Input, coupler, output and ground link lengths [m], positive, as for
fourbar_output_angle().d (float) – Input, coupler, output and ground link lengths [m], positive, as for
fourbar_output_angle().theta2 (float or array_like) – Input crank angle [rad].
omega2 (float) – Input angular velocity [rad/s].
alpha2 (float, optional) – Input angular acceleration [rad/s^2].
crossed (bool, optional) – False for the open circuit, True for the crossed circuit.
- Returns:
\(\theta_{2,3,4}\) [rad], \(\omega_{3,4}\) [rad/s] and \(\alpha_{3,4}\) [rad/s^2]; infinite at a change point, where coupler and output are in line.
- Return type:
- Raises:
ValueError – If the linkage cannot be assembled at some
theta2.
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> motion = fourbar_kinematics(1.0, 3.0, 2.0, 3.0, np.pi / 2, 1.0) >>> round(float(motion.omega4), 6) 0.487298
- engineeringkit.mechanical_engineering.fourbar_output_angle(a, b, c, d, theta2, crossed=False)[source]#
Output-rocker angle of a four-bar linkage from its loop-closure equation.
The ground link \(d\) lies along the x axis from the input pivot to the output pivot. The input crank \(a\) at angle \(\theta_2\) and the output link \(c\) at angle \(\theta_4\) are joined by the coupler \(b\):
\[a e^{i\theta_2} + b e^{i\theta_3} = d + c e^{i\theta_4}\]- Parameters:
a (float) – Input, coupler, output and ground link lengths [m], positive.
b (float) – Input, coupler, output and ground link lengths [m], positive.
c (float) – Input, coupler, output and ground link lengths [m], positive.
d (float) – Input, coupler, output and ground link lengths [m], positive.
theta2 (float or array_like) – Input crank angle [rad].
crossed (bool, optional) – False for the open circuit, True for the crossed circuit.
- Returns:
\(\theta_4\) [rad] in (-pi, pi].
- Return type:
float or ndarray
- Raises:
ValueError – If the linkage cannot be assembled at some
theta2.
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(np.degrees(fourbar_output_angle(1.0, 3.0, 2.0, 3.0, np.pi / 2))), 4) 94.8488
- engineeringkit.mechanical_engineering.freudenstein_coefficients(input_angles, output_angles)[source]#
Freudenstein’s coefficients from prescribed input and output angles.
Freudenstein’s equation
\[K_1\cos\theta_4 - K_2\cos\theta_2 + K_3 = \cos(\theta_2 - \theta_4)\]with \(K_1 = d/a\), \(K_2 = d/c\) and \(K_3 = (a^2 - b^2 + c^2 + d^2)/(2ac)\) is linear in the \(K\). Three precision points determine them exactly; more are fitted by least squares.
- Parameters:
input_angles (array_like) – Matching crank angles \(\theta_2\) and rocker angles \(\theta_4\) [rad], at least three pairs.
output_angles (array_like) – Matching crank angles \(\theta_2\) and rocker angles \(\theta_4\) [rad], at least three pairs.
- Returns:
[K1, K2, K3][-].- Return type:
ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
F. Freudenstein, “An analytical approach to the design of four-link mechanisms,” Trans. ASME 76 (1954) 483-492.
Examples
>>> t2 = np.radians([40.0, 70.0, 100.0]) >>> t4 = fourbar_output_angle(1.0, 3.0, 2.0, 3.0, t2) >>> np.round(freudenstein_coefficients(t2, t4), 6).tolist() [3.0, 1.5, 1.25]
- engineeringkit.mechanical_engineering.freudenstein_link_lengths(K, ground=1.0)[source]#
Four-bar link lengths
(a, b, c, d)from Freudenstein’s coefficients.- Parameters:
K (array_like) –
[K1, K2, K3]fromfreudenstein_coefficients().ground (float, optional) – Ground link length \(d\) [m], positive; it sets the scale.
- Returns:
Input, coupler, output and ground lengths [m].
- Return type:
ndarray
- Raises:
ValueError – If
K1orK2is not positive (a link of negative length) or no real coupler exists.
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> freudenstein_link_lengths([3.0, 1.5, 1.25], ground=3.0).round(6).tolist() [1.0, 3.0, 2.0, 3.0]
- engineeringkit.mechanical_engineering.gear_output_speed(input_speed, teeth_driver, teeth_driven)[source]#
Output speed \(\omega_o = \omega_i N_i / N_o\) of a gear pair.
- Parameters:
input_speed (float or array_like) – Driver speed, in any angular-speed unit (rad/s or rpm).
teeth_driver (int) – Tooth counts, at least one.
teeth_driven (int) – Tooth counts, at least one.
- Returns:
Driven speed in the unit of
input_speed. The sign is preserved; the reversal of rotation in an external mesh is not applied.- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> gear_output_speed(1500.0, 20, 60) 500.0
- engineeringkit.mechanical_engineering.gear_output_torque(input_torque, teeth_driver, teeth_driven, efficiency=1)[source]#
Output torque \(T_o = \eta T_i N_o / N_i\) of a gear pair.
- Parameters:
input_torque (float or array_like) – Driver torque [N m].
teeth_driver (int) – Tooth counts, at least one.
teeth_driven (int) – Tooth counts, at least one.
efficiency (float, optional) – Mesh power efficiency [-] in [0, 1].
- Returns:
Driven torque [N m]. Output power is
efficiencytimes input power.- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> gear_output_torque(10.0, 20, 60, efficiency=0.9) 27.0
- engineeringkit.mechanical_engineering.gear_ratio(teeth_driven, teeth_driver)[source]#
Speed-reduction ratio \(N_\text{driven}/N_\text{driver}\) of a gear pair.
- Parameters:
teeth_driven (int) – Teeth on the driven gear, at least one.
teeth_driver (int) – Teeth on the driving gear, at least one.
- Returns:
Input speed over output speed [-]; above one for a reduction.
- Return type:
float
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> gear_ratio(60, 20) 3.0
- engineeringkit.mechanical_engineering.harmonic_response(M, K, F, omega, C=None)[source]#
Steady-state complex amplitudes \(X = (K - \omega^2 M + i\omega C)^{-1} F\).
- Parameters:
M (array_like) – Mass and stiffness matrices, as for
normal_modes().K (array_like) – Mass and stiffness matrices, as for
normal_modes().F (array_like) – Force amplitudes on each coordinate [N or N m], length
n.omega (float or array_like) – Forcing frequencies [rad/s], nonnegative.
C (array_like, optional) – Viscous damping matrix [N s/m], symmetric; undamped if omitted.
- Returns:
Complex displacement amplitudes [m or rad], shape
(n,)for a scalaromegaor(len(omega), n); the response is \(\operatorname{Re}(X e^{i\omega t})\).- Return type:
ndarray
- Raises:
ValueError – If the dynamic stiffness is singular, as at an undamped resonance.
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> X = harmonic_response(np.eye(2), [[2.0, -1.0], [-1.0, 2.0]], [1.0, 0.0], 0.0) >>> np.round(X.real, 12).tolist() [0.666666666667, 0.333333333333]
- engineeringkit.mechanical_engineering.holzer_frequencies(inertias, stiffnesses, omega_max, n_grid=4000)[source]#
Torsional natural frequencies of a free-free shaft by Holzer’s method.
- Parameters:
inertias (array_like) – Disk polar moments of inertia [kg m^2], positive, at least two.
stiffnesses (array_like) – Shaft torsional stiffnesses [N m/rad], positive, one fewer than
inertias.omega_max (float) – Upper end of the frequency search [rad/s], positive.
n_grid (int, optional) – Trial frequencies scanned for sign changes of the residual torque, at least 10; closely spaced modes need a finer grid.
- Returns:
Nonzero natural frequencies below
omega_max[rad/s] and each mode’s disk twists, scaled so the largest is one. The zero-frequency rigid-body rotation is excluded.- Return type:
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
H. Holzer, Die Berechnung der Drehschwingungen (Springer, Berlin, 1921).
Examples
>>> result = holzer_frequencies([1.0, 1.0], [1.0], 5.0) >>> np.round(result.frequencies ** 2, 9).tolist() [2.0]
- engineeringkit.mechanical_engineering.holzer_residual(omega, inertias, stiffnesses)[source]#
Holzer’s residual torque beyond the last disk of a free-free shaft.
Start with unit twist at disk 1 and no torque; at each disk add its inertia torque \(J_i\omega^2\theta_i\), then twist the next shaft by the accumulated torque over its stiffness.
omegais a natural frequency when the torque left over at the free end is zero.- Parameters:
omega (float or array_like) – Trial frequency [rad/s].
inertias (array_like) – Disk polar moments of inertia [kg m^2], positive, at least two.
stiffnesses (array_like) – Torsional stiffness of each shaft between disks [N m/rad], positive, one fewer than
inertias.
- Returns:
Residual torque per unit twist of disk 1 [N m/rad].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(abs(holzer_residual(np.sqrt(2.0), [1.0, 1.0], [1.0])), 12) 0.0
- engineeringkit.mechanical_engineering.jeffcott_response(m, k, e, omega, c=0.0)[source]#
Steady synchronous whirl of a Jeffcott (Föppl-de Laval) rotor.
A disk of mass \(m\), whose centre of mass sits \(e\) from the shaft centre, spins at \(\omega\) midway on a massless shaft of lateral stiffness \(k\). With \(r = \omega/\omega_c\) and \(\zeta = c/(2\sqrt{km})\),
\[\frac{|z|}{e} = \frac{r^2}{\sqrt{(1 - r^2)^2 + (2\zeta r)^2}}, \qquad \phi = \operatorname{atan2}(2\zeta r,\ 1 - r^2)\]- Parameters:
m (float) – Disk mass [kg], positive.
k (float) – Shaft lateral stiffness at the disk [N/m], positive.
e (float) – Mass eccentricity [m], positive.
omega (float or array_like) – Spin speeds [rad/s], nonnegative.
c (float, optional) – External viscous damping [N s/m], nonnegative.
- Returns:
Whirl radius [m] and its lag behind the unbalance [rad] at each speed, and the critical speed [rad/s]. Without damping the radius is infinite at the critical speed.
- Return type:
Notes
m,k,eandcare scalar-only, since the result describes one rotor;omegabroadcasts.Gyroscopic effects, internal damping and bearing flexibility are neglected. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
H. H. Jeffcott, “The lateral vibration of loaded shafts in the neighbourhood of a whirling speed – the effect of want of balance,” Phil. Mag. (6) 37 (1919) 304-314.
Examples
>>> result = jeffcott_response(10.0, 1e6, 1e-4, [0.0, 1e4], c=100.0) >>> round(result.critical_speed, 6), round(float(result.amplitude[1] / 1e-4), 4) (316.227766, 1.001)
- engineeringkit.mechanical_engineering.kinetic_energy(m, v)[source]#
Translational kinetic energy \(T = \tfrac12 m v^2\).
- Parameters:
m (float or array_like) – Mass [kg], positive.
v (float or array_like) – Speed [m/s].
- Returns:
Kinetic energy [J].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
G. Coriolis, Du calcul de l’effet des machines (Carilian-Goeury, Paris, 1829).
Examples
>>> kinetic_energy(2.0, 3.0) 9.0
- engineeringkit.mechanical_engineering.lagrange_accelerations(lagrangian, q, qdot, t=0.0, forces=None, step=0.0001)[source]#
Generalised accelerations \(\ddot q\) from Lagrange’s equations at one state.
- Parameters:
lagrangian (callable) –
lagrangian(q, qdot) -> float, the Lagrangian \(T - V\) [J] of the coordinate and rate vectors.q (array_like) – Generalised coordinates [m or rad].
qdot (array_like) – Their rates [m/s or rad/s], same length as
q.t (float, optional) – Time [s], passed to
forces.forces (callable, optional) –
forces(t, q, qdot) -> Q, the generalised non-conservative forces [N or N m], one per coordinate; none if omitted.step (float, optional) – Relative central-difference step [-], positive.
- Returns:
\(\ddot q\) [m/s^2 or rad/s^2].
- Return type:
ndarray
- Raises:
numpy.linalg.LinAlgError – If \(\partial^2 L/\partial\dot q^2\) is singular, so the coordinates are not independent.
Notes
The derivatives are second-order central differences, exact to rounding for a Lagrangian quadratic in
qdotand accurate to aboutstep**2inq. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.References
J. L. Lagrange, Mécanique analytique (Desaint, Paris, 1788), part II, section IV.
Examples
A pendulum of length 1 m, \(L = \tfrac12\dot\theta^2 + g\cos\theta\):
>>> L = lambda q, v: 0.5 * v[0] ** 2 + 9.81 * np.cos(q[0]) >>> round(float(lagrange_accelerations(L, [np.pi / 2], [0.0])[0]), 6) -9.81
- engineeringkit.mechanical_engineering.lewis_bending_stress(tangential_load, face_width, module, form_factor, velocity_factor=1.0)[source]#
Lewis bending stress at the root of a spur-gear tooth, \(\sigma = K_v W_t/(F m Y)\).
- Parameters:
tangential_load (float or array_like) – Transmitted load \(W_t\) at the pitch circle [N], nonnegative.
face_width (float or array_like) – Face width \(F\) [m], positive.
module (float or array_like) – Module \(m\) = pitch diameter over teeth [m], positive.
form_factor (float or array_like) – Lewis form factor \(Y\) [-], positive (see
lewis_form_factor()).velocity_factor (float or array_like, optional) – Dynamic factor \(K_v\) [-], at least one (see
barth_velocity_factor()).
- Returns:
Bending stress [Pa].
- Return type:
float or ndarray
Notes
The whole load is assumed to act at the tip of one tooth, with no stress concentration at the fillet and no radial compression; the AGMA method refines all three. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
W. Lewis, “Investigation of the strength of gear teeth,” Proc. Engineers’ Club of Philadelphia (1892) 16-23.
Examples
>>> round(float(lewis_bending_stress(1000.0, 0.03, 0.003, 0.322)) / 1e6, 3) 34.507
- engineeringkit.mechanical_engineering.lewis_form_factor(teeth)[source]#
Lewis form factor \(Y\) of a 20-degree full-depth involute spur tooth.
- Parameters:
teeth (float or array_like) – Number of teeth [-], from 12 to 400; values between the tabulated tooth counts are interpolated linearly.
- Returns:
\(Y\) [-], from 0.245 at 12 teeth to 0.480 at 400 (0.485 for a rack).
- Return type:
float or ndarray
Notes
\(Y = 2xP/3\) in Lewis’s terms, with \(x\) the depth from the root to where the inscribed parabola of uniform strength meets the tooth centreline and \(P\) the diametral pitch (here \(1/m\)). Values are those of Shigley’s Table 14-2. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> float(lewis_form_factor(20)) 0.322
- engineeringkit.mechanical_engineering.long_bearing_eccentricity(S)[source]#
Eccentricity ratio of an infinitely long journal bearing (full Sommerfeld solution).
Solves
\[S = \frac{(2 + \varepsilon^2)\sqrt{1 - \varepsilon^2}}{12\pi^2\varepsilon}\]for \(\varepsilon = e/c\), the journal’s offset as a fraction of the radial clearance.
- Parameters:
S (float or array_like) – Sommerfeld number [-], positive (see
sommerfeld_number()).- Returns:
Eccentricity ratio [-] in (0, 1); it tends to zero (Petroff’s centred journal) as \(S \to \infty\).
- Return type:
float or ndarray
Notes
The full Sommerfeld solution keeps the negative film pressures that a real oil film cavitates away, so it puts the journal at 90 degrees to the load. The short-bearing and finite-bearing solutions are not implemented. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
O. Reynolds, “On the theory of lubrication and its application to Mr. Beauchamp Tower’s experiments,” Phil. Trans. R. Soc. Lond. 177 (1886) 157-234; Sommerfeld (1904), as for
sommerfeld_number().Examples
>>> eps = long_bearing_eccentricity(0.1) >>> round(float(eps), 4) 0.1688
- engineeringkit.mechanical_engineering.magnification_factor(r, zeta)[source]#
Steady-state amplitude of a harmonically forced oscillator over its static deflection.
For \(m\ddot x + c\dot x + kx = F_0\cos\omega t\), the steady amplitude is \(X = (F_0/k)\,M\) with
\[M = \frac{1}{\sqrt{(1 - r^2)^2 + (2\zeta r)^2}}, \qquad r = \omega/\omega_n\]- Parameters:
r (float or array_like) – Forcing frequency over natural frequency [-], nonnegative.
zeta (float or array_like) – Damping ratio [-], nonnegative.
- Returns:
Magnification factor [-]: one at \(r = 0\), peaking at \(1/(2\zeta\sqrt{1 - \zeta^2})\) at \(r = \sqrt{1 - 2\zeta^2}\) when \(\zeta < 1/\sqrt 2\), and infinite at undamped resonance.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
J. W. Strutt, Baron Rayleigh, The Theory of Sound, vol. 1 (Macmillan, London, 1877), chapter III.
Examples
>>> float(magnification_factor(1.0, 0.25)) 2.0
- engineeringkit.mechanical_engineering.member_stiffness(E, d, grip, washer_diameter=None, cone_angle=0.5235987755982988)[source]#
Stiffness of two identical clamped members from the pressure-cone (frustum) model.
Each member is a hollow frustum of half-angle \(\alpha\) spreading from the washer face \(D\) round the bolt hole \(d\); the two, each of thickness \(l/2\), act in series:
\[k_m = \frac{\pi E d \tan\alpha} {2\ln\dfrac{(l\tan\alpha + D - d)(D + d)}{(l\tan\alpha + D + d)(D - d)}}\]- Parameters:
E (float) – Young’s modulus of the members [Pa], positive.
d (float) – Bolt diameter [m], positive.
grip (float) – Total clamped thickness \(l\) [m], positive.
washer_diameter (float, optional) – Washer-face diameter \(D\) [m], greater than
d;1.5 dif omitted.cone_angle (float, optional) – Frustum half-angle \(\alpha\) [rad] in (0, pi/2); 30 degrees is the usual choice.
- Returns:
\(k_m\) [N/m].
- Return type:
float
Notes
With \(D = 1.5d\) and 30 degrees this is Shigley’s equation 8-22. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
Rötscher, Die Maschinenelemente (Springer, Berlin, 1927).
Examples
>>> round(member_stiffness(200e9, 0.012, 0.04) / 1e9, 4) 2.1595
- engineeringkit.mechanical_engineering.modal_response(M, K, x0, v0=None, t=None, modal_damping=0.0)[source]#
Free vibration by modal superposition, \(x(t) = \sum_r \phi_r q_r(t)\).
Each modal coordinate \(q_r = \phi_r^T M x\) starts from the projection of the initial state and decays as a damped single-degree-of- freedom oscillator, \(\ddot q_r + 2\zeta_r\omega_r\dot q_r + \omega_r^2 q_r = 0\), in closed form.
- Parameters:
M (array_like) – Mass and stiffness matrices, as for
normal_modes().K (array_like) – Mass and stiffness matrices, as for
normal_modes().x0 (array_like) – Initial displacements [m or rad], length
n.v0 (array_like, optional) – Initial velocities [m/s or rad/s]; zero if omitted.
t (array_like, optional) – Output times [s]; 1001 samples on [0, 10] s if omitted.
modal_damping (float or array_like, optional) – Damping ratio of each mode [-] in [0, 1), one value for all modes or one per mode. Rigid-body modes are left undamped.
- Returns:
Displacements and velocities at each time, shape
(len(t), n).- Return type:
Notes
Modal damping keeps the modes uncoupled; a general damping matrix does not. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> result = modal_response(np.eye(2), [[2.0, -1.0], [-1.0, 2.0]], [1.0, 1.0], t=[0.0, np.pi]) >>> np.round(result.displacement[-1], 12).tolist() [-1.0, -1.0]
- engineeringkit.mechanical_engineering.natural_frequency(k, m)[source]#
Undamped natural frequency \(\omega_n = \sqrt{k/m}\).
- Parameters:
k (float or array_like) – Stiffness [N/m], positive.
m (float or array_like) – Mass [kg], positive.
- Returns:
Natural frequency [rad/s].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
J. W. Strutt, Baron Rayleigh, The Theory of Sound, vol. 1 (Macmillan, London, 1877).
Examples
>>> float(natural_frequency(100.0, 4.0)) 5.0
- engineeringkit.mechanical_engineering.natural_frequency_hz(k, m)[source]#
Undamped natural frequency in hertz, \(f_n = \sqrt{k/m}/2\pi\).
- Parameters:
k (float or array_like) – Stiffness [N/m], positive.
m (float or array_like) – Mass [kg], positive.
- Returns:
Natural frequency [Hz].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(natural_frequency_hz(4.0, 1.0)), 6) 0.31831
- engineeringkit.mechanical_engineering.normal_modes(M, K)[source]#
Natural frequencies and mode shapes from the eigenproblem \(K\phi = \omega^2 M\phi\).
- Parameters:
M (array_like) – Mass matrix [kg or kg m^2], symmetric positive definite,
(n, n).K (array_like) – Stiffness matrix [N/m or N m/rad], symmetric positive semidefinite,
(n, n).
- Returns:
All
nfrequencies [rad/s] in increasing order, zero for rigid-body modes, and mode shapes normalised so \(\Phi^T M \Phi = I\) and \(\Phi^T K \Phi = \operatorname{diag}(\omega^2)\).- Return type:
Notes
Damping is ignored; the frequencies are undamped natural frequencies. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
J. L. Lagrange, Mécanique analytique (Desaint, Paris, 1788), part II, section VI; D. Bernoulli, “Réflexions et éclaircissemens sur les nouvelles vibrations des cordes,” Hist. Acad. R. Sci. Belles Lettres Berlin 9 (1753, published 1755) 147-172.
Examples
>>> modes = normal_modes(np.eye(2), [[2.0, -1.0], [-1.0, 2.0]]) >>> np.round(modes.frequencies ** 2, 12).tolist() [1.0, 3.0]
- engineeringkit.mechanical_engineering.parallel_axis(I_centroid, m, d)[source]#
Steiner’s parallel-axis theorem, \(I = I_G + m d^2\).
- Parameters:
I_centroid (float or array_like) – Moment of inertia about an axis through the centre of mass [kg m^2], nonnegative.
m (float or array_like) – Mass [kg], positive.
d (float or array_like) – Distance from that axis to the parallel axis [m].
- Returns:
Moment of inertia about the parallel axis [kg m^2].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
C. Huygens, Horologium oscillatorium (Muguet, Paris, 1673), part IV; J. Steiner, “Von dem Krümmungs-Schwerpuncte ebener Curven,” J. Reine Angew. Math. 21 (1840) 33-63.
Examples
>>> parallel_axis(1.0, 2.0, 1.0) 3.0
- engineeringkit.mechanical_engineering.petroff_friction_torque(viscosity, radius, length, clearance, omega)[source]#
Petroff’s viscous friction torque in a concentric journal bearing.
\[T = \frac{2\pi \mu \omega r^3 L}{c}\]- Parameters:
viscosity (float or array_like) – Dynamic viscosity of the lubricant \(\mu\) [Pa s], positive.
radius (float or array_like) – Journal radius \(r\) [m], positive.
length (float or array_like) – Bearing length \(L\) [m], positive.
clearance (float or array_like) – Radial clearance \(c\) [m], positive and much less than
radius.omega (float or array_like) – Journal speed [rad/s].
- Returns:
Friction torque [N m], with the sign of
omega.- Return type:
float or ndarray
Notes
The film is a linear (Couette) shear flow across a gap \(c \ll r\) with the journal centred, which holds for light loads and high speeds. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
N. P. Petroff, “Friction in machines and the effect of the lubricant,” Inzhenernyi Zhurnal (St Petersburg), nos. 1-4 (1883), in Russian.
Examples
>>> round(float(petroff_friction_torque(0.05, 0.02, 0.04, 2e-5, 100.0)), 6) 0.502655
- engineeringkit.mechanical_engineering.phase_angle(r, zeta)[source]#
Angle by which the steady displacement of a forced oscillator lags the force.
\[\phi = \operatorname{atan2}(2\zeta r,\ 1 - r^2)\]- Parameters:
r (float or array_like) – Forcing frequency over natural frequency [-], nonnegative.
zeta (float or array_like) – Damping ratio [-], nonnegative.
- Returns:
Phase lag [rad] in [0, pi]: zero below resonance, pi/2 at \(r = 1\) for any damping, tending to pi above.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(phase_angle(1.0, 0.1)), 12) 1.570796326795
- engineeringkit.mechanical_engineering.power_torque(torque, omega)[source]#
Shaft power \(P = T\omega\).
- Parameters:
torque (float or array_like) – Torque [N m].
omega (float or array_like) – Angular speed [rad/s].
- Returns:
Power [W].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> power_torque(10.0, 100.0) 1000.0
- engineeringkit.mechanical_engineering.preload_torque(preload, d, torque_coefficient=0.2)[source]#
Wrench torque to reach a bolt preload, \(T = K F_i d\).
- Parameters:
preload (float or array_like) – \(F_i\) [N], nonnegative.
d (float or array_like) – Nominal bolt diameter [m], positive.
torque_coefficient (float or array_like, optional) – \(K\) [-], positive; about 0.2 for unlubricated steel and 0.15 to 0.18 when lubricated.
- Returns:
Torque [N m].
- Return type:
float or ndarray
Notes
\(K\) lumps thread and collar friction and scatters by about \(\pm 25\%\), so torque control sets the preload only roughly. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(preload_torque(20e3, 0.012)), 6) 48.0
- engineeringkit.mechanical_engineering.rayleigh_frequency(M, K, shape)[source]#
Rayleigh’s quotient \(\omega^2 \approx x^T K x / x^T M x\) for a trial shape.
- Parameters:
M (array_like) – Mass and stiffness matrices, as for
normal_modes().K (array_like) – Mass and stiffness matrices, as for
normal_modes().shape (array_like) – Assumed mode shape [-], length
n, not zero.
- Returns:
Estimated frequency [rad/s]. It is never below the lowest natural frequency, and its error is second order in the error of the shape.
- Return type:
float
Notes
The static deflection under the weights is a good trial shape for the fundamental mode of a shaft or beam. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
J. W. Strutt, Baron Rayleigh, “Some general theorems relating to vibrations,” Proc. Lond. Math. Soc. 4 (1873) 357-368; The Theory of Sound, vol. 1 (Macmillan, London, 1877), sections 88-89.
Examples
>>> round(rayleigh_frequency(np.eye(2), [[2.0, -1.0], [-1.0, 2.0]], [1.0, 1.0]), 12) 1.0
- engineeringkit.mechanical_engineering.rotating_unbalance_force(m_e, e, omega)[source]#
Centrifugal force \(m_e e \omega^2\) of a rotating unbalance.
- Parameters:
m_e (float or array_like) – Unbalanced mass [kg], nonnegative.
e (float or array_like) – Its distance from the spin axis [m], nonnegative.
omega (float or array_like) – Spin speed [rad/s].
- Returns:
Force amplitude [N], rotating with the shaft.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(rotating_unbalance_force(2.0, 0.1, 10.0)), 12) 20.0
- engineeringkit.mechanical_engineering.rotational_energy(I, omega)[source]#
Kinetic energy of rotation about a fixed axis, \(\tfrac12 I\omega^2\).
- Parameters:
I (float or array_like) – Moment of inertia about the axis [kg m^2], positive.
omega (float or array_like) – Angular speed [rad/s].
- Returns:
Kinetic energy [J].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> rotational_energy(2.0, 3.0) 9.0
- engineeringkit.mechanical_engineering.screw_torque_raise(load, mean_diameter, lead, mu)[source]#
Torque to raise a load with a square-thread power screw.
\[T = \frac{W d_m}{2}\tan(\phi + \lambda), \quad \tan\lambda = \frac{L}{\pi d_m}, \quad \tan\phi = \mu\]- Parameters:
load (float or array_like) – Axial load \(W\) [N], nonnegative.
mean_diameter (float or array_like) – Mean thread diameter \(d_m\) [m], positive.
lead (float or array_like) – Axial advance per revolution \(L\) [m], positive.
mu (float or array_like) – Thread friction coefficient [-], nonnegative.
- Returns:
Torque [N m], excluding collar friction.
- Return type:
float or ndarray
- Raises:
ValueError – If \(\phi + \lambda \ge \pi/2\), where no torque can raise the load.
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
C. A. Coulomb, “Théorie des machines simples,” Mém. Math. Phys. Acad. R. Sci. 10 (1785) 161-332.
Examples
>>> round(float(screw_torque_raise(1000.0, 0.02, 0.005, 0.0) * 2 * np.pi), 6) 5.0
- engineeringkit.mechanical_engineering.shaft_diameter(M, T, yield_strength, safety_factor=1.0, criterion='von_mises')[source]#
Smallest solid-shaft diameter that keeps static bending plus torsion below yield.
\[d = \left(\frac{16 n}{\pi S_y}\sqrt{4M^2 + 3T^2}\right)^{1/3} \ \text{(von Mises)}, \qquad d = \left(\frac{32 n}{\pi S_y}\sqrt{M^2 + T^2}\right)^{1/3} \ \text{(Tresca)}\]- Parameters:
M (float or array_like) – Bending moment [N m].
T (float or array_like) – Torque [N m].
yield_strength (float or array_like) – Tensile yield strength \(S_y\) [Pa], positive.
safety_factor (float or array_like, optional) – \(n\) [-], positive.
criterion ({"von_mises", "tresca"}, optional) – Yield criterion; Tresca is the more conservative.
- Returns:
Diameter [m].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(shaft_diameter(500.0, 0.0, 79.5775e6)), 6) 0.04
- engineeringkit.mechanical_engineering.shaft_diameter_goodman(endurance_limit, ultimate_strength, Ma=0.0, Tm=0.0, Mm=0.0, Ta=0.0, safety_factor=1.0, Kf=1.0, Kfs=1.0)[source]#
Shaft diameter for infinite fatigue life by the distortion-energy Goodman criterion.
\[d = \left\{\frac{16 n}{\pi}\left[ \frac{\sqrt{4(K_f M_a)^2 + 3(K_{fs} T_a)^2}}{S_e} + \frac{\sqrt{4(K_f M_m)^2 + 3(K_{fs} T_m)^2}}{S_{ut}}\right]\right\}^{1/3}\]- Parameters:
endurance_limit (float) – Fully corrected endurance limit \(S_e\) [Pa], positive.
ultimate_strength (float) – Ultimate tensile strength \(S_{ut}\) [Pa], positive.
Ma (float, optional) – Alternating and mean bending moment [N m]. A rotating shaft under a steady bending load has only \(M_a\).
Mm (float, optional) – Alternating and mean bending moment [N m]. A rotating shaft under a steady bending load has only \(M_a\).
Ta (float, optional) – Alternating and mean torque [N m].
Tm (float, optional) – Alternating and mean torque [N m].
safety_factor (float, optional) – \(n\) [-], positive.
Kf (float, optional) – Fatigue stress-concentration factors in bending and torsion [-], at least one.
Kfs (float, optional) – Fatigue stress-concentration factors in bending and torsion [-], at least one.
- Returns:
Diameter [m] at which the von Mises alternating and mean stresses lie on the Goodman line \(\sigma_a'/S_e + \sigma_m'/S_{ut} = 1/n\).
- Return type:
float
Notes
Yielding on the first cycle is not checked; compare \(\sigma_a' + \sigma_m'\) with \(S_y\) separately. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(shaft_diameter_goodman(200e6, 600e6, Ma=100.0, Tm=0.0), 6) 0.017205
- engineeringkit.mechanical_engineering.shaft_max_shear_stress(d, M, T)[source]#
Maximum shear stress at the surface of a solid shaft, \(\tau_\text{max} = \frac{16}{\pi d^3}\sqrt{M^2 + T^2}\).
- Parameters:
d (float or array_like) – Shaft diameter [m], positive.
M (float or array_like) – Bending moment [N m].
T (float or array_like) – Torque [N m].
- Returns:
\(\sqrt{(\sigma/2)^2 + \tau^2}\) [Pa], the radius of Mohr’s circle.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
J. J. Guest, “On the strength of ductile materials under combined stress,” Phil. Mag. (5) 50 (1900) 69-132.
Examples
>>> round(float(shaft_max_shear_stress(0.04, 300.0, 400.0)) / 1e6, 4) 39.7887
- engineeringkit.mechanical_engineering.shaft_von_mises_stress(d, M, T)[source]#
Von Mises stress at the surface of a solid shaft, \(\sigma' = \frac{16}{\pi d^3}\sqrt{4M^2 + 3T^2}\).
- Parameters:
d (float or array_like) – Shaft diameter [m], positive.
M (float or array_like) – Bending moment [N m].
T (float or array_like) – Torque [N m].
- Returns:
\(\sqrt{\sigma^2 + 3\tau^2}\) [Pa].
- Return type:
float or ndarray
Notes
Transverse shear, which is zero at the surface fibre of greatest bending stress, and axial load are neglected. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(shaft_von_mises_stress(0.04, 500.0, 0.0)) / 1e6, 4) 79.5775
- engineeringkit.mechanical_engineering.simulate_lagrangian(lagrangian, q0, qdot0, t=None, forces=None, step=0.0001)[source]#
Integrate Lagrange’s equations of motion from an initial state.
- Parameters:
lagrangian (callable) –
lagrangian(q, qdot) -> float[J]; seelagrange_accelerations().q0 (array_like) – Initial coordinates [m or rad] and rates [m/s or rad/s].
qdot0 (array_like) – Initial coordinates [m or rad] and rates [m/s or rad/s].
t (array_like, optional) – Strictly increasing output times [s]; 1001 samples on [0, 10] s if omitted.
forces (callable, optional) –
forces(t, q, qdot) -> Q[N or N m]; none if omitted.step (float, optional) – Relative central-difference step [-], positive.
- Returns:
Coordinates and rates at each time, shape
(len(t), n).- Return type:
Notes
Uses
engineeringkit.integrators.integrate_ode()(adaptive Runge-Kutta). Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.Examples
>>> L = lambda q, v: 0.5 * v[0] ** 2 - 0.5 * 4.0 * q[0] ** 2 >>> result = simulate_lagrangian(L, [0.1], [0.0], t=np.linspace(0, np.pi, 3)) >>> np.round(result.displacement[:, 0], 6).tolist() [0.1, -0.1, 0.1]
- engineeringkit.mechanical_engineering.simulate_sdof(m, c, k, x0=0, v0=0, t=None, force=None)[source]#
Integrate \(m\ddot x + c\dot x + kx = F(t)\) for a passive linear oscillator.
- Parameters:
m (float) – Mass [kg], positive.
c (float) – Viscous damping [N s/m], nonnegative.
k (float) – Stiffness [N/m], nonnegative.
x0 (float, optional) – Initial displacement [m].
v0 (float, optional) – Initial velocity [m/s].
t (array_like, optional) – Strictly increasing output times [s]; defaults to 1001 samples on [0, 10] s.
force (callable, optional) –
force(time [s]) -> force [N]; omit for free vibration.
- Returns:
Time [s], displacement [m] and velocity [m/s].
- Return type:
Notes
Constant coefficients and small linear displacements are assumed. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> result = simulate_sdof(1.0, 0.0, 4.0, x0=0.1, t=np.linspace(0, np.pi, 3)) >>> np.round(result.displacement, 6).tolist() [0.1, -0.1, 0.1]
- engineeringkit.mechanical_engineering.slider_crank_displacement(r, l, theta)[source]#
Slider position of an in-line slider-crank, measured from the crank axis.
\[x = r\cos\theta + \sqrt{l^2 - r^2\sin^2\theta}\]- Parameters:
r (float) – Crank radius [m], positive.
l (float) – Connecting-rod length [m], at least
r.theta (float or array_like) – Crank angle from top dead centre [rad].
- Returns:
Slider position [m], from \(l + r\) at \(\theta = 0\) to \(l - r\) at \(\theta = \pi\).
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
Reuleaux, Theoretische Kinematik (Vieweg, Braunschweig, 1875).
Examples
>>> float(slider_crank_displacement(1.0, 3.0, 0.0)) 4.0
- engineeringkit.mechanical_engineering.slider_crank_kinematics(r, l, theta, omega, alpha=0.0)[source]#
Exact slider velocity and acceleration of an in-line slider-crank.
With the rod at angle \(\beta\) to the line of stroke, \(l\sin\beta = r\sin\theta\) and \(x = r\cos\theta + l\cos\beta\). Differentiating,
\[\dot\beta = \frac{r\omega\cos\theta}{l\cos\beta}, \qquad \dot x = -r\omega\sin\theta - l\dot\beta\sin\beta,\]and once more for \(\ddot\beta\) and \(\ddot x\). For a rod long compared with the crank, \(\ddot x \approx -r\omega^2(\cos\theta + (r/l)\cos 2\theta)\).
- Parameters:
r (float) – Crank radius [m], positive.
l (float) – Connecting-rod length [m], greater than
r.theta (float or array_like) – Crank angle from top dead centre [rad].
omega (float) – Crank angular velocity [rad/s].
alpha (float, optional) – Crank angular acceleration [rad/s^2].
- Returns:
Slider position [m], velocity [m/s] and acceleration [m/s^2], and the rod’s angle [rad], angular velocity [rad/s] and acceleration [rad/s^2].
- Return type:
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> motion = slider_crank_kinematics(0.05, 0.2, 0.0, 100.0) >>> round(float(motion.acceleration), 6) -625.0
- engineeringkit.mechanical_engineering.solid_sphere_inertia(m, r)[source]#
Moment of inertia \(\tfrac25 m r^2\) of a uniform sphere about a diameter.
- Parameters:
m (float or array_like) – Mass [kg], positive.
r (float or array_like) – Radius [m], positive.
- Returns:
Moment of inertia [kg m^2].
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> solid_sphere_inertia(5.0, 1.0) 2.0
- engineeringkit.mechanical_engineering.sommerfeld_number(viscosity, omega, load, radius, length, clearance)[source]#
Bearing characteristic number \(S = (r/c)^2 \mu N / P\).
- Parameters:
viscosity (float or array_like) – Dynamic viscosity \(\mu\) [Pa s], positive.
omega (float or array_like) – Journal speed [rad/s], positive; \(N = \omega/2\pi\) [rev/s].
load (float or array_like) – Radial load \(W\) [N], positive.
radius (float or array_like) – Journal radius, bearing length and radial clearance [m], positive.
length (float or array_like) – Journal radius, bearing length and radial clearance [m], positive.
clearance (float or array_like) – Journal radius, bearing length and radial clearance [m], positive.
- Returns:
Sommerfeld number [-], with projected pressure \(P = W/(2rL)\).
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
A. Sommerfeld, “Zur hydrodynamischen Theorie der Schmiermittelreibung,” Z. Math. Phys. 50 (1904) 97-155.
Examples
>>> round(float(sommerfeld_number(0.05, 2 * np.pi * 30, 2000.0, 0.02, 0.04, 2e-5)), 4) 1.2
- engineeringkit.mechanical_engineering.spring_index(D, d)[source]#
Spring index \(C = D/d\), mean coil diameter over wire diameter.
- Parameters:
D (float or array_like) – Mean coil diameter [m], positive.
d (float or array_like) – Wire diameter [m], positive and less than
D.
- Returns:
\(C\) [-]; practical springs have \(4 \le C \le 12\).
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> float(spring_index(0.03, 0.005)) 6.0
- engineeringkit.mechanical_engineering.spring_rate(d, D, active_coils, G)[source]#
Rate of a close-coiled helical spring, \(k = Gd^4/(8D^3N_a)\).
- Parameters:
d (float or array_like) – Wire diameter [m], positive.
D (float or array_like) – Mean coil diameter [m], positive.
active_coils (float or array_like) – Number of active coils \(N_a\) [-], positive.
G (float or array_like) – Shear modulus of the wire [Pa], positive.
- Returns:
Rate [N/m].
- Return type:
float or ndarray
Notes
Only torsion of the wire is counted; the direct-shear deflection, a fraction of about \(1/2C^2\), is neglected. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(spring_rate(0.005, 0.03, 10, 79.3e9)), 3) 22945.602
- engineeringkit.mechanical_engineering.spring_shear_stress(F, D, d, correction='wahl')[source]#
Maximum shear stress in the wire of a helical spring, \(\tau = K\,8FD/\pi d^3\).
- Parameters:
F (float or array_like) – Axial load [N].
D (float or array_like) – Mean coil diameter [m], positive.
d (float or array_like) – Wire diameter [m], positive and less than
D.correction ({"wahl", "bergstrasser", "direct", "none"}, optional) – Factor \(K\): Wahl’s or Bergsträsser’s (direct shear and curvature), direct shear only, \(K_s = 1 + 0.5/C\), or none.
- Returns:
Shear stress [Pa], with the sign of
F.- Return type:
float or ndarray
Notes
Use the curvature-corrected factors for fatigue; for static loads of ductile wire, where local yielding relieves the curvature peak, the direct-shear factor is usual. Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(spring_shear_stress(100.0, 0.03, 0.005, correction="none")) / 1e6, 4) 61.1155
- engineeringkit.mechanical_engineering.transmissibility(r, zeta)[source]#
Force (or base-motion) transmissibility of a damped linear isolator.
\[T = \sqrt{\frac{1 + (2\zeta r)^2}{(1 - r^2)^2 + (2\zeta r)^2}}\]- Parameters:
r (float or array_like) – Excitation frequency over natural frequency [-], nonnegative.
zeta (float or array_like) – Damping ratio [-], nonnegative.
- Returns:
Transmitted over applied amplitude [-]; below one only for \(r > \sqrt 2\), and infinite at undamped resonance.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(transmissibility(np.sqrt(2), 0.1)), 12) 1.0
- engineeringkit.mechanical_engineering.tuned_mass_damper(m, k, mass_ratio, frequency_ratio=None, damping_ratio=None)[source]#
Design a dynamic vibration absorber for a mass-spring system.
With
frequency_ratioanddamping_ratioomitted, Den Hartog’s optimum tuning is used:\[f = \frac{1}{1 + \mu}, \qquad \zeta = \sqrt{\frac{3\mu}{8(1 + \mu)^3}}\]which makes the two fixed points of the response curve equal in height, \(\sqrt{1 + 2/\mu}\) times the static deflection, and puts the peaks near them.
- Parameters:
m (float) – Primary mass \(m_1\) [kg], positive.
k (float) – Primary stiffness \(k_1\) [N/m], positive.
mass_ratio (float) – \(\mu = m_2/m_1\) [-], positive.
frequency_ratio (float, optional) – Absorber frequency \(\sqrt{k_2/m_2}\) over \(\omega_1\) [-], positive. Frahm’s undamped absorber uses 1, tuned to the forcing.
damping_ratio (float, optional) – \(c_2/(2 m_2 \omega_1)\) [-], nonnegative.
- Returns:
Absorber mass, stiffness and damping, with
amplification(r)for the primary mass’s frequency response.- Return type:
Notes
All parameters are scalar-only: the result is one absorber design.
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
H. Frahm, “Device for damping vibrations of bodies,” U.S. Patent 989,958 (filed 1909, issued 1911); J. Ormondroyd and J. P. Den Hartog, “The theory of the dynamic vibration absorber,” Trans. ASME 50 (1928) APM-50-7, 9-22.
Examples
>>> tmd = tuned_mass_damper(100.0, 1e5, 0.05) >>> round(tmd.frequency_ratio, 6), round(tmd.damping_ratio, 6) (0.952381, 0.127267)
- engineeringkit.mechanical_engineering.unbalance(masses, radii, angles, positions=None)[source]#
Resultant unbalance and, optionally, its moment about the axial origin.
- Parameters:
masses (array_like) – Rotating masses [kg], nonnegative.
radii (array_like) – Their distances from the spin axis [m], nonnegative.
angles (array_like) – Their angular positions [rad].
positions (array_like, optional) – Their axial positions along the shaft [m].
- Returns:
Magnitude of \(\sum m_i r_i e^{i\theta_i}\) [kg m]; with
positions, also the magnitude of the couple unbalance \(\sum m_i r_i z_i e^{i\theta_i}\) [kg m^2]. Multiply by \(\omega^2\) for the shaking force [N] and moment [N m].- Return type:
float or tuple of float
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(unbalance([1.0, 1.0], [0.1, 0.1], [0.0, np.pi]), 12) 0.0
- engineeringkit.mechanical_engineering.wahl_factor(C)[source]#
Wahl’s stress-correction factor \(K_W = \frac{4C - 1}{4C - 4} + \frac{0.615}{C}\).
- Parameters:
C (float or array_like) – Spring index [-], greater than one.
- Returns:
\(K_W\) [-], the inner-fibre shear over \(8FD/\pi d^3\), including direct shear and coil curvature.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
References
A. M. Wahl, “Stresses in heavy closely coiled helical springs,” Trans. ASME 51 (1929) APM-51-17; A. M. Wahl, Mechanical Springs (Penton, Cleveland, 1944).
Examples
>>> round(float(wahl_factor(6.0)), 4) 1.2525
- engineeringkit.mechanical_engineering.work_constant_force(F, d, theta=0)[source]#
Work \(W = F d \cos\theta\) of a constant force over a straight displacement.
- Parameters:
F (float or array_like) – Force magnitude [N].
d (float or array_like) – Displacement magnitude [m].
theta (float or array_like, optional) – Angle between force and displacement [rad].
- Returns:
Work done by the force [J]; negative when it opposes the motion.
- Return type:
float or ndarray
Notes
Inputs are raw SI numbers with no dimensional metadata; see Mechanical engineering: power, vibration and mechanism geometry.
Examples
>>> round(float(work_constant_force(10.0, 2.0, np.pi / 3)), 12) 10.0
Utilities#
Supporting numerics for engineeringkit.mechanical_engineering’s systems/ modules.
- engineeringkit.mechanical_engineering.utils.bracketed_roots(f, grid)[source]#
Roots of a scalar function between consecutive grid points where it changes sign.
- Parameters:
f (callable) –
f(x) -> float, vectorized over a 1-D array.grid (array_like) – Increasing sample points; roots closer together than the grid spacing may be missed.
- Returns:
Roots in increasing order. A grid point where
fis exactly zero is returned as a root.- Return type:
ndarray
Visualizers#
Matplotlib visualizers for engineeringkit.mechanical_engineering.
- engineeringkit.mechanical_engineering.visualizers.plot_frequency_response(r, amplitude, ax=None, label=None)[source]#
Semilog plot of an amplitude ratio against a frequency ratio.
- Parameters:
r (array_like) – Frequency ratios [-].
amplitude (array_like) – Matching amplitude ratios [-], positive; infinite or nonpositive values are left out of the log axis.
ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.
label (str, optional) – Legend label.
- Return type:
matplotlib.axes.Axes
- engineeringkit.mechanical_engineering.visualizers.plot_linkage(points, ax=None, **style)[source]#
Draw a chain of rigid links through successive joint positions.
- Parameters:
points (array_like) – Joint coordinates [m], shape
(n, 2)withn >= 2.ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.
**style – Passed to
matplotlib.axes.Axes.plot().
- Return type:
matplotlib.axes.Axes
- engineeringkit.mechanical_engineering.visualizers.plot_mode_shapes(mode_shapes, frequencies, ax=None)[source]#
Plot each mode’s disk amplitudes against disk number.
- Parameters:
mode_shapes (array_like) – Shape
(modes, disks).frequencies (array_like) – One natural frequency per mode [rad/s], used in the legend.
ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.
- Return type:
matplotlib.axes.Axes