ROOTPWA
TSpinWaveFunction.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include "TSpinWaveFunction.h"
4 using namespace std;
5 
6 extern ClebschGordanBox box;
7 
9 
11 
12  J=J_;
13  type=type_;
14 
15  max_pzm=1;
16  pot3 = new Int_t[J];
17  for (Int_t i=0; i<J; i++) {
18  pot3[i]=max_pzm;
19  max_pzm*=3;
20  }
21  mi = new Int_t[max_pzm*J];
22  M = new Int_t[max_pzm];
23 
24  coeff = new TFracNum[max_pzm];
25  TFracNum ZERO(0,0,0,0,0);
26  for (Int_t pzm=0; pzm<max_pzm; pzm++) {
27  coeff[pzm] = ZERO;
28  }
29 
30  for (Int_t pzm=0; pzm<max_pzm; pzm++) {
31  Int_t rest=pzm;
32  Int_t i=J-1;
33  M[pzm]=0;
34  while (i>=0) {
35  Int_t ipot3=rest/pot3[i];
36  mi[J*pzm+i]=ipot3-1;
37  M[pzm]+=mi[J*pzm+i];
38  //cout << "Setting mi["<<J<<"*"<<pzm<<"+"<<i<<"]="<<mi[J*pzm+i]<<endl;
39  rest-=ipot3*pot3[i];
40  i--;
41  }
42  }
43 
44  for (Int_t MM=J; MM>=-J; MM--) {
45  if (debugSpinWave==2) cout << "Phi("<<J<<","<<MM<<")="<<endl;
46  for (Int_t pzm=max_pzm-1; pzm>=0; pzm--) {
47  if ( ((type=='s' || type=='c') && M[pzm]==MM) ||
48  (type=='l' && M[pzm]==MM && MM==0) ) {
49  Int_t m0=0;
50  for (Int_t i=0; i<J; i++) {
51  if (debugSpinWave==2) {
52  if (mi[J*pzm+i]== 1) cout <<"+";
53  if (mi[J*pzm+i]== 0) cout <<"0";
54  if (mi[J*pzm+i]==-1) cout <<"-";
55  }
56  if (mi[J*pzm+i]== 0) m0++;
57  }
58  if (type=='s' || type=='c')
59  coeff[pzm] = am0_to_J(J,MM,m0);
60  if (type=='l')
61  coeff[pzm] = cm0_sub_ell_2(J,m0);
62  if (debugSpinWave==2)
63  cout << " * sqrt("
64  << coeff[pzm].FracString()
65  <<") (eq. 4.1) ["<<pzm<<"]" <<endl;
66  }
67  }
68  }
69 }
70 
73 
74  TTensorSum *ts = new TTensorSum();
75  TFracNum ZERO(0,0,0,0,0);
76 
77  for (Int_t pzm=max_pzm-1; pzm>=0; pzm--) {
78  if ( M[pzm]==delta ) {
79  Int_t *pzm_field = new Int_t[J];
80  for (Int_t i=0; i<J; i++) pzm_field[i] = mi[J*pzm+i];
81 
82  if ( !(coeff[pzm]==ZERO) )
83  ts->AddTerm(new TTensorTerm(name, J, pzm_field, &(coeff[pzm])));
84  }
85  }
86  return ts;
87 }
88 
91  Int_t delta, Int_t S) {
92 
93  if ( !(type=='s' && E->type=='s') ) {
94  cerr<<"GetSpinCoupledTensorSum only for spin-type wave functions!"<<endl;
95  return 0;
96  }
97 
98  Int_t twoS1=2*J;
99  Int_t twoS2=2*E->J;
100  Int_t twoS=2*S;
101 
102  Int_t twoSmin=twoS1-twoS2;
103  if (twoSmin<0) twoSmin=-twoSmin;
104 
105  if (twoS<twoSmin || twoS>twoS1+twoS2){
106  cerr<<"GetSpinCoupledTensorSum: no coupling "
107  << J << " + " << E->J << " -> "<< S << endl;
108  return 0;
109  }
110 
111  //TFracNum *S1S2 = ClebschGordan(twoS, twoS1, twoS2);
112  TFracNum *S1S2 = box.GetCG(S, J, E->J);
113  if (debugSpinWave==1){
114  cout << "Clebsch-Gordans calculated for "
115  <<twoS<<","<<twoS1<<","<<twoS2<<": "<< S1S2 << endl;
116  }
117 
118  TTensorSum *ts = new TTensorSum();
119  TFracNum ZERO(0,0,0,0,0);
120 
121  for (Int_t MM1=J; MM1>=-J; MM1--) {
122  for (Int_t pzm1=max_pzm-1; pzm1>=0; pzm1--) {
123  if ( M[pzm1]==MM1 && !(coeff[pzm1]==ZERO) ) {
124 
125  for (Int_t MM2=E->J; MM2>=-J; MM2--) {
126  for (Int_t pzm2=E->max_pzm-1; pzm2>=0; pzm2--) {
127  if ( E->M[pzm2]==MM2 && !(E->coeff[pzm2]==ZERO) ) {
128 
129  if (MM1+MM2==delta) {
130 
131  Int_t *pzm1_field = new Int_t[J];
132  for (Int_t i=0; i<J; i++)
133  pzm1_field[i] = mi[J*pzm1+i];
134 
135  Int_t *pzm2_field = new Int_t[E->J];
136  for (Int_t i=0; i<E->J; i++)
137  pzm2_field[i] = E->mi[E->J*pzm2+i];
138 
139  TTensorTerm* newterm =
140  new TTensorTerm('o', J, pzm1_field, &(coeff[pzm1]));
141 
142  TFracNum coeff2_CG = S1S2[CGIndex(J, MM1, E->J, MM2)];
143  coeff2_CG = coeff2_CG * E->coeff[pzm2];
144 
145  newterm->Multiply('e', E->J, pzm2_field, &coeff2_CG);
146 
147  ts->AddTerm(newterm);
148  }
149  }
150  }
151  }
152  }
153  }
154  }
155  return ts;
156 }
157 
158 Int_t
160 
161  TFracNum **J1J=new TFracNum*[J-1];
162  for (Int_t i=0; i<J-1; i++){
163  // Int_t twoJ=2*(i+2);
164  // J1J[i] = ClebschGordan(twoJ, 2, twoJ-2);
165  J1J[i] = box.GetCG(i+2, 1, i+1);
166  }
167 
168  TFracNum *coeffCG = new TFracNum[max_pzm];
169  TFracNum ONE(0,0,0,0,1);
170 
171  for (Int_t pzm=0; pzm<max_pzm; pzm++) {
172  coeffCG[pzm]=ONE;
173  Int_t m=mi[J*pzm];
174  if (debugSpinWave==2) cout << m << " x ";
175  for (Int_t jj=1; jj<J; jj++) {
176  Int_t mj=mi[J*pzm+jj];
177  // m1=i/max2-J1, m2=i%max2-J2 ==> i=(m1+J1)*max2
178  if (debugSpinWave==2) {
179  cout << mj << ": * CG["<<jj-1<<"]["
180  << (mj+1)*(2*jj+1) + jj+m
181  <<"]:"<< J1J[jj-1][ (mj+1)*(2*jj+1) + jj+m ].Dval()
182  <<endl;
183  }
184  coeffCG[pzm]=coeffCG[pzm] * J1J[jj-1][ (mj+1)*(2*jj+1) + jj+m ];
185  m+=mj;
186  if (debugSpinWave==2) cout << m << " x ";
187  }
188  if (debugSpinWave==2) {
189  cout <<"done."<<endl;
190  }
191  }
192 
193  for (Int_t MM=J; MM>=0; MM--) {
194  cout << "Phi("<<J<<","<<MM<<")="<<endl;
195  for (Int_t pzm=max_pzm-1; pzm>=0; pzm--) {
196  if (M[pzm]==MM) {
197  cout << coeffCG[pzm].FracString()<< " * (";
198  Int_t m0=0;
199  for (Int_t i=0; i<J; i++) {
200  if (mi[J*pzm+i]== 1) cout <<"+";
201  if (mi[J*pzm+i]== 0) {cout <<"0"; m0++;}
202  if (mi[J*pzm+i]==-1) cout <<"-";
203  }
204  cout << ") [ (4.1): "<< coeff[pzm].FracString()<<" ]" <<endl;
205  }
206  }
207  }
208  return 0;
209 }