@@ -810,44 +810,45 @@ end
810
810
$(TYPEDEF)
811
811
812
812
A callable struct to use as the `get_updated_u0` field of `InitializationMetadata`.
813
- Returns the value of `Initial.(unknowns(sys))`, except with algebraic variables replaced
814
- by their guess values in the initialization problem.
813
+ Returns the value to use for the `u0` of the problem.
815
814
816
815
# Fields
817
816
818
817
$(TYPEDFIELDS)
819
818
"""
820
- struct GetUpdatedU0{GA , GIU}
819
+ struct GetUpdatedU0{GG , GIU}
821
820
"""
822
- Mask with length `length(unknowns(sys))` denoting indices of algebraic variables.
821
+ Mask with length `length(unknowns(sys))` denoting indices of variables which should
822
+ take the guess value from `initializeprob`.
823
823
"""
824
- algevars :: BitVector
824
+ guessvars :: BitVector
825
825
"""
826
- Function which returns the values of algebraic variables in `initializeprob`, in the
827
- order the algebraic variables occur in `unknowns(sys)`.
826
+ Function which returns the values of variables in `initializeprob` for which
827
+ `guessvars` is `true`, in the order they occur in `unknowns(sys)`.
828
828
"""
829
- get_algevars :: GA
829
+ get_guessvars :: GG
830
830
"""
831
831
Function which returns `Initial.(unknowns(sys))` as a `Vector`.
832
832
"""
833
833
get_initial_unknowns:: GIU
834
834
end
835
835
836
- function GetUpdatedU0 (sys:: AbstractSystem , initsys:: AbstractSystem )
836
+ function GetUpdatedU0 (sys:: AbstractSystem , initsys:: AbstractSystem , op :: AbstractDict )
837
837
dvs = unknowns (sys)
838
838
eqs = equations (sys)
839
- algevaridxs = BitVector (is_alg_equation .(eqs))
840
- append! (algevaridxs, falses (length (dvs) - length (eqs)))
841
- algevars = dvs[algevaridxs]
842
- get_algevars = getu (initsys, algevars)
839
+ guessvars = trues (length (dvs))
840
+ for (i, var) in enumerate (dvs)
841
+ guessvars[i] = ! isequal (get (op, var, nothing ), Initial (var))
842
+ end
843
+ get_guessvars = getu (initsys, dvs[guessvars])
843
844
get_initial_unknowns = getu (sys, Initial .(dvs))
844
- return GetUpdatedU0 (algevaridxs, get_algevars , get_initial_unknowns)
845
+ return GetUpdatedU0 (guessvars, get_guessvars , get_initial_unknowns)
845
846
end
846
847
847
848
function (guu:: GetUpdatedU0 )(prob, initprob)
848
849
buffer = guu. get_initial_unknowns (prob)
849
- algebuf = view (buffer, guu. algevars )
850
- copyto! (algebuf, guu. get_algevars (initprob))
850
+ algebuf = view (buffer, guu. guessvars )
851
+ copyto! (algebuf, guu. get_guessvars (initprob))
851
852
return buffer
852
853
end
853
854
@@ -890,7 +891,7 @@ function maybe_build_initialization_problem(
890
891
initializeprob = remake (initializeprob; p = initp)
891
892
892
893
get_initial_unknowns = if is_time_dependent (sys)
893
- GetUpdatedU0 (sys, initializeprob. f. sys)
894
+ GetUpdatedU0 (sys, initializeprob. f. sys, op )
894
895
else
895
896
nothing
896
897
end
0 commit comments