Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MachineLearning_Al13Co4_PES
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GAUDRY Emilie
MachineLearning_Al13Co4_PES
Commits
22acce9a
Commit
22acce9a
authored
1 year ago
by
BOULANGEOT Nathan
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
2a00ca92
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
codes/tool.py
+61
-0
61 additions, 0 deletions
codes/tool.py
with
61 additions
and
0 deletions
codes/tool.py
0 → 100644
+
61
−
0
View file @
22acce9a
import
numpy
as
np
from
ase.constraints
import
FixScaled
,
FixAtoms
from
ase.io
import
Trajectory
from
dscribe.descriptors
import
SOAP
import
os
import
ase
def
sign
(
x
):
if
x
<
0
:
return
-
1
else
:
return
1
def
get_train_data
(
traj
,
data_folder
,
train_pos_indices
):
sys
=
Trajectory
(
traj
)
ind_slab
=
sys
[
0
].
constraints
[
1
].
index
ind_free
=
np
.
delete
(
np
.
arange
(
len
(
sys
[
0
])),
ind_slab
)
species
=
[]
elem
=
sys
[
0
].
get_chemical_symbols
()
#identification des espèces
for
el
in
range
(
len
(
elem
)):
if
elem
[
el
]
not
in
species
:
species
.
append
(
elem
[
el
])
y_ini
=
np
.
load
(
data_folder
+
'
/E.npy
'
)
index_pos
=
np
.
load
(
data_folder
+
'
/ind_pos.npy
'
)
ind_train
=
[]
#select only 3 config per position
for
i
in
range
(
len
(
index_pos
)):
if
i
in
train_pos_indices
:
ind_train
.
append
(
index_pos
[
i
,
0
])
ind_train
.
append
((
index_pos
[
i
,
1
]
-
index_pos
[
i
,
0
]
+
1
)
//
2
)
ind_train
.
append
(
index_pos
[
i
,
1
])
y_train
=
np
.
array
([
y_ini
[
i
]
for
i
in
ind_train
])
return
[
sys
[
i
]
for
i
in
ind_train
],
y_train
,
species
def
pos_to_relax
(
poscar_file
,
n
=
20
):
poscar
=
ase
.
io
.
read
(
poscar_file
)
#position à relaxer
a
=
poscar
.
get_cell
()[
0
,
0
]
b
=
poscar
.
get_cell
()[
1
,
1
]
c
=
poscar
.
get_cell
()[
2
,
2
]
#maillage
n
=
20
Xpos
=
[
i
*
a
/
n
for
i
in
range
(
n
)]
Ypos
=
[
i
*
b
/
n
for
i
in
range
(
n
)]
xx
,
yy
=
np
.
meshgrid
(
Xpos
,
Ypos
)
xx
,
yy
=
np
.
ravel
(
xx
),
np
.
ravel
(
yy
)
zz
=
np
.
empty
(
len
(
xx
))
#zpos
atom_top
=
poscar
.
get_positions
()
for
i
in
range
(
len
(
xx
)):
dx
=
atom_top
[:,
0
]
-
xx
[
i
]
dy
=
atom_top
[:,
1
]
-
yy
[
i
]
dz
=
atom_top
[:,
2
]
-
18
dxy
=
np
.
linalg
.
norm
([
dx
,
dy
,
dz
],
axis
=
0
)
indice
=
np
.
where
(
dxy
==
np
.
min
(
dxy
))[
0
][
0
]
zz
[
i
]
=
atom_top
[
indice
,
2
]
+
1.6
return
xx
,
yy
,
zz
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment