def test_quartic(verbose=False): if verbose: print '--> test_quartic' num_orbitals = 2 num_spins = 2 U, J = 1.0, 0.2 up, do = 0, 1 spin_names = [up, do] orb_names = range(num_orbitals) U_ab, UPrime_ab = U_matrix_kanamori(n_orb=2, U_int=U, J_hund=J) if verbose: print 'U_ab =\n', U_ab print 'UPrime_ab =\n', UPrime_ab T_ab = np.array([ [1., 1.], [1., -1.], ]) / np.sqrt(2.) # -- Check hermitian np.testing.assert_array_almost_equal(np.mat(T_ab) * np.mat(T_ab).H, np.eye(2)) I = np.eye(num_spins) T_ab_spin = np.kron(T_ab, I) H_int = h_int_kanamori( spin_names, orb_names, U_ab, UPrime_ab, J_hund=J, off_diag=True, map_operator_structure=None, H_dump=None) op_imp = [c(up,0), c(do,0), c(up,1), c(do,1)] Ht_int = operator_single_particle_transform(H_int, T_ab_spin, op_imp) if verbose: print 'H_int =', H_int print 'Ht_int =', Ht_int from transform_kanamori import h_int_kanamori_transformed Ht_int_ref = h_int_kanamori_transformed( [T_ab, T_ab], spin_names, orb_names, U_ab, UPrime_ab, J_hund=J, off_diag=True, map_operator_structure=None, H_dump=None) if verbose: print 'Ht_int_ref =', Ht_int_ref assert( (Ht_int_ref - Ht_int).is_zero() )
def test_single_particle_transform(verbose=False): if verbose: print('--> test_single_particle_transform') h_loc = np.array([ [1.0, 0.0], [0.0, -1.0], ]) op_imp = [c(0, 0), c(0, 1)] H_loc = get_quadratic_operator(h_loc, op_imp) H_loc_ref = c_dag(0, 0) * c(0, 0) - c_dag(0, 1) * c(0, 1) assert ((H_loc - H_loc_ref).is_zero()) h_loc_ref = quadratic_matrix_from_operator(H_loc, op_imp) np.testing.assert_array_almost_equal(h_loc, h_loc_ref) if verbose: print('h_loc =\n', h_loc) print('h_loc_ref =\n', h_loc_ref) print('H_loc =', H_loc) T_ab = np.array([ [1., 1.], [1., -1.], ]) / np.sqrt(2.) Ht_loc = operator_single_particle_transform(H_loc, T_ab, op_imp) ht_loc = quadratic_matrix_from_operator(Ht_loc, op_imp) ht_loc_ref = np.array([ [0., 1.], [1., 0.], ]) Ht_loc_ref = c_dag(0, 0) * c(0, 1) + c_dag(0, 1) * c(0, 0) if verbose: print('ht_loc =\n', ht_loc) print('ht_loc_ref =\n', ht_loc_ref) print('Ht_loc =', Ht_loc) print('Ht_loc_ref =', Ht_loc_ref) assert ((Ht_loc - Ht_loc_ref).is_zero())
J_hund=p.J) H_int = h_int_kanamori(p.spin_names, p.orb_names, U_ab, UPrime_ab, J_hund=p.J, off_diag=True, map_operator_structure=None, H_dump=None) p.H_int = relabel_operators(H_int, p.spin_block_ops, p.org_ops) # -- Complete 2site + 2bath Hamiltonian p.H = p.H_loc + p.H_bath + p.H_int # -- Single particle transformed Hamiltonian p.Ht = operator_single_particle_transform(p.H, p.T, p.op_imp) p.Ht_int = operator_single_particle_transform(p.H_int, p.T, p.op_imp) # ------------------------------------------------------------------ # -- Store to hdf5 if mpi.is_master_node(): with HDFArchive('data_model.h5', 'w') as res: res['p'] = p # ----------------------------------------------------------------------