Skip to content

Commit d70bc05

Browse files
ven-kAayushSabharwal
authored andcommitted
metadata(components): adds units and descriptions to Rotational components
1 parent 2b0bc6e commit d70bc05

File tree

4 files changed

+80
-40
lines changed

4 files changed

+80
-40
lines changed

src/Mechanical/Rotational/components.jl

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Flange fixed in housing at a given angle.
1616
flange = Flange()
1717
end
1818
@parameters begin
19-
phi0 = 0.0, [description = "Fixed offset angle of flange"]
19+
phi0 = 0.0, [description = "Fixed offset angle of flange", unit = u"rad"]
2020
end
2121
@equations begin
2222
flange.phi ~ phi0
@@ -45,7 +45,7 @@ end
4545
"""
4646
@mtkmodel Inertia begin
4747
@parameters begin
48-
J, [description = "Moment of inertia"]
48+
J, [description = "Moment of inertia", unit = u"kg*m^2"]
4949
end
5050
@components begin
5151
flange_a = Flange()
@@ -55,9 +55,9 @@ end
5555
@symcheck J > 0 || throw(ArgumentError("Expected `J` to be positive"))
5656
end
5757
@variables begin
58-
phi(t) = 0.0, [description = "Absolute rotation angle"]
59-
w(t) = 0.0, [description = "Absolute angular velocity"]
60-
a(t) = 0.0, [description = "Absolute angular acceleration"]
58+
phi(t) = 0.0, [description = "Absolute rotation angle", unit = u"rad"]
59+
w(t) = 0.0, [description = "Absolute angular velocity", unit = u"rad*s^-1"]
60+
a(t) = 0.0, [description = "Absolute angular acceleration", rad = u"rad*s^-2"]
6161
end
6262
@equations begin
6363
phi ~ flange_a.phi
@@ -94,8 +94,8 @@ Linear 1D rotational spring
9494
@symcheck c > 0 || throw(ArgumentError("Expected `c` to be positive"))
9595
end
9696
@parameters begin
97-
c, [description = "Spring constant"]
98-
phi_rel0 = 0.0, [description = "Unstretched spring angle"]
97+
c, [description = "Spring constant", unit = u"N*m*rad^-1"]
98+
phi_rel0 = 0.0, [description = "Unstretched spring angle", unit = u"rad"]
9999
end
100100
@equations begin
101101
tau ~ c * (phi_rel - phi_rel0)
@@ -129,7 +129,7 @@ Linear 1D rotational damper
129129
@symcheck d > 0 || throw(ArgumentError("Expected `d` to be positive"))
130130
end
131131
@parameters begin
132-
d, [description = "Damping constant"]
132+
d, [description = "Damping constant", unit = u"N*m*s*rad^-1"]
133133
end
134134
@equations begin
135135
tau ~ d * w_rel
@@ -159,10 +159,10 @@ Linear 1D rotational spring and damper
159159
- `phi_rel0`: [`rad`] Unstretched spring angle
160160
"""
161161
@mtkmodel SpringDamper begin
162-
@extend phi_rel, w_rel, tau = partial_comp = PartialCompliantWithRelativeStates()
162+
@extend phi_rel, w_rel, a_rel, tau = partial_comp = PartialCompliantWithRelativeStates()
163163
@variables begin
164-
tau_c(t), [description = "Spring torque"]
165-
tau_d(t), [description = "Damper torque"]
164+
tau_c(t), [description = "Spring torque", unit = u"N*m"]
165+
tau_d(t), [description = "Damper torque", unit = u"N*m"]
166166
end
167167
@parameters begin
168168
d, [description = "Damping constant"]
@@ -206,8 +206,14 @@ This element characterizes any type of gear box which is fixed in the ground and
206206
ratio, [description = "Transmission ratio"]
207207
end
208208
@variables begin
209-
phi_a(t) = 0.0, [description = "Relative angle between shaft a and the support"]
210-
phi_b(t) = 0.0, [description = "Relative angle between shaft b and the support"]
209+
function phi_a(t)
210+
0.0,
211+
[description = "Relative angle between shaft a and the support", unit = u"rad"]
212+
end
213+
function phi_b(t)
214+
0.0,
215+
[description = "Relative angle between shaft b and the support", unit = u"rad"]
216+
end
211217
end
212218
@equations begin
213219
phi_a ~ flange_a.phi - phi_support
@@ -245,14 +251,13 @@ Friction model: "Armstrong, B. and C.C. de Wit, Friction Modeling and Compensati
245251
- `tau_brk`: [`N⋅m`] Breakaway friction torque
246252
"""
247253
@mtkmodel RotationalFriction begin
248-
@extend w_rel, tau = partial_comp = PartialCompliantWithRelativeStates()
254+
@extend phi_rel, w_rel, a_rel, tau = partial_comp = PartialCompliantWithRelativeStates()
249255
@parameters begin
250-
f, [description = "Viscous friction coefficient"]
251-
tau_c, [description = "Coulomb friction torque"]
252-
w_brk, [description = "Breakaway friction velocity"]
253-
tau_brk, [description = "Breakaway friction torque"]
256+
f, [description = "Viscous friction coefficient", unit = u"N*m*s/rad"]
257+
tau_c, [description = "Coulomb friction torque", unit = u"N*m"]
258+
w_brk, [description = "Breakaway friction velocity", unit = u"rad*s^-1"]
259+
tau_brk, [description = "Breakaway friction torque", unit = "N*m"]
254260
end
255-
256261
begin
257262
str_scale = sqrt(2 * exp(1)) * (tau_brk - tau_c)
258263
w_st = w_brk * sqrt(2)

src/Mechanical/Rotational/sensors.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Ideal sensor to measure the relative angular velocity
7272
7373
- `flange_a`: [Flange](@ref) Flange of shaft from which sensor information shall be measured
7474
- `flange_b`: [Flange](@ref) Flange of shaft from which sensor information shall be measured
75-
- `w`: [RealOutput](@ref) Absolute angular velocity of flange
75+
- `w_rel`: [RealOutput](@ref) Relative angular velocity
7676
"""
7777
@mtkmodel RelSpeedSensor begin
7878
@components begin
@@ -81,7 +81,7 @@ Ideal sensor to measure the relative angular velocity
8181
w_rel = RealOutput()
8282
end
8383
@variables begin
84-
phi_rel(t) = 0.0
84+
phi_rel(t) = 0.0, [description = "Relative rotation angle", units = u"rad"]
8585
end
8686
@equations begin
8787
0 ~ flange_a.tau + flange_b.tau

