Skip to content

Commit

Permalink
Polishing examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasvarga committed Nov 30, 2022
1 parent 03215bc commit 1703f4f
Show file tree
Hide file tree
Showing 31 changed files with 56 additions and 40 deletions.
5 changes: 3 additions & 2 deletions Examples/CS1_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using JLD2

## CS1_1 - Case-study example: Monitoring flight actuator faults
# No measurements of control surface angles are used
println("Case study CS1_1 with Fig8.2 and Fig8.3")

## Part 1 - Model setup
# load matrices of the aircraft multiple-model SYSACM,
Expand Down Expand Up @@ -137,9 +138,9 @@ y = [stepresp(Rtot[i][:,indf],10)[1] for i in 1:N];
include("Fig8_3.jl")
Fig8_3 = f

#export Fig8_2, Fig8_3

end # module

using Main.CS1_1
CS1_1.Fig8_2
CS1_1.Fig8_3

6 changes: 2 additions & 4 deletions Examples/CS1_2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using JLD2

## CS1_2 - Case-study example: Monitoring flight actuator faults
# Local measurements of control surface angles are used
println("Case study CS1_2")
println("Case study CS1_2 with Fig8.4")

## Part 1 - Model setup
# load matrices of the aircraft multiple-model SYSACM,
Expand Down Expand Up @@ -123,8 +123,6 @@ tout = Vector(0:0.02:2.)
include("Fig8_4.jl")
Fig8_4 = f

export Fig8_4

end # module
using Main.CS1_2

CS1_2.Fig8_4
8 changes: 4 additions & 4 deletions Examples/CS2_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using FaultDetectionTools, DescriptorSystems, LinearAlgebra,

## CS2_1 - Case-study example: Monitoring air data sensor faults
# Robust least order LTI synthesis
println("Case study CS2_1")
println("Case study CS2_1 with Fig8.5, Fig8.6 and Fig8.7")

## Part 1 - Model setup
# load matrices of the aircraft multiple-model SYSACSM and
Expand Down Expand Up @@ -198,9 +198,9 @@ tout = Vector(0:0.1:10.)
include("Fig8_7.jl")
Fig8_7 = f

export Fig8_5, Fig8_6, Fig8_7

end # module
using Main.CS2_1

CS2_1.Fig8_5
CS2_1.Fig8_6
CS2_1.Fig8_7

5 changes: 2 additions & 3 deletions Examples/CS2_2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using FaultDetectionTools, DescriptorSystems, LinearAlgebra,

## CS2_2 - Case-study example: Monitoring air data sensor faults
# Robust least order LPV synthesis
println("Case study CS2_2")
println("Case study CS2_2 with Fig8.8")

## Part 1 - Model setup
# load matrices of the aircraft multiple-model SYSACM
Expand Down Expand Up @@ -88,9 +88,8 @@ tout = Vector(0:0.1:10.)
include("Fig8_8.jl")
Fig8_8 = f

export Fig8_8

end # module
using Main.CS2_2
CS2_2.Fig8_8


1 change: 1 addition & 0 deletions Examples/Ex5_10.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ R = FDIFilterIF(scale .* Rft; mf)
# check all gaps are infinite
@test all(fdif2ngap(R,S)[1] .== Inf)
end # module
using Main.Ex5_10
1 change: 1 addition & 0 deletions Examples/Ex5_11.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ println("R = "); display(R)
@test fdif2ngap(R,S)[1] [3,Inf] # check gap

end # module
using Main.Ex5_11
1 change: 1 addition & 0 deletions Examples/Ex5_11c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ indfn = [Rt.faults;Rt.noise]
iszero(vcat(Rt.sys...)[:,indfn]-vcat(R.sys...); atol) &&
fdif2ngap(R,SFDI)[1] info.gap [3,Inf]
end # module
using Main.Ex5_11c
1 change: 1 addition & 0 deletions Examples/Ex5_12.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ Qbar = glsol(Ge, Me; atol)[1]


