Skip to content

Commit

Permalink
refactor: use tuple for p instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
sathvikbhagavan committed Aug 6, 2023
1 parent 8e25b07 commit 1b28561
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/FMI2/sim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ end
function fx(c::FMU2Component,
dx::AbstractArray{<:Real},
x::AbstractArray{<:Real},
p::AbstractArray,
p::Tuple,
t::Real)

c.solution.evals_fx_inplace += 1
Expand All @@ -247,7 +247,7 @@ end

function fx(c::FMU2Component,
x::AbstractArray{<:Real},
p::AbstractArray,
p::Tuple,
t::Real)

c.solution.evals_fx_outofplace += 1
Expand All @@ -269,9 +269,9 @@ function fmi2SimulateME(c::FMU2Component, tspan::Union{Tuple{Float64, Float64},
end

# sets up the ODEProblem for simulating a ME-FMU
function setupODEProblem(c::FMU2Component, x0::AbstractArray{fmi2Real}, tspan::Union{Tuple{Float64, Float64}, Nothing}=nothing; p=[], customFx=nothing)
function setupODEProblem(c::FMU2Component, x0::AbstractArray{fmi2Real}, tspan::Union{Tuple{Float64, Float64}, Nothing}=nothing; p=(), customFx=nothing)

p = []
p = ()

if c.fmu.executionConfig.inPlace
if customFx === nothing
Expand Down
6 changes: 3 additions & 3 deletions src/FMI3/sim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ end
function fx(c::FMU3Instance,
dx::AbstractArray{<:Real},
x::AbstractArray{<:Real},
p::AbstractArray,
p::Tuple,
t::Real)

# if isa(t, ForwardDiff.Dual)
Expand Down Expand Up @@ -799,12 +799,12 @@ function fmi3SimulateME(c::FMU3Instance, t_start::Union{Real, Nothing} = nothing
end

# sets up the ODEProblem for simulating a ME-FMU
function setupODEProblem(c::FMU3Instance, x0::AbstractArray{fmi3Float64}, t_start::fmi3Float64, t_stop::fmi3Float64; p=[], customFx=nothing)
function setupODEProblem(c::FMU3Instance, x0::AbstractArray{fmi3Float64}, t_start::fmi3Float64, t_stop::fmi3Float64; p=(), customFx=nothing)
if customFx === nothing
customFx = (dx, x, p, t) -> fx(c, dx, x, p, t)
end

p = []
p = ()
c.problem = ODEProblem(customFx, x0, (t_start, t_stop), p,)

return c.problem
Expand Down

0 comments on commit 1b28561

Please sign in to comment.