basisset.cc

00001 
00005 #include<cstdio>
00006 #include<stdlib.h>
00007 #include<cmath>
00008 #include<libciomr/libciomr.h>
00009 #include<libchkpt/chkpt.h>
00010 
00011 #include<libint/libint.h>
00012 #include"defines.h"
00013 #define EXTERN
00014 #include"global.h"
00015 #include <stdexcept>
00016 #include"shell_pairs.h"
00017 #include"small_fns.h"
00018 
00019 namespace psi { namespace CINTS {
00020 
00021 /*--------------------------------
00022   Explicit functions declarations
00023  --------------------------------*/
00024 static void get_primitives(void);
00025 static void get_shell_info(void);
00026 
00027 void init_basisset()
00028 {
00029   BasisSet.num_shells = chkpt_rd_nshell();
00030   BasisSet.num_prims = chkpt_rd_nprim();
00031   BasisSet.num_ao = chkpt_rd_nao();
00032   BasisSet.am2shell = chkpt_rd_am2canon_shell_order();
00033   BasisSet.shells_per_am = chkpt_rd_shells_per_am();
00034   BasisSet.max_am = chkpt_rd_max_am()+1;
00035   BasisSet.puream = chkpt_rd_puream();
00036 /* BasisSet.cgtos = */ get_primitives();
00037 /* BasisSet.shells = */ get_shell_info();
00038 /* BasisSet.shell_pairs = */ init_shell_pairs();
00039 
00040   /*-----------------------------------------------
00041     Namespaces are not well defined in CINTS,
00042     because of this here're some overlapping inits
00043    -----------------------------------------------*/
00044   if (BasisSet.puream && UserOptions.symm_ints)
00045     Symmetry.usotao = chkpt_rd_usotbf();
00046   else
00047     Symmetry.usotao = chkpt_rd_usotao();
00048   if (Symmetry.nirreps > 1 && UserOptions.symm_ints)
00049 /* Symmetry.us_pairs = */ init_unique_shell_pairs();
00050 
00051   return;
00052 }
00053 
00054 
00055 void cleanup_basisset()
00056 {
00057   int i;
00058   
00059   dealloc_pairs();
00060   for(i=0;i<BasisSet.num_shells;i++)
00061     free(BasisSet.shells[i].trans_vec);
00062   free(BasisSet.shells);
00063   free(BasisSet.cgtos);
00064 
00065   return;
00066 }
00067 
00068 void get_shell_info()
00069 {
00070    int i, j, l, g, count, stab_index;
00071    int *shell_center;           /* atomic center of each shell */
00072    int *shell_type;             /* angular mom. of shell */
00073    int *shell_num_prims;        /* number of primitives per shell */
00074    int *prim_pointers;          /* first primitive in shell */
00075    int *shell_fbf;              /* first basisfn in shell */
00076    int *shell_fao;              /* first AO in shell */
00077    int **shell_trans_table;     /* shell transformation table */
00078 
00079    /*--- retrieve location of shells (which atom it's centered on) ---*/
00080    shell_center = chkpt_rd_snuc();
00081 
00082    /*--- retrieve angular momentum of each shell (1=s, 2=p, 3=d, etc  ) ---*/
00083    shell_type = chkpt_rd_stype();
00084 
00085    /*--- retrieve number of primitives per shell ---*/
00086    shell_num_prims = chkpt_rd_snumg();
00087 
00088    /*--- retrieve pointer to first primitive in shell ---*/
00089    prim_pointers = chkpt_rd_sprim();
00090 
00091    /*--- retrieve pointer to first basisfn in shell ---*/
00092    shell_fbf = chkpt_rd_sloc_new();
00093 
00094    /*--- retrieve pointer to first AO in shell ---*/
00095    shell_fao = chkpt_rd_sloc();
00096    
00097    /*--- retrieve shell tranformation table ---*/
00098    shell_trans_table = chkpt_rd_shell_transm();
00099 
00100    /*--- retrieve maximum am ---*/
00101    if (BasisSet.max_am > CINTS_MAX_AM)
00102      throw std::domain_error("Angular momentum limit of CINTS exceeded, reconfigure and recompile");
00103    
00104    BasisSet.shells = (struct shell_def *) malloc(sizeof(struct shell_def)*
00105                                                  BasisSet.num_shells);
00106    BasisSet.max_num_prims = 0;
00107    for (i=0; i<BasisSet.num_shells; i++){
00108       BasisSet.shells[i].center = shell_center[i];
00109       BasisSet.shells[i].am = shell_type[i];
00110       BasisSet.shells[i].n_prims = shell_num_prims[i];
00111       if (shell_num_prims[i] > BasisSet.max_num_prims)
00112         BasisSet.max_num_prims = shell_num_prims[i];
00113       BasisSet.shells[i].fprim = prim_pointers[i];
00114       BasisSet.shells[i].trans_vec = init_int_array(Symmetry.nirreps);
00115       for(j=0; j<Symmetry.nirreps; ++j)
00116           BasisSet.shells[i].trans_vec[j] = shell_trans_table[i][j];
00117       BasisSet.shells[i].fbf = shell_fbf[i];
00118       BasisSet.shells[i].fao = shell_fao[i];
00119       /*--- compute index of the stabilizer for the shell ---*/
00120       count = 1;
00121       for(g=1;g<Symmetry.nirreps;g++)
00122         if (i == BasisSet.shells[i].trans_vec[g]-1)
00123           count++;
00124       stab_index = Symmetry.nirreps/count;
00125       if (Symmetry.max_stab_index < stab_index)
00126         Symmetry.max_stab_index = stab_index;
00127    }
00128 
00129    free(shell_center);
00130    free(shell_type);
00131    free(shell_num_prims);
00132    free(prim_pointers);
00133    free(shell_fbf);
00134    free(shell_fao);
00135    free_int_matrix(shell_trans_table);
00136    
00137    return;
00138 }
00139 
00140 
00141 void get_primitives(void)
00142 {
00143    int i, j;
00144    double *exponents;      /* primitive gaussian exponents */
00145    double **ccoeffs;       /* primitive gaussian cont. coeff. for each ang. momentum*/
00146 
00147    /*--- read in exponents of primitive gaussians ---*/
00148    exponents = chkpt_rd_exps();
00149 
00150    /*--- read in coefficients of primitive gaussians ---*/
00151    ccoeffs = chkpt_rd_contr_full();
00152 
00153    /*--- allocate prims structure ---*/
00154    BasisSet.cgtos = (struct gaussian_function *)malloc(sizeof(struct gaussian_function)*BasisSet.num_prims);
00155 
00156    /*--- fill prims structure ---*/
00157    for (i=0; i<BasisSet.num_prims; i++){
00158      BasisSet.cgtos[i].exp = exponents[i];
00159      for(j=0;j<CINTS_MAX_AM;j++) 
00160        BasisSet.cgtos[i].ccoeff[j] = ccoeffs[i][j];
00161    }
00162 
00163    free(exponents);
00164    free_block(ccoeffs);
00165 
00166    return;
00167 }
00168 
00169 
00170 };};

Generated on Wed Feb 13 16:35:39 2008 for PSI by  doxygen 1.5.4