Skip to content
Snippets Groups Projects
Commit 8f37f70b authored by Askarpour, Zahra's avatar Askarpour, Zahra
Browse files

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
"""Main module containing the Extrapolator class."""
"""module containing the Extrapolator class."""
from typing import Optional
import numpy as np
......@@ -21,6 +21,7 @@ class Extrapolator:
"fitting": "diff",
"allow_partially_filled": True,
"store_overlap": True,
"tangent": "first",
}
def __init__(self, nelectrons: int, nbasis: int, natoms: int, **kwargs):
......@@ -41,7 +42,9 @@ class Extrapolator:
if self.options["store_overlap"]:
self.overlaps = CircularBuffer(self.options["nsteps"],
(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
def set_options(self, **kwargs):
......@@ -101,12 +104,17 @@ class Extrapolator:
coeff = self._normalize(coeff, overlap)
# 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)
# push the new data to the corresponding vectors
self.gammas.push(self._grassmann_log(coeff))
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"]:
self.overlaps.push(overlap)
......@@ -141,7 +149,19 @@ class Extrapolator:
# use the fitting coefficients and the previous gammas to
# extrapolate a new gamma
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)
if self.options["verbose"]:
......@@ -179,6 +199,9 @@ class Extrapolator:
def _set_tangent(self, c: np.ndarray):
"""Set the tangent point."""
if self.options["tangent"]="one_before_last"
self.tangent = c
else:
if self.tangent is None:
self.tangent = c
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment