void check_FindVacX() { int i,j; double vac[3][2]; FILE* pf=NULL; POSCAR *pos=NULL; POSCAR_Init(pos); if ((pf=fopen("data/surface/InSb_VAC10_X","r"))==NULL) { g_assert(false); } POSCAR_Read(pos, pf); FindVac(pos, vac); for (i=0; i<3; i++) { if (i!=0) { for (j=0; j<2; j++) { g_assert_cmpfloat(vac[i][j],==,0); } } else { g_assert_cmpfloat(vac[i][0],==,0.2994904607365295); g_assert_cmpfloat(vac[i][1],==,1.0); } }
/** \brief 讀取CHGCAR格式 */ int SCALAR3D_READ( SCALAR3D* sca, POSCAR* pos, FILE* pf) { int i,j,count; int NGRID; int iline, ret; char cdump[POSCAR_COMMENT_LEN]; if (sca==NULL) { fprintf(stderr, "SCALAR3D_READ: sca must not be null."); exit(1); } if (pos==NULL) { fprintf(stderr, "SCALAR3D_READ: pos must not be null."); exit(1); } if (pf==NULL) { fprintf(stderr, "SCALAR3D_READ: pf must not be null."); exit(1); } ret= POSCAR_Read(pos,pf); if (ret!=0) return ret; for (i=0; i<3; i++) for (j=0; j<3; j++) sca->axis[i][j]= pos->lat->a[i][j]; if (pos->elem_num!=NULL) iline= pos->natom+8; else iline= pos->natom+7; /*blank line*/ READLINE(iline, cdump, POSCAR_COMMENT_LEN, pf); /*NGX NGY NGZ*/ READLINE(iline, cdump, POSCAR_COMMENT_LEN, pf); ret= sscanf(cdump, "%d %d %d", &sca->ngrid[0], &sca->ngrid[1], &sca->ngrid[2]); if (ret!=3) { fprintf(stderr,"SCALAR3D_READ: Parsing Number of grid failed.\n"); exit(iline); } for (i=0; i<3; i++) { if (sca->ngrid[i]<=0) { fprintf(stderr,"SCALAR3D_READ: Numbers of grids must be postive.\n"); exit(iline); } } NGRID= sca->ngrid[0]*sca->ngrid[1]*sca->ngrid[2]; sca->val= malloc(sizeof(double)*NGRID); if (sca->val==NULL) { fprintf(stderr,"SCALAR3D_READ: Memroy Allocate for scalar field failed.\n"); exit(1); } /*Data*/ for (count=0; count<NGRID; count++) { fscanf(pf,"%lf", &(sca->val[count])); } READLINE(iline, cdump, POSCAR_COMMENT_LEN, pf); return 0; }