41 #define NAMESTRLEN 128 43 #define FCCSPACING 5.260 45 #define NCELLSPERSIDE 2 46 #define NCLUSTERPARTS \ 47 (4 * (NCELLSPERSIDE * NCELLSPERSIDE * NCELLSPERSIDE) \ 48 + 6 * (NCELLSPERSIDE * NCELLSPERSIDE) + 3 * (NCELLSPERSIDE) + 1) 51 #define MY_ERROR(message) \ 53 printf("* Error : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \ 57 #define MY_WARNING(message) \ 59 printf("* WARNING : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \ 79 int const numberOfNeighborLists,
80 double const *
const cutoffs,
81 int const neighborListIndex,
82 int const particleNumber,
83 int *
const numberOfNeighbors,
84 int const **
const neighborsOfParticle);
96 double CurrentSpacing;
107 int speciesIsSupported;
113 int number_of_neighbor_lists_cluster_model;
114 double influence_distance_cluster_model;
115 double const * cutoff_cluster_model;
116 double energy_cluster_model = 0.0;
120 int requestedUnitsAccepted;
121 int numberOfModelRoutineNames;
126 int numberOfComputeArgumentNames;
130 int numberOfComputeCallbackNames;
134 printf(
"Please enter valid KIM Model name: \n");
135 error = scanf(
"%s", modelname);
136 if (1 != error) {
MY_ERROR(
"Unable to read model name"); }
146 &requestedUnitsAccepted,
148 if (error)
MY_ERROR(
"KIM_create_model_interface()");
151 if (!requestedUnitsAccepted)
MY_ERROR(
"Must adapt to model units");
155 &numberOfModelRoutineNames);
156 for (i = 0; i < numberOfModelRoutineNames; ++i)
161 model, modelRoutineName, &present, &required);
162 if (error) {
MY_ERROR(
"Unable to get ModelRoutineName."); }
164 if ((present ==
TRUE) && (required ==
TRUE))
179 {
MY_ERROR(
"Unknown required ModelRoutineName found."); }
186 if ((error) || (!speciesIsSupported))
187 {
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");
211 {
MY_ERROR(
"unsupported required argument"); }
224 {
MY_ERROR(
"energy or forces not available"); }
230 &numberOfComputeCallbackNames);
231 for (i = 0; i < numberOfComputeCallbackNames; ++i)
234 i, &computeCallbackName);
235 if (error)
MY_ERROR(
"can't get call back name");
237 computeArguments, computeCallbackName, &supportStatus);
238 if (error)
MY_ERROR(
"can't get call back supportStatus");
242 {
MY_ERROR(
"unsupported required call back"); }
250 &numberOfParticles_cluster)
254 particleSpecies_cluster_model)
258 particleContributing_cluster_model)
262 (
double *) &coords_cluster)
266 &energy_cluster_model)
270 (
double *) &forces_cluster);
271 if (error)
MY_ERROR(
"KIM_setm_data");
281 &number_of_neighbor_lists_cluster_model,
282 &cutoff_cluster_model,
284 if (number_of_neighbor_lists_cluster_model != 1)
285 MY_ERROR(
"too many neighbor lists");
292 &(particleSpecies_cluster_model[0]));
293 if (error)
MY_ERROR(
"KIM_get_species_code");
295 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
300 particleContributing_cluster_model[i] = 1;
306 nl_cluster_model.
NNeighbors = (
int *) malloc(NCLUSTERPARTS *
sizeof(
int));
310 = (
int *) malloc(NCLUSTERPARTS * NCLUSTERPARTS *
sizeof(
int));
314 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
315 printf(
"---------------------------------------------------------------------" 317 printf(
"Results for KIM Model : %s\n", modelname);
319 printf(
"%20s, %20s, %20s\n",
"Energy",
"Force Norm",
"Lattice Spacing");
320 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing;
321 CurrentSpacing += SpacingIncr)
328 &(coords_cluster[0][0]),
329 (*cutoff_cluster_model + cutpad),
334 if (error)
MY_ERROR(
"KIM_model_compute");
338 for (i = 0; i <
DIM * numberOfParticles_cluster; ++i)
339 { force_norm += forces_cluster[i] * forces_cluster[i]; }
340 force_norm = sqrt(force_norm);
343 printf(
"%20.10e, %20.10e, %20.10e\n",
344 energy_cluster_model,
350 if (error) {
MY_ERROR(
"Unable to destroy compute arguments"); }
366 double FCCshifts[4][
DIM];
376 FCCshifts[0][0] = 0.0;
377 FCCshifts[0][1] = 0.0;
378 FCCshifts[0][2] = 0.0;
379 FCCshifts[1][0] = 0.5 * FCCspacing;
380 FCCshifts[1][1] = 0.5 * FCCspacing;
381 FCCshifts[1][2] = 0.0;
382 FCCshifts[2][0] = 0.5 * FCCspacing;
383 FCCshifts[2][1] = 0.0;
384 FCCshifts[2][2] = 0.5 * FCCspacing;
385 FCCshifts[3][0] = 0.0;
386 FCCshifts[3][1] = 0.5 * FCCspacing;
387 FCCshifts[3][2] = 0.5 * FCCspacing;
390 for (i = 0; i < nCellsPerSide; ++i)
392 latVec[0] = ((double) i) * FCCspacing;
393 for (j = 0; j < nCellsPerSide; ++j)
395 latVec[1] = ((double) j) * FCCspacing;
396 for (k = 0; k < nCellsPerSide; ++k)
398 latVec[2] = ((double) k) * FCCspacing;
399 for (m = 0; m < 4; ++
m)
401 for (n = 0; n <
DIM; ++n)
402 { coords[a * DIM + n] = latVec[n] + FCCshifts[
m][n]; }
409 latVec[1] = ((double) i) * FCCspacing;
410 latVec[2] = ((double) j) * FCCspacing;
411 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
413 for (n = 0; n <
DIM; ++n)
414 { coords[a * DIM + n] = latVec[n] + FCCshifts[3][n]; }
417 latVec[0] = ((double) i) * FCCspacing;
419 latVec[2] = ((double) j) * FCCspacing;
420 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
422 for (n = 0; n <
DIM; ++n)
423 { coords[a * DIM + n] = latVec[n] + FCCshifts[2][n]; }
426 latVec[0] = ((double) i) * FCCspacing;
427 latVec[1] = ((double) j) * FCCspacing;
429 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
431 for (n = 0; n <
DIM; ++n)
432 { coords[a * DIM + n] = latVec[n] + FCCshifts[1][n]; }
436 latVec[0] = ((double) i) * FCCspacing;
439 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
442 latVec[1] = ((double) i) * FCCspacing;
444 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
448 latVec[2] = ((double) i) * FCCspacing;
449 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
453 for (n = 0; n <
DIM; ++n)
479 cutoff2 = cutoff * cutoff;
487 for (k = 0; k <
DIM; ++k)
489 dx[k] = coords[j * DIM + k] - coords[i * DIM + k];
495 if ((half && i < j) || (!half && i != j))
504 (*nl).NNeighbors[i] = a;
511 int const numberOfNeighborLists,
512 double const *
const cutoffs,
513 int const neighborListIndex,
514 int const particleNumber,
515 int *
const numberOfNeighbors,
516 int const **
const neighborsOfParticle)
523 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
525 if (neighborListIndex != 0)
return error;
528 *numberOfNeighbors = 0;
530 if ((particleNumber >= numberOfParticles)
531 || (particleNumber < 0))
533 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
538 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
542 = &((*nl).neighborList[(particleNumber) *numberOfParticles]);
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy
The standard Destroy routine.
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_ROUTINE_NAME_GetModelRoutineName(int const index, KIM_ModelRoutineName *const modelRoutineName)
Get the identity of each defined standard ModelRoutineName.
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.
KIM_ChargeUnit const KIM_CHARGE_UNIT_e
The standard electron unit of charge.
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)
int KIM_COMPUTE_ARGUMENT_NAME_GetComputeArgumentName(int const index, KIM_ComputeArgumentName *const computeArgumentName)
Get the identity of each defined standard ComputeArgumentName.
void KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames(int *const numberOfModelRoutineNames)
Get the number of standard ModelRoutineName's defined by the KIM API.
void KIM_Model_Destroy(KIM_Model **const model)
Destroy a previously Model::Create'd object.
int KIM_ComputeArguments_GetArgumentSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus *const supportStatus)
Get the SupportStatus of a ComputeArgumentName.
An Extensible Enumeration for the ModelRoutineName's supported by the KIM API.
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_K
The standard Kelvin unit of temperature.
KIM_SupportStatus const KIM_SUPPORT_STATUS_required
The standard required status.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Create
The standard Create routine.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
The standard partialForces argument.
int KIM_ComputeArguments_SetArgumentPointerDouble(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, double const *const ptr)
Set the data pointer for a ComputeArgumentName.
void KIM_Model_GetInfluenceDistance(KIM_Model const *const model, double *const influenceDistance)
Get the Model's influence distance.
int KIM_Model_ComputeArgumentsCreate(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
Create a new ComputeArguments object for the Model object.
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_SupportStatus_Equal(KIM_SupportStatus const lhs, KIM_SupportStatus const rhs)
Compares SupportStatus objects for equality.
KIM_LengthUnit const KIM_LENGTH_UNIT_A
The standard angstrom unit of length.
KIM_TimeUnit const KIM_TIME_UNIT_ps
The standard picosecond unit of time.
int KIM_ComputeArgumentName_NotEqual(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs)
Compares ComputeArgumentName objects for inequality.
int KIM_ComputeArgumentName_Equal(KIM_ComputeArgumentName const lhs, KIM_ComputeArgumentName const rhs)
Compares ComputeArgumentName objects for equality.
void() KIM_Function(void)
Generic function type.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate
The standard ComputeArgumentsCreate 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.
#define MY_WARNING(message)
struct KIM_ComputeArguments KIM_ComputeArguments
Provides the primary interface to a KIM API ComputeArguments object and is meant to be used by simula...
LengthUnit const m
The standard meter unit of length.
struct KIM_Model KIM_Model
Provides the primary interface to a KIM API Model object and is meant to be used by simulators...
void KIM_COMPUTE_CALLBACK_NAME_GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
KIM_LanguageName const KIM_LANGUAGE_NAME_c
The standard c language.
An Extensible Enumeration for the ComputeCallbackName's supported by the KIM API. ...
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
The standard optional status.
An Extensible Enumeration for the ComputeArgumentName's supported by the KIM API. ...
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
The standard partialEnergy argument.
int KIM_ComputeArguments_GetCallbackSupportStatus(KIM_ComputeArguments const *const computeArguments, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus *const supportStatus)
Get the SupportStatus of a ComputeCallbackName.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing
The standard particleContributing argument.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Refresh
The standard Refresh routine.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
The standard coordinates argument.
An Extensible Enumeration for the SupportStatus's supported by the KIM API.
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
KIM_Numbering const KIM_NUMBERING_zeroBased
The standard zeroBased numbering.
#define MY_ERROR(message)
ComputeArgumentName const numberOfParticles
The standard numberOfParticles argument.
int KIM_ComputeArguments_SetArgumentPointerInteger(KIM_ComputeArguments *const computeArguments, KIM_ComputeArgumentName const computeArgumentName, int const *const ptr)
Set the data pointer for a ComputeArgumentName.
SupportStatus const required
The standard required status.
int KIM_COMPUTE_CALLBACK_NAME_GetComputeCallbackName(int const index, KIM_ComputeCallbackName *const computeCallbackName)
Get the identity of each defined standard ComputeCallbackName.
void KIM_COMPUTE_ARGUMENT_NAME_GetNumberOfComputeArgumentNames(int *const numberOfComputeArgumentNames)
Get the number of standard ComputeArgumentName's defined by the KIM API.
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.
int KIM_Model_ComputeArgumentsDestroy(KIM_Model const *const model, KIM_ComputeArguments **const computeArguments)
Destroy a previously Model::ComputeArgumentsCreate'd object.
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_GetNeighborList
The standard GetNeighborList callback.
LogVerbosity const error
The standard error verbosity.
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
int KIM_Model_Compute(KIM_Model const *const model, KIM_ComputeArguments const *const computeArguments)
Call the Model's MODEL_ROUTINE_NAME::Compute routine.
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
The standard electronvolt unit of energy.
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
The standard Argon species.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
The standard particleSpeciesCodes argument.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles
The standard numberOfParticles argument.
int KIM_ModelRoutineName_Equal(KIM_ModelRoutineName const lhs, KIM_ModelRoutineName const rhs)
Compares ModelRoutineName objects for equality.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute
The standard Compute routine.