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; \ 78 int const numberOfNeighborLists,
79 double const *
const cutoffs,
80 int const neighborListIndex,
int const particleNumber,
81 int *
const numberOfNeighbors,
82 int const **
const neighborsOfParticle);
94 double CurrentSpacing;
108 double influence_distance_cluster_model;
109 int number_of_neighbor_lists;
110 double const * cutoff_cluster_model;
111 double energy_cluster_model;
114 std::string modelname;
117 printf(
"Please enter valid KIM Model name: \n");
118 std::cin >> modelname;
123 int requestedUnitsAccepted;
131 &requestedUnitsAccepted,
139 if (!requestedUnitsAccepted)
141 MY_ERROR(
"Must Adapt to model units");
151 kim_cluster_model->
GetUnits(&lengthUnit, &energyUnit, &chargeUnit,
152 &temperatureUnit, &timeUnit);
154 std::cout <<
"LengthUnit is \"" << lengthUnit.
String() <<
"\"" << std::endl
155 <<
"EnergyUnit is \"" << energyUnit.
String() <<
"\"" << std::endl
156 <<
"ChargeUnit is \"" << chargeUnit.
String() <<
"\"" << std::endl
157 <<
"TemperatureUnit is \"" << temperatureUnit.
String()
159 <<
"TimeUnit is \"" << timeUnit.
String() <<
"\"" << std::endl;
162 int speciesIsSupported;
166 if ((
error) || (!speciesIsSupported))
168 MY_ERROR(
"Species Ar not supported");
175 MY_ERROR(
"Unable to create a ComputeArguments object.");
179 int numberOfComputeArgumentNames;
181 &numberOfComputeArgumentNames);
182 for (
int i=0; i<numberOfComputeArgumentNames; ++i)
189 computeArgumentName, &dataType);
193 MY_ERROR(
"unable to get ComputeArgument SupportStatus");
195 std::cout <<
"ComputeArgument Name \"" 196 << computeArgumentName.
String() <<
"\"" 198 << dataType.
String() <<
"\"" 199 <<
" and has supportStatus \"" 200 << supportStatus.
String() <<
"\"" 210 MY_ERROR(
"unsupported required ComputeArgument");
223 MY_ERROR(
"energy or forces not available");
229 int numberOfComputeCallbackNames;
231 &numberOfComputeCallbackNames);
232 for (
int i=0; i<numberOfComputeCallbackNames; ++i)
240 std::cout <<
"ComputeCallback Name \"" 241 << computeCallbackName.
String() <<
"\"" 242 <<
" has supportStatus \"" 243 << supportStatus.
String() <<
"\"" 249 MY_ERROR(
"unsupported required ComputeCallback");
253 int numberOfParameters;
255 for (
int i=0; i<numberOfParameters; ++i)
258 std::string
const * str;
261 i, &dataType, &extent, &str);
262 std::cout <<
"Parameter No. " << i
263 <<
" has data type \"" << dataType.
String() <<
"\"" 264 <<
" with extent " << extent
265 <<
" and description : " << *str << std::endl;
272 (
int *) &numberOfParticles_cluster)
275 particleSpecies_cluster_model)
278 particleContributing_cluster_model)
294 int const * paddingNeighborHints;
295 int const * halfListHints;
297 &cutoff_cluster_model,
298 &paddingNeighborHints,
300 std::cout <<
"Model has influence distance of : " 301 << influence_distance_cluster_model << std::endl;
302 std::cout <<
"Model has numberOfNeighborLists : " << number_of_neighbor_lists
304 for (
int i=0; i<number_of_neighbor_lists; ++i)
306 std::cout <<
"\t" <<
"Neighbor list " << i <<
" has cutoff " 307 << cutoff_cluster_model[i] <<
" with paddingNeighborHint " 308 << paddingNeighborHints[i] <<
" and halfListHint " 313 if (number_of_neighbor_lists != 1)
MY_ERROR(
"too many neighbor lists");
316 int isSpeciesSupported;
320 &(particleSpecies_cluster_model[0]));
323 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
326 particleContributing_cluster_model[i] = 1;
338 std::cout << std::setiosflags(std::ios::scientific) << std::setprecision(10);
339 std::cout <<
"This is Test : ex_test_Ar_fcc_cluster_cpp\n";
340 std::cout <<
"--------------------------------------------------------------------------------\n";
341 std::cout <<
"Results for KIM Model : " << modelname << std::endl;
343 std::cout << std::setw(20) <<
"Energy" 344 << std::setw(20) <<
"Force Norm" 345 << std::setw(20) <<
"Lattice Spacing" 347 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
353 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
361 for (i=0; i <
DIM*numberOfParticles_cluster; ++i)
363 force_norm += forces_cluster[i]*forces_cluster[i];
365 force_norm = sqrt(force_norm);
368 std::cout << std::setw(20) << energy_cluster_model
369 << std::setw(20) << force_norm
370 << std::setw(20) << CurrentSpacing
378 MY_ERROR(
"Unable to destroy compute arguments");
395 double FCCshifts[4][
DIM];
405 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
406 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
407 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
408 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
411 for (i = 0; i < nCellsPerSide; ++i)
413 latVec[0] = ((double) i)*FCCspacing;
414 for (j = 0; j < nCellsPerSide; ++j)
416 latVec[1] = ((double) j)*FCCspacing;
417 for (k = 0; k < nCellsPerSide; ++k)
419 latVec[2] = ((double) k)*FCCspacing;
420 for (
m = 0;
m < 4; ++
m)
422 for (n = 0; n <
DIM; ++n)
424 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
432 latVec[1] = ((double) i)*FCCspacing;
433 latVec[2] = ((double) j)*FCCspacing;
434 for (n = 0; n <
DIM; ++n)
436 coords[a*
DIM + n] = latVec[n];
439 for (n = 0; n <
DIM; ++n)
441 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
445 latVec[0] = ((double) i)*FCCspacing;
447 latVec[2] = ((double) j)*FCCspacing;
448 for (n = 0; n <
DIM; ++n)
450 coords[a*
DIM + n] = latVec[n];
453 for (n = 0; n <
DIM; ++n)
455 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
459 latVec[0] = ((double) i)*FCCspacing;
460 latVec[1] = ((double) j)*FCCspacing;
462 for (n = 0; n <
DIM; ++n)
464 coords[a*
DIM + n] = latVec[n];
467 for (n = 0; n <
DIM; ++n)
469 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
474 latVec[0] = ((double) i)*FCCspacing;
477 for (n = 0; n <
DIM; ++n)
479 coords[a*
DIM + n] = latVec[n];
483 latVec[1] = ((double) i)*FCCspacing;
485 for (n = 0; n <
DIM; ++n)
487 coords[a*
DIM + n] = latVec[n];
492 latVec[2] = ((double) i)*FCCspacing;
493 for (n = 0; n <
DIM; ++n)
495 coords[a*
DIM + n] = latVec[n];
500 for (n = 0; n <
DIM; ++n)
533 for (k = 0; k <
DIM; ++k)
535 dx[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
541 if ((half && i < j) || (!half && i != j))
550 (*nl).NNeighbors[i] = a;
557 int const numberOfNeighborLists,
558 double const *
const cutoffs,
559 int const neighborListIndex,
int const particleNumber,
560 int *
const numberOfNeighbors,
561 int const **
const neighborsOfParticle)
568 if ((numberOfNeighborLists != 1) || (cutoffs[0] > nl->
cutoff))
return error;
570 if (neighborListIndex != 0)
return error;
573 *numberOfNeighbors = 0;
577 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
582 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
585 *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 GetNumberOfComputeCallbackNames(int *const numberOfComputeCallbackNames)
#define MY_ERROR(message)
std::string const & String() const
#define MY_WARNING(message)
void GetNumberOfComputeArgumentNames(int *const numberOfComputeArgumentNames)
void GetNeighborListPointers(int *const numberOfNeighborLists, double const **const cutoffs, int const **const paddingNeighborHints, int const **const halfListHints) const
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
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)
SupportStatus const optional