47 use,
intrinsic :: iso_c_binding
61 integer(c_int),
parameter :: cd = c_double
62 integer(c_int),
parameter :: DIM = 3
63 integer(c_int),
parameter :: speccode = 1
64 real(c_double),
parameter :: model_cutoff = 8.15_cd
66 real(c_double),
parameter :: model_cutsq = model_cutoff**2
83 real(c_double),
parameter :: lj_epsilon = 0.0104_cd
84 real(c_double),
parameter :: lj_sigma = 3.40_cd
85 real(c_double),
parameter :: lj_cutnorm = model_cutoff/lj_sigma
86 real(c_double),
parameter :: lj_A = 12.0_cd*lj_epsilon*(-26.0_cd &
87 + 7.0_cd*lj_cutnorm**6)/(lj_cutnorm**14 &
89 real(c_double),
parameter :: lj_B = 96.0_cd*lj_epsilon*(7.0_cd &
90 - 2.0_cd*lj_cutnorm**6)/(lj_cutnorm**13*lj_sigma)
91 real(c_double),
parameter :: lj_C = 28.0_cd*lj_epsilon*(-13.0_cd &
92 + 4.0_cd*lj_cutnorm**6)/(lj_cutnorm**12)
94 type, bind(c) :: buffer_type
95 real(c_double) :: influence_distance
96 real(c_double) :: cutoff(1)
97 integer(c_int) :: padding_neighbor_hints(1)
98 integer(c_int) :: half_list_hints(1)
108 subroutine calc_phi(r,phi)
112 real(c_double),
intent(in) :: r
113 real(c_double),
intent(out) :: phi
116 real(c_double) rsq,sor,sor6,sor12
123 if (r .gt. model_cutoff)
then 127 phi = 4.0_cd*lj_epsilon*(sor12-sor6) + lj_a*rsq + lj_b*r + lj_c
130 end subroutine calc_phi
137 subroutine calc_phi_dphi(r,phi,dphi)
141 real(c_double),
intent(in) :: r
142 real(c_double),
intent(out) :: phi,dphi
145 real(c_double) rsq,sor,sor6,sor12
152 if (r .gt. model_cutoff)
then 157 phi = 4.0_cd*lj_epsilon*(sor12-sor6) + lj_a*rsq + lj_b*r + lj_c
158 dphi = 24.0_cd*lj_epsilon*(-2.0_cd*sor12+sor6)/r + 2.0_cd*lj_a*r + lj_b
161 end subroutine calc_phi_dphi
343 #include "kim_model_compute_arguments_create_log_macros.fd" 345 model_compute_arguments_create_handle, ierr) bind(c)
346 use,
intrinsic :: iso_c_binding
348 log_entry=>kim_model_compute_arguments_create_log_entry
352 type(kim_model_compute_handle_type),
intent(in) :: model_compute_handle
353 type(kim_model_compute_arguments_create_handle_type),
intent(inout) :: &
354 model_compute_arguments_create_handle
355 integer(c_int),
intent(out) :: ierr
357 integer(c_int) :: ierr2
358 character(kind=c_char, len=100000) compute_arguments_string
364 call kim_model_compute_arguments_create_set_argument_support_status( &
365 model_compute_arguments_create_handle, &
366 kim_compute_argument_name_partial_energy, &
367 kim_support_status_optional, ierr2)
369 call kim_model_compute_arguments_create_set_argument_support_status( &
370 model_compute_arguments_create_handle, &
371 kim_compute_argument_name_partial_forces, &
372 kim_support_status_optional, ierr2)
374 call kim_model_compute_arguments_create_set_argument_support_status( &
375 model_compute_arguments_create_handle, &
376 kim_compute_argument_name_partial_particle_energy, &
377 kim_support_status_optional, ierr2)
379 call kim_model_compute_arguments_create_set_argument_support_status( &
380 model_compute_arguments_create_handle, &
381 kim_compute_argument_name_partial_virial, &
382 kim_support_status_optional, ierr2)
390 kim_log_message =
"Unable to successfully create compute_arguments object" 394 model_compute_arguments_create_handle, compute_arguments_string)
395 print
'(A)', trim(compute_arguments_string)
406 #include "kim_model_compute_arguments_destroy_log_macros.fd" 408 model_compute_arguments_destroy_handle, ierr) bind(c)
409 use,
intrinsic :: iso_c_binding
411 log_entry=>kim_model_compute_arguments_destroy_log_entry
415 type(kim_model_compute_handle_type),
intent(in) :: model_compute_handle
416 type(kim_model_compute_arguments_destroy_handle_type),
intent(inout) :: &
417 model_compute_arguments_destroy_handle
418 integer(c_int),
intent(out) :: ierr
420 integer(c_int) :: ierr2
437 #include "kim_model_create_log_macros.fd" 438 subroutine model_create_routine(model_create_handle, requested_length_unit, &
439 requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
440 requested_time_unit, ierr) bind(c)
441 use,
intrinsic :: iso_c_binding
447 type(kim_model_create_handle_type),
intent(inout) :: model_create_handle
448 type(kim_length_unit_type),
intent(in) :: requested_length_unit
449 type(kim_energy_unit_type),
intent(in) :: requested_energy_unit
450 type(kim_charge_unit_type),
intent(in) :: requested_charge_unit
451 type(kim_temperature_unit_type),
intent(in) :: requested_temperature_unit
452 type(kim_time_unit_type),
intent(in) :: requested_time_unit
453 integer(c_int),
intent(out) :: ierr
456 integer(c_int) :: ierr2
457 type(buffer_type),
pointer :: buf
458 character(kind=c_char, len=100000) model_create_string
460 kim_log_file = __file__
466 call kim_model_create_set_units(model_create_handle, &
468 kim_energy_unit_ev, &
469 kim_charge_unit_unused, &
470 kim_temperature_unit_unused, &
471 kim_time_unit_unused, &
476 call kim_model_create_set_species_code(model_create_handle, &
477 kim_species_name_ar, speccode, ierr2)
481 call kim_model_create_set_model_numbering(model_create_handle, &
482 kim_numbering_one_based, ierr2);
486 call kim_model_create_set_compute_pointer(model_create_handle, &
487 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
489 call kim_model_create_set_compute_arguments_create_pointer( &
490 model_create_handle, kim_language_name_fortran, &
493 call kim_model_create_set_compute_arguments_destroy_pointer( &
494 model_create_handle, kim_language_name_fortran, &
497 call kim_model_create_set_destroy_pointer(model_create_handle, &
498 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
500 call kim_model_create_set_refresh_pointer( &
501 model_create_handle, kim_language_name_fortran, &
502 c_funloc(kim_model_create_string), ierr2)
509 call kim_model_create_set_model_buffer_pointer(model_create_handle, &
513 buf%influence_distance = model_cutoff
514 buf%cutoff = model_cutoff
515 buf%padding_neighbor_hints = 1
516 buf%half_list_hints = 0
519 call kim_model_create_set_influence_distance_pointer( &
520 model_create_handle, buf%influence_distance)
523 call kim_model_create_set_neighbor_list_pointers(model_create_handle, &
524 1, buf%cutoff, buf%padding_neighbor_hints, buf%half_list_hints)
529 kim_log_message =
"Unable to successfully initialize model" 533 call kim_model_create_string(model_create_handle, model_create_string)
534 print
'(A)', trim(model_create_string)
539 end subroutine model_create_routine
subroutine, public model_compute_arguments_destroy(model_compute_handle, model_compute_arguments_destroy_handle, ierr)
subroutine, public model_compute_arguments_create(model_compute_handle, model_compute_arguments_create_handle, ierr)