Beispiel #1
0
    def begin_iterations(self, orbital_energies, orbital_coefficients):
        previous_total_energy = 0

        while True:

            density_matrix = density_matrix_restricted(orbital_coefficients,
                                                       self.electrons)
            core_matrix, elst_matrix, xc_matrix \
                = self.hamiltonian_matrix_factory.create(density_matrix)
            ks_matrix = core_matrix + elst_matrix + xc_matrix
            total_energy = self.calculate.restricted(orbital_energies,
                                                     density_matrix,
                                                     elst_matrix, xc_matrix)
            delta_energy = previous_total_energy - total_energy
            previous_total_energy = total_energy
            print('SCF ENERGY: ' + str(total_energy) + ' a.u.')

            if abs(delta_energy) < self.threshold:
                break

            ks_matrix = self.diis.fock_matrix(ks_matrix, density_matrix)
            orbital_energies, orbital_coefficients \
                = self.linear_algebra.diagonalize(ks_matrix)

        return total_energy, orbital_energies, orbital_coefficients
Beispiel #2
0
 def test_method_calculate_returns_density_matrix_element_for_1_1(self):
     element = density_matrix_restricted(self.orbital_coefficients,
                                         2).item(1, 1)
     testing.assert_approx_equal(element, 0.0391, 3)
Beispiel #3
0
 def test_method_calculate_returns_density_matrix_element_for_0_0(self):
     element = density_matrix_restricted(self.orbital_coefficients,
                                         2).item(0, 0)
     testing.assert_approx_equal(element, 1.7266, 4)