Simscape custom component to have one parameters unit change depending on the input of another parameter

3 visualizzazioni (ultimi 30 giorni)
Hi all,
I am creating a custom simscape block and it all works fine, except the units. The equation is Torq = D1*w + D2*w^PE and the parametres I declare are D1, D2 and PE (w is the rotational velocity). Therefore you can see that if I delcare PE to be 2.5 for example, then this implies that the units of D2 will have to change accordingly to make D2*w^PE be equal to N*m (Newton meters).
I tried implementing the change in units by using a typical sprintf function, however as Simscape laguage appears to be its own thing, it doesn' seem to be working... So do you have any ideas on that?
Here is the code for the component:
component propeller_law
% The equation is Torq = D1*w + D2*w^PE, where:
nodes
r = foundation.mechanical.rotational.rotational; % R
c = foundation.mechanical.rotational.rotational; % C:right
end
parameters
PE = 2.5 ; % Exponent
D1 = { 0.001, '(N*m)*s/rad'}; % Linear Damping Coefficient
D2 = { 0.001, sprintf('(N*m)*(s/rad)^%f',PE)}; % Non-Linear Coefficient
end
variables
w = { value = {0, 'rad/s'}, priority = priority.high }; % Angular Velocity
theta = { 0, 'rad' }; % Angular Displacement
t = { 0, 'N*m' }; % Torque
end
branches
t : r.t -> c.t; % torque through from node r to node c
end
equations
assert(D1>=0 && D2>=0) % Damping coefficients must be positive
w == r.w - c.w;
t == D1*w + D2*w^PE ;
w == theta.der
end
end
Kind Regards,
KMT.

Risposte (0)

Categorie

Scopri di più su Equations in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by