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
Open sidebar
Neel Shah
NIFTy
Commits
597286b4
Commit
597286b4
authored
May 29, 2018
by
Martin Reinecke
Browse files
improve energy test
parent
0df979f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty4/extra/energy_tests.py
View file @
597286b4
...
...
@@ -54,11 +54,13 @@ def check_value_gradient_consistency(E, tol=1e-6, ntries=100):
dirnorm
=
dir
.
norm
()
dirder
=
E
.
gradient
.
vdot
(
dir
)
/
dirnorm
for
i
in
range
(
50
):
Emid
=
E
.
at
(
E
.
position
+
0.5
*
dir
)
dirder
=
Emid
.
gradient
.
vdot
(
dir
)
/
dirnorm
if
abs
((
E2
.
value
-
val
)
/
dirnorm
-
dirder
)
<
tol
:
break
dir
*=
0.5
dirnorm
*=
0.5
E2
=
E
2
.
at
(
E
.
position
+
dir
)
E2
=
E
mid
else
:
raise
ValueError
(
"gradient and value seem inconsistent"
)
# E = Enext
...
...
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