VirtualSiteGenerator

class openff.recharge.charges.vsite.VirtualSiteGenerator[source]

Bases: object

Methods

__init__()

apply_charge_assignment_matrix(...)

Applies an assignment matrix to a list of virtual site parameters to yield the final charges increments due to the virtual sites for a molecule.

build_charge_assignment_matrix(molecule, ...)

Generates a matrix that specifies which v-site charge increments have been applied to which atoms in the molecule.

build_local_coordinate_frames(conformer, ...)

Builds an orthonormal coordinate frame for each virtual particle based on the type of virtual site and the coordinates of the parent atoms.

convert_local_coordinates()

Converts a set of local virtual site coordinates defined in a spherical coordinate system into a full set of cartesian coordinates.

generate_charge_increments(molecule, ...)

Generate a set of charge increments due to virtual sites for a molecule.

generate_positions(molecule, ...)

Computes the positions of a set of virtual sites relative to a provided molecule in a given conformer.

__init__()
classmethod apply_charge_assignment_matrix(assignment_matrix: ndarray, vsite_collection: VirtualSiteCollection) ndarray[source]

Applies an assignment matrix to a list of virtual site parameters to yield the final charges increments due to the virtual sites for a molecule.

Parameters
  • assignment_matrix – The virtual site charge increment assignment matrix constructed using build_charge_assignment_matrix that describes how the virtual site charge increments should be applied. This should have shape=(n_atoms + n_vsites, n_charge_increments)

  • vsite_collection – The virtual site parameters that may be assigned.

Return type

The charge increments with shape=(n_atoms + n_vsites, 1).

classmethod build_charge_assignment_matrix(molecule: Molecule, vsite_collection: VirtualSiteCollection) ndarray[source]

Generates a matrix that specifies which v-site charge increments have been applied to which atoms in the molecule.

The matrix takes the form …

Parameters
  • molecule – The molecule to assign the v-site charge increments to.

  • vsite_collection – The v-site parameters that may be assigned.

Returns

  • The assignment matrix with shape=(n_atoms + n_vsites, n_charge_increments)

  • where …

classmethod build_local_coordinate_frames(conformer: ndarray, assigned_parameters: List[Tuple[Union[BondChargeSiteParameter, MonovalentLonePairParameter, DivalentLonePairParameter, TrivalentLonePairParameter], List[Tuple[int, ...]]]]) ndarray[source]

Builds an orthonormal coordinate frame for each virtual particle based on the type of virtual site and the coordinates of the parent atoms.

Notes

Parameters
  • conformer – The conformer of the molecule that the virtual sites are being added to with shape=(n_atoms, 3) and units of [A].

  • assigned_parameters – A dictionary of the form assigned_parameters[atom_indices] = parameters where atom_indices is a tuple of indices corresponding to the atoms that the virtual site is orientated on, and parameters is a list of the parameters that describe the virtual sites.

Returns

  • An array storing the local frames of all virtual sites with

  • shape=(4, n_vsites, 3) whereby local_frames[0] is an array of the

  • origins of each frame, local_frames[1] the x-directions,

  • local_frames[2] the y-directions, and local_frames[2] the

  • z-directions.

classmethod convert_local_coordinates(local_frame_coordinates: ndarray, local_coordinate_frames: ndarray, backend: Literal['numpy']) ndarray[source]
classmethod convert_local_coordinates(local_frame_coordinates: torch.Tensor, local_coordinate_frames: torch.Tensor, backend: Literal['torch']) torch.Tensor

Converts a set of local virtual site coordinates defined in a spherical coordinate system into a full set of cartesian coordinates.

Parameters
  • local_frame_coordinates – An array containing the local coordinates with shape=(n_vsites, 3) and with columns of distance [A], ‘in plane angle’ [deg] and ‘out of plane’ angle [deg].

  • local_coordinate_frames – The orthonormal basis associated with each of the virtual sites with shape=(4, n_vsites, 3). See the build_local_coordinate_frames function for more details.

  • backend – The framework to use when performing mathematical operations.

Returns

  • An array of the cartesian coordinates of the virtual sites with

  • shape=(n_vsites, 3) and units of [A].

classmethod generate_charge_increments(molecule: Molecule, vsite_collection: VirtualSiteCollection) ndarray[source]

Generate a set of charge increments due to virtual sites for a molecule.

Parameters
  • molecule – The molecule to generate the charge increments for.

  • vsite_collection – The virtual site parameters that may be assigned.

Returns

  • The charge increments with shape=(n_atoms + n_vsites, 1) that should be

  • applied to the molecule.

