SImple example error on simulate!()
GHE-HS opened this issue · 2 comments
When running
using BoreholeNetworksSimulator
Δt = 8760*3600/12.
Nt = 10*12
α = 1e-6
λ = 3.
T0 = 10.
medium = GroundMedium(α=α, λ=λ, T0=T0)
D = 10.
H = 100.
borehole = SingleUPipeBorehole(H=H, D=D)
σ = 5.
positions = [(0., 0.), (0., σ)]
borefield = EqualBoreholesBorefield(borehole_prototype=borehole, positions=positions)
configurations = [BoreholeNetwork([[1], [2]])]
q1 = 5.
q2 = 5.
constraint = constant_HeatLoadConstraint([q1, q2], Nt)
options = SimulationOptions(
method = ConvolutionMethod(),
constraint = constraint,
borefield = borefield,
medium = medium,
Δt = Δt,
Nt = Nt,
configurations = configurations
)
function operator(i, Tin, Tout, Tb, q, configurations)
network = configurations[1]
BoreholeOperation(network, 2 .* ones(n_branches(network)))
end
containers = initialize(options)
@time simulate!(operator=operator, options=options, containers=containers)
containers.X
I got the following error:
ERROR: MethodError: no method matching operator(::Int64, ::SubArray{…}, ::SubArray{…}, ::SubArray{…}, ::SubArray{…}, ::Vector{…}, ::Vector{…})
Closest candidates are:
operator(::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
@ Main c:\Users\adrien.vautrin\Documents\GitHub\temp\test2.jl:37Stacktrace:
[1] simulate!(; operator::typeof(operator), options::SimulationOptions{…}, containers::SimulationContainers{…})
@ BoreholeNetworksSimulator C:\Users\adrien.vautrin.julia\packages\BoreholeNetworksSimulator\PQD9M\src\modular\simulate.jl:38
[2] macro expansion
@ .\timing.jl:279 [inlined]
[3] top-level scope
@ c:\Users\adrien.vautrin\Documents\GitHub\temp\test2.jl:44
Some type information was truncated. Useshow(err)
to see complete types.
Packages installed:
[b11dda51] BoreholeNetworksSimulator v0.1.7
[336ed68f] CSV v0.10.14
And now with this slightly different example:
using BoreholeNetworksSimulator
Δt = 3600.#8760*3600/12.
Nt = 8760
medium = GroundMedium(α=1e-6, λ=3., T0=10.)
borehole = SingleUPipeBorehole(H=10., D=10.)
positions = [(0., 0.), (0., 5.)]
borefield = EqualBoreholesBorefield(borehole_prototype=borehole, positions=positions)
constraint = constant_HeatLoadConstraint(5 .* ones(BoreholeNetworksSimulator.n_boreholes(borefield)), Nt)
configurations = [BoreholeNetwork([[1], [2]])]
function operator(i, Tin, Tout, Tb, q, configurations)
network = configurations[1]
BoreholeOperation(network, 2 .* ones(n_branches(network)))
end
options_nonhistory = SimulationOptions(
method = NonHistoryMethod(),
constraint = constraint,
borefield = borefield,
medium = medium,
Δt = Δt,
Nt = Nt,
configurations = configurations
)
containers_nonhistory = @time initialize(options_nonhistory)
@time simulate!(operator=operator, options=options_nonhistory, containers=containers_nonhistory)
I get
ERROR: BoundsError: attempt to access 1-element Vector{BoreholeNetwork}
at index [2]
Stacktrace:
[1] getindex
@ .\essentials.jl:13 [inlined]
[2] operator(i::Int64, Tin::SubArray{…}, Tout::SubArray{…}, Tb::SubArray{…}, q::SubArray{…}, configurations::Vector{…}, mass_flow_containers::Vector{…})
@ Main .\Untitled-1:55
[3] simulate!(; operator::typeof(operator), options::SimulationOptions{…}, containers::SimulationContainers{…})
@ BoreholeNetworksSimulator C:\Users\adrien.vautrin\.julia\packages\BoreholeNetworksSimulator\PQD9M\src\modular\simulate.jl:38
[4] macro expansion
@ .\timing.jl:279 [inlined]
[5] top-level scope
@ .\Untitled-1:30
Some type information was truncated. Use `show(err)` to see complete types.
On simulate!(). It seems to happen on:
operation = @views operator(i, X[1:2:2Nb, 1:i], X[2:2:2Nb, 1:i], X[2Nb+1:3Nb, 1:i], X[3Nb+1:end, 1:i], configurations, mass_flows_container)
Not entirely sure what is going on