end # module
using Main.Ex5_12
3 changes: 2 additions & 1 deletion Examples/Ex5_13a.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Ex5_13
module Ex5_13a
using FaultDetectionTools
using DescriptorSystems
using LinearAlgebra
Expand Down Expand Up @@ -68,3 +68,4 @@ G = dss([Gu Gf;eye(mu,mu+mf)]); F = [zeros(mf,mu) M*Mr];
@test iszero(Q*G-F; atol)

end # module
using Main.Ex5_13a
1 change: 1 addition & 0 deletions Examples/Ex5_14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ println("gamma_sub = $(info.gammasub)") # suboptimal performance


end # module
using Main.Ex5_14
1 change: 1 addition & 0 deletions Examples/Ex5_15.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ println("gamma_sub_∞ = $(fdimmperf(R, info.M*Mr))") # suboptimal performanc


end # module
using Main.Ex5_15
1 change: 1 addition & 0 deletions Examples/Ex5_16.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ err_opt = glinfnorm(Qopt*G-F)[1]
@test err_sub-err_opt < 0.002

end # module
using Main.Ex5_16
6 changes: 2 additions & 4 deletions Examples/Ex5_16c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Ex5_16c
using FaultDetectionTools, DescriptorSystems, Measurements, Test

# Example 5.16c - Solution of an H∞ AMMP
println("Example 5.16c")
println("Example 5.16c with Fig5.2")

# define system with control, noise and actuator fault inputs
A = [-.8 0 0; 0 -.5 .6; 0 -.6 -.5]
Expand Down Expand Up @@ -56,8 +56,6 @@ yl = y .- yerr; yu = y .+ yerr # lower and upper bounds
include("Fig5_2.jl")
Fig5_2 = f

export Fig5_2

end
using Main.Ex5_16c

