From 3c0d8361f27841fd9e186952ce05da77c0df75e2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:19:34 +0000 Subject: [PATCH 1/6] Initial plan From 481698d35efb3b912c774eab69c97160c98e11d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:27:37 +0000 Subject: [PATCH 2/6] Add comprehensive pwmat argument documentation and structure Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- dpgen/generator/arginfo.py | 59 +++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/dpgen/generator/arginfo.py b/dpgen/generator/arginfo.py index 2e31a1f85..87610da69 100644 --- a/dpgen/generator/arginfo.py +++ b/dpgen/generator/arginfo.py @@ -923,6 +923,58 @@ 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." + + 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), + Argument("flag_symm", [int, str], optional=True, doc=doc_flag_symm), + Argument("user_pwmat_params", dict, optional=True, doc=doc_user_pwmat_params), + ] + 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, args, [], optional=True, doc=doc_fp_params), + Argument("user_fp_params", dict, optional=True, doc=doc_user_fp_params), + ] + + def fp_style_variant_type_args() -> Variant: doc_fp_style = "Software for First Principles." doc_amber_diff = ( @@ -932,6 +984,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. " @@ -949,7 +1006,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), ], From ffa5f22a39f72b332d3d26a96f1e551f2815b61c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:50:46 +0000 Subject: [PATCH 3/6] Add pwmat parameter file to test_check_examples.py Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- tests/test_check_examples.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_check_examples.py b/tests/test_check_examples.py index 3033740f2..3bcbb4bd7 100644 --- a/tests/test_check_examples.py +++ b/tests/test_check_examples.py @@ -163,6 +163,8 @@ / "param_C4H16N4_deepmd-kit-2.0.1.json", ), (run_jdata, p_examples / "run" / "dprc" / "generator.json"), + # pwmat test file from tests/generator + (run_jdata, Path(__file__).parent / "generator" / "param-pyridine-pwmat.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"), From 64e17f52edf79ca231a4f0c9be66cd1f447cc51e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:01:59 +0000 Subject: [PATCH 4/6] Use p_examples path for pwmat test file instead of direct path Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- tests/test_check_examples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_check_examples.py b/tests/test_check_examples.py index 3bcbb4bd7..38d5f40f7 100644 --- a/tests/test_check_examples.py +++ b/tests/test_check_examples.py @@ -163,8 +163,8 @@ / "param_C4H16N4_deepmd-kit-2.0.1.json", ), (run_jdata, p_examples / "run" / "dprc" / "generator.json"), - # pwmat test file from tests/generator - (run_jdata, Path(__file__).parent / "generator" / "param-pyridine-pwmat.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"), From c9ace727cf0dc178b89c15868223644ecf469bda Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:04:11 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_check_examples.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_check_examples.py b/tests/test_check_examples.py index 38d5f40f7..0585cf077 100644 --- a/tests/test_check_examples.py +++ b/tests/test_check_examples.py @@ -164,7 +164,10 @@ ), (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"), + ( + 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"), From e4a3bbcb111a2a2fcdae489e411401b0983f30fc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 23 Aug 2025 02:42:31 +0000 Subject: [PATCH 6/6] Fix pwmat argument structure based on code analysis and review comments - Make flag_symm required for user_fp_params (accessed directly in run.py:3037) - Remove icmix, smearing, sigma from user_fp_params (not used in that code path) - Keep icmix, smearing, sigma in fp_params (used via make_pwmat_input_user_dict) - Add proper argument definitions for user_fp_params parameter structure - Add comments explaining the different behavior between fp_params and user_fp_params paths Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- dpgen/generator/arginfo.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/dpgen/generator/arginfo.py b/dpgen/generator/arginfo.py index 87610da69..0eeff4471 100644 --- a/dpgen/generator/arginfo.py +++ b/dpgen/generator/arginfo.py @@ -952,7 +952,8 @@ def fp_style_pwmat_args() -> list[Argument]: 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." - args = [ + # 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), @@ -966,12 +967,27 @@ def fp_style_pwmat_args() -> list[Argument]: Argument("flag_symm", [int, str], optional=True, doc=doc_flag_symm), 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, args, [], optional=True, doc=doc_fp_params), - Argument("user_fp_params", dict, optional=True, doc=doc_user_fp_params), + 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), ]