Skip to content

Commit fc86b99

Browse files
ven-kChrisRackauckas
authored andcommitted
refactor: cut down the description of variables
- or the formatter turns them into a function
1 parent e9f430d commit fc86b99

File tree

8 files changed

+36
-39
lines changed

8 files changed

+36
-39
lines changed

src/Mechanical/MultiBody2D/components.jl

+4-5
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@
6060
D(y_cm) ~ dy_cm
6161
D(dy_cm) ~ ddy_cm
6262

63-
# x forces
63+
# x forces
6464
m * ddx_cm ~ fx1 + fx2
6565

66-
# y forces
66+
# y forces
6767
m * ddy_cm ~ m * g + fy1 + fy2
6868

69-
# torques
69+
# torques
7070
I * ddA ~ -fy1 * (x2 - x1) / 2 + fy2 * (x2 - x1) / 2 + fx1 * (y2 - y1) / 2 -
7171
fx2 * (y2 - y1) / 2
7272

73-
# geometry
73+
# geometry
7474
x2 ~ l * cos(A) + x1
7575
y2 ~ l * sin(A) + y1
7676
x_cm ~ l * cos(A) / 2 + x1
@@ -84,5 +84,4 @@
8484
TY2.f ~ fy2
8585
TY2.v ~ dy2
8686
end
87-
8887
end

src/Mechanical/Translational/components.jl

