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
1673bbe1
Commit
1673bbe1
authored
1 year ago
by
BOULANGEOT Nathan
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
6761f6f9
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/position_selection.py
+86
-0
86 additions, 0 deletions
codes/position_selection.py
with
86 additions
and
0 deletions
codes/position_selection.py
0 → 100644
+
86
−
0
View file @
1673bbe1
import
os
import
numpy
as
np
from
sklearn.metrics
import
pairwise_kernels
from
ase.io
import
Trajectory
from
scipy.spatial
import
distance_matrix
from
sklearn.preprocessing
import
StandardScaler
from
create_descriptor
import
*
def
matrice_farthest_search
(
points
,
k
,
mode
=
'
euclidian
'
,
gamma
=
1e-5
,
n
=
3
):
if
mode
is
'
euclidian
'
:
def
distance_m
(
a
):
return
distance_matrix
(
a
,
a
)
if
mode
is
'
rbf
'
:
def
distance_m
(
a
):
DM
=
pairwise_kernels
(
a
,
a
,
metric
=
'
rbf
'
,
gamma
=
gamma
)
return
1
-
DM
DM
=
distance_m
(
points
)
remaining_points
=
list
(
points
)
solution_set
=
[]
indices
=
[]
indices_cluster
=
[]
indiceleft
=
list
(
range
(
len
(
remaining_points
)))
#init=indiceleft.pop(random.randint(0, len(indiceleft) - 1))
init
=
indiceleft
.
pop
(
np
.
argmin
(
np
.
mean
(
DM
,
axis
=
0
)))
indices
.
append
(
init
)
for
_
in
range
(
k
-
1
):
a
=
[
min
([
DM
[
p
][
pl
]
for
p
in
indices
])
for
pl
in
indiceleft
]
ind_rem
=
a
.
index
(
max
(
a
))
rem
=
indiceleft
.
pop
(
ind_rem
)
indices
.
append
(
rem
)
solution_set
.
append
(
max
(
a
))
solution_set
=
np
.
array
(
solution_set
)
return
solution_set
,
indices
if
__name__
==
'
__main__
'
:
#debut de l initialisation
path
=
os
.
getcwd
()
atomseul
=
'
H
'
#atome depose
traj
=
'
final.traj
'
#bdd 1
data_folder
=
'
data
'
gamma
=
1e-5
sys
=
Trajectory
(
traj
)
species
=
[]
elem
=
sys
[
0
].
get_chemical_symbols
()
#identification de l atome seul dans la structure
for
el
in
range
(
len
(
elem
)):
if
elem
[
el
]
not
in
species
:
species
.
append
(
elem
[
el
])
if
elem
[
el
]
==
atomseul
:
ats
=
el
# bases entieres
params
=
{
'
species
'
:
species
,
'
l_max
'
:
2
,
'
n_max
'
:
2
,
'
r_cut
'
:
7
}
desc
=
create_descriptor
(
method
=
'
soap
'
,
params
=
params
,
ats
=
ats
)
X_ini
=
desc
.
create
(
traj
,
load
=
True
,
save_file
=
data_folder
)
# bases poscars
index_pos_100
=
np
.
load
(
data_folder
+
'
/ind_pos.npy
'
)
X_poscar
=
[
X_ini
[
i
[
0
]]
for
i
in
index_pos_100
]
len100
=
len
(
X_poscar
)
print
(
len100
)
#scaling
scaler
=
StandardScaler
()
scaler
.
fit
(
X_poscar
)
X_poscar_T
=
scaler
.
transform
(
X_poscar
)
ncomp
=
144
#initialisation
distances
,
indices
=
matrice_farthest_search
(
X_poscar_T
,
ncomp
,)
np
.
save
(
"
distances.npy
"
,
distances
)
for
i
in
range
(
1
,
145
):
if
i
in
[
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
,
100
,]:
#resultpath
resultpath
=
path
+
'
/
'
+
str
(
i
)
try
:
os
.
mkdir
(
resultpath
)
except
:
pass
#save
print
(
len
(
indices
[:
i
]))
np
.
save
(
resultpath
+
'
/indices.npy
'
,
indices
[:
i
])
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