Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

sponge.partition.DistanceNeighbours

View Source On Gitee
class sponge.partition.DistanceNeighbours(cutoff: float, num_neighbours: int = None, atom_mask: Tensor = None, exclude_index: Tensor = None, use_pbc: bool = None, cutoff_scale: float = 1.2, large_dis: float = 10000.0, cast_fp16: bool = False)[source]

Neighbour list calculated by distance

Parameters
  • cutoff (float) – Cutoff distance.

  • num_neighbours (int, optional) – Number of neighbours. If None is given, this value will be calculated by the ratio of the number of neighbouring grids to the total number of grids. Default: None.

  • atom_mask (Tensor, optional) – Tensor of shape (B,A). Data type is bool_. Mask of atoms in the system. Default: None.

  • exclude_index (Tensor, optional) – Tensor of shape (B,A,Ex). Data type is int32. Index of neighbour atoms which could be excluded from the neighbour list. Default: None.

  • use_pbc (bool, optional) – Whether to use periodic boundary condition. Default: None.

  • cutoff_scale (float, optional) – Factor to scale the cutoff distance. Default: 1.2

  • large_dis (float, optional) – A large number to fill in the distances to the masked neighbouring atoms. Default: 1e4

  • cast_fp16 (bool, optional) – If this is set to True, the data will be cast to float16 before sort. For use with some devices that only support sorting of float16 data. Default: False.

Note

  • B: Number of simulation walker.

  • A: Number of atoms in system.

  • N: Number of neighbour atoms.

  • Ex: Maximum number of excluded neighbour atoms.

Supported Platforms:

Ascend GPU

Examples

>>> import sponge
>>> from sponge.partition import DistanceNeighbours
>>> import mindspore
>>> from mindspore import Tensor
>>> distance_neighbours = DistanceNeighbours(0.5, use_pbc=False)
>>> coordinate = Tensor([[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]])
>>> distance_neighbours(coordinate)
(Tensor(shape=[1, 2, 1], dtype=Float32, value=
 [[[ 1.00000000e+00],
 [ 1.00000000e+00]]]),
 Tensor(shape=[1, 2, 1], dtype=Int64, value=
 [[[0],
 [1]]]),
 Tensor(shape=[1, 2, 1], dtype=Bool, value=
 [[[False],
 [False]]]))
>>> distance = Tensor([[[1.0, 0.0, 0.0], [0.0, 0.0, 0.0]]])
>>> distance_neighbours.calc_max_neighbours(distance, 0.5)
Tensor(shape=[], dtype=Int32, value= 2)
>>> distance_neighbours.check_neighbour_list()
DistanceNeighbours<
  (get_distance): GetDistance<>
  >
static calc_max_neighbours(distances: Tensor, cutoff: float)[source]

Calculate the maximum number of neighbouring atoms.

Parameters
  • distances (Tensor) – Tensor of shape (B,A,N). Data type is float.

  • cutoff (float) – Cutoff distance.

check_neighbour_list()[source]

Check the number of neighbouring atoms in neighbour list.

print_info()[source]

Print the information of neighbour list.

set_exclude_index(exclude_index: Tensor)[source]

Set the indices of atoms to be excluded from the neighbor list.

Parameters

exclude_index (Tensor) – Tensor of shape (B,A,Ex). Data type is int. Index of the atoms that should be excluded from the neighbour list.

set_num_neighbours(coordinate: Tensor, pbc_box: Tensor = None, scale_factor: float = 1.25)[source]

Set maximum number of neighbouring atoms.

Parameters
  • coordinate (Tensor) – Tensor of shape (B,A,D). Data type is float. Position coordinates of atoms

  • pbc_box (Tensor, optional) – Tensor of shape (B,D). Data type is bool. Periodic boundary condition box. Default: None.

  • scale_factor (float, optional) – Factor to scale the cutoff distance. Default: 1.25.