Skip to content

Commit 4d84c92

Browse files
committed
Link solverstats to DEStats
1 parent 3e93bf2 commit 4d84c92

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/MATLABDiffEq.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ function DiffEqBase.__solve(
6262

6363
eval_string("options = odeset('RelTol',reltol,'AbsTol',abstol);")
6464
algstr = string(typeof(alg).name.name)
65-
@show algstr
6665
eval_string("mxsol = $(algstr)(diffeqf,tspan,u0,options);")
6766
eval_string("mxsolstats = struct(mxsol.stats);")
68-
solstats= get_variable(:mxsolstats)
67+
solstats = get_variable(:mxsolstats)
6968
eval_string("t = mxsol.x;")
7069
ts = jvector(get_mvariable(:t))
7170
eval_string("u = mxsol.y';")
@@ -81,13 +80,21 @@ function DiffEqBase.__solve(
8180
timeseries = timeseries_tmp
8281
end
8382

84-
destats = DiffEqBase.DEStats(0)
85-
86-
# destats.naccept = solstats["nsteps"]
87-
# #destats.nsolve = solstats[""]
83+
destats = buildDEStats(solstats)
8884

8985
DiffEqBase.build_solution(prob,alg,ts,timeseries,
90-
timeseries_errors = timeseries_errors,destats=solstats)
86+
timeseries_errors = timeseries_errors,destats = destats)
87+
end
88+
89+
function buildDEStats(solverstats::Dict)
90+
91+
destats = DiffEqBase.DEStats(0)
92+
destats.nf = if (haskey(solverstats, "nfevals")) solverstats["nfevals"] else 0 end
93+
destats.nreject = if (haskey(solverstats, "nfailed")) solverstats["nfailed"] else 0 end
94+
destats.naccept = if (haskey(solverstats, "nsteps")) solverstats["nsteps"] else 0 end
95+
destats.nsolve = if (haskey(solverstats, "nsolves")) solverstats["nsolves"] else 0 end
96+
destats.njacs = if (haskey(solverstats, "npds")) solverstats["npds"] else 0 end
97+
destats
9198
end
9299

93100
end # module

0 commit comments

Comments
 (0)