src/HSLib/SpinSystem.cc
// ----------------------------------------------------------------------------
//            Functions To Make A Spin System From A Parameter Set
// ----------------------------------------------------------------------------
Functions To Make A Spin System From A Parameter Set
Functions To Make A Spin System From A Parameter Set
void spin_system::setJs(const ParameterSet& pset)
  {
  std::string Jst("J(");				
  std::string Jmi(","), Jfi(")");			
  int notfound = 0;				
  ParameterSet::const_iterator item;         
  std::string pname;					
  std::string pstate;				
  double Jval = 0;				
  int ns = spins();				
  std::string* NoJSet;
  NoJSet = new std::string[ns*ns];
  int i, j=0;
  for(i=0; i<ns-1; i++)				
    { 						
    for(j=i+1; j<ns; j++)			
      {
      pname = Jst+Gdec(i)+Jmi+Gdec(j)+Jfi;	
      item = pset.seek(pname);			
      if(item != pset.end())
        {
        if(enpair(i,j))				
          {					
          if(warnings())			
            {
            SYSTerror(41, 1);
            SYSTerror(130, pname);
            }
          Jcouplings[pairidx(i, j)]= 0;		
          }					
        else
          {
          (*item).parse(pname,Jval,pstate);
          J(i, j, Jval);
          }
        }
      else
        {
        if(!enpair(i,j))			
          { 					
          NoJSet[notfound] = pname; 		
          J(i, j, 0.0);				
          notfound++;				
          }
        }
      }
    }
  if(!notfound) { delete [] NoJSet; return; }	
  if(warnings() < 2) { delete [] NoJSet; return; } 	
  for(i=0,j=0; i<notfound; i++,j++)		
    {						
    if(!j) SYSTerror(102, NoJSet[i], 1); 	
    else
      {
      std::cout << "; " << NoJSet[i];
      if(j>=2) j=-1;
      }
    }
  SYSTerror(35); 				
  delete [] NoJSet;
  }
void spin_system :: setJs ( const ParameterSet & pset ) { std :: string Jst ( " " ) ; std :: string Jmi ( " " ) , Jfi ( " " ) ; int notfound = 0 ; ParameterSet :: const_iterator item ; std :: string pname ; std :: string pstate ; double Jval = 0 ; int ns = spins ( ) ; std :: string * NoJSet ; NoJSet = new std :: string [ ns * ns ] ; int i , j = 0 ; for ( i = 0 ; i < ns - 1 ; i ++ ) { for ( j = i + 1 ; j < ns ; j ++ ) { pname = Jst + Gdec ( i ) + Jmi + Gdec ( j ) + Jfi ; item = pset . seek ( pname ) ; if ( item != pset . end ( ) ) { if ( enpair ( i , j ) ) { if ( warnings ( ) ) { SYSTerror ( 41 , 1 ) ; SYSTerror ( 130 , pname ) ; } Jcouplings [ pairidx ( i , j ) ] = 0 ; } else { ( * item ) . parse ( pname , Jval , pstate ) ; J ( i , j , Jval ) ; } } else { if ( ! enpair ( i , j ) ) { NoJSet [ notfound ] = pname ; J ( i , j , 0.0 ) ; notfound ++ ; } } } } if ( ! notfound ) { delete [ ] NoJSet ; return ; } if ( warnings ( ) < 2 ) { delete [ ] NoJSet ; return ; } for ( i = 0 , j = 0 ; i < notfound ; i ++ , j ++ ) { if ( ! j ) SYSTerror ( 102 , NoJSet [ i ] , 1 ) ; else { std :: cout << " " << NoJSet [ i ] ; if ( j >= 2 ) j = -1 ; } } SYSTerror ( 35 ) ; delete [ ] NoJSet ; }
Functions To Make A Spin System From A Parameter Set
Functions To Make A Spin System From A Parameter Set
// Input                ssys    : A spin system (this) //                      pset    : A parameter set // Output               none    : Spin system scalar couplings //                                are set from parameters in pset // Note				: This restricts the setting of J(i,j) //				  to have j>i for all spin pairs // Note				: Hyperfine couplings are NOT read //				  in with this function // Note				: Error output messages are herein //				  controled by warnings() as //				     0: no warnings whatsoever //				    !0: warn if J involves e- //				    >1: also  warn if J absent // Start of J parameter names // Finish of J parameter names // Count Js found // A pix into parameter list // Use for the parameter name  // Use for parameter statment // User for parameter value // Number of spins in system //  std::string NoJSet[ns*ns];				// string of Js not found // Loop throught the spin pairs // and retrieve the couplings // All Js need not be present // Parameter name // Pix in list for J(i,j) // Insure not e- to nucleus // as these take hyperfine  // couplings not J couplings // Set hyperfine coupling // to 0 for e-/nucleus // Insure either e- to e- // or nucleus to nucleus // Store that this J not set // Set to default 0 // Add to count of no J spins //	    Now Output Warnings If Any Spin Pairs Not J Assigned  //	           (Only Done if Warnings Are Active > 1) // Exit if all J's set // Exit if no warnings desired // Loop over Js not set // and issue warnings // (five J labels per line) // Warning, Unspecified Js