-
-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathtype.jl
108 lines (91 loc) · 2.32 KB
/
type.jl
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
abstract type AbstractNLSolverAlgorithm end
abstract type AbstractNLSolverCache end
@enum NLStatus::Int8 begin
FastConvergence = 2
Convergence = 1
SlowConvergence = 0
VerySlowConvergence = -1
Divergence = -2
end
# solver
mutable struct NLSolver{iip,uType,rateType,uTolType,kType,gType,cType,du1Type,ufType,jcType,lsType,C1,C<:AbstractNLSolverCache}
z::uType
dz::uType
tmp::uType
ztmp::uType
k::rateType
ηold::uTolType
κ::kType
γ::gType
c::cType
max_iter::Int
nl_iters::Int
status::NLStatus
fast_convergence_cutoff::C1
du1::du1Type
uf::ufType
jac_config::jcType
linsolve::lsType
weight::uType
cache::C
end
# algorithms
struct NLFunctional{K,C} <: AbstractNLSolverAlgorithm
κ::K
fast_convergence_cutoff::C
max_iter::Int
end
NLFunctional(; κ=1//100, max_iter=10, fast_convergence_cutoff=1//5) = NLFunctional(κ, fast_convergence_cutoff, max_iter)
struct NLAnderson{K,D,C} <: AbstractNLSolverAlgorithm
κ::K
fast_convergence_cutoff::C
max_iter::Int
max_history::Int
aa_start::Int
droptol::D
end
NLAnderson(; κ=1//100, max_iter=10, max_history::Int=5, aa_start::Int=1, droptol=nothing, fast_convergence_cutoff=1//5) =
NLAnderson(κ, fast_convergence_cutoff, max_iter, max_history, aa_start, droptol)
struct NLNewton{K,C1,C2} <: AbstractNLSolverAlgorithm
κ::K
max_iter::Int
fast_convergence_cutoff::C1
new_W_dt_cutoff::C2
end
NLNewton(; κ=1//100, max_iter=10, fast_convergence_cutoff=1//5, new_W_dt_cutoff=1//5) = NLNewton(κ, max_iter, fast_convergence_cutoff, new_W_dt_cutoff)
# caches
mutable struct NLNewtonCache{W,J,T,C} <: AbstractNLSolverCache
new_W::Bool
W::W
J::J
W_dt::T
new_W_dt_cutoff::C
end
mutable struct NLNewtonConstantCache{W,J,C} <: AbstractNLSolverCache
W::W
J::J
new_W_dt_cutoff::C
end
struct NLFunctionalCache{uType} <: AbstractNLSolverCache
z₊::uType
end
struct NLFunctionalConstantCache <: AbstractNLSolverCache end
mutable struct NLAndersonCache{uType,gsType,QType,RType,gType,D} <: AbstractNLSolverCache
z₊::uType
dzold::uType
z₊old::uType
Δz₊s::gsType
Q::QType
R::RType
γs::gType
aa_start::Int
droptol::D
end
mutable struct NLAndersonConstantCache{gsType,QType,RType,gType,D} <: AbstractNLSolverCache
Δz₊s::gsType
Q::QType
R::RType
γs::gType
aa_start::Int
droptol::D
end