41 #define NAMESTRLEN 128 42 #define NAMESTRFMT "%127s" 44 #define FCCSPACING 5.260 46 #define NCELLSPERSIDE 2 47 #define NCLUSTERPARTS \ 48 (4 * (NCELLSPERSIDE * NCELLSPERSIDE * NCELLSPERSIDE) \ 49 + 6 * (NCELLSPERSIDE * NCELLSPERSIDE) + 3 * (NCELLSPERSIDE) + 1) 52 #define MY_ERROR(message) \ 54 printf("* Error : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \ 58 #define MY_WARNING(message) \ 60 printf("* WARNING : \"%s\" %d:%s\n", message, __LINE__, __FILE__); \ 80 int const numberOfNeighborLists,
81 double const *
const cutoffs,
82 int const neighborListIndex,
83 int const particleNumber,
84 int *
const numberOfNeighbors,
85 int const **
const neighborsOfParticle);
97 double CurrentSpacing;
108 int speciesIsSupported;
114 int number_of_neighbor_lists_cluster_model;
115 double influence_distance_cluster_model;
116 double const * cutoff_cluster_model;
117 double energy_cluster_model = 0.0;
121 int requestedUnitsAccepted;
122 int numberOfModelRoutineNames;
127 int numberOfComputeArgumentNames;
131 int numberOfComputeCallbackNames;
135 printf(
"Please enter valid KIM Model name: \n");
137 if (1 != error) {
MY_ERROR(
"Unable to read model name"); }
147 &requestedUnitsAccepted,
149 if (error)
MY_ERROR(
"KIM_create_model_interface()");
152 if (!requestedUnitsAccepted)
MY_ERROR(
"Must adapt to model units");
156 &numberOfModelRoutineNames);
157 for (i = 0; i < numberOfModelRoutineNames; ++i)
162 model, modelRoutineName, &present, &required);
163 if (error) {
MY_ERROR(
"Unable to get ModelRoutineName."); }
165 if ((present ==
TRUE) && (required ==
TRUE))
181 MY_ERROR(
"Unknown required ModelRoutineName found.");
189 if ((error) || (!speciesIsSupported))
191 MY_ERROR(
"Species Ar not supported");
195 if (error) {
MY_ERROR(
"KIM_Model_ComputeArgumentsCreate"); }
199 &numberOfComputeArgumentNames);
200 for (i = 0; i < numberOfComputeArgumentNames; ++i)
203 i, &computeArgumentName);
204 if (error)
MY_ERROR(
"can't get argument name");
206 computeArguments, computeArgumentName, &supportStatus);
207 if (error)
MY_ERROR(
"can't get argument supportStatus");
217 MY_ERROR(
"unsupported required argument");
232 MY_ERROR(
"energy or forces not available");
239 &numberOfComputeCallbackNames);
240 for (i = 0; i < numberOfComputeCallbackNames; ++i)
243 i, &computeCallbackName);
244 if (error)
MY_ERROR(
"can't get call back name");
246 computeArguments, computeCallbackName, &supportStatus);
247 if (error)
MY_ERROR(
"can't get call back supportStatus");
252 MY_ERROR(
"unsupported required call back");
261 &numberOfParticles_cluster)
265 particleSpecies_cluster_model)
269 particleContributing_cluster_model)
273 (
double *) &coords_cluster)
277 &energy_cluster_model)
281 (
double *) &forces_cluster);
282 if (error)
MY_ERROR(
"KIM_setm_data");
292 &number_of_neighbor_lists_cluster_model,
293 &cutoff_cluster_model,
295 if (number_of_neighbor_lists_cluster_model != 1)
296 MY_ERROR(
"too many neighbor lists");
303 &(particleSpecies_cluster_model[0]));
304 if (error)
MY_ERROR(
"KIM_get_species_code");
306 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
311 particleContributing_cluster_model[i] = 1;
317 nl_cluster_model.
NNeighbors = (
int *) malloc(NCLUSTERPARTS *
sizeof(
int));
321 = (
int *) malloc(NCLUSTERPARTS * NCLUSTERPARTS *
sizeof(
int));
325 printf(
"This is Test : ex_test_Ar_fcc_cluster\n");
326 printf(
"---------------------------------------------------------------------" 328 printf(
"Results for KIM Model : %s\n", modelname);
330 printf(
"%20s, %20s, %20s\n",
"Energy",
"Force Norm",
"Lattice Spacing");
331 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing;
332 CurrentSpacing += SpacingIncr)
339 &(coords_cluster[0][0]),
340 (*cutoff_cluster_model + cutpad),
345 if (error)
MY_ERROR(
"KIM_model_compute");
349 for (i = 0; i <
DIM * numberOfParticles_cluster; ++i)
351 force_norm += forces_cluster[i] * forces_cluster[i];
353 force_norm = sqrt(force_norm);
356 printf(
"%20.10e, %20.10e, %20.10e\n",
357 energy_cluster_model,
363 if (error) {
MY_ERROR(
"Unable to destroy compute arguments"); }
379 double FCCshifts[4][
DIM];
389 FCCshifts[0][0] = 0.0;
390 FCCshifts[0][1] = 0.0;
391 FCCshifts[0][2] = 0.0;
392 FCCshifts[1][0] = 0.5 * FCCspacing;
393 FCCshifts[1][1] = 0.5 * FCCspacing;
394 FCCshifts[1][2] = 0.0;
395 FCCshifts[2][0] = 0.5 * FCCspacing;
396 FCCshifts[2][1] = 0.0;
397 FCCshifts[2][2] = 0.5 * FCCspacing;
398 FCCshifts[3][0] = 0.0;
399 FCCshifts[3][1] = 0.5 * FCCspacing;
400 FCCshifts[3][2] = 0.5 * FCCspacing;
403 for (i = 0; i < nCellsPerSide; ++i)
405 latVec[0] = ((double) i) * FCCspacing;
406 for (j = 0; j < nCellsPerSide; ++j)
408 latVec[1] = ((double) j) * FCCspacing;
409 for (k = 0; k < nCellsPerSide; ++k)
411 latVec[2] = ((double) k) * FCCspacing;
412 for (m = 0; m < 4; ++
m)
414 for (n = 0; n <
DIM; ++n)
416 coords[a * DIM + n] = latVec[n] + FCCshifts[
m][n];
424 latVec[1] = ((double) i) * FCCspacing;
425 latVec[2] = ((double) j) * FCCspacing;
426 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
428 for (n = 0; n <
DIM; ++n)
430 coords[a * DIM + n] = latVec[n] + FCCshifts[3][n];
434 latVec[0] = ((double) i) * FCCspacing;
436 latVec[2] = ((double) j) * FCCspacing;
437 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
439 for (n = 0; n <
DIM; ++n)
441 coords[a * DIM + n] = latVec[n] + FCCshifts[2][n];
445 latVec[0] = ((double) i) * FCCspacing;
446 latVec[1] = ((double) j) * FCCspacing;
448 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
450 for (n = 0; n <
DIM; ++n)
452 coords[a * DIM + n] = latVec[n] + FCCshifts[1][n];
457 latVec[0] = ((double) i) * FCCspacing;
460 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
463 latVec[1] = ((double) i) * FCCspacing;
465 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
469 latVec[2] = ((double) i) * FCCspacing;
470 for (n = 0; n <
DIM; ++n) { coords[a * DIM + n] = latVec[n]; }
474 for (n = 0; n <
DIM; ++n)
502 cutoff2 = cutoff * cutoff;
510 for (k = 0; k <
DIM; ++k)
512 dx[k] = coords[j * DIM + k] - coords[i * DIM + k];
518 if ((half && i < j) || (!half && i != j))
527 (*nl).NNeighbors[i] = a;
534 int const numberOfNeighborLists,
535 double const *
const cutoffs,
536 int const neighborListIndex,
537 int const particleNumber,
538 int *
const numberOfNeighbors,
539 int const **
const neighborsOfParticle)
546 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
548 if (neighborListIndex != 0)
return error;
551 *numberOfNeighbors = 0;
553 if ((particleNumber >= numberOfParticles)
554 || (particleNumber < 0))
556 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
561 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
565 = &((*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.