src/MultiSys/MultiExch0.cc
// ----------------------------------------------------------------------------
//     This is an older function for generating Xnm, left for comparison.
// ----------------------------------------------------------------------------
This is an older function for generating Xnm, left for comparison.
This is an older function for generating Xnm left for comparison .
super_op XXnm(const multi_sys& mixture)
  {
  int   dim = mixture.LS();			
  basis Dbs = D_basis(mixture);	        	
  matrix Xmx(dim, dim, 0.0);			
  int i, j, k;			
  int ic1=0, ic2=0;				
  int s1, s2;					
  int match, mover;				
  double q1b = 0, q1k = 0;			
  double q2b = 0, q2k = 0;			
  double pop2, kex2;
  int spinHS, norm;				
  ExchProc Pro;					
  sys_dynamic dsys;
  row_vector bra1, ket1, bra2, ket2;
  for(i=0; i<mixture.NExProcs(); i++)		
    {
    Pro = mixture.ExProc(i);			
    matrix Xel(dim, dim, 0.0);			
    int ic0 = Pro.LHSComp(0);			
    double pop0 = mixture.pop(ic0);	        
    double kex0 = Pro.Kex();		        
    if(kex0 == 0) continue;			
    for(j=0; j<dim; j++)			
      { 					
      for(k=0; k<dim; k++)  			
	{
        ic1 = Dbs.which_sub_LS(j);		
        ic2 = Dbs.which_sub_LS(k);	        
        pop2 = mixture.pop(ic2);
        kex2 = (pop0*kex0)/pop2;
        if(ic1 == ic2)				
	  if(Pro.involves(ic1) )		
            {
            if(j == k) Xel.put(kex2, j, j); 	
            continue;
            }
         if(!Pro.mixes(ic1, ic2)) continue;	
         bra1 = LS_qState_bra(mixture, j);	
         ket1 = LS_qState_ket(mixture, j);	
         bra2 = LS_qState_bra(mixture, k);	
         ket2 = LS_qState_ket(mixture, k);	 |ket2><bra2| form superket
         norm = 1;
         match = 1;
         for(s1=0; s1<bra1.cols(); s1++)	 parse bra1;
	   {
           mover = 0;				 flag for exchanging spin s1
           for(s2=0; s2<bra2.cols(); s2++)	 look for s2 <-> s1 
	     {
             q1b = bra1.getRe(s1);		 Mz of spin s1 in bra1
             q1k = ket1.getRe(s1);		 Mz of spin s1 in ket1
             q2b = bra2.getRe(s2);		 Mz of spin s2 in bra2
             q2k = ket2.getRe(s2);		 Mz of spin s2 in ket2
	     if(Pro.mapped(ic1,s1,ic2,s2))	 if partners in exchange
               {
               mover = 1;			 s1 in exchange with s2
               if((q1b!=q2b) || (q1k!=q2k))	 different quantum state
                 {
		 match = 0;			 do not click
                 break;
                 }
               }
             }
           if(!match) break;
           if(!mover)			     s1 is not exchanging
             {
             if(q1b!=q1k)                   it's not |m><m|
               {
               match = 0;
               break;
               }
             dsys = mixture.Comp(ic1);	 spin that is in superbra
             spinHS = dsys.HS(s1);		 but not in superket
             norm *= spinHS;			 contributes into norm 
             } 
           }
	 if(!match) continue;
         for(s2=0; s2<bra2.cols(); s2++)	 now parse bra2 to find
           {					 local non-movers
           q2b = bra2.getRe(s2);		 Mz of spin s2 in bra2
           q2k = ket2.getRe(s2);		 Mz of spin s2 in ket2
           mover = 0;				 flag for exchanging s2
           for(s1=0; s1<bra1.cols(); s1++)     
	     if(Pro.mapped(ic2, s2, ic1, s1))	  
	       mover = 1;			 this is mover
             if(!mover)				 s2 is not exchanging
               if(q2b!=q2k)			 it is not |m><m|
		 {
                 match = 0;
                 break;
                 }
           }			
         if(!match) continue;
         else
           {
	   kex2 /= double(norm);
           Xel.put(-kex2,j,k);			 Normalization good for any 
           }					 non-mutual exchange. 
         }
       }
     Xmx += Xel;				 Add this exchange process'
     }						 contribution to Xnm
   return super_op(Xmx,Dbs);
   }
