50 #define NAMESTRLEN 128 52 #define FCCSPACING 5.260 54 #define NCELLSPERSIDE 2 55 #define NCLUSTERPARTS (4*(NCELLSPERSIDE*NCELLSPERSIDE*NCELLSPERSIDE) + \ 56 6*(NCELLSPERSIDE*NCELLSPERSIDE) \ 57 + 3*(NCELLSPERSIDE) + 1) 59 #define MY_ERROR(message) \ 61 std::cout << "* Error : \"" << message << "\" : " \ 62 << __LINE__ << ":" << __FILE__ << std::endl; \ 66 #define MY_WARNING(message) \ 68 std::cout << "* Error : \"" << message << "\" : " \ 69 << __LINE__ << ":" << __FILE__ << std::endl; \ 84 double cutoff, NeighList* nl);
87 int const neighborListIndex,
int const particleNumber,
88 int *
const numberOfNeighbors,
89 int const **
const neighborsOfParticle);
101 double CurrentSpacing;
102 double cutpad = 0.75;
112 NeighList nl_cluster_model;
114 double influence_distance_cluster_model;
115 int number_of_cutoffs;
116 double const * cutoff_cluster_model;
117 double energy_cluster_model;
119 std::string modelname;
122 std::cout <<
"Please enter valid KIM Model name: \n";
123 std::cin >> modelname;
128 int requestedUnitsAccepted;
137 &requestedUnitsAccepted,
141 MY_ERROR(
"KIM_create_model_interface()");
145 if (!requestedUnitsAccepted)
147 MY_ERROR(
"Must Adapt to model units");
157 kim_cluster_model->
GetUnits(&lengthUnit, &energyUnit, &chargeUnit,
158 &temperatureUnit, &timeUnit);
160 std::cout <<
"LengthUnit is \"" << lengthUnit.
String() <<
"\"" << std::endl
161 <<
"EnergyUnit is \"" << energyUnit.
String() <<
"\"" << std::endl
162 <<
"ChargeUnit is \"" << chargeUnit.
String() <<
"\"" << std::endl
163 <<
"TemperatureUnit is \"" << temperatureUnit.
String()
165 <<
"TimeUnit is \"" << timeUnit.
String() <<
"\"" << std::endl;
168 int speciesIsSupported;
172 if ((
error) || (!speciesIsSupported))
174 MY_ERROR(
"Species Ar not supported");
178 int numberOfArguments;
180 for (
int i=0; i<numberOfArguments; ++i)
190 MY_ERROR(
"unable to get argument supportStatus");
192 std::cout <<
"Argument Name \"" 193 << argumentName.
String() <<
"\"" 195 << dataType.
String() <<
"\"" 196 <<
" and has supportStatus \"" 197 << supportStatus.
String() <<
"\"" 205 MY_ERROR(
"unsupported required argument");
222 int numberOfCallbacks;
224 for (
int i=0; i<numberOfCallbacks; ++i)
231 std::cout <<
"Callback Name \"" 232 << callbackName.
String() <<
"\"" 233 <<
" has supportStatus \"" 234 << supportStatus.
String() <<
"\"" 240 MY_ERROR(
"unsupported required call back");
246 int numberOfParameters;
248 for (
int i=0; i<numberOfParameters; ++i)
254 i, &dataType, &extent, &str);
255 std::cout <<
"Parameter No. " << i
256 <<
" has data type \"" << dataType.
String() <<
"\"" 257 <<
" with extent " << extent
258 <<
" and description : " << str << std::endl;
265 particleSpecies_cluster_model)
268 particleContributing_cluster_model)
283 &cutoff_cluster_model);
284 if (number_of_cutoffs != 1)
MY_ERROR(
"too many cutoffs");
287 int isSpeciesSupported;
291 &(particleSpecies_cluster_model[0]));
294 particleSpecies_cluster_model[i] = particleSpecies_cluster_model[0];
297 particleContributing_cluster_model[i] = 1;
303 if (NULL==nl_cluster_model.NNeighbors)
MY_ERROR(
"new unsuccessful");
306 if (NULL==nl_cluster_model.neighborList)
MY_ERROR(
"new unsuccessful");
309 std::cout << std::setiosflags(std::ios::scientific) << std::setprecision(10);
310 std::cout <<
"--------------------------------------------------------------------------------\n";
311 std::cout <<
"This is Test : ex_test_Ar_fcc_cluster\n";
312 std::cout <<
"MODEL is : " << modelname << std::endl;
314 for (CurrentSpacing = MinSpacing; CurrentSpacing < MaxSpacing; CurrentSpacing += SpacingIncr)
320 (*cutoff_cluster_model + cutpad), &nl_cluster_model);
328 << std::setw(20) << energy_cluster_model
329 << std::setw(20) << CurrentSpacing
338 delete [] nl_cluster_model.NNeighbors;
339 delete [] nl_cluster_model.neighborList;
348 double FCCshifts[4][
DIM];
358 FCCshifts[0][0] = 0.0; FCCshifts[0][1] = 0.0; FCCshifts[0][2] = 0.0;
359 FCCshifts[1][0] = 0.5*FCCspacing; FCCshifts[1][1] = 0.5*FCCspacing; FCCshifts[1][2] = 0.0;
360 FCCshifts[2][0] = 0.5*FCCspacing; FCCshifts[2][1] = 0.0; FCCshifts[2][2] = 0.5*FCCspacing;
361 FCCshifts[3][0] = 0.0; FCCshifts[3][1] = 0.5*FCCspacing; FCCshifts[3][2] = 0.5*FCCspacing;
364 for (i = 0; i < nCellsPerSide; ++i)
366 latVec[0] = ((double) i)*FCCspacing;
367 for (j = 0; j < nCellsPerSide; ++j)
369 latVec[1] = ((double) j)*FCCspacing;
370 for (k = 0; k < nCellsPerSide; ++k)
372 latVec[2] = ((double) k)*FCCspacing;
373 for (
m = 0;
m < 4; ++
m)
375 for (n = 0; n <
DIM; ++n)
377 coords[a*
DIM + n] = latVec[n] + FCCshifts[
m][n];
385 latVec[1] = ((double) i)*FCCspacing;
386 latVec[2] = ((double) j)*FCCspacing;
387 for (n = 0; n <
DIM; ++n)
389 coords[a*
DIM + n] = latVec[n];
392 for (n = 0; n <
DIM; ++n)
394 coords[a*
DIM + n] = latVec[n] + FCCshifts[3][n];
398 latVec[0] = ((double) i)*FCCspacing;
400 latVec[2] = ((double) j)*FCCspacing;
401 for (n = 0; n <
DIM; ++n)
403 coords[a*
DIM + n] = latVec[n];
406 for (n = 0; n <
DIM; ++n)
408 coords[a*
DIM + n] = latVec[n] + FCCshifts[2][n];
412 latVec[0] = ((double) i)*FCCspacing;
413 latVec[1] = ((double) j)*FCCspacing;
415 for (n = 0; n <
DIM; ++n)
417 coords[a*
DIM + n] = latVec[n];
420 for (n = 0; n <
DIM; ++n)
422 coords[a*
DIM + n] = latVec[n] + FCCshifts[1][n];
427 latVec[0] = ((double) i)*FCCspacing;
430 for (n = 0; n <
DIM; ++n)
432 coords[a*
DIM + n] = latVec[n];
436 latVec[1] = ((double) i)*FCCspacing;
438 for (n = 0; n <
DIM; ++n)
440 coords[a*
DIM + n] = latVec[n];
445 latVec[2] = ((double) i)*FCCspacing;
446 for (n = 0; n <
DIM; ++n)
448 coords[a*
DIM + n] = latVec[n];
453 for (n = 0; n <
DIM; ++n)
464 double cutoff, NeighList* nl)
476 cutoff2 = cutoff*cutoff;
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 neighborListIndex,
int const particleNumber,
509 int *
const numberOfNeighbors,
510 int const **
const neighborsOfParticle)
514 NeighList* nl = (NeighList*) dataObject;
517 if (neighborListIndex != 0)
return error;
520 *numberOfNeighbors = 0;
524 MY_WARNING(
"Invalid part ID in get_cluster_neigh");
529 *numberOfNeighbors = (*nl).NNeighbors[particleNumber];
532 *neighborsOfParticle = &((*nl).neighborList[(particleNumber)*
numberOfParticles]);
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
int GetArgumentName(int const index, ArgumentName *const argumentName)
ArgumentName const particleContributing
std::string String() const
std::string String() const
ArgumentName const numberOfParticles
void GetNeighborListCutoffsPointer(int *const numberOfCutoffs, double const **const cutoffs) const
int GetParameterDataTypeExtentAndDescription(int const index, DataType *const dataType, int *extent, std::string *const description) const
int GetArgumentDataType(ArgumentName const argumentName, DataType *const dataType)
std::string String() const
ArgumentName const partialEnergy
std::string String() const
SupportStatus const required
std::string String() const
std::string String() const
int SetCallbackPointer(CallbackName const callbackName, LanguageName const languageName, func *const fptr, void const *const dataObject)
ArgumentName const coordinates
void GetInfluenceDistance(double *const influenceDistance) const
void GetNumberOfCallbacks(int *const numberOfCallbacks)
int GetCallbackName(int const index, CallbackName *const callbackName)
void create_FCC_cluster(double FCCspacing, int nCellsPerSide, double *coords)
static void Destroy(Model **const model)
ArgumentName const particleSpeciesCodes
int SetArgumentPointer(ArgumentName const argumentName, int const *const ptr)
std::string String() const
std::string String() const
void GetNumberOfArguments(int *const numberOfArguments)
int get_cluster_neigh(void const *const dataObject, int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle)
int GetArgumentSupportStatus(ArgumentName const argumentName, SupportStatus *const supportStatus) const
void GetNumberOfParameters(int *const numberOfParameters) const
#define MY_WARNING(message)
int GetCallbackSupportStatus(CallbackName const callbackName, SupportStatus *const supportStatus) const
int GetSpeciesSupportAndCode(KIM::SpeciesName const speciesName, int *const speciesIsSupported, int *const code) const
#define MY_ERROR(message)
Numbering const zeroBased
CallbackName const GetNeighborList
std::string String() const
void fcc_cluster_neighborlist(int half, int numberOfParticles, double *coords, double cutoff, NeighList *nl)
SupportStatus const optional