Skip to content

feat(band): auto-configure DOS file retrieval list based on basis_type - #55

Merged
zhubonan merged 6 commits into
MCresearch:developfrom
stillfast:feat/auto-dos-file-retrieval
Jun 19, 2026
Merged

zhubonan merged 6 commits into
MCresearch:developfrom
stillfast:feat/auto-dos-file-retrieval

Conversation

@stillfast

Copy link
Copy Markdown
Contributor
  • Auto-set out_dos parameter (1 for pw, 2 for lcao)
  • Add DOS1_smearing.dat and PDOS to additional_retrieve_list
  • PDOS is only retrieved when basis_type is lcao (out_dos=2)
  • DOS1_smearing.dat is always retrieved

liguozhou added 2 commits May 28, 2026 03:02
- Auto-set out_dos parameter (1 for pw, 2 for lcao)
- Add DOS1_smearing.dat and PDOS to additional_retrieve_list
- PDOS is only retrieved when basis_type is lcao (out_dos=2)
- DOS1_smearing.dat is always retrieved
…rieval

- Add DosParser class to parse DOS1/DOS2 smearing files
- Add DOS parsing logic in AbacusParser with include_dos flag
- Add "dos" output port (ArrayData) to AbacusCalculation
- Add include_dos flag to SettingsOptions
- Update band workflow to use nspin-based DOS file retrieval
@stillfast

Copy link
Copy Markdown
Contributor Author

This PR adds DOS (Density of States) output support for ABACUS calculations, including a new parser, output port, and automatic file retrieval configuration in the band workchain.

Changes

1. calculations.py

  • Added a new dos output port of type orm.ArrayData to AbacusCalculation for exposing DOS data. The port is optional (required=False) and only populated when DOS output files are present.

2. common/opthold.py

  • Added include_dos boolean field (default False) to SettingsOptions, consistent with existing flags like include_bands. This controls whether the parser processes DOS output. It is set to True in the band workflow.

3. parsers/raw_parsers.py

  • Added DosParser class that parses DOS1_smearing.dat and DOS2_smearing.dat files.
  • Supports spin-polarized calculations: when both dos1 and dos2 are present, tdos = dos1 + dos2; when only one exists, tdos copies that array; when neither exists, tdos is None.
  • Returns a dict with keys: energy, tdos, dos1, dos2.

4. parsers/abacus.py

  • Imported DosParser.
  • Added "dos": False to default output settings.
  • Added DOS parsing logic: when include_dos is True, reads DOS1_smearing.dat and DOS2_smearing.dat from the OUT.<suffix>/ directory, invokes DosParser, and stores the result in an orm.ArrayData output node. Logs a warning if neither file is found.

5. workflows/band.py

  • Refactored DOS file retrieval logic in the band workchain:
    • Replaced the basis_type-based branching (lcao/pw) with a generic nspin-aware approach.
    • Automatically determines the file list based on nspin (default 1): retrieves DOS1_smearing.dat for non-spin-polarized, and both DOS1_smearing.dat and DOS2_smearing.dat for spin-polarized calculations.
    • Only sets out_dos = 1 when the user hasn't explicitly provided it.
  • Sets include_dos = True for DOS calculations so the parser picks up the output.
  • Ensures settings is initialized as a dict before use.

I have succeed in dos calculation in both cases of nspin = 1 and nspin =2. You can check my results by downloading my file.
dos_parser.zip

liguozhou added 3 commits May 31, 2026 00:53
- Define 'dos' output port (ArrayData) in spec
- Output DOS data from the DOS sub-workchain when it finishes successfully
Use inputs.abacus.get('settings') to safely handle all three cases:
1. settings already a dict (bands section was run first)
2. settings still an orm.Dict (bands not run, but user provided settings)
3. settings not present at all (bands not run, user didn't provide settings)

Remove redundant type-checking code that was no longer needed.
Use a single expression to handle all three cases: dict, orm.Dict, and None.
@zhubonan

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 895b98ec49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/aiida_abacus/workflows/band.py Outdated
help="Primitive structure for which the band structure is calculated for.",
)
spec.output("seekpath_parameters", valid_type=orm.Dict, help="Parameters used for the kpath generation.")
spec.output("dos", valid_type=orm.ArrayData, help="Output density of states data.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Mark DOS output optional for band-only workflows

AiiDA output ports default to required=True, but the default band settings leave run_dos disabled, so run_bands_dos does not submit a DOS workchain and verify_bands_dos never emits dos. Default band-structure workflows will therefore finish with AiiDA's missing-required-output error even though DOS was not requested; please make this output optional or only require it when run_dos is enabled.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right. I will change the code as your advice.

Allow the DOS output to be optional since it may not be generated
when certain calculation parameters are used.
@stillfast

Copy link
Copy Markdown
Contributor Author

@zhubonan Would you please check this PR?

@zhubonan zhubonan 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.

LGTM

@zhubonan
zhubonan merged commit 70bd153 into MCresearch:develop Jun 19, 2026
3 checks passed
@zhubonan

Copy link
Copy Markdown
Collaborator

Merged, thanks!

@stillfast
stillfast deleted the feat/auto-dos-file-retrieval branch June 19, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants