pub struct Pmsm {
pub r_s: f64,
pub l_d: f64,
pub l_q: f64,
pub lambda_pm: f64,
pub pole_pairs: f64,
pub inertia: f64,
pub friction: f64,
}Expand description
Motor parameters (SI units): stator resistance r_s (ohm), d/q-axis inductance l_d/
l_q (H — equal for a surface-mount PMSM, unequal for an interior-PM motor with reluctance
torque), permanent-magnet flux linkage lambda_pm (Wb), pole_pairs (electrical cycles per
mechanical revolution), rotor+load inertia inertia (kgm^2), and viscous friction
coefficient friction (Nm*s/rad).
Fields§
§r_s: f64§l_d: f64§l_q: f64§lambda_pm: f64§pole_pairs: f64§inertia: f64§friction: f64Implementations§
Source§impl Pmsm
impl Pmsm
pub fn new( r_s: f64, l_d: f64, l_q: f64, lambda_pm: f64, pole_pairs: f64, inertia: f64, friction: f64, ) -> Result<Self, PmsmError>
Sourcepub fn torque(&self, id: f64, iq: f64) -> f64
pub fn torque(&self, id: f64, iq: f64) -> f64
Electromagnetic torque (N*m) at a given id/iq operating point — the standard
permanent-magnet-alignment term plus reluctance torque (zero when l_d == l_q, the
surface-mount case).
Sourcepub fn theta_e_wrapped(theta_e: f64) -> f64
pub fn theta_e_wrapped(theta_e: f64) -> f64
This block’s own electrical angle, wrapped to [0, 2*pi) — matches
crate::coordinate_transforms::anglewrap’s own convention, so a downstream Park/
ClarkePark block can consume either interchangeably.
Sourcepub fn step(
&self,
x: [f64; 4],
vd: f64,
vq: f64,
t_load: f64,
dt: f64,
) -> [f64; 4]
pub fn step( &self, x: [f64; 4], vd: f64, vq: f64, t_load: f64, dt: f64, ) -> [f64; 4]
Advances the motor state by one step via classical 4th-order Runge-Kutta, with vd/
vq/t_load held fixed (zero-order hold) across the step — the same convention
crate::StateSpace::rk4_step uses for its own single-step input.