37#define NAMESTRFMT "%127s"
39#define FCCSPACING 5.260
41#define NCELLSPERSIDE 2
42#define NCLUSTERPARTS \
43 (4 * (NCELLSPERSIDE * NCELLSPERSIDE * NCELLSPERSIDE) \
44 + 6 * (NCELLSPERSIDE * NCELLSPERSIDE) + 3 * (NCELLSPERSIDE) + 1)
47#define MY_ERROR(message) \
49 printf("* Error : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \
53#define MY_WARNING(message) \
55 printf("* WARNING : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \
69 int numberOfParticles,
75 int const numberOfNeighborLists,
76 double const *
const cutoffs,
77 int const neighborListIndex,
78 int const particleNumber,
79 int *
const numberOfNeighbors,
80 int const **
const neighborsOfParticle);
92 double CurrentSpacing;
103 int speciesIsSupported;
109 int number_of_neighbor_lists_cluster_model;
110 double influence_distance_cluster_model;
111 double const * cutoff_cluster_model;
112 double energy_cluster_model = 0.0;
116 int requestedUnitsAccepted;
117 int numberOfModelRoutineNames;
122 int numberOfComputeArgumentNames;
126 int numberOfComputeCallbackNames;
130 printf(
"Please enter valid KIM Model name: \n");
142 &requestedUnitsAccepted,
147 if (!requestedUnitsAccepted)
MY_ERROR(
"Must adapt to model units");
151 &numberOfModelRoutineNames);
152 for (i = 0; i < numberOfModelRoutineNames; ++i)
157 model, modelRoutineName, &present, &required);
160 if ((present ==
TRUE) && (required ==
TRUE))
176 MY_ERROR(
"Unknown required ModelRoutineName found.");
184 if ((
error) || (!speciesIsSupported))
186 MY_ERROR(
"Species Ar not supported");
194 &numberOfComputeArgumentNames);
195 for (i = 0; i < numberOfComputeArgumentNames; ++i)
198 i, &computeArgumentName);
201 computeArguments, computeArgumentName, &supportStatus);
212 MY_ERROR(
"unsupported required argument");
227 MY_ERROR(
"energy or forces not available");
234 &numberOfComputeCallbackNames);
235 for (i = 0; i < numberOfComputeCallbackNames; ++i)
238 i, &computeCallbackName);
241 computeArguments, computeCallbackName, &supportStatus);
247 MY_ERROR(
"unsupported required call back");
256 &numberOfParticles_cluster)
260 particleSpecies_cluster_model)
264 particleContributing_cluster_model)
268 (
double *) &coords_cluster)
272 &energy_cluster_model)
276 (
double *) &forces_cluster);
287 &number_of_neighbor_lists_cluster_model,
288 &cutoff_cluster_model,
290 if (number_of_neighbor_lists_cluster_model != 1)
291 MY_ERROR(
"too many neighbor lists");
298 &(particleSpecies_cluster_model[0]));
301 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
306 particleContributing_cluster_model[i] = 1;
320 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
321 printf(
"---------------------------------------------------------------------"
323 printf(
"Results for KIM Model : %s\n", modelname);
325 printf(
"%20s, %20s, %20s\n",
"Energy",
"Force Norm",
"Lattice Spacing");
326 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing;
327 CurrentSpacing += SpacingIncr)
334 &(coords_cluster[0][0]),
335 (*cutoff_cluster_model + cutpad),
344 for (i = 0; i <
DIM * numberOfParticles_cluster; ++i)
346 force_norm += forces_cluster[i] * forces_cluster[i];
348 force_norm = sqrt(force_norm);
351 printf(
"%20.10e, %20.10e, %20.10e\n",
352 energy_cluster_model,
358 if (
error) {
MY_ERROR(
"Unable to destroy compute arguments"); }
374 double FCCshifts[4][
DIM];
384 FCCshifts[0][0] = 0.0;
385 FCCshifts[0][1] = 0.0;
386 FCCshifts[0][2] = 0.0;
387 FCCshifts[1][0] = 0.5 * FCCspacing;
388 FCCshifts[1][1] = 0.5 * FCCspacing;
389 FCCshifts[1][2] = 0.0;
390 FCCshifts[2][0] = 0.5 * FCCspacing;
391 FCCshifts[2][1] = 0.0;
392 FCCshifts[2][2] = 0.5 * FCCspacing;
393 FCCshifts[3][0] = 0.0;
394 FCCshifts[3][1] = 0.5 * FCCspacing;
395 FCCshifts[3][2] = 0.5 * FCCspacing;
398 for (i = 0; i < nCellsPerSide; ++i)
400 latVec[0] = ((double) i) * FCCspacing;
401 for (j = 0; j < nCellsPerSide; ++j)
403 latVec[1] = ((double) j) * FCCspacing;
404 for (k = 0; k < nCellsPerSide; ++k)
406 latVec[2] = ((double) k) * FCCspacing;
407 for (m = 0; m < 4; ++m)
409 for (n = 0; n <
DIM; ++n)
411 coords[a *
DIM + n] = latVec[n] + FCCshifts[m][n];
419 latVec[1] = ((double) i) * FCCspacing;
420 latVec[2] = ((double) j) * FCCspacing;
421 for (n = 0; n <
DIM; ++n) { coords[a *
DIM + n] = latVec[n]; }
423 for (n = 0; n <
DIM; ++n)
425 coords[a *
DIM + n] = latVec[n] + FCCshifts[3][n];
429 latVec[0] = ((double) i) * FCCspacing;
431 latVec[2] = ((double) j) * FCCspacing;
432 for (n = 0; n <
DIM; ++n) { coords[a *
DIM + n] = latVec[n]; }
434 for (n = 0; n <
DIM; ++n)
436 coords[a *
DIM + n] = latVec[n] + FCCshifts[2][n];
440 latVec[0] = ((double) i) * FCCspacing;
441 latVec[1] = ((double) j) * FCCspacing;
443 for (n = 0; n <
DIM; ++n) { coords[a *
DIM + n] = latVec[n]; }
445 for (n = 0; n <
DIM; ++n)
447 coords[a *
DIM + n] = latVec[n] + FCCshifts[1][n];
452 latVec[0] = ((double) i) * FCCspacing;
455 for (n = 0; n <
DIM; ++n) { coords[a *
DIM + n] = latVec[n]; }
458 latVec[1] = ((double) i) * FCCspacing;
460 for (n = 0; n <
DIM; ++n) { coords[a *
DIM + n] = latVec[n]; }
464 latVec[2] = ((double) i) * FCCspacing;
465 for (n = 0; n <
DIM; ++n) { coords[a *
DIM + n] = latVec[n]; }
469 for (n = 0; n <
DIM; ++n)
480 int numberOfParticles,
497 cutoff2 = cutoff * cutoff;
499 for (i = 0; i < numberOfParticles; ++i)
502 for (j = 0; j < numberOfParticles; ++j)
505 for (k = 0; k <
DIM; ++k)
507 dx[k] = coords[j *
DIM + k] - coords[i *
DIM + k];
513 if ((half && i < j) || (!half && i != j))
522 (*nl).NNeighbors[i] = a;
529 int const numberOfNeighborLists,
530 double const *
const cutoffs,
531 int const neighborListIndex,
532 int const particleNumber,
533 int *
const numberOfNeighbors,
534 int const **
const neighborsOfParticle)
541 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
543 if (neighborListIndex != 0)
return error;
546 *numberOfNeighbors = 0;
548 if ((particleNumber >= numberOfParticles)
549 || (particleNumber < 0))
551 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
556 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
560 = &((*nl).neighborList[(particleNumber) *numberOfParticles]);
KIM_ChargeUnit const KIM_CHARGE_UNIT_e
The standard electron unit of charge.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles
The standard numberOfParticles argument.
void KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames(int *const numberOfComputeArgumentNames)
KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing
The standard particleContributing argument.
int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs)
Compares ComputeArgumentName objects for inequality.
int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName(int const index, KIM_ComputeArgumentName *const computeArgumentName)
Get the identity of each defined standard ComputeArgumentName.
int KIM_ComputeArgumentName_Equal(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs)
Compares ComputeArgumentName objects for equality.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
The standard coordinates argument.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
The standard particleSpeciesCodes argument.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
The standard partialForces argument.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
The standard partialEnergy argument.
int KIM_ComputeArguments_SetArgumentPointerDouble(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, double const *const ptr)
Set the data pointer for a ComputeArgumentName.
int KIM_ComputeArguments_SetCallbackPointer(KIM_ComputeArguments *const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_LanguageName const languageName, KIM_Function *const fptr, void *const dataObject)
Set the function pointer for a ComputeCallbackName.
struct KIM_ComputeArguments KIM_ComputeArguments
Provides the primary interface to a KIM API ComputeArguments object and is meant to be used by simula...
int KIM_ComputeArguments_GetArgumentSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus *const supportStatus)
Get the SupportStatus of a ComputeArgumentName.
int KIM_ComputeArguments_GetCallbackSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus *const supportStatus)
Get the SupportStatus of a ComputeCallbackName.
int KIM_ComputeArguments_SetArgumentPointerInteger(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, int const *const ptr)
Set the data pointer for a ComputeArgumentName.
void KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_GetNeighborList
The standard GetNeighborList callback.
int KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName(int const index, KIM_ComputeCallbackName *const computeCallbackName)
Get the identity of each defined standard ComputeCallbackName.
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
The standard electronvolt unit of energy.
void() KIM_Function(void)
Generic function type.
KIM_LanguageName const KIM_LANGUAGE_NAME_c
The standard c language.
KIM_LengthUnit const KIM_LENGTH_UNIT_A
The standard angstrom unit of length.
void KIM_Model_GetInfluenceDistance(KIM_Model const *const model, double *const influenceDistance)
Get the Model's influence distance.
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)
Create a new KIM API Model object.
int KIM_Model_IsRoutinePresent(KIM_Model const *const model, KIM_ModelRoutineName const modelRoutineName, int *const present, int *const required)
Determine presence and required status of the given ModelRoutineName.
int KIM_Model_GetSpeciesSupportAndCode(KIM_Model const *const model, KIM_SpeciesName const speciesName, int *const speciesIsSupported, int *const code)
Get the Model's support and code for the requested SpeciesName.
int KIM_Model_ComputeArgumentsCreate(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
Create a new ComputeArguments object for the Model object.
int KIM_Model_ComputeArgumentsDestroy(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
Destroy a previously Model::ComputeArgumentsCreate'd object.
void KIM_Model_GetNeighborListPointers(KIM_Model const *const model, int *const numberOfNeighborLists, double const **const cutoffs, int const **const modelWillNotRequestNeighborsOfNoncontributingParticles)
Get the Model's neighbor list information.
struct KIM_Model KIM_Model
Provides the primary interface to a KIM API Model object and is meant to be used by simulators.
int KIM_Model_Compute(KIM_Model const *const model, KIM_ComputeArguments const *const computeArguments)
Call the Model's MODEL_ROUTINE_NAME::Compute routine.
void KIM_Model_Destroy(KIM_Model **const model)
Destroy a previously Model::Create'd object.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy
The standard Destroy routine.
int KIM_ModelRoutineName_Equal(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs)
Compares ModelRoutineName objects for equality.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Refresh
The standard Refresh routine.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute
The standard Compute routine.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Create
The standard Create routine.
int KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(int const index, KIM_ModelRoutineName *const modelRoutineName)
Get the identity of each defined standard ModelRoutineName.
void KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames(int *const numberOfModelRoutineNames)
Get the number of standard ModelRoutineName's defined by the KIM API.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
KIM_Numbering const KIM_NUMBERING_zeroBased
The standard zeroBased numbering.
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
The standard Argon species.
int KIM_SupportStatus_Equal(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs)
Compares SupportStatus objects for equality.
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
The standard optional status.
KIM_SupportStatus const KIM_SUPPORT_STATUS_required
The standard required status.
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K
The standard Kelvin unit of temperature.
KIM_TimeUnit const KIM_TIME_UNIT_ps
The standard picosecond unit of time.
#define MY_ERROR(message)
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
#define MY_WARNING(message)
int get_cluster_neigh(void *const dataObject, int const numberOfNeighborLists, double const *const cutoffs, int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle)
An Extensible Enumeration for the ComputeArgumentName's supported by the KIM API.
An Extensible Enumeration for the ComputeCallbackName's supported by the KIM API.
An Extensible Enumeration for the ModelRoutineName's supported by the KIM API.
An Extensible Enumeration for the SupportStatus's supported by the KIM API.