~kaktusjoe/spacetime/spacetime2.0.0-ubuntu18.05

« back to all changes in this revision

Viewing changes to Spacetime/DiracSpinor.icc

  • Committer: Joseph F. Boudreau
  • Date: 2018-01-05 17:09:07 UTC
  • Revision ID: boudreau@pitt.edu-20180105170907-jcxsjfkvnvpjdnrw
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "Spacetime/SpecialOperators.h"
 
2
#include "Spacetime/LorentzTransformation.h"
 
3
#include <cmath>
 
4
 
 
5
namespace DiracSpinor{
 
6
 
 
7
  template<int T> 
 
8
  inline BasicSpinor<T>::BasicSpinor():Eigen::Vector4cd(0,0,0,0) {}
 
9
 
 
10
  template<int T>
 
11
  inline BasicSpinor<T>::BasicSpinor(const Spinor<2> & s, double mass) {
 
12
    double sqrtM=std::sqrt(mass);
 
13
    static std::complex<double> I(0,1);
 
14
    if (T==UType) {
 
15
      head(2)=sqrtM*s;
 
16
      tail(2)=sqrtM*s;
 
17
    }
 
18
    else if (T==VType) {
 
19
      // Apply charge conjugation:
 
20
      using namespace SpecialOperators;
 
21
      Spinor<2>sp=sqrtM*I*sigma2*s.conjugate();
 
22
      tail(2)=sp;
 
23
      head(2)=-sp;
 
24
    }
 
25
    else {
 
26
      throw std::runtime_error("DiracSpinor:  illegal spinor type");
 
27
    }
 
28
  }
 
29
  
 
30
  template<int T> 
 
31
  inline BasicSpinor<T>::BasicSpinor(const Spinor<2> & s, const FourVector & p) {
 
32
 
 
33
    using namespace SpecialOperators;
 
34
    Eigen::Matrix2cd SDotP=Sigma::dot(p), SBarDotP=SigmaBar::dot(p);
 
35
    Eigen::ComplexEigenSolver<Eigen::Matrix2cd> sol(SDotP),solBar(SBarDotP);
 
36
    Eigen::Matrix2cd A=sol.eigenvectors(), ABar=solBar.eigenvectors();
 
37
    Eigen::Vector2cd D=sol.eigenvalues(), DBar=solBar.eigenvalues();
 
38
    Eigen::Matrix2cd sqrtD=Eigen::Matrix2cd::Zero(), sqrtDBar=Eigen::Matrix2cd::Zero();
 
39
    for (int e=0;e<2;e++) {
 
40
      sqrtD(e,e)=std::sqrt(D(e));
 
41
      sqrtDBar(e,e)=std::sqrt(DBar(e));
 
42
    }
 
43
    Eigen::Matrix2cd R=A*sqrtD*A.inverse(), RBar=ABar*sqrtDBar*ABar.inverse(); 
 
44
    if (T==UType) {
 
45
      head(2)=R*s;
 
46
      tail(2)=RBar*s;
 
47
    }
 
48
    else if (T==VType) {
 
49
      // Apply charge conjugation:
 
50
      using namespace SpecialOperators;
 
51
      tail(2)= RBar*s;
 
52
      head(2)=-R*s;
 
53
    }
 
54
    else {
 
55
      throw std::runtime_error("DiracSpinor:  illegal spinor type");
 
56
    }
 
57
  }
 
58
 
 
59
  template<int T> 
 
60
  inline BasicSpinor<T>::BasicSpinor(const WeylSpinor::Left & s){
 
61
    using namespace SpecialOperators;
 
62
    if (T==UType) {
 
63
      head(2)=std::sqrt(2.0)*s;
 
64
      tail(2)=Eigen::Vector2cd::Zero();
 
65
    }
 
66
    else if (T==VType) {
 
67
      Spinor<2>sp=I*sigma2*s.conjugate();
 
68
      tail(2)=std::sqrt(2.0)*sp;
 
69
      head(2)=Eigen::Vector2cd::Zero();
 
70
   }
 
71
    else {
 
72
      throw std::runtime_error("DiracSpinor:  illegal spinor type");
 
73
    }
 
74
 
 
75
  }
 
76
 
 
77
  template<int T> 
 
78
  inline BasicSpinor<T>::BasicSpinor(const WeylSpinor::Right & s) {
 
79
    using namespace SpecialOperators;
 
80
    if (T==UType) {
 
81
      head(2)=Eigen::Vector2cd::Zero();
 
82
      tail(2)=std::sqrt(2.0)*s;
 
83
    }
 
84
    else if (T==VType) {
 
85
      Spinor<2>sp=I*sigma2*s.conjugate();
 
86
      tail(2)=Eigen::Vector2cd::Zero();
 
87
      head(2)=-std::sqrt(2.0)*sp;
 
88
    }
 
89
    else {
 
90
      throw std::runtime_error("DiracSpinor:  illegal spinor type");
 
91
    }
 
92
  }
 
93
 
 
94
  template<int T> 
 
95
  template<typename Derived>
 
96
  inline BasicSpinor<T>::BasicSpinor(const Eigen::MatrixBase<Derived>& other) : Eigen::Vector4cd(other)
 
97
  { }
 
98
  
 
99
  template<int T> 
 
100
  template<typename Derived>
 
101
  inline BasicSpinor<T> & BasicSpinor<T>::operator= (const Eigen::MatrixBase <Derived>& other)
 
102
  {
 
103
    this->Eigen::Vector4cd::operator=(other);
 
104
    return *this;
 
105
  }
 
106
 
 
107
  inline
 
108
  Bar::Bar():Eigen::RowVector4cd(0,0,0,0) {}
 
109
 
 
110
  inline
 
111
  Bar::Bar(const std::complex<double> & s0,
 
112
           const std::complex<double> & s1,
 
113
           const std::complex<double> & s2,
 
114
           const std::complex<double> & s3
 
115
           ):
 
116
    Eigen::RowVector4cd(s0,s1,s2,s3)
 
117
  {}
 
118
  
 
119
  template<typename Derived>
 
120
  inline Bar::Bar(const Eigen::MatrixBase<Derived>& other) : Eigen::RowVector4cd(other)
 
121
  { }
 
122
  
 
123
  template<typename Derived>
 
124
  inline Bar & Bar::operator= (const Eigen::MatrixBase <Derived>& other)
 
125
  {
 
126
    this->Eigen::RowVector4cd::operator=(other);
 
127
    return *this;
 
128
  }
 
129
 
 
130
  template<typename Derived>
 
131
  inline Any::Any(const Eigen::MatrixBase<Derived>& other) : Eigen::Vector4cd(other)
 
132
  { }
 
133
  
 
134
  template<typename Derived>
 
135
  inline Any & Any::operator= (const Eigen::MatrixBase <Derived>& other)
 
136
  {
 
137
    this->Eigen::Vector4cd::operator=(other);
 
138
    return *this;
 
139
  }
 
140
}