From 4e245f7d41c41b24aa85252b431a912e979f4b61 Mon Sep 17 00:00:00 2001 From: spaette Date: Tue, 27 Jun 2023 12:48:18 -0500 Subject: [PATCH] typos --- docs/src/examples/automatic_differentiation.md | 6 +++--- docs/src/examples/example.md | 6 +++--- example/example_pid_design.md | 4 ++-- example/symbolic_computations.jl | 6 +++--- .../ControlSystemsBaseImplicitDifferentiationExt.jl | 4 ++-- lib/ControlSystemsBase/src/ControlSystemsBase.jl | 2 +- lib/ControlSystemsBase/src/analysis.jl | 2 +- lib/ControlSystemsBase/src/connections.jl | 2 +- lib/ControlSystemsBase/src/delay_systems.jl | 4 ++-- lib/ControlSystemsBase/src/discrete.jl | 6 +++--- lib/ControlSystemsBase/src/freqresp.jl | 2 +- lib/ControlSystemsBase/src/hammerstein_weiner.jl | 2 +- lib/ControlSystemsBase/src/matrix_comps.jl | 6 +++--- lib/ControlSystemsBase/src/pid_design.jl | 2 +- lib/ControlSystemsBase/src/plotting.jl | 6 +++--- lib/ControlSystemsBase/src/sensitivity_functions.jl | 2 +- lib/ControlSystemsBase/src/simplification.jl | 2 +- lib/ControlSystemsBase/src/timeresp.jl | 12 ++++++------ lib/ControlSystemsBase/src/types/DelayLtiSystem.jl | 6 +++--- .../src/types/HammersteinWiener.jl | 2 +- lib/ControlSystemsBase/src/types/LFTSystem.jl | 2 +- .../src/types/PartitionedStateSpace.jl | 4 ++-- .../src/types/SisoTfTypes/SisoRational.jl | 2 +- .../src/types/SisoTfTypes/SisoZpk.jl | 4 ++-- lib/ControlSystemsBase/src/types/StateSpace.jl | 4 ++-- lib/ControlSystemsBase/src/types/TimeEvolution.jl | 2 +- lib/ControlSystemsBase/src/types/TransferFunction.jl | 4 ++-- lib/ControlSystemsBase/src/types/conversion.jl | 4 ++-- lib/ControlSystemsBase/src/utilities.jl | 4 ++-- lib/ControlSystemsBase/test/runtests.jl | 2 +- lib/ControlSystemsBase/test/test_analysis.jl | 2 +- lib/ControlSystemsBase/test/test_autovec.jl | 2 +- lib/ControlSystemsBase/test/test_complex.jl | 2 +- lib/ControlSystemsBase/test/test_conversion.jl | 2 +- lib/ControlSystemsBase/test/test_delayed_systems.jl | 4 ++-- lib/ControlSystemsBase/test/test_discrete.jl | 2 +- lib/ControlSystemsBase/test/test_linalg.jl | 2 +- lib/ControlSystemsBase/test/test_statespace.jl | 2 +- lib/ControlSystemsBase/test/test_timeresp.jl | 2 +- lib/ControlSystemsBase/test/test_transferfunction.jl | 4 ++-- lib/ControlSystemsBase/test/test_zpk.jl | 4 ++-- src/root_locus.jl | 4 ++-- src/timeresp.jl | 4 ++-- test/runtests.jl | 2 +- 44 files changed, 77 insertions(+), 77 deletions(-) diff --git a/docs/src/examples/automatic_differentiation.md b/docs/src/examples/automatic_differentiation.md index 5753a169d..605f04c48 100644 --- a/docs/src/examples/automatic_differentiation.md +++ b/docs/src/examples/automatic_differentiation.md @@ -194,7 +194,7 @@ plot_optimized(P, params, res.u, systemspid) The optimized controller achieves more or less the same low peak in the sensitivity function, but does this while *both* making the step responses significantly faster *and* using much less controller gain for large frequencies (the orange sensitivity function), an altogether better tuning. The only potentially negative effect of this tuning is that the overshoot in response to a reference step increased slightly, indicated also by the slightly higher peak in the complimentary sensitivity function (green). However, the response to reference steps can (and most often should) be additionally shaped by reference pre-filtering (sometimes referred to as "feedforward" or "reference shaping"), by introducing an additional filter appearing in the feedforward path only, thus allowing elimination of the overshoot without affecting the closed-loop properties. ## Optimization-based tuning--LQG controller -We could attempt a similar automatic tuning of an LQG controller. This time, we choose to optimize the weight matrices of the LQR problem and the state covariance matrix of the noise. The synthesis of an LQR controller involves the solution of a Ricatti equation, which in turn involves performing a Schur decomposition. These steps hard hard to differentiate through in a conventional way, but we can make use of implicit differentiation using the implicit function theorem. To do so, we load the package `ImplicitDifferentiation`, and define the conditions that hold at the solution of the Ricatti equaiton: +We could attempt a similar automatic tuning of an LQG controller. This time, we choose to optimize the weight matrices of the LQR problem and the state covariance matrix of the noise. The synthesis of an LQR controller involves the solution of a Ricatti equation, which in turn involves performing a Schur decomposition. These steps hard hard to differentiate through in a conventional way, but we can make use of implicit differentiation using the implicit function theorem. To do so, we load the package `ImplicitDifferentiation`, and define the conditions that hold at the solution of the Ricatti equation: ```math A^TX + XA - XBR^{-1}B^T X + Q = 0 ``` @@ -308,11 +308,11 @@ The following issues are currently known to exist when using AD through ControlS ### ForwardDiff [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) works for a lot of workflows without any intervention required from the user. The following known limitations exist: -- The function [`c2d`](@ref) with the default `:zoh` discretization method makes a call to `LinearAlgebra.exp!`, which is not defined for `ForwardDiff.Dual` numbers. A forward rule for this function exist in ChainRules, which can be eneabled using ForwardDiffChainRules.jl, but [this PR](https://github.com/ThummeTo/ForwardDiffChainRules.jl/pull/16) must be merged and relseased before it will work as intended. A workaround is to use the `:tustin` method instead, or [manually defining this method](https://github.com/JuliaControl/ControlSystems.jl/blob/master/docs/src/examples/automatic_differentiation.md?plain=1#LL2C1-L25C4). +- The function [`c2d`](@ref) with the default `:zoh` discretization method makes a call to `LinearAlgebra.exp!`, which is not defined for `ForwardDiff.Dual` numbers. A forward rule for this function exist in ChainRules, which can be enabled using ForwardDiffChainRules.jl, but [this PR](https://github.com/ThummeTo/ForwardDiffChainRules.jl/pull/16) must be merged and released before it will work as intended. A workaround is to use the `:tustin` method instead, or [manually defining this method](https://github.com/JuliaControl/ControlSystems.jl/blob/master/docs/src/examples/automatic_differentiation.md?plain=1#LL2C1-L25C4). - The function `svdvals` does not have a forward rule defined. This means that the functions [`sigma`](@ref) and `opnorm` will not work for MIMO systems with ForwardDiff. SISO, MISO and SIMO systems will, however, work. - [`hinfnorm`](@ref) requires ImplicitDifferentiation.jl and ComponentArrays.jl to be manually loaded by the user, after which there are implicit differentiation rules defined for [`hinfnorm`](@ref). The implicit rule calls `opnorm`, and is thus affected by the first limitation above for MIMO systems. [`hinfnorm`](@ref) has a reverse rule defined in RobustAndOptimalControl.jl, which is not affected by this limitation. - [`are`](@ref), [`lqr`](@ref) and [`kalman`](@ref) all require ImplicitDifferentiation.jl and ComponentArrays.jl to be manually loaded by the user, after which there are implicit differentiation rules defined. To invoke the correct method of these functions, it is important that the second matrix (corresponding to input or measurement) has the `Dual` number type, i.e., the `R` matrix in `lqr(P, Q, R)` or `lqr(Continuous, A, B, Q, R)` -- The `schur` factorization has an implicit differentiation rule defined, but the companion function `ordschur` does not. This is the fundamental reason for requireing ImplicitDifferentiation.jl to differentiate through the Ricatti equation solver. `schur` is called in several additional places, including [`balreal`](@ref) and all [`lyap`](@ref) solvers. Many of these algorithms also call `givensAlgorithm` which has no rule either. +- The `schur` factorization has an implicit differentiation rule defined, but the companion function `ordschur` does not. This is the fundamental reason for requiring ImplicitDifferentiation.jl to differentiate through the Ricatti equation solver. `schur` is called in several additional places, including [`balreal`](@ref) and all [`lyap`](@ref) solvers. Many of these algorithms also call `givensAlgorithm` which has no rule either. - An implicit rule is defined for continuous-time [`lyap`](@ref) and [`plyap`](@ref) solvers, but not yet for discrete-time solvers. This means that [`gram`](@ref) [`covar`](@ref) and [`norm`](@ref) (``H_2``-norm) is differentiable for continuous-time systems but not for discrete. ### Reverse-mode AD diff --git a/docs/src/examples/example.md b/docs/src/examples/example.md index a78708bdf..a8859e0e3 100644 --- a/docs/src/examples/example.md +++ b/docs/src/examples/example.md @@ -138,7 +138,7 @@ Tf = 1/20ω C, kp, ki, kd, fig, CF = loopshapingPID(P, ω; Mt, ϕt, doplot=true, Tf) fig ``` -As we can see, the addition of the filter increases the high-frequency roll-off in both $T$ and $CS$, which is typically desireable. +As we can see, the addition of the filter increases the high-frequency roll-off in both $T$ and $CS$, which is typically desirable. To get better control over the filter, it can be pre-designed and supplied to [`loopshapingPID`](@ref) with the keyword argument `F`: ```julia @@ -193,12 +193,12 @@ Bm = conv(B⁺, B⁻) # In this case, keep the entire numerator polynomial of t R,S,T = rstc(B⁺,B⁻,A,Bm,Am,Ao,AR) # Calculate the 2-DOF controller polynomials -Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectores are of equal length +Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectors are of equal length plot(step(P, 20)) plot!(step(Gcl, 20)) # Visualize the open and closed loop responses. save_docs_plot("ppstepplot.svg") # hide -gangoffourplot(P, tf(-S,R)) # Plot the gang of four to check that all tranfer functions are OK +gangoffourplot(P, tf(-S,R)) # Plot the gang of four to check that all transfer functions are OK save_docs_plot("ppgofplot.svg"); # hide # output diff --git a/example/example_pid_design.md b/example/example_pid_design.md index b69d29c26..bc2db16ed 100644 --- a/example/example_pid_design.md +++ b/example/example_pid_design.md @@ -48,10 +48,10 @@ Bm = conv(B⁺, B⁻) # In this case, keep the entire numerator polynomial of t R,S,T = rstc(B⁺,B⁻,A,Bm,Am,Ao,AR) # Calculate the 2-DOF controller polynomials -Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectores are of equal length +Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectors are of equal length stepplot([P,Gcl]) # Visualize the open and closed loop responses. -gangoffourplot(P, tf(-S,R)) # Plot the gang of four to check that all tranfer functions are OK +gangoffourplot(P, tf(-S,R)) # Plot the gang of four to check that all transfer functions are OK ``` diff --git a/example/symbolic_computations.jl b/example/symbolic_computations.jl index 5005dc009..ed0a5c1d9 100644 --- a/example/symbolic_computations.jl +++ b/example/symbolic_computations.jl @@ -2,7 +2,7 @@ using Revise using ControlSystems using SymPy -# Some basic demonstations of working with symbolic LTI systems +# Some basic demonstrations of working with symbolic LTI systems # Functionality is rather limited, and for complicated expressions the # printing is awful. # For additional functionality, see https://github.com/JuliaControl/SymbolicControlSystems.jl @@ -33,7 +33,7 @@ end # Define a symbolic parameter a = symbols("a", real=true) -# Define a statespace and a trasnfer function +# Define a statespace and a transfer function sys = ss([1 a; a 1], [0; 1], [1 0], 0) s = tf("s") @@ -73,7 +73,7 @@ real_roots = roots[SymPy.imag(roots) .== 0] maximum([subs(sys_fr_mag, w => r) for r in real_roots]) -# Compute the impulse resonse of some systems (on statespace form) +# Compute the impulse response of some systems (on statespace form) impulse(sys)[1] simplify(impulse(ss(G))[1]) diff --git a/lib/ControlSystemsBase/ext/ControlSystemsBaseImplicitDifferentiationExt.jl b/lib/ControlSystemsBase/ext/ControlSystemsBaseImplicitDifferentiationExt.jl index af956012e..7f3556844 100644 --- a/lib/ControlSystemsBase/ext/ControlSystemsBaseImplicitDifferentiationExt.jl +++ b/lib/ControlSystemsBase/ext/ControlSystemsBaseImplicitDifferentiationExt.jl @@ -215,9 +215,9 @@ const implicit_hinfnorm = ImplicitFunction(forward_hinfnorm, conditions_hinfnorm """ hinfnorm(sys::StateSpace{Continuous, <:Dual}; kwargs) -The H∞ norm can be differentiated through using ForwardDiff.jl, but at the time of writing, is limited to systems with *either* a signel input *or* a single output. +The H∞ norm can be differentiated through using ForwardDiff.jl, but at the time of writing, is limited to systems with *either* a single input *or* a single output. -A reverse-differention rule is defined in RobustAndOptimalControl.jl, which means that hinfnorm is differentiable using, e.g., Zygote in reverse mode. +A reverse-differentiation rule is defined in RobustAndOptimalControl.jl, which means that hinfnorm is differentiable using, e.g., Zygote in reverse mode. """ function hinfnorm(sys::StateSpace{Continuous, <:Dual}; kwargs...) A,B,C,D = ssdata(sys) diff --git a/lib/ControlSystemsBase/src/ControlSystemsBase.jl b/lib/ControlSystemsBase/src/ControlSystemsBase.jl index 30233dbb0..4bdce6a7c 100644 --- a/lib/ControlSystemsBase/src/ControlSystemsBase.jl +++ b/lib/ControlSystemsBase/src/ControlSystemsBase.jl @@ -152,7 +152,7 @@ include("types/Lti.jl") include("types/SisoTf.jl") -# Transfer functions and tranfer function elemements +# Transfer functions and transfer function elements include("types/TransferFunction.jl") include("types/SisoTfTypes/SisoZpk.jl") include("types/SisoTfTypes/SisoRational.jl") diff --git a/lib/ControlSystemsBase/src/analysis.jl b/lib/ControlSystemsBase/src/analysis.jl index 7af82e767..da43b476a 100644 --- a/lib/ControlSystemsBase/src/analysis.jl +++ b/lib/ControlSystemsBase/src/analysis.jl @@ -327,7 +327,7 @@ end Calculate the relative gain array of `G` at frequencies `w`. G(iω) .* pinv(tranpose(G(iω))) -The RGA can be used to find input-output pairings for MIMO control using individially tuned loops. Pair the inputs and outputs such that the RGA(ωc) at the crossover frequency becomes as close to diagonal as possible. Avoid pairings such that RGA(0) contains negative diagonal elements. +The RGA can be used to find input-output pairings for MIMO control using individually tuned loops. Pair the inputs and outputs such that the RGA(ωc) at the crossover frequency becomes as close to diagonal as possible. Avoid pairings such that RGA(0) contains negative diagonal elements. - The sum of the absolute values of the entries in the RGA is a good measure of the "true condition number" of G, the best condition number that can be achieved by input/output scaling of `G`, -Glad, Ljung. - The RGA is invariant to input/output scaling of `G`. diff --git a/lib/ControlSystemsBase/src/connections.jl b/lib/ControlSystemsBase/src/connections.jl index af2bc1afc..07769b864 100644 --- a/lib/ControlSystemsBase/src/connections.jl +++ b/lib/ControlSystemsBase/src/connections.jl @@ -424,7 +424,7 @@ mutable(x::StaticArray, ::Type{T}) where T = Matrix{T}(x) feedback2dof(P,R,S,T) feedback2dof(B,A,R,S,T) -- Return `BT/(AR+ST)` where B and A are the numerator and denomenator polynomials of `P` respectively +- Return `BT/(AR+ST)` where B and A are the numerator and denominator polynomials of `P` respectively - Return `BT/(AR+ST)` """ function feedback2dof(P::TransferFunction,R,S,T) diff --git a/lib/ControlSystemsBase/src/delay_systems.jl b/lib/ControlSystemsBase/src/delay_systems.jl index 404d34070..56457f451 100644 --- a/lib/ControlSystemsBase/src/delay_systems.jl +++ b/lib/ControlSystemsBase/src/delay_systems.jl @@ -76,7 +76,7 @@ function _bounds_and_features(sys::DelayLtiSystem, plot::Val) return [min(ws[1], floor(extreme[1]-0.2)), max(ws[2], ceil(extreme[2]+0.2))], pz end -# Againm we have to do something for default vectors, more or less a copy from timeresp.jl +# Again we have to do something for default vectors, more or less a copy from timeresp.jl function _default_dt(sys::DelayLtiSystem) if !isstable(sys.P.P) return 0.05 # Something small @@ -111,7 +111,7 @@ function _linscale(p::Polynomial, a) return Polynomial(coeffs_scaled) end -# Coefficeints for Padé approximations +# Coefficients for Padé approximations # PADE_Q_COEFFS = [Polynomial([binomial(N,i)*prod(N+1:2*N-i) for i=0:N]) for N=1:10] const PADE_Q_COEFFS = [[2, 1], [12, 6, 1], diff --git a/lib/ControlSystemsBase/src/discrete.jl b/lib/ControlSystemsBase/src/discrete.jl index 2bf8c0815..5247ca941 100644 --- a/lib/ControlSystemsBase/src/discrete.jl +++ b/lib/ControlSystemsBase/src/discrete.jl @@ -13,7 +13,7 @@ relative to the time constants of the system. `method = :tustin` performs a bilinear transform with prewarp frequency `w_prewarp`. -- `w_prewarp`: Frequency (rad/s) for pre-warping when usingthe Tustin method, has no effect for other methods. +- `w_prewarp`: Frequency (rad/s) for pre-warping when using the Tustin method, has no effect for other methods. See also `c2d_x0map` """ @@ -40,7 +40,7 @@ function c2d_x0map(sys::AbstractStateSpace{<:Continuous}, Ts::Real, method::Symb Bd = M[1:nx, nx+1:nx+nu] Cd = C Dd = D - x0map = [Matrix{T}(I, nx, nx) zeros(nx, nu)] # Cant use I if nx==0 + x0map = [Matrix{T}(I, nx, nx) zeros(nx, nu)] # Can't use I if nx==0 elseif method === :foh M = exp!([A*Ts B*Ts zeros(nx, nu); zeros(nu, nx + nu) Matrix{T}(I, nu, nu); @@ -78,7 +78,7 @@ end Convert discrete-time system to a continuous time system, assuming that the discrete-time system was discretized using `method`. Available methods are `:zoh, :fwdeuler´. -- `w_prewarp`: Frequency for pre-warping when usingthe Tustin method, has no effect for other methods. +- `w_prewarp`: Frequency for pre-warping when using the Tustin method, has no effect for other methods. """ function d2c(sys::AbstractStateSpace{<:Discrete}, method::Symbol=:zoh; w_prewarp=0) A, B, C, D = ssdata(sys) diff --git a/lib/ControlSystemsBase/src/freqresp.jl b/lib/ControlSystemsBase/src/freqresp.jl index a1820936a..9b135b7b5 100644 --- a/lib/ControlSystemsBase/src/freqresp.jl +++ b/lib/ControlSystemsBase/src/freqresp.jl @@ -14,7 +14,7 @@ end BodemagWorkspace(R::Array{Complex{T}, 3}, mag::Array{T, 3}) BodemagWorkspace{T}(ny, nu, N) -Genereate a workspace object for use with the in-place function [`bodemag!`](@ref). +Generate a workspace object for use with the in-place function [`bodemag!`](@ref). `N` is the number of frequency points, alternatively, the input `ω` can be provided instead of `N`. Note: for threaded applications, create one workspace object per thread. diff --git a/lib/ControlSystemsBase/src/hammerstein_weiner.jl b/lib/ControlSystemsBase/src/hammerstein_weiner.jl index 12154425c..e57f8bd83 100644 --- a/lib/ControlSystemsBase/src/hammerstein_weiner.jl +++ b/lib/ControlSystemsBase/src/hammerstein_weiner.jl @@ -36,7 +36,7 @@ function _bounds_and_features(sys::HammersteinWienerSystem, plot::Val) _bounds_and_features(sys.P.P, plot) end -# Againm we have to do something for default vectors, more or less a copy from timeresp.jl +# Again we have to do something for default vectors, more or less a copy from timeresp.jl function _default_dt(sys::HammersteinWienerSystem) _default_dt(sys.P.P) end diff --git a/lib/ControlSystemsBase/src/matrix_comps.jl b/lib/ControlSystemsBase/src/matrix_comps.jl index 5ec699433..87bce7061 100644 --- a/lib/ControlSystemsBase/src/matrix_comps.jl +++ b/lib/ControlSystemsBase/src/matrix_comps.jl @@ -1,5 +1,5 @@ const _scaling_notice = """ -Note: Gramian computations are sensitive to input-output scaling. For the result of a numerical balancing, gramian computation or truncation of MIMO systems to be meaningful, the inputs and outputs of the system must thusbe scaled in a meaningful way. A common (but not the only) approach is: +Note: Gramian computations are sensitive to input-output scaling. For the result of a numerical balancing, gramian computation or truncation of MIMO systems to be meaningful, the inputs and outputs of the system must thus be scaled in a meaningful way. A common (but not the only) approach is: - The outputs are scaled such that the maximum allowed control error, the maximum expected reference variation, or the maximum expected variation, is unity. - The input variables are scaled to have magnitude one. This is done by dividing each variable by its maximum expected or allowed change, i.e., ``u_{scaled} = u / u_{max}`` @@ -311,7 +311,7 @@ function _infnorm_two_steps_ct(sys::AbstractStateSpace, normtype::Symbol, tol=1e # approximag is a tuning parameter: what does it mean for a number to be on the imaginary axis # Because of this tuning for example, the relative precision that we provide on the norm computation # is not a true guarantee, more an order of magnitude - # outputs: An approximatation of the L∞ norm and the frequency ω_peak at which it is achieved + # outputs: An approximation of the L∞ norm and the frequency ω_peak at which it is achieved # QUESTION: The tolerance for determining if there are poles on the imaginary axis # would not be very appropriate for systems with slow dynamics? T = promote_type(real(numeric_type(sys)), Float64) @@ -392,7 +392,7 @@ end function _infnorm_two_steps_dt(sys::AbstractStateSpace, normtype::Symbol, tol=1e-6, maxIters=250, approxcirc=1e-8) # Discrete-time version of linfnorm_two_steps_ct above - # Compuations are done in normalized frequency θ + # Computations are done in normalized frequency θ on_unit_circle = z -> abs(abs(z) - 1) < approxcirc # Helper fcn for readability diff --git a/lib/ControlSystemsBase/src/pid_design.jl b/lib/ControlSystemsBase/src/pid_design.jl index 49fbd181d..f99fe62b1 100644 --- a/lib/ControlSystemsBase/src/pid_design.jl +++ b/lib/ControlSystemsBase/src/pid_design.jl @@ -32,7 +32,7 @@ The functions `pid_tf` and `pid_ss` are also exported. They take the same parame and is what is actually called in `pid` based on the `state_space` parameter. """ function pid(param_p, param_i, param_d=zero(typeof(param_p)); form=:standard, Ts=nothing, Tf=nothing, state_space=false) - C = if state_space # Type unstability? Can it be fixed easily, does it matter? + C = if state_space # Type instability? Can it be fixed easily, does it matter? pid_ss(param_p, param_i, param_d; form, Tf) else pid_tf(param_p, param_i, param_d; form, Tf) diff --git a/lib/ControlSystemsBase/src/plotting.jl b/lib/ControlSystemsBase/src/plotting.jl index 4cf8c0ec1..5b41eca3f 100644 --- a/lib/ControlSystemsBase/src/plotting.jl +++ b/lib/ControlSystemsBase/src/plotting.jl @@ -25,7 +25,7 @@ function setPlotScale(str::AbstractString) end # """ -# Get atributes from xlims or ylims +# Get attributes from xlims or ylims # default to extrema(wmag) if xlims/ylims not defined or empty # """ # function getlims(xylims, plotattributes, wmag) @@ -231,7 +231,7 @@ _processfreqplot(plottype, system::LTISystem, args...) = _processfreqplot(plottype, [system], args...) # Catch when system is not vector, with and without frequency input -# Cantch correct form +# Catch correct form function _processfreqplot(plottype, systems::AbstractVector{<:LTISystem}, w = _default_freq_vector(systems, plottype)) @@ -378,7 +378,7 @@ end Create a Nyquist plot of the `LTISystem`(s). A frequency vector `w` can be optionally provided. -- `unit_circle`: if the unit circle should be displayed. The Nyquist curve crosses the unit circle at the gain corssover frequency. +- `unit_circle`: if the unit circle should be displayed. The Nyquist curve crosses the unit circle at the gain crossover frequency. - `Ms_circles`: draw circles corresponding to given levels of sensitivity (circles around -1 with radii `1/Ms`). `Ms_circles` can be supplied as a number or a vector of numbers. A design staying outside such a circle has a phase margin of at least `2asin(1/(2Ms))` rad and a gain margin of at least `Ms/(Ms-1)`. - `Mt_circles`: draw circles corresponding to given levels of complementary sensitivity. `Mt_circles` can be supplied as a number or a vector of numbers. - `critical_point`: point on real axis to mark as critical for encirclements diff --git a/lib/ControlSystemsBase/src/sensitivity_functions.jl b/lib/ControlSystemsBase/src/sensitivity_functions.jl index 184b5d8bb..7a8e8b1e8 100644 --- a/lib/ControlSystemsBase/src/sensitivity_functions.jl +++ b/lib/ControlSystemsBase/src/sensitivity_functions.jl @@ -23,7 +23,7 @@ d₁────+──┴──► P ├─────┬──►e₄ """ See [`output_sensitivity`](@ref) -The output [sensitivity function](https://en.wikipedia.org/wiki/Sensitivity_(control_systems)) ``S_o = (I + PC)^{-1}`` is the transfer function from a reference input to control error, while the input sensitivity function ``S_i = (I + CP)^{-1}`` is the transfer function from a disturbance at the plant input to the total plant input. For SISO systems, input and output sensitivity functions are equal. In general, we want to minimize the sensitivity function to improve robustness and performance, but pracitcal constraints always cause the sensitivity function to tend to 1 for high frequencies. A robust design minimizes the peak of the sensitivity function, ``M_S``. The peak magnitude of ``S`` is the inverse of the distance between the open-loop Nyquist curve and the critical point -1. Upper bounding the sensitivity peak ``M_S`` gives lower-bounds on phase and gain margins according to +The output [sensitivity function](https://en.wikipedia.org/wiki/Sensitivity_(control_systems)) ``S_o = (I + PC)^{-1}`` is the transfer function from a reference input to control error, while the input sensitivity function ``S_i = (I + CP)^{-1}`` is the transfer function from a disturbance at the plant input to the total plant input. For SISO systems, input and output sensitivity functions are equal. In general, we want to minimize the sensitivity function to improve robustness and performance, but practical constraints always cause the sensitivity function to tend to 1 for high frequencies. A robust design minimizes the peak of the sensitivity function, ``M_S``. The peak magnitude of ``S`` is the inverse of the distance between the open-loop Nyquist curve and the critical point -1. Upper bounding the sensitivity peak ``M_S`` gives lower-bounds on phase and gain margins according to ```math ϕ_m ≥ 2\\text{sin}^{-1}(\\frac{1}{2M_S}), g_m ≥ \\frac{M_S}{M_S-1} ``` diff --git a/lib/ControlSystemsBase/src/simplification.jl b/lib/ControlSystemsBase/src/simplification.jl index 5014e9631..103aac075 100644 --- a/lib/ControlSystemsBase/src/simplification.jl +++ b/lib/ControlSystemsBase/src/simplification.jl @@ -45,7 +45,7 @@ structurally controllable based on the location of zeros in the matrices. function struct_ctrb_states(A::AbstractVecOrMat, B::AbstractVecOrMat) size(A,1) > typemax(UInt16) && error("Maximum size of A exceeded. If you encounter this error, please open an issue. This limit is not fundamental and exists for performance reasons only.") # UInt16 can only store up to 65535, so if A is completely dense and of size larger than 65535, the computations below might overflow. This is exceedingly unlikely though. - bitA = UInt16.(.!iszero.(A)) # Convert to Int because mutiplying with a bit matrix is slow + bitA = UInt16.(.!iszero.(A)) # Convert to Int because multiplying with a bit matrix is slow x = vec(any(B .!= 0, dims=2)) # index vector indicating states that have been affected by input xi = bitA * x xi2 = similar(xi) diff --git a/lib/ControlSystemsBase/src/timeresp.jl b/lib/ControlSystemsBase/src/timeresp.jl index 5f1c26472..d45832b0f 100644 --- a/lib/ControlSystemsBase/src/timeresp.jl +++ b/lib/ControlSystemsBase/src/timeresp.jl @@ -19,7 +19,7 @@ end LsimWorkspace(sys::AbstractStateSpace, u::AbstractMatrix) LsimWorkspace{T}(ny, nu, nx, N) -Genereate a workspace object for use with the in-place function [`lsim!`](@ref). +Generate a workspace object for use with the in-place function [`lsim!`](@ref). `sys` is the discrete-time system to be simulated and `N` is the number of time steps, alternatively, the input `u` can be provided instead of `N`. Note: for threaded applications, create one workspace object per thread. """ @@ -112,7 +112,7 @@ impulse(sys::TransferFunction, t::AbstractVector; kwargs...) = impulse(ss(sys), result = lsim(sys, u[, t]; x0, method]) result = lsim(sys, u::Function, t; x0, method) -Calculate the time response of system `sys` to input `u`. If `x0` is ommitted, +Calculate the time response of system `sys` to input `u`. If `x0` is omitted, a zero vector is used. The result structure contains the fields `y, t, x, u` and can be destructured automatically by iteration, e.g., @@ -125,10 +125,10 @@ plot(result, plotu=true, plotx=false) ``` `y`, `x`, `u` have time in the second dimension. Initial state `x0` defaults to zero. -Continuous-time systems are simulated using an ODE solver if `u` is a function (requires using ControlSystems). If `u` is an array, the system is discretized (with `method=:zoh` by default) before simulation. For a lower-level inteface, see `?Simulator` and `?solve` +Continuous-time systems are simulated using an ODE solver if `u` is a function (requires using ControlSystems). If `u` is an array, the system is discretized (with `method=:zoh` by default) before simulation. For a lower-level interface, see `?Simulator` and `?solve` `u` can be a function or a *matrix* of precalculated control signals and must have dimensions `(nu, length(t))`. -If `u` is a function, then `u(x,i)` (for discrete systems) or `u(x,t)` (for continuos ones) is called to calculate the control signal at every iteration (time instance used by solver). This can be used to provide a control law such as state feedback `u(x,t) = -L*x` calculated by `lqr`. +If `u` is a function, then `u(x,i)` (for discrete systems) or `u(x,t)` (for continuous ones) is called to calculate the control signal at every iteration (time instance used by solver). This can be used to provide a control law such as state feedback `u(x,t) = -L*x` calculated by `lqr`. To simulate a unit step at `t=t₀`, use `(x,t)-> t ≥ t₀`, for a ramp, use `(x,t)-> t`, for a step at `t=5`, use `(x,t)-> (t >= 5)` etc. *Note:* The function `u` will be called once before simulating to verify that it returns an array of the correct dimensions. This can cause problems if `u` is stateful. You can disable this check by passing `check_u = false`. @@ -299,7 +299,7 @@ Simulate the discrete time system `x[k + 1] = A x[k] + B u[k]`, returning `x`. If `x0` is not provided, a zero-vector is used. The type of `x0` determines the matrix structure of the returned result, -e.g, `x0` should prefereably not be a sparse vector. +e.g, `x0` should preferably not be a sparse vector. If `u` is a function, then `u(x,i)` is called to calculate the control signal every iteration. This can be used to provide a control law such as state feedback `u=-Lx` calculated by `lqr`. In this case, an integrer `iters` must be provided that indicates the number of iterations. """ @@ -368,7 +368,7 @@ function lsim!(ws::LsimWorkspace{T}, sys::AbstractStateSpace{<:Discrete}, u, t:: x0::AbstractVecOrMat=zeros(eltype(T), nstates(sys))) where T x, y = ws.x, ws.y - size(x, 2) == length(t) || throw(ArgumentError("Inconsitent lengths of workspace cache and t")) + size(x, 2) == length(t) || throw(ArgumentError("Inconsistent lengths of workspace cache and t")) arr = u isa AbstractArray if arr copyto!(ws.u, u) diff --git a/lib/ControlSystemsBase/src/types/DelayLtiSystem.jl b/lib/ControlSystemsBase/src/types/DelayLtiSystem.jl index f9e94e151..ab93ab3cd 100644 --- a/lib/ControlSystemsBase/src/types/DelayLtiSystem.jl +++ b/lib/ControlSystemsBase/src/types/DelayLtiSystem.jl @@ -15,7 +15,7 @@ feedback_channel(sys::DelayLtiSystem) = sys.Tau """ DelayLtiSystem{T, S}(sys::StateSpace, Tau::AbstractVector{S}=Float64[]) where {T <: Number, S <: Real} -Create a delayed system by speciying both the system and time-delay vector. NOTE: if you want to create a system with simple input or output delays, use the Function `delay(τ)`. +Create a delayed system by specifying both the system and time-delay vector. NOTE: if you want to create a system with simple input or output delays, use the Function `delay(τ)`. """ function DelayLtiSystem{T,S}(sys::StateSpace, Tau::AbstractVector{S} = Float64[]) where {T<:Number,S<:Real} nu = ninputs(sys) - length(Tau) @@ -65,7 +65,7 @@ function Base.convert(::Type{DelayLtiSystem{T,S}}, sys::TransferFunction{TE}) wh DelayLtiSystem{T,S}(convert(StateSpace{TE, T}, sys)) end -# Catch convertsion between T +# Catch conversion between T Base.convert(::Type{V}, sys::DelayLtiSystem) where {T, V<:DelayLtiSystem{T}} = sys isa V ? sys : V(StateSpace{Continuous,T}(sys.P.P), sys.Tau) @@ -150,7 +150,7 @@ delay(T::Type{<:Number}, τ::Number, Ts::Number) = c2d(delay(T, τ), Ts) Create a time delay of length `tau` with `exp(-τ*s)` where `s=tf("s")` and `τ` > 0. -See also: [`delay`](@ref) which is arguably more conenient than this function. +See also: [`delay`](@ref) which is arguably more convenient than this function. """ function Base.exp(G::TransferFunction{Continuous,<:SisoRational}) if size(G.matrix) != (1,1) && iscontinuous(G) diff --git a/lib/ControlSystemsBase/src/types/HammersteinWiener.jl b/lib/ControlSystemsBase/src/types/HammersteinWiener.jl index 19d5b3f25..76ccd07f1 100644 --- a/lib/ControlSystemsBase/src/types/HammersteinWiener.jl +++ b/lib/ControlSystemsBase/src/types/HammersteinWiener.jl @@ -72,7 +72,7 @@ end function Base.convert(::Type{HammersteinWienerSystem{T}}, sys::TransferFunction{TE}) where {T,TE} HammersteinWienerSystem{T}(convert(StateSpace{TE, T}, sys)) end -# Catch convertsion between T +# Catch conversion between T Base.convert(::Type{V}, sys::HammersteinWienerSystem) where {T, V<:HammersteinWienerSystem{T}} = sys isa V ? sys : V(StateSpace{Continuous,T}(sys.P.P), sys.f) diff --git a/lib/ControlSystemsBase/src/types/LFTSystem.jl b/lib/ControlSystemsBase/src/types/LFTSystem.jl index 123ac236b..7c3a737f8 100644 --- a/lib/ControlSystemsBase/src/types/LFTSystem.jl +++ b/lib/ControlSystemsBase/src/types/LFTSystem.jl @@ -95,7 +95,7 @@ Base.getindex(sys::LFTSystem, i, j) = function Base.getindex(sys::LFTSystem, i::AbstractArray, j::AbstractArray) ny, nu = size(sys) - # Cant use "boundscheck" since not AbstractArray + # Can't use "boundscheck" since not AbstractArray imin, imax = extrema(i) jmin, jmax = extrema(j) if imax > ny || imin < 1 || jmax > nu || jmin < 1 diff --git a/lib/ControlSystemsBase/src/types/PartitionedStateSpace.jl b/lib/ControlSystemsBase/src/types/PartitionedStateSpace.jl index 45e8e8855..e5ae6335f 100644 --- a/lib/ControlSystemsBase/src/types/PartitionedStateSpace.jl +++ b/lib/ControlSystemsBase/src/types/PartitionedStateSpace.jl @@ -224,7 +224,7 @@ end """ Concatenate systems horizontally with - same first ouput y1 being the sum + same first output y1 being the sum second output y2 = [y2_1; y2_2, ...] and inputs u1 = [u1_1; u1_2, ...] u2 = [u2_1; u2_2, ...] @@ -236,7 +236,7 @@ function hcat_1(systems::PartitionedStateSpace...) ny1 = systems[1].ny1 if !all(s.ny1 == ny1 for s in systems) - error("All systems must have same first ouput dimension") + error("All systems must have same first output dimension") end A = blockdiag([s.A for s in systems]...) diff --git a/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoRational.jl b/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoRational.jl index 390d9f14d..6fca28bbb 100644 --- a/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoRational.jl +++ b/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoRational.jl @@ -90,7 +90,7 @@ function ==(f1::SisoRational, f2::SisoRational) (f1num * f2den[1] == f2num * f1den[1] && f1den * f2den[1] == f2den * f1den[1]) # NOTE: Not in analogy with how it's done for SisoZpk end -# We might want to consider alowing scaled num and den as equal +# We might want to consider allowing scaled num and den as equal function isapprox(f1::SisoRational, f2::SisoRational; rtol::Real=sqrt(eps()), atol::Real=0) # Get representation of num/den so index access is correct f1num, f1den = numvec(f1), denvec(f1) diff --git a/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoZpk.jl b/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoZpk.jl index 984a6de4a..112995f6a 100644 --- a/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoZpk.jl +++ b/lib/ControlSystemsBase/src/types/SisoTfTypes/SisoZpk.jl @@ -154,9 +154,9 @@ function poly_factors2string(poly_factors::AbstractArray{<:Polynomial{T}}, var) end end -""" Heurisitc function that tries to add parentheses when printing the coeffcient +""" Heuristic function that tries to add parentheses when printing the coefficient for systems on zpk form. Should at least handle the following types - Measurment, Dual, Sym. """ + Measurement, Dual, Sym. """ function _printcoefficient(nbr::Number) # Print type information as in 1.0f0 for Float32 # showcompact might be better, but is not consistent with polynomials diff --git a/lib/ControlSystemsBase/src/types/StateSpace.jl b/lib/ControlSystemsBase/src/types/StateSpace.jl index ed0db5708..9f0fec519 100644 --- a/lib/ControlSystemsBase/src/types/StateSpace.jl +++ b/lib/ControlSystemsBase/src/types/StateSpace.jl @@ -8,7 +8,7 @@ function state_space_validation(A,B,C,D) ny = size(C, 1) if size(A, 2) != nx && nx != 0 - error("A has dimentions $(size(A)), but must be square") + error("A has dimensions $(size(A)), but must be square") elseif size(B, 1) != nx error("The number of rows of A ($(size(A,1))) and B ($(size(B,1))) are not equal") elseif size(C, 2) != nx @@ -219,7 +219,7 @@ A destructor that outputs the statespace matrices. """ ssdata(sys) = sys.A, sys.B, sys.C, sys.D -# Funtions for number of intputs, outputs and states +# Functions for number of inputs, outputs and states ninputs(sys::AbstractStateSpace) = size(sys.D, 2) noutputs(sys::AbstractStateSpace) = size(sys.D, 1) nstates(sys::AbstractStateSpace) = size(sys.A, 1) diff --git a/lib/ControlSystemsBase/src/types/TimeEvolution.jl b/lib/ControlSystemsBase/src/types/TimeEvolution.jl index b4032fae1..e6314d7d1 100644 --- a/lib/ControlSystemsBase/src/types/TimeEvolution.jl +++ b/lib/ControlSystemsBase/src/types/TimeEvolution.jl @@ -18,7 +18,7 @@ struct Continuous <: TimeEvolution end # Basic Constructors Discrete(x::T) where T<:Number = Discrete{T}(x) Continuous(x::Continuous) = x -# Simple converseion +# Simple conversion Discrete{T}(x::Discrete) where T = Discrete{T}(x.Ts) diff --git a/lib/ControlSystemsBase/src/types/TransferFunction.jl b/lib/ControlSystemsBase/src/types/TransferFunction.jl index a47f41f07..b51221fba 100644 --- a/lib/ControlSystemsBase/src/types/TransferFunction.jl +++ b/lib/ControlSystemsBase/src/types/TransferFunction.jl @@ -73,7 +73,7 @@ denpoly(G::TransferFunction) = map(denpoly, G.matrix) """ minreal(tf::TransferFunction, eps=sqrt(eps())) -Create a minimial representation of each transfer function in `tf` by cancelling poles and zeros +Create a minimal representation of each transfer function in `tf` by cancelling poles and zeros will promote system to an appropriate numeric type """ function minreal(G::TransferFunction, eps::Real=sqrt(eps())) @@ -224,7 +224,7 @@ function /(n::Number, G::TransferFunction) end /(G::TransferFunction, n::Number) = G*(1/n) /(G1::TransferFunction, G2::TransferFunction) = G1*(1/G2) -Base.:(/)(sys1::LTISystem, sys2::TransferFunction) = *(promote(sys1, ss(1/sys2))...) # This spcial case is needed to properly handle improper inverse transfer function (1/s) +Base.:(/)(sys1::LTISystem, sys2::TransferFunction) = *(promote(sys1, ss(1/sys2))...) # This special case is needed to properly handle improper inverse transfer function (1/s) ##################################################################### diff --git a/lib/ControlSystemsBase/src/types/conversion.jl b/lib/ControlSystemsBase/src/types/conversion.jl index 2bb173470..736469eab 100644 --- a/lib/ControlSystemsBase/src/types/conversion.jl +++ b/lib/ControlSystemsBase/src/types/conversion.jl @@ -111,7 +111,7 @@ function Base.convert(::Type{StateSpace{TE,T}}, G::TransferFunction; balance=!(T for i=1:ny k = (j-1)*ny + i - # states correpsonding to the transfer function element (i,j) + # states corresponding to the transfer function element (i,j) inds = (inds.stop+1):(inds.stop+nvec[k]) A[inds,inds], B[inds,j:j], C[i:i,inds], D[i:i,j:j] = abcd_vec[k] @@ -341,7 +341,7 @@ function siso_ss_to_zpk(sys, i, j) end """ -Implements: "An accurate and efficient algorithm for the computation of thecharacteristic polynomial of a general square matrix." +Implements: "An accurate and efficient algorithm for the computation of the characteristic polynomial of a general square matrix." """ function charpoly(A::AbstractMatrix{T}) where {T} N = size(A, 1) diff --git a/lib/ControlSystemsBase/src/utilities.jl b/lib/ControlSystemsBase/src/utilities.jl index 8eb257e29..317e219f5 100644 --- a/lib/ControlSystemsBase/src/utilities.jl +++ b/lib/ControlSystemsBase/src/utilities.jl @@ -48,7 +48,7 @@ printpolyfun(var) = (io, p, mimetype = MIME"text/plain"()) -> Polynomials.printp # NOTE: Tolerances for checking real-ness removed, shouldn't happen from LAPACK? # TODO: This doesn't play too well with dual numbers.. -# Allocate for maxiumum possible length of polynomial vector? +# Allocate for maximum possible length of polynomial vector? # # This function rely on that the every complex roots is followed by its exact conjugate, # and that the first complex root in each pair has positive imaginary part. This format is always @@ -77,7 +77,7 @@ function roots2real_poly_factors(roots::Vector{cT}) where cT <: Number return poly_factors end -# This function should hande both Complex as well as symbolic types +# This function should handle both Complex as well as symbolic types function roots2poly_factors(roots::Vector{T}) where T <: Number return Polynomial{T,:x}[Polynomial{T,:x}([-r, 1]) for r in roots] end diff --git a/lib/ControlSystemsBase/test/runtests.jl b/lib/ControlSystemsBase/test/runtests.jl index 5e8cff545..5f941c7e6 100644 --- a/lib/ControlSystemsBase/test/runtests.jl +++ b/lib/ControlSystemsBase/test/runtests.jl @@ -6,7 +6,7 @@ import DSP: conv # In test_conversion and test_synthesis using Aqua @testset "Aqua" begin Aqua.test_all(ControlSystemsBase; - ambiguities = false, # casues 100s of hits in all dependencies + ambiguities = false, # causes 100s of hits in all dependencies stale_deps = true, # Aqua complains about itself https://github.com/JuliaTesting/Aqua.jl/issues/78 project_toml_formatting = false, # https://github.com/JuliaTesting/Aqua.jl/issues/105 ) diff --git a/lib/ControlSystemsBase/test/test_analysis.jl b/lib/ControlSystemsBase/test/test_analysis.jl index 1ade4b1d7..d29668e0b 100644 --- a/lib/ControlSystemsBase/test/test_analysis.jl +++ b/lib/ControlSystemsBase/test/test_analysis.jl @@ -115,7 +115,7 @@ known_poles = [-3.383889568918823 + 0.000000000000000im -0.083309192664918 - 0.487701968391972im] approxin2(el,col) = any(el.≈col) # Compares the computed poles with the expected poles -# TODO: Improve the test for testing equalifity of sets of complex numbers +# TODO: Improve the test for testing equality of sets of complex numbers # i.e. simplify and handle doubles. @test all(approxin(p,known_poles) for p in poles(ex_8)) && all(approxin2(p,poles(ex_8)) for p in known_poles) diff --git a/lib/ControlSystemsBase/test/test_autovec.jl b/lib/ControlSystemsBase/test/test_autovec.jl index a7df5f585..a0fef31ba 100644 --- a/lib/ControlSystemsBase/test/test_autovec.jl +++ b/lib/ControlSystemsBase/test/test_autovec.jl @@ -55,7 +55,7 @@ fsv = freqrespv(sys, w) -# Test that we can define varous kinds of methods with autovec +# Test that we can define various kinds of methods with autovec # Test arguments for single output ControlSystemsBase.@autovec () function t0(b::Int, c::Float64=1.0) diff --git a/lib/ControlSystemsBase/test/test_complex.jl b/lib/ControlSystemsBase/test/test_complex.jl index 96b572a22..605256e17 100644 --- a/lib/ControlSystemsBase/test/test_complex.jl +++ b/lib/ControlSystemsBase/test/test_complex.jl @@ -3,7 +3,7 @@ C_1 = zpk([], [-1+im], 1.0+1im) C_2 = zpk([-1+im], [], 1.0+1im) -# Basic arittmetic +# Basic arithmetic @test C_1 + C_1 == zpk([], [-1+im], 2+2im) @test (1.0+im)*C_1 == zpk([], [-1+im], 2.0im) @test C_2 + C_2 == zpk([-1+im], [], 2+2im) diff --git a/lib/ControlSystemsBase/test/test_conversion.jl b/lib/ControlSystemsBase/test/test_conversion.jl index 4d3d136c5..398ce5bf6 100644 --- a/lib/ControlSystemsBase/test/test_conversion.jl +++ b/lib/ControlSystemsBase/test/test_conversion.jl @@ -135,7 +135,7 @@ fb = BigFloat(1.0)*f # @test fb isa RationalBigFloat # Do we want this? We get TransferFunction{ControlSystemsBase.SisoZpk{BigFloat,Complex{Float64}}} @test ss(fb) isa SSBigFloat @test tf(fb) isa RationalBigFloat -# Cant compute poles: +# Can't compute poles: # @test zpk(tf(fb)) isa SSBigFloat @test convert(SSBigFloat, fb) isa SSBigFloat diff --git a/lib/ControlSystemsBase/test/test_delayed_systems.jl b/lib/ControlSystemsBase/test/test_delayed_systems.jl index ceacd5872..6828e95fb 100644 --- a/lib/ControlSystemsBase/test/test_delayed_systems.jl +++ b/lib/ControlSystemsBase/test/test_delayed_systems.jl @@ -27,7 +27,7 @@ using ControlSystemsBase @test evalfr(1 - delay(1.0), 0)[] ≈ 0 @test evalfr([2 -delay(1.0)], 0) ≈ [2 -1] -# Stritcly proper system +# Strictly proper system P1 = DelayLtiSystem(ss(-1.0, 1, 1, 0)) P1_fr = 1 ./ (im*ω .+ 1) @test freqresp(P1, ω)[:] ≈ P1_fr @@ -42,7 +42,7 @@ P2_fr = (im*ω .+ 1) ./ (im*ω .+ 2) @test freqresp(1 + delay(1), ω)[:] ≈ 1 .+ exp.(-im*ω) @test freqresp(P1 + delay(1), ω)[:] ≈ P1_fr .+ exp.(-im*ω) -# Substraction +# Subtraction @test freqresp(P1 - delay(1), ω)[:] ≈ P1_fr .- exp.(-im*ω) ## Multiplication by scalar diff --git a/lib/ControlSystemsBase/test/test_discrete.jl b/lib/ControlSystemsBase/test/test_discrete.jl index 3edd126d9..2a4807c06 100644 --- a/lib/ControlSystemsBase/test/test_discrete.jl +++ b/lib/ControlSystemsBase/test/test_discrete.jl @@ -132,7 +132,7 @@ Bm = conv(B⁺, B⁻) # In this case, keep the entire numerator polynomial of t R,S,T = rstc(B⁺,B⁻,A,Bm,Am,Ao,AR) # Calculate the 2-DOF controller polynomials -Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectores are of equal length +Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectors are of equal length @test ControlSystemsBase.isstable(Gcl) diff --git a/lib/ControlSystemsBase/test/test_linalg.jl b/lib/ControlSystemsBase/test/test_linalg.jl index 0ada4299e..4972b60a9 100644 --- a/lib/ControlSystemsBase/test/test_linalg.jl +++ b/lib/ControlSystemsBase/test/test_linalg.jl @@ -215,7 +215,7 @@ Ninf, ω_peak = hinfnorm( ss([0 1; im -1+2im], [0; 1], [1 0], 0)) @test abs(ω_peak-1) ≈ 1/sqrt(2) rtol=1e-3 -# System with mutiple resonance peaks +# System with multiple resonance peaks A = [-0.1*I -Diagonal(1:10) Diagonal(1:10) zeros(10,10)] diff --git a/lib/ControlSystemsBase/test/test_statespace.jl b/lib/ControlSystemsBase/test/test_statespace.jl index 31e519d46..ab9693814 100644 --- a/lib/ControlSystemsBase/test/test_statespace.jl +++ b/lib/ControlSystemsBase/test/test_statespace.jl @@ -243,7 +243,7 @@ @test_throws ErrorException SS([1 2], [1], [2], [3]) # Not square A @test_throws ErrorException SS([1], [2 0], [1], [2]) # I/0 dim mismatch @test_throws ErrorException SS([1], [2], [3 4], [1]) # I/0 dim mismatch - @test_throws ErrorException SS([1], [2], [3], [4], -0.1) # Negative samping time + @test_throws ErrorException SS([1], [2], [3], [4], -0.1) # Negative sampling time @test_throws ErrorException SS(eye_(2), eye_(2), eye_(2), [0]) # Dimension mismatch # Misc tests diff --git a/lib/ControlSystemsBase/test/test_timeresp.jl b/lib/ControlSystemsBase/test/test_timeresp.jl index 7a58f5b2b..31679627d 100644 --- a/lib/ControlSystemsBase/test/test_timeresp.jl +++ b/lib/ControlSystemsBase/test/test_timeresp.jl @@ -176,7 +176,7 @@ y, t2, x = step(G, 10) @test y ≈ [zeros(1, 3) ones(1, 8)] atol=1e-5 @test t2 == 0:1:10 # isapprox is broken for ranges (julia 1.3.1) -#Impulse response of discrete system to final time that is not mulitple of the sample time +#Impulse response of discrete system to final time that is not multiple of the sample time G = tf([1], [1; zeros(3)], 0.3) y, t2, x = step(G, 2) @test y ≈ [zeros(1, 3) ones(1, 4)] atol=1e-5 diff --git a/lib/ControlSystemsBase/test/test_transferfunction.jl b/lib/ControlSystemsBase/test/test_transferfunction.jl index ccdf6dae1..140000e8a 100644 --- a/lib/ControlSystemsBase/test/test_transferfunction.jl +++ b/lib/ControlSystemsBase/test/test_transferfunction.jl @@ -50,7 +50,7 @@ z = @inferred tf("z", 0.005) @test tf([1.0], [1.0,0.0]) != tf([1.0], [2.0,0.0]) @test tf([1.0+2.0im], [2.0+im,3.0]) != tf([1+2.0im], [1.0+im,3.0]) -# Test approximate equlity +# Test approximate equality # rtol should just be on the order of ϵ, no particular reason that exactly ϵ # would work, but apparently it does ϵ = 1e-14 @@ -208,7 +208,7 @@ D_diffTs = tf([1], [2], 0.1) @test_throws ErrorException D_111 + D_diffTs # Sampling time mismatch @test_throws ErrorException D_111 - D_diffTs # Sampling time mismatch @test_throws ErrorException D_111 * D_diffTs # Sampling time mismatch -@test_throws ErrorException tf([1], [2], -0.1) # Negative samping time +@test_throws ErrorException tf([1], [2], -0.1) # Negative sampling time @test_throws ErrorException tf("s", 0.01) # s creation can't be discrete @test_throws ErrorException tf("z", 0) # z creation can't be continuous @test_throws ErrorException tf("z") # z creation can't be continuous diff --git a/lib/ControlSystemsBase/test/test_zpk.jl b/lib/ControlSystemsBase/test/test_zpk.jl index f3eb4d231..719a44e8e 100644 --- a/lib/ControlSystemsBase/test/test_zpk.jl +++ b/lib/ControlSystemsBase/test/test_zpk.jl @@ -132,7 +132,7 @@ k = 0.3 @test minreal(zpk([-5.0], [-5.0, -5.0], 1.0)) == zpk(Float64[], [-5.0], 1.0) @test minreal(zpk([-1.0, -2.0], [-2.0, -2.0], 1.0)) == zpk([-1.0], [-2.0], 1.0) -# Tests of minreal (roudning and cancelling complex roots with real roots) +# Tests of minreal (rounding and cancelling complex roots with real roots) @test minreal(zpk([-2.0+1e-10im,-2.0-1e-10im], [-2.0], 1.0)) == zpk([-2.0], Float64[], 1.0) @test minreal(zpk([-2.0], [-2.0+1e-10im,-2.0-1e-10im], 1.0)) == zpk(Float64[], [-2.0], 1.0) @test minreal(zpk([-1.0, -2.0, -2.0+1e-10im,-2.0-1e-10im], [-2.0, -2.0], 1.0)) == zpk([-1.0, -2.0], Float64[], 1.0) @@ -169,7 +169,7 @@ D_diffTs = zpk(tf([1], [2], 0.1)) @test_throws ErrorException D_111 + D_diffTs # Sampling time mismatch @test_throws ErrorException D_111 - D_diffTs # Sampling time mismatch @test_throws ErrorException D_111 * D_diffTs # Sampling time mismatch -@test_throws ErrorException zpk([1], [2], 1, -0.1) # Negative samping time +@test_throws ErrorException zpk([1], [2], 1, -0.1) # Negative sampling time @test_throws ErrorException zpk("s", 0.01) # s creation can't be discrete @test_throws ErrorException zpk("z", 0) # z creation can't be continuous @test_throws ErrorException zpk("z") # z creation can't be continuous diff --git a/src/root_locus.jl b/src/root_locus.jl index e5356f847..98ab43e1f 100644 --- a/src/root_locus.jl +++ b/src/root_locus.jl @@ -17,7 +17,7 @@ function getpoles(G, K::Number) f = function (_,_,k) if k == 0 && length(P) > length(Q) # More zeros than poles, make sure the vector of roots is of correct length when k = 0 - # When this happens, there are fewer poles for k = 0, these poles can be seen as beeing located somewhere at Inf + # When this happens, there are fewer poles for k = 0, these poles can be seen as being located somewhere at Inf # We get around the problem by not allowing k = 0 for non-proper systems. k = ϵ end @@ -75,7 +75,7 @@ end Compute the root locus of the SISO LTISystem `P` with a negative feedback loop and feedback gains between 0 and `K`. `rlocus` will use an adaptive step-size algorithm to determine the values of the feedback gains used to generate the plot. -`roots` is a complex matrix containig the poles trajectories of the closed-loop `1+k⋅G(s)` as a function of `k`, `Z` contains the zeros of the open-loop system `G(s)` and `K` the values of the feedback gain. +`roots` is a complex matrix containing the poles trajectories of the closed-loop `1+k⋅G(s)` as a function of `k`, `Z` contains the zeros of the open-loop system `G(s)` and `K` the values of the feedback gain. """ function rlocus(P, K) Z = tzeros(P) diff --git a/src/timeresp.jl b/src/timeresp.jl index 67d2e3f02..1145ebbcf 100644 --- a/src/timeresp.jl +++ b/src/timeresp.jl @@ -73,7 +73,7 @@ Arguments: - `u`: Function to determine control signal `uₜ` at a time `t`, on any of the following forms: - A constant `Number` or `Vector`, interpreted as a constant input. - Function `u(x, t)` that takes the internal state and time, note, the state representation for delay systems is not the same as for rational systems. - - In-place function `u(uₜ, x, t)`. (Slightly more effienct) + - In-place function `u(uₜ, x, t)`. (Slightly more efficient) `alg, abstol, reltol` and `kwargs...`: are sent to `DelayDiffEq.solve`. @@ -312,7 +312,7 @@ Simulate system `sys`, over time `t`, using input signal `u`, with initial state - `u`: Function to determine control signal `uₜ` at a time `t`, on any of the following forms: Can be a constant `Number` or `Vector`, interpreted as `uₜ .= u` , or Function `uₜ .= u(x, t)`, or - In-place function `u(uₜ, x, t)`. (Slightly more effienct) + In-place function `u(uₜ, x, t)`. (Slightly more efficient) - `alg, abstol, reltol` and `kwargs...`: are sent to `OrdinaryDiffEq.solve`. Returns an instance of [`SimResult`](@ref). diff --git a/test/runtests.jl b/test/runtests.jl index 201c3571d..a2339c182 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,7 +3,7 @@ using Test, LinearAlgebra, Random using Aqua # @testset "Aqua" begin # Aqua.test_all(ControlSystems; -# ambiguities = false, # casues 100s of hits in all dependencies +# ambiguities = false, # causes 100s of hits in all dependencies # stale_deps = true, # Aqua complains about itself https://github.com/JuliaTesting/Aqua.jl/issues/78 # ) # end