Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
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
Michele Nottoli
gext
Commits
c76c9b8c
Commit
c76c9b8c
authored
1 year ago
by
Michele Nottoli
Browse files
Options
Downloads
Patches
Plain Diff
Switched to descriptors.
parent
f5c831c7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
grext/buffer.py
+1
-1
1 addition, 1 deletion
grext/buffer.py
grext/descriptors.py
+12
-0
12 additions, 0 deletions
grext/descriptors.py
grext/main.py
+10
-3
10 additions, 3 deletions
grext/main.py
with
23 additions
and
4 deletions
grext/buffer.py
+
1
−
1
View file @
c76c9b8c
...
...
@@ -8,7 +8,7 @@ class CircularBuffer:
"""
Circular buffer to store the last `n` matrices.
"""
def
__init__
(
self
,
n
:
int
,
shape
:
Tuple
[
int
,
int
]):
def
__init__
(
self
,
n
:
int
,
shape
:
Tuple
[
int
,
...
]):
self
.
n
=
n
self
.
shape
=
shape
self
.
buffer
=
[
np
.
zeros
(
shape
,
dtype
=
np
.
float64
)
for
_
in
range
(
n
)]
...
...
This diff is collapsed.
Click to expand it.
grext/descriptors.py
0 → 100644
+
12
−
0
View file @
c76c9b8c
"""
Module which provides functions to compute descriptors.
"""
import
numpy
as
np
from
scipy.spatial.distance
import
pdist
def
distance
(
coords
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Compute the distance matric as a descriptor.
"""
return
pdist
(
coords
,
metric
=
"
euclidean
"
)
def
coulomb
(
coords
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Compute the Coulomb matrix as a descriptor.
"""
return
1.0
/
distance
(
coords
)
This diff is collapsed.
Click to expand it.
grext/main.py
+
10
−
3
View file @
c76c9b8c
...
...
@@ -5,6 +5,7 @@ import numpy as np
from
.
import
grassmann
from
.
import
fitting
from
.
import
descriptors
from
.buffer
import
CircularBuffer
class
Extrapolator
:
...
...
@@ -25,7 +26,8 @@ class Extrapolator:
self
.
gammas
=
CircularBuffer
(
self
.
nsteps
,
(
self
.
nelectrons
,
self
.
nbasis
))
self
.
overlaps
=
CircularBuffer
(
self
.
nsteps
,
(
self
.
nbasis
,
self
.
nbasis
))
self
.
coords
=
CircularBuffer
(
self
.
nsteps
,
(
self
.
natoms
,
3
))
self
.
descriptors
=
CircularBuffer
(
self
.
nsteps
,
((
self
.
natoms
-
1
)
*
self
.
natoms
//
2
,
))
self
.
tangent
:
Optional
[
np
.
ndarray
]
=
None
...
...
@@ -39,11 +41,12 @@ class Extrapolator:
self
.
_set_tangent
(
coeff
)
self
.
gammas
.
push
(
self
.
_grassmann_log
(
coeff
))
self
.
co
or
d
s
.
push
(
coords
)
self
.
descript
ors
.
push
(
self
.
_compute_descriptor
(
coords
)
)
self
.
overlaps
.
push
(
overlap
)
def
guess
(
self
,
coords
:
np
.
ndarray
,
overlap
:
Optional
[
np
.
ndarray
]):
"""
Get a new electronic density to be used as a guess.
"""
descriptor
=
self
.
_compute_descriptor
(
coords
)
coefficients
=
fitting
.
linear
()
def
_get_tangent
(
self
)
->
np
.
ndarray
:
...
...
@@ -77,7 +80,11 @@ class Extrapolator:
tangent
=
self
.
_get_tangent
()
return
grassmann
.
exp
(
gamma
,
tangent
)
def
_sqrt_overlap
(
self
,
overlap
):
def
_sqrt_overlap
(
self
,
overlap
)
->
np
.
ndarray
:
"""
Compute the square root of the overlap matrix.
"""
q
,
s
,
vt
=
np
.
linalg
.
svd
(
overlap
,
full_matrices
=
False
)
return
q
@
np
.
diag
(
np
.
sqrt
(
s
))
@
vt
def
_compute_descriptor
(
self
,
coords
)
->
np
.
ndarray
:
"""
Given a set of coordinates compute the corresponding descriptor.
"""
return
descriptors
.
distance
(
coords
)
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