Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion dpgen/generator/arginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,74 @@ def fp_style_custom_args() -> list[Argument]:
]


# pwmat
def fp_style_pwmat_args() -> list[Argument]:
"""Arguments for FP style pwmat.

Returns
-------
list[dargs.Argument]
list of pwmat fp style arguments
"""
doc_fp_pp_path = "Directory of psuedo-potential file to be used for 02.fp exists."
doc_fp_pp_files = "Psuedo-potential file to be used for 02.fp. Note that the order of elements should correspond to the order in type_map."
doc_fp_incar = "Path to the pwmat input file template (etot.input). If provided, this file will be used directly instead of generating from fp_params or user_fp_params."
doc_user_fp_params = "Parameters for pwmat calculation. When user_fp_params is set, the settings in fp_params will be ignored. This allows direct specification of all pwmat input parameters."
doc_fp_params = (
"Parameters for pwmat calculation. It has lower priority than user_fp_params."
)
doc_node1 = "node1 in pwmat (number of MPI processes for the first direction)."
doc_node2 = "node2 in pwmat (number of MPI processes for the second direction)."
doc_in_atom = "Path to atom configuration file (in.atom) for pwmat."
doc_ecut = "Energy cutoff (ecut) in pwmat."
doc_e_error = "Energy convergence criterion (e_error) in pwmat."
doc_rho_error = "Density convergence criterion (rho_error) in pwmat."
doc_kspacing = "The spacing between kpoints. Helps to determine KPOINTS in pwmat."
doc_icmix = "Mixing method parameter (icmix) in pwmat for SCF iteration."
doc_smearing = "Smearing method for electronic states in pwmat."
doc_sigma = "Smearing width parameter (sigma) in pwmat."
doc_flag_symm = "Symmetry flag (flag_symm) in pwmat. Can be 0, 1, 2, or 3."
doc_user_pwmat_params = "Additional user-defined pwmat parameters that will override the generated input."

# Arguments for fp_params (used via make_pwmat_input_user_dict)
fp_params_args = [
Argument("node1", int, optional=False, doc=doc_node1),
Argument("node2", int, optional=False, doc=doc_node2),
Argument("in.atom", str, optional=False, doc=doc_in_atom),
Argument("ecut", float, optional=False, doc=doc_ecut),
Argument("e_error", float, optional=False, doc=doc_e_error),
Argument("rho_error", float, optional=False, doc=doc_rho_error),
Argument("kspacing", float, optional=False, doc=doc_kspacing),
Argument("icmix", float, optional=True, doc=doc_icmix),
Argument("smearing", int, optional=True, doc=doc_smearing),
Argument("sigma", float, optional=True, doc=doc_sigma),
Comment on lines +964 to +966
Copy link
Member

Choose a reason for hiding this comment

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

@copilot I don't think these are used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct! Removed icmix, smearing, and sigma from user_fp_params structure since they're hardcoded as None in the user_fp_params code path (lines 3057-3059). They remain in fp_params structure since they are used via _make_smearing(). Commit: e4a3bbc

Argument("flag_symm", [int, str], optional=True, doc=doc_flag_symm),
Copy link
Member

Choose a reason for hiding this comment

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

@copilot It seems it cannot be optional:

flag_symm = fp_params["flag_symm"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed! Made flag_symm required for user_fp_params since it's accessed directly without checking at line 3037. The fp_params path still has it as optional since it goes through _make_flag_symm() which handles optional parameters. Commit: e4a3bbc

Argument("user_pwmat_params", dict, optional=True, doc=doc_user_pwmat_params),
]

# Arguments for user_fp_params (used directly in make_pwmat_input)
# Note: icmix, smearing, sigma are not used in user_fp_params path (hardcoded as None)
# flag_symm is required because it's accessed directly without checking
user_fp_params_args = [
Argument("node1", int, optional=False, doc=doc_node1),
Argument("node2", int, optional=False, doc=doc_node2),
Argument("in.atom", str, optional=False, doc=doc_in_atom),
Argument("ecut", float, optional=False, doc=doc_ecut),
Argument("e_error", float, optional=False, doc=doc_e_error),
Argument("rho_error", float, optional=False, doc=doc_rho_error),
Argument("kspacing", float, optional=False, doc=doc_kspacing),
Argument("flag_symm", [int, str], optional=False, doc=doc_flag_symm),
]

return [
Argument("fp_pp_path", str, optional=False, doc=doc_fp_pp_path),
Argument("fp_pp_files", list[str], optional=False, doc=doc_fp_pp_files),
Argument("fp_incar", str, optional=True, doc=doc_fp_incar),
Argument("fp_params", dict, fp_params_args, [], optional=True, doc=doc_fp_params),
Argument("user_fp_params", dict, user_fp_params_args, [], optional=True, doc=doc_user_fp_params),
]


def fp_style_variant_type_args() -> Variant:
doc_fp_style = "Software for First Principles."
doc_amber_diff = (
Expand All @@ -932,6 +1000,11 @@ def fp_style_variant_type_args() -> Variant:
"The command argument in the machine file should be path to sander. "
"One should also install dpamber and make it visible in the PATH."
)
doc_pwmat = (
"PWmat is an ab initio calculation software for density functional theory. "
"It supports various calculation types including SCF calculations with k-point meshes. "
"The command argument in the machine file should be the path to PWmat executable."
)
doc_custom = (
"Custom FP code. You need to provide the input and output file format and name. "
"The command argument in the machine file should be the script to run custom FP codes. "
Expand All @@ -949,7 +1022,7 @@ def fp_style_variant_type_args() -> Variant:
Argument(
"amber/diff", dict, fp_style_amber_diff_args(), doc=doc_amber_diff
),
Argument("pwmat", dict, [], doc="TODO: add doc"),
Argument("pwmat", dict, fp_style_pwmat_args(), doc=doc_pwmat),
Argument("pwscf", dict, fp_style_pwscf_args()),
Argument("custom", dict, fp_style_custom_args(), doc=doc_custom),
],
Expand Down
5 changes: 5 additions & 0 deletions tests/test_check_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@
/ "param_C4H16N4_deepmd-kit-2.0.1.json",
),
(run_jdata, p_examples / "run" / "dprc" / "generator.json"),
# pwmat test file from examples
(
run_jdata,
p_examples / "run" / "deprecated" / "dp2.x-lammps-pwmat" / "param_CH4.json",
),
# machines
(run_mdata, p_examples / "machine" / "DeePMD-kit-2.x" / "lebesgue_v2_machine.json"),
(run_mdata, p_examples / "machine" / "DeePMD-kit-1.x" / "machine-local.json"),
Expand Down