HyQD / coupled-cluster

Upstream coupled cluster code
MIT License
3 stars 3 forks source link

Sign of error vector in DIIS mixing #6

Closed Schoyen closed 5 years ago

Schoyen commented 5 years ago

When passing in the the error_vector to the function compute_new_vector in the class DIIS, we have to make sure the sign is correct. For the amplitudes we presume that error_vector should have the opposite sign of direction_vector, when the latter is the right hand sides divided by the d-tensor. That is, for instance the following code from the CoupledClusterDoubles-class

    def compute_l_amplitudes(self):
        # ...
        trial_vector = self.l_2
        direction_vector = np.divide(self.rhs_l_2, self.d_l_2)
        error_vector = self.rhs_l_2

        self.l_2 = self.l_2_mixer.compute_new_vector(
            trial_vector, direction_vector, error_vector
        )

should be corrected to

    def compute_l_amplitudes(self):
        # ...
        trial_vector = self.l_2
        direction_vector = np.divide(self.rhs_l_2, self.d_l_2)
        error_vector = -self.rhs_l_2 # Opposite sign from the former snippet

        self.l_2 = self.l_2_mixer.compute_new_vector(
            trial_vector, direction_vector, error_vector
        )

However, this should be checked properly.