41 #define NAMESTRLEN 128 43 #define FCCSPACING 5.260 45 #define NCELLSPERSIDE 2 46 #define NCLUSTERPARTS (4*(NCELLSPERSIDE*NCELLSPERSIDE*NCELLSPERSIDE) + \ 47 6*(NCELLSPERSIDE*NCELLSPERSIDE) \ 48 + 3*(NCELLSPERSIDE) + 1) 51 #define MY_ERROR(message) \ 53 printf("* Error : \"%s\" %d:%s\n", message, \ 54 __LINE__, __FILE__); \ 58 #define MY_WARNING(message) \ 60 printf("* Error : \"%s\" %d:%s\n", message, \ 61 __LINE__, __FILE__); \ 78 void const *
const dataObject,
79 int const numberOfNeighborLists,
double const *
const cutoffs,
80 int const neighborListIndex,
81 int const particleNumber,
int *
const numberOfNeighbors,
82 int const **
const neighborsOfParticle);
94 double CurrentSpacing;
102 void* pkim_cluster_model;
105 int numberOfSpecies = 1;
106 int particleSpeciesShapeCluster[1];
108 int coordinatesShapeCluster[2];
112 double cutoff_cluster_model;
113 double energy_cluster_model;
116 char testkimfile[] =
"descriptor.kim";
120 printf(
"Please enter valid KIM Model name: \n");
121 error = scanf(
"%s", modelname);
124 MY_ERROR(
"Unable to read model name");
128 error = KIM_API_file_init(&pkim_cluster_model, testkimfile, modelname);
129 if (KIM_STATUS_OK >
error)
133 coordinatesShapeCluster[0] = numberOfParticles_cluster;
134 coordinatesShapeCluster[1] = 3;
136 KIM_API_set_shape(pkim_cluster_model,
"particleSpecies", particleSpeciesShapeCluster, 1, &
error);
137 if (KIM_STATUS_OK >
error)
138 My_ERROR(
"KIM_API_set_shape");
139 KIM_API_set_shape(pkim_cluster_model,
"coordinates", coordinatesShapeCluster, 2, &
error);
141 KIM_API_setm_data(pkim_cluster_model, &
error, 8*4,
142 "numberOfParticles", 1, &numberOfParticles_cluster, 1,
143 "numberOfSpecies", 1, &numberOfSpecies, 1,
144 "particleSpecies", numberOfParticles_cluster, &particleSpecies_cluster_model, 1,
145 "coordinates",
DIM*numberOfParticles_cluster, coords_cluster, 1,
146 "neighObject", 1, &nl_cluster_model, 1,
147 "cutoff", 1, &cutoff_cluster_model, 1,
148 "energy", 1, &energy_cluster_model, 1,
149 "forces",
DIM*numberOfParticles_cluster, forces_cluster, 1);
155 error = KIM_API_model_init(pkim_cluster_model);
159 particleSpecies_cluster_model[0] = KIM_API_get_species_code(pkim_cluster_model,
"Ar", &
error);
162 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
174 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
175 printf(
"--------------------------------------------------------------------------------\n");
176 printf(
"Results for KIM Model : %s\n", modelname);
178 printf(
"%20s, %20s, %20s\n",
"Energy",
"Force Norm",
"Lattice Spacing");
179 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
185 (cutoff_cluster_model + cutpad), &nl_cluster_model);
188 error = KIM_API_model_compute(pkim_cluster_model);
193 for (i=0; i <
DIM*numberOfParticles_cluster; ++i)
195 force_norm += forces_cluster[i]*forces_cluster[i];
197 force_norm = sqrt(force_norm);
200 printf(
"%20.10e, %20.10e, %20.10e\n",
201 energy_cluster_model,
211 error = KIM_API_model_destroy(pkim_cluster_model);
215 KIM_API_free(&pkim_cluster_model, &
error);
225 double FCCshifts[4][
DIM];
235 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
236 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
237 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
238 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
241 for (i = 0; i < nCellsPerSide; ++i)
243 latVec[0] = ((double) i)*FCCspacing;
244 for (j = 0; j < nCellsPerSide; ++j)
246 latVec[1] = ((double) j)*FCCspacing;
247 for (k = 0; k < nCellsPerSide; ++k)
249 latVec[2] = ((double) k)*FCCspacing;
250 for (
m = 0;
m < 4; ++
m)
252 for (n = 0; n <
DIM; ++n)
254 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
262 latVec[1] = ((double) i)*FCCspacing;
263 latVec[2] = ((double) j)*FCCspacing;
264 for (n = 0; n <
DIM; ++n)
266 coords[a*
DIM + n] = latVec[n];
269 for (n = 0; n <
DIM; ++n)
271 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
275 latVec[0] = ((double) i)*FCCspacing;
277 latVec[2] = ((double) j)*FCCspacing;
278 for (n = 0; n <
DIM; ++n)
280 coords[a*
DIM + n] = latVec[n];
283 for (n = 0; n <
DIM; ++n)
285 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
289 latVec[0] = ((double) i)*FCCspacing;
290 latVec[1] = ((double) j)*FCCspacing;
292 for (n = 0; n <
DIM; ++n)
294 coords[a*
DIM + n] = latVec[n];
297 for (n = 0; n <
DIM; ++n)
299 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
304 latVec[0] = ((double) i)*FCCspacing;
307 for (n = 0; n <
DIM; ++n)
309 coords[a*
DIM + n] = latVec[n];
313 latVec[1] = ((double) i)*FCCspacing;
315 for (n = 0; n <
DIM; ++n)
317 coords[a*
DIM + n] = latVec[n];
322 latVec[2] = ((double) i)*FCCspacing;
323 for (n = 0; n <
DIM; ++n)
325 coords[a*
DIM + n] = latVec[n];
330 for (n = 0; n <
DIM; ++n)
363 for (k = 0; k <
DIM; ++k)
365 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
371 if ((half && i < j) || (!half && i != j))
380 (*nl).NNeighbors[i] = a;
387 int const numberOfNeighborLists,
388 double const *
const cutoffs,
389 int const neighborListIndex,
390 int const particleNumber,
int *
const numberOfNeighbors,
391 int const **
const neighborsOfParticle)
398 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
400 if (neighborListIndex != 0)
return error;
403 *numberOfNeighbors = 0;
407 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
412 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
415 *neighborsOfParticle = &((*nl).neighborList[(particleNumber)*
numberOfParticles]);
int get_cluster_neigh(void *kimmdl, int *mode, int *request, int *part, int *numnei, int **nei1part, double **Rij)
#define MY_ERROR(message)
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
#define MY_WARNING(message)
ComputeArgumentName const numberOfParticles
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)