47 use,
intrinsic :: iso_c_binding
59 integer(c_int),
parameter :: cd = c_double
60 integer(c_int),
parameter :: DIM = 3
61 integer(c_int),
parameter :: speccode = 1
62 real(c_double),
parameter :: model_cutoff = 8.15_cd
64 real(c_double),
parameter :: model_cutsq = model_cutoff**2
81 real(c_double),
parameter :: lj_epsilon = 0.0104_cd
82 real(c_double),
parameter :: lj_sigma = 3.40_cd
83 real(c_double),
parameter :: lj_cutnorm = model_cutoff/lj_sigma
84 real(c_double),
parameter :: lj_A = 12.0_cd*lj_epsilon*(-26.0_cd &
85 + 7.0_cd*lj_cutnorm**6)/(lj_cutnorm**14 &
87 real(c_double),
parameter :: lj_B = 96.0_cd*lj_epsilon*(7.0_cd &
88 - 2.0_cd*lj_cutnorm**6)/(lj_cutnorm**13*lj_sigma)
89 real(c_double),
parameter :: lj_C = 28.0_cd*lj_epsilon*(-13.0_cd &
90 + 4.0_cd*lj_cutnorm**6)/(lj_cutnorm**12)
92 type, bind(c) :: buffer_type
93 real(c_double) :: influence_distance
94 real(c_double) :: cutoff(1)
95 integer(c_int) :: padding_neighbor_hints(1)
96 integer(c_int) :: half_list_hints(1)
106 subroutine calc_phi(r,phi)
110 real(c_double),
intent(in) :: r
111 real(c_double),
intent(out) :: phi
114 real(c_double) rsq,sor,sor6,sor12
121 if (r .gt. model_cutoff)
then 125 phi = 4.0_cd*lj_epsilon*(sor12-sor6) + lj_a*rsq + lj_b*r + lj_c
128 end subroutine calc_phi
135 subroutine calc_phi_dphi(r,phi,dphi)
139 real(c_double),
intent(in) :: r
140 real(c_double),
intent(out) :: phi,dphi
143 real(c_double) rsq,sor,sor6,sor12
150 if (r .gt. model_cutoff)
then 155 phi = 4.0_cd*lj_epsilon*(sor12-sor6) + lj_a*rsq + lj_b*r + lj_c
156 dphi = 24.0_cd*lj_epsilon*(-2.0_cd*sor12+sor6)/r + 2.0_cd*lj_a*r + lj_b
159 end subroutine calc_phi_dphi
343 #include "kim_model_create_log_macros.fd" 344 subroutine model_create_routine(model_create_handle, requested_length_unit, &
345 requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
346 requested_time_unit, ierr) bind(c)
347 use,
intrinsic :: iso_c_binding
353 type(kim_model_create_handle_type),
intent(inout) :: model_create_handle
354 type(kim_length_unit_type),
intent(in) :: requested_length_unit
355 type(kim_energy_unit_type),
intent(in) :: requested_energy_unit
356 type(kim_charge_unit_type),
intent(in) :: requested_charge_unit
357 type(kim_temperature_unit_type),
intent(in) :: requested_temperature_unit
358 type(kim_time_unit_type),
intent(in) :: requested_time_unit
359 integer(c_int),
intent(out) :: ierr
362 integer(c_int) :: ierr2
363 type(buffer_type),
pointer :: buf
364 character(kind=c_char, len=100000) model_create_string
366 kim_log_file = __file__
372 call kim_model_create_set_units(model_create_handle, &
374 kim_energy_unit_ev, &
375 kim_charge_unit_unused, &
376 kim_temperature_unit_unused, &
377 kim_time_unit_unused, &
382 call kim_model_create_set_species_code(model_create_handle, &
383 kim_species_name_ar, speccode, ierr2)
387 call kim_model_create_set_model_numbering(model_create_handle, &
388 kim_numbering_one_based, ierr2);
392 call kim_model_create_set_compute_pointer(model_create_handle, &
393 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
395 call kim_model_create_set_compute_arguments_create_pointer( &
396 model_create_handle, kim_language_name_fortran, &
397 c_funloc(kim_model_create_string), ierr2)
399 call kim_model_create_set_compute_arguments_destroy_pointer( &
400 model_create_handle, kim_language_name_fortran, &
401 c_funloc(kim_model_create_string), ierr2)
403 call kim_model_create_set_destroy_pointer(model_create_handle, &
404 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
406 call kim_model_create_set_refresh_pointer( &
407 model_create_handle, kim_language_name_fortran, &
408 c_funloc(kim_model_create_string), ierr2)
415 call kim_model_create_set_model_buffer_pointer(model_create_handle, &
419 buf%influence_distance = model_cutoff
420 buf%cutoff = model_cutoff
421 buf%padding_neighbor_hints = 1
422 buf%half_list_hints = 0
425 call kim_model_create_set_influence_distance_pointer( &
426 model_create_handle, buf%influence_distance)
429 call kim_model_create_set_neighbor_list_pointers(model_create_handle, &
430 1, buf%cutoff, buf%padding_neighbor_hints, buf%half_list_hints)
435 kim_log_message =
"Unable to successfully initialize model" 439 call kim_model_create_string(model_create_handle, model_create_string)
440 print
'(A)', trim(model_create_string)
445 end subroutine model_create_routine