Skip to main content

CP2K Scanning Probe Microscopy tools

DOI PyPI - Version

Library and scripts to perform scanning probe microscopy simulations based on a CP2K calculation.

Features include:

  • Processing the various output files of CP2K, including the .wfn file
  • Scanning Tunnelling Microscopy and Spectroscopy (STM/STS) analysis
  • Fourier-Transformed STS analysis for finite cutouts of periodic systems
  • Orbital hybridization analysis for adsorbed systems
  • High-resolution STM (HRSTM) simulations

Installation

The package requires an MPI implementation to be available on your system for mpi4py. One option is mpich, which you can install with:

  • On Linux: through your package manager (e.g., apt install mpich or yum install mpich)
  • On macOS: through Homebrew (brew install mpich)
  • Or via conda, but then it's recommended to install it together with mpi4py: conda install -c conda-forge mpi4py mpich

Then install the package with pip:

pip install cp2k-spm-tools

Or, for development:

git clone https://github.com/nanotech-empa/cp2k-spm-tools.git
cd cp2k-spm-tools
pip install -e .[dev]

Command Line Tools

The package provides several command-line tools, including:

  • cp2k-stm-sts-wfn: STM/STS analysis from wavefunction files
  • cp2k-cube-from-wfn: Create cube files from wavefunction files
  • cp2k-bader-bond-order: Bond order analysis based on Bader basins
  • cp2k-overlap-to-sparse-npz: Convert CP2K AO overlap matrix logs to compact sparse NPZ files

Use --help with each command to see its options.

Example Usage

When everything is set up correctly, the bash scripts in examples/ folder can be executed without any further input and illustrate the usage of the various scripts. For example example/benzene_stm/run_stm_sts_from_wfn.sh evaluates the STM/STS signatures of isolated benzene at each orbital energy (out/orb/) as well as in an arbitrary energy range (out/stm/). The corresponding CP2K calculation is included in the repository. For sparse AO overlap conversion, see examples/overlap_to_sparse_npz/run.sh.

NB: In all cases, the underlying DFT calculation has to be performed with the diagonalization algorithm rather than orbital transformation (OT).

Python API Example

Most of the functionality of this library is built on top of the possibility to evaluate the Kohn-Sham orbitals encoded in the .wfn file on an arbitrarily defined grid. This is illustrated by the following script applied for a nanographene adsorbed on a Au(111) slab (total of 1252 atoms and 10512 electrons):

from cp2k_spm_tools.cp2k_grid_orbitals import Cp2kGridOrbitals

### Create the gridding object and load the cp2k data ###
cgo = Cp2kGridOrbitals()
cgo.read_cp2k_input("./cp2k.inp")
cgo.read_xyz("./geom.xyz")
cgo.read_basis_functions("./BASIS_MOLOPT")
cgo.load_restart_wfn_file("./PROJ-RESTART.wfn", n_occ=2, n_virt=2)

### Evaluate the orbitals in the specific region ###
cgo.calc_morbs_in_region(
    dr_guess = 0.15,                          # grid spacing, can change very slightly
    x_eval_region = None,                     # take whole cell in x
    y_eval_region = [0.0, cgo.cell_ang[1]/2], # half cell in y
    z_eval_region = [19.0, 24.0],             # around the molecule in z
)

cgo.write_cube("./homo.cube", orbital_nr=0)

Here's the resulting cube file, illustrating the constrained region of evaluation:

For maintainers:

In order to make a new release of the library and publish to PYPI, run

bumpver update --major/--minor/--patch

This will

  • update version numbers, make a corresponding git commit and a git tag;
  • push this commit and tag to Github, which triggers the Github Action that makes a new Github Release and publishes the package to PYPI.

Metadata

Release files for cp2k-spm-tools 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cp2k-spm-tools 1.6.0
File Size Uploaded
cp2k_spm_tools-1.6.0.tar.gz 70.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cp2k-spm-tools 1.6.0
File Interpreter ABI Platform
cp2k_spm_tools-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 151.6 kB

Release files / cp2k_spm_tools-1.6.0.tar.gz

Download URL cp2k_spm_tools-1.6.0.tar.gz
Size 70.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9ca306284c8a10b22da03d7da3892d187eda2608d0c893f9818205e5f2842a19
BLAKE2b-256 checksum
How to use checksums
4ddf1b76450347bc49801404ea504a564324ac76145e7e2238c1c03ea4842968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / cp2k_spm_tools-1.6.0-py3-none-any.whl

Download URL cp2k_spm_tools-1.6.0-py3-none-any.whl
Size 81.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e46da6cfbd6b71b2e2260b5ae851254e373db90c6af278ef9d641d71a9366731
BLAKE2b-256 checksum
How to use checksums
315cf956e084c4d5686f5316bcc654cce739a70f3d347a5642b739fa87269bce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.0

2 release files

1.4.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page