super_op XXnm ( const multi_sys & mixture ) { int dim = mixture . LS ( ) ; basis Dbs = D_basis ( mixture ) ; matrix Xmx ( dim , dim , 0.0 ) ; int i , j , k ; int ic1 = 0 , ic2 = 0 ; int s1 , s2 ; int match , mover ; double q1b = 0 , q1k = 0 ; double q2b = 0 , q2k = 0 ; double pop2 , kex2 ; int spinHS , norm ; ExchProc Pro ; sys_dynamic dsys ; row_vector bra1 , ket1 , bra2 , ket2 ; for ( i = 0 ; i < mixture . NExProcs ( ) ; i ++ ) { Pro = mixture . ExProc ( i ) ; matrix Xel ( dim , dim , 0.0 ) ; int ic0 = Pro . LHSComp ( 0 ) ; double pop0 = mixture . pop ( ic0 ) ; double kex0 = Pro . Kex ( ) ; if ( kex0 == 0 ) continue ; for ( j = 0 ; j < dim ; j ++ ) { for ( k = 0 ; k < dim ; k ++ ) { ic1 = Dbs . which_sub_LS ( j ) ; ic2 = Dbs . which_sub_LS ( k ) ; pop2 = mixture . pop ( ic2 ) ; kex2 = ( pop0 * kex0 ) / pop2 ; if ( ic1 == ic2 ) if ( Pro . involves ( ic1 ) ) { if ( j == k ) Xel . put ( kex2 , j , j ) ; continue ; } if ( ! Pro . mixes ( ic1 , ic2 ) ) continue ; bra1 = LS_qState_bra ( mixture , j ) ; ket1 = LS_qState_ket ( mixture , j ) ; bra2 = LS_qState_bra ( mixture , k ) ; ket2 = LS_qState_ket ( mixture , k ) ; norm = 1 ; match = 1 ; for ( s1 = 0 ; s1 < bra1 . cols ( ) ; s1 ++ ) { mover = 0 ; for ( s2 = 0 ; s2 < bra2 . cols ( ) ; s2 ++ ) { q1b = bra1 . getRe ( s1 ) ; q1k = ket1 . getRe ( s1 ) ; q2b = bra2 . getRe ( s2 ) ; q2k = ket2 . getRe ( s2 ) ; if ( Pro . mapped ( ic1 , s1 , ic2 , s2 ) ) { mover = 1 ; if ( ( q1b != q2b ) || ( q1k != q2k ) ) { match = 0 ; break ; } } } if ( ! match ) break ; if ( ! mover ) { if ( q1b != q1k ) { match = 0 ; break ; } dsys = mixture . Comp ( ic1 ) ; spinHS = dsys . HS ( s1 ) ; norm *= spinHS ; } } if ( ! match ) continue ; for ( s2 = 0 ; s2 < bra2 . cols ( ) ; s2 ++ ) { q2b = bra2 . getRe ( s2 ) ; q2k = ket2 . getRe ( s2 ) ; mover = 0 ; for ( s1 = 0 ; s1 < bra1 . cols ( ) ; s1 ++ ) if ( Pro . mapped ( ic2 , s2 , ic1 , s1 ) ) mover = 1 ; if ( ! mover ) if ( q2b != q2k ) { match = 0 ; break ; } } if ( ! match ) continue ; else { kex2 /= double ( norm ) ; Xel . put ( - kex2 , j , k ) ; } } } Xmx += Xel ; } return super_op ( Xmx , Dbs ) ; }
This is an older function for generating Xnm, left for comparison.
This is an older function for generating Xnm left for comparison .
// Determine overall LS dim // Default basis // Superop matrices to host Xex // Multi_sys components // Spin numbers within comp's // Flags // Mz quantum numbers of s1, s2 // Mz quantum numbers of s1, s2 // Normalization by dim of HS // A single exchange process // Loop over exchange processes // Get exchange process i // Start with zero superop // 0th component on lhs // population of 0th component // k refers to 0th comp on lhs // Don't contribute if K=0 // Loop rows and columns of // Xel for process i and set // <j|Xel|k> elements // Index of component 1 // Index of component 2  // Component with itself  // It's exchanging component // Only diagonal decay terms // Not in exchange // Generate cross-terms // |ket1><bra1| form superbra // // // |ket2><bra2| form superket // parse bra1; // flag for exchanging spin s1 // look for s2 <-> s1  // Mz of spin s1 in bra1 // Mz of spin s1 in ket1 // Mz of spin s2 in bra2 // Mz of spin s2 in ket2 // if partners in exchange // s1 in exchange with s2 // different quantum state // do not click // s1 is not exchanging // it's not |m><m| // spin that is in superbra // but not in superket // contributes into norm  // now parse bra2 to find // local non-movers // Mz of spin s2 in bra2 // Mz of spin s2 in ket2 // flag for exchanging s2 // this is mover // s2 is not exchanging // it is not |m><m| // Normalization good for any  // non-mutual exchange.  // Add this exchange process' // contribution to Xnm