diff --git a/docs/src/basics/MTKModel_Connector.md b/docs/src/basics/MTKModel_Connector.md index b562c5323c..9fc57bacc2 100644 --- a/docs/src/basics/MTKModel_Connector.md +++ b/docs/src/basics/MTKModel_Connector.md @@ -65,6 +65,11 @@ end @extend ModelB(; p1) @components begin model_a = ModelA(; k_array) + model_array_a = [Model_A(; k = i) for in in 1:N] + model_array_b = for i in 1:N + k = i^2 + Model_A(; k) + end end @equations begin model_a.k ~ f(v) @@ -136,6 +141,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,10 +249,10 @@ For example, the structure of `ModelC` is: ```julia julia> ModelC.structure Dict{Symbol, Any} with 7 entries: - :components => [[:model_a, :ModelA]] + :components => Vector{Union{Expr, Symbol}}[[:model_a, :ModelA], [:model_array_a, :Model_A, :(1:N)], [:model_array_b, :Model_A, :(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, :model_array_b__k=>nothing, :v=>:v_var, :v_array=>nothing, :model_a__k_array=>nothing, :model_array_a__k=>nothing, :p1=>nothing) :independent_variable => t :extend => Any[[:p2, :p1], Symbol("#mtkmodel__anonymous__ModelB"), :ModelB] :equations => ["model_a.k ~ f(v)"]