53 #define EPSILON -0.0134783698072604 58 #define NUMBER_OF_CUTOFFS 2 88 static void calc_phi(
double * epsilon,
128 ep = exp(-(*C) * (r - *Rzero));
138 *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
158 ep = exp(-(*C) * (r - *Rzero));
169 *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
170 *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2);
192 ep = exp(-(*C) * (r - *Rzero));
204 *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
205 *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2);
206 *d2phi = 2.0 * (*epsilon) * (*C) * (*C) * (ep - 2.0 * ep2);
213 #undef KIM_LOGGER_FUNCTION_NAME 214 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry 215 #undef KIM_LOGGER_OBJECT_NAME 216 #define KIM_LOGGER_OBJECT_NAME modelCompute 220 int neighborListIndex,
224 double * particleEnergy,
235 int comp_particleEnergy,
236 int comp_process_dEdr,
237 int comp_process_d2Edr2)
242 int const * neighListOfCurrentPart;
253 double * pRij = &(Rij[0]);
254 double Rij_pairs[2][3];
255 double const * pRij_pairs = &(Rij_pairs[0][0]);
257 int * pi_pairs = &(i_pairs[0]);
259 int * pj_pairs = &(j_pairs[0]);
262 double * pR_pairs = &(R_pairs[0]);
266 for (i = 0; i < *nParts; ++i)
268 if (particleContributing[i])
274 &neighListOfCurrentPart);
284 for (jj = 0; jj < numOfPartNeigh; ++jj)
286 j = neighListOfCurrentPart[jj];
288 if (!(particleContributing[j] && (j < i)))
294 for (k = 0; k <
DIM; ++k)
296 Rij[k] = coords[j * DIM + k] - coords[i * DIM + k];
299 Rsqij += Rij[k] * Rij[k];
307 if (comp_process_d2Edr2)
311 &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi, &d2phi);
314 if (particleContributing[j])
322 d2Eidr = 0.5 * d2phi;
325 else if (comp_force || comp_process_dEdr)
329 &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi);
332 if (particleContributing[j]) { dEidr = dphi; }
341 calc_phi(&epsilon, &C, &Rzero, &shift, cutoff, R, &phi);
345 if (comp_particleEnergy)
347 particleEnergy[i] += 0.5 * phi;
348 if (particleContributing[j]) { particleEnergy[j] += 0.5 * phi; }
352 if (particleContributing[j]) { *energy += phi; }
355 *energy += 0.5 * phi;
360 if (comp_process_dEdr)
363 modelComputeArguments, dEidr, R, pRij, i, j);
366 LOG_ERROR(
"ProcessDEDrTerm callback error");
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,
391 LOG_ERROR(
"ProcessD2EDr2Term callback error");
400 for (k = 0; k <
DIM; ++k)
403 += dEidr * Rij[k] / R;
405 -= dEidr * Rij[k] / R;
419 #undef KIM_LOGGER_FUNCTION_NAME 420 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry 421 #undef KIM_LOGGER_OBJECT_NAME 422 #define KIM_LOGGER_OBJECT_NAME modelCompute 434 int comp_particleEnergy;
435 int comp_process_dEdr;
436 int comp_process_d2Edr2;
450 double * particleEnergy;
458 modelComputeArguments,
462 modelComputeArguments,
464 &comp_process_d2Edr2);
468 modelComputeArguments,
472 modelComputeArguments,
474 &particleSpeciesCodes)
476 modelComputeArguments,
478 &particleContributing)
480 modelComputeArguments,
484 modelComputeArguments,
488 modelComputeArguments,
492 modelComputeArguments,
501 comp_energy = (energy != NULL);
502 comp_force = (force != NULL);
503 comp_particleEnergy = (particleEnergy != NULL);
508 for (i = 0; i < *nParts; ++i)
510 if (
SPECCODE != particleSpeciesCodes[i])
512 LOG_ERROR(
"Unexpected species code detected");
520 if (comp_particleEnergy)
522 for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; }
524 if (comp_energy) { *energy = 0.0; }
528 for (i = 0; i < *nParts; ++i)
530 for (k = 0; k <
DIM; ++k) { force[i * DIM + k] = 0.0; }
538 (
void **) &bufferPointer);
539 cutoff = &(bufferPointer->cutoff[0]);
540 cutsq = (*cutoff) * (*cutoff);
547 calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift);
552 ier =
loops(modelCompute,
553 modelComputeArguments,
556 particleContributing,
571 comp_process_d2Edr2);
572 if (ier)
return TRUE;
574 cutoff = &(bufferPointer->cutoff[1]);
575 cutsq = (*cutoff) * (*cutoff);
582 calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift);
587 ier =
loops(modelCompute,
588 modelComputeArguments,
591 particleContributing,
606 comp_process_d2Edr2);
607 if (ier)
return TRUE;
617 #undef KIM_LOGGER_FUNCTION_NAME 618 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCreate_LogEntry 619 #undef KIM_LOGGER_OBJECT_NAME 620 #define KIM_LOGGER_OBJECT_NAME modelCreate 641 (void) requestedLengthUnit;
642 (void) requestedEnergyUnit;
643 (void) requestedChargeUnit;
644 (void) requestedTemperatureUnit;
645 (void) requestedTimeUnit;
716 &(bufferPointer->
cutoff[0]),
723 LOG_ERROR(
"Unable to successfully initialize model");
731 #undef KIM_LOGGER_FUNCTION_NAME 732 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDestroy_LogEntry 733 #undef KIM_LOGGER_OBJECT_NAME 734 #define KIM_LOGGER_OBJECT_NAME modelDestroy 742 (
void **) &bufferPointer);
750 #undef KIM_LOGGER_FUNCTION_NAME 751 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry 752 #undef KIM_LOGGER_OBJECT_NAME 753 #define KIM_LOGGER_OBJECT_NAME modelCompute 766 modelComputeArgumentsCreate,
771 modelComputeArgumentsCreate,
776 modelComputeArgumentsCreate,
784 modelComputeArgumentsCreate,
789 modelComputeArgumentsCreate,
795 LOG_ERROR(
"Unable to successfully initialize compute arguments");
808 (void) modelComputeArgumentsDestroy;
void KIM_ModelCreate_SetInfluenceDistancePointer(KIM_ModelCreate *const modelCreate, double const *const influenceDistance)
Set the Model's influence distance data pointer.
int KIM_ModelComputeArgumentsCreateFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
The standard optional status.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
The standard coordinates argument.
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessD2EDr2Term
The standard ProcessD2EDr2Term callback.
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.
void() KIM_Function(void)
Generic function type.
static void calc_phi_dphi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi, double *dphi)
void KIM_ModelDestroy_GetModelBufferPointer(KIM_ModelDestroy const *const modelDestroy, void **const ptr)
Get the Model's buffer pointer within the Model object.
recursive subroutine, public destroy(model_destroy_handle, ierr)
KIM_LanguageName const KIM_LANGUAGE_NAME_c
The standard c language.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialForces
The standard partialForces argument.
#define LOG_ERROR(message)
Convenience macro for ERROR Log entries with compile-time optimization.
int KIM_ModelComputeArguments_GetArgumentPointerDouble(KIM_ModelComputeArguments const *const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, double **const ptr)
Get the data pointer for a ComputeArgumentName.
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_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.
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
The standard particleSpeciesCodes argument.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute
The standard Compute routine.
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.
int KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus(KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate, KIM_ComputeCallbackName const computeCallbackName, KIM_SupportStatus const supportStatus)
Set the SupportStatus of a ComputeCallbackName.
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
struct KIM_ModelCompute KIM_ModelCompute
Forward declaration.
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
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...
static int compute_arguments_destroy(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_unused
Indicates that a TemperatureUnit is not used.
struct KIM_ModelComputeArgumentsCreate KIM_ModelComputeArgumentsCreate
Forward declaration.
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
The standard Argon species.
ChargeUnit const C
The standard Coulomb unit of charge.
struct KIM_ModelDestroy KIM_ModelDestroy
Forward declaration.
KIM_TimeUnit const KIM_TIME_UNIT_unused
Indicates that a TimeUnit is not used.
static int model_destroy(KIM_ModelDestroy *const modelDestroy)
#define NUMBER_OF_CUTOFFS
int KIM_ModelComputeArgumentsDestroyFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Destroy
The standard Destroy routine.
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)
void KIM_ModelCreate_SetModelBufferPointer(KIM_ModelCreate *const modelCreate, void *const ptr)
Set the Model's buffer pointer within the Model object.
ComputeArgumentName const particleContributing
The standard particleContributing argument.
int KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus(KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate, KIM_ComputeArgumentName const computeArgumentName, KIM_SupportStatus const supportStatus)
Set the SupportStatus of a ComputeArgumentName.
struct KIM_ModelCreate KIM_ModelCreate
Forward declaration.
void KIM_ModelCompute_GetModelBufferPointer(KIM_ModelCompute const *const modelCompute, void **const ptr)
Get the Model's buffer pointer within the Model object.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_numberOfParticles
The standard numberOfParticles argument.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
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.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
static int compute_arguments_create(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
struct KIM_ModelComputeArgumentsDestroy KIM_ModelComputeArgumentsDestroy
Forward declaration.
int KIM_ModelCreate_SetModelNumbering(KIM_ModelCreate *const modelCreate, KIM_Numbering const numbering)
Set the Model's particle Numbering.
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_ModelCreate_SetSpeciesCode(KIM_ModelCreate *const modelCreate, KIM_SpeciesName const speciesName, int const code)
Set integer code for supported SpeciesName.
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...
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
The standard electronvolt unit of energy.
int modelWillNotRequestNeighborsOfNoncontributingParticles
static void calc_phi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi)
KIM_ChargeUnit const KIM_CHARGE_UNIT_unused
Indicates that a ChargeUnit is not used.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes 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_ModelComputeFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
#define LOG_INFORMATION(message)
Convenience macro for INFORMATION Log entries with compile-time optimization.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialEnergy
The standard partialEnergy argument.
int KIM_ModelDestroyFunction(KIM_ModelDestroy *const modelDestroy)
Prototype for MODEL_ROUTINE_NAME::Destroy routine.
KIM_ComputeCallbackName const KIM_COMPUTE_CALLBACK_NAME_ProcessDEDrTerm
The standard ProcessDEDrTerm callback.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
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.
static int model_compute(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments)
struct KIM_ModelComputeArguments KIM_ModelComputeArguments
Forward declaration.
KIM_LengthUnit const KIM_LENGTH_UNIT_A
The standard angstrom unit of length.
LogVerbosity const error
The standard error verbosity.
KIM_Numbering const KIM_NUMBERING_zeroBased
The standard zeroBased numbering.
int KIM_ModelComputeArguments_GetArgumentPointerInteger(KIM_ModelComputeArguments const *const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, int **const ptr)
Get the data pointer for a ComputeArgumentName.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleContributing
The standard particleContributing argument.