41 #define NAMESTRLEN 128 43 #define FCCSPACING 5.260 45 #define NCELLSPERSIDE 2 46 #define NCLUSTERPARTS (4*(NCELLSPERSIDE*NCELLSPERSIDE*NCELLSPERSIDE) + \ 47 6*(NCELLSPERSIDE*NCELLSPERSIDE) \ 48 + 3*(NCELLSPERSIDE) + 1) 50 #define MY_ERROR(message) \ 52 std::cout << "* Error : \"" << message << "\" : " \ 53 << __LINE__ << ":" << __FILE__ << std::endl; \ 57 #define MY_WARNING(message) \ 59 std::cout << "* Error : \"" << message << "\" : " \ 60 << __LINE__ << ":" << __FILE__ << std::endl; \ 75 double cutoff, NeighList* nl);
78 int const numberOfCutoffs,
double const *
const cutoffs,
79 int const neighborListIndex,
int const particleNumber,
80 int *
const numberOfNeighbors,
81 int const **
const neighborsOfParticle);
93 double CurrentSpacing;
105 NeighList nl_cluster_model;
107 double influence_distance_cluster_model;
108 int number_of_cutoffs;
109 double const * cutoff_cluster_model;
110 double energy_cluster_model;
113 std::string modelname;
116 printf(
"Please enter valid KIM Model name: \n");
117 std::cin >> modelname;
122 int requestedUnitsAccepted;
130 &requestedUnitsAccepted,
138 if (!requestedUnitsAccepted)
140 MY_ERROR(
"Must Adapt to model units");
150 kim_cluster_model->
GetUnits(&lengthUnit, &energyUnit, &chargeUnit,
151 &temperatureUnit, &timeUnit);
153 std::cout <<
"LengthUnit is \"" << lengthUnit.
String() <<
"\"" << std::endl
154 <<
"EnergyUnit is \"" << energyUnit.
String() <<
"\"" << std::endl
155 <<
"ChargeUnit is \"" << chargeUnit.
String() <<
"\"" << std::endl
156 <<
"TemperatureUnit is \"" << temperatureUnit.
String()
158 <<
"TimeUnit is \"" << timeUnit.
String() <<
"\"" << std::endl;
161 int speciesIsSupported;
165 if ((
error) || (!speciesIsSupported))
167 MY_ERROR(
"Species Ar not supported");
174 MY_ERROR(
"Unable to create a ComputeArguments object.");
178 int numberOfComputeArgumentNames;
180 &numberOfComputeArgumentNames);
181 for (
int i=0; i<numberOfComputeArgumentNames; ++i)
188 computeArgumentName, &dataType);
192 MY_ERROR(
"unable to get ComputeArgument SupportStatus");
194 std::cout <<
"ComputeArgument Name \"" 195 << computeArgumentName.
String() <<
"\"" 197 << dataType.
String() <<
"\"" 198 <<
" and has supportStatus \"" 199 << supportStatus.
String() <<
"\"" 209 MY_ERROR(
"unsupported required ComputeArgument");
222 MY_ERROR(
"energy or forces not available");
228 int numberOfComputeCallbackNames;
230 &numberOfComputeCallbackNames);
231 for (
int i=0; i<numberOfComputeCallbackNames; ++i)
239 std::cout <<
"ComputeCallback Name \"" 240 << computeCallbackName.
String() <<
"\"" 241 <<
" has supportStatus \"" 242 << supportStatus.
String() <<
"\"" 248 MY_ERROR(
"unsupported required ComputeCallback");
252 int numberOfParameters;
254 for (
int i=0; i<numberOfParameters; ++i)
257 std::string
const * str;
260 i, &dataType, &extent, &str);
261 std::cout <<
"Parameter No. " << i
262 <<
" has data type \"" << dataType.
String() <<
"\"" 263 <<
" with extent " << extent
264 <<
" and description : " << *str << std::endl;
271 (
int *) &numberOfParticles_cluster)
274 particleSpecies_cluster_model)
277 particleContributing_cluster_model)
294 &cutoff_cluster_model);
295 if (number_of_cutoffs != 1)
MY_ERROR(
"too many cutoffs");
298 int isSpeciesSupported;
302 &(particleSpecies_cluster_model[0]));
305 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
308 particleContributing_cluster_model[i] = 1;
314 if (NULL==nl_cluster_model.NNeighbors)
MY_ERROR(
"new unsuccessful");
317 if (NULL==nl_cluster_model.neighborList)
MY_ERROR(
"new unsuccessful");
320 std::cout << std::setiosflags(std::ios::scientific) << std::setprecision(10);
321 std::cout <<
"This is Test : ex_test_Ar_fcc_cluster_cpp\n";
322 std::cout <<
"--------------------------------------------------------------------------------\n";
323 std::cout <<
"Results for KIM Model : " << modelname << std::endl;
325 std::cout << std::setw(20) <<
"Energy" 326 << std::setw(20) <<
"Force Norm" 327 << std::setw(20) <<
"Lattice Spacing" 329 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
335 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
343 for (i=0; i <
DIM*numberOfParticles_cluster; ++i)
345 force_norm += forces_cluster[i]*forces_cluster[i];
347 force_norm = sqrt(force_norm);
350 std::cout << std::setw(20) << energy_cluster_model
351 << std::setw(20) << force_norm
352 << std::setw(20) << CurrentSpacing
360 MY_ERROR(
"Unable to destroy compute arguments");
367 delete [] nl_cluster_model.NNeighbors;
368 delete [] nl_cluster_model.neighborList;
377 double FCCshifts[4][
DIM];
387 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
388 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
389 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
390 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
393 for (i = 0; i < nCellsPerSide; ++i)
395 latVec[0] = ((double) i)*FCCspacing;
396 for (j = 0; j < nCellsPerSide; ++j)
398 latVec[1] = ((double) j)*FCCspacing;
399 for (k = 0; k < nCellsPerSide; ++k)
401 latVec[2] = ((double) k)*FCCspacing;
402 for (
m = 0;
m < 4; ++
m)
404 for (n = 0; n <
DIM; ++n)
406 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
414 latVec[1] = ((double) i)*FCCspacing;
415 latVec[2] = ((double) j)*FCCspacing;
416 for (n = 0; n <
DIM; ++n)
418 coords[a*
DIM + n] = latVec[n];
421 for (n = 0; n <
DIM; ++n)
423 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
427 latVec[0] = ((double) i)*FCCspacing;
429 latVec[2] = ((double) j)*FCCspacing;
430 for (n = 0; n <
DIM; ++n)
432 coords[a*
DIM + n] = latVec[n];
435 for (n = 0; n <
DIM; ++n)
437 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
441 latVec[0] = ((double) i)*FCCspacing;
442 latVec[1] = ((double) j)*FCCspacing;
444 for (n = 0; n <
DIM; ++n)
446 coords[a*
DIM + n] = latVec[n];
449 for (n = 0; n <
DIM; ++n)
451 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
456 latVec[0] = ((double) i)*FCCspacing;
459 for (n = 0; n <
DIM; ++n)
461 coords[a*
DIM + n] = latVec[n];
465 latVec[1] = ((double) i)*FCCspacing;
467 for (n = 0; n <
DIM; ++n)
469 coords[a*
DIM + n] = latVec[n];
474 latVec[2] = ((double) i)*FCCspacing;
475 for (n = 0; n <
DIM; ++n)
477 coords[a*
DIM + n] = latVec[n];
482 for (n = 0; n <
DIM; ++n)
493 double cutoff, NeighList* nl)
507 cutoff2 = cutoff*cutoff;
515 for (k = 0; k <
DIM; ++k)
517 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
523 if ((half && i < j) || (!half && i != j))
532 (*nl).NNeighbors[i] = a;
539 int const numberOfCutoffs,
double const *
const cutoffs,
540 int const neighborListIndex,
int const particleNumber,
541 int *
const numberOfNeighbors,
542 int const **
const neighborsOfParticle)
546 NeighList* nl = (NeighList*) dataObject;
549 if ((numberOfCutoffs != 1) || (cutoffs[0] > nl->cutoff))
return error;
551 if (neighborListIndex != 0)
return error;
554 *numberOfNeighbors = 0;
558 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
563 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
566 *neighborsOfParticle = &((*nl).neighborList[(particleNumber)*
numberOfParticles]);
int SetArgumentPointer(ComputeArgumentName const computeArgumentName, int const *const ptr)
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
ComputeArgumentName const coordinates
void GetNeighborListCutoffsPointer(int *const numberOfCutoffs, double const **const cutoffs) 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
ComputeCallbackName const GetNeighborList
SupportStatus const required
int Compute(ComputeArguments const *const computeArguments) const
std::string const & String() const
void GetInfluenceDistance(double *const influenceDistance) const
ComputeArgumentName const particleContributing
int GetCallbackSupportStatus(ComputeCallbackName const computeCallbackName, SupportStatus *const supportStatus) const
ComputeArgumentName const partialEnergy
static void Destroy(Model **const model)
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
#define MY_ERROR(message)
void GetNumberOfParameters(int *const numberOfParameters) const
int SetCallbackPointer(ComputeCallbackName const computeCallbackName, LanguageName const languageName, func *const fptr, void const *const dataObject)
std::string const & String() const
ComputeArgumentName const particleSpeciesCodes
ComputeArgumentName const numberOfParticles
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
int GetSpeciesSupportAndCode(SpeciesName const speciesName, int *const speciesIsSupported, int *const code) const
int ComputeArgumentsDestroy(ComputeArguments **const computeArguments) 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)
#define MY_WARNING(message)
SupportStatus const optional