44 #include "KIM_ArgumentName.hpp" 45 #include "KIM_CallbackName.hpp" 49 #define NAMESTRLEN 128 51 #define FCCSPACING 5.260 53 #define NCELLSPERSIDE 2 54 #define NCLUSTERPARTS (4*(NCELLSPERSIDE*NCELLSPERSIDE*NCELLSPERSIDE) + \ 55 6*(NCELLSPERSIDE*NCELLSPERSIDE) \ 56 + 3*(NCELLSPERSIDE) + 1) 58 #define MY_ERROR(message) \ 60 std::cout << "* Error : \"" << message << "\" : " \ 61 << __LINE__ << ":" << __FILE__ << std::endl; \ 65 #define MY_WARNING(message) \ 67 std::cout << "* Error : \"" << message << "\" : " \ 68 << __LINE__ << ":" << __FILE__ << std::endl; \ 86 int const numberOfNeighborLists,
87 double const *
const cutoffs,
88 int const neighborListIndex,
int const particleNumber,
89 int *
const numberOfNeighbors,
90 int const **
const neighborsOfParticle);
102 double CurrentSpacing;
103 double cutpad = 0.75;
111 int numberOfSpecies = 1;
116 double influence_distance_cluster_model;
117 int number_of_neighbor_lists;
118 double const * cutoff_cluster_model;
119 double energy_cluster_model;
122 std::string modelname;
125 printf(
"Please enter valid KIM Model name: \n");
126 std::cin >> modelname;
131 int requestedUnitsAccepted;
139 &requestedUnitsAccepted,
147 if (!requestedUnitsAccepted)
149 MY_ERROR(
"Must Adapt to model units");
159 kim_cluster_model->
GetUnits(&lengthUnit, &energyUnit, &chargeUnit,
160 &temperatureUnit, &timeUnit);
162 std::cout <<
"LengthUnit is \"" << lengthUnit.
String() <<
"\"" << std::endl
163 <<
"EnergyUnit is \"" << energyUnit.
String() <<
"\"" << std::endl
164 <<
"ChargeUnit is \"" << chargeUnit.
String() <<
"\"" << std::endl
165 <<
"TemperatureUnit is \"" << temperatureUnit.
String()
167 <<
"TimeUnit is \"" << timeUnit.
String() <<
"\"" << std::endl;
170 int speciesIsSupported;
174 if ((
error) || (!speciesIsSupported))
176 MY_ERROR(
"Species Ar not supported");
183 MY_ERROR(
"Unable to create a ComputeArguments object.");
187 int numberOfComputeArgumentNames;
189 &numberOfComputeArgumentNames);
190 for (
int i=0; i<numberOfComputeArgumentNames; ++i)
197 computeArgumentName, &dataType);
201 MY_ERROR(
"unable to get ComputeArgument SupportStatus");
203 std::cout <<
"ComputeArgument Name \"" 204 << computeArgumentName.
String() <<
"\"" 206 << dataType.
String() <<
"\"" 207 <<
" and has supportStatus \"" 208 << supportStatus.
String() <<
"\"" 218 MY_ERROR(
"unsupported required ComputeArgument");
231 MY_ERROR(
"energy or forces not available");
237 int numberOfComputeCallbackNames;
239 &numberOfComputeCallbackNames);
240 for (
int i=0; i<numberOfComputeCallbackNames; ++i)
248 std::cout <<
"ComputeCallback Name \"" 249 << computeCallbackName.
String() <<
"\"" 250 <<
" has supportStatus \"" 251 << supportStatus.
String() <<
"\"" 257 MY_ERROR(
"unsupported required ComputeCallback");
261 int numberOfParameters;
263 for (
int i=0; i<numberOfParameters; ++i)
266 std::string
const * str;
269 i, &dataType, &extent, &str);
270 std::cout <<
"Parameter No. " << i
271 <<
" has data type \"" << dataType.
String() <<
"\"" 272 <<
" with extent " << extent
273 <<
" and description : " << *str << std::endl;
279 particleSpecies_cluster_model[0] = kim_cluster_model.get_species_code(
"Ar", &
error);
282 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
294 std::cout << std::setiosflags(std::ios::scientific) << std::setprecision(10);
295 std::cout <<
"This is Test : ex_test_Ar_fcc_cluster_cpp\n";
296 std::cout <<
"--------------------------------------------------------------------------------\n";
297 std::cout <<
"Results for KIM Model : " << modelname << std::endl;
299 std::cout << std::setw(20) <<
"Energy" 300 << std::setw(20) <<
"Force Norm" 301 << std::setw(20) <<
"Lattice Spacing" 303 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
309 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
312 error = kim_cluster_model.model_compute();
317 for (i=0; i <
DIM*numberOfParticles_cluster; ++i)
319 force_norm += forces_cluster[i]*forces_cluster[i];
321 force_norm = sqrt(force_norm);
324 std::cout << std::setw(20) << energy_cluster_model
325 << std::setw(20) << force_norm
326 << std::setw(20) << CurrentSpacing
332 error = kim_cluster_model.model_destroy();
346 double FCCshifts[4][
DIM];
356 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
357 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
358 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
359 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
362 for (i = 0; i < nCellsPerSide; ++i)
364 latVec[0] = ((double) i)*FCCspacing;
365 for (j = 0; j < nCellsPerSide; ++j)
367 latVec[1] = ((double) j)*FCCspacing;
368 for (k = 0; k < nCellsPerSide; ++k)
370 latVec[2] = ((double) k)*FCCspacing;
371 for (
m = 0;
m < 4; ++
m)
373 for (n = 0; n <
DIM; ++n)
375 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
383 latVec[1] = ((double) i)*FCCspacing;
384 latVec[2] = ((double) j)*FCCspacing;
385 for (n = 0; n <
DIM; ++n)
387 coords[a*
DIM + n] = latVec[n];
390 for (n = 0; n <
DIM; ++n)
392 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
396 latVec[0] = ((double) i)*FCCspacing;
398 latVec[2] = ((double) j)*FCCspacing;
399 for (n = 0; n <
DIM; ++n)
401 coords[a*
DIM + n] = latVec[n];
404 for (n = 0; n <
DIM; ++n)
406 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
410 latVec[0] = ((double) i)*FCCspacing;
411 latVec[1] = ((double) j)*FCCspacing;
413 for (n = 0; n <
DIM; ++n)
415 coords[a*
DIM + n] = latVec[n];
418 for (n = 0; n <
DIM; ++n)
420 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
425 latVec[0] = ((double) i)*FCCspacing;
428 for (n = 0; n <
DIM; ++n)
430 coords[a*
DIM + n] = latVec[n];
434 latVec[1] = ((double) i)*FCCspacing;
436 for (n = 0; n <
DIM; ++n)
438 coords[a*
DIM + n] = latVec[n];
443 latVec[2] = ((double) i)*FCCspacing;
444 for (n = 0; n <
DIM; ++n)
446 coords[a*
DIM + n] = latVec[n];
451 for (n = 0; n <
DIM; ++n)
484 for (k = 0; k <
DIM; ++k)
486 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
492 if ((half && i < j) || (!half && i != j))
501 (*nl).NNeighbors[i] = a;
508 int const numberOfNeighborLists,
509 double const *
const cutoffs,
510 int const neighborListIndex,
int const particleNumber,
511 int *
const numberOfNeighbors,
512 int const **
const neighborsOfParticle)
519 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
521 if (neighborListIndex != 0)
return error;
524 *numberOfNeighbors = 0;
528 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
533 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
536 *neighborsOfParticle = &((*nl).neighborList[(particleNumber)*
numberOfParticles]);
#define MY_WARNING(message)
std::string const & String() const
static int Create(Numbering const numbering, LengthUnit const requestedLengthUnit, EnergyUnit const requestedEnergyUnit, ChargeUnit const requestedChargeUnit, TemperatureUnit const requestedTemperatureUnit, TimeUnit const requestedTimeUnit, std::string const &modelName, int *const requestedUnitsAccepted, Model **const model)
void GetUnits(LengthUnit *const lengthUnit, EnergyUnit *const energyUnit, ChargeUnit *const chargeUnit, TemperatureUnit *const temperatureUnit, TimeUnit *const timeUnit) const
std::string const & String() const
std::string const & String() const
int GetComputeCallbackName(int const index, ComputeCallbackName *const computeCallbackName)
std::string const & String() const
void GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
std::string const & String() const
void GetNumberOfComputeArgumentNames(int *const numberOfComputeArgumentNames)
int get_cluster_neigh(void *kimmdl, int *mode, int *request, int *part, int *numnei, int **nei1part, double **Rij)
int ComputeArgumentsCreate(ComputeArguments **const computeArguments) const
SupportStatus const required
std::string const & String() const
int GetCallbackSupportStatus(ComputeCallbackName const computeCallbackName, SupportStatus *const supportStatus) const
ComputeArgumentName const partialEnergy
int GetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus *const supportStatus) const
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
ComputeArgumentName const partialForces
std::string const & String() const
std::string const & String() const
void GetNumberOfParameters(int *const numberOfParameters) const
std::string const & String() const
ComputeArgumentName const numberOfParticles
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
#define MY_ERROR(message)
int GetSpeciesSupportAndCode(SpeciesName const speciesName, int *const speciesIsSupported, int *const code) const
Numbering const zeroBased
int GetParameterDataTypeExtentAndDescription(int const index, DataType *const dataType, int *extent, std::string const **const description) const
int GetComputeArgumentDataType(ComputeArgumentName const computeArgumentName, DataType *const dataType)
int GetComputeArgumentName(int const index, ComputeArgumentName *const computeArgumentName)
SupportStatus const optional