-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOperator_Class.f90
68 lines (54 loc) · 2.42 KB
/
Operator_Class.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
!! Copyright 2010 Fernando M. Cucchietti
!
! This file is part of FortranMPS
!
! FortranMPS is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! FortranMPS is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with FortranMPS. If not, see <http://www.gnu.org/licenses/>.
module Operator_Class
use ErrorHandling
use Constants
use Tensor_Class
implicit none
! private
public :: PauliSigma
integer,parameter :: SPINONEHALF = 2
integer,parameter :: OPERATOR_BASIS_SIZE = 3
integer,parameter :: I_Operator=0,X_Operator=1,Y_Operator=2,Z_Operator=3
!###############################
!##### The class main object
!###############################
type,public,extends(Tensor2) :: SpinOperator
private
end type SpinOperator
complex(8),parameter,dimension(SPINONEHALF,SPINONEHALF):: PauliSigmaXMatrix = Reshape([zero,one,one,zero], [SPINONEHALF,SPINONEHALF])
complex(8),parameter,dimension(SPINONEHALF,SPINONEHALF):: PauliSigmaYMatrix = Reshape([zero,II,-II,zero], [SPINONEHALF,SPINONEHALF])
complex(8),parameter,dimension(SPINONEHALF,SPINONEHALF):: PauliSigmaZMatrix = Reshape([one,zero,zero,-one], [SPINONEHALF,SPINONEHALF])
complex(8),parameter,dimension(SPINONEHALF,SPINONEHALF):: IdentityOperatorMatrix = Reshape([one,zero,zero,one], [SPINONEHALF,SPINONEHALF])
contains
function PauliSigma(whichOperator) result(this)
integer,intent(IN) :: whichOperator
type(SpinOperator) :: this
select case (whichOperator)
case(I_Operator)
this=new_Tensor(IdentityOperatorMatrix)
case(X_Operator)
this=new_Tensor(PauliSigmaXMatrix)
case(Y_Operator)
this=new_Tensor(PauliSigmaYMatrix)
case(Z_Operator)
this=new_Tensor(PauliSigmaZMatrix)
case default
call ThrowException('PauliSigma','Unknown operator requested',whichOperator,CriticalError)
end select
end function PauliSigma
end module Operator_Class