compute_polymer_atoms Subroutine

public pure subroutine compute_polymer_atoms(sys_geom, polymer, polymer_size, atom_list, n_atoms)

Uses

  • proc~~compute_polymer_atoms~~UsesGraph proc~compute_polymer_atoms compute_polymer_atoms module~mqc_physical_fragment mqc_physical_fragment proc~compute_polymer_atoms->module~mqc_physical_fragment module~mqc_cgto mqc_cgto module~mqc_physical_fragment->module~mqc_cgto module~mqc_elements mqc_elements module~mqc_physical_fragment->module~mqc_elements module~mqc_error mqc_error module~mqc_physical_fragment->module~mqc_error module~mqc_geometry mqc_geometry module~mqc_physical_fragment->module~mqc_geometry module~mqc_physical_constants mqc_physical_constants module~mqc_physical_fragment->module~mqc_physical_constants module~mqc_xyz_reader mqc_xyz_reader module~mqc_physical_fragment->module~mqc_xyz_reader pic_types pic_types module~mqc_physical_fragment->pic_types module~mqc_cgto->pic_types module~mqc_elements->pic_types pic_ascii pic_ascii module~mqc_elements->pic_ascii module~mqc_geometry->pic_types module~mqc_physical_constants->pic_types module~mqc_xyz_reader->module~mqc_error module~mqc_xyz_reader->module~mqc_geometry module~mqc_xyz_reader->pic_types

Compute the atom list for a polymer (union of atoms from base fragments) polymer(:) contains base fragment indices (1-based)

Arguments

Type IntentOptional Attributes Name
type(system_geometry_t), intent(in) :: sys_geom
integer, intent(in) :: polymer(:)

Base fragment indices in this polymer

integer, intent(in) :: polymer_size

Number of base fragments in polymer

integer, intent(out), allocatable :: atom_list(:)

Unique atoms in this polymer

integer, intent(out) :: n_atoms

Number of unique atoms


Called by

proc~~compute_polymer_atoms~~CalledByGraph proc~compute_polymer_atoms compute_polymer_atoms proc~generate_polymer_intersections generate_polymer_intersections proc~generate_polymer_intersections->proc~compute_polymer_atoms proc~gmbe_enumerate_pie_terms gmbe_enumerate_pie_terms proc~gmbe_enumerate_pie_terms->proc~compute_polymer_atoms proc~run_fragmented_calculation run_fragmented_calculation proc~run_fragmented_calculation->proc~gmbe_enumerate_pie_terms proc~run_calculation run_calculation proc~run_calculation->proc~run_fragmented_calculation proc~compute_energy_and_forces compute_energy_and_forces proc~compute_energy_and_forces->proc~run_calculation proc~run_multi_molecule_calculations run_multi_molecule_calculations proc~run_multi_molecule_calculations->proc~run_calculation program~main main program~main->proc~run_calculation program~main->proc~run_multi_molecule_calculations

Variables

Type Visibility Attributes Name Initial
logical, private :: already_present
integer, private :: frag_idx
integer, private :: frag_size
integer, private :: i
integer, private :: j
integer, private, allocatable :: temp_atoms(:)
integer, private :: temp_count

Source Code

   pure subroutine compute_polymer_atoms(sys_geom, polymer, polymer_size, atom_list, n_atoms)
      !! Compute the atom list for a polymer (union of atoms from base fragments)
      !! polymer(:) contains base fragment indices (1-based)
      use mqc_physical_fragment, only: system_geometry_t
      type(system_geometry_t), intent(in) :: sys_geom
      integer, intent(in) :: polymer(:)  !! Base fragment indices in this polymer
      integer, intent(in) :: polymer_size  !! Number of base fragments in polymer
      integer, allocatable, intent(out) :: atom_list(:)  !! Unique atoms in this polymer
      integer, intent(out) :: n_atoms  !! Number of unique atoms

      integer, allocatable :: temp_atoms(:)
      integer :: i, j, frag_idx, frag_size, temp_count
      logical :: already_present

      ! Allocate temporary array (worst case: all atoms from all fragments)
      allocate (temp_atoms(sys_geom%total_atoms))
      temp_count = 0

      ! Loop through each base fragment in the polymer
      do i = 1, polymer_size
         frag_idx = polymer(i)
         if (frag_idx == 0) exit  ! Padding zeros

         frag_size = sys_geom%fragment_sizes(frag_idx)

         ! Add each atom from this fragment (avoid duplicates)
         do j = 1, frag_size
            already_present = .false.

            ! Check if this atom is already in our list
            block
               integer :: k, current_atom
               current_atom = sys_geom%fragment_atoms(j, frag_idx)
               do k = 1, temp_count
                  if (temp_atoms(k) == current_atom) then
                     already_present = .true.
                     exit
                  end if
               end do
            end block

            ! Add if not already present
            if (.not. already_present) then
               temp_count = temp_count + 1
               temp_atoms(temp_count) = sys_geom%fragment_atoms(j, frag_idx)
            end if
         end do
      end do

      ! Copy to output array
      n_atoms = temp_count
      allocate (atom_list(n_atoms))
      atom_list = temp_atoms(1:n_atoms)

      deallocate (temp_atoms)
   end subroutine compute_polymer_atoms