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;
105 int speciesIsSupported;
107 int coordinatesShapeCluster[2];
111 int number_of_neighbor_lists_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");
234 particleSpecies_cluster_model[0] = KIM_API_get_species_code(pkim_cluster_model,
"Ar", &
error);
237 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
249 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
250 printf(
"--------------------------------------------------------------------------------\n");
251 printf(
"Results for KIM Model : %s\n", modelname);
253 printf(
"%20s, %20s, %20s\n",
"Energy",
"Force Norm",
"Lattice Spacing");
254 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
260 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
263 error = KIM_API_model_compute(pkim_cluster_model);
268 for (i=0; i <
DIM*numberOfParticles_cluster; ++i)
270 force_norm += forces_cluster[i]*forces_cluster[i];
272 force_norm = sqrt(force_norm);
275 printf(
"%20.10e, %20.10e, %20.10e\n",
276 energy_cluster_model,
286 error = KIM_API_model_destroy(pkim_cluster_model);
290 KIM_API_free(&pkim_cluster_model, &
error);
300 double FCCshifts[4][
DIM];
310 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
311 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
312 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
313 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
316 for (i = 0; i < nCellsPerSide; ++i)
318 latVec[0] = ((double) i)*FCCspacing;
319 for (j = 0; j < nCellsPerSide; ++j)
321 latVec[1] = ((double) j)*FCCspacing;
322 for (k = 0; k < nCellsPerSide; ++k)
324 latVec[2] = ((double) k)*FCCspacing;
325 for (
m = 0;
m < 4; ++
m)
327 for (n = 0; n <
DIM; ++n)
329 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
337 latVec[1] = ((double) i)*FCCspacing;
338 latVec[2] = ((double) j)*FCCspacing;
339 for (n = 0; n <
DIM; ++n)
341 coords[a*
DIM + n] = latVec[n];
344 for (n = 0; n <
DIM; ++n)
346 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
350 latVec[0] = ((double) i)*FCCspacing;
352 latVec[2] = ((double) j)*FCCspacing;
353 for (n = 0; n <
DIM; ++n)
355 coords[a*
DIM + n] = latVec[n];
358 for (n = 0; n <
DIM; ++n)
360 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
364 latVec[0] = ((double) i)*FCCspacing;
365 latVec[1] = ((double) j)*FCCspacing;
367 for (n = 0; n <
DIM; ++n)
369 coords[a*
DIM + n] = latVec[n];
372 for (n = 0; n <
DIM; ++n)
374 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
379 latVec[0] = ((double) i)*FCCspacing;
382 for (n = 0; n <
DIM; ++n)
384 coords[a*
DIM + n] = latVec[n];
388 latVec[1] = ((double) i)*FCCspacing;
390 for (n = 0; n <
DIM; ++n)
392 coords[a*
DIM + n] = latVec[n];
397 latVec[2] = ((double) i)*FCCspacing;
398 for (n = 0; n <
DIM; ++n)
400 coords[a*
DIM + n] = latVec[n];
405 for (n = 0; n <
DIM; ++n)
438 for (k = 0; k <
DIM; ++k)
440 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
446 if ((half && i < j) || (!half && i != j))
455 (*nl).NNeighbors[i] = a;
462 int const numberOfNeighborLists,
463 double const *
const cutoffs,
464 int const neighborListIndex,
465 int const particleNumber,
int *
const numberOfNeighbors,
466 int const **
const neighborsOfParticle)
473 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
475 if (neighborListIndex != 0)
return error;
478 *numberOfNeighbors = 0;
482 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
487 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
490 *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)
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)
void KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
#define MY_WARNING(message)
KIM_ChargeUnit const KIM_CHARGE_UNIT_e
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
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_Model_ComputeArgumentsCreate(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
#define MY_ERROR(message)
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)
int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const left, KIM_ComputeArgumentName const right)
KIM_TimeUnit const KIM_TIME_UNIT_ps
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_SupportStatus_Equal(KIM_SupportStatus const left, KIM_SupportStatus const right)
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
ComputeArgumentName const numberOfParticles
int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName(int const index, KIM_ComputeArgumentName *const computeArgumentName)
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
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