Priority of supported NBC methods.

Dear colleagues,

I had the impression that the order in which a model specifies the supported NBC methods indicates a kind of priority for that model (perhaps a model has better performance with one kind of neighbor lists than with another). But I see nowhere in the KIM API any method to read the list of PBC methods and get this order. In fact, the test vc_force_delta.F90 appears to identify the possible neighbor list methods in quite a clumsy way, by testing for them one by one (see below). Should there not be some kind of API method for getting a (preferably prioritised) list of supported neighbor list methods? Something similar to KIM_API_get_model_partcl_typs().

Best regards

Jakob

subroutine Get_Model_NBC_methods(modelname, max_NBCs, model_NBCs, num_NBCs, ier)
use KIM_API
implicit none

!-- Transferred variables
character(len=100), intent(in) :: modelname
integer, intent(in) :: max_NBCs
character(len=KIM_KEY_STRING_LENGTH), intent(out) :: model_NBCs(max_NBCs)
integer, intent(out) :: num_NBCs
integer, intent(out) :: ier

!-- Local variables
integer :: index

!-- KIM variables
integer(kind=kim_intptr) pkim

! Initialize error flag
ier = KIM_STATUS_OK

! Generate empty KIM object containing generic model info
ier = kim_api_model_info_f(pkim, modelname)
if (ier.lt.KIM_STATUS_OK) return

! Identify supported NBCs by seeking index to each of the NBCs in the KIM model
num_NBCs = 0

! NEIGH_RVEC_H
index = kim_api_get_index_f(pkim, "NEIGH_RVEC_H", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "NEIGH_RVEC_H"
endif

! NEIGH_PURE_H
index = kim_api_get_index_f(pkim, "NEIGH_PURE_H", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "NEIGH_PURE_H"
endif

! NEIGH_RVEC_F
index = kim_api_get_index_f(pkim, "NEIGH_RVEC_F", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "NEIGH_RVEC_F"
endif

! NEIGH_PURE_F
index = kim_api_get_index_f(pkim, "NEIGH_PURE_F", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "NEIGH_PURE_F"
endif

! MI_OPBC_H
index = kim_api_get_index_f(pkim, "MI_OPBC_H", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "MI_OPBC_H"
endif

! MI_OPBC_F
index = kim_api_get_index_f(pkim, "MI_OPBC_F", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "MI_OPBC_F"
endif

! CLUSTER
index = kim_api_get_index_f(pkim, "CLUSTER", ier)
if (index.ge.0) then
   num_NBCs = num_NBCs + 1
   if (num_NBCs>max_NBCs) then
      ier = KIM_STATUS_FAIL
      return
   endif
   model_NBCs(num_NBCs) = "CLUSTER"
endif

! free temporary storage
call kim_api_free_f(pkim,ier)

return

end subroutine Get_Model_NBC_methods

I Jacob,

The best approach is for a Simulator/Test to list the NBC methods it can support in the order of decreasing efficiency (most efficient method first) and for the Model to list its supported NBC methods in the same order.

Currently the API only considers the Simulator/Test ordering when selecting the NBC to be used with a Simulator/Test--Model pairing. The first NBC method (from the Simulator/Test's list) that matches (anywhere) in the Model's list is selected.

In principle, a Simulator/Test should only be interested in if a match is possible or not. However, I agree that ultimately we want to give programmers access to any and all reasonable information such as this. Accordingly, I have plans to include convenient access functions for this information in the v2.0.0 design of the api.

So, I would suggest that we deal with this, in the limited number of cases that it is necessary, in the "clumsy" way for now and wait for v2.0.0 to implement a better solution.

Cheers,

Ryan

Hi Ryan,

The best approach is for a Simulator/Test to list the NBC methods it can support in the order of decreasing efficiency (most efficient method first) and for the Model to list its supported NBC methods in the same order.

Currently the API only considers the Simulator/Test ordering when selecting the NBC to be used with a Simulator/Test--Model pairing. The first NBC method (from the Simulator/Test's list) that matches (anywhere) in the Model's list is selected.

OK, I see. I do not have to check which methods a test supports, before maching; I just list the methods that my simulator supports in order of priority, and then let the matching occur (or fail). Then once the model is loaded, I check which method I should be using.

That makes sense, and is even easier than what I had in mind.

Thank you very much for your quick reply.

Jakob

Hi Ryan,

The best approach is for a Simulator/Test to list the NBC methods it can support in the order of decreasing efficiency (most efficient method first) and for the Model to list its supported NBC methods in the same order.

Currently the API only considers the Simulator/Test ordering when selecting the NBC to be used with a Simulator/Test--Model pairing. The first NBC method (from the Simulator/Test's list) that matches (anywhere) in the Model's list is selected.

OK, I see. I do not have to check which methods a test supports, before maching; I just list the methods that my simulator supports in order of priority, and then let the matching occur (or fail).

Exactly.

Then once the model is loaded, I check which method I should be using.

Yes, you can use the KIM_API_get_NBC_method() api routine for that purpose.

That makes sense, and is even easier than what I had in mind.

Thank you very much for your quick reply.

Great! I'm glad to be of help.

Ryan