47 use,
intrinsic :: iso_c_binding
63 integer(c_int),
parameter :: cd = c_double
64 integer(c_int),
parameter :: DIM = 3
65 integer(c_int),
parameter :: speccode = 1
66 real(c_double),
parameter :: model_cutoff = 8.15_cd
68 real(c_double),
parameter :: model_cutsq = model_cutoff**2
85 real(c_double),
parameter :: lj_epsilon = 0.0104_cd
86 real(c_double),
parameter :: lj_sigma = 3.40_cd
87 real(c_double),
parameter :: lj_cutnorm = model_cutoff/lj_sigma
88 real(c_double),
parameter :: lj_A = 12.0_cd*lj_epsilon*(-26.0_cd &
89 + 7.0_cd*lj_cutnorm**6)/(lj_cutnorm**14 &
91 real(c_double),
parameter :: lj_B = 96.0_cd*lj_epsilon*(7.0_cd &
92 - 2.0_cd*lj_cutnorm**6)/(lj_cutnorm**13*lj_sigma)
93 real(c_double),
parameter :: lj_C = 28.0_cd*lj_epsilon*(-13.0_cd &
94 + 4.0_cd*lj_cutnorm**6)/(lj_cutnorm**12)
96 type, bind(c) :: buffer_type
97 real(c_double) :: influence_distance
98 real(c_double) :: cutoff(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_destroy_log_macros.fd" 345 use,
intrinsic :: iso_c_binding
349 type(kim_model_destroy_handle_type),
intent(inout) :: model_destroy_handle
350 integer(c_int),
intent(out) :: ierr
352 type(buffer_type),
pointer :: buf;
type(c_ptr) :: pbuf
354 kim_log_file = __file__
356 call kim_model_destroy_get_model_buffer_pointer(model_destroy_handle, pbuf)
357 call c_f_pointer(pbuf, buf)
358 kim_log_message =
"deallocating model buffer" 369 #include "kim_model_refresh_log_macros.fd" 371 use,
intrinsic :: iso_c_binding
375 type(kim_model_refresh_handle_type),
intent(inout) :: model_refresh_handle
376 integer(c_int),
intent(out) :: ierr
378 type(buffer_type),
pointer :: buf;
type(c_ptr) :: pbuf
380 kim_log_file = __file__
382 call kim_model_refresh_get_model_buffer_pointer(model_refresh_handle, pbuf)
383 call c_f_pointer(pbuf, buf)
385 kim_log_message =
"Resettings influence distance and cutoffs" 387 call kim_model_refresh_set_influence_distance_pointer( &
388 model_refresh_handle, buf%cutoff(1))
389 call kim_model_refresh_set_neighbor_list_cutoffs_pointer( &
390 model_refresh_handle, 1, buf%cutoff)
400 #include "kim_model_compute_arguments_create_log_macros.fd" 402 model_compute_arguments_create_handle, ierr) bind(c)
403 use,
intrinsic :: iso_c_binding
405 log_entry=>kim_model_compute_arguments_create_log_entry
409 type(kim_model_compute_handle_type),
intent(in) :: model_compute_handle
410 type(kim_model_compute_arguments_create_handle_type),
intent(inout) :: &
411 model_compute_arguments_create_handle
412 integer(c_int),
intent(out) :: ierr
414 integer(c_int) :: ierr2
420 call kim_model_compute_arguments_create_set_argument_support_status( &
421 model_compute_arguments_create_handle, &
422 kim_compute_argument_name_partial_energy, &
423 kim_support_status_optional, ierr2)
425 call kim_model_compute_arguments_create_set_argument_support_status( &
426 model_compute_arguments_create_handle, &
427 kim_compute_argument_name_partial_forces, &
428 kim_support_status_optional, ierr2)
430 call kim_model_compute_arguments_create_set_argument_support_status( &
431 model_compute_arguments_create_handle, &
432 kim_compute_argument_name_partial_particle_energy, &
433 kim_support_status_optional, ierr2)
435 call kim_model_compute_arguments_create_set_argument_support_status( &
436 model_compute_arguments_create_handle, &
437 kim_compute_argument_name_partial_virial, &
438 kim_support_status_optional, ierr2)
446 kim_log_message =
"Unable to successfully create compute_arguments object" 458 #include "kim_model_compute_arguments_destroy_log_macros.fd" 460 model_compute_arguments_destroy_handle, ierr) bind(c)
461 use,
intrinsic :: iso_c_binding
463 log_entry=>kim_model_compute_arguments_destroy_log_entry
467 type(kim_model_compute_handle_type),
intent(in) :: model_compute_handle
468 type(kim_model_compute_arguments_destroy_handle_type),
intent(inout) :: &
469 model_compute_arguments_destroy_handle
470 integer(c_int),
intent(out) :: ierr
472 integer(c_int) :: ierr2
489 #include "kim_model_create_log_macros.fd" 490 subroutine model_create_routine(model_create_handle, requested_length_unit, &
491 requested_energy_unit, requested_charge_unit, requested_temperature_unit, &
492 requested_time_unit, ierr) bind(c)
493 use,
intrinsic :: iso_c_binding
499 type(kim_model_create_handle_type),
intent(inout) :: model_create_handle
500 type(kim_length_unit_type),
intent(in) :: requested_length_unit
501 type(kim_energy_unit_type),
intent(in) :: requested_energy_unit
502 type(kim_charge_unit_type),
intent(in) :: requested_charge_unit
503 type(kim_temperature_unit_type),
intent(in) :: requested_temperature_unit
504 type(kim_time_unit_type),
intent(in) :: requested_time_unit
505 integer(c_int),
intent(out) :: ierr
508 integer(c_int) :: ierr2
509 type(buffer_type),
pointer :: buf
511 kim_log_file = __file__
517 call kim_model_create_set_units(model_create_handle, &
519 kim_energy_unit_ev, &
520 kim_charge_unit_unused, &
521 kim_temperature_unit_unused, &
522 kim_time_unit_unused, &
527 call kim_model_create_set_species_code(model_create_handle, &
528 kim_species_name_ar, speccode, ierr2)
532 call kim_model_create_set_model_numbering(model_create_handle, &
533 kim_numbering_one_based, ierr2);
537 call kim_model_create_set_compute_pointer(model_create_handle, &
538 kim_language_name_fortran, c_funloc(kim_model_create_string), ierr2)
540 call kim_model_create_set_compute_arguments_create_pointer( &
541 model_create_handle, kim_language_name_fortran, &
544 call kim_model_create_set_compute_arguments_destroy_pointer( &
545 model_create_handle, kim_language_name_fortran, &
548 call kim_model_create_set_destroy_pointer(model_create_handle, &
551 call kim_model_create_set_refresh_pointer( &
552 model_create_handle, kim_language_name_fortran, &
560 call kim_model_create_set_model_buffer_pointer(model_create_handle, &
564 buf%influence_distance = model_cutoff
565 buf%cutoff = model_cutoff
568 call kim_model_create_set_influence_distance_pointer( &
569 model_create_handle, buf%influence_distance)
572 call kim_model_create_set_neighbor_list_cutoffs_pointer(model_create_handle, &
578 kim_log_message =
"Unable to successfully initialize model" 584 end subroutine model_create_routine
subroutine, public model_destroy_func(model_destroy_handle, ierr)
subroutine, public model_refresh_func(model_refresh_handle, ierr)
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)