-
-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathOrdinaryDiffEqBDF.jl
More file actions
159 lines (142 loc) · 4.8 KB
/
OrdinaryDiffEqBDF.jl
File metadata and controls
159 lines (142 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
module OrdinaryDiffEqBDF
import OrdinaryDiffEqCore: alg_order, calculate_residuals!,
initialize!, perform_step!, unwrap_alg,
calculate_residuals, alg_extrapolates,
OrdinaryDiffEqAlgorithm,
OrdinaryDiffEqMutableCache, OrdinaryDiffEqConstantCache,
OrdinaryDiffEqNewtonAdaptiveAlgorithm,
OrdinaryDiffEqNewtonAlgorithm,
AbstractController, DEFAULT_PRECS,
CompiledFloats, uses_uprev,
alg_cache, _vec, _reshape, @cache,
isfsal, full_cache,
constvalue, isadaptive, error_constant,
has_special_newton_error,
trivial_limiter!,
issplit, qsteady_min_default, qsteady_max_default,
get_current_alg_order, get_current_adaptive_order,
stepsize_controller!,
step_accept_controller!,
step_reject_controller!, post_newton_controller!,
u_modified!, DAEAlgorithm, _unwrap_val, DummyController,
get_fsalfirstlast, generic_solver_docstring, _bool_to_ADType,
_process_AD_choice,
_ode_interpolant, _ode_interpolant!, has_stiff_interpolation,
_ode_addsteps!, DerivativeOrderNotPossibleError, set_discontinuity
using OrdinaryDiffEqSDIRK: ImplicitEulerConstantCache, ImplicitEulerCache
using TruncatedStacktraces: @truncate_stacktrace
using MuladdMacro: @muladd
using MacroTools: @capture
using FastBroadcast: @..
using RecursiveArrayTools: recursivefill!
import StaticArrays: SArray, MVector, SVector, @SVector, StaticArray, MMatrix, SA
using LinearAlgebra: mul!, I
import ArrayInterface
using ArrayInterface: ismutable
import OrdinaryDiffEqCore
@static if Base.pkgversion(OrdinaryDiffEqCore) >= v"3.4"
@eval begin
import OrdinaryDiffEqCore: default_controller_v7,
legacy_default_controller
end
else
@eval begin
import OrdinaryDiffEqCore: default_controller
end
end
@static if Base.pkgversion(OrdinaryDiffEqCore) >= v"3.10"
@eval begin
import OrdinaryDiffEqCore: get_current_qmax
end
else
@eval begin
# Fallback for older OrdinaryDiffEqCore: no first-step qmax behavior
@inline get_current_qmax(integrator, qmax) = qmax
end
end
using OrdinaryDiffEqDifferentiation: UJacobianWrapper
using OrdinaryDiffEqNonlinearSolve: NLNewton, du_alias_or_new, build_nlsolver,
nlsolve!, nlsolvefail, isnewton, markfirststage!,
set_new_W!, DIRK, compute_step!, COEFFICIENT_MULTISTEP,
NonlinearSolveAlg
import ADTypes: AutoForwardDiff, AutoFiniteDiff, AbstractADType
using Reexport
@reexport using SciMLBase
include("algorithms.jl")
include("alg_utils.jl")
include("bdf_utils.jl")
include("stald.jl")
include("bdf_caches.jl")
include("dae_caches.jl")
include("controllers.jl")
include("dae_perform_step.jl")
include("bdf_perform_step.jl")
include("interp_func.jl")
include("bdf_interpolants.jl")
include("stiff_addsteps.jl")
import PrecompileTools
import Preferences
PrecompileTools.@compile_workload begin
lorenz = OrdinaryDiffEqCore.lorenz
lorenz_oop = OrdinaryDiffEqCore.lorenz_oop
solver_list = [FBDF()]
prob_list = []
if Preferences.@load_preference("PrecompileDefaultSpecialize", true)
push!(prob_list, ODEProblem(lorenz, [1.0; 0.0; 0.0], (0.0, 1.0)))
push!(prob_list, ODEProblem(lorenz, [1.0; 0.0; 0.0], (0.0, 1.0), Float64[]))
end
if Preferences.@load_preference("PrecompileAutoSpecialize", false)
push!(
prob_list,
ODEProblem{true, SciMLBase.AutoSpecialize}(
lorenz, [1.0; 0.0; 0.0],
(0.0, 1.0)
)
)
push!(
prob_list,
ODEProblem{true, SciMLBase.AutoSpecialize}(
lorenz, [1.0; 0.0; 0.0],
(0.0, 1.0), Float64[]
)
)
end
if Preferences.@load_preference("PrecompileFunctionWrapperSpecialize", false)
push!(
prob_list,
ODEProblem{true, SciMLBase.FunctionWrapperSpecialize}(
lorenz, [1.0; 0.0; 0.0],
(0.0, 1.0)
)
)
push!(
prob_list,
ODEProblem{true, SciMLBase.FunctionWrapperSpecialize}(
lorenz, [1.0; 0.0; 0.0],
(0.0, 1.0), Float64[]
)
)
end
if Preferences.@load_preference("PrecompileNoSpecialize", false)
push!(
prob_list,
ODEProblem{true, SciMLBase.NoSpecialize}(lorenz, [1.0; 0.0; 0.0], (0.0, 1.0))
)
push!(
prob_list,
ODEProblem{true, SciMLBase.NoSpecialize}(
lorenz, [1.0; 0.0; 0.0], (0.0, 1.0),
Float64[]
)
)
end
for prob in prob_list, solver in solver_list
solve(prob, solver)(5.0)
end
prob_list = nothing
solver_list = nothing
end
export ABDF2, QNDF1, QBDF1, QNDF2, QBDF2, QNDF, QBDF, FBDF,
SBDF, SBDF2, SBDF3, SBDF4, MEBDF2, IMEXEuler, IMEXEulerARK,
DABDF2, DImplicitEuler, DFBDF
end