[CP2K 8.1 CDFT] Exact nonperturbative Becke/Hirshfeld weight export without entering outer SCF

21 views
Skip to first unread message

Dayu Zhu

unread,
Jul 24, 2026, 3:25:21 AMJul 24
to cp...@googlegroups.com
# CP2K 8.1 support request: exact nonperturbative Becke/Hirshfeld CDFT weight-grid export

## Build identity

- CP2K version: `8.1`
- Executable revision: `git:0b61f2f`
- Container release-source HEAD: `0bfbd41a7402152da7b86a103d5d95a4184367d9`
- Release tag: `v8.1.0`
- Wrapper SHA256: `c786e567853dbe8fafb35a91ec25ba1ca8f5ea5c02d30f5cdf056719ce9bc2d1`
- Input XML SHA256: `728c139a1d87554490e67f0ab30f1f5c78f944dad5e87671894e1aa833f281f4`
- Container executable: `/cp2k/exe/local/cp2k.psmp`
- Container source root: `/cp2k/src`

The wrapper/account path is intentionally omitted. The hashes above and the
attached sanitized identity CSV are sufficient to identify the inspected
build without exposing an HPC account path.

## Narrow technical need

We need exact CP2K 8.1 Becke and Hirshfeld weight grids for offline integration
of local magnetization from already-converged, unconstrained spin-density
cubes. We want to preserve the original density and avoid running CDFT or an
electronic SCF merely to obtain the geometric/partition weight grid.

This request concerns method semantics and a minimal diagnostic interface
only. It does not claim that stock CP2K is wrong, and it does not request
scientific interpretation of any material.

## Distinctions used in this request

- **Exact weight construction:** running the original CP2K 8.1 Becke or
  Hirshfeld builder with fixed geometry, cell/PBC, grid, atom group, COEFF,
  atom-kind, and partition parameters.
- **Exact weight printing:** writing that already-constructed CP2K PW grid
  through the original `cdft_print_weight_function`/cube-writer path.
- **Nonperturbative measurement:** obtaining the weight without changing or
  reoptimizing the electronic density.
- **CDFT outer-SCF perturbation:** adding `weight * STRENGTH` to the
  Kohn-Sham potential and updating the electronic state/multiplier.

## Exact source references inspected

| Routine | CP2K 8.1 source lines |
|---|---|
| `read_constraint_definitions` | `qs_cdft_utils.F:534-717` |
| `becke_constraint_init` | `qs_cdft_utils.F:100-449` |
| `becke_constraint_low` | `qs_cdft_methods.F:142-581` |
| `hirshfeld_constraint_init` | `qs_cdft_utils.F:966-1086` |
| `create_shape_function` | `hirshfeld_methods.F:141-224` |
| `hirshfeld_constraint_low` | `qs_cdft_methods.F:1153-1365` |
| `qs_ks_cdft_constraint` | `qs_ks_apply_restraints.F:62-128` |
| `cdft_constraint_integrate` | `qs_cdft_methods.F:772-954` |
| `cdft_constraint_print` | `qs_cdft_utils.F:1095-1249` |
| `cdft_print_weight_function` | `qs_cdft_utils.F:1257-1301` |
| `qs_ks_build_kohn_sham_matrix` | `qs_ks_methods.F:207-899` |
| `sum_up_and_integrate` | `qs_ks_utils.F:1195-1625` |
| `cdft_scf` | `qs_scf.F:934-1144` |
| `outer_loop_gradient` | `qs_outer_scf.F:102-174` |
| `outer_loop_update_qs_env` | `qs_outer_scf.F:386-430` |
| `cdft_control_release` | `qs_cdft_types.F:419-493` |

`cdft_print_hirshfeld_density` is not present in the exact `/cp2k/src` tree;
both weight types use the common `cdft_print_weight_function` route.

Our revision-pinned source audit indicates that the low-level Becke/Hirshfeld
builders construct weights before `cdft_constraint_integrate` reads the
current density. The stock weight print is reached only after `cdft_scf`
outer-loop initialization, although the print call precedes the first
constraint-potential addition in that Kohn-Sham build. We request confirmation
of the supported semantics and interface rather than asserting undocumented
API guarantees.

## Questions

1. For CP2K 8.1, is there a supported stock-input route to initialize and
   print exact Becke/Hirshfeld CDFT weight grids without entering the CDFT
   outer-SCF loop?

2. For fixed geometry, real-space grid, atom group, COEFF, atom-kind, and
   partition parameters, are the Becke/Hirshfeld weight grids completely
   independent of the current electron density, current spin density, TARGET,
   STRENGTH, and current Lagrange multiplier?

3. Does `PROGRAM_RUN_INFO/WEIGHT_FUNCTION` print exactly the same weight grid
   regardless of the constrained electronic solution, even though the print
   call occurs after outer-loop initialization?

4. Is there an officially recommended internal routine or minimal driver for
   invoking the original CP2K 8.1 Becke/Hirshfeld weight builders and cube
   writer without running CDFT or electronic SCF?

5. Would a minimal source hook that constructs the weight, writes it, and
   exits before `cdft_constraint_integrate`, constraint-potential building,
   electronic SCF, or CDFT outer-SCF optimization be considered semantically
   exact?

6. For Hirshfeld CDFT in CP2K 8.1, what implementation limitations affect
   ENERGY-only local-magnetization integration, weight printing, forces,
   geometry optimization, and MD?

