Skip to contents

Counts the weighted number of nearest neighbors for each central atom based on a table of bonded pairs, accounting for the fractional occupancy of the neighbor sites. This is particularly useful for analyzing disordered crystal structures.

If all occupancies are 1.0, this efficiently returns the standard coordination number. If the fractional occupancies on any single crystallographic site sum to greater than 1.0, this indicates an invalid or physically impossible structure; the function will throw a warning and return NULL so the file can be discarded by the analysis pipeline.

Usage

calculate_weighted_neighbor_counts(bonded_pairs_table, atomic_coordinates)

Arguments

bonded_pairs_table

A data.table of bonded pairs (e.g., from minimum_distance).

atomic_coordinates

A data.table of asymmetric atoms from extract_atomic_coordinates.

Value

A data.table with columns 'Atom', 'CoordinationNumber', and 'WeightedCoordinationNumber'. Returns NULL if the occupancies sum to > 1 on any shared site.

Examples

bp <- data.table::data.table(Atom1 = c("Si1", "Si1"),
                             Atom2 = c("O1_1_0_0", "O2_1_0_0"))
ac <- data.table::data.table(Label = c("Si1", "O1", "O2"),
                             Occupancy = c(1.0, 0.5, 0.5),
                             x_a=c(0,0,0), y_b=c(0,0,0), z_c=c(0,0,0))
calculate_weighted_neighbor_counts(bp, ac)
#> Warning: Fractional occupancies add up to greater than 1.0 on one or more sites. Discarding file.
#> NULL