% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/process_coordinates.R
\name{merge_sites_pbc}
\alias{merge_sites_pbc}
\title{Merge Close Atoms (Pymatgen Style)}
\usage{
merge_sites_pbc(atomic_coordinates, unit_cell_metrics, tol = 1e-04)
}
\arguments{
\item{atomic_coordinates}{A data.table with columns \code{Label}, \code{x_a}, \code{y_b}, \code{z_c}.}

\item{unit_cell_metrics}{A data.table containing cell lengths and angles.}

\item{tol}{Numeric. Distance tolerance in Angstroms. Sites closer than this will be merged.
Default is 1e-4.}
}
\value{
A deduplicated data.table with coordinates averaged.
}
\description{
Merges atomic sites that are within a specified distance tolerance,
accounting for Periodic Boundary Conditions (PBC). This mimics pymatgen's
\code{Structure.merge_sites} logic: it performs hierarchical clustering and then
averages the coordinates of the merged sites, taking care of PBC wrapping.
}
\examples{
ac <- data.table::data.table(Label = c("A", "B"),
                             x_a = c(0, 0.00001),
                             y_b = c(0, 0),
                             z_c = c(0, 0))
uc <- data.table::data.table(`_cell_length_a` = 10, `_cell_length_b` = 10,
                             `_cell_length_c` = 10, `_cell_angle_alpha` = 90,
                             `_cell_angle_beta` = 90, `_cell_angle_gamma` = 90)
merge_sites_pbc(ac, uc, tol = 1e-4)
}
