예제 #1
0
// Print out the basis set specification in the format:
// (example is C atom in 3-21G basis set)
// BASIS: 6-31G
// Total no. of cgbfs: 9
// Total no. of primitives: 9
// ===============
//  Specification
// ===============
// Atom      Shell     #CGBFs    #Prims
// ......................................
// C         s          3         6
//           p          6         3
// (if full = true, then continue with this)
// ===============
// Basis Functions
// ===============
// Atom      Shell     BF    Coeff        Exponent
// .................................................
// C         s         1     0.0617669    172.2560
//                           0.358794     25.91090
//                           0.700713     5.533350
// etc...
void Logger::print(Basis& b, bool full) const
{
  // Collect the data needed for printing
  int nbfs = b.getNBFs(); // Store number of cgbfs and prims
  int nprims = 0;

  Vector qs = b.getCharges();
  // Sort the qs and get rid of duplicates
  qs.sort();
  Vector qtemp(qs.size());
  qtemp[0] = qs(0);
  int k = 1;
  for (int i = 1; i < qs.size(); i++){
    if (qs(i) != qtemp[k-1]){
      qtemp[k] = qs(i);
      k++;
    }
  }
  qs = qtemp;
  qs.resizeCopy(k);

  // Now sum over all basis functions to get the number of prims
  Vector c(3); c[0] = 0.0; c[1] = 0.0; c[2] = 0.0;
  BF bftemp(c, 0, 0, 0, c, c);

  for (int i = 0; i < nbfs; i++){
    bftemp = b.getBF(i);
    nprims += bftemp.getNPrims();
  }

  // Start printing
  title("Basis Set");
  outfile << "BASIS: " << b.getName() << "\n";
  outfile << "Total no. of cgbfs: " << nbfs << "\n";
  outfile << "Total no. of prims: " << nprims << "\n";
  title("Specification");
  outfile << std::setw(8) << "Atom";
  outfile << std::setw(8) << "Shell";
  outfile << std::setw(8) << "#CGBFs";
  outfile << std::setw(8) << "#Prims\n";
  outfile << std::string(35, '.') << "\n";
  
  // loop over the atom types
  outfile << std::setprecision(2);
  Vector subshells; Vector sublnums; 
  for (int i = 0; i < k; i++){
    int nc = 0; int np = 0;
    outfile << std::setw(8) << getAtomName(qs(i));
    subshells = b.getShells(qs[i]);

    sublnums = b.getLnums(qs[i]);
    outfile << std::setw(8) << getShellName(sublnums[0]);
    outfile << std::setw(8) << subshells[0];

    for (int j = 0; j < subshells[0]; j++){
      np += b.getBF(qs[i], j).getNPrims();
    }

    nc += subshells[0];
    outfile << std::setw(8) << np << "\n";
    for (int j = 1; j < subshells.size(); j++){
      outfile << std::setw(8) << "";
      outfile << std::setw(8) << getShellName(sublnums[j]);
      outfile << std::setw(8) << subshells[j];
      np = 0;
      for (int l = 0; l < subshells[j]; l++){
	np += b.getBF(qs[i], nc + l).getNPrims();	
      }
      nc += subshells[j];
      outfile << std::setw(8) << np << "\n";
    }

  }
  outfile << std::setprecision(8);
  // Now print out basis functions if required
  if (full) {
    title("Basis Functions");
    outfile << std::setw(8) << "Atom";
    outfile << std::setw(8) << "Shell";
    outfile << std::setw(5) << "BF";
    outfile << std::setw(18) << "Coeff";
    outfile << std::setw(18) << "Exponent\n";
    outfile << std::string(58, '.') << "\n";
    // Loop over all the basis functions
    Vector subshell; Vector sublnums; 
    Vector coeffs; Vector exps;
    std::string filler = "";
    for (int i = 0; i < k; i++){
      subshell = b.getShells(qs(i));
      sublnums = b.getLnums(qs(i));

      // Loop over shells
      int sum = 0;
      for (int r = 0; r < subshell.size(); r++){ 
	// Loop over bfs
	for (int s = 0; s < subshell[r]; s++){
	  bftemp = b.getBF(qs(i), s+sum);
	  coeffs = bftemp.getCoeffs();
	  exps = bftemp.getExps();

	  // Loop over coeffs/exps
	  for (int t = 0; t < coeffs.size(); t++){
	    filler = ((r == 0 && s==0 && t==0) ? getAtomName(qs[i]) : "");
	    outfile << std::setw(8) << filler;
	    filler = ((s == 0 && t == 0) ? getShellName(sublnums[r]) : "");
	    outfile << std::setw(8) << filler;
	    filler = (t == 0 ? std::to_string(s+1) : "");
	    outfile << std::setw(5) << filler;
	    outfile << std::setw(18) << std::setprecision(8) << coeffs(t);
	    outfile << std::setw(18) << std::setprecision(8) << exps(t) << "\n";
	  }
	}
	sum += subshell[r];
      }
    }
  }
}      
예제 #2
0
 /**
  * Diffusion: Imposing weak boundary condition for q with flux
  *  uflux = g_D  on Dirichlet boundary condition
  *  uflux = u_Fwd  on Neumann boundary condition
  */
 void DiffusionLDG::v_WeakPenaltyforVector(
     const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
     const int                                          var,
     const int                                          dir,
     const Array<OneD, const NekDouble>                &qfield,
           Array<OneD,       NekDouble>                &penaltyflux,
     NekDouble                                          C11)
 {
     int i, e, id1, id2;
     int nBndEdges, nBndEdgePts;
     int nBndRegions = fields[var]->GetBndCondExpansions().num_elements();
     int nTracePts   = fields[0]->GetTrace()->GetTotPoints();
     
     Array<OneD, NekDouble > uterm(nTracePts);
     Array<OneD, NekDouble > qtemp(nTracePts);
     int cnt = 0;
     
     /*
     // Setting up the normals
     m_traceNormals = Array<OneD, Array<OneD, NekDouble> >(nDim);
     for(i = 0; i < nDim; ++i)
     {
         m_traceNormals[i] = Array<OneD, NekDouble> (nTracePts);
     }
     fields[0]->GetTrace()->GetNormals(m_traceNormals);
     */
     
     fields[var]->ExtractTracePhys(qfield, qtemp);
     
     for (i = 0; i < nBndRegions; ++i)
     {
         nBndEdges = fields[var]->
             GetBndCondExpansions()[i]->GetExpSize();
                         
         // Weakly impose boundary conditions by modifying flux values
         for (e = 0; e < nBndEdges ; ++e)
         {
             nBndEdgePts = fields[var]->
             GetBndCondExpansions()[i]->GetExp(e)->GetNumPoints(0);
             
             id1 = fields[var]->
             GetBndCondExpansions()[i]->GetPhys_Offset(e);
             
             id2 = fields[0]->GetTrace()->
             GetPhys_Offset(fields[0]->GetTraceMap()->
                            GetBndCondTraceToGlobalTraceMap(cnt++));
             
             // For Dirichlet boundary condition: 
             //qflux = q+ - C_11 (u+ -    g_D) (nx, ny)
             if(fields[var]->GetBndConditions()[i]->
             GetBoundaryConditionType() == SpatialDomains::eDirichlet)
             {
                 Vmath::Vmul(nBndEdgePts, 
                             &m_traceNormals[dir][id2], 1, 
                             &qtemp[id2], 1, 
                             &penaltyflux[id2], 1);
             }
             // For Neumann boundary condition: qflux = g_N
             else if((fields[var]->GetBndConditions()[i])->
             GetBoundaryConditionType() == SpatialDomains::eNeumann)
             {
                 Vmath::Vmul(nBndEdgePts,
                             &m_traceNormals[dir][id2], 1, 
                             &(fields[var]->
                               GetBndCondExpansions()[i]->
                               GetPhys())[id1], 1, 
                             &penaltyflux[id2], 1);
             }
         }
     }
 }