src/Mechanical/Rotational/sources.jl

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
use_support = false)
44
@variables begin
55
phi(t),
6-
[
7-
description = "Angle of flange with respect to support (= flange.phi - support.phi)",
8-
]
6+
[description = "Angle of flange with respect to support",
7+
unit = u"rad"]
98
end
109
@equations begin
1110
phi ~ flange.phi - phi_support
@@ -64,13 +63,21 @@ Constant torque source
6463
tau_constant,
6564
[
6665
description = "Constant torque (if negative, torque is acting as load in positive direction of rotation)",
66+
unit = u"N*m",
6767
]
6868
end
6969
@extend flange, phi = partial_element = PartialTorque(; use_support = false)
7070
@variables begin
71-
tau(t), [description = "Accelerating torque acting at flange (= -flange.tau)"]
71+
tau(t),
72+
[
73+
description = "Accelerating torque acting at flange (= -flange.tau)",
74+
unit = u"N*m",
75+
]
7276
w(t),
73-
[description = "Angular velocity of flange with respect to support (= der(phi))"]
77+
[
78+
description = "Angular velocity of flange with respect to support",
79+
unit = u"rad*s^-1",
80+
]
7481
end
7582
@equations begin
7683
w ~ D(phi)
@@ -103,15 +110,24 @@ Forced movement of a flange according to a reference angular velocity signal
103110
@named partial_element = PartialElementaryOneFlangeAndSupport2(use_support = use_support)
104111
@unpack flange, phi_support = partial_element
105112
@named w_ref = RealInput()
106-
@variables phi(t)=0.0 w(t)=0.0 a(t)=0.0
113+
@variables begin
114+
function phi(t)
115+
0.0, [description = "Angle of flange with respect to support", unit = u"rad"]
116+
end
117+
w(t) = 0.0, [description = "Angular velocity", unit = u"rad*s^-1"]
118+
a(t) = 0.0, [description = "Angular acceleration", unit = u"rad*s^-2"]
119+
end
107120
eqs = [phi ~ flange.phi - phi_support
108121
D(phi) ~ w]
109122
if exact
110123
pars = []
111124
push!(eqs, w ~ w_ref.u)
112125
push!(eqs, a ~ 0)
113126
else
114-
pars = @parameters tau_filt = tau_filt
127+
pars = @parameters tau_filt=tau_filt [
128+
description = "Time constant of low-pass filter",
129+
unit = u"rad*s^-1",
130+
]
115131
push!(eqs, D(w) ~ a)
116132
push!(eqs, a ~ (w_ref.u - w) * tau_filt)
117133
end