7. Can multiple `ATOM_GROUP` weight grids, for example R0/R1/R2 and a separate
   HSO4 monitoring region, be generated in one invocation without activating
   coupled constraints?

8. What metadata must be preserved to guarantee exact offline integration of
   `integral w(r)[rho_alpha(r)-rho_beta(r)] dr` against existing spin-density
   cubes, including grid origin, axes, stride, cell/PBC, atom order/kinds,
   partition settings, group/COEFF mapping, and numeric print precision?

## Candidate minimal interface for review

After normal input, subsystem, `qs_env`, MGRID, and PW-pool initialization:

1. allocate one weight PW grid per group using the stock lifetime pattern;
2. call the original Becke or Hirshfeld `init` and low-level builder;
3. call the original common weight cube writer;
4. hash/write provenance metadata;
5. release all temporary grids; and
6. exit before density integration, Kohn-Sham potential construction,
   electronic SCF, or outer-SCF optimization.

No patch, build, input, or calculation is included with this request.

## Lightweight attachments

- `CP2K81_CDFT_weight_evaluator_support_request.md`
- `CP2K81_CDFT_weight_evaluator_minimal_context.txt`
- `CP2K81_exact_source_identity_for_support.csv`
- `CP2K81_CDFT_weight_call_graph_compact.csv`
- `CP2K81_weight_function_dependency_matrix.csv`
- `CP2K81_weight_print_timing_audit.csv`
- `CP2K81_exact_weight_extraction_options.csv`
- `CP2K81_exact_weight_source_excerpts_compact.txt`

No coordinates, WFN, trajectory, cube, binary, full source tree, proprietary
data, or unrelated project details are attached.

CP2K81_weight_evaluator_support_package.tar.gz

Dayu Zhu

unread,
Jul 30, 2026, 12:06:14 AMJul 30
to cp...@googlegroups.com
Dear CP2K developers and users,

I am following up with a much shorter version of my question.

For a fixed geometry, grid, and ATOM_GROUP definition, I need to export the exact CP2K Becke or Hirshfeld CDFT weight function without perturbing an already-converged electronic density.

Could you please clarify:

1. Is there a stock CP2K input option, in version 8.1 or a newer release, that prints the weight-function grid without running the CDFT outer SCF?

2. If not, would it be methodologically valid to add a minimal diagnostic hook that calls the existing CP2K weight builder and cube writer, and then exits before density integration, Kohn–Sham construction, constraint-potential application, and CDFT outer-SCF optimization?

A brief yes/no answer or a pointer to the relevant routine, example, or newer implementation would be very helpful.

The longer message below contains the source-level details, but no detailed review of those attachments is necessary to answer these two questions.

Thank you very much for your time.

Best regards,
Dayu Zhu

Thomas Kühne

unread,
Aug 2, 2026, 12:03:15 PM (11 days ago) Aug 2
to cp...@googlegroups.com
Dear Dayu,

Am 30.07.2026 um 04:37 schrieb 'Dayu Zhu' via cp2k <cp...@googlegroups.com>:

Dear CP2K developers and users,

I am following up with a much shorter version of my question.

For a fixed geometry, grid, and ATOM_GROUP definition, I need to export the exact CP2K Becke or Hirshfeld CDFT weight function without perturbing an already-converged electronic density.

Could you please clarify:

1. Is there a stock CP2K input option, in version 8.1 or a newer release, that prints the weight-function grid without running the CDFT outer SCF?
  1. No. CP2K 8.1, as well as the current version, provides CDFT%PROGRAM_RUN_INFO%WEIGHT_FUNCTION, but this print key is only reached from an active CDFT calculation. There is currently no stock builder-only or print-only input mode that avoids the electronic/CDFT SCF path

2. If not, would it be methodologically valid to add a minimal diagnostic hook that calls the existing CP2K weight builder and cube writer, and then exits before density integration, Kohn–Sham construction, constraint-potential application, and CDFT outer-SCF optimization?
  1. Yes. For fixed geometry, cell, grid, atomic kinds and ATOM_GROUP definitions, the Becke and Hirshfeld weight functions are independent of the current molecular electron density. For SHAPE_FUNCTION DENSITY, the Hirshfeld builder uses isolated-atom reference densities rather than the converged molecular density

A brief yes/no answer or a pointer to the relevant routine, example, or newer implementation would be very helpful.

The longer message below contains the source-level details, but no detailed review of those attachments is necessary to answer these two questions.

A clean diagnostic implementation could initialize the normal QS/PW grid environment, allocate the group weight grids as done in qs_ks_cdft_constraint, call the existing constraint-specific initialization and low-level builder, write the grids with cdft_print_weight_function, and then return through normal cleanup before scf_env_do_scf. In CP2K 8.1 the low-level builders and cube writer are private, so a small public wrapper or refactoring would be required.

For an unsubsampled grid, STRIDE 1 1 1 should be used. Please also note that the standard cube format is text-formatted and therefore does not preserve the full internal double precision.

Best regards, 

Thomas Kühne

-- 
You received this message because you are subscribed to the Google Groups "cp2k" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cp2k+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cp2k/CAJ1za7wZVwZXNb_h4Ty2z49-AhxGu-xBxv%3Dzfp32oH%2BWz0N-eQ%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages