kim-api  2.1.4-git+v2.1.3-git-3-g4c859c7f.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
ex_model_driver_P_Morse.c
Go to the documentation of this file.
1 /* */
2 /* CDDL HEADER START */
3 /* */
4 /* The contents of this file are subject to the terms of the Common */
5 /* Development and Distribution License Version 1.0 (the "License"). */
6 /* */
7 /* You can obtain a copy of the license at */
8 /* http://www.opensource.org/licenses/CDDL-1.0. See the License for the */
9 /* specific language governing permissions and limitations under the License. */
10 /* */
11 /* When distributing Covered Code, include this CDDL HEADER in each file and */
12 /* include the License file in a prominent location with the name */
13 /* LICENSE.CDDL. If applicable, add the following below this CDDL HEADER, */
14 /* with the fields enclosed by brackets "[]" replaced with your own */
15 /* identifying information: */
16 /* */
17 /* Portions Copyright (c) [yyyy] [name of copyright owner]. */
18 /* All rights reserved. */
19 /* */
20 /* CDDL HEADER END */
21 /* */
22 
23 /* */
24 /* Copyright (c) 2013--2019, Regents of the University of Minnesota. */
25 /* All rights reserved. */
26 /* */
27 /* Contributors: */
28 /* Ryan S. Elliott */
29 /* Ellad B. Tadmor */
30 /* Stephen M. Whalen */
31 /* */
32 
33 /******************************************************************************/
34 /* */
35 /* ex_model_driver_P_Morse pair potential KIM Model Driver */
36 /* shifted to have zero energy at the cutoff radius */
37 /* */
38 /* Language: C */
39 /* */
40 /******************************************************************************/
41 
42 
43 #include "KIM_LogMacros.h"
44 #include "KIM_ModelDriverHeaders.h"
45 #include <math.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 
49 #define TRUE 1
50 #define FALSE 0
51 
52 /******************************************************************************/
53 /* Below are the definitions for some constants */
54 /******************************************************************************/
55 #define DIM 3 /* dimensionality of space */
56 #define SPECCODE 1 /* internal species code */
57 #define SPEC_NAME_LEN 64 /* max length of species name string */
58 #define SPEC_NAME_FMT "%63s"
59 
60 
61 /* Define prototype for Model Driver init */
62 int model_driver_create(KIM_ModelDriverCreate * const modelDriverCreate,
63  KIM_LengthUnit const requestedLengthUnit,
64  KIM_EnergyUnit const requestedEnergyUnit,
65  KIM_ChargeUnit const requestedChargeUnit,
66  KIM_TemperatureUnit const requestedTemperatureUnit,
67  KIM_TimeUnit const requestedTimeUnit);
68 
69 /* Define prototypes for destroy */
70 /* defined as static to avoid namespace clashes with other codes */
71 static int destroy_routine(KIM_ModelDestroy * const modelDestroy);
72 
73 /* Define prototype for routines */
74 static int
75 compute_routine(KIM_ModelCompute const * const modelCompute,
76  KIM_ModelComputeArguments const * const modelComputeArguments);
77 static int compute_arguments_create(
78  KIM_ModelCompute const * const modelCompute,
79  KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate);
80 static int compute_arguments_destroy(
81  KIM_ModelCompute const * const modelCompute,
82  KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy);
83 static int refresh_routine(KIM_ModelRefresh * const modelRefresh);
84 static int
86  modelWriteParameterizedModel);
87 
88 /* Define prototypes for pair potential calculations */
89 static void calc_phi(double const * epsilon,
90  double const * C,
91  double const * Rzero,
92  double const * shift,
93  double const cutoff,
94  double const r,
95  double * phi);
96 
97 static void calc_phi_dphi(double const * epsilon,
98  double const * C,
99  double const * Rzero,
100  double const * shift,
101  double const cutoff,
102  double const r,
103  double * phi,
104  double * dphi);
105 
106 /* Define model_buffer structure */
108 {
110  double cutoff;
111  double cutsq;
114  double epsilon;
115  double C;
116  double Rzero;
117  double shift;
118 };
119 
120 
121 /* Calculate pair potential phi(r) */
122 static void calc_phi(double const * epsilon,
123  double const * C,
124  double const * Rzero,
125  double const * shift,
126  double const cutoff,
127  double const r,
128  double * phi)
129 {
130  /* local variables */
131  double ep;
132  double ep2;
133 
134  ep = exp(-(*C) * (r - *Rzero));
135  ep2 = ep * ep;
136 
137  if (r > cutoff)
138  {
139  /* Argument exceeds cutoff radius */
140  *phi = 0.0;
141  }
142  else
143  {
144  *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
145  }
146 
147  return;
148 }
149 
150 /* Calculate pair potential phi(r) and its derivative dphi(r) */
151 static void calc_phi_dphi(double const * epsilon,
152  double const * C,
153  double const * Rzero,
154  double const * shift,
155  double const cutoff,
156  double const r,
157  double * phi,
158  double * dphi)
159 {
160  /* local variables */
161  double ep;
162  double ep2;
163 
164  ep = exp(-(*C) * (r - *Rzero));
165  ep2 = ep * ep;
166 
167  if (r > cutoff)
168  {
169  /* Argument exceeds cutoff radius */
170  *phi = 0.0;
171  *dphi = 0.0;
172  }
173  else
174  {
175  *phi = (*epsilon) * (-ep2 + 2.0 * ep) + *shift;
176  *dphi = 2.0 * (*epsilon) * (*C) * (-ep + ep2);
177  }
178 
179  return;
180 }
181 
182 /* compute function */
183 #undef KIM_LOGGER_FUNCTION_NAME
184 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelCompute_LogEntry
185 #undef KIM_LOGGER_OBJECT_NAME
186 #define KIM_LOGGER_OBJECT_NAME modelCompute
187 static int
188 compute_routine(KIM_ModelCompute const * const modelCompute,
189  KIM_ModelComputeArguments const * const modelComputeArguments)
190 {
191  /* local variables */
192  double R;
193  double Rsqij;
194  double phi;
195  double dphi;
196  double dEidr;
197  double Rij[DIM];
198  int ier;
199  int i;
200  int j;
201  int jj;
202  int k;
203  int const * neighListOfCurrentPart;
204  struct model_buffer * buffer;
205  int comp_energy;
206  int comp_force;
207  int comp_particleEnergy;
208 
209  int * nParts;
210  int * particleSpeciesCodes;
211  int * particleContributing;
212  double cutoff;
213  double * cutsq;
214  double * epsilon;
215  double * C;
216  double * Rzero;
217  double * shift;
218  double * coords;
219  double * energy;
220  double * force;
221  double * particleEnergy;
222  int numOfPartNeigh;
223 
224  /* get buffer from KIM object */
225  KIM_ModelCompute_GetModelBufferPointer(modelCompute, (void **) &buffer);
226 
227  /* unpack info from the buffer */
228  cutoff = buffer->influenceDistance;
229  cutsq = &(buffer->cutsq);
230  epsilon = &(buffer->epsilon);
231  C = &(buffer->C);
232  Rzero = &(buffer->Rzero);
233  shift = &(buffer->shift);
234 
236  modelComputeArguments,
238  &nParts)
240  modelComputeArguments,
242  &particleSpeciesCodes)
244  modelComputeArguments,
246  &particleContributing)
248  modelComputeArguments,
250  &coords)
252  modelComputeArguments,
254  &energy)
256  modelComputeArguments,
258  &force)
260  modelComputeArguments,
262  &particleEnergy);
263  if (ier)
264  {
265  LOG_ERROR("GetArgumentPointer");
266  return ier;
267  }
268 
269  comp_energy = (energy != NULL);
270  comp_force = (force != NULL);
271  comp_particleEnergy = (particleEnergy != NULL);
272 
273  /* Check to be sure that the species are correct */
274 
275  ier = TRUE; /* assume an error */
276  for (i = 0; i < *nParts; ++i)
277  {
278  if (SPECCODE != particleSpeciesCodes[i])
279  {
280  LOG_ERROR("Unexpected species code detected");
281  return ier;
282  }
283  }
284  ier = FALSE; /* everything is ok */
285 
286  /* initialize potential energies, forces, and virial term */
287  if (comp_particleEnergy)
288  {
289  for (i = 0; i < *nParts; ++i) { particleEnergy[i] = 0.0; }
290  }
291  if (comp_energy) { *energy = 0.0; }
292 
293  if (comp_force)
294  {
295  for (i = 0; i < *nParts; ++i)
296  {
297  for (k = 0; k < DIM; ++k) { force[i * DIM + k] = 0.0; }
298  }
299  }
300 
301  /* Compute energy and forces */
302 
303  /* loop over particles and compute enregy and forces */
304  for (i = 0; i < *nParts; ++i)
305  {
306  if (particleContributing[i])
307  {
308  ier = KIM_ModelComputeArguments_GetNeighborList(modelComputeArguments,
309  0,
310  i,
311  &numOfPartNeigh,
312  &neighListOfCurrentPart);
313  if (ier)
314  {
315  /* some sort of problem, exit */
316  LOG_ERROR("KIM_get_neigh");
317  ier = TRUE;
318  return ier;
319  }
320 
321  /* loop over the neighbors of particle i */
322  for (jj = 0; jj < numOfPartNeigh; ++jj)
323  {
324  j = neighListOfCurrentPart[jj]; /* get neighbor ID */
325 
326  /* compute relative position vector and squared distance */
327  Rsqij = 0.0;
328  for (k = 0; k < DIM; ++k)
329  {
330  Rij[k] = coords[j * DIM + k] - coords[i * DIM + k];
331  /* compute squared distance */
332  Rsqij += Rij[k] * Rij[k];
333  }
334 
335  /* compute energy and force */
336  if (Rsqij < *cutsq)
337  {
338  /* particles are interacting ? */
339  R = sqrt(Rsqij);
340  if (comp_force)
341  {
342  /* compute pair potential and its derivative */
343  calc_phi_dphi(epsilon, C, Rzero, shift, cutoff, R, &phi, &dphi);
344 
345  /* compute dEidr */
346  dEidr = 0.5 * dphi;
347  }
348  else
349  {
350  /* compute just pair potential */
351  calc_phi(epsilon, C, Rzero, shift, cutoff, R, &phi);
352  }
353 
354  /* contribution to energy */
355  if (comp_particleEnergy) { particleEnergy[i] += 0.5 * phi; }
356  if (comp_energy) { *energy += 0.5 * phi; }
357 
358  /* contribution to forces */
359  if (comp_force)
360  {
361  for (k = 0; k < DIM; ++k)
362  {
363  force[i * DIM + k]
364  += dEidr * Rij[k] / R; /* accumulate force on i */
365  force[j * DIM + k]
366  -= dEidr * Rij[k] / R; /* accumulate force on j */
367  }
368  }
369  } /* if Rsqij */
370  } /* loop on jj */
371  } /* if particleContributing */
372  } /* infinite while loop (terminated by break statements above) */
373 
374  /* everything is great */
375  ier = FALSE;
376 
377  return ier;
378 }
379 
380 /* Create function */
381 #undef KIM_LOGGER_FUNCTION_NAME
382 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelDriverCreate_LogEntry
383 #undef KIM_LOGGER_OBJECT_NAME
384 #define KIM_LOGGER_OBJECT_NAME modelDriverCreate
385 int model_driver_create(KIM_ModelDriverCreate * const modelDriverCreate,
386  KIM_LengthUnit const requestedLengthUnit,
387  KIM_EnergyUnit const requestedEnergyUnit,
388  KIM_ChargeUnit const requestedChargeUnit,
389  KIM_TemperatureUnit const requestedTemperatureUnit,
390  KIM_TimeUnit const requestedTimeUnit)
391 {
392  /* KIM variables */
393  int numberOfParameterFiles;
394  char const * paramfile1name;
395 
396  /* Local variables */
397  FILE * fid;
398  char speciesNameString[SPEC_NAME_LEN];
400  double cutoff;
401  double epsilon;
402  double C;
403  double Rzero;
404  int ier;
405  double dummy;
406  struct model_buffer * buffer;
407 
408  /* Use function pointer definitions to verify prototypes */
418 
419 
420  (void) create; /* avoid unused parameter warnings */
421  (void) requestedLengthUnit;
422  (void) requestedEnergyUnit;
423  (void) requestedChargeUnit;
424  (void) requestedTemperatureUnit;
425  (void) requestedTimeUnit;
426 
427 
428  /* using fixed units */
429  ier = KIM_ModelDriverCreate_SetUnits(modelDriverCreate,
435  if (ier == TRUE)
436  {
437  LOG_ERROR("Problem setting units");
438  return ier;
439  }
440 
441  ier = KIM_ModelDriverCreate_SetModelNumbering(modelDriverCreate,
443  if (ier == TRUE)
444  {
445  LOG_ERROR("Unable to set numbering");
446  return ier;
447  }
448 
449  /* store pointer to functions in KIM object */
451  modelDriverCreate,
454  TRUE,
455  (KIM_Function *) CACreate)
457  modelDriverCreate,
460  TRUE,
461  (KIM_Function *) compute)
463  modelDriverCreate,
466  TRUE,
467  (KIM_Function *) refresh)
469  modelDriverCreate,
472  FALSE,
473  (KIM_Function *) writeModel)
475  modelDriverCreate,
478  TRUE,
479  (KIM_Function *) CADestroy)
481  modelDriverCreate,
484  TRUE,
485  (KIM_Function *) destroy);
486 
487  /* get number of parameter files */
489  &numberOfParameterFiles);
490  /* set paramfile1name */
491  if (numberOfParameterFiles != 1)
492  {
493  ier = TRUE;
494  LOG_ERROR("Incorrect number of parameter files.");
495  return ier;
496  }
498  modelDriverCreate, 0, &paramfile1name);
499  if (ier == TRUE)
500  {
501  LOG_ERROR("Unable to get parameter file name.");
502  return ier;
503  }
504 
505  /* Read in model parameters from parameter file */
506  fid = fopen(paramfile1name, "r");
507  if (fid == NULL)
508  {
509  ier = TRUE;
510  LOG_ERROR("Unable to open parameter file for Morse parameters");
511  return ier;
512  }
513 
514  ier = fscanf(fid,
515  SPEC_NAME_FMT " \n%lf \n%lf \n%lf \n%lf",
516  speciesNameString, /* element symbol */
517  &cutoff, /* cutoff distance in angstroms */
518  &epsilon, /* Morse epsilon in eV */
519  &C, /* Morse C in 1/Angstroms */
520  &Rzero /* Morse Rzero in Angstroms */
521  );
522  fclose(fid);
523 
524  /* check that we read the right number of parameters */
525  if (5 != ier)
526  {
527  ier = TRUE;
528  LOG_ERROR("Unable to read all parameters");
529  return ier;
530  }
531 
532  /* register species */
533  speciesName = KIM_SpeciesName_FromString(speciesNameString);
535  modelDriverCreate, speciesName, SPECCODE);
536  if (ier == TRUE)
537  {
538  LOG_ERROR("Unable to set species code for Ar.");
539  return ier;
540  }
541 
542 
543  /* allocate buffer */
544  buffer = (struct model_buffer *) malloc(sizeof(struct model_buffer));
545  if (NULL == buffer)
546  {
547  ier = TRUE;
548  LOG_ERROR("malloc");
549  return ier;
550  }
551 
552  /* setup buffer */
553  /* set value of parameters */
554  buffer->influenceDistance = cutoff;
555  buffer->cutoff = cutoff;
556  buffer->cutsq = (cutoff) * (cutoff);
558  sprintf(buffer->speciesName, "%s", speciesNameString);
559  buffer->epsilon = epsilon;
560  buffer->C = C;
561  buffer->Rzero = Rzero;
562  /* set value of parameter shift */
563  dummy = 0.0;
564  /* call calc_phi with r=cutoff and shift=0.0 */
565  calc_phi(&(buffer->epsilon),
566  &(buffer->C),
567  &(buffer->Rzero),
568  &dummy,
569  cutoff,
570  cutoff,
571  &(buffer->shift));
572  /* set shift to -shift */
573  buffer->shift = -buffer->shift;
574 
575  /* end setup buffer */
576 
577  /* store in model buffer */
579  (void *) buffer);
580 
581  /* publish model parameters */
582  ier = KIM_ModelDriverCreate_SetParameterPointerDouble(modelDriverCreate,
583  1,
584  &(buffer->cutoff),
585  "cutoff",
586  "pair cutoff distance")
588  1,
589  &(buffer->epsilon),
590  "epsilon",
591  "Morse epsilon")
593  modelDriverCreate, 1, &(buffer->C), "C", "Morse C")
595  modelDriverCreate, 1, &(buffer->Rzero), "Rzero", "Morse Rzero");
596  if (ier == TRUE)
597  {
598  LOG_ERROR("Unable to set parameter pointer(s).");
599  return TRUE;
600  }
601 
602  /* store model cutoff in KIM object */
604  modelDriverCreate, &(buffer->influenceDistance));
606  modelDriverCreate,
607  1,
608  &(buffer->cutoff),
609  &(buffer->modelWillNotRequestNeighborsOfNoncontributingParticles));
610 
611  return FALSE;
612 }
613 
614 /* Refresh function */
615 #undef KIM_LOGGER_FUNCTION_NAME
616 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelRefresh_LogEntry
617 #undef KIM_LOGGER_OBJECT_NAME
618 #define KIM_LOGGER_OBJECT_NAME modelRefresh
619 int refresh_routine(KIM_ModelRefresh * const modelRefresh)
620 {
621  double dummy;
622  struct model_buffer * buffer;
623 
624  /* get model buffer from KIM object */
625  KIM_ModelRefresh_GetModelBufferPointer(modelRefresh, (void **) &buffer);
626 
627  /* set value of parameter shift */
628  dummy = 0.0;
629  /* call calc_phi with r=cutoff and shift=0.0 */
630  calc_phi(&(buffer->epsilon),
631  &(buffer->C),
632  &(buffer->Rzero),
633  &dummy,
634  buffer->cutoff,
635  buffer->cutoff,
636  &(buffer->shift));
637  /* set shift to -shift */
638  buffer->shift = -buffer->shift;
639 
640 
641  /* store model cutoff in KIM object */
643  &(buffer->influenceDistance));
645  modelRefresh,
646  1,
647  &(buffer->cutoff),
648  &(buffer->modelWillNotRequestNeighborsOfNoncontributingParticles));
649 
650  return FALSE;
651 }
652 
653 
654 /* destroy function */
655 static int destroy_routine(KIM_ModelDestroy * const modelDestroy)
656 {
657  /* Local variables */
658  struct model_buffer * buffer;
659  int ier;
660 
661  /* get model buffer from KIM object */
662  KIM_ModelDestroy_GetModelBufferPointer(modelDestroy, (void **) &buffer);
663 
664  /* free the buffer */
665  free(buffer);
666 
667  ier = FALSE;
668  return ier;
669 }
670 
671 /* compute arguments create routine */
672 #undef KIM_LOGGER_FUNCTION_NAME
673 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelComputeArgumentsCreate_LogEntry
674 #undef KIM_LOGGER_OBJECT_NAME
675 #define KIM_LOGGER_OBJECT_NAME modelComputeArgumentsCreate
677  KIM_ModelCompute const * const modelCompute,
678  KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate)
679 {
680  int ier;
681 
682  (void) modelCompute; /* avoid unused parameter warning */
683 
684  /* register arguments */
686  modelComputeArgumentsCreate,
690  modelComputeArgumentsCreate,
694  modelComputeArgumentsCreate,
697  if (ier == TRUE)
698  {
699  LOG_ERROR("Unable to set argument supportStatus.");
700  return TRUE;
701  }
702  else
703  {
704  return FALSE;
705  }
706 }
707 
708 /* compute arguments destroy routine */
710  KIM_ModelCompute const * const modelCompute,
711  KIM_ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy)
712 {
713  (void) modelCompute; /* avoid unused parameter warning */
714  (void) modelComputeArgumentsDestroy;
715 
716  /* Nothing further to do */
717 
718  return FALSE;
719 }
720 
721 /* write parameterized model routine */
722 #undef KIM_LOGGER_FUNCTION_NAME
723 #define KIM_LOGGER_FUNCTION_NAME KIM_ModelWriteParameterizedModel_LogEntry
724 #undef KIM_LOGGER_OBJECT_NAME
725 #define KIM_LOGGER_OBJECT_NAME modelWriteParameterizedModel
727  KIM_ModelWriteParameterizedModel const * const modelWriteParameterizedModel)
728 {
729  FILE * fp;
730  char stringBuffer[2048];
731  struct model_buffer const * buffer;
732  char const * path;
733  char const * modelName;
734 
735  /* get buffer from KIM object */
737  modelWriteParameterizedModel, (void **) &buffer);
738 
739  KIM_ModelWriteParameterizedModel_GetPath(modelWriteParameterizedModel, &path);
740  KIM_ModelWriteParameterizedModel_GetModelName(modelWriteParameterizedModel,
741  &modelName);
742 
743  sprintf(stringBuffer, "%s.params", modelName);
745  modelWriteParameterizedModel, stringBuffer);
746  sprintf(stringBuffer, "%s/%s.params", path, modelName);
747  fp = fopen(stringBuffer, "w");
748  if (NULL == fp)
749  {
750  LOG_ERROR("Unable to open parameter file for writing.");
751  return TRUE;
752  }
753 
754  fprintf(fp, "%s\n", buffer->speciesName);
755  fprintf(fp, "%20.10f\n", buffer->cutoff);
756  fprintf(fp, "%20.10f\n", buffer->epsilon);
757  fprintf(fp, "%20.10f\n", buffer->C);
758  fprintf(fp, "%20.10f\n", buffer->Rzero);
759  fclose(fp);
760 
761  return FALSE;
762 }
static int write_parameterized_model(KIM_ModelWriteParameterizedModel const *const modelWriteParameterizedModel)
int KIM_ModelComputeArgumentsCreateFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
#define SPECCODE
KIM_SupportStatus const KIM_SUPPORT_STATUS_optional
The standard optional status.
struct buffer buffer
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_coordinates
The standard coordinates argument.
int KIM_ModelDriverCreate_SetUnits(KIM_ModelDriverCreate *const modelDriverCreate, 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.
int KIM_ModelDriverCreate_SetRoutinePointer(KIM_ModelDriverCreate *const modelDriverCreate, KIM_ModelRoutineName const modelRoutineName, KIM_LanguageName const languageName, int const required, KIM_Function *const fptr)
Set the function pointer for the ModelRoutineName of interest.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_partialParticleEnergy
The standard partialParticleEnergy argument.
void() KIM_Function(void)
Generic function type.
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)
static int compute_arguments_destroy(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
KIM_LanguageName const KIM_LANGUAGE_NAME_c
The standard c language.
void KIM_ModelDriverCreate_GetNumberOfParameterFiles(KIM_ModelDriverCreate const *const modelDriverCreate, int *const numberOfParameterFiles)
Get the number of parameter files provided by the parameterized model.
int KIM_ModelDriverCreateFunction(KIM_ModelDriverCreate *const modelDriverCreate, 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.
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.
char speciesName[SPEC_NAME_LEN]
int KIM_ModelComputeArguments_GetArgumentPointerDouble(KIM_ModelComputeArguments const *const modelComputeArguments, KIM_ComputeArgumentName const computeArgumentName, double **const ptr)
Get the data pointer for a ComputeArgumentName.
KIM_SpeciesName KIM_SpeciesName_FromString(char const *const str)
Create a SpeciesName object corresponding to the provided string. If the string does not match one of...
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_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_WriteParameterizedModel
The standard WriteParameterizedModel routine.
void KIM_ModelRefresh_GetModelBufferPointer(KIM_ModelRefresh const *const modelRefresh, void **const ptr)
Get the Model&#39;s buffer pointer within the Model object.
void KIM_ModelWriteParameterizedModel_SetParameterFileName(KIM_ModelWriteParameterizedModel const *const modelWriteParameterizedModel, char const *const fileName)
Set the file name for the next parameter file.
KIM_ComputeArgumentName const KIM_COMPUTE_ARGUMENT_NAME_particleSpeciesCodes
The standard particleSpeciesCodes argument.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Compute
The standard Compute routine.
static void calc_phi_dphi(double const *epsilon, double const *C, double const *Rzero, double const *shift, double const cutoff, double const r, double *phi, double *dphi)
void KIM_ModelWriteParameterizedModel_GetModelBufferPointer(KIM_ModelWriteParameterizedModel const *const modelWriteParameterizedModel, void **const ptr)
Get the Model&#39;s buffer pointer within the Model object.
An Extensible Enumeration for the LengthUnit&#39;s supported by the KIM API.
recursive subroutine, public refresh(model_refresh_handle, ierr)
struct KIM_ModelCompute KIM_ModelCompute
Forward declaration.
An Extensible Enumeration for the ChargeUnit&#39;s supported by the KIM API.
KIM_TemperatureUnit const KIM_TEMPERATURE_UNIT_unused
Indicates that a TemperatureUnit is not used.
void KIM_ModelRefresh_SetInfluenceDistancePointer(KIM_ModelRefresh *const modelRefresh, double const *const influenceDistance)
Set the Model&#39;s influence distance data pointer.
struct KIM_ModelComputeArgumentsCreate KIM_ModelComputeArgumentsCreate
Forward declaration.
ChargeUnit const C
The standard Coulomb unit of charge.
void KIM_ModelDriverCreate_SetInfluenceDistancePointer(KIM_ModelDriverCreate *const modelDriverCreate, double const *const influenceDistance)
Set the Model&#39;s influence distance data pointer.
struct KIM_ModelDestroy KIM_ModelDestroy
Forward declaration.
KIM_TimeUnit const KIM_TIME_UNIT_unused
Indicates that a TimeUnit is not used.
static int refresh_routine(KIM_ModelRefresh *const modelRefresh)
#define TRUE
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.
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.
void KIM_ModelCompute_GetModelBufferPointer(KIM_ModelCompute const *const modelCompute, void **const ptr)
Get the Model&#39;s buffer pointer within the Model object.
int KIM_ModelDriverCreate_GetParameterFileName(KIM_ModelDriverCreate const *const modelDriverCreate, int const index, char const **const parameterFileName)
Get a particular parameter file name.
int KIM_ModelWriteParameterizedModelFunction(KIM_ModelWriteParameterizedModel const *const modelWriteParameterizedModel)
Prototype for MODEL_ROUTINE_NAME::WriteParameterizedModel routine.
static int compute_routine(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments)
int model_driver_create(KIM_ModelDriverCreate *const modelDriverCreate, KIM_LengthUnit const requestedLengthUnit, KIM_EnergyUnit const requestedEnergyUnit, KIM_ChargeUnit const requestedChargeUnit, KIM_TemperatureUnit const requestedTemperatureUnit, KIM_TimeUnit const requestedTimeUnit)
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:46
int KIM_ModelDriverCreate_SetSpeciesCode(KIM_ModelDriverCreate *const modelDriverCreate, KIM_SpeciesName const speciesName, int const code)
Set integer code for supported SpeciesName.
int KIM_ModelDriverCreate_SetParameterPointerDouble(KIM_ModelDriverCreate *const modelDriverCreate, int const extent, double *const ptr, char const *const name, char const *const description)
Set the next parameter data pointer to be provided by the model.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
#define FALSE
static int compute_arguments_create(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
struct KIM_ModelComputeArgumentsDestroy KIM_ModelComputeArgumentsDestroy
Forward declaration.
static void calc_phi(double const *epsilon, double const *C, double const *Rzero, double const *shift, double const cutoff, double const r, double *phi)
struct KIM_ModelRefresh KIM_ModelRefresh
Forward declaration.
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...
#define DIM
KIM_EnergyUnit const KIM_ENERGY_UNIT_eV
The standard electronvolt unit of energy.
int modelWillNotRequestNeighborsOfNoncontributingParticles
void KIM_ModelRefresh_SetNeighborListPointers(KIM_ModelRefresh *const modelRefresh, int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model&#39;s neighbor list data pointers.
KIM_ChargeUnit const KIM_CHARGE_UNIT_unused
Indicates that a ChargeUnit is not used.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes argument.
void KIM_ModelWriteParameterizedModel_GetModelName(KIM_ModelWriteParameterizedModel const *const modelWriteParameterizedModel, char const **const modelName)
Get the name of the new parameterized model.
int KIM_ModelComputeFunction(KIM_ModelCompute const *const modelCompute, KIM_ModelComputeArguments const *const modelComputeArguments)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
int KIM_ModelRefreshFunction(KIM_ModelRefresh *const modelRefresh)
Prototype for MODEL_ROUTINE_NAME::Refresh routine.
struct KIM_ModelWriteParameterizedModel KIM_ModelWriteParameterizedModel
Forward declaration.
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.
An Extensible Enumeration for the TemperatureUnit&#39;s supported by the KIM API.
#define SPEC_NAME_LEN
void KIM_ModelDriverCreate_SetModelBufferPointer(KIM_ModelDriverCreate *const modelDriverCreate, void *const ptr)
Set the Model&#39;s buffer pointer within the Model object.
KIM_ModelRoutineName const KIM_MODEL_ROUTINE_NAME_Refresh
The standard Refresh routine.
int KIM_ModelDriverCreate_SetModelNumbering(KIM_ModelDriverCreate *const modelDriverCreate, KIM_Numbering const numbering)
Set the Model&#39;s particle Numbering.
struct KIM_ModelDriverCreate KIM_ModelDriverCreate
Forward declaration.
struct KIM_ModelComputeArguments KIM_ModelComputeArguments
Forward declaration.
KIM_LengthUnit const KIM_LENGTH_UNIT_A
The standard angstrom unit of length.
void KIM_ModelWriteParameterizedModel_GetPath(KIM_ModelWriteParameterizedModel const *const modelWriteParameterizedModel, char const **const path)
Get the directory path where the parameterized model files should be written.
#define SPEC_NAME_FMT
void KIM_ModelDriverCreate_SetNeighborListPointers(KIM_ModelDriverCreate *const modelDriverCreate, int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model&#39;s neighbor list data pointers.
static int destroy_routine(KIM_ModelDestroy *const modelDestroy)
An Extensible Enumeration for the SpeciesName&#39;s supported by the KIM API.
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.