Skip to content

Commit

Permalink
refactor: describe x as the state; pass name to SystemModel; `p…
Browse files Browse the repository at this point in the history
…hi_rel0` defaults to 0.0 instead of guessing.
  • Loading branch information
ven-k committed Mar 18, 2024
1 parent 4a5e082 commit 5332a2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Blocks/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Initial value of integrator state ``x`` can be set with `x`
# Unknowns:
- `x`: Unknown of Integrator (with initial guess of 0.0)
- `x`: State of Integrator (with initial guess of 0.0)
"""
@mtkmodel Integrator begin
@extend u, y = siso = SISO()
@variables begin
x(t), [description = "Unknown of Integrator", guess = 0.0]
x(t), [description = "State of Integrator", guess = 0.0]
end
@parameters begin
k = 1, [description = "Gain"]
Expand All @@ -30,6 +30,7 @@ Initial value of integrator state ``x`` can be set with `x`
y ~ x
end
end

"""
Derivative(; name, k = 1, T, x = 0.0)
Expand Down
6 changes: 3 additions & 3 deletions src/Mechanical/Rotational/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Linear 1D rotational spring
# Parameters:
- `c`: [`N.m/rad`] Spring constant
- `phi_rel0`: [`rad`] Unstretched spring angle
- `phi_rel0`: [`rad`] Unstretched spring angle. Defaults to 0.0.
"""
@mtkmodel Spring begin
@extend phi_rel, tau = partial_comp = PartialCompliant()
Expand Down Expand Up @@ -156,7 +156,7 @@ Linear 1D rotational spring and damper
- `d`: [`N.m.s/rad`] Damping constant
- `c`: [`N.m/rad`] Spring constant
- `phi_rel0`: [`rad`] Unstretched spring angle
- `phi_rel0`: [`rad`] Unstretched spring angle. Defaults to 0.0
"""
@mtkmodel SpringDamper begin
@extend phi_rel, w_rel, tau = partial_comp = PartialCompliantWithRelativeStates()
Expand All @@ -167,7 +167,7 @@ Linear 1D rotational spring and damper
@parameters begin
d, [description = "Damping constant"]
c, [description = "Spring constant"]
phi_rel0, [description = "Unstretched spring angle", guess = 0.0]
phi_rel0 = 0.0, [description = "Unstretched spring angle"]
end
@equations begin
tau_c ~ c * (phi_rel - phi_rel0)
Expand Down
3 changes: 2 additions & 1 deletion test/Blocks/test_analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ function SystemModel(u = nothing; name = :model)
spring,
damper,
u
])
],
name)
end
ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper], name)
end
Expand Down

0 comments on commit 5332a2b

Please sign in to comment.