Ex5_16c.Fig5_2
1 change: 1 addition & 0 deletions Examples/Ex5_17.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ Ge = [sysf.sys[:,[sysf.faults;sysf.noise]]; zeros(mu,mf+mw)]; Me = [info.M*Mr.sy


end # module
using Main.Ex5_17
1 change: 1 addition & 0 deletions Examples/Ex5_4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ else
end

end # module
using Main.Ex5_4
1 change: 1 addition & 0 deletions Examples/Ex5_5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ R = fdIFeval(Q, sysf; minimal = true, atol = 1.e-7)


end # module
using Main.Ex5_5
1 change: 1 addition & 0 deletions Examples/Ex5_6.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ else
end

end # module
using Main.Ex5_6
1 change: 1 addition & 0 deletions Examples/Ex5_7.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ R = fdIFeval(Q, sysf; minimal = true, atol = 1.e-7)


end # module
using Main.Ex5_7
1 change: 1 addition & 0 deletions Examples/Ex5_9.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ R = fdIFeval(Q, sysf; minimal = true, atol = 1.e-7)


end # module
using Main.Ex5_9
1 change: 1 addition & 0 deletions Examples/Ex6_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ println("Norms of final residual models")
display(distinf1)

end # module
using Main.Ex6_1
6 changes: 3 additions & 3 deletions Examples/Ex6_1c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Ex6_1c
using FaultDetectionTools, DescriptorSystems, LinearAlgebra, Test

# Example 6.1c - Solution of an EMDP
println("Example 6.1c")
println("Example 6.1c with Fig6.1 and Fig6.2")

# Lateral aircraft model without faults
A = [-.4492 0.046 .0053 -.9926;
Expand Down Expand Up @@ -47,7 +47,7 @@ Fig6_1 = fig1
include("Fig6_2.jl")
Fig6_2 = fig2

export Fig6_1, Fig6_2

end
using Main.Ex6_1c
Ex6_1c.Fig6_1
Ex6_1c.Fig6_2
1 change: 1 addition & 0 deletions Examples/Ex6_2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ println("Resulting gaps")
display(gap)

end # module
using Main.Ex6_2
5 changes: 2 additions & 3 deletions Examples/Ex6_2c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Ex6_2c
using FaultDetectionTools, DescriptorSystems, LinearAlgebra, Test

# Example 6.2c - Solution of an AMDP
println("Example 6.2c")
println("Example 6.2c with Fig6.3")

# Lateral aircraft model without faults
A = [-.4492 0.046 .0053 -.9926;
Expand Down Expand Up @@ -46,7 +46,6 @@ display(info.MDgap)
include("Fig6_3.jl")
Fig6_3 = fig

export Fig6_3

end
using Main.Ex6_2c
Ex6_2c.Fig6_3
11 changes: 7 additions & 4 deletions Examples/Ex7_1.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module Ex7_1
# Generation of Fig7_1 with CairoMakie for Ex7_1

using Makie, CairoMakie, LaTeXStrings
using DescriptorSystems, Polynomials
Makie.inline!(false)

# Example 7.1 - Illustrating polynomial root sensitivity
println("Example 7.1 with Fig7_1")


Makie.inline!(false)
pexact = Vector(-25.:1.:-1.)
Expand All @@ -25,12 +30,10 @@ axislegend()

Fig7_1 = fig

export Fig7_1


# comment out next line to save plot
#save("Fig7_1.pdf", fig, resolution = (600, 600))

end
using Main.Ex7_1
Ex7_1.Fig7_1

13 changes: 7 additions & 6 deletions Examples/Ex7_1a.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module Ex7_1a
# Generation of Fig7_1a with CairoMakie for Ex7_1

using Makie, CairoMakie, LaTeXStrings
using DescriptorSystems, Polynomials, GenericLinearAlgebra
Makie.inline!(false)

using DescriptorSystems, Polynomials, GenericLinearAlgebra

# Example 7.1 - Illustrating high precision polynomial root computation
println("Example 7.1 with alternative Fig7_1a")


pexact = BigFloat.(Vector(-25.:1.:-1.))
g = rtf(1,Polynomial(fromroots(pexact),:s))
Expand All @@ -20,16 +24,13 @@ h2 = scatter!(ax, real(poles), imag(poles), color = :red, label = "Perturbed pol
h2.marker = :star6
xlims!.(ax, low = -30, high = 0)
ylims!.(ax, low = -15, high =15)

axislegend()


Fig7_1a = fig

export Fig7_1a

# comment out next line to save plot
#save("Fig7_1a.pdf", fig, resolution = (600, 600))

end
using Main.Ex7_1a
Ex7_1a.Fig7_1a
2 changes: 1 addition & 1 deletion Examples/Ex7_3.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Ex7_3
using DescriptorSystems, LinearAlgebra

# Example 7.3 - Nullspace-based synthesis
# Example 7.3 - Illustrating nullspace-based synthesis paradigm
# Uses only DescriptorSystems.jl
println("Example 7.3")

Expand Down
1 change: 1 addition & 0 deletions Examples/Ex7_3c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ println("Q = $(dss2rm(Q.sys))")
println("Rf = $(dss2rm(Rf.sys))")

end # module
using Main.Ex7_3c
2 changes: 1 addition & 1 deletion Examples/Ex7_4.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Ex7_4
using DescriptorSystems, Test

# Example 7.4 - Nullspace-based synthesis
# Example 7.4 - Illustrating least-order synthesis paradigm
# Uses only DescriptorSystems.jl
println("Example 7.4")

Expand Down
1 change: 1 addition & 0 deletions Examples/Ex7_4c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ println("rscond1 = $rscond1 ")
println("rscond2 = $rscond2")

end # module
using Main.Ex7_4c
6 changes: 3 additions & 3 deletions Examples/runbookexamples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ include("Ex6_1c.jl") # solving EMDP
include("Ex6_2c.jl") # solving AMDP
# Chapter 7
include("Ex7_1.jl") # Example for high sensitivity of polynomial poles
include("Ex7_1a.jl") # Example for high sensitivity of polynomial poles
include("Ex7_3.jl")
include("Ex7_4.jl")
include("Ex7_1a.jl") # Example for high precision pole computation
include("Ex7_3.jl") # Illustrating nullspace-based synthesis paradigm
include("Ex7_4.jl") # Illustrating least-order synthesis paradigm
1 change: 0 additions & 1 deletion Examples/runexamples.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using FaultDetectionTools

@testset "Examples" begin
# LPV to noise inputs
include("Ex2_4.jl")
# solving EFDP
Expand Down

2 comments on commit 1703f4f

@andreasvarga
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/73165

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" 1703f4f8029120df0442df495be6c710e87d4b22
git push origin v1.1.0

Please sign in to comment.