Provides pure combinatorial functions for generating molecular fragments including binomial coefficients, combinations, and fragment counting Binomial coefficient calculation Calculate total number of fragments Generate sequential monomer indices Generate all fragments up to max level Generate all combinations of size r Generate next combination in sequence Initialize combination to [1,2,…,k] Generate next combination (alternate interface) Debug utility to print combinations Calculate minimal distances for all fragments
Compute binomial coefficient C(n,r) = n! / (r! * (n-r)!)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | n |
Total number of items |
||
| integer(kind=default_int), | intent(in) | :: | r |
Number of items to choose |
Binomial coefficient result
Calculate total number of fragments for given system size and max level
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | n_monomers |
Number of monomers in system |
||
| integer(kind=default_int), | intent(in) | :: | max_level |
Maximum fragment size |
Total fragment count
Generate next combination in lexicographic order Returns .true. if there’s a next combination, .false. if we’ve exhausted all
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | combination(:) | |||
| integer, | intent(in) | :: | k | |||
| integer, | intent(in) | :: | n |
Calculate minimal atomic distance for each fragment For monomers (1-body), distance is 0.0 For n-mers (n >= 2), distance is the minimum distance between atoms in different constituent monomers
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | polymers(:,:) | |||
| integer(kind=int64), | intent(in) | :: | fragment_count | |||
| type(system_geometry_t), | intent(in) | :: | sys_geom | |||
| real(kind=dp), | intent(out) | :: | distances(:) |
Generate all combinations of size r from array arr of size n Uses int64 for count to handle large numbers of combinations that overflow int32.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | arr(:) | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| integer(kind=default_int), | intent(in) | :: | r | |||
| integer(kind=default_int), | intent(inout) | :: | out_array(:,:) | |||
| integer(kind=int64), | intent(inout) | :: | count |
Generate a list of monomer indices from 1 to N
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(inout), | allocatable | :: | monomers(:) |
Generate all possible fragments (combinations of monomers) up to max_level Uses int64 for count to handle large numbers of fragments that overflow int32.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | monomers(:) | |||
| integer(kind=default_int), | intent(in) | :: | max_level | |||
| integer(kind=default_int), | intent(inout) | :: | polymers(:,:) | |||
| integer(kind=int64), | intent(inout) | :: | count |
Generate next combination (updates indices in place) has_next = .true. if there’s a next combination
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | indices(:) | |||
| integer, | intent(in) | :: | k | |||
| integer, | intent(in) | :: | n | |||
| logical, | intent(out) | :: | has_next |
Initialize combination to [1, 2, …, k]
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | combination(:) | |||
| integer, | intent(in) | :: | k |
Print combinations stored in out_array Uses int64 for count to handle large numbers of combinations that overflow int32.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | out_array(:,:) | |||
| integer(kind=int64), | intent(in) | :: | count | |||
| integer(kind=default_int), | intent(in) | :: | max_len |
Utility for generating combinations recursively Uses int64 for count to handle large numbers of combinations that overflow int32.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | arr(:) | |||
| integer(kind=default_int), | intent(in) | :: | n | |||
| integer(kind=default_int), | intent(in) | :: | r | |||
| integer(kind=default_int), | intent(in) | :: | index | |||
| integer(kind=default_int), | intent(inout) | :: | data(:) | |||
| integer(kind=default_int), | intent(in) | :: | i | |||
| integer(kind=default_int), | intent(inout) | :: | out_array(:,:) | |||
| integer(kind=int64), | intent(inout) | :: | count |