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__); \ 75 double cutoff, NeighList* nl);
78 void const *
const dataObject,
79 int const numberOfCutoffs,
double const *
const cutoffs,
80 int const neighborListIndex,
81 int const particleNumber,
int *
const numberOfNeighbors,
82 int const **
const neighborsOfParticle);
94 double CurrentSpacing;
105 int speciesIsSupported;
109 NeighList nl_cluster_model;
111 int number_of_cutoffs_cluster_model;
112 double influence_distance_cluster_model;
113 double const * cutoff_cluster_model;
114 double energy_cluster_model;
118 int requestedUnitsAccepted;
120 int numberOfComputeArgumentNames;
124 int numberOfComputeCallbackNames;
128 printf(
"Please enter valid KIM Model name: \n");
129 error = scanf(
"%s", modelname);
132 MY_ERROR(
"Unable to read model name");
143 &requestedUnitsAccepted,
148 if (!requestedUnitsAccepted)
MY_ERROR(
"Must adapt to model units");
153 if ((
error) || (!speciesIsSupported))
155 MY_ERROR(
"Species Ar not supported");
161 MY_ERROR(
"KIM_Model_ComputeArgumentsCreate");
166 &numberOfComputeArgumentNames);
167 for (i=0; i<numberOfComputeArgumentNames; ++i)
170 i, &computeArgumentName);
187 MY_ERROR(
"unsupported required argument");
206 MY_ERROR(
"energy or forces not available");
213 &numberOfComputeCallbackNames);
214 for (i=0; i<numberOfComputeCallbackNames; ++i)
217 i, &computeCallbackName);
227 MY_ERROR(
"unsupported required call back");
237 &numberOfParticles_cluster)
242 particleSpecies_cluster_model)
247 particleContributing_cluster_model)
251 (
double*) &coords_cluster)
255 &energy_cluster_model)
259 (
double*) &forces_cluster);
270 &number_of_cutoffs_cluster_model,
271 &cutoff_cluster_model);
272 if (number_of_cutoffs_cluster_model != 1)
MY_ERROR(
"too many cutoffs");
279 &(particleSpecies_cluster_model[0]));
282 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
287 particleContributing_cluster_model[i] = 1;
293 nl_cluster_model.NNeighbors = (
int*) malloc(
NCLUSTERPARTS*
sizeof(
int));
294 if (NULL==nl_cluster_model.NNeighbors)
MY_ERROR(
"malloc unsuccessful");
297 if (NULL==nl_cluster_model.neighborList)
MY_ERROR(
"malloc unsuccessful");
300 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
301 printf(
"--------------------------------------------------------------------------------\n");
302 printf(
"Results for KIM Model : %s\n", modelname);
304 printf(
"%20s, %20s, %20s\n",
"Energy",
"Force Norm",
"Lattice Spacing");
305 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
311 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
319 for (i=0; i <
DIM*numberOfParticles_cluster; ++i)
321 force_norm += forces_cluster[i]*forces_cluster[i];
323 force_norm = sqrt(force_norm);
326 printf(
"%20.10e, %20.10e, %20.10e\n",
327 energy_cluster_model,
335 MY_ERROR(
"Unable to destroy compute arguments");
339 free(nl_cluster_model.NNeighbors);
340 free(nl_cluster_model.neighborList);
352 double FCCshifts[4][
DIM];
362 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
363 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
364 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
365 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
368 for (i = 0; i < nCellsPerSide; ++i)
370 latVec[0] = ((double) i)*FCCspacing;
371 for (j = 0; j < nCellsPerSide; ++j)
373 latVec[1] = ((double) j)*FCCspacing;
374 for (k = 0; k < nCellsPerSide; ++k)
376 latVec[2] = ((double) k)*FCCspacing;
377 for (
m = 0;
m < 4; ++
m)
379 for (n = 0; n <
DIM; ++n)
381 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
389 latVec[1] = ((double) i)*FCCspacing;
390 latVec[2] = ((double) j)*FCCspacing;
391 for (n = 0; n <
DIM; ++n)
393 coords[a*
DIM + n] = latVec[n];
396 for (n = 0; n <
DIM; ++n)
398 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
402 latVec[0] = ((double) i)*FCCspacing;
404 latVec[2] = ((double) j)*FCCspacing;
405 for (n = 0; n <
DIM; ++n)
407 coords[a*
DIM + n] = latVec[n];
410 for (n = 0; n <
DIM; ++n)
412 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
416 latVec[0] = ((double) i)*FCCspacing;
417 latVec[1] = ((double) j)*FCCspacing;
419 for (n = 0; n <
DIM; ++n)
421 coords[a*
DIM + n] = latVec[n];
424 for (n = 0; n <
DIM; ++n)
426 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
431 latVec[0] = ((double) i)*FCCspacing;
434 for (n = 0; n <
DIM; ++n)
436 coords[a*
DIM + n] = latVec[n];
440 latVec[1] = ((double) i)*FCCspacing;
442 for (n = 0; n <
DIM; ++n)
444 coords[a*
DIM + n] = latVec[n];
449 latVec[2] = ((double) i)*FCCspacing;
450 for (n = 0; n <
DIM; ++n)
452 coords[a*
DIM + n] = latVec[n];
457 for (n = 0; n <
DIM; ++n)
468 double cutoff, NeighList* nl)
482 cutoff2 = cutoff*cutoff;
490 for (k = 0; k <
DIM; ++k)
492 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
498 if ((half && i < j) || (!half && i != j))
507 (*nl).NNeighbors[i] = a;
514 int const numberOfCutoffs,
double const *
const cutoffs,
515 int const neighborListIndex,
516 int const particleNumber,
int *
const numberOfNeighbors,
517 int const **
const neighborsOfParticle)
521 NeighList* nl = (NeighList*) dataObject;
524 if ((numberOfCutoffs != 1) || (cutoffs[0] > nl->cutoff))
return error;
526 if (neighborListIndex != 0)
return error;
529 *numberOfNeighbors = 0;
533 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
538 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
541 *neighborsOfParticle = &((*nl).neighborList[(particleNumber)*
numberOfParticles]);
struct KIM_ComputeArguments KIM_ComputeArguments
int get_cluster_neigh(void *kimmdl, int *mode, int *request, int *part, int *numnei, int **nei1part, double **Rij)
void KIM_Model_GetInfluenceDistance(KIM_Model const *const model, double *const influenceDistance)
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
int KIM_ComputeArguments_GetCallbackSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus *const supportStatus)
void KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames(int *const numberOfComputeArgumentNames)
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
void KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
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
KIM_LanguageName const KIM_LANGUAGE_NAME_c
int KIM_ComputeArguments_SetCallbackPointer(KIM_ComputeArguments *const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_LanguageName const languageName, func *const fptr, void const *const dataObject)
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
int KIM_Model_GetSpeciesSupportAndCode(KIM_Model const *const model, KIM_SpeciesName const speciesName, int *const speciesIsSupported, int *const code)
int KIM_ComputeArguments_SetArgumentPointerInteger(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, int const *const ptr)
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
int KIM_Model_ComputeArgumentsCreate(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
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_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles
int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const left, KIM_ComputeArgumentName const right)
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_GetNeighborList
KIM_TimeUnit const KIM_TIME_UNIT_ps
#define MY_WARNING(message)
int KIM_ComputeArguments_SetArgumentPointerDouble(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, double const *const ptr)
int KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName(int const index, KIM_ComputeCallbackName *const computeCallbackName)
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
int KIM_Model_ComputeArgumentsDestroy(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
int KIM_SupportStatus_Equal(KIM_SupportStatus const left, KIM_SupportStatus const right)
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
ComputeArgumentName const numberOfParticles
int KIM_Model_Compute(KIM_Model const *const model, KIM_ComputeArguments const *const computeArguments)
int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName(int const index, KIM_ComputeArgumentName *const computeArgumentName)
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
#define MY_ERROR(message)
KIM_SupportStatus const KIM_SUPPORT_STATUS_required
int KIM_ComputeArguments_GetArgumentSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus *const supportStatus)
struct KIM_Model KIM_Model
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
KIM_LengthUnit const KIM_LENGTH_UNIT_A
int KIM_ComputeArgumentName_Equal(KIM_ComputeArgumentName const left, KIM_ComputeArgumentName const right)
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K
KIM_Numbering const KIM_NUMBERING_zeroBased
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing