def hplus(self, L, r, E, prime=0): """Calculates the Hankel Function H+ in terms of the regular (coulombf) and irregular (coulombg) Coulomb functions: H(+)=G+iF Parameters __________ L: int Angular momentum of the scattering state r: float Position of the boundry match condition E: int or float Energy of the scattering wavefunction prime: int 0 or 1 Whether to calculate the derivative Returns _______ H+: float The Hankel function H+ or its derivative """ if prime == 0: return mp.coulombg( L, 0, cm.sqrt(self.Const * E) * r) + complex(0, 1) * mp.coulombf(L, 0, cm.sqrt(self.Const * E) * r) elif prime == 1: return mp.diff( lambda x: mp.coulombg(L, 0, cm.sqrt(self.Const * E) * x), r) + complex(0, 1) * mp.diff( lambda x: mp.coulombf(L, 0, cm.sqrt(self.Const * E) * x), r)
def asymptotic_oscillating(self, r, E, l): k = sqrt(2.0 * E) solution1 = float( mpmath.coulombf(l, -self.unscreened_charge / k, r * k)) / r solution2 = float( mpmath.coulombg(l, -self.unscreened_charge / k, r * k)) / r return solution1, solution2
def mp_coulomb_wave_func(kr, Z, k, l): eta = -Z / k f = [] for rho in kr: fi = mpmath.coulombf(l, eta, rho) f.append(float(fi)) return (np.array(f))
def mpmath_implementation(self, r): # slow mpmath implementation kr = self.k * r f = [] for rho in kr: fi = mpmath.coulombf(self.l, -self.Z / self.k, rho - self.delta_l) f.append(float(fi)) return np.array(f)
def Right_Side_Vector(grid, lo, l_prime, mo, k, z=2): right_vector = np.zeros(len(grid)) for i, r in enumerate(grid): pot_term = Potential(r, l_prime, lo, mo) if l_prime == lo: pot_term += 2.0/r right_vector[i] = pot_term * mp.coulombf(lo, -z/k, k*r) / k return right_vector
def F(l,eta,x): #F Coulumb function Fc=mp.coulombf(l,eta,x) return Fc
def atomic_pz_orbital(Z, data_file): atomlist = [(Z, (0.0, 0.0, 0.0))] # compute molecular orbitals with DFTB print "compute molecular orbitals with tight-binding DFT" tddftb = LR_TDDFTB(atomlist) tddftb.setGeometry(atomlist, charge=0) options = {"nstates": 1} try: tddftb.getEnergies(**options) except DFTB.Solver.ExcitedStatesNotConverged: pass valorbs, radial_val = load_pseudo_atoms(atomlist) bound_orbs = tddftb.dftb2.getKSCoefficients() # order of orbitals s, py,pz,px, dxy,dyz,dz2,dzx,dx2y2, so the pz-orbital has index 2 mo_bound = bound_orbs[:, 2] tdipole_data = [] for iE, E in enumerate(slako_tables_scattering.energies): print "PKE = %s" % E try: SKT_bf, SKT_ff = load_slako_scattering(atomlist, E) except ImportError: break Dipole = ScatteringDipoleMatrix(atomlist, valorbs, SKT_bf).real # dipole between bound orbital and the continuum AO basis orbitals dipole_bf = np.tensordot(mo_bound, Dipole, axes=(0, 0)) tdip_pz_to_s = dipole_bf[0, 2] # points along z-axis tdip_pz_to_dyz = dipole_bf[5, 1] # points along y-axis tdip_pz_to_dz2 = dipole_bf[6, 2] # points along z-axis tdip_pz_to_dzx = dipole_bf[7, 0] # points along x-axis tdipole_data.append( [E * AtomicData.hartree_to_eV] + [tdip_pz_to_s, tdip_pz_to_dyz, tdip_pz_to_dz2, tdip_pz_to_dzx]) #### # determine the radius of the sphere where the angular distribution is calculated. It should be # much larger than the extent of the molecule (xmin, xmax), (ymin, ymax), (zmin, zmax) = Cube.get_bbox(atomlist, dbuff=0.0) dx, dy, dz = xmax - xmin, ymax - ymin, zmax - zmin Rmax = max([dx, dy, dz]) + 500.0 print "Radius of sphere around molecule, Rmax = %s bohr" % Rmax k = np.sqrt(2 * E) wavelength = 2.0 * np.pi / k print "wavelength = %s" % wavelength valorbsE, radial_valE = load_pseudo_atoms_scattering(atomlist, E, rmin=0.0, rmax=Rmax + 2 * wavelength, Npts=90000) # Plot radial wavefunctions import matplotlib.pyplot as plt plt.ion() r = np.linspace(0.0, Rmax + 2 * wavelength, 5000) for i, (Zi, posi) in enumerate(atomlist): for indx, (ni, li, mi) in enumerate(valorbsE[Zi]): # only plot the dz2 continuum orbital if li == 2 and mi == 0 and (iE % 10 == 0): R_spl = radial_valE[Zi][indx] radial_orbital_wfn = R_spl(r) plt.plot(r, radial_orbital_wfn, label="Z=%s n=%s l=%s m=%s E=%s" % (Zi, ni, li, mi, E)) plt.plot(r, np.sin(k * r) / r, ls="-.") #plt.plot(r, np.sin(k*r + 1.0/k * np.log(2*k*r))/r, ls="--", lw=2) plt.plot(r, np.array([ float(mpmath.coulombf(li, -1.0 / k, k * rx)) / rx for rx in r ]), ls="--", lw=2, label="CoulombF l=%s E=%s" % (li, E)) plt.draw() #### # save table fh = open(data_file, "w") print >> fh, "# PKE/eV pz->s pz->dyz pz->dz2 pz->dzx" np.savetxt(fh, tdipole_data) fh.close() print "Wrote table with transition dipoles to %s" % data_file # show radial wavefunctions plt.ioff() plt.show()
def Coulomb_Fun(grid, lo, k, z=2): coulomb_fun = np.zeros(len(grid)) for i, r in enumerate(grid): coulomb_fun[i] = mp.coulombf(lo, -z/k, k*r) return coulomb_fun
def Coulomb_Function(grid, lo, k, Z=2): cf = np.zeros(len(grid)) for i, r in enumerate(grid): cf[i] = mp.coulombf(lo, -1 * Z / k, k * r) return cf