diff --git a/docs/src/basics/MTKModel_Connector.md b/docs/src/basics/MTKModel_Connector.md index b562c5323c..62873273f0 100644 --- a/docs/src/basics/MTKModel_Connector.md +++ b/docs/src/basics/MTKModel_Connector.md @@ -54,6 +54,7 @@ end @icon "https://github.com/SciML/SciMLDocs/blob/main/docs/src/assets/logo.png" @structural_parameters begin f = sin + N = 2 end begin v_var = 1.0 @@ -65,6 +66,11 @@ end @extend ModelB(; p1) @components begin model_a = ModelA(; k_array) + model_array_a = [ModelA(; k = i) for i in 1:N] + model_array_b = for i in 1:N + k = i^2 + ModelA(; k) + end end @equations begin model_a.k ~ f(v) @@ -136,6 +142,7 @@ julia> @mtkbuild model_c2 = ModelC(; p1 = 2.0) #### `@components` begin block - Declare the subcomponents within `@components` begin block. + - Array of components can be declared with a for loop or a list comprehension. - The arguments in these subcomponents are promoted as keyword arguments as `subcomponent_name__argname` with `nothing` as default value. - Whenever components are created with `@named` macro, these can be accessed with `.` operator as `subcomponent_name.argname` - In the above example, as `k` of `model_a` isn't listed while defining the sub-component in `ModelC`, its default value can't be modified by users. While `k_array` can be set as: @@ -243,13 +250,13 @@ For example, the structure of `ModelC` is: ```julia julia> ModelC.structure Dict{Symbol, Any} with 7 entries: - :components => [[:model_a, :ModelA]] + :components => Any[Union{Expr, Symbol}[:model_a, :ModelA], Union{Expr, Symbol}[:model_array_a, :ModelA, :(1:N)], Union{Expr, Symbol}[:model_array_b, :ModelA, :(1:N)]] :variables => Dict{Symbol, Dict{Symbol, Any}}(:v=>Dict(:default=>:v_var), :v_array=>Dict(:size=>(2, 3))) :icon => URI("https://github.com/SciML/SciMLDocs/blob/main/docs/src/assets/logo.png") - :kwargs => Dict{Symbol, Any}(:f=>:sin, :v=>:v_var, :v_array=>nothing, :model_a__k_array=>nothing, :p1=>nothing) + :kwargs => Dict{Symbol, Any}(:f=>:sin, :N=>2, :v=>:v_var, :v_array=>nothing, :p1=>nothing) :independent_variable => t :extend => Any[[:p2, :p1], Symbol("#mtkmodel__anonymous__ModelB"), :ModelB] - :equations => ["model_a.k ~ f(v)"] + :equations => Any["model_a.k ~ f(v)"] ``` ### Using conditional statements