Check if a fragment should be screened out based on distance cutoffs. Returns true if the fragment itself OR any of its k-subsets (k >= 2) exceeds the corresponding k-mer cutoff. This ensures MBE subset consistency.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | fragment(:) | |||
| integer, | intent(in) | :: | n | |||
| type(system_geometry_t), | intent(in) | :: | sys_geom | |||
| type(driver_config_t), | intent(in) | :: | driver_config |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=dp), | private | :: | cutoff | ||||
| real(kind=dp), | private | :: | distance | ||||
| logical, | private | :: | has_next | ||||
| integer, | private | :: | indices(n) | ||||
| integer, | private | :: | j | ||||
| integer, | private | :: | num_cutoffs | ||||
| integer, | private | :: | subset(n) | ||||
| integer, | private | :: | subset_size |
function fragment_should_be_screened(fragment, n, sys_geom, driver_config) result(should_screen) !! Check if a fragment should be screened out based on distance cutoffs. !! Returns true if the fragment itself OR any of its k-subsets (k >= 2) exceeds !! the corresponding k-mer cutoff. This ensures MBE subset consistency. use mqc_physical_fragment, only: calculate_monomer_distance use mqc_config_adapter, only: driver_config_t integer, intent(in) :: fragment(:) integer, intent(in) :: n type(system_geometry_t), intent(in) :: sys_geom type(driver_config_t), intent(in) :: driver_config logical :: should_screen integer :: subset_size, num_cutoffs integer :: indices(n), subset(n) integer :: j real(dp) :: distance, cutoff logical :: has_next should_screen = .false. num_cutoffs = size(driver_config%fragment_cutoffs) ! Check all subset sizes from 2 up to n (the full fragment) ! If any k-subset exceeds the k-mer cutoff, screen this fragment do subset_size = 2, n ! Skip if no cutoff defined for this level if (subset_size > num_cutoffs) cycle cutoff = driver_config%fragment_cutoffs(subset_size) ! Skip if cutoff is non-positive (no screening for this level) if (cutoff <= 0.0_dp) cycle ! Initialize first combination indices do j = 1, subset_size indices(j) = j end do ! Loop through all combinations of this size do ! Build current subset do j = 1, subset_size subset(j) = fragment(indices(j)) end do ! Calculate distance for this subset distance = calculate_monomer_distance(sys_geom, subset(1:subset_size)) ! If subset exceeds cutoff, screen the whole fragment if (distance > cutoff) then should_screen = .true. return end if ! Get next combination call get_next_combination(indices, subset_size, n, has_next) if (.not. has_next) exit end do end do end function fragment_should_be_screened