classmethod generate_positions(molecule: Molecule, vsite_collection: VirtualSiteCollection, conformer: Quantity) Quantity[source]

Computes the positions of a set of virtual sites relative to a provided molecule in a given conformer.

Parameters
  • molecule – The molecule to apply virtual sites to.

  • vsite_collection – The virtual site parameters to apply to the molecule

  • conformer – The conformer [A] of the molecule with shape=(n_atoms, 3) that the virtual sites should be placed relative to.

Return type

An array of virtual site positions [A] with shape=(n_vsites, 3).

classmethod build_charge_assignment_matrix(molecule: Molecule, vsite_collection: VirtualSiteCollection) ndarray[source]

Generates a matrix that specifies which v-site charge increments have been applied to which atoms in the molecule.

The matrix takes the form …

Parameters
  • molecule – The molecule to assign the v-site charge increments to.

  • vsite_collection – The v-site parameters that may be assigned.

Returns

  • The assignment matrix with shape=(n_atoms + n_vsites, n_charge_increments)

  • where …

classmethod apply_charge_assignment_matrix(assignment_matrix: ndarray, vsite_collection: VirtualSiteCollection) ndarray[source]

Applies an assignment matrix to a list of virtual site parameters to yield the final charges increments due to the virtual sites for a molecule.

Parameters
  • assignment_matrix – The virtual site charge increment assignment matrix constructed using build_charge_assignment_matrix that describes how the virtual site charge increments should be applied. This should have shape=(n_atoms + n_vsites, n_charge_increments)

  • vsite_collection – The virtual site parameters that may be assigned.

Return type

The charge increments with shape=(n_atoms + n_vsites, 1).

classmethod generate_charge_increments(molecule: Molecule, vsite_collection: VirtualSiteCollection) ndarray[source]

Generate a set of charge increments due to virtual sites for a molecule.

Parameters
  • molecule – The molecule to generate the charge increments for.

  • vsite_collection – The virtual site parameters that may be assigned.

Returns

  • The charge increments with shape=(n_atoms + n_vsites, 1) that should be

  • applied to the molecule.

classmethod build_local_coordinate_frames(conformer: ndarray, assigned_parameters: List[Tuple[Union[BondChargeSiteParameter, MonovalentLonePairParameter, DivalentLonePairParameter, TrivalentLonePairParameter], List[Tuple[int, ...]]]]) ndarray[source]

Builds an orthonormal coordinate frame for each virtual particle based on the type of virtual site and the coordinates of the parent atoms.

Notes

Parameters
  • conformer – The conformer of the molecule that the virtual sites are being added to with shape=(n_atoms, 3) and units of [A].

  • assigned_parameters – A dictionary of the form assigned_parameters[atom_indices] = parameters where atom_indices is a tuple of indices corresponding to the atoms that the virtual site is orientated on, and parameters is a list of the parameters that describe the virtual sites.

Returns

  • An array storing the local frames of all virtual sites with

  • shape=(4, n_vsites, 3) whereby local_frames[0] is an array of the

  • origins of each frame, local_frames[1] the x-directions,

  • local_frames[2] the y-directions, and local_frames[2] the

  • z-directions.

classmethod convert_local_coordinates(local_frame_coordinates: ndarray, local_coordinate_frames: ndarray, backend: Literal['numpy']) ndarray[source]
classmethod convert_local_coordinates(local_frame_coordinates: torch.Tensor, local_coordinate_frames: torch.Tensor, backend: Literal['torch']) torch.Tensor

Converts a set of local virtual site coordinates defined in a spherical coordinate system into a full set of cartesian coordinates.

Parameters
  • local_frame_coordinates – An array containing the local coordinates with shape=(n_vsites, 3) and with columns of distance [A], ‘in plane angle’ [deg] and ‘out of plane’ angle [deg].

  • local_coordinate_frames – The orthonormal basis associated with each of the virtual sites with shape=(4, n_vsites, 3). See the build_local_coordinate_frames function for more details.

  • backend – The framework to use when performing mathematical operations.

Returns

  • An array of the cartesian coordinates of the virtual sites with

  • shape=(n_vsites, 3) and units of [A].

classmethod generate_positions(molecule: Molecule, vsite_collection: VirtualSiteCollection, conformer: Quantity) Quantity[source]

Computes the positions of a set of virtual sites relative to a provided molecule in a given conformer.

Parameters
  • molecule – The molecule to apply virtual sites to.

  • vsite_collection – The virtual site parameters to apply to the molecule

  • conformer – The conformer [A] of the molecule with shape=(n_atoms, 3) that the virtual sites should be placed relative to.

Return type

An array of virtual site positions [A] with shape=(n_vsites, 3).