src/HSLib/SpinOpRot.cc
// ----------- Generic Rotations About An Axis In Spherical Space -------------
Generic Rotations About An Axis In Spherical Space
Generic Rotations About An Axis In Spherical Space
spin_op Rspace(const spin_sys & sys, const flagvec& flags, 
                                        double theta, double phi, double beta)
  {
  int dim;
  int ns = sys.spins();
  double cb,sb,cp,sp,ct,st;
  matrix* spr = new matrix [ns];
  cb = cos(beta*PI/360.0);		
  sb = sin(beta*PI/360.0);		
  cp = cos(phi*PI/180.0);		
  sp = sin(phi*PI/180.0);		
  ct = cos(theta*PI/180.0);		
  st = sin(theta*PI/180.0);		
  for(int spin=0; spin<ns; spin++)	
    {
    dim = sys.HS(spin);			
    if(flags[spin])			
      {
      spr[spin]=matrix(dim,dim,complex0);
      matrix &p = spr[spin];
      if(dim == 2)			
	{
	 p.put(complex(cb, -ct*sb), 0,0);	
	 p.put(sb*complex(-st*sp,-st*cp), 0,1);
	 p.put(sb*complex(st*sp,-st*cp), 1,0);
	 p.put(complex(cb, ct*sb), 1,1);
	 }
       else				
	 {
	 p = times_adjoint(Raxis(dim,beta,'z'),Raxis(dim,theta,'y'));
	 p = Raxis(dim,theta,'y')*p;	
	 p = times_adjoint(p,Raxis(dim,phi,'z'));
	 p = Raxis(dim,phi,'z')*p;	
	 }
      }
    else spr[spin] = Ie(dim);		
    }
  spin_op SOp(ns, spr);			
  if(spr) delete [] spr;
  return SOp;
  }
spin_op Rspace ( const spin_sys & sys , const flagvec & flags , double theta , double phi , double beta ) { int dim ; int ns = sys . spins ( ) ; double cb , sb , cp , sp , ct , st ; matrix * spr = new matrix [ ns ] ; cb = cos ( beta * PI / 360.0 ) ; sb = sin ( beta * PI / 360.0 ) ; cp = cos ( phi * PI / 180.0 ) ; sp = sin ( phi * PI / 180.0 ) ; ct = cos ( theta * PI / 180.0 ) ; st = sin ( theta * PI / 180.0 ) ; for ( int spin = 0 ; spin < ns ; spin ++ ) { dim = sys . HS ( spin ) ; if ( flags [ spin ] ) { spr [ spin ] = matrix ( dim , dim , complex0 ) ; matrix & p = spr [ spin ] ; if ( dim == 2 ) { p . put ( complex ( cb , - ct * sb ) , 0 , 0 ) ; p . put ( sb * complex ( - st * sp , - st * cp ) , 0 , 1 ) ; p . put ( sb * complex ( st * sp , - st * cp ) , 1 , 0 ) ; p . put ( complex ( cb , ct * sb ) , 1 , 1 ) ; } else { p = times_adjoint ( Raxis ( dim , beta , ' ' ) , Raxis ( dim , theta , ' ' ) ) ; p = Raxis ( dim , theta , ' ' ) * p ; p = times_adjoint ( p , Raxis ( dim , phi , ' ' ) ) ; p = Raxis ( dim , phi , ' ' ) * p ; } } else spr [ spin ] = Ie ( dim ) ; } spin_op SOp ( ns , spr ) ; if ( spr ) delete [ ] spr ; return SOp ; }
Generic Rotations About An Axis In Spherical Space
Generic Rotations About An Axis In Spherical Space
// Input                sys  : Spin system (base) //			flags: Array of spin flags //                      theta: Rotation axis polar angle //                      phi  : Rotation axis polar angle //                      beta : Rotation angle // Return               SOp  : Spin rotation operator Rxyz for //                             rotations of angle beta about an axis //                             specified by theta and phi // Note                      : Spins whose spin flags are TRUE //                             in flags are affected by R // sosi			     - In need of better sim.trans. routine // angle is beta/2 in radians // angle is beta/2 in radians // angle is phi in radians // angle is phi in radians // angle is theta in radians // angle is theta in radians // Loop over all spins in sys // Current spin Hilbert space // See if rotation affects spin // For I=1/2, do this (easy) // cos(B) - i*cos(T)*sin(B) // For I!=1/2, do this (harder) // p = Ryz(theta,beta) here // p = Rxyz (theta,phi,beta) // Unaffected spin contribution // Set SOp for system