question concerning info from KIM neighbor list

First, I wanted to say thank you to Ryan for his suggestions concerning implementing my MEAM-type potential into openKIM. His advice and direction has helped me go in a direction that would help me to better facilitate this process.

If I may, I have some technical issues with the neighbor list:

Forgive me if this seems like a fundamental/basic issue, but I am trying to import the following information from openKIM to my potential (the latter of which I am writing in fortran):

  1. for a given atom i, the number of neighbors within the cutoff radius
  2. for a given atom i, the number of 1st nearest neighbors (j) atoms
  3. for the atoms j concerning the above #2, the r_ij component distances

I have the following chunk of code from a fortran file from the openKIM website, and I wanted to further ask if I can obtain my needed info from the following:

ier = kim_api_get_neigh(pkim,1,i,atom_ret,numnei,pnei1atom,
& pRij_list)
if (ier.ne.KIM_STATUS_OK) then ! some sort of problem, exit
idum = kim_api_report_error(LINE, THIS_FILE_NAME,
& “kim_api_get_neigh”, ier)
ier = KIM_STATUS_FAIL
return
endif
call c_f_pointer(pnei1atom, nei1atom, [numnei])

Thank you kindly,
Josh

Hi Josh,

Thanks for your questions. See below.

First, I wanted to say thank you to Ryan for his suggestions concerning
implementing my MEAM-type potential into openKIM. His advice and direction
has helped me go in a direction that would help me to better facilitate
this process.

If I may, I have some technical issues with the neighbor list:

Forgive me if this seems like a fundamental/basic issue, but I am trying to
import the following information from openKIM to my potential (the latter
of which I am writing in fortran):

1) for a given atom i, the number of neighbors within the cutoff radius
2) for a given atom i, the number of 1st nearest neighbors (j) atoms
3) for the atoms j concerning the above #2, the r_ij component distances

1) The KIM API defines/provides access to neighbor list data, but only specifies that this list contain all neighbors within the cutoff radius. Thus, in order to know the exact number of particles within the cutoff radius of particle i, you will have to (a) retrieve the neighbor list for particle i; (b) loop over the list, compute the distance and check if it is within the cutoff; (c) if it is within the cutoff, increment the number of neighbors for i.

2) This could be done at the same time as the information in (1) is being collected.

3) Again, this can be collected at the same time.

So, to summarize: None of the information you ask for is provided directly by the kim-api. Instead, you will have to perform a short series of computations using the neighbor list information available to compute and collect the necessary information.

I have the following chunk of code from a fortran file from the openKIM
website, and I wanted to further ask if I can obtain my needed info from
the following:

        ier = kim_api_get_neigh(pkim,1,i,atom_ret,numnei,pnei1atom,
    & pRij_list)
        if (ier.ne.KIM_STATUS_OK) then ! some sort of problem, exit
           idum = kim_api_report_error(__LINE__, THIS_FILE_NAME,
    & "kim_api_get_neigh", ier)
           ier = KIM_STATUS_FAIL
           return
        endif
        call c_f_pointer(pnei1atom, nei1atom, [numnei])

This code gives you access to the neighbor list of particle i. It provides the number of particles in the list (numnei), the list of neighbors (nei1atom), and if using NEIGH_RVEC_* the relative positions vectors Rij (via the pointer pRij_list)

Cheers,

Ryan

Dear Ryan,

I just noticed this answer to Josh Gibson.

Are you saying that a simulator may return “extra” neighbors that are actually outside the neighborlist? It of course makes sense that the simulator maintains a slightly longer neighbor list, so it can be reused between time steps. It also makes sense that the responsability of filtering this lists fall on the Model, since letting the simulator do it would involve extra computations for all other neighborlist types than NEIGH_RVEC. I just did not expect this. Is it documented somewhere? I cannot find it in the current documentation.

Best regards

Jakob

1) The KIM API defines/provides access to neighbor list data, but only specifies that this list contain all neighbors within the cutoff radius. Thus, in order to know the exact number of particles within the cutoff radius of particle i, you will have to (a) retrieve the neighbor list for particle i; (b) loop over the list, compute the distance and check if it is within the cutoff; (c) if it is within the cutoff, increment the number of neighbors for i.

Dear Ryan,

I just noticed this answer to Josh Gibson.

Are you saying that a simulator may return “extra” neighbors that are actually outside the neighborlist?

The Simulator may include in the neighborlist additional particles that are outside the Model's cutoff radius. Yes. This allows for the "skin" that is used by most MD codes in order to make Verlet lists computationally efficient. It also allows for one uniform set of neighbor lists to be used with multiple KIM Models (each with its own distinct cutoff radius) at the same time.

It of course makes sense that the simulator maintains a slightly longer neighbor list, so it can be reused between time steps. It also makes sense that the responsability of filtering this lists fall on the Model, since letting the simulator do it would involve extra computations for all other neighborlist types than NEIGH_RVEC. I just did not expect this. Is it documented somewhere? I cannot find it in the current documentation.

You're right, this particular fact had not made it into the documentation. Thanks for prompting me on this. I've added a comment to the "standard.kim" file that explains this. It will be included in the next release.

Cheers,

Ryan