59 #define EPSILON -0.0134783698072604 64 #define NUMBER_OF_CUTOFFS 2 94 static void calc_phi(
double * epsilon,
134 ep = exp(-(*C) * (r - *Rzero));
144 *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
164 ep = exp(-(*C) * (r - *Rzero));
175 *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
176 *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2);
198 ep = exp(-(*C) * (r - *Rzero));
210 *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
211 *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2);
212 *d2phi = 2.0 * (*epsilon) * (*C) * (*C) * (ep - 2.0 * ep2);
219 #undef KIM_LOGGER_FUNCTION_NAME 220 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry 221 #undef KIM_LOGGER_OBJECT_NAME 222 #define KIM_LOGGER_OBJECT_NAME modelCompute 226 int neighborListIndex,
230 double * particleEnergy,
241 int comp_particleEnergy,
242 int comp_process_dEdr,
243 int comp_process_d2Edr2)
248 int const * neighListOfCurrentPart;
259 double * pRij = &(Rij[0]);
260 double Rij_pairs[2][3];
261 double const * pRij_pairs = &(Rij_pairs[0][0]);
263 int * pi_pairs = &(i_pairs[0]);
265 int * pj_pairs = &(j_pairs[0]);
268 double * pR_pairs = &(R_pairs[0]);
272 for (i = 0; i < *nParts; ++i)
274 if (particleContributing[i])
280 &neighListOfCurrentPart);
290 for (jj = 0; jj < numOfPartNeigh; ++jj)
292 j = neighListOfCurrentPart[jj];
294 if (!(particleContributing[j] && (j < i)))
300 for (k = 0; k <
DIM; ++k)
302 Rij[k] = coords[j * DIM + k] - coords[i * DIM + k];
305 Rsqij += Rij[k] * Rij[k];
313 if (comp_process_d2Edr2)
317 &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi, &d2phi);
320 if (particleContributing[j])
328 d2Eidr = 0.5 * d2phi;
331 else if (comp_force || comp_process_dEdr)
335 &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi);
338 if (particleContributing[j]) { dEidr = dphi; }
347 calc_phi(&epsilon, &C, &Rzero, &shift, cutoff, R, &phi);
351 if (comp_particleEnergy)
353 particleEnergy[i] += 0.5 * phi;
354 if (particleContributing[j]) { particleEnergy[j] += 0.5 * phi; }
358 if (particleContributing[j]) { *energy += phi; }
361 *energy += 0.5 * phi;
366 if (comp_process_dEdr)
369 modelComputeArguments, dEidr, R, pRij, i, j);
373 if (comp_process_d2Edr2)
375 R_pairs[0] = R_pairs[1] = R;
376 Rij_pairs[0][0] = Rij_pairs[1][0] = Rij[0];
377 Rij_pairs[0][1] = Rij_pairs[1][1] = Rij[1];
378 Rij_pairs[0][2] = Rij_pairs[1][2] = Rij[2];
379 i_pairs[0] = i_pairs[1] = i;
380 j_pairs[0] = j_pairs[1] = j;
383 modelComputeArguments,
394 for (k = 0; k <
DIM; ++k)
397 += dEidr * Rij[k] / R;
399 -= dEidr * Rij[k] / R;
413 #undef KIM_LOGGER_FUNCTION_NAME 414 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry 415 #undef KIM_LOGGER_OBJECT_NAME 416 #define KIM_LOGGER_OBJECT_NAME modelCompute 428 int comp_particleEnergy;
429 int comp_process_dEdr;
430 int comp_process_d2Edr2;
444 double * particleEnergy;
452 modelComputeArguments,
456 modelComputeArguments,
458 &comp_process_d2Edr2);
462 modelComputeArguments,
466 modelComputeArguments,
468 &particleSpeciesCodes)
470 modelComputeArguments,
472 &particleContributing)
474 modelComputeArguments,
478 modelComputeArguments,
482 modelComputeArguments,
486 modelComputeArguments,
495 comp_energy = (energy != NULL);
496 comp_force = (force != NULL);
497 comp_particleEnergy = (particleEnergy != NULL);
502 for (i = 0; i < *nParts; ++i)
504 if (
SPECCODE != particleSpeciesCodes[i])
506 LOG_ERROR(
"Unexpected species code detected");
514 if (comp_particleEnergy)
516 for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; }
518 if (comp_energy) { *energy = 0.0; }
522 for (i = 0; i < *nParts; ++i)
524 for (k = 0; k <
DIM; ++k) { force[i * DIM + k] = 0.0; }
532 (
void **) &bufferPointer);
533 cutoff = &(bufferPointer->cutoff[0]);
534 cutsq = (*cutoff) * (*cutoff);
541 calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift);
546 ier =
loops(modelCompute,
547 modelComputeArguments,
550 particleContributing,
565 comp_process_d2Edr2);
566 if (ier)
return TRUE;
568 cutoff = &(bufferPointer->cutoff[1]);
569 cutsq = (*cutoff) * (*cutoff);
576 calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift);
581 ier =
loops(modelCompute,
582 modelComputeArguments,
585 particleContributing,
600 comp_process_d2Edr2);
601 if (ier)
return TRUE;
611 #undef KIM_LOGGER_FUNCTION_NAME 612 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCreate_LogEntry 613 #undef KIM_LOGGER_OBJECT_NAME 614 #define KIM_LOGGER_OBJECT_NAME modelCreate 635 (void) requestedLengthUnit;
636 (void) requestedEnergyUnit;
637 (void) requestedChargeUnit;
638 (void) requestedTemperatureUnit;
639 (void) requestedTimeUnit;
710 &(bufferPointer->
cutoff[0]),
717 LOG_ERROR(
"Unable to successfully initialize model");
725 #undef KIM_LOGGER_FUNCTION_NAME 726 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDestroy_LogEntry 727 #undef KIM_LOGGER_OBJECT_NAME 728 #define KIM_LOGGER_OBJECT_NAME modelDestroy 736 (
void **) &bufferPointer);
744 #undef KIM_LOGGER_FUNCTION_NAME 745 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry 746 #undef KIM_LOGGER_OBJECT_NAME 747 #define KIM_LOGGER_OBJECT_NAME modelCompute 760 modelComputeArgumentsCreate,
765 modelComputeArgumentsCreate,
770 modelComputeArgumentsCreate,
778 modelComputeArgumentsCreate,
783 modelComputeArgumentsCreate,
789 LOG_ERROR(
"Unable to successfully initialize compute arguments");
802 (void) modelComputeArgumentsDestroy;
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy
The standard Destroy routine.
static void calc_phi_d2phi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi, double *dphi, double *d2phi)
int KIM_ModelComputeArgumentsCreateFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
#define LOG_ERROR(message)
Convenience macro for ERROR Log entries with compile-time optimization.
struct KIM_ModelCreate KIM_ModelCreate
Forward declaration.
#define NUMBER_OF_CUTOFFS
struct KIM_ModelComputeArguments KIM_ModelComputeArguments
Forward declaration.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
static int model_compute(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments)
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
int KIM_ModelCreateFunction(KIM_ModelCreate *const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit)
Prototype for MODEL_ROUTINE_NAME::Create routine.
recursive subroutine, public destroy(model_destroy_handle, ierr)
static void calc_phi_dphi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi, double *dphi)
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
The standard partialForces argument.
int KIM_ModelCreate_SetRoutinePointer(KIM_ModelCreate *const modelCreate, KIM_ModelRoutineName const modelRoutineName, KIM_LanguageName const languageName, int const required, KIM_Function *const fptr)
Set the function pointer for the ModelRoutineName of interest.
int KIM_ModelComputeArgumentsDestroyFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine.
void KIM_ModelCompute_GetModelBufferPointer(KIM_ModelCompute const *const modelCompute, void **const ptr)
Get the Model's buffer pointer within the Model object.
void KIM_ModelCreate_SetInfluenceDistancePointer(KIM_ModelCreate *const modelCreate, double const *const influenceDistance)
Set the Model's influence distance data pointer.
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_unused
Indicates that a TemperatureUnit is not used.
int loops(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments, int neighborListIndex, int *nParts, int *particleContributing, double *energy, double *particleEnergy, double *force, double *coords, double cutsq, double epsilon, double C, double Rzero, double shift, double *cutoff, int comp_energy, int comp_force, int comp_particleEnergy, int comp_process_dEdr, int comp_process_d2Edr2)
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy
The standard partialParticleEnergy argument.
int model_create(KIM_ModelCreate *const modelCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit)
static void calc_phi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi)
int KIM_ModelCreate_SetSpeciesCode(KIM_ModelCreate *const modelCreate, KIM_SpeciesName const speciesName, int const code)
Set integer code for supported SpeciesName.
KIM_LengthUnit const KIM_LENGTH_UNIT_A
The standard angstrom unit of length.
int KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus(KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus const supportStatus)
Set the SupportStatus of a ComputeCallbackName.
int KIM_ModelComputeFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
int KIM_ModelComputeArguments_IsCallbackPresent(KIM_ModelComputeArguments const *const modelComputeArguments, KIM_ComputeCallbackName const computeCallbackName, int *const present)
Determine if the Simulator has provided a non-NULL function pointer for a ComputeCallbackName of inte...
KIM_ChargeUnit const KIM_CHARGE_UNIT_unused
Indicates that a ChargeUnit is not used.
void() KIM_Function(void)
Generic function type.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
static int compute_arguments_destroy(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
int KIM_ModelComputeArguments_GetNeighborList(KIM_ModelComputeArguments const *const modelComputeArguments, int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle)
Get the neighbor list for a particle of interest corresponding to a particular neighbor list cutoff d...
struct KIM_ModelCompute KIM_ModelCompute
Forward declaration.
struct KIM_ModelComputeArgumentsDestroy KIM_ModelComputeArgumentsDestroy
Forward declaration.
static int compute_arguments_create(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
KIM_LanguageName const KIM_LANGUAGE_NAME_c
The standard c language.
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
The standard optional status.
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term
The standard ProcessD2EDr2Term callback.
int KIM_ModelDestroyFunction(KIM_ModelDestroy *const modelDestroy)
Prototype for MODEL_ROUTINE_NAME::Destroy routine.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
The standard partialEnergy argument.
int KIM_ModelCreate_SetUnits(KIM_ModelCreate *const modelCreate, KIM_LengthUnit const lengthUnit, KIM_EnergyUnit const energyUnit, KIM_ChargeUnit const chargeUnit, KIM_TemperatureUnit const temperatureUnit, KIM_TimeUnit const timeUnit)
Set the Model's base unit values.
int KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus(KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus const supportStatus)
Set the SupportStatus of a ComputeArgumentName.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing
The standard particleContributing argument.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
The standard coordinates argument.
int KIM_ModelComputeArguments_ProcessDEDrTerm(KIM_ModelComputeArguments const *const modelComputeArguments, double const de, double const r, double const *const dx, int const i, int const j)
Call the Simulator's COMPUTE_CALLBACK_NAME::ProcessDEDrTerm routine.
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
struct KIM_ModelDestroy KIM_ModelDestroy
Forward declaration.
KIM_Numbering const KIM_NUMBERING_zeroBased
The standard zeroBased numbering.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes argument.
void KIM_ModelCreate_SetNeighborListPointers(KIM_ModelCreate *const modelCreate, int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model's neighbor list data pointers.
int KIM_ModelComputeArguments_GetArgumentPointerDouble(KIM_ModelComputeArguments const *const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, double **const ptr)
Get the data pointer for a ComputeArgumentName.
ChargeUnit const C
The standard Coulomb unit of charge.
struct KIM_ModelComputeArgumentsCreate KIM_ModelComputeArgumentsCreate
Forward declaration.
int modelWillNotRequestNeighborsOfNoncontributingParticles
void KIM_ModelCreate_SetModelBufferPointer(KIM_ModelCreate *const modelCreate, void *const ptr)
Set the Model's buffer pointer within the Model object.
void KIM_ModelDestroy_GetModelBufferPointer(KIM_ModelDestroy const *const modelDestroy, void **const ptr)
Get the Model's buffer pointer within the Model object.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
static int model_destroy(KIM_ModelDestroy *const modelDestroy)
int KIM_ModelCreate_SetModelNumbering(KIM_ModelCreate *const modelCreate, KIM_Numbering const numbering)
Set the Model's particle Numbering.
LogVerbosity const error
The standard error verbosity.
#define LOG_INFORMATION(message)
Convenience macro for INFORMATION Log entries with compile-time optimization.
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm
The standard ProcessDEDrTerm callback.
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
The standard electronvolt unit of energy.
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
The standard Argon species.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
The standard particleSpeciesCodes argument.
ComputeArgumentName const particleContributing
The standard particleContributing argument.
int KIM_ModelComputeArguments_ProcessD2EDr2Term(KIM_ModelComputeArguments const *const modelComputeArguments, double const de, double const *const r, double const *const dx, int const *const i, int const *const j)
Call the Simulator's COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term routine.
int KIM_ModelComputeArguments_GetArgumentPointerInteger(KIM_ModelComputeArguments const *const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, int **const ptr)
Get the data pointer for a ComputeArgumentName.
KIM_TimeUnit const KIM_TIME_UNIT_unused
Indicates that a TimeUnit is not used.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles
The standard numberOfParticles argument.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute
The standard Compute routine.