Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
5104854f
Commit
5104854f
authored
Jul 22, 2019
by
Philipp Arras
Browse files
Add preconditioner to NewtonCG
parent
36209276
Pipeline
#52271
passed with stages
in 8 minutes and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty5/minimization/descent_minimizers.py
View file @
5104854f
...
...
@@ -160,14 +160,14 @@ class NewtonCG(DescentMinimizer):
super
(
NewtonCG
,
self
).
__init__
(
controller
=
controller
,
line_searcher
=
line_searcher
)
def
get_descent_direction
(
self
,
energy
):
def
get_descent_direction
(
self
,
energy
,
preconditioner
=
None
):
float64eps
=
np
.
finfo
(
np
.
float64
).
eps
r
=
energy
.
gradient
maggrad
=
abs
(
r
).
sum
()
termcond
=
np
.
min
([
0.5
,
np
.
sqrt
(
maggrad
)])
*
maggrad
pos
=
energy
.
position
*
0
d
=
r
previous_gamma
=
r
.
vdot
(
r
)
d
=
r
if
preconditioner
is
None
else
preconditioner
(
r
)
previous_gamma
=
r
.
vdot
(
d
)
ii
=
0
while
True
:
if
abs
(
r
).
sum
()
<=
termcond
:
...
...
@@ -182,7 +182,8 @@ class NewtonCG(DescentMinimizer):
alpha
=
previous_gamma
/
curv
pos
=
pos
-
alpha
*
d
r
=
r
-
alpha
*
q
gamma
=
r
.
vdot
(
r
)
s
=
r
if
preconditioner
is
None
else
preconditioner
(
r
)
gamma
=
r
.
vdot
(
s
)
d
=
d
*
(
gamma
/
previous_gamma
)
+
r
previous_gamma
=
gamma
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment