class TestKineticEnergyMatrixHeHCation(TestCase): def setUp(self): hydrogen_basis_1 = MagicMock(contraction=0.15432897, exponent=3.42525091, coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0), normalisation = 1.794441832218435) hydrogen_basis_2 = MagicMock(contraction=0.53532814, exponent=0.62391373, coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0), normalisation = 0.5003264923314032) hydrogen_basis_3 = MagicMock(contraction=0.44463454, exponent=0.16885540, coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0), normalisation = 0.18773545851092535) helium_basis_1 = MagicMock(contraction=0.15432897, exponent=9.75393461, coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0), normalisation = 3.9336432656254527) helium_basis_2 = MagicMock(contraction=0.53532814, exponent=1.77669115, coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0), normalisation = 1.0967787981767012) helium_basis_3 = MagicMock(contraction=0.44463454, exponent=0.48084429, coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0), normalisation = 0.41154131374122654) helium = MagicMock(primitive_gaussian_array=[helium_basis_1, helium_basis_2, helium_basis_3], coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0)) hydrogen = MagicMock(primitive_gaussian_array=[hydrogen_basis_1, hydrogen_basis_2, hydrogen_basis_3], coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0)) basis_set_array = [helium, hydrogen] self.kinetic_energy_integral = KineticEnergyMatrix(basis_set_array) def test_method_calculate_returns_the_kinetic_energy_of_helium_1s(self): kinetic_energy = self.kinetic_energy_integral.calculate(0, 0) testing.assert_approx_equal(kinetic_energy, 2.1643, 5) def test_method_calculate_returns_the_kinetic_energy_of_quantum_mechanical_off_diagonal_parts(self): kinetic_energy = self.kinetic_energy_integral.calculate(0, 1) testing.assert_approx_equal(kinetic_energy, 0.167, 3) def test_method_calculate_returns_the_kinetic_energy_of_hydrogen_1s(self): kinetic_energy = self.kinetic_energy_integral.calculate(1, 1) testing.assert_approx_equal(kinetic_energy, 0.7600, 4)
def setUp(self): hydrogen_basis_1 = MagicMock(contraction=0.15432897, exponent=3.42525091, coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0), normalisation = 1.794441832218435) hydrogen_basis_2 = MagicMock(contraction=0.53532814, exponent=0.62391373, coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0), normalisation = 0.5003264923314032) hydrogen_basis_3 = MagicMock(contraction=0.44463454, exponent=0.16885540, coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0), normalisation = 0.18773545851092535) helium_basis_1 = MagicMock(contraction=0.15432897, exponent=9.75393461, coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0), normalisation = 3.9336432656254527) helium_basis_2 = MagicMock(contraction=0.53532814, exponent=1.77669115, coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0), normalisation = 1.0967787981767012) helium_basis_3 = MagicMock(contraction=0.44463454, exponent=0.48084429, coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0), normalisation = 0.41154131374122654) helium = MagicMock(primitive_gaussian_array=[helium_basis_1, helium_basis_2, helium_basis_3], coordinates=(0, 0, -0.7316), integral_exponents=(0, 0, 0)) hydrogen = MagicMock(primitive_gaussian_array=[hydrogen_basis_1, hydrogen_basis_2, hydrogen_basis_3], coordinates=(0, 0, 0.7316), integral_exponents=(0, 0, 0)) basis_set_array = [helium, hydrogen] self.kinetic_energy_integral = KineticEnergyMatrix(basis_set_array)
def setUp(self): hydrogen_basis_1 = MagicMock(contraction=0.15432897, exponent=3.42525091, coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0), normalisation = 1.794441832218435) hydrogen_basis_2 = MagicMock(contraction=0.53532814, exponent=0.62391373, coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0), normalisation = 0.5003264923314032) hydrogen_basis_3 = MagicMock(contraction=0.44463454, exponent=0.16885540, coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0), normalisation = 0.18773545851092535) hydrogen_basis_4 = MagicMock(contraction=0.15432897, exponent=3.42525091, coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0), normalisation = 1.794441832218435) hydrogen_basis_5 = MagicMock(contraction=0.53532814, exponent=0.62391373, coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0), normalisation = 0.5003264923314032) hydrogen_basis_6 = MagicMock(contraction=0.44463454, exponent=0.16885540, coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0), normalisation = 0.18773545851092535) hydrogen_1 = MagicMock(primitive_gaussian_array=[hydrogen_basis_1, hydrogen_basis_2, hydrogen_basis_3], coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0)) hydrogen_2 = MagicMock(primitive_gaussian_array=[hydrogen_basis_4, hydrogen_basis_5, hydrogen_basis_6], coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0)) basis_set_array = [hydrogen_1, hydrogen_2] self.kinetic_energy_integral = KineticEnergyMatrix(basis_set_array)
class TestKineticEnergyMatrixHydrogen(TestCase): def setUp(self): hydrogen_basis_1 = MagicMock(contraction=0.15432897, exponent=3.42525091, coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0), normalisation = 1.794441832218435) hydrogen_basis_2 = MagicMock(contraction=0.53532814, exponent=0.62391373, coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0), normalisation = 0.5003264923314032) hydrogen_basis_3 = MagicMock(contraction=0.44463454, exponent=0.16885540, coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0), normalisation = 0.18773545851092535) hydrogen_basis_4 = MagicMock(contraction=0.15432897, exponent=3.42525091, coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0), normalisation = 1.794441832218435) hydrogen_basis_5 = MagicMock(contraction=0.53532814, exponent=0.62391373, coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0), normalisation = 0.5003264923314032) hydrogen_basis_6 = MagicMock(contraction=0.44463454, exponent=0.16885540, coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0), normalisation = 0.18773545851092535) hydrogen_1 = MagicMock(primitive_gaussian_array=[hydrogen_basis_1, hydrogen_basis_2, hydrogen_basis_3], coordinates=(0, 0, -0.7000), integral_exponents=(0, 0, 0)) hydrogen_2 = MagicMock(primitive_gaussian_array=[hydrogen_basis_4, hydrogen_basis_5, hydrogen_basis_6], coordinates=(0, 0, 0.7000), integral_exponents=(0, 0, 0)) basis_set_array = [hydrogen_1, hydrogen_2] self.kinetic_energy_integral = KineticEnergyMatrix(basis_set_array) def test_method_calculate_returns_the_kinetic_energy_of_hydrogen_1s(self): kinetic_energy = self.kinetic_energy_integral.calculate(0, 0) testing.assert_approx_equal(kinetic_energy, 0.7600, 4) def test_method_calculate_returns_the_kinetic_energy_of_quantum_mechanical_off_diagonal_parts(self): kinetic_energy = self.kinetic_energy_integral.calculate(0, 1) testing.assert_approx_equal(kinetic_energy, 0.2365, 4)
class HartreeFock: def __init__(self, nuclei_array, basis_set_array, electrons, scf_method): self.nuclei_array = nuclei_array self.basis_set_array = basis_set_array self.electrons = electrons self.scf_method = scf_method self.orbital_overlap_matrix = OrbitalOverlapMatrix(basis_set_array) self.kinetic_energy_matrix = KineticEnergyMatrix(basis_set_array) self.nuclear_attraction_matrix = NuclearAttractionMatrix(basis_set_array, nuclei_array) # self.repulsion_elements = TwoElectronRepulsionElementCook(basis_set_array) self.repulsion_elements = TwoElectronRepulsionElementOS(basis_set_array) # self.repulsion_elements = TwoElectronRepulsionElementHGP(basis_set_array) self.linear_algebra = LinearAlgebra self.core_hamiltonian = np.matrix([]) self.repulsion = np.matrix([]) def start(self): print('\n*****************************************************************************************************') orbital_overlap = self.orbital_overlap_matrix.create() kinetic_energy = self.kinetic_energy_matrix.create() nuclear_potential = self.nuclear_attraction_matrix.create() self.linear_algebra = self.linear_algebra(orbital_overlap) self.core_hamiltonian = kinetic_energy + nuclear_potential print('\nMATRICES\n') print('\nORBITAL OVERLAP MATRIX') print(orbital_overlap) print('\nKINETIC ENERGY MATRIX') print(kinetic_energy) print('\nNUCLEAR POTENTIAL ENERGY MATRIX') print(nuclear_potential) print('\nCORE HAMILTONIAN MATRIX') print(self.core_hamiltonian) print('\n*****************************************************************************************************') print('\nINITIAL GUESS\n') initial_orbital_energies, initial_orbital_coefficients = self.linear_algebra.diagonalize(self.core_hamiltonian) print('\nORBITAL ENERGY EIGENVALUES') print(initial_orbital_energies) print('\nORBITAL COEFFICIENTS') print(initial_orbital_coefficients) print('\n*****************************************************************************************************') print('\nBEGIN TWO ELECTRON REPULSION CALCULATION') start_repulsion = time.clock() self.repulsion = self.repulsion_elements.store_parallel(4) print('TIME TAKEN: ' + str(time.clock() - start_repulsion) + 's\n') return initial_orbital_coefficients
def __init__(self, nuclei_array, basis_set_array, electrons, scf_method): self.nuclei_array = nuclei_array self.basis_set_array = basis_set_array self.electrons = electrons self.scf_method = scf_method self.orbital_overlap_matrix = OrbitalOverlapMatrix(basis_set_array) self.kinetic_energy_matrix = KineticEnergyMatrix(basis_set_array) self.nuclear_attraction_matrix = NuclearAttractionMatrix(basis_set_array, nuclei_array) # self.repulsion_elements = TwoElectronRepulsionElementCook(basis_set_array) self.repulsion_elements = TwoElectronRepulsionElementOS(basis_set_array) # self.repulsion_elements = TwoElectronRepulsionElementHGP(basis_set_array) self.linear_algebra = LinearAlgebra self.core_hamiltonian = np.matrix([]) self.repulsion = np.matrix([])