kim-api  2.3.1-git+v2.3.0-git-2-g378406f9.GNU.GNU.
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
ex_model_Ar_P_Morse_MultiCutoff.c
Go to the documentation of this file.
1 /* */
2 /* KIM-API: An API for interatomic models */
3 /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */
4 /* All rights reserved. */
5 /* */
6 /* Contributors: */
7 /* Ryan S. Elliott */
8 /* Ellad B. Tadmor */
9 /* Stephen M. Whalen */
10 /* */
11 /* SPDX-License-Identifier: LGPL-2.1-or-later */
12 /* */
13 /* This library is free software; you can redistribute it and/or */
14 /* modify it under the terms of the GNU Lesser General Public */
15 /* License as published by the Free Software Foundation; either */
16 /* version 2.1 of the License, or (at your option) any later version. */
17 /* */
18 /* This library is distributed in the hope that it will be useful, */
19 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
20 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
21 /* Lesser General Public License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with this library; if not, write to the Free Software Foundation, */
25 /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
26 /* */
27 
28 /******************************************************************************/
29 /* */
30 /* ex_model_Ar_P_Morse_07C pair potential KIM Model */
31 /* shifted to have zero energy at the cutoff radius */
32 /* */
33 /* Language: C */
34 /* */
35 /******************************************************************************/
36 
37 
38 #include "KIM_LogMacros.h"
39 #include "KIM_ModelHeaders.h"
40 #include <math.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 
44 #define TRUE 1
45 #define FALSE 0
46 
47 /******************************************************************************/
48 /* Below are the definitions and values of all Model parameters */
49 /******************************************************************************/
50 #define DIM 3 /* dimensionality of space */
51 #define SPECCODE 1 /* internal species code */
52 #define CUTOFF 8.15 /* Angstroms */
53 #define EPSILON -0.0134783698072604 /* eV */
54 #define PARAM_C 1.545 /* 1/Angstroms */
55 #define RZERO 3.786 /* Angstroms */
56 
57 /* Model buffer definition */
58 #define NUMBER_OF_CUTOFFS 2
59 struct buffer
60 {
61  double influenceDistance;
62  double cutoff[NUMBER_OF_CUTOFFS];
64 };
65 typedef struct buffer buffer;
66 
67 /* Define prototype for Model create */
68 int model_create(KIM_ModelCreate * const modelCreate,
69  KIM_LengthUnit const requestedLengthUnit,
70  KIM_EnergyUnit const requestedEnergyUnit,
71  KIM_ChargeUnit const requestedChargeUnit,
72  KIM_TemperatureUnit const requestedTemperatureUnit,
73  KIM_TimeUnit const requestedTimeUnit);
74 
75 /* Define prototype for other routines */
76 static int
77 model_compute(KIM_ModelCompute const * const modelCompute,
78  KIM_ModelComputeArguments const * const modelComputeArguments);
79 static int compute_arguments_create(
80  KIM_ModelCompute const * const modelCompute,
81  KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate);
82 static int compute_arguments_destroy(
83  KIM_ModelCompute const * const modelCompute,
84  KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy);
85 static int model_destroy(KIM_ModelDestroy * const modelDestroy);
86 
87 /* Define prototypes for pair potential calculations */
88 static void calc_phi(double * epsilon,
89  double * C,
90  double * Rzero,
91  double * shift,
92  double * cutoff,
93  double r,
94  double * phi);
95 
96 static void calc_phi_dphi(double * epsilon,
97  double * C,
98  double * Rzero,
99  double * shift,
100  double * cutoff,
101  double r,
102  double * phi,
103  double * dphi);
104 
105 static void calc_phi_d2phi(double * epsilon,
106  double * C,
107  double * Rzero,
108  double * shift,
109  double * cutoff,
110  double r,
111  double * phi,
112  double * dphi,
113  double * d2phi);
114 
115 /* Calculate pair potential phi(r) */
116 static void calc_phi(double * epsilon,
117  double * C,
118  double * Rzero,
119  double * shift,
120  double * cutoff,
121  double r,
122  double * phi)
123 {
124  /* local variables */
125  double ep;
126  double ep2;
127 
128  ep = exp(-(*C) * (r - *Rzero));
129  ep2 = ep * ep;
130 
131  if (r > *cutoff)
132  {
133  /* Argument exceeds cutoff radius */
134  *phi = 0.0;
135  }
136  else
137  {
138  *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
139  }
140 
141  return;
142 }
143 
144 /* Calculate pair potential phi(r) and its derivative dphi(r) */
145 static void calc_phi_dphi(double * epsilon,
146  double * C,
147  double * Rzero,
148  double * shift,
149  double * cutoff,
150  double r,
151  double * phi,
152  double * dphi)
153 {
154  /* local variables */
155  double ep;
156  double ep2;
157 
158  ep = exp(-(*C) * (r - *Rzero));
159  ep2 = ep * ep;
160 
161  if (r > *cutoff)
162  {
163  /* Argument exceeds cutoff radius */
164  *phi = 0.0;
165  *dphi = 0.0;
166  }
167  else
168  {
169  *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
170  *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2);
171  }
172 
173  return;
174 }
175 
176 /* Calculate pair potential phi(r) and its 1st & 2nd derivatives dphi(r), */
177 /* d2phi(r) */
178 static void calc_phi_d2phi(double * epsilon,
179  double * C,
180  double * Rzero,
181  double * shift,
182  double * cutoff,
183  double r,
184  double * phi,
185  double * dphi,
186  double * d2phi)
187 {
188  /* local variables */
189  double ep;
190  double ep2;
191 
192  ep = exp(-(*C) * (r - *Rzero));
193  ep2 = ep * ep;
194 
195  if (r > *cutoff)
196  {
197  /* Argument exceeds cutoff radius */
198  *phi = 0.0;
199  *dphi = 0.0;
200  *d2phi = 0.0;
201  }
202  else
203  {
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);
207  }
208 
209  return;
210 }
211 
212 /* function to loop over particles */
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
217 
218 int loops(KIM_ModelCompute const * const modelCompute,
219  KIM_ModelComputeArguments const * const modelComputeArguments,
220  int neighborListIndex,
221  int * nParts,
222  int * particleContributing,
223  double * energy,
224  double * particleEnergy,
225  double * force,
226  double * coords,
227  double cutsq,
228  double epsilon,
229  double C,
230  double Rzero,
231  double shift,
232  double * cutoff,
233  int comp_energy,
234  int comp_force,
235  int comp_particleEnergy,
236  int comp_process_dEdr,
237  int comp_process_d2Edr2)
238 {
239  int ier;
240  int i;
241  int numOfPartNeigh;
242  int const * neighListOfCurrentPart;
243  int jj;
244  int j;
245  double Rsqij;
246  int k;
247  double Rij[DIM];
248  double phi;
249  double dphi;
250  double d2phi;
251  double dEidr;
252  double d2Eidr;
253  double * pRij = &(Rij[0]);
254  double Rij_pairs[2][3];
255  double const * pRij_pairs = &(Rij_pairs[0][0]);
256  int i_pairs[2];
257  int * pi_pairs = &(i_pairs[0]);
258  int j_pairs[2];
259  int * pj_pairs = &(j_pairs[0]);
260  double R;
261  double R_pairs[2];
262  double * pR_pairs = &(R_pairs[0]);
263 
264  /* loop over particles and compute enregy and forces */
265  LOG_INFORMATION("Starting main compute loop");
266  for (i = 0; i < *nParts; ++i)
267  {
268  if (particleContributing[i])
269  {
270  ier = KIM_ModelComputeArguments_GetNeighborList(modelComputeArguments,
271  neighborListIndex,
272  i,
273  &numOfPartNeigh,
274  &neighListOfCurrentPart);
275  if (ier)
276  {
277  /* some sort of problem, exit */
278  LOG_ERROR("GetNeighborList failed");
279  ier = TRUE;
280  return ier;
281  }
282 
283  /* loop over the neighbors of particle i */
284  for (jj = 0; jj < numOfPartNeigh; ++jj)
285  {
286  j = neighListOfCurrentPart[jj]; /* get neighbor ID */
287 
288  if (!(particleContributing[j] && (j < i)))
289  {
290  /* short-circuit half-list */
291 
292  /* compute relative position vector and squared distance */
293  Rsqij = 0.0;
294  for (k = 0; k < DIM; ++k)
295  {
296  Rij[k] = coords[j * DIM + k] - coords[i * DIM + k];
297 
298  /* compute squared distance */
299  Rsqij += Rij[k] * Rij[k];
300  }
301 
302  /* compute energy and force */
303  if (Rsqij < cutsq)
304  {
305  /* particles are interacting ? */
306  R = sqrt(Rsqij);
307  if (comp_process_d2Edr2)
308  {
309  /* compute pair potential and its derivatives */
311  &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi, &d2phi);
312 
313  /* compute dEidr */
314  if (particleContributing[j])
315  {
316  dEidr = dphi;
317  d2Eidr = d2phi;
318  }
319  else
320  {
321  dEidr = 0.5 * dphi;
322  d2Eidr = 0.5 * d2phi;
323  }
324  }
325  else if (comp_force || comp_process_dEdr)
326  {
327  /* compute pair potential and its derivative */
329  &epsilon, &C, &Rzero, &shift, cutoff, R, &phi, &dphi);
330 
331  /* compute dEidr */
332  if (particleContributing[j]) { dEidr = dphi; }
333  else
334  {
335  dEidr = 0.5 * dphi;
336  }
337  }
338  else
339  {
340  /* compute just pair potential */
341  calc_phi(&epsilon, &C, &Rzero, &shift, cutoff, R, &phi);
342  }
343 
344  /* contribution to energy */
345  if (comp_particleEnergy)
346  {
347  particleEnergy[i] += 0.5 * phi;
348  if (particleContributing[j]) { particleEnergy[j] += 0.5 * phi; }
349  }
350  if (comp_energy)
351  {
352  if (particleContributing[j]) { *energy += phi; }
353  else
354  {
355  *energy += 0.5 * phi;
356  }
357  }
358 
359  /* contribution to process_dEdr */
360  if (comp_process_dEdr)
361  {
363  modelComputeArguments, dEidr, R, pRij, i, j);
364  if (ier)
365  {
366  LOG_ERROR("ProcessDEDrTerm callback error");
367  ier = TRUE;
368  return ier;
369  }
370  }
371 
372  /* contribution to process_d2Edr2 */
373  if (comp_process_d2Edr2)
374  {
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;
381 
383  modelComputeArguments,
384  d2Eidr,
385  pR_pairs,
386  pRij_pairs,
387  pi_pairs,
388  pj_pairs);
389  if (ier)
390  {
391  LOG_ERROR("ProcessD2EDr2Term callback error");
392  ier = TRUE;
393  return ier;
394  }
395  }
396 
397  /* contribution to forces */
398  if (comp_force)
399  {
400  for (k = 0; k < DIM; ++k)
401  {
402  force[i * DIM + k]
403  += dEidr * Rij[k] / R; /* accumulate force on i */
404  force[j * DIM + k]
405  -= dEidr * Rij[k] / R; /* accumulate force on j */
406  }
407  }
408  }
409  } /* if (i < j) */
410  } /* loop on jj */
411  } /* if contributing */
412  } /* loop on i */
413  LOG_INFORMATION("Finished compute loop");
414 
415  return FALSE;
416 }
417 
418 /* compute function */
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
423 
424 static int
425 model_compute(KIM_ModelCompute const * const modelCompute,
426  KIM_ModelComputeArguments const * const modelComputeArguments)
427 {
428  /* local variables */
429  int ier;
430  int i;
431  int k;
432  int comp_energy;
433  int comp_force;
434  int comp_particleEnergy;
435  int comp_process_dEdr;
436  int comp_process_d2Edr2;
437 
438  int * particleSpeciesCodes;
439  int * particleContributing;
440  buffer * bufferPointer;
441  double * cutoff;
442  double cutsq;
443  double epsilon;
444  double C;
445  double Rzero;
446  double shift;
447  double * coords;
448  double * energy;
449  double * force;
450  double * particleEnergy;
451  int * nParts;
452  double dummy;
453 
454  /* check to see if we have been asked to compute the forces, */
455  /* particleEnergy, and d1Edr */
456  LOG_INFORMATION("Checking if call backs are present.");
458  modelComputeArguments,
460  &comp_process_dEdr);
462  modelComputeArguments,
464  &comp_process_d2Edr2);
465 
466  LOG_INFORMATION("Getting data pointers");
468  modelComputeArguments,
470  &nParts)
472  modelComputeArguments,
474  &particleSpeciesCodes)
476  modelComputeArguments,
478  &particleContributing)
480  modelComputeArguments,
482  &coords)
484  modelComputeArguments,
486  &energy)
488  modelComputeArguments,
490  &force)
492  modelComputeArguments,
494  &particleEnergy);
495  if (ier)
496  {
497  LOG_ERROR("get data pointers failed");
498  return ier;
499  }
500 
501  comp_energy = (energy != NULL);
502  comp_force = (force != NULL);
503  comp_particleEnergy = (particleEnergy != NULL);
504 
505  /* Check to be sure that the species are correct */
506 
507  ier = TRUE; /* assume an error */
508  for (i = 0; i < *nParts; ++i)
509  {
510  if (SPECCODE != particleSpeciesCodes[i])
511  {
512  LOG_ERROR("Unexpected species code detected");
513  return ier;
514  }
515  }
516  ier = FALSE; /* everything is ok */
517 
518  /* initialize potential energies, forces, and virial term */
519  LOG_INFORMATION("Initializing data");
520  if (comp_particleEnergy)
521  {
522  for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; }
523  }
524  if (comp_energy) { *energy = 0.0; }
525 
526  if (comp_force)
527  {
528  for (i = 0; i < *nParts; ++i)
529  {
530  for (k = 0; k < DIM; ++k) { force[i * DIM + k] = 0.0; }
531  }
532  }
533 
534  /* Compute energy and forces */
535 
536  /* set value of parameters */
538  (void **) &bufferPointer);
539  cutoff = &(bufferPointer->cutoff[0]);
540  cutsq = (*cutoff) * (*cutoff);
541  epsilon = EPSILON;
542  C = PARAM_C;
543  Rzero = RZERO;
544  /* set value of parameter shift */
545  dummy = 0.0;
546  /* call calc_phi with r=cutoff and shift=0.0 */
547  calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift);
548  /* set shift to -shift */
549  shift = -(shift);
550 
551  /* do computation for short list */
552  ier = loops(modelCompute,
553  modelComputeArguments,
554  0 /* neighborListIndex */,
555  nParts,
556  particleContributing,
557  energy,
558  particleEnergy,
559  force,
560  coords,
561  cutsq,
562  epsilon,
563  C,
564  Rzero,
565  shift,
566  cutoff,
567  comp_energy,
568  comp_force,
569  comp_particleEnergy,
570  comp_process_dEdr,
571  comp_process_d2Edr2);
572  if (ier) return TRUE;
573 
574  cutoff = &(bufferPointer->cutoff[1]);
575  cutsq = (*cutoff) * (*cutoff);
576  epsilon = EPSILON / 4.0;
577  C = PARAM_C / 2.0;
578  Rzero = RZERO * 1.5;
579  /* set value of parameter shift */
580  dummy = 0.0;
581  /* call calc_phi with r=cutoff and shift=0.0 */
582  calc_phi(&epsilon, &C, &Rzero, &dummy, cutoff, *cutoff, &shift);
583  /* set shift to -shift */
584  shift = -(shift);
585 
586  /* do computation for short list */
587  ier = loops(modelCompute,
588  modelComputeArguments,
589  1 /* neighborListIndex */,
590  nParts,
591  particleContributing,
592  energy,
593  particleEnergy,
594  force,
595  coords,
596  cutsq,
597  epsilon,
598  C,
599  Rzero,
600  shift,
601  cutoff,
602  comp_energy,
603  comp_force,
604  comp_particleEnergy,
605  comp_process_dEdr,
606  comp_process_d2Edr2);
607  if (ier) return TRUE;
608 
609  /* everything is great */
610  ier = FALSE;
611 
612  return ier;
613 }
614 
615 
616 /* Create function */
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
621 
622 int model_create(KIM_ModelCreate * const modelCreate,
623  KIM_LengthUnit const requestedLengthUnit,
624  KIM_EnergyUnit const requestedEnergyUnit,
625  KIM_ChargeUnit const requestedChargeUnit,
626  KIM_TemperatureUnit const requestedTemperatureUnit,
627  KIM_TimeUnit const requestedTimeUnit)
628 {
629  buffer * bufferPointer;
630  int error;
631 
632  /* use function pointer definitions to verify prototypes */
639 
640  (void) create; /* avoid unused parameter warnings */
641  (void) requestedLengthUnit;
642  (void) requestedEnergyUnit;
643  (void) requestedChargeUnit;
644  (void) requestedTemperatureUnit;
645  (void) requestedTimeUnit;
646 
647  /* set units */
648  LOG_INFORMATION("Set model units");
649  error = KIM_ModelCreate_SetUnits(modelCreate, /* ignoring requested units */
655 
656  /* register species */
657  LOG_INFORMATION("Setting species code");
658  error = error
660  modelCreate, KIM_SPECIES_NAME_Ar, SPECCODE);
661 
662  /* register numbering */
663  LOG_INFORMATION("Setting model numbering");
664  error = error
665  || KIM_ModelCreate_SetModelNumbering(modelCreate,
667 
668  /* register function pointers */
669  LOG_INFORMATION("Register model function pointers");
670  error = error
672  modelCreate,
675  TRUE,
676  (KIM_Function *) CACreate)
677  || KIM_ModelCreate_SetRoutinePointer(modelCreate,
680  TRUE,
681  (KIM_Function *) compute)
683  modelCreate,
686  TRUE,
687  (KIM_Function *) CADestroy)
688  || KIM_ModelCreate_SetRoutinePointer(modelCreate,
691  TRUE,
692  (KIM_Function *) destroy);
693 
694  /* allocate buffer */
695  bufferPointer = (buffer *) malloc(sizeof(buffer));
696 
697  /* store model buffer in KIM object */
698  LOG_INFORMATION("Set influence distance and cutoffs");
699  KIM_ModelCreate_SetModelBufferPointer(modelCreate, bufferPointer);
700 
701  /* set buffer values */
702  bufferPointer->influenceDistance = CUTOFF;
703  bufferPointer->cutoff[0] = CUTOFF / 2.0;
704  bufferPointer->cutoff[1] = CUTOFF;
707 
708  /* register influence distance */
710  modelCreate, &(bufferPointer->influenceDistance));
711 
712  /* register cutoff */
714  modelCreate,
716  &(bufferPointer->cutoff[0]),
717  &(bufferPointer
719 
720  if (error)
721  {
722  free(bufferPointer);
723  LOG_ERROR("Unable to successfully initialize model");
724  return TRUE;
725  }
726  else
727  return FALSE;
728 }
729 
730 /* Initialization function */
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
735 
736 int model_destroy(KIM_ModelDestroy * const modelDestroy)
737 {
738  buffer * bufferPointer;
739 
740  LOG_INFORMATION("Getting buffer");
742  (void **) &bufferPointer);
743  LOG_INFORMATION("Freeing model memory");
744  free(bufferPointer);
745 
746  return FALSE;
747 }
748 
749 /* compute arguments create routine */
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
754 
756  KIM_ModelCompute const * const modelCompute,
757  KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate)
758 {
759  int error;
760 
761  (void) modelCompute; /* avoid unused parameter warning */
762 
763  /* register arguments */
764  LOG_INFORMATION("Register argument supportStatus");
766  modelComputeArgumentsCreate,
769  error = error
771  modelComputeArgumentsCreate,
774  error = error
776  modelComputeArgumentsCreate,
779 
780  /* register call backs */
781  LOG_INFORMATION("Register call back supportStatus");
782  error = error
784  modelComputeArgumentsCreate,
787  error = error
789  modelComputeArgumentsCreate,
792 
793  if (error)
794  {
795  LOG_ERROR("Unable to successfully initialize compute arguments");
796  return TRUE;
797  }
798  else
799  return FALSE;
800 }
801 
802 /* compute arguments destroy routine */
804  KIM_ModelCompute const * const modelCompute,
805  KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy)
806 {
807  (void) modelCompute; /* avoid unused parameter warning */
808  (void) modelComputeArgumentsDestroy; /* avoid unused parameter warning */
809 
810  /* Nothing further to do */
811 
812  return FALSE;
813 }
void KIM_ModelCreate_SetInfluenceDistancePointer(KIM_ModelCreate *const modelCreate, double const *const influenceDistance)
Set the Model&#39;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&#39;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&#39;s COMPUTE_CALLBACK_NAME::ProcessD2EDr2Term routine.
An Extensible Enumeration for the EnergyUnit&#39;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&#39;s supported by the KIM API.
struct KIM_ModelCompute KIM_ModelCompute
Forward declaration.
An Extensible Enumeration for the ChargeUnit&#39;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&#39;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&#39;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&#39;s supported by the KIM API.
Definition: KIM_TimeUnit.h:41
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&#39;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&#39;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&#39;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...
double influenceDistance
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&#39;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&#39;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.