科研 Skill

CP2K第一性原理分子动力学

cp2k-workflow

Covers end-to-end DFT, AIMD, and atomistic workflows with CP2K using the Gaussian-and-plane-waves method: input construction, convergence testing. Use for CP2K-based simulations.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

CP2K Workflow

Description

This skill covers end-to-end DFT, AIMD, and atomistic simulation workflows using CP2K, from input file construction through convergence testing, geometry optimization, and ab initio molecular dynamics. CP2K uses the Gaussian and Plane Waves (GPW) method, which combines a Gaussian-type orbital (GTO) basis with an auxiliary plane-wave density grid, making it efficient for large systems, liquid-phase simulations, and condensed-phase AIMD. Invoke this skill when setting up CP2K calculations, selecting basis sets and GTH pseudopotentials, converging CUTOFF and REL_CUTOFF parameters, diagnosing SCF convergence failures, generating AIMD trajectories, or producing DFT reference data for ML potential training with an open-source code.

Domain Context

CP2K solves the Kohn-Sham DFT equations using the GPW (Gaussian and Plane Waves) or GAPW (Gaussian Augmented Plane Waves) method. The key idea is a dual representation of the electron density: the wavefunction and density matrix are represented in a localized Gaussian basis, while the Hartree potential is evaluated on an auxiliary plane-wave grid using fast Fourier transforms. This avoids the O(N³) cost of dielectric screening in pure plane-wave codes for very large systems, and enables linear-scaling DFT (LS-DFT) via the linear-scaling module.

Physical approximations and structural concepts that must be understood before using this workflow:

  • GPW method: The total electron density is expanded as a sum of atom-centered Gaussian functions, then mapped onto a regular real-space grid at a grid spacing controlled by CUTOFF (in Ry). The Hartree energy is evaluated in reciprocal space via FFT. The accuracy of this mapping depends on both CUTOFF and REL_CUTOFF — both must be converged explicitly. Unlike VASP or QE, a high CUTOFF alone is insufficient if REL_CUTOFF is too low.
  • GAPW method: Augments GPW with atom-centered hard and soft auxiliary density expansions near nuclei (analogous to PAW), allowing all-electron calculations or harder core regions without increasing the plane-wave grid cost. Used for core-level spectroscopy (XPS, XANES) and when soft pseudopotentials are insufficient. Higher cost than GPW for the same basis.
  • GTH pseudopotentials: Goedecker-Teter-Hutter norm-conserving pseudopotentials are the standard for CP2K. They are available for LDA, PBE, BLYP, PBE0, and several other functionals. The pseudopotential and basis set must be generated for and matched to the same XC functional — using a GTH-PBE pseudopotential with a BLYP functional is inconsistent and produces wrong results.
  • Gaussian basis sets: CP2K ships MOLOPT-optimized basis sets (short-range SR variants for solids, standard for molecules). Quality tiers: SZV (minimal, screening only), DZVP (double-ζ + polarization, standard production), TZV2P (triple-ζ, higher accuracy), TZV2PX (extended). Short-range SR basis sets are preferred for periodic solids because they minimize linear dependence and basis set superposition error in condensed phases.
  • CUTOFF (Ry): Controls the plane-wave grid density for the auxiliary density. Analogous to ecutrho in QE but expressed per-calculation, not per-element. Higher CUTOFF increases grid density and accuracy of the Hartree term. Typical production values: 400–800 Ry for most GTH basis sets.
  • REL_CUTOFF (Ry): Controls the accuracy of the Gaussian-to-grid mapping for each atom type. Each Gaussian is mapped onto a subgrid whose fineness is determined by REL_CUTOFF. If REL_CUTOFF is too small, Gaussian functions are mapped poorly regardless of CUTOFF. Default: 60 Ry; recommended production: 60–100 Ry. Converge by scanning REL_CUTOFF at fixed CUTOFF.
  • OT (Orbital Transformation) method: An iterative direct minimization approach for finding the ground-state wavefunction without diagonalizing the Kohn-Sham matrix. Efficient and stable for insulators and semiconductors with a band gap. Requires a good preconditioner. Cannot handle fractional occupations and must not be used for metallic systems. OUTER_SCF is required alongside OT to converge the total energy, not just the orbital gradient.
  • Diagonalization + smearing for metals: For metallic systems, OT must be replaced with standard diagonalization (&DIAGONALIZATION ON) plus ADDED_MOS (extra molecular orbitals above the HOMO) and Fermi-Dirac or Gaussian smearing. Broyden or Pulay mixing is then required for charge density convergence.
  • Periodic boundary conditions and Poisson solver: CP2K supports fully periodic (3D), slab (2D), wire (1D), and isolated (0D) boundary conditions via the POISSON section. The correct Poisson solver must match the periodicity: PERIODIC for bulk, Martyna-Tuckerman (MT) for isolated molecules or charged slabs, and wavelet-based WAVELET for general non-orthorhombic cells with mixed periodicity.
  • AIMD integration: CP2K uses the Verlet algorithm for NVE, and thermostat-augmented integrators for NVT (CSVR, NOSE) and NPT (BAROSTAT + thermostat). The timestep must be ≤ 1/10 of the period of the fastest vibrational mode — typically 0.5 fs for hydrogen-containing systems, 1–2 fs for heavy-element systems.

When to Use This Skill

  • AIMD simulations of liquids, solutions, interfaces, and disordered systems, where the Gaussian basis and Born-Oppenheimer dynamics are well-suited.
  • Large-scale DFT calculations (> 200–1000 atoms) where CP2K's O(N log N) Coulomb solver is more efficient than pure plane-wave codes.
  • Linear-scaling DFT for very large systems (> 1000 atoms) using CP2K's LS-DFT module.
  • DFT calculations for molecular systems, complex interfaces, or solution-phase chemistry where the Gaussian basis is advantageous.
  • Open-source DFT data generation for ML potential training, as an alternative or complement to QE or VASP.
  • Hybrid functional calculations (PBE0, HSE06) with ADMM acceleration, which is often faster than VASP for large systems.
  • Core-level XPS and XANES spectra using the GAPW method.
  • Condensed-phase thermodynamics via metadynamics or enhanced sampling (CP2K integrates with PLUMED).

When Not to Use This Skill

  • Routine plane-wave DFT benchmarking where VASP or QE are the established standard — CP2K energy comparisons require careful basis-set-superposition correction and are not directly comparable to plane-wave energies without cross-validation.
  • Band structure calculations along high-symmetry paths — CP2K's localized basis does not naturally produce dispersion curves; use VASP or QE with a Wannier interpolation instead.
  • Phonon calculations via DFPT — CP2K lacks a mature DFPT phonon module; use QE (ph.x) or VASP with phonopy/DFPT instead.
  • Strongly correlated systems requiring DMFT or high-level multireference methods — CP2K's DFT+U is available but limited; use dedicated correlated-electron codes.
  • Systems with very heavy elements (actinides, 5f) without validated GTH pseudopotentials — pseudopotential availability and accuracy should be verified against all-electron benchmarks. [EXPERT REVIEW NEEDED]
  • High-throughput DFT screening at the > 10,000 structure scale — CP2K input file generation and output parsing pipelines are less mature than pymatgen/VASP or AiiDA/QE; use those stacks for large-scale screening.

Core Concepts

  • GPW dual representation: Wavefunction expanded in GTOs (Gaussian-type orbitals); density mapped to auxiliary PW grid for Coulomb/XC integration. Both CUTOFF and REL_CUTOFF must converge to achieve accurate energies and forces.
  • MOLOPT basis sets: Optimized to minimize basis set superposition error (BSSE) in condensed phases. SR (short-range) variants suppress long-range tails for better linear independence in periodic systems. Always prefer MOLOPT-SR-GTH for periodic solids and MOLOPT-GTH for molecules.
  • GTH pseudopotential naming: GTH-{FUNCTIONAL}-q{NVALENCE}. The q number gives the number of valence electrons. Example: GTH-PBE-q8 for Fe (3d⁶4s² = 8 valence electrons). The pseudopotential file (GTH_POTENTIALS) and basis set file (BASIS_MOLOPT) are separate and must be consistently paired.
  • OUTER_SCF: An outer loop that restarts the OT minimization with updated density after each outer iteration. Required with OT to ensure the total energy (not just the orbital gradient) converges to the requested EPS_SCF. Without OUTER_SCF, OT may produce a wavefunction satisfying the orbital gradient criterion but with a non-self-consistent Hamiltonian.
  • OT preconditioner: FULL_ALL (full diagonalization-based) is most robust for insulators with large band gaps. FULL_KINETIC is faster for medium-gap systems. FULL_SINGLE_INVERSE is the default and balances cost and stability. A poor preconditioner choice causes OT to converge slowly or not at all.
  • ADDED_MOS: Number of additional molecular orbitals beyond the occupied states. Required for metallic systems using diagonalization + smearing. A too-small value causes unoccupied states to fall below the Fermi level, producing an unconverged electron density.
  • ADMM (Auxiliary Density Matrix Method): Approximates the Hartree-Fock exchange by projecting it onto a smaller auxiliary basis, reducing hybrid functional cost from O(N⁴) toward O(N³) or lower. Controlled by the AUXILIARY_DENSITY_MATRIX_METHOD subsection. The ADMM basis must be smaller than the primary basis and chosen to minimize the exchange approximation error.
  • Poisson solver: The MT (Martyna-Tuckerman) solver enforces zero potential boundary conditions for isolated systems and charged slabs by extending the cell artificially. The PERIODIC solver assumes 3D periodicity and wraps the potential. Using the wrong solver for a charged system or a molecule-in-vacuum causes electrostatic errors that do not converge with cell size.
  • Restart logic: CP2K restart files (.wfn for wavefunction, .xyz and .vel for AIMD state) must match the system size, basis set, and calculation type. Restarting from a wavefunction generated with a different basis or cell produces noise or divergence.

Key Workflows

Full steps for each part are in references/key-workflows/; open the one you need:

Common Failure Modes

FailureSymptomLikely CauseDiagnosticFix
Wrong basis/pseudopotential pairSCF converges but energies are systematically wrong; forces inconsistent; atom-type errors in logGTH pseudopotential generated for a different functional than the XC in use (e.g., GTH-PBE-q with BLYP XC)Check &KIND sections: POTENTIAL GTH-{FUNC}-q{N} must match &XC_FUNCTIONAL {FUNC}Use matching PP and XC functional throughout; GTH-PBE with PBE, GTH-BLYP with BLYP
Unconverged CUTOFFTotal energy drifts as cell deforms; stress tensor unreliable; forces noisy for large basis functionsCUTOFF too low for the contracted Gaussians in the basis setRun CUTOFF convergence scan (Workflow 2); plot E/atom vs CUTOFFIncrease CUTOFF until ΔE/atom < 1 meV/atom; typical production: 400–800 Ry for DZVP-MOLOPT-SR
Low REL_CUTOFF causing grid mapping errorTotal energy converged with CUTOFF but shows steps/kinks in relaxation; forces inconsistentREL_CUTOFF too small for tight Gaussians; atoms mapped onto coarse subgridRun REL_CUTOFF scan at fixed CUTOFF; check CUTOFF / REL_CUTOFF ratio (should give grid spacing < orbital radius)Increase REL_CUTOFF to 60–100 Ry; re-run convergence; ratio CUTOFF/REL_CUTOFF > 8 is a warning sign
OT stalls on metallic systemRMS gradient plateaus above EPS_SCF; energy barely decreases; outer SCF does not convergeFractional occupations at Fermi level violate OT assumptions; OT requires a finite gapCheck if system is metallic (DOS at Fermi level from a prior GGA run); check if ENERGY_GAP is unrealisticSwitch to diagonalization + ADDED_MOS + SMEAR; use Fermi-Dirac smearing
SCF oscillation with diagonalizationEnergy oscillates ±0.1 eV between steps; Broyden mixing divergesMixing coefficient too large; strong charge sloshing in metallic or near-metallic systemPlot energy vs SCF iteration; check Broyden NBUFFER is adequateReduce ALPHA to 0.1–0.2; increase NBUFFER to 16; try PULAY_MIXING
Wrong Poisson solver for isolated systemTotal energy depends on cell size anomalously; electrostatic potential diverges; spurious image interactionsPERIODIC Poisson solver applied to a molecule, cluster, or charged slabCompare energy with two cell sizes; for isolated: energy should be cell-size-independent with MTUse PSOLVER MT for molecules and clusters; for charged slabs use PSOLVER WAVELET or add compensating charge
AIMD timestep too largeSimulation diverges after a few steps; total energy increases without bound; forces grow explosivelyBorn-Oppenheimer timestep exceeds stability limit for fastest vibrational modeCheck highest frequency from a prior phonon or normal mode analysis; for H-containing systems, OH stretch is ~3600 cm⁻¹ → period ~9.3 fsUse TIMESTEP ≤ 0.5 fs for H-containing systems; 1–2 fs for heavy-element systems without H
AIMD restart file mismatchRestart fails with basis set error or atom count mismatch; geometry jumps discontinuouslyRestart wavefunction from wrong run (different cell, basis, or atom count)Check PROJECT name and WFN_RESTART_FILE_NAME path; verify atom count matchesEnsure PROJECT names and basis sets match between original and restart run; use SCF_GUESS ATOMIC if wfn file is suspect
Treating CP2K energy as directly comparable to VASP/QEApparent formation energy errors of 0.1–1 eV; systematic energy offsets between codesDifferent pseudopotential definitions, core-electron count, and basis set incompleteness correctionCross-validate on a known compound (e.g., MgO) against VASP or QE; compare lattice constants and bulk modulusNever mix CP2K and VASP/QE energies in the same thermodynamic cycle without explicit cross-validation and energy alignment
ADMM HFX memory overflowCP2K crashes with out-of-memory error during hybrid calculationMAX_MEMORY in &HF/&MEMORY too small; 2-electron integrals exceed available RAMCheck available RAM per process; count MPI ranks; estimate memory as MAX_MEMORY * n_MPI_ranksIncrease MAX_MEMORY; reduce MPI processes per node; enable EPS_STORAGE_SCALING to discard small integrals

Best Practices

  • Always converge both CUTOFF and REL_CUTOFF for each new basis set family and element combination. A single CUTOFF scan at fixed REL_CUTOFF is insufficient — run both scans systematically using Workflow 2.
  • Match pseudopotential to XC functional exactly. GTH-PBE must be paired with PBE XC; GTH-BLYP with BLYP. Mismatches produce wrong energies without an error message.
  • Use MOLOPT-SR basis sets for periodic solids. The short-range (SR) variants have smaller basis set superposition error and better linear independence in condensed phases than the standard MOLOPT sets.
  • Always include OUTER_SCF when using OT. Without it, the OT loop converges the orbital gradient but not the total energy self-consistency; the resulting energy is not variational with respect to the density.
  • For AIMD, always enable RESTART printing with BACKUP_COPIES ≥ 3. AIMD restarts are fragile — a corrupt or missing restart file loses the entire trajectory. Multiple backup copies guard against filesystem failures.
  • Do not compare CP2K total energies to VASP or QE energies without cross-validation. Different pseudopotential core definitions and basis set incompleteness mean raw energies are not comparable across codes. Only energy differences within the same code and settings are meaningful.
  • For ML potential training data, use EPS_SCF 1E-6 minimum and tighten to 1E-7 if forces are noisy. Loose SCF convergence introduces force noise that corrupts ML training signals. Always enable STRESS_TENSOR ANALYTICAL in &FORCE_EVAL.
  • Enable dispersion correction (D3 or D4) for all condensed-phase and surface calculations. Bare PBE misses London dispersion. D3(BJ) is the standard choice for most systems; D4 improves on D3 for highly polarizable systems. [EXPERT REVIEW NEEDED: D3 vs D4 crossover for specific material classes]
  • For charged supercells or defects, use the Martyna-Tuckerman (MT) or WAVELET Poisson solver. The periodic PERIODIC solver wraps periodic images of charges and produces divergent or spurious electrostatics for charged systems.
  • Validate ADMM accuracy on a small test case before committing to production hybrid calculations. Compare ADMM and non-ADMM energies on a 10–20 atom cell; acceptable discrepancy is < 1 meV/atom.
  • Record the full CP2K version, BASIS_SET file checksums, and POTENTIAL file checksums for reproducibility. CP2K basis set files are updated between releases and can affect energies.

Integration with Other Skills

Moved to references/integration-with-other-skills.md to keep this file short; read it when this part is needed.

Key References

  1. Kühne, T. D., et al. (2020). CP2K: An electronic structure and molecular dynamics software package — Quickstep: Efficient and accurate electronic structure calculations. Journal of Chemical Physics, 152(19), 194103. https://doi.org/10.1063/5.0007045
  2. Lippert, G., Hutter, J., & Parrinello, M. (1997). A hybrid Gaussian and plane wave density functional scheme. Molecular Physics, 92(3), 477–487. https://doi.org/10.1080/002689797170220
  3. VandeVondele, J., & Hutter, J. (2007). Gaussian basis sets for accurate calculations on molecular systems in gas and condensed phases. Journal of Chemical Physics, 127(11), 114105. https://doi.org/10.1063/1.2770708
  4. Goedecker, S., Teter, M., & Hutter, J. (1996). Separable dual-space Gaussian pseudopotentials. Physical Review B, 54(3), 1703. https://doi.org/10.1103/PhysRevB.54.1703
  5. Guidon, M., Hutter, J., & VandeVondele, J. (2010). Auxiliary density matrix methods for Hartree-Fock exchange calculations. Journal of Chemical Theory and Computation, 6(8), 2348–2364. https://doi.org/10.1021/ct1002225
  6. Bussi, G., Donadio, D., & Parrinello, M. (2007). Canonical sampling through velocity rescaling. Journal of Chemical Physics, 126(1), 014101. https://doi.org/10.1063/1.2408420
  7. Grimme, S., Antony, J., Ehrlich, S., & Krieg, H. (2010). A consistent and accurate ab initio parametrization of density functional dispersion correction (DFT-D) for the 94 elements H–Pu. Journal of Chemical Physics, 132(15), 154104. https://doi.org/10.1063/1.3382344

示例提示词

我想用CP2K搭建一套从输入文件到AIMD的完整计算流程。

所属插件

计算材料学:第一性原理与原子模拟面向计算材料研究:DFT 与第一性原理(VASP、Quantum ESPRESSO、CP2K、AiiDA)、缺陷/表面/声子/弹性常数、机器学习势函数训练与验证、分子动力学与增强采样、晶体性质图神经网络与生成模型。

安装该插件会一并获得同领域的 35 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

CP2K第一性原理分子动力学能做什么?

Covers end-to-end DFT, AIMD, and atomistic workflows with CP2K using the Gaussian-and-plane-waves method: input construction, convergence testing. Use for CP2K-based simulations。

如何安装CP2K第一性原理分子动力学?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「CP2K第一性原理分子动力学」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

CP2K第一性原理分子动力学需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

CP2K第一性原理分子动力学经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。