//------------------------------------------------------------------------- int Cubic_spline::read( vector <string> & words, unsigned int & pos ) { Array1 <double> basisparms(4); atomname=words[0]; basisparms(0)=.02; //spacing basisparms(1)=2500; //number of points basisparms(2)=1e31; basisparms(3)=1e31; if(!readvalue(words, pos=0, norm_type, "NORMTYPE")) { norm_type="GAMESSNORM"; } if(haskeyword(words, pos=0, "NORENORMALIZE")) { renormalize=false; } else { renormalize=true; } doublevar cutmax; if(readvalue(words, pos=0, cutmax, "CUTOFF")) { requested_cutoff=cutmax; } else { requested_cutoff=-1; } enforce_cusp=false; if(readvalue(words, pos=0, cusp, "CUSP")) enforce_cusp=true; match_sto=false; if(readvalue(words, pos=0, cusp_matching, "CUSP_MATCHING")) match_sto=true; zero_derivative=false; if(haskeyword(words, pos=0, "ZERO_DERIVATIVE")) zero_derivative=true; customspacing=basisparms(0); if(readvalue(words, pos=0, customspacing, "SPACING")) { basisparms(0)=customspacing; basisparms(1)=50.0/customspacing; } vector <string> basisspec; string read_file; //read positions from a file if(readsection(words,pos=0, basisspec, "GAMESS")) { unsigned int newpos=0; return readbasis(basisspec, newpos, basisparms); } else { pos=0; if(readspline(words)) { return 1; } else { error("couldn't find proper basis section in AOSPLINE. " "Try GAMESS { .. }."); return 0; } } //We assume that all splines use the same interval, //which saves a few floating divisions, so check to make //sure the assumption is good. for(int i=0; i< splines.GetDim(0); i++) { if(!splines(0).match(splines(i))) error("spline ", i, " doesn't match the first one "); } }
INPUT_INFO* parse_input(const char* file_name) { /* hf 6-31g* 0 1 N 7 0.0000000000 0.0000000000 0.0000000000 N 7 0.0000000000 0.0000000000 1.0980000000 */ int i = 0, j; FILE *f; INPUT_INFO *inputFile; char BasisFile[20] = "EMSL/"; // save the name of basis file char method[5], basisName[10]; ATOM_INFO *atomList; COORD *coord; int gCount = 0, basisCount; // initial allocate 100 basis function, 300 GTO; inputFile = calloc(sizeof(INPUT_INFO), 1); atomList = inputFile->atomList = malloc(sizeof(ATOM_INFO)*INITIAL_ATOM_COUNT); coord = inputFile->gXYZ = malloc(sizeof(COORD) * INITIAL_ATOM_COUNT); OPEN_FILE(f, file_name); // read the control parameter like Gaussian 09 fscanf(f, "%s%s", method, basisName); // Get the electronic count and multidegree of the system fscanf(f, "%d%u", &inputFile->icharge, &inputFile->imult); #if DEBUG_OUTPUT_INPUTFILE fprintf(stdout, "%s %s\n\n%d %u\n", method, basisName, inputFile->icharge, inputFile->imult); #endif // read the atom information include atom Number and coordination while (fscanf(f, "%s%d%lf%lf%lf", atomList[i].symbol, &atomList[i].n, &coord[i].x, &coord[i].y, &coord[i].z) != EOF) { // tranverse ANGS to BOHR coord[i].x *= ANGS_2_BOHR; coord[i].y *= ANGS_2_BOHR; coord[i].z *= ANGS_2_BOHR; #if DEBUG_OUTPUT_INPUTFILE fprintf(stdout, "%s %d %lf %lf %lf\n", atomList[i].symbol, atomList[i].n, coord[i].x, coord[i].y, coord[i].z); #endif // connect the coordination inputFile->atomList[i].cid = i; inputFile->atomCount++; i++; } fclose(f); // release redundant memory REALLOC(inputFile->atomList, inputFile->atomCount * sizeof(ATOM_INFO)); // ---------------------------------------------------------------- // Read Basis information from the basis function database // ---------------------------------------------------------------- inputFile->basisSet = malloc(sizeof(BASIS)* INITIAL_BASIS_COUNT); inputFile->gp = malloc(sizeof(GTO_PARTIAL)* INDEPENDENT_GTO_COUNT); inputFile->gtoSet = malloc(sizeof(GTO)* INDEPENDENT_GTO_COUNT); Get_Basis_File(basisName, BasisFile); OPEN_FILE(f, BasisFile); readbasis(f, inputFile); fclose(f); /* ---------------------------------------------------------------- * allocate memory for store P, K, gamma * ---------------------------------------------------------------- */ gCount = inputFile->gCount; basisCount = inputFile->basisCount; #if DEBUG_INPUT fprintf(stdout, "%d %d %d\n", gCount, inputFile->gtoCount, basisCount); for (i = 0; i < gCount; i++) fprintf(stdout, "%d %lf %lf\n", i, inputFile->gp[i].alpha, inputFile->gp[i].coeff); #endif inputFile->K = (double **)malloc(sizeof(double *) * gCount); inputFile->zeta = (double **)malloc(sizeof(double *) * gCount); inputFile->P = (COORD **)malloc(sizeof(COORD *) * gCount); for (i = 0; i < gCount; i ++) { MALLOC(inputFile->K[i], sizeof(double) * gCount); MALLOC(inputFile->zeta[i], sizeof(double) * gCount); MALLOC(inputFile->P[i], sizeof(COORD) * gCount); } for (i = 0; i < gCount; i++) { for (j = 0; j <= i; j++) { // compute \zeta = \alpha_1 + \alpha_2 inputFile->zeta[i][j] = inputFile->zeta[j][i] = inputFile->gp[i].alpha + inputFile->gp[j].alpha; // compute K = f(\alpha_1, \alpha_2, AB) inputFile->K[i][j] = inputFile->K[j][i] = K_OS(&inputFile->gp[i], &inputFile->gp[j], inputFile->gXYZ); // compute P Gaussian_product_center(&inputFile->gp[i], &inputFile->gp[j], inputFile->gXYZ, &inputFile->P[i][j]); inputFile->P[j][i] = inputFile->P[i][j]; #if DEBUG_ZETA_K_P fprintf(stdout, "i, j: %d %d\nzeta = %lf\tK = %lf\tP: %lf %lf %lf\n", i, j, inputFile->zeta[i][j], inputFile->K[i][j], inputFile->P[i][j].x, inputFile->P[i][j].y, inputFile->P[i][j].z); #endif } } return inputFile; }