Skip to content

Changes in MTK initialization?? #3393

@B-LIE

Description

@B-LIE

Question: What has changed with MTK initialization?

I'm running a model to steady-state, picking out the steady state value, and try to use that in linearization. My code worked yesterday, but this morning I updated Julia packages (it's been a couple of weeks since last update), and now my code does not work.

So - either a bug has been introduced in MTK, or the method to initialize models has changed.

Here is what is going on:

  1. Run model to steady state:
tspan_ss = (0,1e3)   # "long" time to reach steady state
u_u_v(t) = u_v_const(t)   # u_u_v(t) is a register_symbolic function that provides input in the model
#
prob_ns_oL_ss = ODEProblem(hp_ns_oL, [], tspan_ss)
sol = solve(prob_ns_oL_ss,Rodas5())
x_ss = sol[end]   # Picks out the final value, interpreted as the steady state
  1. Creating model for linearization:
@named hp_ns_LoL = HydroPower_ns(; case = :u_i)   # case is a structural_parameter, 
                                                                                     # used to remove input equation.
hp_ns_LoL = complete(hp_ns_LoL)
  1. Specifying operational point for linearization:
op_x = Dict(unknowns(hp_ns_oL) .=> x_ss)  # specifying unknown values
op_u = Dict(hp_ns_LoL.u_v=>alpha_1_n/alpha_1_max) # "u" is the input
#
op_pt = merge(op_x, op_u)  # Operating point
  1. Carrying out linearization -- this worked yesterday, but fails now:
mats, _ = linearize(hp_ns_LoL, [hp_ns_LoL.u_v], [hp_ns_LoL.f_e]; op=op_pt, allow_input_derivatives=true)
sys_2 = ss(mats...)

This leads to the following error message:

Warning: Initialization system is overdetermined. 3 equations for 0 unknowns. Initialization will default to using least squares. `SCCNo...

NOTE to "clarify" my model...

  • In the model @variables section, I give initial values to sufficient number of "states" to ensure that the initial unknowns can be computed. And normal simulation works fine.
  • I have had some problems using the remake function lately. If I do remake(model_name, u0 = x_ss), it seems like I get an error message related to overdetermined initialization problem. Is there a conflict with the default initial values I have given to the model in the @variables section?
  • From the documentation of remake, there appears to have been made some changes??? There is also references to setp and setu, without examples of use (are these functions? keywords? or what?), as well as a replace (function?).
  • Has the above possible changes also led to setting the operational point by op = op_pt malfunctioning?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions