def begin_iterations(self, orbital_coefficients): orbital_energies = [] total_energy = previous_total_energy = 0 while True: density_matrix = density_matrix_restricted(orbital_coefficients, self.electrons) fock_matrix = self.hamiltonian_matrix_factory.create(density_matrix) total_energy = self.calculate.restricted(density_matrix, fock_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 fock_matrix = self.diis.fock_matrix(fock_matrix, density_matrix) orbital_energies, orbital_coefficients = self.linear_algebra.diagonalize(fock_matrix) return total_energy, orbital_energies, orbital_coefficients
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)
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)