From 883996a32b284cea4e062f5d7be35b155e819322 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Fri, 26 Jul 2019 03:08:47 +0530 Subject: [PATCH 1/6] Create transmissionlinecircuits.jl --- .../transmissionlinecircuits.jl | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 models/TransmissionLineCircuit/transmissionlinecircuits.jl diff --git a/models/TransmissionLineCircuit/transmissionlinecircuits.jl b/models/TransmissionLineCircuit/transmissionlinecircuits.jl new file mode 100644 index 00000000..d4725dac --- /dev/null +++ b/models/TransmissionLineCircuit/transmissionlinecircuits.jl @@ -0,0 +1,126 @@ +# ============================================================================== + +# ============================================================================== + +using Revise, MathematicalSystems, Reachability, LinearAlgebra, HybridSystems +using LazySets +using Reachability: solve +using Plots +using TaylorIntegration + +@taylorize function transmission_line_circuits_one!(t, x, dx) + local α = 5 + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 2 + dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) + dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) + dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) + dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) + dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + return dx +end + +@taylorize function transmission_line_circuits_two!(t, x, dx) + local α = 5 + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 3 - t + dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) + dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) + dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) + dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) + dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + return dx +end + +@taylorize function transmission_line_circuits_three!(t, x, dx) + local α = 5 + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 1 + dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) + dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) + dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) + dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) + dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + return dx +end + +function circuits() + + automaton = LightAutomaton(2) # two modes + + inv_one = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) + + inv_one = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) + + inv_one = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) + + m1 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_one!, 3, inv_one) + + m2 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_two!, 3, inv_two) + + m3 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_three!, 3, inv_three) + + modes = [m1, m2, m3] #modes + + G_first = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) + + G_second = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) + + + add_transition!(automaton, 1, 2, 1) # first transition + add_transition!(automaton, 2, 3, 2) # second transition + + R_first = ConstrainedIdentityMap(6, G_first) + R_second = ConstrainedIdentityMap(6, G_second) + + # resetmaps + resetmaps = [R_first, R_second] + + # switchings + switching = AutonomousSwitching() + switchings = fill(switching, 2) + + ℋ = HybridSystem(automaton, modes, resetmaps, switchings) + + # initial condition in mode three + X0 = Hyperrectangle(low = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], high = [0.02, 0.02, 0.02, 0.02, 0.02, 0.02]) + + initial_condition = [(1, X0)] # initial condition in the "down" mode + + system = InitialValueProblem(ℋ, initial_condition) + + options = Options(:mode=>"reach", :T=>3.5, :plot_vars=>[1, 2], :project_reachset=>false) + + return (system, options) +end + + +problem, options = circuits(); + +options = Options(:mode=>"reach", :T=>3.0, :plot_vars=>[1, 2], :project_reachset=>false, :verbosity => "info") + +@time sol_TMJets = solve(problem, options, TMJets(:orderT=>5, :orderQ=>2, :abs_tol=>1e-10),LazyDiscretePost(:check_invariant_intersection=>true)); + +plot(sol_TMJets, xlab="x", ylab="v", alpha=.5, color=:lightblue) From f579d5169ef6f64bbdd7a9bb778c88469de44ab0 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Sat, 27 Jul 2019 13:54:06 +0530 Subject: [PATCH 2/6] Update transmissionlinecircuits.jl --- .../transmissionlinecircuits.jl | 94 ++++++++----------- 1 file changed, 40 insertions(+), 54 deletions(-) diff --git a/models/TransmissionLineCircuit/transmissionlinecircuits.jl b/models/TransmissionLineCircuit/transmissionlinecircuits.jl index d4725dac..36f9fee6 100644 --- a/models/TransmissionLineCircuit/transmissionlinecircuits.jl +++ b/models/TransmissionLineCircuit/transmissionlinecircuits.jl @@ -2,15 +2,12 @@ # ============================================================================== -using Revise, MathematicalSystems, Reachability, LinearAlgebra, HybridSystems -using LazySets -using Reachability: solve +using Reachability, HybridSystems using Plots -using TaylorIntegration @taylorize function transmission_line_circuits_one!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 2 + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + x[7] dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) @@ -21,7 +18,7 @@ end @taylorize function transmission_line_circuits_two!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 3 - t + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + x[7] dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) @@ -32,7 +29,7 @@ end @taylorize function transmission_line_circuits_three!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 1 + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + x[7] dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) @@ -45,26 +42,13 @@ function circuits() automaton = LightAutomaton(2) # two modes - inv_one = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) - - inv_one = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) - - inv_one = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) + inv_one = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0)]) + + inv_two = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 2.0), + HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -1.0)]) + + inv_three = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) + m1 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_one!, 3, inv_one) @@ -74,40 +58,42 @@ function circuits() modes = [m1, m2, m3] #modes - G_first = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) - - G_second = HPolyhedron([HalfSpace([1.0, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 1.0, 0.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 1.0, 0.0], 0.0), - HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.0)]) - - - add_transition!(automaton, 1, 2, 1) # first transition - add_transition!(automaton, 2, 3, 2) # second transition - - R_first = ConstrainedIdentityMap(6, G_first) - R_second = ConstrainedIdentityMap(6, G_second) + add_transition!(automaton, 1, 2, 1) # first transion + add_transition!(automaton, 2, 3, 2) # second transion + add_transition!(automaton, 2, 1, 3) # third transion + add_transition!(automaton, 3, 2, 4) # fourth transion + + G_first = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -1.0)]) + G_second = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) + G_third = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0)]) + G_fourth = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 2.0)]) + + A1 = [0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; + 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 -1.0] + A2 = [0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; + 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0] + + + b1 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0] + b2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0] + b3 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0] + + R_first = ConstrainedAffineMap(A1, b2, G_first) + R_second = ConstrainedAffineMap(A2, b3, G_second) + R_third = ConstrainedAffineMap(A2, b1, G_third) + R_fourth = ConstrainedAffineMap(A1, b2, G_fourth) # resetmaps - resetmaps = [R_first, R_second] - + resetmaps = [R_first, R_second, R_third, R_fourth] # switchings switching = AutonomousSwitching() - switchings = fill(switching, 2) + switchings = fill(switching, 4) ℋ = HybridSystem(automaton, modes, resetmaps, switchings) - # initial condition in mode three - X0 = Hyperrectangle(low = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], high = [0.02, 0.02, 0.02, 0.02, 0.02, 0.02]) - - initial_condition = [(1, X0)] # initial condition in the "down" mode + X0 = Hyperrectangle(low = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], high = [0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.01]) + # initial condition + initial_condition = [(1, X0)] system = InitialValueProblem(ℋ, initial_condition) From bb3bd1c22e2fd8a239d53246cc2ad5d472d16600 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Sat, 27 Jul 2019 20:30:36 +0530 Subject: [PATCH 3/6] Update transmissionlinecircuits.jl --- .../transmissionlinecircuits.jl | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/models/TransmissionLineCircuit/transmissionlinecircuits.jl b/models/TransmissionLineCircuit/transmissionlinecircuits.jl index 36f9fee6..27b3e772 100644 --- a/models/TransmissionLineCircuit/transmissionlinecircuits.jl +++ b/models/TransmissionLineCircuit/transmissionlinecircuits.jl @@ -7,34 +7,37 @@ using Plots @taylorize function transmission_line_circuits_one!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + x[7] + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 2 dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + dx[7] = one(x[7]) return dx end @taylorize function transmission_line_circuits_two!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + x[7] + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 3 - x[7] dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + dx[7] = one(x[7]) return dx end @taylorize function transmission_line_circuits_three!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + x[7] + dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 1 dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + dx[7] = one(x[7]) return dx end @@ -50,44 +53,39 @@ function circuits() inv_three = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) - m1 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_one!, 3, inv_one) + m1 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_one!, 7, inv_one) - m2 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_two!, 3, inv_two) + m2 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_two!, 7, inv_two) - m3 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_three!, 3, inv_three) + m3 = ConstrainedBlackBoxContinuousSystem(transmission_line_circuits_three!, 7, inv_three) modes = [m1, m2, m3] #modes add_transition!(automaton, 1, 2, 1) # first transion add_transition!(automaton, 2, 3, 2) # second transion - add_transition!(automaton, 2, 1, 3) # third transion - add_transition!(automaton, 3, 2, 4) # fourth transion +# add_transition!(automaton, 2, 1, 3) # third transion +# add_transition!(automaton, 3, 2, 4) # fourth transion G_first = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -1.0)]) G_second = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) - G_third = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0)]) - G_fourth = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 2.0)]) - - A1 = [0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; - 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 -1.0] - A2 = [0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; - 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0] - - - b1 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0] - b2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0] - b3 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0] +# G_third = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0)]) +# G_fourth = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 2.0)]) + + A = [0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; + 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 1.0] - R_first = ConstrainedAffineMap(A1, b2, G_first) - R_second = ConstrainedAffineMap(A2, b3, G_second) - R_third = ConstrainedAffineMap(A2, b1, G_third) - R_fourth = ConstrainedAffineMap(A1, b2, G_fourth) + b = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + + R_first = ConstrainedAffineMap(A, b, G_first) + R_second = ConstrainedAffineMap(A, b, G_second) +# R_third = ConstrainedAffineMap(A2, b1, G_third) +# R_fourth = ConstrainedAffineMap(A1, b2, G_fourth) # resetmaps - resetmaps = [R_first, R_second, R_third, R_fourth] + resetmaps = [R_first, R_second]# R_third, R_fourth] # switchings switching = AutonomousSwitching() - switchings = fill(switching, 4) + switchings = fill(switching, 2) ℋ = HybridSystem(automaton, modes, resetmaps, switchings) # initial condition in mode three From 6e8ac729b86df13f3d97efe0dd5eb1dcb009c116 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Tue, 30 Jul 2019 16:10:20 +0530 Subject: [PATCH 4/6] Update transmissionlinecircuits.jl --- .../transmissionlinecircuits.jl | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/models/TransmissionLineCircuit/transmissionlinecircuits.jl b/models/TransmissionLineCircuit/transmissionlinecircuits.jl index 27b3e772..c52cdada 100644 --- a/models/TransmissionLineCircuit/transmissionlinecircuits.jl +++ b/models/TransmissionLineCircuit/transmissionlinecircuits.jl @@ -7,43 +7,44 @@ using Plots @taylorize function transmission_line_circuits_one!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 2 - dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) - dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) - dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) - dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) - dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + dx[1] = (-2*x[1] + x[2]) + ((2 - exp(α*x[1])) + (2 - exp(α*(x[1] - x[2])))) + dx[2] = (-2*x[2] + x[1]) + ((x[3] + exp(α*(x[1] - x[2]))) - exp(α*(x[2] - x[3]))) + dx[3] = (-2*x[3] + x[2]) + ((x[4] + exp(α*(x[2] - x[3]))) - exp(α*(x[3] - x[4]))) + dx[4] = (-2*x[4] + x[3]) + ((x[5] + exp(α*(x[3] - x[4]))) - exp(α*(x[4] - x[5]))) + dx[5] = (-2*x[5] + x[4]) + ((x[6] + exp(α*(x[4] - x[5]))) - exp(α*(x[5] - x[6]))) + dx[6] = (-x[6] + x[5]) + (exp(α*(x[5] - x[6])) - 1) dx[7] = one(x[7]) return dx end @taylorize function transmission_line_circuits_two!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 3 - x[7] - dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) - dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) - dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) - dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) - dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + dx[1] = (-2*x[1] + x[2]) + ((2 - exp(α*x[1])) + ((3 - exp(α*(x[1] - x[2]))) - x[7])) + dx[2] = (-2*x[2] + x[1]) + ((x[3] + exp(α*(x[1] - x[2]))) - exp(α*(x[2] - x[3]))) + dx[3] = (-2*x[3] + x[2]) + ((x[4] + exp(α*(x[2] - x[3]))) - exp(α*(x[3] - x[4]))) + dx[4] = (-2*x[4] + x[3]) + ((x[5] + exp(α*(x[3] - x[4]))) - exp(α*(x[4] - x[5]))) + dx[5] = (-2*x[5] + x[4]) + ((x[6] + exp(α*(x[4] - x[5]))) - exp(α*(x[5] - x[6]))) + dx[6] = (-x[6] + x[5]) + (exp(α*(x[5] - x[6])) - 1) dx[7] = one(x[7]) return dx end @taylorize function transmission_line_circuits_three!(t, x, dx) local α = 5 - dx[1] = -2*x[1] + x[2] + 2 - exp(α*x[1]) - exp(α*(x[1] - x[2])) + 1 - dx[2] = -2*x[2] + x[1] + x[3] + exp(α*(x[1] - x[2])) - exp(α*(x[2] - x[3])) - dx[3] = -2*x[3] + x[2] + x[4] + exp(α*(x[2] - x[3])) - exp(α*(x[3] - x[4])) - dx[4] = -2*x[4] + x[3] + x[5] + exp(α*(x[3] - x[4])) - exp(α*(x[4] - x[5])) - dx[5] = -2*x[5] + x[4] + x[6] + exp(α*(x[4] - x[5])) - exp(α*(x[5] - x[6])) - dx[6] = -x[6] + x[5] -1 + exp(α*(x[5] - x[6])) + dx[1] = (-2*x[1] + x[2]) + ((2 - exp(α*x[1])) + (1 - exp(α*(x[1] - x[2])))) + dx[2] = (-2*x[2] + x[1]) + ((x[3] + exp(α*(x[1] - x[2]))) - exp(α*(x[2] - x[3]))) + dx[3] = (-2*x[3] + x[2]) + ((x[4] + exp(α*(x[2] - x[3]))) - exp(α*(x[3] - x[4]))) + dx[4] = (-2*x[4] + x[3]) + ((x[5] + exp(α*(x[3] - x[4]))) - exp(α*(x[4] - x[5]))) + dx[5] = (-2*x[5] + x[4]) + ((x[6] + exp(α*(x[4] - x[5]))) - exp(α*(x[5] - x[6]))) + dx[6] = (-x[6] + x[5]) + (exp(α*(x[5] - x[6])) - 1) dx[7] = one(x[7]) return dx end + function circuits() - automaton = LightAutomaton(2) # two modes + automaton = LightAutomaton(3) #three modes inv_one = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0)]) @@ -64,31 +65,20 @@ function circuits() add_transition!(automaton, 1, 2, 1) # first transion add_transition!(automaton, 2, 3, 2) # second transion -# add_transition!(automaton, 2, 1, 3) # third transion -# add_transition!(automaton, 3, 2, 4) # fourth transion G_first = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -1.0)]) - G_second = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) -# G_third = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0)]) -# G_fourth = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 2.0)]) - - A = [0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; - 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 1.0] - - b = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] - - R_first = ConstrainedAffineMap(A, b, G_first) - R_second = ConstrainedAffineMap(A, b, G_second) -# R_third = ConstrainedAffineMap(A2, b1, G_third) -# R_fourth = ConstrainedAffineMap(A1, b2, G_fourth) + G_second = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) + + R_first = ConstrainedIdentityMap(7, G_first) + R_second = ConstrainedIdentityMap(7, G_second) # resetmaps - resetmaps = [R_first, R_second]# R_third, R_fourth] + resetmaps = [R_first, R_second] # switchings switching = AutonomousSwitching() switchings = fill(switching, 2) ℋ = HybridSystem(automaton, modes, resetmaps, switchings) - # initial condition in mode three + X0 = Hyperrectangle(low = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], high = [0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.01]) # initial condition initial_condition = [(1, X0)] From 2fb745b32da4cd212aac5eab7c1f14100f5462e5 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Tue, 30 Jul 2019 16:45:12 +0530 Subject: [PATCH 5/6] Update transmissionlinecircuits.jl --- models/TransmissionLineCircuit/transmissionlinecircuits.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/TransmissionLineCircuit/transmissionlinecircuits.jl b/models/TransmissionLineCircuit/transmissionlinecircuits.jl index c52cdada..a35273c8 100644 --- a/models/TransmissionLineCircuit/transmissionlinecircuits.jl +++ b/models/TransmissionLineCircuit/transmissionlinecircuits.jl @@ -2,8 +2,9 @@ # ============================================================================== -using Reachability, HybridSystems -using Plots +using MathematicalSystems, Reachability, HybridSystems +using Reachability: solve +using TaylorIntegration @taylorize function transmission_line_circuits_one!(t, x, dx) local α = 5 From b26a5f6f6c249eb3c60835fdf137a42f95656e93 Mon Sep 17 00:00:00 2001 From: Aadesha Date: Wed, 31 Jul 2019 19:49:37 +0530 Subject: [PATCH 6/6] Update transmissionlinecircuits.jl --- .../transmissionlinecircuits.jl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/models/TransmissionLineCircuit/transmissionlinecircuits.jl b/models/TransmissionLineCircuit/transmissionlinecircuits.jl index a35273c8..68846c2a 100644 --- a/models/TransmissionLineCircuit/transmissionlinecircuits.jl +++ b/models/TransmissionLineCircuit/transmissionlinecircuits.jl @@ -1,6 +1,15 @@ -# ============================================================================== +#= +This is Non-linear transmission line circuits model, +Originally considered by Chen et al [1] +and then adapted to be hybrid case studies [2, 3] -# ============================================================================== +[1] https://www.researchgate.net/publication/2538345_A_Quadratic_Method_for_Nonlinear_Model_Order_Reduction + +[2] https://ieeexplore.ieee.org/document/1174092 + +[3] C. Gu. Model Order Reduction of Nonlinear Dynamical Systems. + PhD thesis, University of California, Berkeley, 2011 +=# using MathematicalSystems, Reachability, HybridSystems using Reachability: solve @@ -67,8 +76,8 @@ function circuits() add_transition!(automaton, 1, 2, 1) # first transion add_transition!(automaton, 2, 3, 2) # second transion - G_first = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -1.0)]) - G_second = HPolyhedron([HalfSpace([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0], -2.0)]) + G_first = Hyperplane([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 1.0) + G_second = Hyperplane([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], 2.0) R_first = ConstrainedIdentityMap(7, G_first) R_second = ConstrainedIdentityMap(7, G_second)