Skip to content

Commit 970b404

Browse files
authored
Merge branch 'SciML:master' into iss3707
2 parents 17f978b + 7b5c5f0 commit 970b404

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
4-
version = "10.7.0"
4+
version = "10.8.0"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -89,7 +89,7 @@ MTKPyomoDynamicOptExt = "Pyomo"
8989
ADTypes = "1.14.0"
9090
AbstractTrees = "0.3, 0.4"
9191
ArrayInterface = "6, 7"
92-
BifurcationKit = "0.4"
92+
BifurcationKit = "0.4, 0.5"
9393
BlockArrays = "1.1"
9494
BoundaryValueDiffEqAscher = "1.6.0"
9595
BoundaryValueDiffEqMIRK = "1.7.0"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
3434
[compat]
3535
Attractors = "1.24"
3636
BenchmarkTools = "1.3"
37-
BifurcationKit = "0.4"
37+
BifurcationKit = "0.4, 0.5"
3838
CairoMakie = "0.13, 0.15"
3939
CommonSolve = "0.2"
4040
DataInterpolations = "6.5, 8"

src/systems/analysis_points.jl

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,20 @@ struct Break <: AnalysisPointTransformation
491491
applicable if `add_input == true`.
492492
"""
493493
default_outputs_to_input::Bool
494+
"""
495+
Whether the added input is a parameter. Only applicable if `add_input == true`.
496+
"""
497+
added_input_is_param::Bool
494498
end
495499

496500
"""
497501
$(TYPEDSIGNATURES)
498502
499503
`Break` the given analysis point `ap`.
500504
"""
501-
Break(ap::AnalysisPoint, add_input::Bool = false) = Break(ap, add_input, false)
505+
function Break(ap::AnalysisPoint, add_input::Bool = false, default_outputs_to_input = false)
506+
Break(ap, add_input, default_outputs_to_input, false)
507+
end
502508

503509
function apply_transformation(tf::Break, sys::AbstractSystem)
504510
modify_nested_subsystem(sys, tf.ap) do breaksys
@@ -528,9 +534,15 @@ function apply_transformation(tf::Break, sys::AbstractSystem)
528534
new_def
529535
end
530536
@set! breaksys.defaults = defs
531-
unks = copy(get_unknowns(breaksys))
532-
push!(unks, new_var)
533-
@set! breaksys.unknowns = unks
537+
if tf.added_input_is_param
538+
ps = copy(get_ps(breaksys))
539+
push!(ps, new_var)
540+
@set! breaksys.ps = ps
541+
else
542+
unks = copy(get_unknowns(breaksys))
543+
push!(unks, new_var)
544+
@set! breaksys.unknowns = unks
545+
end
534546

535547
return breaksys, (new_var,)
536548
end
@@ -812,12 +824,14 @@ Given a list of analysis points, break the connection for each and set the outpu
812824
"""
813825
function handle_loop_openings(sys::AbstractSystem, aps)
814826
for ap in canonicalize_ap(sys, aps)
815-
sys, (outvar,) = apply_transformation(Break(ap, true, true), sys)
816-
if Symbolics.isarraysymbolic(outvar)
817-
push!(get_eqs(sys), outvar ~ zeros(size(outvar)))
827+
sys, (d_v,) = apply_transformation(Break(ap, true, true, true), sys)
828+
guesses = copy(get_guesses(sys))
829+
guesses[d_v] = if symbolic_type(d_v) == ArraySymbolic()
830+
fill(NaN, size(d_v))
818831
else
819-
push!(get_eqs(sys), outvar ~ 0)
832+
NaN
820833
end
834+
@set! sys.guesses = guesses
821835
end
822836
return sys
823837
end
@@ -849,10 +863,10 @@ All other keyword arguments are forwarded to `linearization_function`.
849863
"""
850864
function get_linear_analysis_function(
851865
sys::AbstractSystem, transform, aps; system_modifier = identity, loop_openings = [], kwargs...)
852-
sys = handle_loop_openings(sys, loop_openings)
853-
aps = canonicalize_ap(sys, aps)
854866
dus = []
855867
us = []
868+
sys = handle_loop_openings(sys, loop_openings)
869+
aps = canonicalize_ap(sys, aps)
856870
for ap in aps
857871
sys, (du, u) = apply_transformation(transform(ap), sys)
858872
push!(dus, du)

0 commit comments

Comments
 (0)