The charge_flow package is a visualization and analysis tool for exploring charge flow between atoms in an atomistic structure. It combines per-atom charge data (e.g. from Bader analysis) with structural coordinates to produce 3D or 2D visualizations of charge flow magnitudes and directions.
You can install and run charge_flow in an isolated Conda environment to ensure all dependencies work correctly. The package relies on scientific Python libraries and visualization backends such as pyvista and vtk.
git clone git@github.com:nlesc-nano/charge_flow.git
cd charge_flowCreate the environment manually using conda-forge
conda create -n charge_flow python=3.10 numpy scipy matplotlib pyvista vtk networkx rdkit -c conda-forge
conda activate charge_flowStandard install:
pip install .Editable/development install:
pip install -e .python -m charge_flow --xyz your_structure.xyz --bader ACF.datThis command launches the 3D visualization showing charge-flow vectors (arrows). Larger arrows represent larger charge-flow magnitudes; smaller arrows represent smaller ones.
python -m charge_flow -hDisplays all available options.
python -m charge_flow --xyz file.xyz --bader ACF.dat --mode fieldDisplays the full 3D vector field.
--display arrows
--scale-3d N- Adjusts arrow size (
N=2default). N=0will cause the program to fail.
--show-total-resultant
--resultant-scale N
--resultant-color COLORShows a resultant arrow at the model’s center of mass, summing all charge-flow magnitudes. Scale and color are customizable.
--show-snowball
--snowball-scale N
--snowball-color COLORDisplays an interactive cumulative resultant vector, growing with the sphere radius from the center of mass.
--display spheres
--sphere-scale NShows spheres representing charge-flow magnitudes. N=0 hides spheres (wireframe only), N=1 enlarges them.
python -m charge_flow --xyz file.xyz --bader ACF.dat --mode atomWithout selecting atoms, shows only the wireframe.
--atoms a1 a2 a3 ... aNShows charge-flow vectors for the selected atoms (1-based indexing). If any index exceeds total atoms, an error appears.
--view 3d
--view 2d
--view both3d: Default interactive mode.2d: 2D projected map with arrows and dots for atoms.both: Combines both visualizations.
--plane {xy, yz, xz, pca, ...}Sets projection plane (origin at center of mass). Must be combined with --view 2d.
--plane-normal h k l
--plane-origin x y z
--slab nDefines projection using Miller indices and optional custom origin or slab thickness (in Å).
Recommended slab thickness: n=1 Å.
--fig-size X Y
--fig-lims x1min x1max x2min x2maxControls figure dimensions and axis limits in projected coordinates.
--idw-radius N
--idw-power NControls the inverse distance weighting parameters for smooth background mapping.
- Default view is equivalent to
--mode field --display arrows --view 3d. --planerequires--view 2dto take effect.- Atom indices are 1-based and must be valid within the structure size.
python -m charge_flow --xyz model.xyz --bader ACF.datpython -m charge_flow --xyz model.xyz --bader ACF.dat --show-total-resultantpython -m charge_flow --xyz model.xyz --bader ACF.dat --mode atom --atoms 5 12 33python -m charge_flow --xyz model.xyz --bader ACF.dat --view 2d --plane xypython -m charge_flow --xyz model.xyz --bader ACF.dat --view 2d --plane-normal 1 1 0 --slab 1