kim-api  2.2.1+v2.2.1.GNU.GNU.
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
ex_model_Ar_SLJ_MultiCutoff.f90
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 Development
5 ! 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 LICENSE.CDDL.
13 ! If applicable, add the following below this CDDL HEADER, with the fields
14 ! enclosed by brackets "[]" replaced with your own identifying information:
15 !
16 ! Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
17 !
18 ! CDDL HEADER END
19 !
20 
21 !
22 ! Copyright (c) 2013--2020, Regents of the University of Minnesota.
23 ! All rights reserved.
24 !
25 ! Contributors:
26 ! Ellad B. Tadmor
27 !
28 
29 !****************************************************************************
30 !**
31 !** MODULE ex_model_Ar_SLJ_MultiCutoff
32 !**
33 !** Spring-modified Lennard-Jones (SLJ) pair potential model for Ar
34 !**
35 !** V = 0.5 \sum_i \sum_j eps_i eps_j 4 [ (sig/r_ij)^12 - (sig/r_ij)^6 ] (1)
36 !**
37 !** where
38 !** eps_i = 0.5 \sum_k spring (r_ik)^2 (2)
39 !**
40 !** See README for details.
41 !**
42 !** Language: Fortran 2003
43 !**
44 !** Author: Ellad B. Tadmor
45 !**
46 !** Date: August 23, 2018
47 !**
48 !****************************************************************************
49 
51 
52  use, intrinsic :: iso_c_binding
54  implicit none
55 
56  save
57  private
58  public compute_energy_forces, &
62  model_cutoff1, &
63  model_cutoff2, &
64  speccode, &
65  buffer_type
66 
67  ! Below are the definitions and values of all Model parameters
68  integer(c_int), parameter :: cd = c_double ! used for literal constants
69  integer(c_int), parameter :: dim = 3 ! dimensionality of space
70  integer(c_int), parameter :: speccode = 1 ! internal species code
71 
72  !-----------------------------------------------------------------------------
73  ! Below are the definitions and values of all additional model parameters
74  !
75  ! Recall that the Fortran 2003 format for declaring parameters is as follows:
76  !
77  ! integer(c_int), parameter :: parname = value ! This defines an integer
78  ! ! parameter called `parname'
79  ! ! with a value equal to
80  ! ! `value' (a number)
81  !
82  ! real(c_double), parameter :: parname = value ! This defines a real(c_double)
83  ! ! parameter called `parname'
84  ! ! with a value equal to
85  ! ! `value' (a number)
86  !-----------------------------------------------------------------------------
87  real(c_double), parameter :: lj_spring = 0.00051226_cd
88  real(c_double), parameter :: lj_sigma = 5.26_cd / 1.74724_cd
89  ! experimental fcc lattice constant is a0=5.26
90  real(c_double), parameter :: model_cutoff1 = 1.25 * lj_sigma
91  ! short-range nearest neighbor for fcc
92  real(c_double), parameter :: model_cutoff2 = 2.25 * lj_sigma
93  ! long-range third neighbor for fcc
94  real(c_double), parameter :: model_cutsq1 = model_cutoff1**2
95  real(c_double), parameter :: model_cutsq2 = model_cutoff2**2
96 
97  type, bind(c) :: buffer_type
98  real(c_double) :: influence_distance
99  real(c_double) :: cutoff(2)
100  integer(c_int) :: &
101  model_will_not_request_neighbors_of_noncontributing_particles(2)
102  end type buffer_type
103 
104 contains
105 
106  !-----------------------------------------------------------------------------
107  !
108  ! Calculate Lennard-Jones potential phi(r) and, if requested,
109  ! its derivative dphi(r)
110  !
111  !-----------------------------------------------------------------------------
112  recursive subroutine calc_phi(r, phi, dphi, calc_deriv)
113  implicit none
114 
115  !-- Transferred variables
116  real(c_double), intent(in) :: r
117  real(c_double), intent(out) :: phi
118  real(c_double), intent(out) :: dphi
119  logical, intent(in) :: calc_deriv
120 
121  !-- Local variables
122  real(c_double) rsq, sor, sor6, sor12
123 
124  rsq = r * r ! r^2
125  sor = lj_sigma / r ! (sig/r)
126  sor6 = sor * sor * sor !
127  sor6 = sor6 * sor6 ! (sig/r)^6
128  sor12 = sor6 * sor6 ! (sig/r)^12
129  if (r > model_cutoff2) then
130  ! Argument exceeds cutoff radius
131  phi = 0.0_cd
132  if (calc_deriv) dphi = 0.0_cd
133  else
134  phi = 4.0_cd * (sor12 - sor6)
135  if (calc_deriv) dphi = 24.0_cd * (-2.0_cd * sor12 + sor6) / r
136  end if
137 
138  end subroutine calc_phi
139 
140  !-----------------------------------------------------------------------------
141  !
142  ! Calculate short-range linear spring-based energy amplitude for `atom`
143  !
144  !-----------------------------------------------------------------------------
145  recursive subroutine calc_spring_energyamp(model_compute_arguments_handle, &
146  atom, coor, eps, ierr)
147  implicit none
148 
149  !-- Transferred variables
150  type(kim_model_compute_arguments_handle_type), &
151  intent(in) :: model_compute_arguments_handle
152  integer(c_int), intent(in) :: atom
153  real(c_double), intent(in) :: coor(:, :)
154  real(c_double), intent(out) :: eps
155  integer(c_int), intent(out) :: ierr
156 
157  !-- Local variables
158  integer(c_int) k, kk
159  real(c_double) rrel(dim)
160  real(c_double) rsqrel
161  integer(c_int) numneishort
162  integer(c_int), pointer :: neishort(:)
163 
164  ! Get short-range neighbors of `atom`
165  call kim_get_neighbor_list( &
166  model_compute_arguments_handle, 1, atom, numneishort, neishort, ierr)
167  if (ierr /= 0) return
168 
169  eps = 0.0_cd
170  do kk = 1, numneishort
171  k = neishort(kk)
172  rrel(:) = coor(:, k) - coor(:, atom)
173  rsqrel = dot_product(rrel, rrel)
174  if (rsqrel < model_cutsq1) eps = eps + rsqrel
175  end do
176  eps = 0.5_cd * lj_spring * eps
177 
178  end subroutine calc_spring_energyamp
179 
180  !-----------------------------------------------------------------------------
181  !
182  ! Calculate short-range linear spring-based contribution to force
183  !
184  !-----------------------------------------------------------------------------
185  recursive subroutine calc_spring_force(model_compute_arguments_handle, atom, &
186  coor, eps, phi, force, ierr)
187  implicit none
188 
189  !-- Transferred variables
190  type(kim_model_compute_arguments_handle_type), &
191  intent(in) :: model_compute_arguments_handle
192  integer(c_int), intent(in) :: atom
193  real(c_double), intent(in) :: coor(:, :)
194  real(c_double), intent(in) :: eps
195  real(c_double), intent(in) :: phi
196  real(c_double), intent(inout) :: force(:, :)
197  integer(c_int), intent(out) :: ierr
198 
199  !-- Local variables
200  integer(c_int) k, kk
201  real(c_double) rrel(dim), dforce(dim)
202  real(c_double) rsqrel
203  integer(c_int) numneishort
204  integer(c_int), pointer :: neishort(:)
205 
206  ! Get short-range neighbors of `atom`
207  call kim_get_neighbor_list( &
208  model_compute_arguments_handle, 1, atom, numneishort, neishort, ierr)
209  if (ierr /= 0) return
210 
211  ! Add contribution to force on `atom` and its near neighbors that contribute
212  ! to the spring term
213  do kk = 1, numneishort
214  k = neishort(kk)
215  rrel(:) = coor(:, k) - coor(:, atom)
216  rsqrel = dot_product(rrel, rrel)
217  if (rsqrel < model_cutsq1) then
218  dforce(:) = 0.5_cd * eps * lj_spring * rrel(:) * phi
219  force(:, atom) = force(:, atom) + dforce(:) ! accumulate force on atom
220  force(:, k) = force(:, k) - dforce(:) ! accumulate force on k
221  end if
222  end do
223 
224  end subroutine calc_spring_force
225 
226  !-----------------------------------------------------------------------------
227  !
228  ! Compute energy and forces on particles from the positions.
229  !
230  !-----------------------------------------------------------------------------
231  recursive subroutine compute_energy_forces( &
232  model_compute_handle, model_compute_arguments_handle, ierr) bind(c)
233  implicit none
234 
235  !-- Transferred variables
236  type(kim_model_compute_handle_type), intent(in) :: model_compute_handle
237  type(kim_model_compute_arguments_handle_type), intent(in) :: &
238  model_compute_arguments_handle
239  integer(c_int), intent(out) :: ierr
240 
241  !-- Local variables
242  real(c_double) :: Rij(dim), dforce(dim)
243  real(c_double) :: r, Rsqij, phi, dphi, dEidr, epsi, epsj
244  integer(c_int) :: i, j, jj, comp_force, comp_enepot, comp_energy
245  !integer(c_int) :: comp_virial
246  integer(c_int) :: numnei
247  integer(c_int) :: ierr2
248  logical :: calc_deriv
249 
250  !-- KIM variables
251  integer(c_int), pointer :: N
252  real(c_double), pointer :: energy
253  real(c_double), pointer :: coor(:, :)
254  real(c_double), pointer :: force(:, :)
255  real(c_double), pointer :: enepot(:)
256  integer(c_int), pointer :: nei1part(:)
257  integer(c_int), pointer :: particleSpeciesCodes(:)
258  integer(c_int), pointer :: particleContributing(:)
259  !real(c_double), pointer :: virial(:)
260 
261  ! Unpack data from KIM object
262  !
263  ierr = 0
264  call kim_get_argument_pointer( &
265  model_compute_arguments_handle, &
266  kim_compute_argument_name_number_of_particles, n, ierr2)
267  ierr = ierr + ierr2
268  call kim_get_argument_pointer( &
269  model_compute_arguments_handle, &
270  kim_compute_argument_name_particle_species_codes, n, &
271  particlespeciescodes, ierr2)
272  ierr = ierr + ierr2
273  call kim_get_argument_pointer( &
274  model_compute_arguments_handle, &
275  kim_compute_argument_name_particle_contributing, n, &
276  particlecontributing, ierr2)
277  ierr = ierr + ierr2
278  call kim_get_argument_pointer( &
279  model_compute_arguments_handle, &
280  kim_compute_argument_name_coordinates, dim, n, coor, ierr2)
281  ierr = ierr + ierr2
282  call kim_get_argument_pointer( &
283  model_compute_arguments_handle, &
284  kim_compute_argument_name_partial_energy, energy, ierr2)
285  ierr = ierr + ierr2
286  call kim_get_argument_pointer( &
287  model_compute_arguments_handle, &
288  kim_compute_argument_name_partial_forces, dim, n, force, ierr2)
289  ierr = ierr + ierr2
290  call kim_get_argument_pointer( &
291  model_compute_arguments_handle, &
292  kim_compute_argument_name_partial_particle_energy, n, enepot, ierr2)
293  ierr = ierr + ierr2
294  !call kim_model_compute_arguments_get_argument_pointer( &
295  ! model_compute_arguments_handle, &
296  ! KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, 6, virial, ierr2)
297  !ierr = ierr + ierr2
298  if (ierr /= 0) then
299  call kim_log_entry(model_compute_arguments_handle, &
300  kim_log_verbosity_error, "get data")
301  return
302  end if
303 
304  ! Check to see if we have been asked to compute the forces, energyperpart,
305  ! energy and virial
306  !
307  if (associated(energy)) then
308  comp_energy = 1
309  else
310  comp_energy = 0
311  end if
312  if (associated(force)) then
313  comp_force = 1
314  else
315  comp_force = 0
316  end if
317  if (associated(enepot)) then
318  comp_enepot = 1
319  else
320  comp_enepot = 0
321  end if
322  !if (associated(virial)) then
323  ! comp_virial = 1
324  !else
325  ! comp_virial = 0
326  !end if
327  calc_deriv = comp_force == 1 !.or.comp_virial.eq.1
328 
329  ! Check to be sure that the species are correct
330  !
331  ierr = 1 ! assume an error
332  do i = 1, n
333  if (particlespeciescodes(i) /= speccode) then
334  call kim_log_entry( &
335  model_compute_handle, kim_log_verbosity_error, &
336  "Unexpected species code detected")
337  return
338  end if
339  end do
340  ierr = 0 ! everything is ok
341 
342  ! Initialize potential energies, forces, virial term
343  !
344  if (comp_enepot == 1) enepot = 0.0_cd
345  if (comp_energy == 1) energy = 0.0_cd
346  if (comp_force == 1) force = 0.0_cd
347  !if (comp_virial.eq.1) virial = 0.0_cd
348  if (calc_deriv) deidr = 0.0_cd
349 
350  !
351  ! Compute energy and forces
352  !
353 
354  ! Loop over particles and compute energy and forces
355  !
356  do i = 1, n
357  if (particlecontributing(i) == 1) then
358  ! Set up neighbor list for next particle
359  call kim_get_neighbor_list( &
360  model_compute_arguments_handle, 2, i, numnei, nei1part, ierr)
361  if (ierr /= 0) then
362  ! some sort of problem, exit
363  call kim_log_entry( &
364  model_compute_arguments_handle, kim_log_verbosity_error, &
365  "GetNeighborList failed")
366  ierr = 1
367  return
368  end if
369 
370  ! Get short range contribution for atom i to energy amplitude
371  call calc_spring_energyamp(model_compute_arguments_handle, &
372  i, coor, epsi, ierr)
373  if (ierr /= 0) then
374  ! some sort of problem, exit
375  call kim_log_entry( &
376  model_compute_handle, kim_log_verbosity_error, &
377  "GetNeighborList failed")
378  ierr = 1
379  return
380  end if
381 
382  ! Loop over the neighbors of particle i
383  !
384  do jj = 1, numnei
385 
386  j = nei1part(jj) ! get neighbor ID
387 
388  ! Get short range contribution for atom j to energy amplitude
389  call calc_spring_energyamp(model_compute_arguments_handle, j, coor, &
390  epsj, ierr)
391  if (ierr /= 0) then
392  ! some sort of problem, exit
393  call kim_log_entry( &
394  model_compute_handle, kim_log_verbosity_error, &
395  "GetNeighborList failed")
396  ierr = 1
397  return
398  end if
399 
400  ! compute relative position vector
401  !
402  rij(:) = coor(:, j) - coor(:, i) ! distance vector between i j
403 
404  ! compute energy and forces
405  !
406  rsqij = dot_product(rij, rij) ! compute square distance
407  if (rsqij < model_cutsq2) then ! particles are interacting?
408 
409  r = sqrt(rsqij) ! compute distance
410  call calc_phi(r, phi, dphi, calc_deriv) ! compute pair potential and deriv
411  if (calc_deriv) deidr = 0.5_cd * dphi
412 
413  ! contribution to energy
414  !
415  if (comp_enepot == 1) then
416  enepot(i) = enepot(i) + 0.5_cd * epsi * epsj * phi ! accumulate energy
417  end if
418  if (comp_energy == 1) then
419  energy = energy + 0.5_cd * epsi * epsj * phi
420  end if
421 
422  !!@@@@@@@@@@@@@@@@@@@@ NOT FIXED YET
423  ! ! contribution to virial tensor,
424  ! ! virial(i,j)=r(i)*r(j)*(dV/dr)/r
425  ! !
426  ! if (comp_virial.eq.1) then
427  ! virial(1) = virial(1) + Rij(1)*Rij(1)*dEidr/r
428  ! virial(2) = virial(2) + Rij(2)*Rij(2)*dEidr/r
429  ! virial(3) = virial(3) + Rij(3)*Rij(3)*dEidr/r
430  ! virial(4) = virial(4) + Rij(2)*Rij(3)*dEidr/r
431  ! virial(5) = virial(5) + Rij(1)*Rij(3)*dEidr/r
432  ! virial(6) = virial(6) + Rij(1)*Rij(2)*dEidr/r
433  ! endif
434  !!@@@@@@@@@@@@@@@@@@@@
435 
436  ! contribution to forces
437  !
438  if (comp_force == 1) then
439  ! Contribution due to short range neighbors of i
440  call calc_spring_force(model_compute_arguments_handle, i, coor, &
441  epsj, phi, force, ierr)
442  if (ierr /= 0) then
443  ! some sort of problem, exit
444  call kim_log_entry( &
445  model_compute_handle, kim_log_verbosity_error, &
446  "GetNeighborList failed")
447  ierr = 1
448  return
449  end if
450  ! Contribution due to short range neighbors of j
451  call calc_spring_force(model_compute_arguments_handle, j, coor, &
452  epsi, phi, force, ierr)
453  if (ierr /= 0) then
454  ! some sort of problem, exit
455  call kim_log_entry( &
456  model_compute_handle, kim_log_verbosity_error, &
457  "GetNeighborList failed")
458  ierr = 1
459  return
460  end if
461  ! Contribution due to deriv of LJ term
462  dforce(:) = epsi * epsj * deidr * rij(:) / r
463  force(:, i) = force(:, i) + dforce(:) ! accumulate force on i
464  force(:, j) = force(:, j) - dforce(:) ! accumulate force on j
465  end if
466 
467  end if
468 
469  end do ! loop on jj
470 
471  end if ! if particleContributing
472 
473  end do ! do i
474 
475  ! Everything is great
476  !
477  ierr = 0
478  return
479 
480  end subroutine compute_energy_forces
481 
482  !-----------------------------------------------------------------------------
483  !
484  ! Model destroy routine (REQUIRED)
485  !
486  !-----------------------------------------------------------------------------
487  recursive subroutine model_destroy_func(model_destroy_handle, ierr) bind(c)
488  use, intrinsic :: iso_c_binding
489  implicit none
490 
491  !-- Transferred variables
492  type(kim_model_destroy_handle_type), intent(inout) :: model_destroy_handle
493  integer(c_int), intent(out) :: ierr
494 
495  type(buffer_type), pointer :: buf; type(c_ptr) :: pbuf
496 
497  call kim_get_model_buffer_pointer(model_destroy_handle, pbuf)
498  call c_f_pointer(pbuf, buf)
499  call kim_log_entry(model_destroy_handle, kim_log_verbosity_information, &
500  "deallocating model buffer")
501  deallocate (buf)
502  ierr = 0 ! everything is good
503  end subroutine model_destroy_func
504 
505  !-----------------------------------------------------------------------------
506  !
507  ! Model compute arguments create routine (REQUIRED)
508  !
509  !-----------------------------------------------------------------------------
510  recursive subroutine model_compute_arguments_create( &
511  model_compute_handle, model_compute_arguments_create_handle, ierr) bind(c)
512  use, intrinsic :: iso_c_binding
513  implicit none
514 
515  !-- Transferred variables
516  type(kim_model_compute_handle_type), intent(in) :: model_compute_handle
517  type(kim_model_compute_arguments_create_handle_type), intent(inout) :: &
518  model_compute_arguments_create_handle
519  integer(c_int), intent(out) :: ierr
520 
521  integer(c_int) :: ierr2
522 
523  ! avoid unsed dummy argument warnings
524  if (model_compute_handle == kim_model_compute_null_handle) continue
525 
526  ierr = 0
527  ierr2 = 0
528 
529  ! register arguments
530  call kim_set_argument_support_status( &
531  model_compute_arguments_create_handle, &
532  kim_compute_argument_name_partial_energy, &
533  kim_support_status_optional, ierr2)
534  ierr = ierr + ierr2
535  call kim_set_argument_support_status( &
536  model_compute_arguments_create_handle, &
537  kim_compute_argument_name_partial_forces, &
538  kim_support_status_optional, ierr2)
539  ierr = ierr + ierr2
540  call kim_set_argument_support_status( &
541  model_compute_arguments_create_handle, &
542  kim_compute_argument_name_partial_particle_energy, &
543  kim_support_status_optional, ierr2)
544  ierr = ierr + ierr2
545  ! call kim_set_argument_support_status( &
546  ! model_compute_arguments_create_handle, &
547  ! KIM_COMPUTE_ARGUMENT_NAME_PARTIAL_VIRIAL, &
548  ! KIM_SUPPORT_STATUS_OPTIONAL, ierr2)
549  ! ierr = ierr + ierr2
550 
551  ! register call backs
552  ! NONE
553 
554  if (ierr /= 0) then
555  ierr = 1
556  call kim_log_entry( &
557  model_compute_arguments_create_handle, &
558  kim_log_verbosity_error, &
559  "Unable to successfully create compute_arguments object")
560  end if
561 
562  return
563  end subroutine model_compute_arguments_create
564 
565  !-----------------------------------------------------------------------------
566  !
567  ! Model compute arguments destroy routine (REQUIRED)
568  !
569  !-----------------------------------------------------------------------------
570  recursive subroutine model_compute_arguments_destroy( &
571  model_compute_handle, model_compute_arguments_destroy_handle, ierr) bind(c)
572  use, intrinsic :: iso_c_binding
573  implicit none
574 
575  !-- Transferred variables
576  type(kim_model_compute_handle_type), intent(in) :: model_compute_handle
577  type(kim_model_compute_arguments_destroy_handle_type), intent(inout) :: &
578  model_compute_arguments_destroy_handle
579  integer(c_int), intent(out) :: ierr
580 
581  ! avoid unsed dummy argument warnings
582  if (model_compute_handle == kim_model_compute_null_handle) continue
583  if (model_compute_arguments_destroy_handle == &
584  kim_model_compute_arguments_destroy_null_handle) continue
585 
586  ierr = 0
587  return
588  end subroutine model_compute_arguments_destroy
589 
591 
592 !-------------------------------------------------------------------------------
593 !
594 ! Model create routine (REQUIRED)
595 !
596 !-------------------------------------------------------------------------------
597 recursive subroutine model_create_routine( &
598  model_create_handle, requested_length_unit, requested_energy_unit, &
599  requested_charge_unit, requested_temperature_unit, requested_time_unit, &
600  ierr) bind(c)
601  use, intrinsic :: iso_c_binding
604  implicit none
605 
606  !-- Transferred variables
607  type(kim_model_create_handle_type), intent(inout) :: model_create_handle
608  type(kim_length_unit_type), intent(in), value :: requested_length_unit
609  type(kim_energy_unit_type), intent(in), value :: requested_energy_unit
610  type(kim_charge_unit_type), intent(in), value :: requested_charge_unit
611  type(kim_temperature_unit_type), intent(in), value :: &
612  requested_temperature_unit
613  type(kim_time_unit_type), intent(in), value :: requested_time_unit
614  integer(c_int), intent(out) :: ierr
615 
616  !-- KIM variables
617  integer(c_int) :: ierr2
618  type(buffer_type), pointer :: buf
619 
620  ierr = 0
621  ierr2 = 0
622 
623  ! avoid unsed dummy argument warnings
624  if (requested_length_unit == kim_length_unit_unused) continue
625  if (requested_energy_unit == kim_energy_unit_unused) continue
626  if (requested_charge_unit == kim_charge_unit_unused) continue
627  if (requested_temperature_unit == kim_temperature_unit_unused) continue
628  if (requested_time_unit == kim_time_unit_unused) continue
629 
630  ! set units
631  call kim_set_units(model_create_handle, &
632  kim_length_unit_a, &
633  kim_energy_unit_ev, &
634  kim_charge_unit_unused, &
635  kim_temperature_unit_unused, &
636  kim_time_unit_unused, &
637  ierr2)
638  ierr = ierr + ierr2
639 
640  ! register species
641  call kim_set_species_code(model_create_handle, &
642  kim_species_name_ar, speccode, ierr2)
643  ierr = ierr + ierr2
644 
645  ! register numbering
646  call kim_set_model_numbering(model_create_handle, &
647  kim_numbering_one_based, ierr2)
648  ierr = ierr + ierr2
649 
650  ! register function pointers
651  call kim_set_routine_pointer( &
652  model_create_handle, &
653  kim_model_routine_name_compute, kim_language_name_fortran, &
654  1, c_funloc(compute_energy_forces), ierr2)
655  ierr = ierr + ierr2
656  call kim_set_routine_pointer( &
657  model_create_handle, &
658  kim_model_routine_name_compute_arguments_create, &
659  kim_language_name_fortran, &
660  1, c_funloc(model_compute_arguments_create), ierr2)
661  ierr = ierr + ierr2
662  call kim_set_routine_pointer( &
663  model_create_handle, &
664  kim_model_routine_name_compute_arguments_destroy, &
665  kim_language_name_fortran, &
666  1, c_funloc(model_compute_arguments_destroy), ierr2)
667  ierr = ierr + ierr2
668  call kim_set_routine_pointer( &
669  model_create_handle, &
670  kim_model_routine_name_destroy, kim_language_name_fortran, 1, &
671  c_funloc(model_destroy_func), ierr2)
672  ierr = ierr + ierr2
673 
674  ! allocate buffer
675  allocate (buf)
676 
677  ! store model buffer in KIM object
678  call kim_set_model_buffer_pointer(model_create_handle, &
679  c_loc(buf))
680 
681  ! set buffer values
682  buf%influence_distance = model_cutoff1 + model_cutoff2
683  buf%cutoff(1) = model_cutoff1
684  buf%cutoff(2) = model_cutoff2
685  buf%model_will_not_request_neighbors_of_noncontributing_particles(1) = 0
686  buf%model_will_not_request_neighbors_of_noncontributing_particles(2) = 1
687 
688  ! register influence distance
689  call kim_set_influence_distance_pointer( &
690  model_create_handle, buf%influence_distance)
691 
692  ! register cutoff
693  call kim_set_neighbor_list_pointers( &
694  model_create_handle, 2, buf%cutoff, &
695  buf%model_will_not_request_neighbors_of_noncontributing_particles)
696 
697  if (ierr /= 0) then
698  ierr = 1
699  deallocate (buf)
700  call kim_log_entry( &
701  model_create_handle, kim_log_verbosity_error, &
702  "Unable to successfully initialize model")
703  end if
704 
705  return
706 
707 end subroutine model_create_routine
recursive subroutine, public model_compute_arguments_create(model_compute_handle, model_compute_arguments_create_handle, ierr)
recursive subroutine, public model_compute_arguments_destroy(model_compute_handle, model_compute_arguments_destroy_handle, ierr)
real(c_double), parameter, public model_cutoff1
real(c_double), parameter, public model_cutoff2
integer(c_int), parameter, public speccode
static void calc_phi(double const *epsilon, double const *C, double const *Rzero, double const *shift, double const cutoff, double const r, double *phi)
recursive subroutine, public compute_energy_forces(model_compute_handle, model_compute_arguments_handle, ierr)
recursive subroutine, public model_destroy_func(model_destroy_handle, ierr)