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
Malthe Kjær Bisbo
GOFEE
Commits
1e343e82
Commit
1e343e82
authored
Jan 20, 2020
by
Malthe Kjær Bisbo
Browse files
works when tested on C6H6
parent
ccc788d2
Changes
2
Show whitespace changes
Inline
Side-by-side
__pycache__/gofee.cpython-36.pyc
View file @
1e343e82
No preview for this file type
gofee.py
View file @
1e343e82
...
@@ -66,6 +66,10 @@ class GOFEE():
...
@@ -66,6 +66,10 @@ class GOFEE():
kappa:
kappa:
N_relax_final_pop: int or None.
If not None the best 'N_relax_final_pop' structures in the
population is relaxed after the specified number of search
iterations is reached.
"""
"""
def
__init__
(
self
,
structures
=
None
,
def
__init__
(
self
,
structures
=
None
,
calc
=
None
,
calc
=
None
,
...
@@ -74,14 +78,15 @@ class GOFEE():
...
@@ -74,14 +78,15 @@ class GOFEE():
candidate_generator
=
None
,
candidate_generator
=
None
,
trajectory
=
None
,
trajectory
=
None
,
kappa
=
2
,
kappa
=
2
,
Niter
=
200
,
max_steps
=
200
,
Ninit
=
10
,
Ninit
=
10
,
dmax_cov
=
3.5
,
dmax_cov
=
3.5
,
Ncandidates
=
30
,
Ncandidates
=
30
,
population_size
=
5
,
population_size
=
5
,
dualpoint
=
True
,
dualpoint
=
True
,
min_certainty
=
0.7
,
min_certainty
=
0.7
,
restart
=
None
):
restart
=
None
,
N_relax_final_pop
=
None
):
if
structures
is
None
:
if
structures
is
None
:
assert
startgenerator
is
not
None
assert
startgenerator
is
not
None
...
@@ -141,13 +146,21 @@ class GOFEE():
...
@@ -141,13 +146,21 @@ class GOFEE():
self
.
master
=
self
.
comm
.
rank
==
0
self
.
master
=
self
.
comm
.
rank
==
0
self
.
kappa
=
kappa
self
.
kappa
=
kappa
self
.
Niter
=
Niter
self
.
max_steps
=
max_steps
self
.
Ninit
=
Ninit
self
.
Ninit
=
Ninit
self
.
dmax_cov
=
dmax_cov
self
.
dmax_cov
=
dmax_cov
self
.
Ncandidates
=
Ncandidates
self
.
Ncandidates
=
Ncandidates
self
.
dualpoint
=
dualpoint
self
.
dualpoint
=
dualpoint
self
.
min_certainty
=
min_certainty
self
.
min_certainty
=
min_certainty
self
.
restart
=
restart
self
.
restart
=
restart
if
N_relax_final_pop
is
None
:
self
.
N_relax_final_pop
=
0
else
:
try
:
self
.
N_relax_final_pop
=
int
(
N_relax_final_pop
)
except
TypeError
:
raise
if
isinstance
(
trajectory
,
str
):
if
isinstance
(
trajectory
,
str
):
self
.
trajectory
=
Trajectory
(
filename
=
trajectory
,
mode
=
'a'
,
master
=
self
.
master
)
self
.
trajectory
=
Trajectory
(
filename
=
trajectory
,
mode
=
'a'
,
master
=
self
.
master
)
...
@@ -177,6 +190,7 @@ class GOFEE():
...
@@ -177,6 +190,7 @@ class GOFEE():
generated using self.startgenerator (if supplied), otherwise
generated using self.startgenerator (if supplied), otherwise
they are generated by heavily rattling the supplied structures.
they are generated by heavily rattling the supplied structures.
"""
"""
# Collect potentially supplied structures and evaluate
# Collect potentially supplied structures and evaluate
# energies and forces if not present.
# energies and forces if not present.
structures_init
=
[]
structures_init
=
[]
...
@@ -221,7 +235,7 @@ class GOFEE():
...
@@ -221,7 +235,7 @@ class GOFEE():
def
run
(
self
):
def
run
(
self
):
self
.
get_initial_structures
()
self
.
get_initial_structures
()
while
self
.
steps
<
self
.
Niter
:
while
self
.
steps
<
self
.
max_steps
:
self
.
print_master
(
'steps:'
,
self
.
steps
)
self
.
print_master
(
'steps:'
,
self
.
steps
)
self
.
train_surrogate
()
self
.
train_surrogate
()
self
.
update_population
()
self
.
update_population
()
...
@@ -260,6 +274,8 @@ class GOFEE():
...
@@ -260,6 +274,8 @@ class GOFEE():
print
(
'E_true:'
,
[
a
.
get_potential_energy
()
for
a
in
a_add
])
print
(
'E_true:'
,
[
a
.
get_potential_energy
()
for
a
in
a_add
])
print
(
'pop:'
,
[
a
.
get_potential_energy
()
for
a
in
self
.
population
.
pop
])
print
(
'pop:'
,
[
a
.
get_potential_energy
()
for
a
in
self
.
population
.
pop
])
self
.
relax_final_population
()
def
get_dualpoint
(
self
,
a
,
lmax
=
0.10
,
Fmax_flat
=
5
):
def
get_dualpoint
(
self
,
a
,
lmax
=
0.10
,
Fmax_flat
=
5
):
"""Returns dual-point structure, i.e. the original structure
"""Returns dual-point structure, i.e. the original structure
perturbed slightly along the forces.
perturbed slightly along the forces.
...
@@ -401,6 +417,14 @@ class GOFEE():
...
@@ -401,6 +417,14 @@ class GOFEE():
return
a
return
a
def
relax_final_population
(
self
):
if
self
.
N_relax_final_pop
>
0
:
relaxed_population_trajectory
=
Trajectory
(
filename
=
'relaxed_final_population.traj'
,
mode
=
'a'
,
master
=
self
.
master
)
for
a
in
self
.
population
.
pop
[:
self
.
N_relax_final_pop
]:
a
=
relax
(
a
,
self
.
calc
,
Fmax
=
0.05
,
steps_max
=
20
)
relaxed_population_trajectory
.
write
(
a
)
def
write
(
self
,
a
):
def
write
(
self
,
a
):
if
self
.
trajectory
is
not
None
:
if
self
.
trajectory
is
not
None
:
self
.
trajectory
.
write
(
a
)
self
.
trajectory
.
write
(
a
)
...
...
Write
Preview
Supports
Markdown
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