Hi
I’m trying to automate the battery cells’ creation from an already defined ECM model:
const Qs = [4.8 4.4 4.2 ; 3.7 3.5 3.3]
@mtkmodel Series_Connection begin
@variables begin
v_max
v_min
end
@components begin
cells = [ECM(focv=focv, Q=Qs[i]) for i in eachindex(Qs)]
#...
end
@equations begin
# Series connect all cells
[connect(cells[j+(col*i)].n, cells[j+1+(col*i)].p) for i in 0:row-1, j in 1:col-1] #error
#Connect in parallel
connect(source.n, voltage.n, cells[1+col*0].p, cells[1+col*1].p)
connect(source.p, voltage.p, cells[col*1].n, cells[end].n, ground.g)
v_max ~ maximum([cells[i].v for i in eachindex(Qs)])
v_min ~ minimum([cells[i].v for i in eachindex(Qs)])
#...
end
end
With ERROR: MethodError: Cannot `convert` an object of type Matrix{Equation} to an object of type Union{Equation, Vector{Equation}}
How could I implement this otherwise? Even better would be to be able to manipulate matrices instead of arrays.