void Nevpt2_npdm::compute_A22_matrix( array_6d<double>& eee, array_8d<double>& eeee ) 
{ 
if( mpigetrank() == 0 ) {

  std::cout << "Building NEVPT2 A22 matrix\n";

  int dim = eee.dim1();
  const TwoElectronArray& twoInt = v_2;

  // Output text file
  char file[5000];
  sprintf (file, "%s%s%d.%d%s", dmrginp.save_prefix().c_str(),"/A22_matrix.", 0, 0,".txt");
  ofstream ofs(file);
  ofs << dim << endl;

  for(int ap=0; ap<dim; ++ap) {
    for(int bp=0; bp<dim; ++bp) {
      for(int cp=0; cp<dim; ++cp) {
        for(int a=0; a<dim; ++a) {
          for(int b=0; b<dim; ++b) {
            int d_bpb = ( bp == b );
            for(int c=0; c<dim; ++c) {
          
              double val = 0.0;
              for(int d=0; d<dim; ++d) {
                for(int e=0; e<dim; ++e) {
                  int d_bpe = ( bp == e );
                  for(int f=0; f<dim; ++f) {
                    // Factor of 2 on indices to recover spatial two-electron integrals
                    val += twoInt(2*d,2*e,2*f,2*a) * ( 2.0 * d_bpb * eee(cp,ap,d,f,e,c) - eeee(cp,ap,b,bp,d,f,e,c) );
                    val -= twoInt(2*d,2*c,2*f,2*e) * ( 2.0 * d_bpb * eee(cp,ap,d,f,a,e) - eeee(cp,ap,b,bp,d,f,a,e) );
                    val += twoInt(2*d,2*e,2*f,2*b) * ( 2.0 * d_bpe * eee(cp,ap,d,f,a,c) - eeee(cp,ap,e,bp,d,f,a,c) );
                  }
                }
              }
              if ( abs(val) > 1e-14 ) ofs << boost::format("%d %d %d %d %d %d %20.14e\n") % ap % bp % cp % a % b % c % val;
            }
          }
        }
      }
    }
  }
  ofs.close();

}
}
Beispiel #2
0
/*
  Read ISO 8601 date and time notation (extended format only).
*/
double ur_stringToDate( const char* start, const char* end, const char** pos )
{
    // yyyy-mm-ddThh:mm:ss.fff[+/-hh:mm]
    // _123456789_123456789_123456789

    struct tm tmp;
    const char* it;
    double sec = 0.0;
    int utc = 0;
    int offset;
    int len = end - start;

    if( (len < 10) || (start[4] != '-') || (start[7] != '-') )
    {
        if( pos )
            *pos = start;
        return 0.0;
    }

    // Handle date portion.

    tmp.tm_year  = (twoInt( start ) * 100 + twoInt( start + 2 )) - 1900;
    tmp.tm_mon   = twoInt( start + 5 ) - 1;
    tmp.tm_mday  = twoInt( start + 8 );
    tmp.tm_hour  = 0;
    tmp.tm_min   = 0;
    tmp.tm_sec   = 0;
    tmp.tm_isdst = -1;


    // Handle time portion.  Both 'T' and '/' are accepted as separator.

    it = start + 10;

    if( (len < 13) || (*it != 'T' && *it != '/') )
        goto done;
    ++it;
    len = end - it;

    tmp.tm_hour = twoInt( it );
    it += 2;
    if( (len < 5) || (*it != ':') )
        goto done;

    tmp.tm_min = twoInt( ++it );
    it += 2;
    if( it == end )
        goto done;
    if( *it == ':' )
    {
        ++it;
        sec = str_toDouble( it, end, &it );
        if( it == end )
            goto done;
    }


    // Handle UTC offset.

    switch( *it )
    {
        case '+':
            utc = 1;
            break;
        case '-':
            utc = -1;
            break;
        case 'Z':
            utc = 1;
            ++it;
        default:
            goto done;
    }
    ++it;
    len = end - it;
    if( len < 2 )
        goto done;
    offset = twoInt( it );
    tmp.tm_hour += (utc < 0) ? offset : -offset;
    it += 2;
    if( (len < 5) || (*it != ':') )
        goto done;
    ++it;
    offset = twoInt( it );
    tmp.tm_min += (utc < 0) ? offset : -offset;
    it += 2;

done:

    if( pos )
        *pos = it;
#ifdef _WIN32
#if _MSC_VER >= 1400
    return sec + (double) (utc ? _mkgmtime( &tmp ) : mktime( &tmp ));
#else
    return sec + (double) mktime( &tmp );   // TODO: Handle utc.
#endif
#elif defined(__sun__)
    return sec + (double) mktime( &tmp );   // TODO: Handle utc.
#else
    return sec + (double) (utc ? timegm( &tmp ) : mktime( &tmp ));
#endif
}