Add hydrogen caps to fragment for broken bonds Caps are placed at the position of the atom outside the fragment
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | atoms_in_fragment(:) |
0-indexed atom indices in fragment |
||
| type(bond_t), | intent(in) | :: | bonds(:) | |||
| type(system_geometry_t), | intent(in) | :: | sys_geom | |||
| type(physical_fragment_t), | intent(inout) | :: | fragment | |||
| integer, | intent(in) | :: | base_atom_count |
Number of non-cap atoms |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | atom_i_in_frag | ||||
| logical, | private | :: | atom_j_in_frag | ||||
| integer, | private | :: | cap_idx | ||||
| integer, | private | :: | ibond |
subroutine add_hydrogen_caps(atoms_in_fragment, bonds, sys_geom, fragment, base_atom_count) !! Add hydrogen caps to fragment for broken bonds !! Caps are placed at the position of the atom outside the fragment integer, intent(in) :: atoms_in_fragment(:) !! 0-indexed atom indices in fragment type(bond_t), intent(in) :: bonds(:) type(system_geometry_t), intent(in) :: sys_geom type(physical_fragment_t), intent(inout) :: fragment integer, intent(in) :: base_atom_count !! Number of non-cap atoms integer :: ibond, cap_idx logical :: atom_i_in_frag, atom_j_in_frag if (fragment%n_caps == 0) return cap_idx = 0 do ibond = 1, size(bonds) if (.not. bonds(ibond)%is_broken) cycle atom_i_in_frag = any(atoms_in_fragment == bonds(ibond)%atom_i) atom_j_in_frag = any(atoms_in_fragment == bonds(ibond)%atom_j) if (atom_i_in_frag .and. .not. atom_j_in_frag) then ! atom_i is in fragment, atom_j is not → cap at position of atom_j cap_idx = cap_idx + 1 fragment%element_numbers(base_atom_count + cap_idx) = 1 ! Hydrogen ! Place H at position of atom_j (1-indexed for coordinates array) fragment%coordinates(:, base_atom_count + cap_idx) = & sys_geom%coordinates(:, bonds(ibond)%atom_j + 1) fragment%cap_replaces_atom(cap_idx) = bonds(ibond)%atom_j else if (atom_j_in_frag .and. .not. atom_i_in_frag) then ! atom_j is in fragment, atom_i is not → cap at position of atom_i cap_idx = cap_idx + 1 fragment%element_numbers(base_atom_count + cap_idx) = 1 ! Hydrogen ! Place H at position of atom_i (1-indexed for coordinates array) fragment%coordinates(:, base_atom_count + cap_idx) = & sys_geom%coordinates(:, bonds(ibond)%atom_i + 1) fragment%cap_replaces_atom(cap_idx) = bonds(ibond)%atom_i end if end do end subroutine add_hydrogen_caps