Skip to content

Commit

Permalink
Merge pull request #846 from mimiframework/ConnectorCompDims
Browse files Browse the repository at this point in the history
Connector comp dims
  • Loading branch information
davidanthoff authored Sep 28, 2021
2 parents 69a8def + e231262 commit 09379b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/connector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ using Mimi
end

@defcomp ConnectorCompMatrix begin
regions = Index()
ConnectorCompMatrix_Dim2 = Index()

input1 = Parameter(index = [time, regions])
input2 = Parameter(index = [time, regions])
output = Variable(index = [time, regions])
input1 = Parameter(index = [time, ConnectorCompMatrix_Dim2])
input2 = Parameter(index = [time, ConnectorCompMatrix_Dim2])
output = Variable(index = [time, ConnectorCompMatrix_Dim2])

first = Parameter() # first year to use the shorter data
last = Parameter() # last year to use the shorter data
Expand All @@ -38,7 +38,7 @@ end
input = p.input2
end

for r in d.regions
for r in d.ConnectorCompMatrix_Dim2
v.output[t, r] = @allow_missing(input[t, r])
end
end
Expand Down
3 changes: 3 additions & 0 deletions src/core/connections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,9 @@ function add_connector_comps!(obj::AbstractCompositeComponentDef)
# required it, and for now let the first and last of the component
# be free and thus be set to the same as the model
conn_comp = add_comp!(obj, conn_comp_def, conn_comp_name, before=comp_name)
if num_dims == 2
set_dimension!(obj, :ConnectorCompMatrix_Dim2, 1:size(model_param(obj, conn.backup).values,2))
end
conn_path = conn_comp.comp_path

# remove the connections added in add_comp!
Expand Down

0 comments on commit 09379b2

Please sign in to comment.