src/Mechanical/Rotational/utils.jl

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@connector Flange begin
2-
phi(t), [description = "Rotation angle of flange"]
3-
tau(t), [connect = Flow, description = "Cut torque in flange"]
2+
phi(t), [description = "Rotation angle of flange", unit = u"rad"]
3+
tau(t), [connect = Flow, description = "Cut torque in flange", unit = u"N*m"]
44
end
55

66
Base.@doc """
@@ -14,8 +14,8 @@ Base.@doc """
1414
""" Flange
1515

1616
@connector Support begin
17-
phi(t), [description = "Rotation angle of flange"]
18-
tau(t), [connect = Flow, description = "Cut torque in flange"]
17+
phi(t), [description = "Rotation angle of flange", unit = u"rad"]
18+
tau(t), [connect = Flow, description = "Cut torque in flange", unit = u"N*m"]
1919
end
2020

2121
# Base.@doc """
@@ -71,8 +71,10 @@ Partial model for the compliant connection of two rotational 1-dim. shaft flange
7171
flange_b = Flange()
7272
end
7373
@variables begin
74-
phi_rel(t) = 0.0, [description = "Relative rotation angle between flanges"]
75-
tau(t) = 0.0, [description = "Torque between flanges"]
74+
function phi_rel(t)
75+
0.0, [description = "Relative rotation angle between flanges", units = u"rad"]
76+
end
77+
tau(t) = 0.0, [description = "Torque between flanges", u"N*m"]
7678
end
7779
@equations begin
7880
phi_rel ~ flange_b.phi - flange_a.phi
@@ -104,10 +106,21 @@ Partial model for the compliant connection of two rotational 1-dim. shaft flange
104106
flange_b = Flange()
105107
end
106108
@variables begin
107-
phi_rel(t) = 0.0, [description = "Relative rotation angle between flanges"]
108-
w_rel(t) = 0.0, [description = "Relative angular velocity between flanges"]
109-
a_rel(t) = 0.0, [description = "Relative angular acceleration between flanges"]
110-
tau(t) = 0.0, [description = "Torque between flanges"]
109+
function phi_rel(t)
110+
0.0, [description = "Relative rotation angle between flanges", unit = u"rad"]
111+
end
112+
function w_rel(t)
113+
0.0,
114+
[description = "Relative angular velocity between flanges", unit = u"rad*s^-1"]
115+
end
116+
function a_rel(t)
117+
0.0,
118+
[
119+
description = "Relative angular acceleration between flanges",
120+
unit = u"rad*s^-2",
121+
]
122+
end
123+
tau(t) = 0.0, [description = "Torque between flanges", unit = u"N*m"]
111124
end
112125
@equations begin
113126
phi_rel ~ flange_b.phi - flange_a.phi
@@ -138,7 +151,10 @@ Partial model for a component with one rotational 1-dim. shaft flange and a supp
138151
@component function PartialElementaryOneFlangeAndSupport2(; name, use_support = false)
139152
@named flange = Flange()
140153
sys = [flange]
141-
@variables phi_support(t)=0.0 [description = "Absolute angle of support flange"]
154+
@variables phi_support(t)=0.0 [
155+
description = "Absolute angle of support flange",
156+
unit = u"rad",
157+
]
142158
if use_support
143159
@named support = Support()
144160
eqs = [support.phi ~ phi_support
@@ -173,7 +189,10 @@ Partial model for a component with two rotational 1-dim. shaft flanges and a sup
173189
@named flange_a = Flange()
174190
@named flange_b = Flange()
175191
sys = [flange_a, flange_b]
176-
@variables phi_support(t)=0.0 [description = "Absolute angle of support flange"]
192+
@variables phi_support(t)=0.0 [
193+
description = "Absolute angle of support flange",
194+
unit = u"rad",
195+
]
177196
if use_support
178197
@named support = Support()
179198
eqs = [support.phi ~ phi_support

0 commit comments

Comments
 (0)