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)
104 subroutine calc_phi(r,phi)
108 real(c_double),
intent(in) :: r
109 real(c_double),
intent(out) :: phi
112 real(c_double) rsq,sor,sor6,sor12
119 if (r .gt. model_cutoff)
then 123 phi = 4.0_cd*lj_epsilon*(sor12-sor6) + lj_a*rsq + lj_b*r + lj_c
126 end subroutine calc_phi
133 subroutine calc_phi_dphi(r,phi,dphi)
137 real(c_double),
intent(in) :: r
138 real(c_double),
intent(out) :: phi,dphi
141 real(c_double) rsq,sor,sor6,sor12
148 if (r .gt. model_cutoff)
then 153 phi = 4.0_cd*lj_epsilon*(sor12-sor6) + lj_a*rsq + lj_b*r + lj_c
154 dphi = 24.0_cd*lj_epsilon*(-2.0_cd*sor12+sor6)/r + 2.0_cd*lj_a*r + lj_b
157 end subroutine calc_phi_dphi
341 #include "kim_model_create_log_macros.fd" 342 subroutine model_create_routine(model_create_handle, requested_length_unit, &
343 requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
344 requested_time_unit, ierr) bind(c)
345 use,
intrinsic :: iso_c_binding
351 type(kim_model_create_handle_type),
intent(inout) :: model_create_handle
352 type(kim_length_unit_type),
intent(in) :: requested_length_unit
353 type(kim_energy_unit_type),
intent(in) :: requested_energy_unit
354 type(kim_charge_unit_type),
intent(in) :: requested_charge_unit
355 type(kim_temperature_unit_type),
intent(in) :: requested_temperature_unit
356 type(kim_time_unit_type),
intent(in) :: requested_time_unit
357 integer(c_int),
intent(out) :: ierr
360 integer(c_int) :: ierr2
361 type(buffer_type),
pointer :: buf
362 character(kind=c_char, len=100000) model_create_string
364 kim_log_file = __file__
370 call kim_model_create_set_units(model_create_handle, &
372 kim_energy_unit_ev, &
373 kim_charge_unit_unused, &
374 kim_temperature_unit_unused, &
375 kim_time_unit_unused, &
380 call kim_model_create_set_species_code(model_create_handle, &
381 kim_species_name_ar, speccode, ierr2)
385 call kim_model_create_set_model_numbering(model_create_handle, &
386 kim_numbering_one_based, ierr2);
390 call kim_model_create_set_compute_pointer(model_create_handle, &
391 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
393 call kim_model_create_set_compute_arguments_create_pointer( &
394 model_create_handle, kim_language_name_fortran, &
395 c_funloc(kim_model_create_string), ierr2)
397 call kim_model_create_set_compute_arguments_destroy_pointer( &
398 model_create_handle, kim_language_name_fortran, &
399 c_funloc(kim_model_create_string), ierr2)
401 call kim_model_create_set_destroy_pointer(model_create_handle, &
402 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
404 call kim_model_create_set_refresh_pointer( &
405 model_create_handle, kim_language_name_fortran, &
406 c_funloc(kim_model_create_string), ierr2)
413 call kim_model_create_set_model_buffer_pointer(model_create_handle, &
417 buf%influence_distance = model_cutoff
418 buf%cutoff = model_cutoff
421 call kim_model_create_set_influence_distance_pointer( &
422 model_create_handle, buf%influence_distance)
425 call kim_model_create_set_neighbor_list_cutoffs_pointer(model_create_handle, &
431 kim_log_message =
"Unable to successfully initialize model" 435 call kim_model_create_string(model_create_handle, model_create_string)
436 print
'(A)', trim(model_create_string)
440 end subroutine model_create_routine