71 #define EPSILON -0.0134783698072604 90 static void calc_phi(
double* epsilon,
94 double* cutoff,
double r,
double* phi);
100 double* cutoff,
double r,
double* phi,
double* dphi);
106 double* cutoff,
double r,
double* phi,
double* dphi,
114 double* cutoff,
double r,
double* phi) {
119 ep = exp(-(*
C)*(r-*Rzero));
126 *phi = (*epsilon)*( -ep2 + 2.0*ep ) + *shift; }
135 double* cutoff,
double r,
double* phi,
double* dphi) {
140 ep = exp(-(*
C)*(r-*Rzero));
148 *phi = (*epsilon)*( -ep2 + 2.0*ep ) + *shift;
149 *dphi = 2.0*(*epsilon)*(*C)*( -ep + ep2 ); }
159 double* cutoff,
double r,
double* phi,
double* dphi,
165 ep = exp(-(*
C)*(r-*Rzero));
174 *phi = (*epsilon)*( -ep2 + 2.0*ep ) + *shift;
175 *dphi = 2.0*(*epsilon)*(*C)*( -ep + ep2 );
176 *d2phi = 2.0*(*epsilon)*(*C)*(*C)*(ep - 2.0*ep2); }
187 double *pR_pairs = &(R_pairs[0]);
195 double *pRij = &(Rij[0]);
196 double Rij_pairs[2][3];
197 double const * pRij_pairs = &(Rij_pairs[0][0]);
201 int *pi_pairs = &(i_pairs[0]);
204 int *pj_pairs = &(j_pairs[0]);
207 int const * neighListOfCurrentPart;
210 int comp_particleEnergy;
211 int comp_process_dEdr;
212 int comp_process_d2Edr2;
226 double* particleEnergy;
238 &comp_process_d2Edr2);
280 comp_energy = (energy != 0);
281 comp_force = (force != 0);
282 comp_particleEnergy = (particleEnergy != 0);
286 cutsq = (*cutoff)*(*cutoff);
293 calc_phi(&epsilon, &
C, &Rzero, &dummy, cutoff, *cutoff, &shift);
300 for (i = 0; i < *nParts; ++i) {
302 LOG_ERROR(
"Unexpected species code detected");
308 if (comp_particleEnergy) {
309 for (i = 0; i < *nParts; ++i) {
310 particleEnergy[i] = 0.0; } }
315 for (i = 0; i < *nParts; ++i) {
316 for (k = 0; k <
DIM; ++k) {
317 force[i*
DIM + k] = 0.0; } } }
323 for (i = 0; i< *nParts; ++i) {
327 modelCompute, 0, i, &numOfPartNeigh, &neighListOfCurrentPart);
335 for (jj = 0; jj < numOfPartNeigh; ++ jj) {
336 j = neighListOfCurrentPart[jj];
340 for (k = 0; k <
DIM; ++k) {
341 Rij[k] = coords[j*
DIM + k] - coords[i*
DIM + k];
344 Rsqij += Rij[k]*Rij[k]; }
350 if (comp_process_d2Edr2) {
356 cutoff, R, &phi, &dphi, &d2phi);
361 d2Eidr = 0.5*d2phi; }
362 else if (comp_force || comp_process_dEdr) {
368 cutoff, R, &phi, &dphi);
382 if (comp_particleEnergy) {
383 particleEnergy[i] += 0.5*phi; }
386 *energy += 0.5*phi; }
389 if (comp_process_dEdr) {
391 modelCompute, dEidr, R, pRij, i, j); }
394 if (comp_process_d2Edr2) {
395 R_pairs[0] = R_pairs[1] = R;
396 Rij_pairs[0][0] = Rij_pairs[1][0] = Rij[0];
397 Rij_pairs[0][1] = Rij_pairs[1][1] = Rij[1];
398 Rij_pairs[0][2] = Rij_pairs[1][2] = Rij[2];
399 i_pairs[0] = i_pairs[1] = i;
400 j_pairs[0] = j_pairs[1] = j;
403 modelCompute, d2Eidr, pR_pairs, pRij_pairs, pi_pairs, pj_pairs);
408 for (k = 0; k <
DIM; ++k) {
409 force[i*
DIM + k] += dEidr*Rij[k]/R;
410 force[j*
DIM + k] -= dEidr*Rij[k]/R; } } }
510 LOG_ERROR(
"Unable to successfully initialize model");
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
KIM_ArgumentName const KIM_ARGUMENT_NAME_particleContributing
KIM_ArgumentName const KIM_ARGUMENT_NAME_numberOfParticles
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_ModelDestroy_GetModelBufferPointer(KIM_ModelDestroy const *const modelDestroy, void **const ptr)
KIM_LanguageName const KIM_LANGUAGE_NAME_c
ArgumentName const particleContributing
int KIM_ModelCreate_SetComputePointer(KIM_ModelCreate *const modelCreate, KIM_LanguageName const languageName, func *const fptr)
struct KIM_ModelRefresh KIM_ModelRefresh
static int model_refresh(KIM_ModelRefresh *const modelRefresh)
void KIM_ModelRefresh_GetModelBufferPointer(KIM_ModelRefresh const *const modelRefresh, void **const ptr)
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_unused
KIM_SpeciesName const KIM_SPECIES_NAME_Ar
KIM_TimeUnit const KIM_TIME_UNIT_unused
static void calc_phi_dphi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi, double *dphi)
void KIM_ModelCreate_SetNeighborListCutoffsPointer(KIM_ModelCreate *const modelCreate, int const numberOfCutoffs, double const *const cutoffs)
void KIM_ModelRefresh_SetNeighborListCutoffsPointer(KIM_ModelRefresh *const modelRefresh, int const numberOfCutoffs, double const *const cutoffs)
KIM_ArgumentName const KIM_ARGUMENT_NAME_partialParticleEnergy
KIM_ArgumentName const KIM_ARGUMENT_NAME_partialForces
struct KIM_ModelDestroy KIM_ModelDestroy
void KIM_ModelCreate_SetModelBufferPointer(KIM_ModelCreate *const modelCreate, void *const ptr)
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_ModelCreate_SetRefreshPointer(KIM_ModelCreate *const modelCreate, KIM_LanguageName const languageName, func *const fptr)
int KIM_ModelCompute_GetNeighborList(KIM_ModelCompute const *const modelCompute, int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle)
void KIM_ModelCompute_GetModelBufferPointer(KIM_ModelCompute const *const modelCompute, void **const ptr)
ArgumentName const particleSpeciesCodes
int KIM_ModelCreate_SetDestroyPointer(KIM_ModelCreate *const modelCreate, KIM_LanguageName const languageName, func *const fptr)
int KIM_ModelCompute_IsCallbackPresent(KIM_ModelCompute const *const modelCompute, KIM_CallbackName const callbackName, int *const present)
void KIM_ModelCreate_SetInfluenceDistancePointer(KIM_ModelCreate *const modelCreate, double *const influenceDistance)
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)
int KIM_ModelCompute_GetArgumentPointerInteger(KIM_ModelCompute const *const modelCompute, KIM_ArgumentName const argumentName, int **const ptr)
#define LOG_INFORMATION(message)
int KIM_ModelCreate_SetModelNumbering(KIM_ModelCreate *const modelCreate, KIM_Numbering const numbering)
static int compute(KIM_ModelCompute const *const modelCompute)
int KIM_ModelCreate_SetArgumentSupportStatus(KIM_ModelCreate *const modelCreate, KIM_ArgumentName const argumentName, KIM_SupportStatus const supportStatus)
int KIM_ModelCreate_SetSpeciesCode(KIM_ModelCreate *const modelCreate, KIM_SpeciesName const speciesName, int const code)
static void calc_phi(double *epsilon, double *C, double *Rzero, double *shift, double *cutoff, double r, double *phi)
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
void KIM_ModelRefresh_SetInfluenceDistancePointer(KIM_ModelRefresh *const modelRefresh, double *const influenceDistance)
KIM_CallbackName const KIM_CALLBACK_NAME_ProcessDEDrTerm
KIM_CallbackName const KIM_CALLBACK_NAME_ProcessD2EDr2Term
KIM_ChargeUnit const KIM_CHARGE_UNIT_unused
int KIM_ModelCompute_ProcessDEDrTerm(KIM_ModelCompute const *const modelCompute, double const de, double const r, double const *const dx, int const i, int const j)
KIM_ArgumentName const KIM_ARGUMENT_NAME_coordinates
int KIM_ModelCompute_ProcessD2EDr2Term(KIM_ModelCompute const *const modelCompute, double const de, double const *const r, double const *const dx, int const *const i, int const *const j)
KIM_ArgumentName const KIM_ARGUMENT_NAME_particleSpeciesCodes
int KIM_ModelCompute_GetArgumentPointerDouble(KIM_ModelCompute const *const modelCompute, KIM_ArgumentName const argumentName, double **const ptr)
static int model_destroy(KIM_ModelDestroy *const modelDestroy)
real(c_double), parameter, public model_cutoff
struct KIM_ModelCreate KIM_ModelCreate
int KIM_ModelCreate_SetCallbackSupportStatus(KIM_ModelCreate *const modelCreate, KIM_CallbackName const callbackName, KIM_SupportStatus const supportStatus)
#define LOG_ERROR(message)
KIM_LengthUnit const KIM_LENGTH_UNIT_A
KIM_ArgumentName const KIM_ARGUMENT_NAME_partialEnergy
KIM_Numbering const KIM_NUMBERING_zeroBased
struct KIM_ModelCompute KIM_ModelCompute