Commit 548b5690 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

merge Reimar's changes

parents 9327b752 ffc6059b
Pipeline #61317 passed with stages
in 8 minutes and 26 seconds
...@@ -166,7 +166,8 @@ class NewtonCG(DescentMinimizer): ...@@ -166,7 +166,8 @@ class NewtonCG(DescentMinimizer):
""" """
def __init__(self, controller, napprox=0, line_searcher=None, name=None, def __init__(self, controller, napprox=0, line_searcher=None, name=None,
nreset=20, file_name=None): nreset=20, max_cg_iterations=200, energy_reduction_factor=0.1,
file_name=None):
if line_searcher is None: if line_searcher is None:
line_searcher = LineSearch(preferred_initial_step_size=1.) line_searcher = LineSearch(preferred_initial_step_size=1.)
super(NewtonCG, self).__init__(controller=controller, super(NewtonCG, self).__init__(controller=controller,
...@@ -175,15 +176,16 @@ class NewtonCG(DescentMinimizer): ...@@ -175,15 +176,16 @@ class NewtonCG(DescentMinimizer):
self._name = name self._name = name
self._nreset = nreset self._nreset = nreset
self._file_name = file_name self._file_name = file_name
self._max_cg_iterations = max_cg_iterations
self._alpha = energy_reduction_factor
def get_descent_direction(self, energy, old_value=None): def get_descent_direction(self, energy, old_value=None):
if old_value is None: if old_value is None:
ic = GradientNormController(iteration_limit=5) ic = GradientNormController(iteration_limit=5)
else: else:
alpha = 0.1 ediff = self._alpha*(old_value-energy.value)
ediff = alpha*(old_value-energy.value)
ic = AbsDeltaEnergyController( ic = AbsDeltaEnergyController(
ediff, iteration_limit=200, name=self._name, ediff, iteration_limit=self._max_cg_iterations, name=self._name,
file_name=self._file_name) file_name=self._file_name)
e = QuadraticEnergy(0*energy.position, energy.metric, energy.gradient) e = QuadraticEnergy(0*energy.position, energy.metric, energy.gradient)
p = None p = None
......
...@@ -138,7 +138,6 @@ def probe_diagonal(op, nprobes, random_type="pm1"): ...@@ -138,7 +138,6 @@ def probe_diagonal(op, nprobes, random_type="pm1"):
def approximation2endo(op, nsamples): def approximation2endo(op, nsamples):
print('Calculate preconditioner')
sc = StatCalculator() sc = StatCalculator()
for _ in range(nsamples): for _ in range(nsamples):
sc.add(op.draw_sample()) sc.add(op.draw_sample())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment