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
8f37f70b
Commit
8f37f70b
authored
1 year ago
by
Askarpour, Zahra
Browse files
Options
Downloads
Patches
Plain Diff
tangent point is one point before the last one
parent
8ef9b9b0
No related branches found
No related tags found
No related merge requests found
Pipeline
#2062
failed
1 year ago
Stage: test
Stage: lint
Stage: coverage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gext/main.py
+31
-8
31 additions, 8 deletions
gext/main.py
with
31 additions
and
8 deletions
gext/main.py
+
31
−
8
View file @
8f37f70b
"""
Main
module containing the Extrapolator class.
"""
"""
module containing the Extrapolator class.
"""
from
typing
import
Optional
from
typing
import
Optional
import
numpy
as
np
import
numpy
as
np
...
@@ -21,6 +21,7 @@ class Extrapolator:
...
@@ -21,6 +21,7 @@ class Extrapolator:
"
fitting
"
:
"
diff
"
,
"
fitting
"
:
"
diff
"
,
"
allow_partially_filled
"
:
True
,
"
allow_partially_filled
"
:
True
,
"
store_overlap
"
:
True
,
"
store_overlap
"
:
True
,
"
tangent
"
:
"
first
"
,
}
}
def
__init__
(
self
,
nelectrons
:
int
,
nbasis
:
int
,
natoms
:
int
,
**
kwargs
):
def
__init__
(
self
,
nelectrons
:
int
,
nbasis
:
int
,
natoms
:
int
,
**
kwargs
):
...
@@ -41,7 +42,9 @@ class Extrapolator:
...
@@ -41,7 +42,9 @@ class Extrapolator:
if
self
.
options
[
"
store_overlap
"
]:
if
self
.
options
[
"
store_overlap
"
]:
self
.
overlaps
=
CircularBuffer
(
self
.
options
[
"
nsteps
"
],
self
.
overlaps
=
CircularBuffer
(
self
.
options
[
"
nsteps
"
],
(
self
.
nbasis
,
self
.
nbasis
))
(
self
.
nbasis
,
self
.
nbasis
))
if
self
.
options
[
"
tangent
"
]
==
"
one_before_last
"
:
self
.
coeffs
=
CircularBuffer
(
self
.
options
[
"
nsteps
"
],
(
self
.
nelectrons
//
2
,
self
.
nbasis
))
self
.
tangent
:
Optional
[
np
.
ndarray
]
=
None
self
.
tangent
:
Optional
[
np
.
ndarray
]
=
None
def
set_options
(
self
,
**
kwargs
):
def
set_options
(
self
,
**
kwargs
):
...
@@ -101,12 +104,17 @@ class Extrapolator:
...
@@ -101,12 +104,17 @@ class Extrapolator:
coeff
=
self
.
_normalize
(
coeff
,
overlap
)
coeff
=
self
.
_normalize
(
coeff
,
overlap
)
# if it is the first time we load data, set the tangent point
# if it is the first time we load data, set the tangent point
if
self
.
tangent
is
None
:
if
self
.
tangent
is
None
and
self
.
options
[
"
tangent
"
]
is
not
"
one_before_last
"
:
self
.
_set_tangent
(
coeff
)
self
.
_set_tangent
(
coeff
)
# push the new data to the corresponding vectors
# push the new data to the corresponding vectors
self
.
gammas
.
push
(
self
.
_grassmann_log
(
coeff
))
self
.
descriptors
.
push
(
self
.
_compute_descriptor
(
coords
))
self
.
descriptors
.
push
(
self
.
_compute_descriptor
(
coords
))
if
self
.
options
[
"
tangent
"
]
==
"
one_before_last
"
:
cropped_coeff
=
self
.
_crop_coeff
(
coeff
)
self
.
coeffs
.
push
(
cropped_coeff
)
else
:
self
.
gammas
.
push
(
self
.
_grassmann_log
(
coeff
))
if
self
.
options
[
"
store_overlap
"
]:
if
self
.
options
[
"
store_overlap
"
]:
self
.
overlaps
.
push
(
overlap
)
self
.
overlaps
.
push
(
overlap
)
...
@@ -141,9 +149,21 @@ class Extrapolator:
...
@@ -141,9 +149,21 @@ class Extrapolator:
# use the fitting coefficients and the previous gammas to
# use the fitting coefficients and the previous gammas to
# extrapolate a new gamma
# extrapolate a new gamma
gammas
=
self
.
gammas
.
get
(
n
)
if
self
.
options
[
"
tangent
"
]
==
"
one_before_last
"
:
coeffs
=
self
.
coeffs
.
get
(
n
)
self
.
_set_tangent
(
coeffs
[
-
1
])
gammas
=
[]
for
i
in
range
(
len
(
coeffs
)):
gammas
.
append
(
self
.
_grassmann_log
(
coeffs
[
i
]))
print
(
'
maxgamma_last
'
,
np
.
max
(
gammas
[
-
1
]))
else
:
gammas
=
self
.
gammas
.
get
(
n
)
print
(
'
maxgamm
'
,
np
.
max
(
gammas
[
0
]))
gamma
=
self
.
fitting_calculator
.
linear_combination
(
gammas
,
fit_coefficients
)
gamma
=
self
.
fitting_calculator
.
linear_combination
(
gammas
,
fit_coefficients
)
if
self
.
options
[
"
verbose
"
]:
if
self
.
options
[
"
verbose
"
]:
fit_descriptor
=
self
.
fitting_calculator
.
linear_combination
(
fit_descriptor
=
self
.
fitting_calculator
.
linear_combination
(
prev_descriptors
,
fit_coefficients
)
prev_descriptors
,
fit_coefficients
)
...
@@ -179,10 +199,13 @@ class Extrapolator:
...
@@ -179,10 +199,13 @@ class Extrapolator:
def
_set_tangent
(
self
,
c
:
np
.
ndarray
):
def
_set_tangent
(
self
,
c
:
np
.
ndarray
):
"""
Set the tangent point.
"""
"""
Set the tangent point.
"""
if
self
.
tangent
is
None
:
if
self
.
options
[
"
tangent
"
]
=
"
one_before_last
"
self
.
tangent
=
c
self
.
tangent
=
c
else
:
else
:
raise
ValueError
(
"
Resetting the tangent.
"
)
if
self
.
tangent
is
None
:
self
.
tangent
=
c
else
:
raise
ValueError
(
"
Resetting the tangent.
"
)
def
_grassmann_log
(
self
,
coeff
:
np
.
ndarray
)
->
np
.
ndarray
:
def
_grassmann_log
(
self
,
coeff
:
np
.
ndarray
)
->
np
.
ndarray
:
"""
Map from the manifold to the tangent plane.
"""
"""
Map from the manifold to the tangent plane.
"""
...
...
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