Skip to content

refactor(input): declare dfpt mixing parameter domains (set_choices / set_rule) - #8251

Merged
mohanchen merged 5 commits into
deepmodeling:developfrom
Zanthoxylum:dfpt-input-domain
Nov 1, 2026
Merged

mohanchen merged 5 commits into
deepmodeling:developfrom
Zanthoxylum:dfpt-input-domain

Conversation

@Zanthoxylum

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to PR #8214 review finding A10: declare the DFPT mixing INPUT parameter domains with the declarative set_choices / set_rule system instead of hand-written check_value lambdas, so the constraints appear in the generated help and rejection routes through the shared input-error path.

What's changed?

  • dfpt_mix_type: domain.set_choices({"rho_plain", "rho_kerker", "rho_broyden", "v_sc_plain", "v_sc_broyden"}) — replaces the 5-way string comparison in check_value
  • dfpt_kerker_a2: domain.set_rule("value>0") — replaces the positive check
  • dfpt_broyden_ndim: domain.set_rule("value>=1") — replaces the ≥1 check

No behavior change; the same invalid values are rejected with the same error path.

Unit Tests and/or Case Tests for my changes

  • DFPT serial suite 9/9
  • INPUT domain/reader/help tests all pass (MODULE_IO_input_domain, MODULE_IO_input_domain_reader, MODULE_IO_read_input_serial, MODULE_IO_read_input_tool, MODULE_IO_input_help_test)

…et_rule)

Follow-up to PR deepmodeling#8214 review finding A10: replace the hand-written
check_value lambdas with the declarative domain system so the
constraints appear in the generated help and rejection routes through
the shared input-error path.

- dfpt_mix_type: domain.set_choices({rho_plain, rho_kerker,
  rho_broyden, v_sc_plain, v_sc_broyden})
- dfpt_kerker_a2: domain.set_rule("value>0")
- dfpt_broyden_ndim: domain.set_rule("value>=1")

No behavior change; DFPT serial 9/9, INPUT domain/reader/help tests
all pass. MODULE_IO_input_test_para fails identically on the develop
baseline (pre-existing MPI environment issue).
@Zanthoxylum Zanthoxylum added Refactor Refactor ABACUS codes DFPT Density Functional Perturbation Theory labels Oct 30, 2026

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review at 93179c0: the five choices, numeric bounds and omitted defaults are preserved. One nonblocking note covers the explicit-empty input contract and focused reader/help coverage. No build or test was run.

…add reader tests

The scalar choices domain now rejects an explicitly empty dfpt_mix_type
before read_value runs, so the legacy get_size()==0 fallback (which
silently mapped an empty value onto v_sc_broyden) was unreachable.
Replace the hand-written read_value with read_sync_string and record the
contract in a comment: omitted line keeps the default, an explicit empty
or unknown value is rejected.

Add reader tests for the three registrations: all five dfpt_mix_type
choices plus empty/unknown/multi-token rejection, dfpt_kerker_a2 with
the a^2=0 boundary under value>0, and dfpt_broyden_ndim with the
ndim=0 boundary under value>=1. Each rejection also checks that
read_value is not reached (previous value survives) and the doc anchor.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new implementation defect found at 6ef7199. fd271f168 resolves the explicit-empty contract concern and adds the requested rejection cases.

Static source review covered the PR and affected interfaces at develop 75e2a62. The author-reported 3/3 tests and CLI checks were not independently rerun; merged-build verification remains unperformed.

@mohanchen
mohanchen merged commit d20090c into deepmodeling:develop Nov 1, 2026
18 checks passed
@Zanthoxylum
Zanthoxylum deleted the dfpt-input-domain branch November 1, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DFPT Density Functional Perturbation Theory Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants