36 #define NAMESTRLEN 128 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__); \ 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");
132 if (1 != error) {
MY_ERROR(
"Unable to read model name"); }
142 &requestedUnitsAccepted,
144 if (error)
MY_ERROR(
"KIM_create_model_interface()");
147 if (!requestedUnitsAccepted)
MY_ERROR(
"Must adapt to model units");
151 &numberOfModelRoutineNames);
152 for (i = 0; i < numberOfModelRoutineNames; ++i)
157 model, modelRoutineName, &present, &required);
158 if (error) {
MY_ERROR(
"Unable to get ModelRoutineName."); }
160 if ((present ==
TRUE) && (required ==
TRUE))
176 MY_ERROR(
"Unknown required ModelRoutineName found.");
184 if ((error) || (!speciesIsSupported))
186 MY_ERROR(
"Species Ar not supported");
190 if (error) {
MY_ERROR(
"KIM_Model_ComputeArgumentsCreate"); }
194 &numberOfComputeArgumentNames);
195 for (i = 0; i < numberOfComputeArgumentNames; ++i)
198 i, &computeArgumentName);
199 if (error)
MY_ERROR(
"can't get argument name");
201 computeArguments, computeArgumentName, &supportStatus);
202 if (error)
MY_ERROR(
"can't get argument 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);
239 if (error)
MY_ERROR(
"can't get call back name");
241 computeArguments, computeCallbackName, &supportStatus);
242 if (error)
MY_ERROR(
"can't get call back 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);
277 if (error)
MY_ERROR(
"KIM_setm_data");
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]));
299 if (error)
MY_ERROR(
"KIM_get_species_code");
301 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
306 particleContributing_cluster_model[i] = 1;
312 nl_cluster_model.
NNeighbors = (
int *) malloc(NCLUSTERPARTS *
sizeof(
int));
316 = (
int *) malloc(NCLUSTERPARTS * NCLUSTERPARTS *
sizeof(
int));
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),
340 if (error)
MY_ERROR(
"KIM_model_compute");
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)
497 cutoff2 = cutoff * cutoff;
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]);
struct KIM_ComputeArguments KIM_ComputeArguments
Provides the primary interface to a KIM API ComputeArguments object and is meant to be used by simula...
void KIM_Model_GetInfluenceDistance(KIM_Model const *const model, double *const influenceDistance)
Get the Model's influence distance.
int KIM_ComputeArgumentName_Equal(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs)
Compares ComputeArgumentName objects for equality.
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
The standard optional status.
int KIM_ComputeArguments_GetCallbackSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus *const supportStatus)
Get the SupportStatus of a ComputeCallbackName.
void KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames(int *const numberOfComputeArgumentNames)
Get the number of standard ComputeArgumentName's defined by the KIM API.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
The standard coordinates argument.
void KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
void KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames(int *const numberOfModelRoutineNames)
Get the number of standard ModelRoutineName's defined by the KIM API.
void() KIM_Function(void)
Generic function type.
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)
void KIM_Model_Destroy(KIM_Model **const model)
Destroy a previously Model::Create'd object.
KIM_ChargeUnit const KIM_CHARGE_UNIT_e
The standard electron unit of charge.
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
An Extensible Enumeration for the ComputeArgumentName's supported by the KIM API. ...
KIM_LanguageName const KIM_LANGUAGE_NAME_c
The standard c language.
int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs)
Compares ComputeArgumentName objects for inequality.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
The standard partialForces argument.
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.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
int KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(int const index, KIM_ModelRoutineName *const modelRoutineName)
Get the identity of each defined standard ModelRoutineName.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
The standard particleSpeciesCodes argument.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute
The standard Compute routine.
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.
An Extensible Enumeration for the SupportStatus's supported by the KIM API.
int KIM_ComputeArguments_SetArgumentPointerInteger(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, int const *const ptr)
Set the data pointer for a ComputeArgumentName.
int KIM_ModelRoutineName_Equal(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs)
Compares ModelRoutineName objects for equality.
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
The standard Argon species.
SupportStatus const required
The standard required status.
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.
int KIM_Model_ComputeArgumentsCreate(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
Create a new ComputeArguments object for the Model object.
#define MY_WARNING(message)
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy
The standard Destroy routine.
An Extensible Enumeration for the ModelRoutineName's supported by the KIM API.
LengthUnit const m
The standard meter unit of length.
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.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles
The standard numberOfParticles argument.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Create
The standard Create routine.
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_GetNeighborList
The standard GetNeighborList callback.
KIM_TimeUnit const KIM_TIME_UNIT_ps
The standard picosecond unit of time.
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_COMPUTE_CALLBACK_NAME_GetComputeCallbackName(int const index, KIM_ComputeCallbackName *const computeCallbackName)
Get the identity of each defined standard ComputeCallbackName.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
An Extensible Enumeration for the ComputeCallbackName's supported by the KIM API. ...
int KIM_Model_ComputeArgumentsDestroy(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
Destroy a previously Model::ComputeArgumentsCreate'd object.
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
The standard electronvolt unit of energy.
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.
ComputeArgumentName const numberOfParticles
The standard numberOfParticles argument.
int KIM_Model_Compute(KIM_Model const *const model, KIM_ComputeArguments const *const computeArguments)
Call the Model's MODEL_ROUTINE_NAME::Compute routine.
int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName(int const index, KIM_ComputeArgumentName *const computeArgumentName)
Get the identity of each defined standard ComputeArgumentName.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
The standard partialEnergy argument.
#define MY_ERROR(message)
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Refresh
The standard Refresh routine.
KIM_SupportStatus const KIM_SUPPORT_STATUS_required
The standard required status.
int KIM_ComputeArguments_GetArgumentSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus *const supportStatus)
Get the SupportStatus of a ComputeArgumentName.
struct KIM_Model KIM_Model
Provides the primary interface to a KIM API Model object and is meant to be used by simulators...
KIM_LengthUnit const KIM_LENGTH_UNIT_A
The standard angstrom unit of length.
LogVerbosity const error
The standard error verbosity.
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K
The standard Kelvin unit of temperature.
int KIM_SupportStatus_Equal(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs)
Compares SupportStatus objects for equality.
KIM_Numbering const KIM_NUMBERING_zeroBased
The standard zeroBased numbering.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing
The standard particleContributing argument.