AtomicSystem.neutralize_charge#
- AtomicSystem.neutralize_charge(atom_types=None, tol=1e-08)#
Neutralize the system by spreading its excess charge over atom types.
The current
total_chargeis subtracted back into the system as a per-atom offset, split across the given atom types. The offset for a type is added to every atom of that type, so any charge variation between individual atoms of the same type (e.g. per-atom ReaxFF/EEM charges) is preserved rather than overwritten.- Parameters:
- atom_types
Mapping from atom type to a relative per-atom weight: every atom of type
treceives the offset-excess * w_t / sum(w_i * n_i), wheren_iis the number of atoms of typei. Equal weights therefore give the same offset to every atom of the listed types, whatever their number (only the ratio between weights matters, they need not sum to 1). Types absent from the mapping are left untouched. If omitted, the excess is divided uniformly over every atom in the system.- tol
Below this absolute total charge, the system is already considered neutral and nothing is done.