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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michele Nottoli
gext
Commits
2ae7f6e6
Commit
2ae7f6e6
authored
Mar 4, 2024
by
Michele Nottoli
Browse files
Options
Downloads
Patches
Plain Diff
Fixed normal tangent case.
parent
63489817
No related branches found
No related tags found
No related merge requests found
Pipeline
#2066
passed
Mar 4, 2024
Stage: test
Stage: lint
Stage: coverage
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
gext/main.py
+10
-7
10 additions, 7 deletions
gext/main.py
tests/test_grassmann.py
+2
-1
2 additions, 1 deletion
tests/test_grassmann.py
with
12 additions
and
8 deletions
gext/main.py
+
10
−
7
View file @
2ae7f6e6
...
@@ -102,13 +102,16 @@ class Extrapolator:
...
@@ -102,13 +102,16 @@ class Extrapolator:
# pairs, then apply S^1/2
# pairs, then apply S^1/2
coeff
=
self
.
_crop_coeff
(
coeff
)
coeff
=
self
.
_crop_coeff
(
coeff
)
coeff
=
self
.
_normalize
(
coeff
,
overlap
)
coeff
=
self
.
_normalize
(
coeff
,
overlap
)
# if it is the first time we load data, set the tangent point
if
self
.
tangent
is
None
and
self
.
options
[
"
tangent
"
]
!=
"
one_before_last
"
:
self
.
_set_tangent
(
coeff
)
if
self
.
options
[
"
tangent
"
]
==
"
one_before_last
"
:
if
self
.
options
[
"
tangent
"
]
==
"
one_before_last
"
:
self
.
coeffs
.
push
(
coeff
)
self
.
coeffs
.
push
(
coeff
)
else
:
else
:
self
.
gammas
.
push
(
self
.
_grassmann_log
(
coeff
))
self
.
gammas
.
push
(
self
.
_grassmann_log
(
coeff
))
# if it is the first time we load data, set the tangent point
if
self
.
tangent
is
None
and
self
.
options
[
"
tangent
"
]
is
not
"
one_before_last
"
:
self
.
_set_tangent
(
coeff
)
# push the new data to the corresponding vectors
# push the new data to the corresponding vectors
self
.
descriptors
.
push
(
self
.
_compute_descriptor
(
descriptor_input
))
self
.
descriptors
.
push
(
self
.
_compute_descriptor
(
descriptor_input
))
...
@@ -140,7 +143,7 @@ class Extrapolator:
...
@@ -140,7 +143,7 @@ class Extrapolator:
# use the descriptors to find the fitting coefficients
# use the descriptors to find the fitting coefficients
prev_descriptors
=
self
.
descriptors
.
get
(
n
)
prev_descriptors
=
self
.
descriptors
.
get
(
n
)
descriptor
=
self
.
_compute_descriptor
(
coords
)
descriptor
=
self
.
_compute_descriptor
(
descriptor_input
)
fit_coefficients
=
self
.
_fit
(
prev_descriptors
,
descriptor
)
fit_coefficients
=
self
.
_fit
(
prev_descriptors
,
descriptor
)
print
(
fit_coefficients
)
print
(
fit_coefficients
)
...
@@ -224,9 +227,9 @@ class Extrapolator:
...
@@ -224,9 +227,9 @@ class Extrapolator:
q
,
s
,
vt
=
np
.
linalg
.
svd
(
overlap
,
full_matrices
=
False
)
q
,
s
,
vt
=
np
.
linalg
.
svd
(
overlap
,
full_matrices
=
False
)
return
q
@
np
.
diag
(
1.0
/
np
.
sqrt
(
s
))
@
vt
return
q
@
np
.
diag
(
1.0
/
np
.
sqrt
(
s
))
@
vt
def
_compute_descriptor
(
self
,
coords
)
->
np
.
ndarray
:
def
_compute_descriptor
(
self
,
descriptor_input
)
->
np
.
ndarray
:
"""
Given a
set of coordinates
compute the corresponding descriptor.
"""
"""
Given a
n input
compute the corresponding descriptor.
"""
return
self
.
descriptor_calculator
.
compute
(
coords
)
return
self
.
descriptor_calculator
.
compute
(
descriptor_input
)
def
_fit
(
self
,
prev_descriptors
,
descriptor
)
->
np
.
ndarray
:
def
_fit
(
self
,
prev_descriptors
,
descriptor
)
->
np
.
ndarray
:
"""
Fit the current descriptor using previous descriptors and
"""
Fit the current descriptor using previous descriptors and
...
...
This diff is collapsed.
Click to expand it.
tests/test_grassmann.py
+
2
−
1
View file @
2ae7f6e6
...
@@ -21,7 +21,8 @@ def test_grassmann(datafile):
...
@@ -21,7 +21,8 @@ def test_grassmann(datafile):
nframes
=
data
[
"
trajectory
"
].
shape
[
0
]
nframes
=
data
[
"
trajectory
"
].
shape
[
0
]
# initialize an extrapolator
# initialize an extrapolator
extrapolator
=
gext
.
Extrapolator
(
nelectrons
,
nbasis
,
natoms
,
nsteps
=
nframes
)
extrapolator
=
gext
.
Extrapolator
(
nelectrons
,
nbasis
,
natoms
,
nsteps
=
nframes
,
tangent
=
"
one
"
)
# load data in the extrapolator
# load data in the extrapolator
for
(
coords
,
coeff
,
overlap
)
in
zip
(
data
[
"
trajectory
"
],
for
(
coords
,
coeff
,
overlap
)
in
zip
(
data
[
"
trajectory
"
],
...
...
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