Navigation

Source code for sympy.physics.quantum.piab

"""1D quantum particle in a box."""from__future__importprint_function,divisionfromsympyimportSymbol,pi,sqrt,sin,Interval,Sfromsympy.physics.quantum.operatorimportHermitianOperatorfromsympy.physics.quantum.stateimportKet,Brafromsympy.physics.quantum.constantsimporthbarfromsympy.functions.special.tensor_functionsimportKroneckerDeltafromsympy.physics.quantum.hilbertimportL2m=Symbol('m')L=Symbol('L')__all__=['PIABHamiltonian','PIABKet','PIABBra']

[docs]classPIABHamiltonian(HermitianOperator):"""Particle in a box Hamiltonian operator."""@classmethoddef_eval_hilbert_space(cls,label):returnL2(Interval(S.NegativeInfinity,S.Infinity))def_apply_operator_PIABKet(self,ket,**options):n=ket.label[0]return(n**2*pi**2*hbar**2)/(2*m*L**2)*ket

[docs]classPIABKet(Ket):"""Particle in a box eigenket."""@classmethoddef_eval_hilbert_space(cls,args):returnL2(Interval(S.NegativeInfinity,S.Infinity))@classmethoddefdual_class(self):returnPIABBradef_represent_default_basis(self,**options):returnself._represent_XOp(None,**options)def_represent_XOp(self,basis,**options):x=Symbol('x')n=Symbol('n')subs_info=options.get('subs',{})returnsqrt(2/L)*sin(n*pi*x/L).subs(subs_info)def_eval_innerproduct_PIABBra(self,bra):returnKroneckerDelta(bra.label[0],self.label[0])

[docs]classPIABBra(Bra):"""Particle in a box eigenbra."""@classmethoddef_eval_hilbert_space(cls,label):returnL2(Interval(S.NegativeInfinity,S.Infinity))@classmethoddefdual_class(self):returnPIABKet