+1-7
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const ABS = Val(:absolute)
159159
f ~ k * (sa - sb - l) #delta_s
160160
flange_a.f ~ +f
161161
flange_b.f ~ -f]
162-
return compose(ODESystem(eqs, t, vars, pars; name = name,),
162+
return compose(ODESystem(eqs, t, vars, pars; name = name),
163163
flange_a,
164164
flange_b) #, flange_a.f => k * (flange_a__s - flange_b__s - l)
165165
end
@@ -199,9 +199,3 @@ Linear 1D translational damper
199199
flange_b.f ~ -f
200200
end
201201
end
202-
203-
204-
#=
205-
206-
207-
=#

src/Mechanical/Translational/sensors.jl

-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ Linear 1D position input sensor.
4848
output.u ~ s
4949
flange.f ~ 0.0
5050
end
51-
5251
end

src/Mechanical/Translational/sources.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Linear 1D position input source
4242

4343
!solves_force && push!(eqs, 0 ~ flange.f)
4444

45-
ODESystem(eqs, t, vars, []; name, systems, defaults = [flange.v => 0, s.u => s__u_start])
45+
ODESystem(eqs, t, vars, [];
46+
name, systems, defaults = [flange.v => 0, s.u => s__u_start])
4647
end
4748

4849
@component function Velocity(; solves_force = true, name)
@@ -74,4 +75,4 @@ end
7475
!solves_force && push!(eqs, 0 ~ flange.f)
7576

7677
ODESystem(eqs, t, vars, []; name, systems, defaults = [flange.v => 0])
77-
end
78+
end

src/Mechanical/TranslationalModelica/components.jl

+14-14
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ Flange fixed in housing at a given position.
1313
"""
1414
@mtkmodel Fixed begin
1515
@parameters begin
16-
s0
16+
s0
1717
end
1818

1919
@components begin
20-
flange = Flange(; s = 0.0)
20+
flange = Flange(; s = 0.0)
2121
end
2222

2323
@equations begin
24-
flange.s ~ s0
24+
flange.s ~ s0
2525
end
2626
end
2727

@@ -45,12 +45,12 @@ Sliding mass with inertia
4545
"""
4646
@mtkmodel Mass begin
4747
@parameters begin
48-
m = 0.0, [description = "Mass of sliding mass [kg]"]
48+
m = 0.0, [description = "Mass of sliding mass [kg]"]
4949
end
5050
@variables begin
51-
s
52-
v(t) = 0.0, [description = "Absolute linear velocity of sliding mass [m/s]"]
53-
a(t) = 0.0, [description = "Absolute linear acceleration of sliding mass [m/s^2]"]
51+
s
52+
v(t) = 0.0, [description = "Absolute linear velocity of sliding mass [m/s]"]
53+
a(t) = 0.0, [description = "Absolute linear acceleration of sliding mass [m/s^2]"]
5454
end
5555
@extend flange_a, flange_b, s = pr = PartialRigid(; L = 0.0, s = s)
5656
@equations begin
@@ -78,12 +78,12 @@ Linear 1D translational spring
7878
@mtkmodel Spring begin
7979
@extend flange_a, flange_b, s_rel, f = pc = PartialCompliant()
8080
@parameters begin
81-
c = 0.0, [description = "Spring constant [N/m]"]
82-
s_rel0 = 0.0, [description = "Unstretched spring length [m]"]
81+
c = 0.0, [description = "Spring constant [N/m]"]
82+
s_rel0 = 0.0, [description = "Unstretched spring length [m]"]
8383
end
8484

8585
@equations begin
86-
f ~ c * (s_rel - s_rel0)
86+
f ~ c * (s_rel - s_rel0)
8787
end
8888
end
8989

@@ -104,13 +104,13 @@ Linear 1D translational damper
104104
@mtkmodel Damper begin
105105
@extend flange_a, flange_b, v_rel, f = pc = PartialCompliantWithRelativeStates()
106106
@parameters begin
107-
d = 0.0, [description = "Damping constant [Ns/m]"]
107+
d = 0.0, [description = "Damping constant [Ns/m]"]
108108
end
109109
@variables begin
110-
lossPower(t) = 0.0, [description = "Power dissipated by the damper [W]"]
110+
lossPower(t) = 0.0, [description = "Power dissipated by the damper [W]"]
111111
end
112112
@equations begin
113-
f ~ d * v_rel
114-
lossPower ~ f * v_rel
113+
f ~ d * v_rel
114+
lossPower ~ f * v_rel
115115
end
116116
end

src/Mechanical/TranslationalModelica/utils.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Partial model for the compliant connection of two translational 1-dim. flanges.
4646
@mtkmodel PartialCompliant begin
4747
@extend (flange_a, flange_b) = pt = PartialTwoFlanges()
4848
@variables begin
49-
s_rel(t) = 0.0, [description = "Relative distance between flanges flange_b.s - flange_a.s"]
50-
f(t) = 0.0, [description = "Force between flanges (positive in direction of flange axis R)"]
49+
s_rel(t) = 0.0, [description = "Relative distance between flanges"]
50+
f(t) = 0.0, [description = "Force between flanges"]
5151
end
5252

5353
@equations begin
@@ -71,9 +71,9 @@ Partial model for the compliant connection of two translational 1-dim. flanges.
7171
@mtkmodel PartialCompliantWithRelativeStates begin
7272
@extend flange_a, flange_b = pt = PartialTwoFlanges()
7373
@variables begin
74-
s_rel(t) = 0.0, [description = "Relative distance between flanges flange_b.s - flange_a.s"]
75-
v_rel(t) = 0.0, [description = "Relative linear velocity (= D(s_rel))"]
76-
f(t) = 0.0, [description = "Forces between flanges (= flange_b.f)"]
74+
s_rel(t) = 0.0, [description = "Relative distance between flanges"]
75+
v_rel(t) = 0.0, [description = "Relative linear velocity))"]
76+
f(t) = 0.0, [description = "Forces between flanges"]
7777
end
7878

7979
@equations begin
@@ -149,10 +149,10 @@ end
149149
@mtkmodel PartialRigid begin
150150
@extend flange_a, flange_b = ptf = PartialTwoFlanges()
151151
@variables begin
152-
s(t) = 0.0, [description = "Absolute position of center of component (s = flange_a.s + L/2 = flange_b.s - L/2)"]
152+
s(t) = 0.0, [description = "Absolute position of center of component"]
153153
end
154154
@parameters begin
155-
L = 0.0, [description = "Length of component, from left flange to right flange (= flange_b.s - flange_a.s)"]
155+
L = 0.0, [description = "Length of component, from left flange to right flange"]
156156
end
157157
@equations begin
158158
flange_a.s ~ s - L / 2

src/Mechanical/TranslationalPosition/components.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ Linear 1D translational spring
114114
- `flange_a: 1-dim. translational flange on one side of spring`
115115
- `flange_b: 1-dim. translational flange on opposite side of spring` #default function
116116
"""
117-
Spring(; name, k, flange_a__s = 0, flange_b__s = 0, l = 0) = Spring(ABS; name, k, flange_a__s, flange_b__s, l) #default function
117+
function Spring(; name, k, flange_a__s = 0, flange_b__s = 0, l = 0)
118+
Spring(ABS; name, k, flange_a__s, flange_b__s, l)
119+
end #default function
118120

119-
@component function Spring(::Val{:absolute}; name, k, flange_a__s = 0, flange_b__s = 0, l = 0)
121+
@component function Spring(::Val{:absolute};
122+
name, k, flange_a__s = 0,
123+
flange_b__s = 0, l = 0)
120124
pars = @parameters begin
121125
k = k
122126
l = l

src/Mechanical/TranslationalPosition/utils.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Partial model for the compliant connection of two translational 1-dim. flanges.
7676
- `f`: [N] Force between flanges (= flange_b.f)
7777
"""
7878
@mtkmodel PartialCompliantWithRelativeStates begin
79-
@components begin
79+
@components begin
8080
flange_a = Flange()
8181
flange_b = Flange()
8282
end

0 commit comments

Comments
 (0)