![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/local/lib/python3.6/dist-packages/sympy/physics/quantum/tests/ |
Upload File : |
from sympy.physics.quantum import Dagger from sympy.physics.quantum.boson import BosonOp from sympy.physics.quantum.fermion import FermionOp from sympy.physics.quantum.operatorordering import (normal_order, normal_ordered_form) def test_normal_order(): a = BosonOp('a') c = FermionOp('c') assert normal_order(a * Dagger(a)) == Dagger(a) * a assert normal_order(Dagger(a) * a) == Dagger(a) * a assert normal_order(a * Dagger(a) ** 2) == Dagger(a) ** 2 * a assert normal_order(c * Dagger(c)) == - Dagger(c) * c assert normal_order(Dagger(c) * c) == Dagger(c) * c assert normal_order(c * Dagger(c) ** 2) == Dagger(c) ** 2 * c def test_normal_ordered_form(): a = BosonOp('a') c = FermionOp('c') assert normal_ordered_form(Dagger(a) * a) == Dagger(a) * a assert normal_ordered_form(a * Dagger(a)) == 1 + Dagger(a) * a assert normal_ordered_form(a ** 2 * Dagger(a)) == \ 2 * a + Dagger(a) * a ** 2 assert normal_ordered_form(a ** 3 * Dagger(a)) == \ 3 * a ** 2 + Dagger(a) * a ** 3 assert normal_ordered_form(Dagger(c) * c) == Dagger(c) * c assert normal_ordered_form(c * Dagger(c)) == 1 - Dagger(c) * c assert normal_ordered_form(c ** 2 * Dagger(c)) == Dagger(c) * c ** 2 assert normal_ordered_form(c ** 3 * Dagger(c)) == \ c ** 2 - Dagger(c) * c ** 3