52 #define NAMESTRLEN 128 54 #define FCCSPACING 5.260 56 #define NCELLSPERSIDE 2 57 #define NCLUSTERPARTS (4*(NCELLSPERSIDE*NCELLSPERSIDE*NCELLSPERSIDE) + \ 58 6*(NCELLSPERSIDE*NCELLSPERSIDE) \ 59 + 3*(NCELLSPERSIDE) + 1) 62 #define MY_ERROR(message) \ 64 printf("* Error : \"%s\" %d:%s\n", message, \ 65 __LINE__, __FILE__); \ 69 #define MY_WARNING(message) \ 71 printf("* Error : \"%s\" %d:%s\n", message, \ 72 __LINE__, __FILE__); \ 87 double* coords,
double cutoff, NeighList* nl);
90 void const *
const dataObject,
91 int const neighborListIndex,
92 int const particleNumber,
int *
const numberOfNeighbors,
93 int const **
const neighborsOfParticle);
105 double CurrentSpacing;
106 double cutpad = 0.75;
115 int speciesIsSupported;
120 NeighList nl_cluster_model;
122 int number_of_cutoffs_cluster_model;
123 double influence_distance_cluster_model;
124 double const * cutoff_cluster_model;
125 double energy_cluster_model = 0.0;
126 double energy_one_atom_model = 0.0;
130 int requestedUnitsAccepted;
132 int numberOfAPI_Arguments;
135 int numberOfAPI_Callbacks;
141 printf(
"Please enter valid KIM Model name: \n");
142 error = scanf(
"%s", modelname);
145 MY_ERROR(
"Unable to read model name");
156 &requestedUnitsAccepted,
161 if (!requestedUnitsAccepted)
MY_ERROR(
"Must adapt to model units");
166 if ((
error) || (!speciesIsSupported))
168 MY_ERROR(
"Species Ar not supported");
173 for (i=0; i<numberOfAPI_Arguments; ++i)
187 MY_ERROR(
"unsupported required argument");
207 for (i=0; i<numberOfAPI_Callbacks; ++i)
218 MY_ERROR(
"unsupported required call back");
227 &numberOfParticles_cluster)
232 particleSpecies_cluster_model)
235 (
double*) &coords_cluster)
248 &number_of_cutoffs_cluster_model,
249 &cutoff_cluster_model);
250 if (number_of_cutoffs_cluster_model != 1)
MY_ERROR(
"too many cutoffs");
257 &(particleSpecies_cluster_model[0]));
260 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
265 particleContributing_cluster_model[i] = 1;
266 particleContributing_one_atom_model[i] = 0;
268 particleContributing_one_atom_model[30] = 1;
273 nl_cluster_model.NNeighbors = (
int*) malloc(
NCLUSTERPARTS*
sizeof(
int));
274 if (NULL==nl_cluster_model.NNeighbors)
MY_ERROR(
"malloc unsuccessful");
277 if (NULL==nl_cluster_model.neighborList)
MY_ERROR(
"malloc unsuccessful");
280 printf(
"--------------------------------------------------------------------------------\n");
281 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
282 printf(
"MODEL is : %s\n", modelname);
285 printf(
"%20s, %20s, %20s\n",
"Cluster Energy",
"One Atom Energy",
"Current Spacing");
286 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
292 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
298 energy_cluster_model = energy;
303 energy_one_atom_model = energy;
306 printf(
"%20.10e, %20.10e, %20.10e\n",
307 energy_cluster_model,
308 energy_one_atom_model,
314 free(nl_cluster_model.NNeighbors);
315 free(nl_cluster_model.neighborList);
327 double FCCshifts[4][
DIM];
337 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
338 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
339 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
340 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
343 for (i = 0; i < nCellsPerSide; ++i)
345 latVec[0] = ((double) i)*FCCspacing;
346 for (j = 0; j < nCellsPerSide; ++j)
348 latVec[1] = ((double) j)*FCCspacing;
349 for (k = 0; k < nCellsPerSide; ++k)
351 latVec[2] = ((double) k)*FCCspacing;
352 for (
m = 0;
m < 4; ++
m)
354 for (n = 0; n <
DIM; ++n)
356 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
364 latVec[1] = ((double) i)*FCCspacing;
365 latVec[2] = ((double) j)*FCCspacing;
366 for (n = 0; n <
DIM; ++n)
368 coords[a*
DIM + n] = latVec[n];
371 for (n = 0; n <
DIM; ++n)
373 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
377 latVec[0] = ((double) i)*FCCspacing;
379 latVec[2] = ((double) j)*FCCspacing;
380 for (n = 0; n <
DIM; ++n)
382 coords[a*
DIM + n] = latVec[n];
385 for (n = 0; n <
DIM; ++n)
387 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
391 latVec[0] = ((double) i)*FCCspacing;
392 latVec[1] = ((double) j)*FCCspacing;
394 for (n = 0; n <
DIM; ++n)
396 coords[a*
DIM + n] = latVec[n];
399 for (n = 0; n <
DIM; ++n)
401 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
406 latVec[0] = ((double) i)*FCCspacing;
409 for (n = 0; n <
DIM; ++n)
411 coords[a*
DIM + n] = latVec[n];
415 latVec[1] = ((double) i)*FCCspacing;
417 for (n = 0; n <
DIM; ++n)
419 coords[a*
DIM + n] = latVec[n];
424 latVec[2] = ((double) i)*FCCspacing;
425 for (n = 0; n <
DIM; ++n)
427 coords[a*
DIM + n] = latVec[n];
432 for (n = 0; n <
DIM; ++n)
443 double cutoff, NeighList* nl)
455 cutoff2 = cutoff*cutoff;
459 if ((allOrOne == i) || (allOrOne < 0))
464 for (k = 0; k <
DIM; ++k)
466 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
470 if ((r2 < cutoff2) && (i != j))
479 (*nl).NNeighbors[i] = a;
486 int const neighborListIndex,
487 int const particleNumber,
int *
const numberOfNeighbors,
488 int const **
const neighborsOfParticle)
492 NeighList* nl = (NeighList*) dataObject;
495 if (neighborListIndex != 0)
return error;
498 *numberOfNeighbors = 0;
502 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
507 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
510 *neighborsOfParticle = &((*nl).neighborList[(particleNumber)*
numberOfParticles]);
void KIM_Model_GetInfluenceDistance(KIM_Model const *const model, double *const influenceDistance)
int KIM_ArgumentNameNotEqual(KIM_ArgumentName const left, KIM_ArgumentName const right)
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
int KIM_Model_SetArgumentPointerDouble(KIM_Model *const model, KIM_ArgumentName const argumentName, double const *const ptr)
int KIM_Model_GetArgumentSupportStatus(KIM_Model const *const model, KIM_ArgumentName const argumentName, KIM_SupportStatus *const supportStatus)
KIM_ArgumentName const KIM_ARGUMENT_NAME_particleContributing
KIM_ArgumentName const KIM_ARGUMENT_NAME_numberOfParticles
int KIM_Model_SetCallbackPointer(KIM_Model *const model, KIM_CallbackName const callbackName, KIM_LanguageName const languageName, func *const fptr, void const *const dataObject)
void KIM_Model_GetNeighborListCutoffsPointer(KIM_Model const *const model, int *const numberOfCutoffs, double const **const cutoffs)
void KIM_Model_Destroy(KIM_Model **const model)
KIM_ChargeUnit const KIM_CHARGE_UNIT_e
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
KIM_LanguageName const KIM_LANGUAGE_NAME_c
ArgumentName const numberOfParticles
int KIM_CALLBACK_NAME_GetCallbackName(int const index, KIM_CallbackName *const callbackName)
void fcc_cluster_neighborlist(int allOrOne, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
void KIM_ARGUMENT_NAME_GetNumberOfArguments(int *const numberOfArguments)
int KIM_Model_GetSpeciesSupportAndCode(KIM_Model const *const model, KIM_SpeciesName const speciesName, int *const speciesIsSupported, int *const code)
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
int KIM_ARGUMENT_NAME_GetArgumentName(int const index, KIM_ArgumentName *const argumentName)
KIM_CallbackName const KIM_CALLBACK_NAME_GetNeighborList
#define MY_WARNING(message)
void KIM_CALLBACK_NAME_GetNumberOfCallbacks(int *const numberOfCallbacks)
int KIM_Model_Create(KIM_Numbering const numbering, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit, char const *const modelName, int *const requestedUnitsAccepted, KIM_Model **const model)
KIM_TimeUnit const KIM_TIME_UNIT_ps
int KIM_ArgumentNameEqual(KIM_ArgumentName const left, KIM_ArgumentName const right)
int KIM_Model_Compute(KIM_Model const *const model)
int get_cluster_neigh(void const *const dataObject, int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle)
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
KIM_ArgumentName const KIM_ARGUMENT_NAME_coordinates
KIM_ArgumentName const KIM_ARGUMENT_NAME_particleSpeciesCodes
#define MY_ERROR(message)
int KIM_SupportStatusEqual(KIM_SupportStatus const left, KIM_SupportStatus const right)
KIM_SupportStatus const KIM_SUPPORT_STATUS_required
struct KIM_Model KIM_Model
int KIM_Model_SetArgumentPointerInteger(KIM_Model *const model, KIM_ArgumentName const argumentName, int const *const ptr)
KIM_LengthUnit const KIM_LENGTH_UNIT_A
KIM_ArgumentName const KIM_ARGUMENT_NAME_partialEnergy
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K
int KIM_Model_GetCallbackSupportStatus(KIM_Model const *const model, KIM_CallbackName const callbackName, KIM_SupportStatus *const supportStatus)
KIM_Numbering const KIM_NUMBERING_zeroBased