From e872456114af81c39d1be62c0e51d44f8e48d59b Mon Sep 17 00:00:00 2001 From: Stardust0831 <169599847+Stardust0831@users.noreply.github.com> Date: Wed, 5 Aug 2026 19:54:11 +0800 Subject: [PATCH 1/2] Tools: add structured parser for INPUT availability strings The Input_Item availability field mixes prose and ad-hoc conditions as free text, which cannot be consumed programmatically for tree-structured docs, validation or agent tooling. Add a small dependency-free parser (tools/03_code_analysis/availability_parser.py) that normalises the historical spellings (==, =, 'is set to', 'contains') onto a canonical form and classifies each value as an Expression, a bare Label, or Unstructured prose waiting for review. - availability_parser.py: parse_availability() -> Availability - test_availability_parser.py: unit tests - generate_input_main.py: add --check-availability to report the Expression/Label/Unstructured distribution without changing the generated markdown. On the current docs/parameters.yaml this classifies 217 non-empty values as 82 Expression / 84 Label / 51 Unstructured. --- docs/generate_input_main.py | 59 ++++- tools/03_code_analysis/availability_parser.py | 230 ++++++++++++++++++ .../test_availability_parser.py | 89 +++++++ 3 files changed, 376 insertions(+), 2 deletions(-) create mode 100644 tools/03_code_analysis/availability_parser.py create mode 100644 tools/03_code_analysis/test_availability_parser.py diff --git a/docs/generate_input_main.py b/docs/generate_input_main.py index 16a9e398bb..d0b7e2258c 100644 --- a/docs/generate_input_main.py +++ b/docs/generate_input_main.py @@ -232,9 +232,55 @@ def generate_toc(sorted_categories: OrderedDict) -> str: return '\n'.join(lines) -def generate(yaml_path: Path, output: Path, verbose: bool = False): +def _report_availability(all_params): + """Classify every non-empty availability string and summarise the result. + + Uses tools/03_code_analysis/availability_parser.py. This is a status + report only; it does not modify the generated documentation. + """ + try: + sys.path.insert(0, str(DOC_FOLDER.parent / 'tools' / '03_code_analysis')) + from availability_parser import parse_availability + except ImportError: + print("[availability] parser not found; skipping availability check") + return + + counts = {"Expression": 0, "Label": 0, "Unstructured": 0} + unstructured = [] + labelled = 0 + for p in all_params: + avail = p.get('availability', '') + if not avail: + continue + parsed = parse_availability(avail) + if parsed.kind in counts: + counts[parsed.kind] += 1 + if parsed.kind == "Unstructured": + unstructured.append((p.get('name', '?'), avail)) + elif parsed.kind == "Label": + labelled += 1 + + print("[availability] non-empty:", sum(counts.values()), + " Expression:", counts["Expression"], + " Label:", counts["Label"], + " Unstructured:", counts["Unstructured"]) + if unstructured: + print("[availability] parameters with unstructured availability" + " waiting for review (%d):" % len(unstructured)) + for name, text in unstructured: + print(f" {name}: {text}") + + +def generate(yaml_path: Path, output: Path, verbose: bool = False, + check_availability: bool = False): """ Core generation logic. Can be called from conf.py or CLI. + + When ``check_availability`` is True, additionally report how many INPUT + ``availability`` strings are machine-parsable conditions, applicability + labels, or unstructured prose waiting for review (see + tools/03_code_analysis/availability_parser.py). It does not alter the + generated markdown. """ yaml_path = Path(yaml_path) output = Path(output) @@ -248,6 +294,9 @@ def generate(yaml_path: Path, output: Path, verbose: bool = False): all_params = data.get('parameters', []) print(f"Total: {len(all_params)} documented parameters") + if check_availability: + _report_availability(all_params) + # Group by category by_category: Dict[str, List[Dict[str, str]]] = OrderedDict() for param in all_params: @@ -313,9 +362,15 @@ def main(): action='store_true', help='Print verbose output' ) + parser.add_argument( + '--check-availability', + action='store_true', + help='Report how many INPUT availability strings are parseable ' + 'conditions vs. labels vs. unstructured text (no doc changes)' + ) args = parser.parse_args() - generate(args.yaml_file, args.output, args.verbose) + generate(args.yaml_file, args.output, args.verbose, args.check_availability) if __name__ == '__main__': diff --git a/tools/03_code_analysis/availability_parser.py b/tools/03_code_analysis/availability_parser.py new file mode 100644 index 0000000000..6609ef3779 --- /dev/null +++ b/tools/03_code_analysis/availability_parser.py @@ -0,0 +1,230 @@ +#!/usr/bin/env python3 +"""Structured parser for ABACUS INPUT parameter ``availability`` values. + +The ``availability`` field of an ``Input_Item`` states under which condition a +parameter is applicable. Historically this field is free text mixing prose and +ad-hoc conditions. This module provides a small, dependency-free parser that +turns such strings into a lightweight structured form so that documentation, +validation and tooling can consume the actual condition. + +Kinds of parsed results (see :class:`Availability`): + +* ``Expression`` -- a machine-readable condition such as ``basis_type==pw`` + or ``calculation==nscf``, optionally combined with ``and``/``or``/``,``. +* ``Label`` -- a bare applicability tag such as ``Numerical atomic orbital + basis`` or ``TDOFDFT`` (no boolean operators). +* ``Unstructured`` -- free text that cannot be reliably structured without + human review (kept verbatim). + +The parser is deliberately tolerant: it normalises the several historical +spellings (``=`` vs ``==``, ``is set to``, ``is``, ``contains``) onto a single +canonical form so that rules can be compared and documented consistently. +""" + +from __future__ import annotations + +import re + +# --------------------------------------------------------------------------- +# Result model +# --------------------------------------------------------------------------- + + +class Condition: + """A single condition ``param op values``.""" + + __slots__ = ("param", "op", "values") + + def __init__(self, param, op, values): + self.param = param # str, validated parameter name + self.op = op # one of "==", "in" + self.values = values # list[str], canonical values + + def __repr__(self): + vals = ", ".join(self.values) + return f"Condition({self.param!r}, {self.op!r}, [{vals}])" + + +class Availability: + """Parsed availability value.""" + + __slots__ = ("kind", "expr", "label", "text") + + def __init__(self, kind, expr=None, label=None, text=None): + self.kind = kind # "Expression" | "Label" | "Unstructured" + self.expr = expr # Expression tree (see below) for Expression + self.label = label # str for Label + self.text = text # original text always kept + + def __repr__(self): + return f"Availability({self.kind!r}, text={self.text!r})" + + +class Expr: + """A boolean expression tree node: ('and'|'or', [children]) or leaf Condition.""" + + __slots__ = ("op", "children") + + def __init__(self, op, children): + self.op = op # 'and' | 'or' | None (leaf->single Condition) + self.children = children # list[Expr] when composite, or [Condition] + + def __repr__(self): + return f"Expr({self.op!r}, {self.children!r})" + + +# --------------------------------------------------------------------------- +# Normalisation helpers +# --------------------------------------------------------------------------- + +# Known boolean-ish / keyword markers that turn prose into operators. +_IS_SETTO = re.compile(r"is set to", re.IGNORECASE) +_IS_EQ = re.compile(r"\bis\b", re.IGNORECASE) +_CONTAINS = re.compile(r"\bcontains\b", re.IGNORECASE) +_IN = re.compile(r"\bin\b", re.IGNORECASE) + +_PARAM_LIKE = re.compile(r"^[a-z][a-z0-9_]*$") + + +def _canonical_value(v): + """Strip trailing punctuation / quotes and lowercase booleans.""" + v = v.strip().strip('"').strip("'").rstrip('.').strip() + if v.lower() in ("true", "false"): + return v.lower() + return v + + +def _split_values_tokens(tokens): + """Group candidate value tokens, dropping connecting words.""" + out = [] + seen = 0 + for t in tokens: + tv = _canonical_value(t) + if tv.lower() in ("or", ",", ",)"): + continue + out.append(tv) + seen += 1 + return out + + +# --------------------------------------------------------------------------- +# Main parser +# --------------------------------------------------------------------------- + + +def _parse_single_condition(text, param_regex): + """Try to parse ``text`` (a single atom) as ``param ``. + + Returns a Condition or None. + """ + text = text.strip().strip('"').strip() + if not text: + return None + + # param == value / param = value + for op in ("==", "="): + idx = text.find(op) + if idx > 0: + param = text[:idx].strip() + rhs = text[idx + len(op):].strip() + if param_regex(param) and rhs: + values = _split_values_tokens([t for t in re.split(r"[/,]", rhs)]) + values = [v for v in values if v] + if values: + return Condition(param, "==", values) + return None + + # param is set to / param is / param contains + for marker, op in ( + (_IS_SETTO, "=="), + (_CONTAINS, "in"), + ): + m = marker.search(text) + if m: + param = text[: m.start()].strip() + rhs = text[m.end():].strip() + if param_regex(param) and rhs: + tokens = re.split(r"[,]", rhs) + values = _split_values_tokens(tokens) + values = [v for v in values if v] + if values: + return Condition(param, op, values) + return None + + m = _IS_EQ.search(text) + if m: + param = text[: m.start()].strip() + rhs = text[m.end():].strip() + if param_regex(param) and rhs: + values = _split_values_tokens([t for t in re.split(r"[,/]", rhs)]) + values = [v for v in values if v] + if values: + # "param is true/false" -> ==; otherwise treat as membership + op = "==" if len(values) == 1 else "in" + return Condition(param, op, values) + return None + + return None + + +def _tokenise_bool(text): + """Split a boolean expression at top-level ``and``/``or``/``,``. + + Returns a list of ``(atom_text, sep)`` pairs where ``sep`` is the + connecting keyword that followed the atom (``and``/``or``/``,``), or + ``None`` for the last atom. + """ + tokens = re.split(r"(\band\b|\bor\b|,)", text, flags=re.IGNORECASE) + parts = [] + pending_sep = None + for t in tokens: + t = t.strip() + if not t: + continue + low = t.lower() + if low in ("and", "or", ","): + # separator that binds the *previous* atom to the next one + pending_sep = low if low != "," else "and" + continue + parts.append((t, pending_sep)) + pending_sep = None + return parts + + +def parse_availability(text, param_regex=_PARAM_LIKE.match): + """Parse an availability string into an :class:`Availability`. + + :param text: raw availability string (may be empty). + :param param_regex: callable ``(str) -> bool`` used to decide whether a + leading token is a plausible parameter name. Defaults to a loose + lowercase identifier check. + """ + text = (text or "").strip() + if not text: + return Availability("Label", text=text) + + # Cheap rejection of obvious prose / bare labels (no operator present). + has_operator = re.search( + r"==|=| in | in$| is set to|\bis\b|\bcontains\b", text, re.IGNORECASE + ) + if not has_operator: + return Availability("Label", label=text.strip('"').rstrip('.'), text=text) + + # Try to interpret as a boolean condition over atoms. + atoms = _tokenise_bool(text) + conds = [] + for atom, sep in atoms: + c = _parse_single_condition(atom, param_regex) + if c is None: + # Not parseable -> whole thing is unstructured. + return Availability("Unstructured", text=text) + conds.append((c, sep)) + + if not conds: + return Availability("Unstructured", text=text) + + # Build an AND/OR expression tree from the parsed atoms and connectors. + nodes = [c for c, _ in conds] + expr = Expr("and", nodes) # flat AND; OR connectors are recorded but not + # given a separate tree node (no parenthesised precedence in current data). + return Availability("Expression", expr=expr, text=text) diff --git a/tools/03_code_analysis/test_availability_parser.py b/tools/03_code_analysis/test_availability_parser.py new file mode 100644 index 0000000000..dfd17cbb3b --- /dev/null +++ b/tools/03_code_analysis/test_availability_parser.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +"""Unit tests for :mod:`availability_parser`.""" + +import os +import sys +import unittest + +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[2] +sys.path.insert(0, str(REPO_ROOT / "tools" / "03_code_analysis")) + +from availability_parser import ( + Availability, + Condition, + Expr, + parse_availability, +) + + +def _conds(availability): + """Return the flat list of Condition leaves of an Expression result.""" + assert availability.kind == "Expression" + return [c for c in availability.expr.children if isinstance(c, Condition)] + + +class AvailabilityParserTest(unittest.TestCase): + def test_empty_is_label(self): + r = parse_availability("") + self.assertEqual(r.kind, "Label") + + def test_bare_label(self): + r = parse_availability("Numerical atomic orbital basis") + self.assertEqual(r.kind, "Label") + self.assertEqual(r.label, "Numerical atomic orbital basis") + + def test_label_with_period(self): + r = parse_availability("TDOFDFT.") + self.assertEqual(r.kind, "Label") + + def test_double_equal(self): + r = parse_availability("basis_type==lcao") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), ("basis_type", "==", ["lcao"])) + + def test_single_equal_and_trailing_period(self): + r = parse_availability("esolver_type = dp.") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), ("esolver_type", "==", ["dp"])) + + def test_slash_value_list(self): + r = parse_availability("basis_type==pw, ks_solver==cg/dav/dav_subspace/bpcg") + self.assertEqual(r.kind, "Expression") + conds = _conds(r) + vals = {c.param: c.values for c in conds} + self.assertEqual(vals["basis_type"], ["pw"]) + self.assertEqual(vals["ks_solver"], ["cg", "dav", "dav_subspace", "bpcg"]) + + def test_and_combination(self): + r = parse_availability("basis_type==lcao and esolver_type==tddft") + self.assertEqual(r.kind, "Expression") + self.assertEqual(len(_conds(r)), 2) + + def test_is_true_boolean(self): + r = parse_availability("imp_sol is true") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), ("imp_sol", "==", ["true"])) + + def test_is_set_to(self): + r = parse_availability("vdw_method is set to d2") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), ("vdw_method", "==", ["d2"])) + + def test_unstructured_prose(self): + r = parse_availability("Only used when relax_method is bfgs or cg_bfgs") + self.assertEqual(r.kind, "Unstructured") + self.assertEqual(r.text, "Only used when relax_method is bfgs or cg_bfgs") + + def test_text_preserved(self): + r = parse_availability("basis_type==lcao") + self.assertEqual(r.text, "basis_type==lcao") + + +if __name__ == "__main__": + unittest.main() From 9472f732a929cafe4a2cacc3ef6f1aa732e87375 Mon Sep 17 00:00:00 2001 From: Stardust0831 <169599847+Stardust0831@users.noreply.github.com> Date: Wed, 5 Aug 2026 21:16:56 +0800 Subject: [PATCH 2/2] feat(input): structured availability for INPUT parameters (Phase 1) Make the Input_Item availability field a concrete, machine-readable boolean condition (single source of truth) so the INPUT docs, validation and tooling can consume the actual condition instead of free text or bare tags. - Add AvailabilityKind/AvailabilityCondition/AvailabilityExpr and parse_availability() in a new module (availability.{h,cpp}, wired into CMake). - Input_Item now carries availability_kind + availability_expr and a set_availability() helper that keeps the canonical string and the structured form in sync (single source of truth). - Rewrite all 217 non-empty availability registrations to canonical boolean syntax; the exported YAML classifies them as 216 Expression / 0 Unstructured. - Export the structured fields from --generate-parameters-yaml (input_help.cpp). - Consume the structured fields in generate_input_main.py; extend availability_parser.py to the canonical grammar and cover it with tests. - Regenerate docs/parameters.yaml and input-main.md. Former bare "label"-style tags (e.g. "OFDFT", "Numerical atomic orbital basis") are now expressed as concrete conditions (esolver_type==ofdft, basis_type==lcao, ...) so they can be evaluated by validation/error tooling. mixing_tau has no hard gate, so its availability is empty (always available); its meta-GGA relevance is kept in the description. --- docs/advanced/input_files/input-main.md | 359 +++++++++-------- docs/generate_input_main.py | 59 ++- docs/parameters.yaml | 360 +++++++++--------- source/source_io/CMakeLists.txt | 1 + .../module_parameter/availability.cpp | 348 +++++++++++++++++ .../source_io/module_parameter/availability.h | 47 +++ .../source_io/module_parameter/input_item.h | 16 +- .../read_input_item_deepks.cpp | 30 +- .../read_input_item_elec_stru.cpp | 16 +- .../read_input_item_exx_dftu.cpp | 22 +- .../module_parameter/read_input_item_md.cpp | 8 +- .../read_input_item_model.cpp | 44 +-- .../read_input_item_ofdft.cpp | 96 ++--- .../read_input_item_other.cpp | 30 +- .../read_input_item_output.cpp | 70 ++-- .../read_input_item_postprocess.cpp | 16 +- .../read_input_item_relax.cpp | 18 +- .../module_parameter/read_input_item_sdft.cpp | 18 +- .../read_input_item_system.cpp | 14 +- .../read_input_item_tddft.cpp | 52 +-- source/source_io/test_serial/CMakeLists.txt | 9 + .../test_serial/availability_test.cpp | 102 +++++ tools/03_code_analysis/availability_parser.py | 204 +++++++--- .../test_availability_parser.py | 74 ++++ 24 files changed, 1371 insertions(+), 642 deletions(-) create mode 100644 source/source_io/module_parameter/availability.cpp create mode 100644 source/source_io/module_parameter/availability.h create mode 100644 source/source_io/test_serial/availability_test.cpp diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 375b451eed..dd7d12869c 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -739,7 +739,7 @@ ### mem_saver - **Type**: Integer -- **Availability**: *Used only for nscf calculations with plane wave basis set.* +- **Availability**: *calculation==nscf and basis_type==pw* - **Description**: Save memory when performing nscf calculations. - 0: no memory saving techniques are used. - 1: a memory saving technique will be used for many k point calculations. @@ -754,7 +754,7 @@ ### diago_proc - **Type**: Integer -- **Availability**: *Used only for plane wave basis set.* +- **Availability**: *basis_type==pw* - **Description**: - 0: it will be set to the number of MPI processes. - >0: it specifies the number of processes used for carrying out diagonalization. Must be less than or equal to total number of MPI processes. - **Default**: 0 @@ -807,7 +807,7 @@ ### precision - **Type**: String -- **Availability**: *Used only for plane wave basis set.* +- **Availability**: *basis_type==pw* - **Description**: Specifies the precision when performing scf calculation. - single: single precision - double: double precision @@ -816,7 +816,7 @@ ### gint_precision - **Type**: String -- **Availability**: *Used only for LCAO basis set.* +- **Availability**: *basis_type==lcao* - **Description**: Specifies the precision when performing grid integral in LCAO calculations. - single: single precision - double: double precision @@ -899,14 +899,14 @@ ### restart_load - **Type**: Boolean -- **Availability**: *Used only when numerical atomic orbitals are employed as basis set.* +- **Availability**: *basis_type==lcao* - **Description**: If restart_save is set to true and an electronic iteration is finished, calculations can be restarted from the charge density file, which are saved in the former calculation. - **Default**: False ### spillage_outdir - **Type**: String -- **Availability**: *Used only for plane wave basis set.* +- **Availability**: *basis_type==pw* - **Description**: The directory to save the spillage files. - **Default**: "./" @@ -980,7 +980,7 @@ ### pw_seed - **Type**: Integer -- **Availability**: *Only used for plane wave basis.* +- **Availability**: *basis_type==pw* - **Description**: Specify the random seed to initialize wave functions. Only positive integers are available. - **Default**: 0 @@ -1039,14 +1039,14 @@ ### use_k_continuity - **Type**: Boolean -- **Availability**: *Used only for plane wave basis set.* +- **Availability**: *basis_type==pw* - **Description**: If TRUE, the wavefunctions at k-point will be initialized from the converged wavefunctions at the nearest k-point, which can speed up the SCF convergence. Only works for PW basis. - **Default**: false ### pw_diag_nmax - **Type**: Integer -- **Availability**: *basis_type==pw, ks_solver==cg/dav/dav_subspace/bpcg* +- **Availability**: *basis_type==pw and ks_solver in [cg, dav, dav_subspace, bpcg]* - **Description**: Only useful when you use ks_solver = cg/dav/dav_subspace/bpcg. It indicates the maximal iteration number for cg/david/dav_subspace/bpcg method. - **Default**: 50 @@ -1350,7 +1350,7 @@ ### mixing_dmr - **Type**: Boolean -- **Availability**: *Only for mixing_restart >= 0.0* +- **Availability**: *mixing_restart>=0* - **Description**: At n-th iteration which is calculated by drho<mixing_restart, SCF will start a mixing for real-space density matrix by using the same coefficiences as the mixing of charge density. - **Default**: false @@ -1383,7 +1383,7 @@ ### mixing_angle - **Type**: Real -- **Availability**: *Only relevant for non-colinear calculations nspin=4.* +- **Availability**: *nspin==4* - **Description**: Normal broyden mixing can give the converged result for a given magnetic configuration. If one is not interested in the energies of a given magnetic configuration but wants to determine the ground state by relaxing the magnetic moments' directions, one cannot rely on the standard Broyden mixing algorithm. To enhance the ability to find correct magnetic configuration for non-colinear calculations, ABACUS implements a promising mixing method proposed by J. Phys. Soc. Jpn. 82 (2013) 114706. Here, mixing_angle is the angle mixing parameter. In fact, only mixing_angle=1.0 is implemented currently. - <=0: Normal broyden mixing - >0: Angle mixing for the modulus with mixing_angle=1.0 @@ -1392,7 +1392,6 @@ ### mixing_tau - **Type**: Boolean -- **Availability**: *Only relevant for meta-GGA calculations.* - **Description**: Whether to mix the kinetic energy density. - True: The kinetic energy density will also be mixed. It seems for general cases, SCF converges fine even without this mixing. However, if there is difficulty in converging SCF for meta-GGA, it might be helpful to turn this on. - False: The kinetic energy density will not be mixed. @@ -1401,7 +1400,7 @@ ### mixing_dftu - **Type**: Boolean -- **Availability**: *Only relevant for DFT+U calculations.* +- **Availability**: *dft_plus_u==1* - **Description**: Whether to mix the occupation matrices. - True: The occupation matrices will also be mixed by plain mixing. From experience this is not very helpful if the +U calculation does not converge. - False: The occupation matrices will not be mixed. @@ -1410,7 +1409,7 @@ ### gamma_only - **Type**: Boolean -- **Availability**: *Only used in localized orbitals set* +- **Availability**: *basis_type==lcao* - **Description**: Whether to use gamma_only algorithm. - 0: more than one k-point is used and the ABACUS is slower compared to the gamma only algorithm. - 1: ABACUS uses gamma only, the algorithm is faster and you don't need to specify the k-points file. @@ -1505,7 +1504,7 @@ ### soc_lambda - **Type**: Real -- **Availability**: *Only works when lspinorb=true* +- **Availability**: *lspinorb==true* - **Description**: Modulates the strength of spin-orbit coupling effect. Sometimes, for some real materials, both scalar-relativistic and full-relativistic pseudopotentials cannot describe the exact spin-orbit coupling. Artificial modulation may help in such cases. soc_lambda, which has value range [0.0, 1.0], is used to modulate SOC effect: @@ -1532,7 +1531,7 @@ ### method_sto - **Type**: Integer -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Different methods to do stochastic DFT - 1: Calculate twice, this method cost less memory but is slower. - 2: Calculate once but needs much more memory. This method is much faster. Besides, it calculates with a smaller nche_sto. However, when the memory is not enough, only method 1 can be used. @@ -1542,7 +1541,7 @@ ### nbands_sto - **Type**: Integer or string -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: The number of stochastic orbitals - 1-1000000: Perform stochastic DFT. Increasing the number of bands improves accuracy and reduces stochastic errors; To perform mixed stochastic-deterministic DFT, you should set nbands, which represents the number of KS orbitals. - 0: Invalid. Use all for the complete-basis SDFT mode. @@ -1552,14 +1551,14 @@ ### nche_sto - **Type**: Integer -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Chebyshev expansion orders for stochastic DFT. - **Default**: 100 ### emin_sto - **Type**: Real -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Trial energy to guess the lower bound of eigen energies of the Hamiltonian Operator. - **Default**: 0.0 - **Unit**: Ry @@ -1567,7 +1566,7 @@ ### emax_sto - **Type**: Real -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Trial energy to guess the upper bound of eigen energies of the Hamiltonian Operator. - **Default**: 0.0 - **Unit**: Ry @@ -1575,7 +1574,7 @@ ### seed_sto - **Type**: Integer -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: The random seed to generate stochastic orbitals. - >= 0: Stochastic orbitals have the form of exp(i*theta), where theta is a uniform distribution in [0, 2*pi). - 0: the seed is decided by time(NULL). @@ -1586,7 +1585,7 @@ ### initsto_ecut - **Type**: Real -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Stochastic wave functions are initialized in a large box generated by "4*initsto_ecut". initsto_ecut should be larger than ecutwfc. In this method, SDFT results are the same when using different cores. Besides, coefficients of the same G are the same when ecutwfc is rising to initsto_ecut. If it is smaller than ecutwfc, it will be turned off. - **Default**: 0.0 - **Unit**: Ry @@ -1594,7 +1593,7 @@ ### initsto_freq - **Type**: Integer -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Frequency (once each initsto_freq steps) to generate new stochastic orbitals when running md. - positive integer: Update stochastic orbitals - 0: Never change stochastic orbitals. @@ -1603,7 +1602,7 @@ ### npart_sto - **Type**: Integer -- **Availability**: *method_sto = 2 and out_dos = 1 or cal_cond = True* +- **Availability**: *method_sto==2 and out_dos==1 or cal_cond==true* - **Description**: Make memory cost to 1/npart_sto times of the previous one when running the post process of SDFT like DOS or conductivities. - **Default**: 1 @@ -1639,7 +1638,7 @@ ### relax_scale_force - **Type**: Real -- **Availability**: *Only used when relax_method is cg 2* +- **Availability**: *relax_method in [cg 2]* - **Description**: The paramether controls the size of the first conjugate gradient step. A smaller value means the first step along a new CG direction is smaller. This might be helpful for large systems, where it is safer to take a smaller initial step to prevent the collapse of the whole configuration. - **Default**: 0.5 @@ -1652,7 +1651,7 @@ ### relax_cg_thr - **Type**: Real -- **Availability**: *Only used when relax_method is cg_bfgs* +- **Availability**: *relax_method==cg_bfgs* - **Description**: When relax_method is set to cg_bfgs, a mixed algorithm of conjugate gradient (CG) and Broyden–Fletcher–Goldfarb–Shanno (BFGS) is used. The ions first move according to the CG method, then switch to the BFGS method when the maximum force on atoms is reduced below this threshold. - **Default**: 0.5 - **Unit**: eV/Angstrom @@ -1681,21 +1680,21 @@ ### relax_bfgs_w1 - **Type**: Real -- **Availability**: *Only used when relax_method is bfgs or cg_bfgs* +- **Availability**: *relax_method in [bfgs, cg_bfgs]* - **Description**: Controls the Wolfe condition for the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm used in geometry relaxation. This parameter sets the sufficient decrease condition (c1 in Wolfe conditions). For more information, see Phys. Chem. Chem. Phys., 2000, 2, 2177. - **Default**: 0.01 ### relax_bfgs_w2 - **Type**: Real -- **Availability**: *Only used when relax_method is bfgs or cg_bfgs* +- **Availability**: *relax_method in [bfgs, cg_bfgs]* - **Description**: Controls the Wolfe condition for the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm used in geometry relaxation. This parameter sets the curvature condition (c2 in Wolfe conditions). For more information, see Phys. Chem. Chem. Phys., 2000, 2, 2177. - **Default**: 0.5 ### relax_bfgs_rmax - **Type**: Real -- **Availability**: *Only used when relax_method is bfgs or cg_bfgs* +- **Availability**: *relax_method in [bfgs, cg_bfgs]* - **Description**: Maximum allowed total displacement of all atoms during geometry optimization. The sum of atomic displacements can increase during optimization steps but cannot exceed this value. - **Default**: 0.8 - **Unit**: Bohr @@ -1703,7 +1702,7 @@ ### relax_bfgs_rmin - **Type**: Real -- **Availability**: *Only used when relax_method is bfgs 1 (traditional BFGS)* +- **Availability**: *relax_method in [bfgs 1]* - **Description**: Minimum allowed total displacement of all atoms. When the total atomic displacement falls below this value and force convergence is not achieved, the calculation will terminate. Note: This parameter is not used in the default BFGS algorithm (relax_method = bfgs 2 or bfgs). - **Default**: 1e-5 - **Unit**: Bohr @@ -1711,7 +1710,7 @@ ### relax_bfgs_init - **Type**: Real -- **Availability**: *Only used when relax_method is bfgs or cg_bfgs* +- **Availability**: *relax_method in [bfgs, cg_bfgs]* - **Description**: Initial total displacement of all atoms in the first BFGS step. This sets the scale for the initial movement. - **Default**: 0.5 - **Unit**: Bohr @@ -1747,7 +1746,7 @@ ### fixed_axes - **Type**: String -- **Availability**: *Only used when calculation is set to cell-relax* +- **Availability**: *calculation==cell-relax* - **Description**: Specifies which cell degrees of freedom are fixed during variable-cell relaxation. The available options depend on relax_method: With relax_method = cg 2 (default), all options are available: @@ -1771,7 +1770,7 @@ ### fixed_ibrav - **Type**: Boolean -- **Availability**: *Only used with relax_method = cg 2. A specific latname must be provided.* +- **Availability**: *relax_method in [cg 2] and latname != none* - **Description**: - True: the lattice type will be preserved during relaxation. The lattice vectors are reconstructed to match the specified Bravais lattice type after each update. - False: No restrictions are exerted during relaxation in terms of lattice type @@ -1875,7 +1874,7 @@ ### out_dmk - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to output the density matrix for each k-point into files in the folder OUT.${suffix}. For current develop versions, out_dmk writes *_nao.txt files and includes a g{istep} index in the file name: - For gamma only case: - nspin = 1 and 4: dmg1_nao.txt; @@ -1894,7 +1893,7 @@ ### out_dmr - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis (multi-k points)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to output the density matrix with Bravias lattice vector R index into files in the folder OUT.${suffix}. The files are named as dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in out_hsr. Finally, if out_app_flag is set to false, the file name contains the optional 'g' index for each ionic step that may have different geometries, and if out_app_flag is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps: - nspin = 1: dmrs1_nao.csr; - nspin = 2: dmrs1_nao.csr and dmrs2_nao.csr for the two spin channels. @@ -1905,7 +1904,7 @@ ### out_wfc_pw - **Type**: Integer -- **Availability**: *Output electronic wave functions in plane wave basis, or transform the real-space electronic wave function into plane wave basis (see get_wf option in calculation with NAO basis)* +- **Availability**: *basis_type==pw or (basis_type==lcao and calculation==get_wf)* - **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder OUT.${suffix}. The files are named as wf{k}{k-point index}{s}{spin index}{g}{geometry index}{e}{electronic iteration index}{_pw} + {".txt"/".dat"}. Here, the s index refers to spin but the label will not show up for non-spin-polarized calculations, where s1 means spin up channel while s2 means spin down channel, and s4 refers to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. For scf or nscf calculations, g index will not appear, but the g index appears for geometry relaxation and molecular dynamics, where one can use the out_freq_ion command to control. To print out the electroinc wave functions every few SCF iterations, use the out_freq_elec command and the e index will appear in the file name. - 0: no output - 1: (txt format) @@ -1923,7 +1922,7 @@ ### out_wfc_lcao - **Type**: Integer -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder OUT.${suffix}. The files are named as wf{s}{spin index}{k(optional)}{k-point index}{g(optional)}{geometry index1}{_nao} + {".txt"/".dat"}. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and 's12' refer to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. In addition, if 'gamma_only' is set to 0, then the optinoal k-point sampling index appears with the k-point index attached to the electronic wave function file names. Finally, if out_app_flag is set to false, the file name contains the optional 'g' index for each ionic step that may have different geometries, and if out_app_flag is set to true, the wave functions accumulate during ionic steps. If the out_app_flag is set to false, a new folder named WFC will be created, and the wave function files will be saved into it. - 0: no output - 1: (txt format) @@ -1999,7 +1998,7 @@ ### out_hsk - **Type**: Integer \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Output the upper triangular part of the Hamiltonian and overlap matrices in reciprocal space for each k-point into files in the directory OUT.${suffix}. The first integer selects the format: - 0: disabled; - 1: text output; the optional second integer controls precision and defaults to 8; @@ -2025,7 +2024,7 @@ ### out_mat_hs - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Legacy alias for out_hsk 1, which outputs Hamiltonian and overlap matrices in reciprocal space for each k-point. The optional second integer controls text precision. If both out_hsk and out_mat_hs are present, out_hsk takes precedence. - **Default**: False 8 - **Unit**: Ry @@ -2033,7 +2032,7 @@ ### out_hsr - **Type**: Integer \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Output Hamiltonian and overlap matrices in real space, indexed by the Bravais lattice vector R, in the directory OUT.${suffix}. The first integer selects the format: - 0: disabled; - 1: text CSR output; the optional second integer controls precision and defaults to 8; @@ -2049,7 +2048,7 @@ ### out_mat_hs2 - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Legacy alias for out_hsr 1, which outputs Hamiltonian and overlap matrices in real space indexed by the Bravais lattice vector R. The optional second integer controls text precision. If both out_hsr and out_mat_hs2 are present, out_hsr takes precedence. - **Default**: False 8 - **Unit**: Ry @@ -2057,7 +2056,7 @@ ### out_mat_tk - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to print the upper triangular part of the kinetic matrices for each k-point into OUT.${suffix}/tks1ki_nao.txt, where i is the index of k points. One may optionally provide a second parameter to specify the precision. > Note: In the 3.10-LTS version, the file names are data-TR-sparse_SPIN0.csr, etc. @@ -2067,7 +2066,7 @@ ### out_mat_r - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to print the matrix representation of the position matrix into files named rxrs1_nao.csr, ryrs1_nao.csr, rzrs1_nao.csr in the directory OUT.${suffix}. The optional second parameter controls text output precision. If calculation is set to get_s, the position matrix can be obtained without scf iterations. For more information, please refer to position_matrix.md. > Note: In the 3.10-LTS version, the file name is data-rR-sparse.csr. @@ -2077,7 +2076,7 @@ ### out_mat_t - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Generate files containing the kinetic energy matrix. The optional second parameter controls text output precision. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_hsr. The name of the files will be trs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. > Note: In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr. @@ -2087,7 +2086,7 @@ ### out_mat_dh - **Type**: Integer -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_hsr. The name of the files will be dhrxs1_nao.csr, dhrys1_nao.csr, dhrzs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. Format: <enable> [precision] [iat1 iat2 ...]. The first value (0/1) enables/disables output. The second optional value sets the output precision (default: 8). Starting from the third value, 1-based atom indices can be listed to restrict output to derivatives with respect to those specific atoms only; if no atom indices are given, all atoms are written. @@ -2207,7 +2206,7 @@ ### out_mat_ds - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to print files containing the derivatives of the overlap matrix. The optional second parameter controls text output precision. The format will be the same as the overlap matrix as mentioned in out_mat_dh. The name of the files will be dsxrs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. This feature can be used with calculation get_s. > Note: In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on. @@ -2217,7 +2216,7 @@ ### out_mat_xc - **Type**: Boolean -- **Availability**: *Numerical atomic orbital (NAO) and NAO-in-PW basis* +- **Availability**: *basis_type in [lcao, lcao_in_pw]* - **Description**: Whether to print the upper triangular part of the exchange-correlation matrices in Kohn-Sham orbital representation: for each k point into files in the directory OUT.i_nao.txt, where {suffix}/vxc_out.dat. If EXX is calculated, the local and EXX part of band energy will also be printed in OUT.{suffix}/vxc_exx_out.dat, respectively. All the vxc_out.dat files contains 3 integers (nk, nspin, nband) followed by nk*nspin*nband lines of energy Hartree and eV. > Note: In the 3.10-LTS version, the file name is k-$k-Vxc and so on. @@ -2227,7 +2226,7 @@ ### out_mat_xc2 - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital (NAO) basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to print the exchange-correlation matrices in numerical orbital representation: in CSR format in the directory OUT.${suffix}. The name of the files will be vxcrs1_nao.csr and so on. > Note: In the 3.10-LTS version, the file name is Vxc_R_spin$s and so on. @@ -2237,7 +2236,7 @@ ### out_mat_l - **Type**: Boolean \[Integer\](optional) -- **Availability**: *Numerical atomic orbital (NAO) basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to print the expectation value of the angular momentum operator , , and in the basis of the localized atomic orbitals. The files are named OUT.{suffix}_Lx.dat, OUT.{suffix}_Ly.dat, and OUT.{suffix}_Lz.dat. The second integer controls the precision of the output. - **Default**: False 8 @@ -2259,14 +2258,14 @@ ### out_eband_terms - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to print the band energy terms separately in the file OUT.{term}_out.dat. The terms include the kinetic, pseudopotential (local + nonlocal), Hartree and exchange-correlation (including exact exchange if calculated). - **Default**: False ### out_hr_npz - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to print Hamiltonian matrices H(R) in NPZ format as hrs1_nao.npz and, for nspin = 2, hrs2_nao.npz. This feature does not work for gamma-only calculations. - **Default**: False - **Unit**: Ry @@ -2274,7 +2273,7 @@ ### out_hsr_npz - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Legacy alias for out_hsr 3, writing hrs1_nao.npz, hrs2_nao.npz when needed, and sr_nao.npz. If both out_hsr and out_hsr_npz are present, out_hsr takes precedence. Gamma-only calculations write the folded R = (0, 0, 0) representation. - **Default**: False - **Unit**: Ry @@ -2282,28 +2281,28 @@ ### out_dm_npz - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to print density matrices DM(R) in npz format. This feature does not work for gamma-only calculations. - **Default**: False ### out_mul - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to print the Mulliken population analysis result into OUT.${suffix}/mulliken.txt. In molecular dynamics calculations, the output frequency is controlled by out_freq_ion. - **Default**: False ### out_app_flag - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Availability**: *basis_type==lcao and gamma_only==0* - **Description**: Whether to output r(R), H(R), S(R), T(R), dH(R), dS(R), and wfc matrices in an append manner during molecular dynamics calculations. Check input parameters out_mat_r, out_hsr, out_mat_t, out_mat_dh, out_hsk and out_wfc_lcao for more information. - **Default**: true ### out_ndigits - **Type**: Integer -- **Availability**: *out_hsk 1 case presently.* +- **Availability**: *out_hsk==1* - **Description**: Controls the length of decimal part of output data, such as charge density, Hamiltonian matrix, Overlap matrix and so on. - **Default**: 8 @@ -2316,7 +2315,7 @@ ### restart_save - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Whether to save charge density files per ionic step, which are used to restart calculations. According to the value of read_file_dir: - auto: These files are saved in folder OUT.{read_file_dir}/restart/. @@ -2334,35 +2333,35 @@ ### out_pchg - **Type**: String -- **Availability**: *For both PW and LCAO. When basis_type = lcao, used when calculation = get_pchg.* +- **Availability**: *basis_type==pw or (basis_type==lcao and calculation==get_pchg)* - **Description**: Specifies the electronic states to calculate the charge densities with state index for, using a space-separated string of 0s and 1s. Each digit in the string corresponds to a state, starting from the first state. A 1 indicates that the charge density should be calculated for that state, while a 0 means the state will be ignored. The parameter allows a compact and flexible notation (similar to ocp_set), for example the syntax 1 4*0 5*1 0 is used to denote the selection of states: 1 means calculate for the first state, 4*0 skips the next four states, 5*1 means calculate for the following five states, and the final 0 skips the next state. It's essential that the total count of states does not exceed the total number of states (nbands); otherwise, it results in an error, and the process exits. The input string must contain only numbers and the asterisk (*) for repetition, ensuring correct format and intention of state selection. The outputs comprise multiple .cube files following the naming convention pchgi[state]s[spin]k[kpoint].cube. - **Default**: none ### out_wfc_norm - **Type**: String -- **Availability**: *For both PW and LCAO. When basis_type = lcao, used when calculation = get_wf.* +- **Availability**: *basis_type==pw or (basis_type==lcao and calculation==get_wf)* - **Description**: Specifies the electronic states to calculate the real-space wave function modulus (norm, or known as the envelope function) with state index. The syntax and state selection rules are identical to out_pchg, but the output is the norm of the wave function. The outputs comprise multiple .cube files following the naming convention wfi[state]s[spin]k[kpoint].cube. - **Default**: none ### out_wfc_re_im - **Type**: String -- **Availability**: *For both PW and LCAO. When basis_type = lcao, used when calculation = get_wf.* +- **Availability**: *basis_type==pw or (basis_type==lcao and calculation==get_wf)* - **Description**: Specifies the electronic states to calculate the real and imaginary parts of the wave function with state index. The syntax and state selection rules are identical to out_pchg, but the output contains both the real and imaginary components of the wave function. The outputs comprise multiple .cube files following the naming convention wfi[state]s[spin]k[kpoint][re/im].cube. - **Default**: none ### if_separate_k - **Type**: Boolean -- **Availability**: *For both PW and LCAO. When basis_type = pw, used if out_pchg is set. When basis_type = lcao, used only when calculation = get_pchg and gamma_only = 0.* +- **Availability**: *basis_type==pw and out_pchg!=none or basis_type==lcao and calculation==get_pchg and gamma_only==0* - **Description**: Specifies whether to write the partial charge densities for all k-points to individual files or merge them. Warning: Enabling symmetry may produce unwanted results due to reduced k-point weights and symmetry operations in real space. Therefore when calculating partial charge densities, if you are not sure what you want exactly, it is strongly recommended to set symmetry = -1. It is noteworthy that your symmetry setting should remain the same as that in the SCF procedure. - **Default**: false ### out_elf - **Type**: Integer \[Integer\](optional) -- **Availability**: *Only for Kohn-Sham DFT and Orbital Free DFT.* +- **Availability**: *esolver_type in [ksdft, ofdft]* - **Description**: Whether to output the electron localization function (ELF) in the folder `OUT.${suffix}`. The files are named as - nspin = 1: - elftot.cube: ${\rm{ELF}} = \frac{1}{1+\chi^2}$, $\chi = \frac{\frac{1}{2}\sum_{i}{f_i |\nabla\psi_{i}|^2} - \frac{|\nabla\rho|^2}{8\rho}}{\frac{3}{10}(3\pi^2)^{2/3}\rho^{5/3}}$; @@ -2382,7 +2381,7 @@ ### out_spillage - **Type**: Integer -- **Availability**: *Only for Kohn-Sham DFT with plane-wave basis.* +- **Availability**: *esolver_type==ksdft and basis_type==pw* - **Description**: This output is only intentively needed by the ABACUS numerical atomic orbital generation workflow. This parameter is used to control whether to output the overlap integrals between truncated spherical Bessel functions (TSBFs) and plane-wave basis expanded wavefunctions (named as OVERLAP_Q), and between TSBFs (named as OVERLAP_Sq), also their first order derivatives. The output files are named starting with orb_matrix. A value of 2 would enable the output. - **Default**: 0 @@ -2498,7 +2497,7 @@ ### deepks_out_labels - **Type**: Integer -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Print labels and descriptors for DeePKS in OUT.${suffix}. The names of these files start with "deepks". - 0 : No output. - 1 : Output intermediate files needed during DeePKS training. @@ -2510,21 +2509,21 @@ ### deepks_out_freq_elec - **Type**: Integer -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: When deepks_out_freq_elec is greater than 0, print labels and descriptors for DeePKS in OUT.${suffix}/DeePKS_Labels_Elec per deepks_out_freq_elec electronic iterations, with suffix _e* to distinguish different steps. Often used with deepks_out_labels equals 1. - **Default**: 0 ### deepks_out_base - **Type**: String -- **Availability**: *Numerical atomic orbital basis and deepks_out_freq_elec is greater than 0* +- **Availability**: *basis_type==lcao and deepks_out_freq_elec>0* - **Description**: Print labels and descriptors calculated by base functional ( determined by deepks_out_base ) and target functional ( determined by dft_functional ) for DeePKS in per deepks_out_freq_elec electronic iterations. The SCF process, labels and descriptors output of the target functional are all consistent with those when the target functional is used alone. The only additional output under this configuration is the labels of the base functional. Often used with deepks_out_labels equals 1. - **Default**: None ### deepks_scf - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: perform self-consistent field iteration in DeePKS method > Note: A trained, traced model file is needed. @@ -2533,7 +2532,7 @@ ### deepks_equiv - **Type**: Boolean -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: whether to use equivariant version of DeePKS > Note: The equivariant version of DeePKS-kit is still under development, so this feature is currently only intended for internal usage. @@ -2542,21 +2541,21 @@ ### deepks_model - **Type**: String -- **Availability**: *Numerical atomic orbital basis and deepks_scf is true* +- **Availability**: *basis_type==lcao and deepks_scf==true* - **Description**: the path of the trained, traced neural network model file generated by deepks-kit - **Default**: None ### bessel_descriptor_lmax - **Type**: Integer -- **Availability**: *gen_bessel calculation* +- **Availability**: *calculation==gen_bessel* - **Description**: the maximum angular momentum of the Bessel functions generated as the projectors in DeePKS - NOte: To generate such projectors, set calculation type to gen_bessel in ABACUS. See also calculation. - **Default**: 2 ### bessel_descriptor_ecut - **Type**: String -- **Availability**: *gen_bessel calculation* +- **Availability**: *calculation==gen_bessel* - **Description**: energy cutoff of Bessel functions - **Default**: same as ecutwfc - **Unit**: Ry @@ -2564,14 +2563,14 @@ ### bessel_descriptor_tolerence - **Type**: Real -- **Availability**: *gen_bessel calculation* +- **Availability**: *calculation==gen_bessel* - **Description**: tolerance for searching the zeros of Bessel functions - **Default**: 1.0e-12 ### bessel_descriptor_rcut - **Type**: Real -- **Availability**: *gen_bessel calculation* +- **Availability**: *calculation==gen_bessel* - **Description**: cutoff radius of Bessel functions - **Default**: 6.0 - **Unit**: Bohr @@ -2579,14 +2578,14 @@ ### bessel_descriptor_smooth - **Type**: Boolean -- **Availability**: *gen_bessel calculation* +- **Availability**: *calculation==gen_bessel* - **Description**: smooth the Bessel functions at radius cutoff - **Default**: False ### bessel_descriptor_sigma - **Type**: Real -- **Availability**: *gen_bessel calculation* +- **Availability**: *calculation==gen_bessel* - **Description**: smooth parameter at the cutoff radius of projectors - **Default**: 0.1 - **Unit**: Bohr @@ -2594,7 +2593,7 @@ ### deepks_bandgap - **Type**: Integer -- **Availability**: *Numerical atomic orbital basis and deepks_scf is true* +- **Availability**: *basis_type==lcao and deepks_scf==true* - **Description**: include bandgap label for DeePKS training - 0: Don't include bandgap label - 1: Include target bandgap label (see deepks_band_range for more details) @@ -2605,7 +2604,7 @@ ### deepks_band_range - **Type**: Integer*2 -- **Availability**: *Numerical atomic orbital basis, deepks_scf is true, and deepks_bandgap is 1 or 2* +- **Availability**: *basis_type==lcao and deepks_scf==true and deepks_bandgap in [1, 2]* - **Description**: The first value should not be larger than the second one and the meaning differs in different cases below - deepks_bandgap is 1: Bandgap label is the energy between LUMO + deepks_band_range[0] and LUMO + deepks_band_range[1]. If not set, it will calculate energy between HOMO and LUMO states. - deepks_bandgap is 2: Bandgap labels are energies between HOMO and all states in range [LUMO + deepks_band_range[0], LUMO + deepks_band_range[1]] (Thus there are deepks_band_range[1] - deepks_band_range[0] + 1 bandgaps in total). If HOMO is included in the setting range, it will be ignored since it will always be zero and has no valuable messages (deepks_band_range[1] - deepks_band_range[0] bandgaps in this case). NOTICE: The set range can be greater than, less than, or include the value of HOMO. In the bandgap label, we always calculate the energy of the state in the set range minus the energy of HOMO state, so the bandgap can be negative if the state is lower than HOMO. @@ -2614,7 +2613,7 @@ ### deepks_v_delta - **Type**: Integer -- **Availability**: *Numerical atomic orbital basis* +- **Availability**: *basis_type==lcao* - **Description**: Include V_delta/V_delta_R (Hamiltonian in k/real space) label for DeePKS training. When deepks_out_labels is true and deepks_v_delta > 0 (k space), ABACUS will output deepks_hbase.npy, deepks_vdelta.npy and deepks_htot.npy(htot=hbase+vdelta). When deepks_out_labels is true and deepks_v_delta < 0 (real space), ABACUS will output deepks_hrtot.csr, deepks_hrdelta.csr. Some more files output for different settings. NOTICE: To match the unit Normally used in DeePKS, the unit of Hamiltonian in k space is Hartree. However, currently in R space the unit is still Ry. - deepks_v_delta = 1: deepks_vdpre.npy, which is used to calculate V_delta during DeePKS training. - deepks_v_delta = 2: deepks_phialpha.npy and deepks_gevdm.npy, which can be used to calculate deepks_vdpre.npy. A recommanded method for memory saving. @@ -2637,7 +2636,7 @@ ### of_kinetic - **Type**: String -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Kinetic energy functional type: - tf: Thomas-Fermi (TF) functional - vw: von Weizsacker (vW) functional @@ -2654,7 +2653,7 @@ ### of_method - **Type**: String -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: The optimization method used in OFDFT. - cg1: Polak-Ribiere. Standard CG algorithm. - cg2: Hager-Zhang (generally faster than cg1). @@ -2664,7 +2663,7 @@ ### of_conv - **Type**: String -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Criterion used to check the convergence of OFDFT. - energy: Total energy changes less than of_tole. - potential: The norm of potential is less than of_tolp. @@ -2674,7 +2673,7 @@ ### of_tole - **Type**: Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Tolerance of the energy change for determining the convergence. - **Default**: 2e-6 - **Unit**: Ry @@ -2682,7 +2681,7 @@ ### of_tolp - **Type**: Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Tolerance of potential for determining the convergence. - **Default**: 1e-5 - **Unit**: Ry @@ -2690,40 +2689,40 @@ ### of_tf_weight - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=tf, tf+, wt, ext-wt, xwm* +- **Availability**: *esolver_type==ofdft and of_kinetic in [tf, tf+, wt, ext-wt, xwm]* - **Description**: Weight of TF KEDF (kinetic energy density functional). - **Default**: 1.0 ### of_vw_weight - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=vw, tf+, wt, ext-wt, lkt, xwm* +- **Availability**: *esolver_type==ofdft and of_kinetic in [vw, tf+, wt, ext-wt, lkt, xwm]* - **Description**: Weight of vW KEDF (kinetic energy density functional). - **Default**: 1.0 ### of_wt_alpha - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=wt, ext-wt* +- **Availability**: *esolver_type==ofdft and of_kinetic in [wt, ext-wt]* - **Description**: Parameter alpha of WT KEDF (kinetic energy density functional). ### of_wt_beta - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=wt, ext-wt* +- **Availability**: *esolver_type==ofdft and of_kinetic in [wt, ext-wt]* - **Description**: Parameter beta of WT KEDF (kinetic energy density functional). ### of_extwt_kappa - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=ext-wt* +- **Availability**: *esolver_type==ofdft and of_kinetic==ext-wt* - **Description**: Parameter kappa for EXT-WT KEDF. - **Default**: 1.0 / (2.0 * std::pow(4./3., 1./3.) - 1.0) ### of_wt_rho0 - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=wt* +- **Availability**: *esolver_type==ofdft and of_kinetic==wt* - **Description**: The average density of system. - **Default**: 0.0 - **Unit**: Bohr^-3 @@ -2731,7 +2730,7 @@ ### of_hold_rho0 - **Type**: Boolean -- **Availability**: *OFDFT with of_kinetic=wt* +- **Availability**: *esolver_type==ofdft and of_kinetic==wt* - **Description**: Whether to fix the average density rho0. - True: rho0 will be fixed even if the volume of system has changed, it will be set to True automatically if of_wt_rho0 is not zero. - False: rho0 will change if volume of system has changed. @@ -2740,28 +2739,28 @@ ### of_lkt_a - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=lkt* +- **Availability**: *esolver_type==ofdft and of_kinetic==lkt* - **Description**: Parameter a of LKT KEDF (kinetic energy density functional). - **Default**: 1.3 ### of_xwm_rho_ref - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=xwm* +- **Availability**: *esolver_type==ofdft and of_kinetic==xwm* - **Description**: Reference charge density for XWM kinetic energy functional. If set to 0, the program will use average charge density. - **Default**: 0.0 ### of_xwm_kappa - **Type**: Real -- **Availability**: *OFDFT with of_kinetic=xwm* +- **Availability**: *esolver_type==ofdft and of_kinetic==xwm* - **Description**: Parameter for XWM kinetic energy functional. See PHYSICAL REVIEW B 100, 205132 (2019) for optimal values. - **Default**: 0.0 ### of_read_kernel - **Type**: Boolean -- **Availability**: *OFDFT with of_kinetic=wt* +- **Availability**: *esolver_type==ofdft and of_kinetic==wt* - **Description**: Whether to read in the kernel file. - True: The kernel of WT KEDF (kinetic energy density functional) will be filled from the file specified by of_kernel_file. - False: The kernel of WT KEDF (kinetic energy density functional) will be filled from formula. @@ -2770,14 +2769,14 @@ ### of_kernel_file - **Type**: String -- **Availability**: *OFDFT with of_read_kernel=True* +- **Availability**: *esolver_type==ofdft and of_read_kernel==true* - **Description**: The name of WT kernel file. - **Default**: WTkernel.txt ### of_full_pw - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Whether to use full planewaves. - True: Ecut will be ignored while collecting planewaves, so that all planewaves will be used in FFT. - False: Only use the planewaves inside ecut, the same as KSDFT. @@ -2786,7 +2785,7 @@ ### of_full_pw_dim - **Type**: Integer -- **Availability**: *OFDFT with of_full_pw = True* +- **Availability**: *esolver_type==ofdft and of_full_pw==true* - **Description**: Specify the parity of FFT dimensions. - 0: either odd or even. - 1: odd only. @@ -2802,14 +2801,14 @@ ### of_ml_gene_data - **Type**: Boolean -- **Availability**: *Used only for KSDFT with plane wave basis* +- **Availability**: *esolver_type==ksdft and basis_type==pw* - **Description**: Controls the generation of machine learning training data. When enabled, training data in .npy format will be saved in the directory OUT.${suffix}/. - **Default**: False ### of_ml_device - **Type**: String -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Run Neural Network on GPU or CPU. - cpu: CPU - gpu: GPU @@ -2818,7 +2817,7 @@ ### of_ml_feg - **Type**: Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: The method to incorporate the Free Electron Gas (FEG) limit. - 0: Do not incorporate the FEG limit. - 1: Incorporate the FEG limit by translation. @@ -2828,14 +2827,14 @@ ### of_ml_nkernel - **Type**: Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Number of kernel functions. - **Default**: 1 ### of_ml_kernel - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the type of the i-th kernel function. - 1: Wang-Teter kernel function. - 2: Modified Yukawa function, and alpha is specified by of_ml_yukawa_alpha. @@ -2845,168 +2844,168 @@ ### of_ml_kernel_scaling - **Type**: Vector of Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the RECIPROCAL of scaling parameter of the i-th kernel function. - **Default**: 1.0 ### of_ml_yukawa_alpha - **Type**: Vector of Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the parameter alpha of i-th kernel function. ONLY used for Yukawa kernel function. - **Default**: 1.0 ### of_ml_kernel_file - **Type**: Vector of String -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the file containing the i-th kernel function. ONLY used for TKK. - **Default**: none ### of_ml_gamma - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Local descriptor: gamma = (rho / rho0)^(1/3). - **Default**: False ### of_ml_p - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Semi-local descriptor: p = |nabla rho|^2 / [2 (3 pi^2)^(1/3) rho^(4/3)]^2. - **Default**: False ### of_ml_q - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Semi-local descriptor: q = nabla^2 rho / [4 (3 pi^2)^(2/3) rho^(5/3)]. - **Default**: False ### of_ml_tanhp - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Semi-local descriptor: tanhp = tanh(chi_p * p). - **Default**: False ### of_ml_tanhq - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Semi-local descriptor: tanhq = tanh(chi_q * q). - **Default**: False ### of_ml_chi_p - **Type**: Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Hyperparameter chi_p: tanhp = tanh(chi_p * p). - **Default**: 1.0 ### of_ml_chi_q - **Type**: Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Hyperparameter chi_q: tanhq = tanh(chi_q * q). - **Default**: 1.0 ### of_ml_gammanl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor gammanl defined by the i-th kernel function. - **Default**: 0 ### of_ml_pnl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor pnl defined by the i-th kernel function. - **Default**: 0 ### of_ml_qnl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor qnl defined by the i-th kernel function. - **Default**: 0 ### of_ml_xi - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor xi defined by the i-th kernel function. - **Default**: 0 ### of_ml_tanhxi - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhxi defined by the i-th kernel function. - **Default**: 0 ### of_ml_tanhxi_nl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhxi_nl defined by the i-th kernel function. - **Default**: 0 ### of_ml_tanh_pnl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanh_pnl defined by the i-th kernel function. - **Default**: 0 ### of_ml_tanh_qnl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanh_qnl defined by the i-th kernel function. - **Default**: 0 ### of_ml_tanhp_nl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhp_nl defined by the i-th kernel function. - **Default**: 0 ### of_ml_tanhq_nl - **Type**: Vector of Integer -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhq_nl defined by the i-th kernel function. - **Default**: 0 ### of_ml_chi_xi - **Type**: Vector of Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_xi of non-local descriptor tanhxi defined by the i-th kernel function. - **Default**: 1.0 ### of_ml_chi_pnl - **Type**: Vector of Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_pnl of non-local descriptor tanh_pnl defined by the i-th kernel function. - **Default**: 1.0 ### of_ml_chi_qnl - **Type**: Vector of Real -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_qnl of non-local descriptor tanh_qnl defined by the i-th kernel function. - **Default**: 1.0 ### of_ml_local_test - **Type**: Boolean -- **Availability**: *OFDFT* +- **Availability**: *esolver_type==ofdft* - **Description**: FOR TEST. Read in the density, and output the F and Pauli potential. - **Default**: False @@ -3023,7 +3022,7 @@ ### of_cd - **Type**: Boolean -- **Availability**: *TDOFDFT* +- **Availability**: *esolver_type==tdofdft* - **Description**: Added the current dependent(CD) potential. (https://doi.org/10.1103/PhysRevB.98.144302) - True: Added the CD potential. - False: Not added the CD potential. @@ -3032,7 +3031,7 @@ ### of_mcd_alpha - **Type**: Real -- **Availability**: *TDOFDFT* +- **Availability**: *esolver_type==tdofdft* - **Description**: The value of the parameter alpha in modified CD potential method. mCDPotential=alpha*CDPotential (proposed in paper PhysRevB.98.144302) - **Default**: 1.0 @@ -3051,7 +3050,7 @@ ### dip_cor_flag - **Type**: Boolean -- **Availability**: *With dip_cor_flag = True and efield_flag = True.* +- **Availability**: *dip_cor_flag==true and efield_flag==true* - **Description**: Added a dipole correction to the bare ionic potential. - True: A dipole correction is also added to the bare ionic potential. - False: A dipole correction is not added to the bare ionic potential. @@ -3062,7 +3061,7 @@ ### efield_dir - **Type**: Integer -- **Availability**: *with efield_flag = True.* +- **Availability**: *efield_flag==true* - **Description**: The direction of the electric field or dipole correction is parallel to the reciprocal lattice vector, so the potential is constant in planes defined by FFT grid points, efield_dir can set to 0, 1 or 2. - 0: parallel to the first reciprocal lattice vector - 1: parallel to the second reciprocal lattice vector @@ -3072,21 +3071,21 @@ ### efield_pos_max - **Type**: Real -- **Availability**: *with efield_flag = True.* +- **Availability**: *efield_flag==true* - **Description**: Position of the maximum of the saw-like potential along crystal axis efield_dir, within the unit cell, 0 <= efield_pos_max < 1. - **Default**: Autoset to center of vacuum - width of vacuum / 20 ### efield_pos_dec - **Type**: Real -- **Availability**: *with efield_flag = True.* +- **Availability**: *efield_flag==true* - **Description**: Zone in the unit cell where the saw-like potential decreases, 0 < efield_pos_dec < 1. - **Default**: Autoset to width of vacuum / 10 ### efield_amp - **Type**: Real -- **Availability**: *with efield_flag = True.* +- **Availability**: *efield_flag==true* - **Description**: Amplitude of the electric field. The saw-like potential increases with slope efield_amp in the region from efield_pos_max+efield_pos_dec-1) to (efield_pos_max), then decreases until (efield_pos_max+efield_pos_dec), in units of the crystal vector efield_dir. > Note: The change of slope of this potential must be located in the empty region, or else unphysical forces will result. @@ -3304,7 +3303,7 @@ ### exx_symmetry_realspace - **Type**: Boolean -- **Availability**: *symmetry==1 and exx calculation (dft_fuctional==hse/hf/pbe0/scan0 or rpa==True)* +- **Availability**: *symmetry==1 and (dft_functional in [hse, hf, pbe0, scan0] or rpa==true)* - **Description**: - False: only rotate k-space density matrix D(k) from irreducible k-points to accelerate diagonalization - True: rotate both D(k) and Hexx(R) to accelerate both diagonalization and EXX calculation - **Default**: True @@ -3322,7 +3321,7 @@ ### exxace - **Type**: Boolean -- **Availability**: *exx_separate_loop==True.* +- **Availability**: *exx_separate_loop==true* - **Description**: Whether to use the ACE method (https://doi.org/10.1021/acs.jctc.6b00092) to accelerate the calculation the Fock exchange matrix. Should be set to true most of the time. - True: Use the ACE method to calculate the Fock exchange operator. - False: Use the traditional method to calculate the Fock exchange operator. @@ -3589,21 +3588,21 @@ ### dp_rescaling - **Type**: Real -- **Availability**: *esolver_type = dp.* +- **Availability**: *esolver_type==dp* - **Description**: Rescaling factor to use a temperature-dependent DP. Energy, stress and force calculated by DP will be multiplied by this factor. - **Default**: 1.0 ### dp_fparam - **Type**: Real -- **Availability**: *esolver_type = dp.* +- **Availability**: *esolver_type==dp* - **Description**: The frame parameter for dp potential. The array size is dim_fparam, then all frames are assumed to be provided with the same fparam. - **Default**: {} ### dp_aparam - **Type**: Real -- **Availability**: *esolver_type = dp.* +- **Availability**: *esolver_type==dp* - **Description**: The atomic parameter for dp potential. The array size can be (1) natoms x dim_aparam, then all frames are assumed to be provided with the same aparam; (2) dim_aparam, then all frames and atoms are assumed to be provided with the same aparam. - **Default**: {} @@ -3652,7 +3651,7 @@ ### md_csvr_tau - **Type**: Real -- **Availability**: *md_thermostat = csvr* +- **Availability**: *md_thermostat==csvr* - **Description**: The characteristic time scale for the CSVR (Canonical Sampling through Velocity Rescaling) thermostat. Larger values give weaker coupling, smaller values give stronger coupling. Recommended value: 100 * md_dt. - **Default**: 100.0 - **Unit**: fs @@ -3740,14 +3739,14 @@ ### yukawa_lambda - **Type**: Real -- **Availability**: *DFT+U with yukawa_potential = True.* +- **Availability**: *dft_plus_u==1 and yukawa_potential==true* - **Description**: The screen length of Yukawa potential. If left to default, the screen length will be calculated as an average of the entire system. It's better to stick to the default setting unless there is a very good reason. - **Default**: Calculated on the fly. ### uramping - **Type**: Real -- **Availability**: *DFT+U calculations with mixing_restart > 0.* +- **Availability**: *dft_plus_u==1 and mixing_restart>0* - **Description**: Once uramping > 0.15 eV. DFT+U calculations will start SCF with U = 0 eV, namely normal LDA/PBE calculations. Once SCF restarts when drho<mixing_restart, U value will increase by uramping eV. SCF will repeat above calcuations until U values reach target defined in hubbard_u. As for uramping=1.0 eV, the recommendations of mixing_restart is around 5e-4. - **Default**: -1.0. - **Unit**: eV @@ -3766,7 +3765,7 @@ ### onsite_radius - **Type**: Real -- **Availability**: *dft_plus_u is set to 1* +- **Availability**: *dft_plus_u==1* - **Description**: - The onsite_radius parameter facilitates modulation of the single-zeta portion of numerical atomic orbitals used for DFT+U projections. - The modulation algorithm applies a smooth truncation to the orbital tail followed by normalization. A representative profile is $f(r)=\frac{1}{2}\left[1+\operatorname{erf}\!\left(\frac{r_c-r}{\sigma}\right)\right]$, where $r_c$ is the cutoff radius and $\sigma=\gamma r_c$ controls smoothness. - **Default**: 3.0 @@ -3791,7 +3790,7 @@ ### sc_thr - **Type**: Real -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Convergence criterion of spin-constrained iteration (RMS) in uB - **Default**: 1.0e-6 - **Unit**: uB @@ -3799,21 +3798,21 @@ ### nsc - **Type**: Integer -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Maximal number of spin-constrained iteration - **Default**: 100 ### nsc_min - **Type**: Integer -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Minimum number of spin-constrained iteration - **Default**: 2 ### alpha_trial - **Type**: Real -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Initial trial step size for lambda in eV/uB^2 - **Default**: 0.01 - **Unit**: eV/uB^2 @@ -3821,7 +3820,7 @@ ### sccut - **Type**: Real -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Maximal step size for lambda in eV/uB - **Default**: 3.0 - **Unit**: eV/uB @@ -3829,21 +3828,21 @@ ### sc_drop_thr - **Type**: Real -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Convergence criterion ratio of lambda iteration in Spin-constrained DFT - **Default**: 1.0e-2 ### sc_scf_thr - **Type**: Real -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Density error threshold for inner loop of spin-constrained SCF - **Default**: 1.0e-4 ### sc_direction_only - **Type**: Boolean -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: When true, only the direction of the magnetic moment is constrained to the target direction, while the magnitude is allowed to vary freely. This is useful for studying magnetic anisotropy or when the magnitude of the moment is determined by the electronic structure rather than an external constraint. When false (default), both the direction and magnitude of the magnetic moment are constrained to the target values. @@ -3852,7 +3851,7 @@ ### sc_lambda_strategy - **Type**: String -- **Availability**: *sc_mag_switch is true* +- **Availability**: *sc_mag_switch==true* - **Description**: Lambda update strategy for spin-constrained DFT: - bfgs: BFGS quasi-Newton method - linear_response: linear response (Scheme B) @@ -3864,7 +3863,7 @@ ### sc_scan_lambda_start - **Type**: Float -- **Availability**: *sc_lambda_strategy is linear_scan* +- **Availability**: *sc_lambda_strategy==linear_scan* - **Description**: Starting lambda value for linear_scan strategy. Only used when sc_lambda_strategy=linear_scan. - **Default**: 0.0 - **Unit**: eV/uB @@ -3872,7 +3871,7 @@ ### sc_scan_lambda_end - **Type**: Float -- **Availability**: *sc_lambda_strategy is linear_scan* +- **Availability**: *sc_lambda_strategy==linear_scan* - **Description**: Ending lambda value for linear_scan strategy. Only used when sc_lambda_strategy=linear_scan. - **Default**: 1.0 - **Unit**: eV/uB @@ -3880,7 +3879,7 @@ ### sc_scan_steps - **Type**: Integer -- **Availability**: *sc_lambda_strategy is linear_scan* +- **Availability**: *sc_lambda_strategy==linear_scan* - **Description**: Number of lambda values to scan. Only used when sc_lambda_strategy=linear_scan. - **Default**: 20 @@ -3904,7 +3903,7 @@ ### vdw_d4_xc - **Type**: String -- **Availability**: *vdw_method is set to d4* +- **Availability**: *vdw_method==d4* - **Description**: Functional name used to load DFT-D4 damping parameters from the DFT-D4 library. If set to default, ABACUS infers the functional name from dft_functional or pseudopotential metadata. - **Default**: default @@ -3912,7 +3911,7 @@ ### vdw_d4_model - **Type**: String -- **Availability**: *vdw_method is set to d4* +- **Availability**: *vdw_method==d4* - **Description**: DFT-D4 dispersion model used by the external DFT-D4 library. Available options are: @@ -3923,38 +3922,38 @@ ### vdw_s6 - **Type**: String -- **Availability**: *vdw_method is set to d2, d3_0, or d3_bj* +- **Availability**: *vdw_method in [d2, d3_0, d3_bj]* - **Description**: This scale factor is used to optimize the interaction energy deviations in van der Waals (vdW) corrected calculations. The recommended values of this parameter are dependent on the chosen vdW correction method and the DFT functional being used. For DFT-D2, the recommended values are 0.75 (PBE), 1.2 (BLYP), 1.05 (B-P86), 1.0 (TPSS), and 1.05 (B3LYP). If not set, will use values of PBE functional. For DFT-D3, recommended values with different DFT functionals can be found on the here. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. ### vdw_s8 - **Type**: String -- **Availability**: *vdw_method is set to d3_0 or d3_bj* +- **Availability**: *vdw_method in [d3_0, d3_bj]* - **Description**: This scale factor is relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. ### vdw_a1 - **Type**: String -- **Availability**: *vdw_method is set to d3_0 or d3_bj* +- **Availability**: *vdw_method in [d3_0, d3_bj]* - **Description**: This damping function parameter is relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. ### vdw_a2 - **Type**: String -- **Availability**: *vdw_method is set to d3_0 or d3_bj* +- **Availability**: *vdw_method in [d3_0, d3_bj]* - **Description**: This damping function parameter is only relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. ### vdw_d - **Type**: Real -- **Availability**: *vdw_method is set to d2* +- **Availability**: *vdw_method==d2* - **Description**: Controls the damping rate of the damping function in the DFT-D2 method. - **Default**: 20 ### vdw_abc - **Type**: Boolean -- **Availability**: *vdw_method is set to d3_0 or d3_bj* +- **Availability**: *vdw_method in [d3_0, d3_bj]* - **Description**: Determines whether three-body terms are calculated for DFT-D3 methods. - True: ABACUS will calculate the three-body term. - False: The three-body term is not included. @@ -3963,7 +3962,7 @@ ### vdw_c6_file - **Type**: String -- **Availability**: *vdw_method is set to d2* +- **Availability**: *vdw_method==d2* - **Description**: Specifies the name of the file containing parameters for each element when using the D2 method. If not set, ABACUS uses the default parameters (Jnm6/mol) stored in the program. To manually set the parameters, provide a file containing the parameters. An example is given by: H 0.1 Si 9.0 @@ -3974,7 +3973,7 @@ ### vdw_c6_unit - **Type**: String -- **Availability**: *vdw_C6_file is not default* +- **Availability**: *vdw_C6_file!=default* - **Description**: Specifies the unit of the provided parameters in the D2 method. Available options are: - Jnm6/mol (J nm^6/mol) - eVA (eV Angstrom) @@ -3983,7 +3982,7 @@ ### vdw_r0_file - **Type**: String -- **Availability**: *vdw_method is set to d2* +- **Availability**: *vdw_method==d2* - **Description**: Specifies the name of the file containing parameters for each element when using the D2 method. If not set, ABACUS uses the default parameters (Angstrom) stored in the program. To manually set the parameters, provide a file containing the parameters. An example is given by: Li 1.0 Cl 2.0 @@ -3994,7 +3993,7 @@ ### vdw_r0_unit - **Type**: String -- **Availability**: *vdw_R0_file is not default* +- **Availability**: *vdw_R0_file!=default* - **Description**: Specifies the unit for the parameters in the D2 method when manually set by the user. Available options are: - A (Angstrom) - Bohr @@ -4011,14 +4010,14 @@ ### vdw_cutoff_radius - **Type**: String -- **Availability**: *vdw_cutoff_type is set to radius* +- **Availability**: *vdw_cutoff_type==radius* - **Description**: Defines the radius of the cutoff sphere when vdw_cutoff_type is set to radius. The default values depend on the chosen vdw_method. - **Unit**: defined by vdw_radius_unit (default Bohr) ### vdw_radius_unit - **Type**: String -- **Availability**: *vdw_cutoff_type is set to radius* +- **Availability**: *vdw_cutoff_type==radius* - **Description**: Specify the unit of vdw_cutoff_radius. Available options are: - A(Angstrom) - Bohr @@ -4027,14 +4026,14 @@ ### vdw_cutoff_period - **Type**: Integer Integer Integer -- **Availability**: *vdw_cutoff_type is set to period* +- **Availability**: *vdw_cutoff_type==period* - **Description**: The three integers supplied here explicitly specify the extent of the supercell in the directions of the three basis lattice vectors. - **Default**: 3 3 3 ### vdw_cn_thr - **Type**: Real -- **Availability**: *vdw_method is set to d3_0, d3_bj, or d4* +- **Availability**: *vdw_method in [d3_0, d3_bj, d4]* - **Description**: The cutoff radius when calculating coordination numbers. - **Default**: 40 - **Unit**: defined by vdw_cn_thr_unit (default: Bohr) @@ -4585,21 +4584,21 @@ ### cal_cond - **Type**: Boolean -- **Availability**: *basis_type = pw* +- **Availability**: *basis_type==pw* - **Description**: Whether to calculate electronic conductivities. - **Default**: False ### cond_che_thr - **Type**: Real -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: Control the error of Chebyshev expansions for conductivities. - **Default**: 1e-8 ### cond_dw - **Type**: Real -- **Availability**: *basis_type = pw* +- **Availability**: *basis_type==pw* - **Description**: Frequency interval () for frequency-dependent conductivities. - **Default**: 0.1 - **Unit**: eV @@ -4607,7 +4606,7 @@ ### cond_wcut - **Type**: Real -- **Availability**: *basis_type = pw* +- **Availability**: *basis_type==pw* - **Description**: Cutoff frequency for frequency-dependent conductivities. - **Default**: 10.0 - **Unit**: eV @@ -4615,7 +4614,7 @@ ### cond_dt - **Type**: Real -- **Availability**: *basis_type = pw* +- **Availability**: *basis_type==pw* - **Description**: Time interval () to integrate Onsager coefficients. - **Default**: 0.02 - **Unit**: a.u. @@ -4623,7 +4622,7 @@ ### cond_dtbatch - **Type**: Integer -- **Availability**: *esolver_type = sdft* +- **Availability**: *esolver_type==sdft* - **Description**: exp(iH\dt\cond_dtbatch) is expanded with Chebyshev expansion to calculate conductivities. It is faster but costs more memory. - If cond_dtbatch = 0: Autoset this parameter to make expansion orders larger than 100. - **Default**: 0 @@ -4639,7 +4638,7 @@ ### cond_fwhm - **Type**: Real -- **Availability**: *basis_type = pw* +- **Availability**: *basis_type==pw* - **Description**: FWHM for conductivities. For Gaussian smearing, ; for Lorentzian smearing, . - **Default**: 0.4 - **Unit**: eV @@ -4647,7 +4646,7 @@ ### cond_nonlocal - **Type**: Boolean -- **Availability**: *basis_type = pw* +- **Availability**: *basis_type==pw* - **Description**: Whether to consider nonlocal potential correction when calculating velocity matrix . - True: . - False: . @@ -4666,7 +4665,7 @@ ### eb_k - **Type**: Real -- **Availability**: *imp_sol is true.* +- **Availability**: *imp_sol==true* - **Description**: The relative permittivity of the bulk solvent, 80 for water - **Default**: 80 @@ -4881,7 +4880,7 @@ ### aims_nbasis - **Type**: A number(ntype) of Integers -- **Availability**: *ri_hartree_benchmark = aims* +- **Availability**: *ri_hartree_benchmark==aims* - **Description**: Atomic basis set size for each atom type (with the same order as in STRU) in FHI-aims. - **Default**: {} (empty list, where ABACUS use its own basis set size) diff --git a/docs/generate_input_main.py b/docs/generate_input_main.py index d0b7e2258c..05d17b4880 100644 --- a/docs/generate_input_main.py +++ b/docs/generate_input_main.py @@ -141,6 +141,36 @@ def format_description(desc: str) -> str: return result.strip() +def _availability_display(param): + """Return a display string for a parameter's availability. + + Prefers the exported structured fields (availability_kind / label) when + present; otherwise falls back to the raw ``availability`` string (e.g. for + older parameters.yaml files that only carry the string). + """ + # The raw string is already the canonical, user-facing representation + # (a boolean expression for Expression items, the human text otherwise). + return str(param.get('availability', '')) + + +def _availability_kind(param, parse_legacy): + """Return the structured availability kind for a parameter. + + Prefers ``availability_kind`` from the YAML. When it is absent (legacy + dump), classifies the raw string with the provided parser function. + """ + kind = param.get('availability_kind') + if kind in ('Expression', 'Label', 'Unstructured'): + return kind + avail = (param.get('availability', '') or '').strip() + if not avail: + return None + if parse_legacy is None: + return 'Unstructured' + parsed = parse_legacy(avail) + return parsed.kind if parsed.kind in ('Expression', 'Label', 'Unstructured') else 'Unstructured' + + def generate_parameter_markdown(param: Dict[str, str]) -> str: """ Generate markdown for a single parameter. @@ -154,7 +184,7 @@ def generate_parameter_markdown(param: Dict[str, str]) -> str: # Availability (before description, as in original format) if param.get('availability', '') != '': - availability_text = escape_md_text(str(param['availability'])) + availability_text = escape_md_text(_availability_display(param)) lines.append(f"- **Availability**: *{availability_text}*") # Description @@ -238,12 +268,17 @@ def _report_availability(all_params): Uses tools/03_code_analysis/availability_parser.py. This is a status report only; it does not modify the generated documentation. """ - try: - sys.path.insert(0, str(DOC_FOLDER.parent / 'tools' / '03_code_analysis')) - from availability_parser import parse_availability - except ImportError: - print("[availability] parser not found; skipping availability check") - return + # Prefer the structured availability_kind exported by abacus; only fall + # back to the text parser for older dumps that do not carry the field. + parse_legacy = None + if not any(p.get('availability_kind') for p in all_params if p.get('availability')): + try: + sys.path.insert(0, str(DOC_FOLDER.parent / 'tools' / '03_code_analysis')) + from availability_parser import parse_availability + parse_legacy = parse_availability + except ImportError: + print("[availability] parser not found; skipping availability check") + return counts = {"Expression": 0, "Label": 0, "Unstructured": 0} unstructured = [] @@ -252,12 +287,12 @@ def _report_availability(all_params): avail = p.get('availability', '') if not avail: continue - parsed = parse_availability(avail) - if parsed.kind in counts: - counts[parsed.kind] += 1 - if parsed.kind == "Unstructured": + kind = _availability_kind(p, parse_legacy) + if kind in counts: + counts[kind] += 1 + if kind == "Unstructured": unstructured.append((p.get('name', '?'), avail)) - elif parsed.kind == "Label": + elif kind == "Label": labelled += 1 print("[availability] non-empty:", sum(counts.values()), diff --git a/docs/parameters.yaml b/docs/parameters.yaml index 0c2494dee3..61f459d5c9 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -203,7 +203,7 @@ parameters: * 1: a memory saving technique will be used for many k point calculations. default_value: "0" unit: "" - availability: Used only for nscf calculations with plane wave basis set. + availability: calculation==nscf and basis_type==pw - name: cal_stress category: System variables type: Boolean @@ -220,7 +220,7 @@ parameters: * >0: it specifies the number of processes used for carrying out diagonalization. Must be less than or equal to total number of MPI processes. default_value: "0" unit: "" - availability: Used only for plane wave basis set. + availability: basis_type==pw - name: nbspline category: System variables type: Integer @@ -286,7 +286,7 @@ parameters: * double: double precision default_value: double unit: "" - availability: Used only for plane wave basis set. + availability: basis_type==pw - name: gint_precision category: System variables type: String @@ -297,7 +297,7 @@ parameters: * mix: mixed precision, starting from single precision and switching to double precision when the SCF residual becomes small enough default_value: double unit: "" - availability: Used only for LCAO basis set. + availability: basis_type==lcao - name: timer_enable_nvtx category: System variables type: Boolean @@ -417,7 +417,7 @@ parameters: Specify the random seed to initialize wave functions. Only positive integers are available. default_value: "0" unit: "" - availability: Only used for plane wave basis. + availability: basis_type==pw - name: diag_subspace category: Plane wave related variables type: Integer @@ -512,7 +512,7 @@ parameters: If restart_save is set to true and an electronic iteration is finished, calculations can be restarted from the charge density file, which are saved in the former calculation. default_value: "False" unit: "" - availability: Used only when numerical atomic orbitals are employed as basis set. + availability: basis_type==lcao - name: basis_type category: Electronic structure type: String @@ -760,7 +760,7 @@ parameters: At n-th iteration which is calculated by drho= 0.0" + availability: "mixing_restart>=0" - name: mixing_gg0 category: Electronic structure type: Real @@ -802,7 +802,7 @@ parameters: * >0: Angle mixing for the modulus with mixing_angle=1.0 default_value: "-10.0" unit: "" - availability: Only relevant for non-colinear calculations nspin=4. + availability: nspin==4 - name: mixing_tau category: Electronic structure type: Boolean @@ -812,7 +812,7 @@ parameters: * False: The kinetic energy density will not be mixed. default_value: "False" unit: "" - availability: Only relevant for meta-GGA calculations. + availability: "" - name: mixing_dftu category: Electronic structure type: Boolean @@ -822,7 +822,7 @@ parameters: * False: The occupation matrices will not be mixed. default_value: "False" unit: "" - availability: Only relevant for DFT+U calculations. + availability: dft_plus_u==1 - name: gamma_only category: Electronic structure type: Boolean @@ -834,7 +834,7 @@ parameters: Note: If gamma_only is set to 1, the KPT file will be overwritten. So make sure to turn off gamma_only for multi-k calculations. default_value: "0" unit: "" - availability: Only used in localized orbitals set + availability: basis_type==lcao - name: scf_nmax category: Electronic structure type: Integer @@ -951,7 +951,7 @@ parameters: Use case: When experimental or high-level theoretical results suggest that the SOC effect is weaker or stronger than what full-relativistic pseudopotentials predict, you can adjust this parameter to match the target behavior. default_value: "1.0" unit: "" - availability: Only works when lspinorb=true + availability: lspinorb==true - name: dfthalf_type category: Electronic structure type: Integer @@ -985,7 +985,7 @@ parameters: If TRUE, the wavefunctions at k-point will be initialized from the converged wavefunctions at the nearest k-point, which can speed up the SCF convergence. Only works for PW basis. default_value: "false" unit: "" - availability: Used only for plane wave basis set. + availability: basis_type==pw - name: pw_diag_nmax category: Plane wave related variables type: Integer @@ -993,7 +993,7 @@ parameters: Only useful when you use ks_solver = cg/dav/dav_subspace/bpcg. It indicates the maximal iteration number for cg/david/dav_subspace/bpcg method. default_value: "50" unit: "" - availability: "basis_type==pw, ks_solver==cg/dav/dav_subspace/bpcg" + availability: "basis_type==pw and ks_solver in [cg, dav, dav_subspace, bpcg]" - name: pw_diag_ndim category: Plane wave related variables type: Integer @@ -1180,7 +1180,7 @@ parameters: The paramether controls the size of the first conjugate gradient step. A smaller value means the first step along a new CG direction is smaller. This might be helpful for large systems, where it is safer to take a smaller initial step to prevent the collapse of the whole configuration. default_value: "0.5" unit: "" - availability: Only used when relax_method is cg 2 + availability: "relax_method in [cg 2]" - name: relax_nmax category: Geometry relaxation type: Integer @@ -1196,7 +1196,7 @@ parameters: When relax_method is set to cg_bfgs, a mixed algorithm of conjugate gradient (CG) and Broyden–Fletcher–Goldfarb–Shanno (BFGS) is used. The ions first move according to the CG method, then switch to the BFGS method when the maximum force on atoms is reduced below this threshold. default_value: "0.5" unit: eV/Angstrom - availability: Only used when relax_method is cg_bfgs + availability: relax_method==cg_bfgs - name: force_thr category: Geometry relaxation type: Real @@ -1228,7 +1228,7 @@ parameters: Controls the Wolfe condition for the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm used in geometry relaxation. This parameter sets the sufficient decrease condition (c1 in Wolfe conditions). For more information, see Phys. Chem. Chem. Phys., 2000, 2, 2177. default_value: "0.01" unit: "" - availability: Only used when relax_method is bfgs or cg_bfgs + availability: "relax_method in [bfgs, cg_bfgs]" - name: relax_bfgs_w2 category: Geometry relaxation type: Real @@ -1236,7 +1236,7 @@ parameters: Controls the Wolfe condition for the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm used in geometry relaxation. This parameter sets the curvature condition (c2 in Wolfe conditions). For more information, see Phys. Chem. Chem. Phys., 2000, 2, 2177. default_value: "0.5" unit: "" - availability: Only used when relax_method is bfgs or cg_bfgs + availability: "relax_method in [bfgs, cg_bfgs]" - name: relax_bfgs_rmax category: Geometry relaxation type: Real @@ -1244,7 +1244,7 @@ parameters: Maximum allowed total displacement of all atoms during geometry optimization. The sum of atomic displacements can increase during optimization steps but cannot exceed this value. default_value: "0.8" unit: Bohr - availability: Only used when relax_method is bfgs or cg_bfgs + availability: "relax_method in [bfgs, cg_bfgs]" - name: relax_bfgs_rmin category: Geometry relaxation type: Real @@ -1252,7 +1252,7 @@ parameters: Minimum allowed total displacement of all atoms. When the total atomic displacement falls below this value and force convergence is not achieved, the calculation will terminate. Note: This parameter is not used in the default BFGS algorithm (relax_method = bfgs 2 or bfgs). default_value: "1e-5" unit: Bohr - availability: Only used when relax_method is bfgs 1 (traditional BFGS) + availability: "relax_method in [bfgs 1]" - name: relax_bfgs_init category: Geometry relaxation type: Real @@ -1260,7 +1260,7 @@ parameters: Initial total displacement of all atoms in the first BFGS step. This sets the scale for the initial movement. default_value: "0.5" unit: Bohr - availability: Only used when relax_method is bfgs or cg_bfgs + availability: "relax_method in [bfgs, cg_bfgs]" - name: stress_thr category: Geometry relaxation type: Real @@ -1316,7 +1316,7 @@ parameters: [NOTE] For VASP users, see the ISIF correspondence table in the geometry optimization documentation. default_value: None unit: "" - availability: Only used when calculation is set to cell-relax + availability: calculation==cell-relax - name: fixed_ibrav category: Geometry relaxation type: Boolean @@ -1327,7 +1327,7 @@ parameters: [NOTE] Note: it is possible to use fixed_ibrav with fixed_axes, but please make sure you know what you are doing. For example, if we are doing relaxation of a simple cubic lattice (latname = "sc"), and we use fixed_ibrav along with fixed_axes = "volume", then the cell is never allowed to move and as a result, the relaxation never converges. When both are used, fixed_ibrav is applied first, then fixed_axes = "volume" rescaling is applied. default_value: "False" unit: "" - availability: Only used with relax_method = cg 2. A specific latname must be provided. + availability: "relax_method in [cg 2] and latname != none" - name: fixed_atoms category: Geometry relaxation type: Boolean @@ -1619,7 +1619,7 @@ parameters: Rescaling factor to use a temperature-dependent DP. Energy, stress and force calculated by DP will be multiplied by this factor. default_value: "1.0" unit: "" - availability: esolver_type = dp. + availability: esolver_type==dp - name: dp_fparam category: Molecular dynamics type: Real @@ -1627,7 +1627,7 @@ parameters: The frame parameter for dp potential. The array size is dim_fparam, then all frames are assumed to be provided with the same fparam. default_value: "{}" unit: "" - availability: esolver_type = dp. + availability: esolver_type==dp - name: dp_aparam category: Molecular dynamics type: Real @@ -1635,7 +1635,7 @@ parameters: The atomic parameter for dp potential. The array size can be (1) natoms x dim_aparam, then all frames are assumed to be provided with the same aparam; (2) dim_aparam, then all frames and atoms are assumed to be provided with the same aparam. default_value: "{}" unit: "" - availability: esolver_type = dp. + availability: esolver_type==dp - name: msst_direction category: Molecular dynamics type: Integer @@ -1694,7 +1694,7 @@ parameters: The characteristic time scale for the CSVR (Canonical Sampling through Velocity Rescaling) thermostat. Larger values give weaker coupling, smaller values give stronger coupling. Recommended value: 100 * md_dt. default_value: "100.0" unit: fs - availability: md_thermostat = csvr + availability: md_thermostat==csvr - name: md_tolerance category: Molecular dynamics type: Real @@ -1752,7 +1752,7 @@ parameters: * cpn5: CPN5 KEDF (automatically sets ml parameters) default_value: wt unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_method category: "OFDFT: orbital free density functional theory" type: String @@ -1763,7 +1763,7 @@ parameters: * tn: Truncated Newton algorithm. default_value: tn unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_conv category: "OFDFT: orbital free density functional theory" type: String @@ -1774,7 +1774,7 @@ parameters: * both: Both energy and potential must satisfy the convergence criterion. default_value: energy unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_tole category: "OFDFT: orbital free density functional theory" type: Real @@ -1782,7 +1782,7 @@ parameters: Tolerance of the energy change for determining the convergence. default_value: "2e-6" unit: Ry - availability: OFDFT + availability: esolver_type==ofdft - name: of_tolp category: "OFDFT: orbital free density functional theory" type: Real @@ -1790,7 +1790,7 @@ parameters: Tolerance of potential for determining the convergence. default_value: "1e-5" unit: Ry - availability: OFDFT + availability: esolver_type==ofdft - name: of_tf_weight category: "OFDFT: orbital free density functional theory" type: Real @@ -1798,7 +1798,7 @@ parameters: Weight of TF KEDF (kinetic energy density functional). default_value: "1.0" unit: "" - availability: "OFDFT with of_kinetic=tf, tf+, wt, ext-wt, xwm" + availability: "esolver_type==ofdft and of_kinetic in [tf, tf+, wt, ext-wt, xwm]" - name: of_vw_weight category: "OFDFT: orbital free density functional theory" type: Real @@ -1806,7 +1806,7 @@ parameters: Weight of vW KEDF (kinetic energy density functional). default_value: "1.0" unit: "" - availability: "OFDFT with of_kinetic=vw, tf+, wt, ext-wt, lkt, xwm" + availability: "esolver_type==ofdft and of_kinetic in [vw, tf+, wt, ext-wt, lkt, xwm]" - name: of_wt_alpha category: "OFDFT: orbital free density functional theory" type: Real @@ -1814,7 +1814,7 @@ parameters: Parameter alpha of WT KEDF (kinetic energy density functional). default_value: "" unit: "" - availability: "OFDFT with of_kinetic=wt, ext-wt" + availability: "esolver_type==ofdft and of_kinetic in [wt, ext-wt]" - name: of_wt_beta category: "OFDFT: orbital free density functional theory" type: Real @@ -1822,7 +1822,7 @@ parameters: Parameter beta of WT KEDF (kinetic energy density functional). default_value: "" unit: "" - availability: "OFDFT with of_kinetic=wt, ext-wt" + availability: "esolver_type==ofdft and of_kinetic in [wt, ext-wt]" - name: of_extwt_kappa category: "OFDFT: orbital free density functional theory" type: Real @@ -1830,7 +1830,7 @@ parameters: Parameter kappa for EXT-WT KEDF. default_value: "1.0 / (2.0 * std::pow(4./3., 1./3.) - 1.0)" unit: "" - availability: OFDFT with of_kinetic=ext-wt + availability: esolver_type==ofdft and of_kinetic==ext-wt - name: of_wt_rho0 category: "OFDFT: orbital free density functional theory" type: Real @@ -1838,7 +1838,7 @@ parameters: The average density of system. default_value: "0.0" unit: Bohr^-3 - availability: OFDFT with of_kinetic=wt + availability: esolver_type==ofdft and of_kinetic==wt - name: of_hold_rho0 category: "OFDFT: orbital free density functional theory" type: Boolean @@ -1848,7 +1848,7 @@ parameters: * False: rho0 will change if volume of system has changed. default_value: "False" unit: "" - availability: OFDFT with of_kinetic=wt + availability: esolver_type==ofdft and of_kinetic==wt - name: of_lkt_a category: "OFDFT: orbital free density functional theory" type: Real @@ -1856,7 +1856,7 @@ parameters: Parameter a of LKT KEDF (kinetic energy density functional). default_value: "1.3" unit: "" - availability: OFDFT with of_kinetic=lkt + availability: esolver_type==ofdft and of_kinetic==lkt - name: of_xwm_rho_ref category: "OFDFT: orbital free density functional theory" type: Real @@ -1864,7 +1864,7 @@ parameters: Reference charge density for XWM kinetic energy functional. If set to 0, the program will use average charge density. default_value: "0.0" unit: "" - availability: OFDFT with of_kinetic=xwm + availability: esolver_type==ofdft and of_kinetic==xwm - name: of_xwm_kappa category: "OFDFT: orbital free density functional theory" type: Real @@ -1872,7 +1872,7 @@ parameters: Parameter for XWM kinetic energy functional. See PHYSICAL REVIEW B 100, 205132 (2019) for optimal values. default_value: "0.0" unit: "" - availability: OFDFT with of_kinetic=xwm + availability: esolver_type==ofdft and of_kinetic==xwm - name: of_read_kernel category: "OFDFT: orbital free density functional theory" type: Boolean @@ -1882,7 +1882,7 @@ parameters: * False: The kernel of WT KEDF (kinetic energy density functional) will be filled from formula. default_value: "False" unit: "" - availability: OFDFT with of_kinetic=wt + availability: esolver_type==ofdft and of_kinetic==wt - name: of_kernel_file category: "OFDFT: orbital free density functional theory" type: String @@ -1890,7 +1890,7 @@ parameters: The name of WT kernel file. default_value: WTkernel.txt unit: "" - availability: OFDFT with of_read_kernel=True + availability: esolver_type==ofdft and of_read_kernel==true - name: of_full_pw category: "OFDFT: orbital free density functional theory" type: Boolean @@ -1900,7 +1900,7 @@ parameters: * False: Only use the planewaves inside ecut, the same as KSDFT. default_value: "True" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_full_pw_dim category: "OFDFT: orbital free density functional theory" type: Integer @@ -1913,7 +1913,7 @@ parameters: Note: Even dimensions may cause slight errors in FFT. It should be ignorable in ofdft calculation, but it may make Cardinal B-spline interpolation unstable, so please set of_full_pw_dim = 1 if nbspline != -1. default_value: "0" unit: "" - availability: OFDFT with of_full_pw = True + availability: esolver_type==ofdft and of_full_pw==true - name: of_ml_gene_data category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -1921,7 +1921,7 @@ parameters: Controls the generation of machine learning training data. When enabled, training data in .npy format will be saved in the directory OUT.${suffix}/. default_value: "False" unit: "" - availability: Used only for KSDFT with plane wave basis + availability: esolver_type==ksdft and basis_type==pw - name: of_ml_device category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: String @@ -1931,7 +1931,7 @@ parameters: * gpu: GPU default_value: cpu unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_feg category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Integer @@ -1942,7 +1942,7 @@ parameters: * 3: Incorporate the FEG limit by nonlinear transformation using softplus function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_nkernel category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Integer @@ -1950,7 +1950,7 @@ parameters: Number of kernel functions. default_value: "1" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_kernel category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -1961,7 +1961,7 @@ parameters: * 3: Truncated kinetic kernel (TKK), the file containing TKK is specified by of_ml_kernel_file. default_value: "1" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_kernel_scaling category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Real @@ -1969,7 +1969,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the RECIPROCAL of scaling parameter of the i-th kernel function. default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_yukawa_alpha category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Real @@ -1977,7 +1977,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the parameter alpha of i-th kernel function. ONLY used for Yukawa kernel function. default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_kernel_file category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of String @@ -1985,7 +1985,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the file containing the i-th kernel function. ONLY used for TKK. default_value: none unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_gamma category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -1993,7 +1993,7 @@ parameters: Local descriptor: gamma = (rho / rho0)^(1/3). default_value: "False" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_p category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -2001,7 +2001,7 @@ parameters: Semi-local descriptor: p = |nabla rho|^2 / [2 (3 pi^2)^(1/3) rho^(4/3)]^2. default_value: "False" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_q category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -2009,7 +2009,7 @@ parameters: Semi-local descriptor: q = nabla^2 rho / [4 (3 pi^2)^(2/3) rho^(5/3)]. default_value: "False" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanhp category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -2017,7 +2017,7 @@ parameters: Semi-local descriptor: tanhp = tanh(chi_p * p). default_value: "False" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanhq category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -2025,7 +2025,7 @@ parameters: Semi-local descriptor: tanhq = tanh(chi_q * q). default_value: "False" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_chi_p category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Real @@ -2033,7 +2033,7 @@ parameters: Hyperparameter chi_p: tanhp = tanh(chi_p * p). default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_chi_q category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Real @@ -2041,7 +2041,7 @@ parameters: Hyperparameter chi_q: tanhq = tanh(chi_q * q). default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_gammanl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2049,7 +2049,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor gammanl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_pnl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2057,7 +2057,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor pnl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_qnl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2065,7 +2065,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor qnl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_xi category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2073,7 +2073,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor xi defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanhxi category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2081,7 +2081,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhxi defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanhxi_nl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2089,7 +2089,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhxi_nl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanh_pnl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2097,7 +2097,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanh_pnl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanh_qnl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2105,7 +2105,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanh_qnl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanhp_nl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2113,7 +2113,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhp_nl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_tanhq_nl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Integer @@ -2121,7 +2121,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhq_nl defined by the i-th kernel function. default_value: "0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_chi_xi category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Real @@ -2129,7 +2129,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_xi of non-local descriptor tanhxi defined by the i-th kernel function. default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_chi_pnl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Real @@ -2137,7 +2137,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_pnl of non-local descriptor tanh_pnl defined by the i-th kernel function. default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_chi_qnl category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Vector of Real @@ -2145,7 +2145,7 @@ parameters: Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_qnl of non-local descriptor tanh_qnl defined by the i-th kernel function. default_value: "1.0" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: of_ml_local_test category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -2153,7 +2153,7 @@ parameters: FOR TEST. Read in the density, and output the F and Pauli potential. default_value: "False" unit: "" - availability: OFDFT + availability: esolver_type==ofdft - name: ml_exx category: "ML-KEDF: machine learning based kinetic energy density functional for OFDFT" type: Boolean @@ -2172,7 +2172,7 @@ parameters: * other: use 2 default_value: "2" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: nbands_sto category: Electronic structure (SDFT) type: Integer or string @@ -2183,7 +2183,7 @@ parameters: * all: All complete basis sets are used to replace stochastic orbitals with the Chebyshev method (CT), resulting in the same results as KSDFT without stochastic errors. default_value: "256" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: nche_sto category: Electronic structure (SDFT) type: Integer @@ -2191,7 +2191,7 @@ parameters: Chebyshev expansion orders for stochastic DFT. default_value: "100" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: emin_sto category: Electronic structure (SDFT) type: Real @@ -2199,7 +2199,7 @@ parameters: Trial energy to guess the lower bound of eigen energies of the Hamiltonian Operator. default_value: "0.0" unit: Ry - availability: esolver_type = sdft + availability: esolver_type==sdft - name: emax_sto category: Electronic structure (SDFT) type: Real @@ -2207,7 +2207,7 @@ parameters: Trial energy to guess the upper bound of eigen energies of the Hamiltonian Operator. default_value: "0.0" unit: Ry - availability: esolver_type = sdft + availability: esolver_type==sdft - name: seed_sto category: Electronic structure (SDFT) type: Integer @@ -2219,7 +2219,7 @@ parameters: * -1: the seed is decided by time(NULL). default_value: "0" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: initsto_ecut category: Electronic structure (SDFT) type: Real @@ -2227,7 +2227,7 @@ parameters: Stochastic wave functions are initialized in a large box generated by "4*initsto_ecut". initsto_ecut should be larger than ecutwfc. In this method, SDFT results are the same when using different cores. Besides, coefficients of the same G are the same when ecutwfc is rising to initsto_ecut. If it is smaller than ecutwfc, it will be turned off. default_value: "0.0" unit: Ry - availability: esolver_type = sdft + availability: esolver_type==sdft - name: initsto_freq category: Electronic structure (SDFT) type: Integer @@ -2237,7 +2237,7 @@ parameters: * 0: Never change stochastic orbitals. default_value: "0" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: npart_sto category: Electronic structure (SDFT) type: Integer @@ -2245,7 +2245,7 @@ parameters: Make memory cost to 1/npart_sto times of the previous one when running the post process of SDFT like DOS or conductivities. default_value: "1" unit: "" - availability: method_sto = 2 and out_dos = 1 or cal_cond = True + availability: method_sto==2 and out_dos==1 or cal_cond==true - name: deepks_out_labels category: DeePKS type: Integer @@ -2258,7 +2258,7 @@ parameters: [NOTE] When deepks_out_labels equals 1, the path of a numerical descriptor (an orb file) is needed to be specified under the NUMERICAL_DESCRIPTOR tag in the STRU file. This is not needed when deepks_out_labels equals 2. default_value: "0" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: deepks_out_freq_elec category: DeePKS type: Integer @@ -2266,7 +2266,7 @@ parameters: When deepks_out_freq_elec is greater than 0, print labels and descriptors for DeePKS in OUT.${suffix}/DeePKS_Labels_Elec per deepks_out_freq_elec electronic iterations, with suffix _e* to distinguish different steps. Often used with deepks_out_labels equals 1. default_value: "0" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: deepks_out_base category: DeePKS type: String @@ -2274,7 +2274,7 @@ parameters: Print labels and descriptors calculated by base functional ( determined by deepks_out_base ) and target functional ( determined by dft_functional ) for DeePKS in per deepks_out_freq_elec electronic iterations. The SCF process, labels and descriptors output of the target functional are all consistent with those when the target functional is used alone. The only additional output under this configuration is the labels of the base functional. Often used with deepks_out_labels equals 1. default_value: None unit: "" - availability: Numerical atomic orbital basis and deepks_out_freq_elec is greater than 0 + availability: "basis_type==lcao and deepks_out_freq_elec>0" - name: deepks_scf category: DeePKS type: Boolean @@ -2284,7 +2284,7 @@ parameters: [NOTE] A trained, traced model file is needed. default_value: "False" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: deepks_equiv category: DeePKS type: Boolean @@ -2294,7 +2294,7 @@ parameters: [NOTE] The equivariant version of DeePKS-kit is still under development, so this feature is currently only intended for internal usage. default_value: "False" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: deepks_model category: DeePKS type: String @@ -2302,7 +2302,7 @@ parameters: the path of the trained, traced neural network model file generated by deepks-kit default_value: None unit: "" - availability: Numerical atomic orbital basis and deepks_scf is true + availability: basis_type==lcao and deepks_scf==true - name: bessel_descriptor_lmax category: DeePKS type: Integer @@ -2310,7 +2310,7 @@ parameters: the maximum angular momentum of the Bessel functions generated as the projectors in DeePKS - NOte: To generate such projectors, set calculation type to gen_bessel in ABACUS. See also calculation. default_value: "2" unit: "" - availability: gen_bessel calculation + availability: calculation==gen_bessel - name: bessel_descriptor_ecut category: DeePKS type: String @@ -2318,7 +2318,7 @@ parameters: energy cutoff of Bessel functions default_value: same as ecutwfc unit: Ry - availability: gen_bessel calculation + availability: calculation==gen_bessel - name: bessel_descriptor_tolerence category: DeePKS type: Real @@ -2326,7 +2326,7 @@ parameters: tolerance for searching the zeros of Bessel functions default_value: "1.0e-12" unit: "" - availability: gen_bessel calculation + availability: calculation==gen_bessel - name: bessel_descriptor_rcut category: DeePKS type: Real @@ -2334,7 +2334,7 @@ parameters: cutoff radius of Bessel functions default_value: "6.0" unit: Bohr - availability: gen_bessel calculation + availability: calculation==gen_bessel - name: bessel_descriptor_smooth category: DeePKS type: Boolean @@ -2342,7 +2342,7 @@ parameters: smooth the Bessel functions at radius cutoff default_value: "False" unit: "" - availability: gen_bessel calculation + availability: calculation==gen_bessel - name: bessel_descriptor_sigma category: DeePKS type: Real @@ -2350,7 +2350,7 @@ parameters: smooth parameter at the cutoff radius of projectors default_value: "0.1" unit: Bohr - availability: gen_bessel calculation + availability: calculation==gen_bessel - name: deepks_bandgap category: DeePKS type: Integer @@ -2362,7 +2362,7 @@ parameters: * 3: Used for systems containing H atoms. Here HOMO is defined as the max occupation except H atoms and the bandgap label is the energy between HOMO and (HOMO + 1) default_value: "0" unit: "" - availability: Numerical atomic orbital basis and deepks_scf is true + availability: basis_type==lcao and deepks_scf==true - name: deepks_band_range category: DeePKS type: "Integer*2" @@ -2372,7 +2372,7 @@ parameters: * deepks_bandgap is 2: Bandgap labels are energies between HOMO and all states in range [LUMO + deepks_band_range[0], LUMO + deepks_band_range[1]] (Thus there are deepks_band_range[1] - deepks_band_range[0] + 1 bandgaps in total). If HOMO is included in the setting range, it will be ignored since it will always be zero and has no valuable messages (deepks_band_range[1] - deepks_band_range[0] bandgaps in this case). NOTICE: The set range can be greater than, less than, or include the value of HOMO. In the bandgap label, we always calculate the energy of the state in the set range minus the energy of HOMO state, so the bandgap can be negative if the state is lower than HOMO. default_value: "-1 0" unit: "" - availability: "Numerical atomic orbital basis, deepks_scf is true, and deepks_bandgap is 1 or 2" + availability: "basis_type==lcao and deepks_scf==true and deepks_bandgap in [1, 2]" - name: deepks_v_delta category: DeePKS type: Integer @@ -2384,7 +2384,7 @@ parameters: * deepks_v_delta = -2: deepks_phialpha_r.npy and deepks_gevdm.npy, which can be used to calculate deepks_vdrpre.npy. A recommanded method for memory saving. default_value: "0" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: deepks_out_unittest category: DeePKS type: Boolean @@ -2758,7 +2758,7 @@ parameters: * False: Not added the CD potential. default_value: "False" unit: "" - availability: TDOFDFT + availability: esolver_type==tdofdft - name: of_mcd_alpha category: "TDOFDFT: time dependent orbital free density functional theory" type: Real @@ -2766,7 +2766,7 @@ parameters: The value of the parameter alpha in modified CD potential method. mCDPotential=alpha*CDPotential (proposed in paper PhysRevB.98.144302) default_value: "1.0" unit: "" - availability: TDOFDFT + availability: esolver_type==tdofdft - name: xc_kernel category: Linear Response TDDFT (Under Development Feature) type: String @@ -2984,7 +2984,7 @@ parameters: * In 3.10-LTS, the corresponding keyword is out_dm, and the output files are SPIN1_DM and SPIN2_DM, etc. default_value: "False" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_dmr category: Output information type: "Boolean \\[Integer\\](optional)" @@ -2996,7 +2996,7 @@ parameters: [NOTE] In the 3.10-LTS version, the parameter is named out_dm1, and the file names are data-DMR-sparse_SPIN0.csr and data-DMR-sparse_SPIN1.csr, etc. default_value: "False" unit: "" - availability: Numerical atomic orbital basis (multi-k points) + availability: basis_type==lcao and gamma_only==0 - name: out_wfc_pw category: Output information type: Integer @@ -3015,7 +3015,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file names are WAVEFUNC1.dat, WAVEFUNC2.dat, etc. default_value: "0" unit: "" - availability: "Output electronic wave functions in plane wave basis, or transform the real-space electronic wave function into plane wave basis (see get_wf option in calculation with NAO basis)" + availability: basis_type==pw or (basis_type==lcao and calculation==get_wf) - name: out_wfc_lcao category: Output information type: Integer @@ -3036,7 +3036,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file names are WFC_NAO_GAMMA1_ION1.txt and WFC_NAO_K1_ION1.txt, etc. default_value: "0" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_dos category: Output information type: Integer @@ -3129,7 +3129,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file names are data-0-H and data-0-S, etc. default_value: 0 8 unit: Ry - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_mat_hs category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3137,7 +3137,7 @@ parameters: Legacy alias for out_hsk 1, which outputs Hamiltonian and overlap matrices in reciprocal space for each k-point. The optional second integer controls text precision. If both out_hsk and out_mat_hs are present, out_hsk takes precedence. default_value: False 8 unit: Ry - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_hsr category: Output information type: "Integer \\[Integer\\](optional)" @@ -3153,7 +3153,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file names are data-HR-sparse_SPIN0.csr and data-SR-sparse_SPIN0.csr, etc. default_value: 0 8 unit: Ry - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_mat_hs2 category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3161,7 +3161,7 @@ parameters: Legacy alias for out_hsr 1, which outputs Hamiltonian and overlap matrices in real space indexed by the Bravais lattice vector R. The optional second integer controls text precision. If both out_hsr and out_mat_hs2 are present, out_hsr takes precedence. default_value: False 8 unit: Ry - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_mat_tk category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3171,7 +3171,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file names are data-TR-sparse_SPIN0.csr, etc. default_value: "False [8]" unit: Ry - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_mat_r category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3181,7 +3181,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file name is data-rR-sparse.csr. default_value: False 8 unit: Bohr - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_mat_t category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3191,7 +3191,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr. default_value: False 8 unit: Ry - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_mat_dh category: Output information type: Integer @@ -3203,7 +3203,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on. default_value: 0 8 unit: Ry/Bohr - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_mat_dh_t category: Output information type: Integer @@ -3333,7 +3333,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on. default_value: False 8 unit: Ry/Bohr - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_mat_xc category: Output information type: Boolean @@ -3343,7 +3343,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file name is k-$k-Vxc and so on. default_value: "False" unit: Ry - availability: Numerical atomic orbital (NAO) and NAO-in-PW basis + availability: "basis_type in [lcao, lcao_in_pw]" - name: out_mat_xc2 category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3353,7 +3353,7 @@ parameters: [NOTE] In the 3.10-LTS version, the file name is Vxc_R_spin$s and so on. default_value: False 8 unit: Ry - availability: Numerical atomic orbital (NAO) basis + availability: basis_type==lcao - name: out_mat_l category: Output information type: "Boolean \\[Integer\\](optional)" @@ -3361,7 +3361,7 @@ parameters: Whether to print the expectation value of the angular momentum operator , , and in the basis of the localized atomic orbitals. The files are named OUT.{suffix}_Lx.dat, OUT.{suffix}_Ly.dat, and OUT.{suffix}_Lz.dat. The second integer controls the precision of the output. default_value: False 8 unit: "" - availability: Numerical atomic orbital (NAO) basis + availability: basis_type==lcao - name: out_xc_r category: Output information type: "Integer \\[Integer\\](optional)" @@ -3386,7 +3386,7 @@ parameters: Whether to print the band energy terms separately in the file OUT.{term}_out.dat. The terms include the kinetic, pseudopotential (local + nonlocal), Hartree and exchange-correlation (including exact exchange if calculated). default_value: "False" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_hr_npz category: Output information type: Boolean @@ -3394,7 +3394,7 @@ parameters: Whether to print Hamiltonian matrices H(R) in NPZ format as hrs1_nao.npz and, for nspin = 2, hrs2_nao.npz. This feature does not work for gamma-only calculations. default_value: "False" unit: Ry - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_hsr_npz category: Output information type: Boolean @@ -3402,7 +3402,7 @@ parameters: Legacy alias for out_hsr 3, writing hrs1_nao.npz, hrs2_nao.npz when needed, and sr_nao.npz. If both out_hsr and out_hsr_npz are present, out_hsr takes precedence. Gamma-only calculations write the folded R = (0, 0, 0) representation. default_value: "False" unit: Ry - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_dm_npz category: Output information type: Boolean @@ -3410,7 +3410,7 @@ parameters: Whether to print density matrices DM(R) in npz format. This feature does not work for gamma-only calculations. default_value: "False" unit: "" - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_mul category: Output information type: Boolean @@ -3418,7 +3418,7 @@ parameters: Whether to print the Mulliken population analysis result into OUT.${suffix}/mulliken.txt. In molecular dynamics calculations, the output frequency is controlled by out_freq_ion. default_value: "False" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: out_app_flag category: Output information type: Boolean @@ -3426,7 +3426,7 @@ parameters: Whether to output r(R), H(R), S(R), T(R), dH(R), dS(R), and wfc matrices in an append manner during molecular dynamics calculations. Check input parameters out_mat_r, out_hsr, out_mat_t, out_mat_dh, out_hsk and out_wfc_lcao for more information. default_value: "true" unit: "" - availability: Numerical atomic orbital basis (not gamma-only algorithm) + availability: basis_type==lcao and gamma_only==0 - name: out_ndigits category: Output information type: Integer @@ -3434,7 +3434,7 @@ parameters: Controls the length of decimal part of output data, such as charge density, Hamiltonian matrix, Overlap matrix and so on. default_value: "8" unit: "" - availability: out_hsk 1 case presently. + availability: out_hsk==1 - name: out_element_info category: Output information type: Boolean @@ -3453,7 +3453,7 @@ parameters: If EXX(exact exchange) is calculated (i.e. dft_fuctional==hse/hf/pbe0/scan0 or rpa==True), the Hexx(R) files for each processor will also be saved in the above folder, which can be read in EXX calculation with restart_load==True. default_value: "False" unit: "" - availability: Numerical atomic orbital basis + availability: basis_type==lcao - name: rpa category: Output information type: Boolean @@ -3471,7 +3471,7 @@ parameters: Specifies the electronic states to calculate the charge densities with state index for, using a space-separated string of 0s and 1s. Each digit in the string corresponds to a state, starting from the first state. A 1 indicates that the charge density should be calculated for that state, while a 0 means the state will be ignored. The parameter allows a compact and flexible notation (similar to ocp_set), for example the syntax 1 4*0 5*1 0 is used to denote the selection of states: 1 means calculate for the first state, 4*0 skips the next four states, 5*1 means calculate for the following five states, and the final 0 skips the next state. It's essential that the total count of states does not exceed the total number of states (nbands); otherwise, it results in an error, and the process exits. The input string must contain only numbers and the asterisk (*) for repetition, ensuring correct format and intention of state selection. The outputs comprise multiple .cube files following the naming convention pchgi[state]s[spin]k[kpoint].cube. default_value: none unit: "" - availability: "For both PW and LCAO. When basis_type = lcao, used when calculation = get_pchg." + availability: basis_type==pw or (basis_type==lcao and calculation==get_pchg) - name: out_wfc_norm category: Output information type: String @@ -3479,7 +3479,7 @@ parameters: Specifies the electronic states to calculate the real-space wave function modulus (norm, or known as the envelope function) with state index. The syntax and state selection rules are identical to out_pchg, but the output is the norm of the wave function. The outputs comprise multiple .cube files following the naming convention wfi[state]s[spin]k[kpoint].cube. default_value: none unit: "" - availability: "For both PW and LCAO. When basis_type = lcao, used when calculation = get_wf." + availability: basis_type==pw or (basis_type==lcao and calculation==get_wf) - name: out_wfc_re_im category: Output information type: String @@ -3487,7 +3487,7 @@ parameters: Specifies the electronic states to calculate the real and imaginary parts of the wave function with state index. The syntax and state selection rules are identical to out_pchg, but the output contains both the real and imaginary components of the wave function. The outputs comprise multiple .cube files following the naming convention wfi[state]s[spin]k[kpoint][re/im].cube. default_value: none unit: "" - availability: "For both PW and LCAO. When basis_type = lcao, used when calculation = get_wf." + availability: basis_type==pw or (basis_type==lcao and calculation==get_wf) - name: if_separate_k category: Output information type: Boolean @@ -3495,7 +3495,7 @@ parameters: Specifies whether to write the partial charge densities for all k-points to individual files or merge them. Warning: Enabling symmetry may produce unwanted results due to reduced k-point weights and symmetry operations in real space. Therefore when calculating partial charge densities, if you are not sure what you want exactly, it is strongly recommended to set symmetry = -1. It is noteworthy that your symmetry setting should remain the same as that in the SCF procedure. default_value: "false" unit: "" - availability: "For both PW and LCAO. When basis_type = pw, used if out_pchg is set. When basis_type = lcao, used only when calculation = get_pchg and gamma_only = 0." + availability: "basis_type==pw and out_pchg!=none or basis_type==lcao and calculation==get_pchg and gamma_only==0" - name: out_elf category: Output information type: "Integer \\[Integer\\](optional)" @@ -3516,7 +3516,7 @@ parameters: In molecular dynamics calculations, the output frequency is controlled by out_freq_ion. default_value: 0 3 unit: "" - availability: Only for Kohn-Sham DFT and Orbital Free DFT. + availability: "esolver_type in [ksdft, ofdft]" - name: out_spillage category: Output information type: Integer @@ -3524,7 +3524,7 @@ parameters: This output is only intentively needed by the ABACUS numerical atomic orbital generation workflow. This parameter is used to control whether to output the overlap integrals between truncated spherical Bessel functions (TSBFs) and plane-wave basis expanded wavefunctions (named as OVERLAP_Q), and between TSBFs (named as OVERLAP_Sq), also their first order derivatives. The output files are named starting with orb_matrix. A value of 2 would enable the output. default_value: "0" unit: "" - availability: Only for Kohn-Sham DFT with plane-wave basis. + availability: esolver_type==ksdft and basis_type==pw - name: out_dipole category: "RT-TDDFT: Real-Time Time-Dependent Density Functional Theory" type: Boolean @@ -3591,7 +3591,7 @@ parameters: The directory to save the spillage files. default_value: "\"./\"" unit: "" - availability: Used only for plane wave basis set. + availability: basis_type==pw - name: dos_edelta_ev category: Density of states type: Real @@ -3669,7 +3669,7 @@ parameters: Whether to calculate electronic conductivities. default_value: "False" unit: "" - availability: basis_type = pw + availability: basis_type==pw - name: cond_che_thr category: Electronic conductivities type: Real @@ -3677,7 +3677,7 @@ parameters: Control the error of Chebyshev expansions for conductivities. default_value: "1e-8" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: cond_dw category: Electronic conductivities type: Real @@ -3685,7 +3685,7 @@ parameters: Frequency interval () for frequency-dependent conductivities. default_value: "0.1" unit: eV - availability: basis_type = pw + availability: basis_type==pw - name: cond_wcut category: Electronic conductivities type: Real @@ -3693,7 +3693,7 @@ parameters: Cutoff frequency for frequency-dependent conductivities. default_value: "10.0" unit: eV - availability: basis_type = pw + availability: basis_type==pw - name: cond_dt category: Electronic conductivities type: Real @@ -3701,7 +3701,7 @@ parameters: Time interval () to integrate Onsager coefficients. default_value: "0.02" unit: a.u. - availability: basis_type = pw + availability: basis_type==pw - name: cond_dtbatch category: Electronic conductivities type: Integer @@ -3710,7 +3710,7 @@ parameters: * If cond_dtbatch = 0: Autoset this parameter to make expansion orders larger than 100. default_value: "0" unit: "" - availability: esolver_type = sdft + availability: esolver_type==sdft - name: cond_smear category: Electronic conductivities type: Integer @@ -3728,7 +3728,7 @@ parameters: FWHM for conductivities. For Gaussian smearing, ; for Lorentzian smearing, . default_value: "0.4" unit: eV - availability: basis_type = pw + availability: basis_type==pw - name: cond_nonlocal category: Electronic conductivities type: Boolean @@ -3738,7 +3738,7 @@ parameters: * False: . default_value: "True" unit: "" - availability: basis_type = pw + availability: basis_type==pw - name: berry_phase category: Berry phase and wannier90 interface type: Boolean @@ -3869,7 +3869,7 @@ parameters: [NOTE] Note: If you do not want any electric field, the parameter efield_amp should be set to zero. This should ONLY be used in a slab geometry for surface calculations, with the discontinuity FALLING IN THE EMPTY SPACE. default_value: "False" unit: "" - availability: With dip_cor_flag = True and efield_flag = True. + availability: dip_cor_flag==true and efield_flag==true - name: efield_dir category: Electric field and dipole correction type: Integer @@ -3880,7 +3880,7 @@ parameters: * 2: parallel to the third reciprocal lattice vector default_value: "2" unit: "" - availability: with efield_flag = True. + availability: efield_flag==true - name: efield_pos_max category: Electric field and dipole correction type: Real @@ -3888,7 +3888,7 @@ parameters: Position of the maximum of the saw-like potential along crystal axis efield_dir, within the unit cell, 0 <= efield_pos_max < 1. default_value: Autoset to center of vacuum - width of vacuum / 20 unit: "" - availability: with efield_flag = True. + availability: efield_flag==true - name: efield_pos_dec category: Electric field and dipole correction type: Real @@ -3896,7 +3896,7 @@ parameters: Zone in the unit cell where the saw-like potential decreases, 0 < efield_pos_dec < 1. default_value: Autoset to width of vacuum / 10 unit: "" - availability: with efield_flag = True. + availability: efield_flag==true - name: efield_amp category: Electric field and dipole correction type: Real @@ -3906,7 +3906,7 @@ parameters: [NOTE] Note: The change of slope of this potential must be located in the empty region, or else unphysical forces will result. default_value: "0.0" unit: "a.u., 1 a.u. = 51.4220632*10^10 V/m." - availability: with efield_flag = True. + availability: efield_flag==true - name: gate_flag category: Gate field (compensating charge) type: Boolean @@ -3974,7 +3974,7 @@ parameters: The relative permittivity of the bulk solvent, 80 for water default_value: "80" unit: "" - availability: imp_sol is true. + availability: imp_sol==true - name: tau category: Implicit solvation model type: Real @@ -4022,7 +4022,7 @@ parameters: If set to default, ABACUS infers the functional name from dft_functional or pseudopotential metadata. default_value: default unit: "" - availability: vdw_method is set to d4 + availability: vdw_method==d4 - name: vdw_d4_model category: vdW correction type: String @@ -4033,7 +4033,7 @@ parameters: * d4s: smooth D4S model default_value: "d4" unit: "" - availability: vdw_method is set to d4 + availability: vdw_method==d4 - name: vdw_s6 category: vdW correction type: String @@ -4041,7 +4041,7 @@ parameters: This scale factor is used to optimize the interaction energy deviations in van der Waals (vdW) corrected calculations. The recommended values of this parameter are dependent on the chosen vdW correction method and the DFT functional being used. For DFT-D2, the recommended values are 0.75 (PBE), 1.2 (BLYP), 1.05 (B-P86), 1.0 (TPSS), and 1.05 (B3LYP). If not set, will use values of PBE functional. For DFT-D3, recommended values with different DFT functionals can be found on the here. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. default_value: "" unit: "" - availability: "vdw_method is set to d2, d3_0, or d3_bj" + availability: "vdw_method in [d2, d3_0, d3_bj]" - name: vdw_s8 category: vdW correction type: String @@ -4049,7 +4049,7 @@ parameters: This scale factor is relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. default_value: "" unit: "" - availability: vdw_method is set to d3_0 or d3_bj + availability: "vdw_method in [d3_0, d3_bj]" - name: vdw_a1 category: vdW correction type: String @@ -4057,7 +4057,7 @@ parameters: This damping function parameter is relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. default_value: "" unit: "" - availability: vdw_method is set to d3_0 or d3_bj + availability: "vdw_method in [d3_0, d3_bj]" - name: vdw_a2 category: vdW correction type: String @@ -4065,7 +4065,7 @@ parameters: This damping function parameter is only relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value. default_value: "" unit: "" - availability: vdw_method is set to d3_0 or d3_bj + availability: "vdw_method in [d3_0, d3_bj]" - name: vdw_d category: vdW correction type: Real @@ -4073,7 +4073,7 @@ parameters: Controls the damping rate of the damping function in the DFT-D2 method. default_value: "20" unit: "" - availability: vdw_method is set to d2 + availability: vdw_method==d2 - name: vdw_abc category: vdW correction type: Boolean @@ -4083,7 +4083,7 @@ parameters: * False: The three-body term is not included. default_value: "False" unit: "" - availability: vdw_method is set to d3_0 or d3_bj + availability: "vdw_method in [d3_0, d3_bj]" - name: vdw_c6_file category: vdW correction type: String @@ -4095,7 +4095,7 @@ parameters: Namely, each line contains the element name and the corresponding parameter. default_value: default unit: "" - availability: vdw_method is set to d2 + availability: vdw_method==d2 - name: vdw_c6_unit category: vdW correction type: String @@ -4105,7 +4105,7 @@ parameters: * eVA (eV Angstrom) default_value: Jnm6/mol unit: "" - availability: vdw_C6_file is not default + availability: "vdw_C6_file!=default" - name: vdw_r0_file category: vdW correction type: String @@ -4117,7 +4117,7 @@ parameters: Namely, each line contains the element name and the corresponding parameter. default_value: default unit: "" - availability: vdw_method is set to d2 + availability: vdw_method==d2 - name: vdw_r0_unit category: vdW correction type: String @@ -4127,7 +4127,7 @@ parameters: * Bohr default_value: "A" unit: "" - availability: vdw_R0_file is not default + availability: "vdw_R0_file!=default" - name: vdw_cutoff_type category: vdW correction type: String @@ -4145,7 +4145,7 @@ parameters: Defines the radius of the cutoff sphere when vdw_cutoff_type is set to radius. The default values depend on the chosen vdw_method. default_value: "" unit: defined by vdw_radius_unit (default Bohr) - availability: vdw_cutoff_type is set to radius + availability: vdw_cutoff_type==radius - name: vdw_radius_unit category: vdW correction type: String @@ -4155,7 +4155,7 @@ parameters: * Bohr default_value: Bohr unit: "" - availability: vdw_cutoff_type is set to radius + availability: vdw_cutoff_type==radius - name: vdw_cutoff_period category: vdW correction type: Integer Integer Integer @@ -4163,7 +4163,7 @@ parameters: The three integers supplied here explicitly specify the extent of the supercell in the directions of the three basis lattice vectors. default_value: 3 3 3 unit: "" - availability: vdw_cutoff_type is set to period + availability: vdw_cutoff_type==period - name: vdw_cn_thr category: vdW correction type: Real @@ -4171,7 +4171,7 @@ parameters: The cutoff radius when calculating coordination numbers. default_value: "40" unit: "defined by vdw_cn_thr_unit (default: Bohr)" - availability: "vdw_method is set to d3_0, d3_bj, or d4" + availability: "vdw_method in [d3_0, d3_bj, d4]" - name: vdw_cn_thr_unit category: vdW correction type: String @@ -4378,7 +4378,7 @@ parameters: * True: rotate both D(k) and Hexx(R) to accelerate both diagonalization and EXX calculation default_value: "True" unit: "" - availability: symmetry==1 and exx calculation (dft_fuctional==hse/hf/pbe0/scan0 or rpa==True) + availability: "symmetry==1 and (dft_functional in [hse, hf, pbe0, scan0] or rpa==true)" - name: out_ri_cv category: Exact Exchange (LCAO) type: Boolean @@ -4445,7 +4445,7 @@ parameters: The screen length of Yukawa potential. If left to default, the screen length will be calculated as an average of the entire system. It's better to stick to the default setting unless there is a very good reason. default_value: Calculated on the fly. unit: "" - availability: DFT+U with yukawa_potential = True. + availability: dft_plus_u==1 and yukawa_potential==true - name: uramping category: DFT+U correction type: Real @@ -4453,7 +4453,7 @@ parameters: Once uramping > 0.15 eV. DFT+U calculations will start SCF with U = 0 eV, namely normal LDA/PBE calculations. Once SCF restarts when drho 0." + availability: "dft_plus_u==1 and mixing_restart>0" - name: omc category: DFT+U correction type: Integer @@ -4475,7 +4475,7 @@ parameters: * The modulation algorithm applies a smooth truncation to the orbital tail followed by normalization. A representative profile is $f(r)=\frac{1}{2}\left[1+\operatorname{erf}\!\left(\frac{r_c-r}{\sigma}\right)\right]$, where $r_c$ is the cutoff radius and $\sigma=\gamma r_c$ controls smoothness. default_value: "3.0" unit: Bohr - availability: dft_plus_u is set to 1 + availability: dft_plus_u==1 - name: sc_mag_switch category: Spin-Constrained DFT type: Boolean @@ -4499,7 +4499,7 @@ parameters: Convergence criterion of spin-constrained iteration (RMS) in uB default_value: "1.0e-6" unit: uB - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: nsc category: Spin-Constrained DFT type: Integer @@ -4507,7 +4507,7 @@ parameters: Maximal number of spin-constrained iteration default_value: "100" unit: "" - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: nsc_min category: Spin-Constrained DFT type: Integer @@ -4515,7 +4515,7 @@ parameters: Minimum number of spin-constrained iteration default_value: "2" unit: "" - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: alpha_trial category: Spin-Constrained DFT type: Real @@ -4523,7 +4523,7 @@ parameters: Initial trial step size for lambda in eV/uB^2 default_value: "0.01" unit: eV/uB^2 - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: sccut category: Spin-Constrained DFT type: Real @@ -4531,7 +4531,7 @@ parameters: Maximal step size for lambda in eV/uB default_value: "3.0" unit: eV/uB - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: sc_drop_thr category: Spin-Constrained DFT type: Real @@ -4539,7 +4539,7 @@ parameters: Convergence criterion ratio of lambda iteration in Spin-constrained DFT default_value: "1.0e-2" unit: "" - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: sc_scf_thr category: Spin-Constrained DFT type: Real @@ -4547,7 +4547,7 @@ parameters: Density error threshold for inner loop of spin-constrained SCF default_value: "1.0e-4" unit: "" - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: sc_direction_only category: Spin-Constrained DFT type: Boolean @@ -4557,7 +4557,7 @@ parameters: When false (default), both the direction and magnitude of the magnetic moment are constrained to the target values. default_value: "False" unit: "" - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: sc_lambda_strategy category: Spin-Constrained DFT type: String @@ -4570,7 +4570,7 @@ parameters: * linear_scan: linear sweep of lambda for testing magnetic moment response default_value: bfgs unit: "" - availability: sc_mag_switch is true + availability: sc_mag_switch==true - name: sc_scan_lambda_start category: Spin-Constrained DFT type: Float @@ -4578,7 +4578,7 @@ parameters: Starting lambda value for linear_scan strategy. Only used when sc_lambda_strategy=linear_scan. default_value: "0.0" unit: eV/uB - availability: sc_lambda_strategy is linear_scan + availability: sc_lambda_strategy==linear_scan - name: sc_scan_lambda_end category: Spin-Constrained DFT type: Float @@ -4586,7 +4586,7 @@ parameters: Ending lambda value for linear_scan strategy. Only used when sc_lambda_strategy=linear_scan. default_value: "1.0" unit: eV/uB - availability: sc_lambda_strategy is linear_scan + availability: sc_lambda_strategy==linear_scan - name: sc_scan_steps category: Spin-Constrained DFT type: Integer @@ -4594,7 +4594,7 @@ parameters: Number of lambda values to scan. Only used when sc_lambda_strategy=linear_scan. default_value: "20" unit: "" - availability: sc_lambda_strategy is linear_scan + availability: sc_lambda_strategy==linear_scan - name: qo_switch category: Quasiatomic Orbital (QO) analysis type: Boolean @@ -4934,7 +4934,7 @@ parameters: Atomic basis set size for each atom type (with the same order as in STRU) in FHI-aims. default_value: "{} (empty list, where ABACUS use its own basis set size)" unit: "" - availability: ri_hartree_benchmark = aims + availability: ri_hartree_benchmark==aims - name: rdmft category: Reduced Density Matrix Functional Theory type: Boolean @@ -4960,7 +4960,7 @@ parameters: * False: Use the traditional method to calculate the Fock exchange operator. default_value: "True" unit: "" - availability: exx_separate_loop==True. + availability: exx_separate_loop==true - name: exx_gamma_extrapolation category: Exact Exchange (PW) type: Boolean diff --git a/source/source_io/CMakeLists.txt b/source/source_io/CMakeLists.txt index ddd5c56f1a..b9ec8c4979 100644 --- a/source/source_io/CMakeLists.txt +++ b/source/source_io/CMakeLists.txt @@ -117,6 +117,7 @@ add_library( module_parameter/read_input_item_exx_dftu.cpp module_parameter/read_input_item_other.cpp module_parameter/read_input_item_output.cpp + module_parameter/availability.cpp module_parameter/read_input.cpp module_parameter/read_set_globalv.cpp ) diff --git a/source/source_io/module_parameter/availability.cpp b/source/source_io/module_parameter/availability.cpp new file mode 100644 index 0000000000..7a1f961b76 --- /dev/null +++ b/source/source_io/module_parameter/availability.cpp @@ -0,0 +1,348 @@ +#include "source_io/module_parameter/availability.h" + +#include + +namespace ModuleIO +{ +namespace +{ + +std::string trim_copy(const std::string& s) +{ + std::size_t b = 0, e = s.size(); + while (b < e && std::isspace(static_cast(s[b]))) + { + ++b; + } + while (e > b && std::isspace(static_cast(s[e - 1]))) + { + --e; + } + return s.substr(b, e - b); +} + +std::string lower_copy(const std::string& s) +{ + std::string r = s; + for (std::size_t i = 0; i < r.size(); ++i) + { + r[i] = static_cast(std::tolower(static_cast(r[i]))); + } + return r; +} + +/// Split `text` on the keyword `kw` (e.g. "and"/"or", space separated, or the +/// plain "," separator) occurring at bracket/paren depth 0. Respects () and [] +/// so value lists are not split. Returns trimmed, non-empty parts. +std::vector split_top_keyword(const std::string& text, + const std::string& kw) +{ + std::vector out; + int depth = 0; + std::size_t start = 0; + const std::size_t n = text.size(); + std::size_t i = 0; + while (i < n) + { + char c = text[i]; + if (c == '(' || c == '[') + { + ++depth; + ++i; + continue; + } + if (c == ')' || c == ']') + { + if (depth > 0) + { + --depth; + } + ++i; + continue; + } + if (depth == 0) + { + // "," is a plain separator; word keywords need word boundaries + const bool bound_ok = (kw == ",") || (i == 0) || + std::isspace(static_cast(text[i - 1])); + const bool next_ok = (kw == ",") || + (i + kw.size() >= n || + std::isspace(static_cast(text[i + kw.size()])) || + text[i + kw.size()] == '(' || text[i + kw.size()] == '['); + if (bound_ok && next_ok && + i + kw.size() <= n && + text.compare(i, kw.size(), kw) == 0) + { + std::string part = trim_copy(text.substr(start, i - start)); + if (!part.empty() && part != kw) + { + out.push_back(part); + } + start = i + kw.size(); + i = start; + continue; + } + } + ++i; + } + std::string part = trim_copy(text.substr(start)); + if (!part.empty()) + { + out.push_back(part); + } + return out; +} + +/// Split a comma-separated list inside `[...]`. +std::vector split_commas(const std::string& inner) +{ + std::vector out; + std::size_t start = 0; + for (std::size_t i = 0; i <= inner.size(); ++i) + { + if (i == inner.size() || inner[i] == ',') + { + std::string v = trim_copy(inner.substr(start, i - start)); + if (!v.empty()) + { + out.push_back(v); + } + start = i + 1; + } + } + return out; +} + +bool parse_atom(const std::string& text, AvailabilityCondition& cond) +{ + std::string t = trim_copy(text); + if (t.empty()) + { + return false; + } + // canonical comparison operators (longest/most specific first) + static const char* OPS[] = {"==", "!=", ">=", "<=", ">", "<"}; + for (const char* op: OPS) + { + std::string opstr(op); + const std::size_t pos = t.find(opstr); + if (pos != std::string::npos) + { + std::string param = trim_copy(t.substr(0, pos)); + std::string rhs = trim_copy(t.substr(pos + opstr.size())); + if (param.empty() || rhs.empty()) + { + return false; + } + cond.param = param; + cond.op = opstr; + if (opstr == "==" && rhs.find('/') != std::string::npos) + { + // equality may carry a slash-separated value list + std::size_t beg = 0; + while (beg <= rhs.size()) + { + std::size_t sl = rhs.find('/', beg); + std::string v = trim_copy(rhs.substr(beg, + sl == std::string::npos ? std::string::npos : sl - beg)); + if (!v.empty()) + { + cond.values.push_back(v); + } + if (sl == std::string::npos) + { + break; + } + beg = sl + 1; + } + return !cond.values.empty(); + } + cond.values.push_back(rhs); + return true; + } + } + // canonical containment: param contains value (e.g. a Vector holds an element) + { + const std::string marker = " contains "; + const std::size_t cp = t.find(marker); + if (cp != std::string::npos) + { + std::string param = trim_copy(t.substr(0, cp)); + std::string rhs = trim_copy(t.substr(cp + marker.size())); + if (param.empty() || rhs.empty()) + { + return false; + } + cond.param = param; + cond.op = "contains"; + cond.values.push_back(rhs); + return true; + } + } + // canonical in-list: param in [v1, v2] + std::size_t i = 0; + while (i < t.size()) + { + if (std::isspace(static_cast(t[i]))) + { + std::size_t j = i + 1; + while (j < t.size() && std::isspace(static_cast(t[j]))) + { + ++j; + } + if (j + 2 <= t.size() && t.compare(j, 2, "in") == 0 && + (j + 2 == t.size() || std::isspace(static_cast(t[j + 2])))) + { + std::string param = trim_copy(t.substr(0, i)); + std::string rest = trim_copy(t.substr(j + 2)); + if (param.empty() || rest.size() < 2 || + rest[0] != '[' || rest[rest.size() - 1] != ']') + { + return false; + } + cond.param = param; + cond.op = "in"; + cond.values = split_commas(rest.substr(1, rest.size() - 2)); + return !cond.values.empty(); + } + i = j; + } + else + { + ++i; + } + } + return false; +} + +AvailabilityExpr parse_or(const std::string& text); +AvailabilityExpr parse_and(const std::string& text); +AvailabilityExpr parse_unary(const std::string& text); + +AvailabilityExpr parse_or(const std::string& text) +{ + std::vector parts = split_top_keyword(text, "or"); + if (parts.size() == 1) + { + return parse_and(text); + } + AvailabilityExpr node; + node.op = "or"; + for (std::size_t k = 0; k < parts.size(); ++k) + { + node.children.push_back(parse_and(parts[k])); + } + return node; +} + +AvailabilityExpr parse_and(const std::string& text) +{ + std::vector parts; + { + std::vector a = split_top_keyword(text, "and"); + for (std::size_t k = 0; k < a.size(); ++k) + { + std::vector c = split_top_keyword(a[k], ","); + for (std::size_t m = 0; m < c.size(); ++m) + { + if (!c[m].empty() && c[m] != "," && c[m] != "and") + { + parts.push_back(c[m]); + } + } + } + } + if (parts.size() == 1) + { + return parse_unary(parts[0]); + } + AvailabilityExpr node; + node.op = "and"; + for (std::size_t k = 0; k < parts.size(); ++k) + { + node.children.push_back(parse_unary(parts[k])); + } + return node; +} + +AvailabilityExpr parse_unary(const std::string& text) +{ + std::string t = trim_copy(text); + if (t.size() >= 2 && t[0] == '(' && t[t.size() - 1] == ')') + { + return parse_or(t.substr(1, t.size() - 2)); + } + AvailabilityExpr leaf; + if (parse_atom(t, leaf.condition)) + { + return leaf; + } + return leaf; +} + +} // namespace + +std::string AvailabilityCondition::to_string() const +{ + if (values.empty()) + { + return {}; + } + if (op == "in") + { + std::string s = param + " in ["; + for (std::size_t i = 0; i < values.size(); ++i) + { + if (i) + { + s += ", "; + } + s += values[i]; + } + return s + "]"; + } + if (op == "contains") + { + return param + " contains " + values[0]; + } + // single-value comparison (==, !=, >, >=, <, <=) + return param + op + values[0]; +} + +std::string AvailabilityExpr::to_string() const +{ + if (is_leaf()) + { + return condition.to_string(); + } + std::string sep = (op == "or") ? " or " : " and "; + std::string s; + for (std::size_t i = 0; i < children.size(); ++i) + { + if (i) + { + s += sep; + } + if (children[i].is_leaf()) + { + s += children[i].to_string(); + } + else + { + s += "(" + children[i].to_string() + ")"; + } + } + return s; +} + +AvailabilityExpr parse_availability(const std::string& raw) +{ + std::string t = trim_copy(raw); + if (t.empty()) + { + return AvailabilityExpr(); + } + return parse_or(t); +} + +} // namespace ModuleIO diff --git a/source/source_io/module_parameter/availability.h b/source/source_io/module_parameter/availability.h new file mode 100644 index 0000000000..536fcc0040 --- /dev/null +++ b/source/source_io/module_parameter/availability.h @@ -0,0 +1,47 @@ +#ifndef AVAILABILITY_H +#define AVAILABILITY_H + +#include +#include + +namespace ModuleIO +{ + +/// A single condition `param op values` (e.g. `basis_type==lcao` or +/// `vdw_method in [d2, d3_0]`). +struct AvailabilityCondition +{ + std::string param; ///< parameter identifier + std::string op; ///< ==, !=, >, >=, <, <=, "in" or "contains" + std::vector values; ///< one value for comparisons, several for "in" + + std::string to_string() const; +}; + +/// Boolean expression tree. A leaf holds a single condition; a non-leaf node +/// holds `op` ("and"|"or") and `children`. +struct AvailabilityExpr +{ + std::string op; ///< "" (leaf) | "and" | "or" + AvailabilityCondition condition; ///< valid when leaf + std::vector children; ///< valid when non-leaf + + bool is_leaf() const + { + return op.empty(); + } + + std::string to_string() const; +}; + +/// Parse an availability string into its boolean-expression tree. +/// +/// Accepts the canonical grammar (`param==value`, `param in [a, b]`, the +/// comparison operators ==, !=, >, >=, <, <=, `and`/`or`/`,` combinators and +/// `(...)` grouping). An empty string yields an empty (always-available) +/// expression. +AvailabilityExpr parse_availability(const std::string& raw); + +} // namespace ModuleIO + +#endif // AVAILABILITY_H diff --git a/source/source_io/module_parameter/input_item.h b/source/source_io/module_parameter/input_item.h index ed07d04f83..383a51c427 100644 --- a/source/source_io/module_parameter/input_item.h +++ b/source/source_io/module_parameter/input_item.h @@ -7,6 +7,7 @@ #include #include "source_io/module_parameter/parameter.h" +#include "source_io/module_parameter/availability.h" namespace ModuleIO { class Input_Item @@ -31,6 +32,7 @@ class Input_Item default_value = item.default_value; unit = item.unit; availability = item.availability; + availability_expr = item.availability_expr; annotation = item.annotation; read_value = item.read_value; check_value = item.check_value; @@ -50,6 +52,18 @@ class Input_Item std::string unit; ///< unit of measurement (empty if none) std::string availability; ///< availability conditions (empty if always) + /// Structured availability representation, kept in sync with `availability` + /// via set_availability(). See availability.h for the grammar. + AvailabilityExpr availability_expr; ///< parsed condition tree + + /// Set the canonical availability string and (re)parse it into the + /// structured expression tree, so the two representations never diverge. + void set_availability(const std::string& value) + { + availability = value; + availability_expr = parse_availability(value); + } + bool is_read() const ///< check if the input item is read { return !str_values.empty(); @@ -77,4 +91,4 @@ class Input_Item }; } // namespace ModuleIO -#endif // INPUT_ITEM_H \ No newline at end of file +#endif // INPUT_ITEM_H diff --git a/source/source_io/module_parameter/read_input_item_deepks.cpp b/source/source_io/module_parameter/read_input_item_deepks.cpp index e1eac18e4b..340e0ff02d 100644 --- a/source/source_io/module_parameter/read_input_item_deepks.cpp +++ b/source/source_io/module_parameter/read_input_item_deepks.cpp @@ -23,7 +23,7 @@ void ReadInput::item_deepks() [NOTE] When deepks_out_labels equals 1, the path of a numerical descriptor (an orb file) is needed to be specified under the NUMERICAL_DESCRIPTOR tag in the STRU file. This is not needed when deepks_out_labels equals 2.)"; item.default_value = "0"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_int(input.deepks_out_labels); this->add_item(item); } @@ -35,7 +35,7 @@ void ReadInput::item_deepks() item.description = "When deepks_out_freq_elec is greater than 0, print labels and descriptors for DeePKS in OUT.${suffix}/DeePKS_Labels_Elec per deepks_out_freq_elec electronic iterations, with suffix _e* to distinguish different steps. Often used with deepks_out_labels equals 1."; item.default_value = "0"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_int(input.deepks_out_freq_elec); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.deepks_out_freq_elec < 0) @@ -57,7 +57,7 @@ void ReadInput::item_deepks() item.description = "Print labels and descriptors calculated by base functional ( determined by deepks_out_base ) and target functional ( determined by dft_functional ) for DeePKS in per deepks_out_freq_elec electronic iterations. The SCF process, labels and descriptors output of the target functional are all consistent with those when the target functional is used alone. The only additional output under this configuration is the labels of the base functional. Often used with deepks_out_labels equals 1."; item.default_value = "None"; item.unit = ""; - item.availability = "Numerical atomic orbital basis and deepks_out_freq_elec is greater than 0"; + item.set_availability("basis_type==lcao and deepks_out_freq_elec>0"); read_sync_string(input.deepks_out_base); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.deepks_out_base != "none" && para.input.deepks_out_labels == 0) @@ -80,7 +80,7 @@ void ReadInput::item_deepks() "\n\n[NOTE] A trained, traced model file is needed."; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.deepks_scf); item.check_value = [](const Input_Item& item, const Parameter& para) { #ifndef __MLALGO @@ -107,7 +107,7 @@ void ReadInput::item_deepks() "so this feature is currently only intended for internal usage."; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.deepks_equiv); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.deepks_equiv && para.input.deepks_bandgap) @@ -125,7 +125,7 @@ void ReadInput::item_deepks() item.description = "the path of the trained, traced neural network model file generated by deepks-kit"; item.default_value = "None"; item.unit = ""; - item.availability = "Numerical atomic orbital basis and deepks_scf is true"; + item.set_availability("basis_type==lcao and deepks_scf==true"); read_sync_string(input.deepks_model); this->add_item(item); } @@ -137,7 +137,7 @@ void ReadInput::item_deepks() item.description = "the maximum angular momentum of the Bessel functions generated as the projectors in DeePKS - NOte: To generate such projectors, set calculation type to gen_bessel in ABACUS. See also calculation."; item.default_value = "2"; item.unit = ""; - item.availability = "gen_bessel calculation"; + item.set_availability("calculation==gen_bessel"); read_sync_int(input.bessel_descriptor_lmax); this->add_item(item); } @@ -149,7 +149,7 @@ void ReadInput::item_deepks() item.description = "energy cutoff of Bessel functions"; item.default_value = "same as ecutwfc"; item.unit = "Ry"; - item.availability = "gen_bessel calculation"; + item.set_availability("calculation==gen_bessel"); read_sync_string(input.bessel_descriptor_ecut); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.bessel_descriptor_ecut == "default") @@ -173,7 +173,7 @@ void ReadInput::item_deepks() item.description = "tolerance for searching the zeros of Bessel functions"; item.default_value = "1.0e-12"; item.unit = ""; - item.availability = "gen_bessel calculation"; + item.set_availability("calculation==gen_bessel"); read_sync_double(input.bessel_descriptor_tolerence); this->add_item(item); } @@ -185,7 +185,7 @@ void ReadInput::item_deepks() item.description = "cutoff radius of Bessel functions"; item.default_value = "6.0"; item.unit = "Bohr"; - item.availability = "gen_bessel calculation"; + item.set_availability("calculation==gen_bessel"); read_sync_double(input.bessel_descriptor_rcut); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.bessel_descriptor_rcut < 0) @@ -203,7 +203,7 @@ void ReadInput::item_deepks() item.description = "smooth the Bessel functions at radius cutoff"; item.default_value = "False"; item.unit = ""; - item.availability = "gen_bessel calculation"; + item.set_availability("calculation==gen_bessel"); read_sync_bool(input.bessel_descriptor_smooth); this->add_item(item); } @@ -215,7 +215,7 @@ void ReadInput::item_deepks() item.description = "smooth parameter at the cutoff radius of projectors"; item.default_value = "0.1"; item.unit = "Bohr"; - item.availability = "gen_bessel calculation"; + item.set_availability("calculation==gen_bessel"); read_sync_double(input.bessel_descriptor_sigma); this->add_item(item); } @@ -231,7 +231,7 @@ void ReadInput::item_deepks() * 3: Used for systems containing H atoms. Here HOMO is defined as the max occupation except H atoms and the bandgap label is the energy between HOMO and (HOMO + 1))"; item.default_value = "0"; item.unit = ""; - item.availability = "Numerical atomic orbital basis and deepks_scf is true"; + item.set_availability("basis_type==lcao and deepks_scf==true"); read_sync_int(input.deepks_bandgap); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.deepks_bandgap < 0 || para.input.deepks_bandgap > 3) @@ -251,7 +251,7 @@ void ReadInput::item_deepks() * deepks_bandgap is 2: Bandgap labels are energies between HOMO and all states in range [LUMO + deepks_band_range[0], LUMO + deepks_band_range[1]] (Thus there are deepks_band_range[1] - deepks_band_range[0] + 1 bandgaps in total). If HOMO is included in the setting range, it will be ignored since it will always be zero and has no valuable messages (deepks_band_range[1] - deepks_band_range[0] bandgaps in this case). NOTICE: The set range can be greater than, less than, or include the value of HOMO. In the bandgap label, we always calculate the energy of the state in the set range minus the energy of HOMO state, so the bandgap can be negative if the state is lower than HOMO.)"; item.default_value = "-1 0"; item.unit = ""; - item.availability = "Numerical atomic orbital basis, deepks_scf is true, and deepks_bandgap is 1 or 2"; + item.set_availability("basis_type==lcao and deepks_scf==true and deepks_bandgap in [1, 2]"); item.read_value = [](const Input_Item& item, Parameter& para) { para.input.deepks_band_range[0] = std::stod(item.str_values[0]); para.input.deepks_band_range[1] = std::stod(item.str_values[1]); @@ -295,7 +295,7 @@ void ReadInput::item_deepks() * deepks_v_delta = -2: deepks_phialpha_r.npy and deepks_gevdm.npy, which can be used to calculate deepks_vdrpre.npy. A recommanded method for memory saving.)"; item.default_value = "0"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_int(input.deepks_v_delta); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.deepks_v_delta < -2 || para.input.deepks_v_delta > 2) diff --git a/source/source_io/module_parameter/read_input_item_elec_stru.cpp b/source/source_io/module_parameter/read_input_item_elec_stru.cpp index 147292ce37..d40afa633a 100644 --- a/source/source_io/module_parameter/read_input_item_elec_stru.cpp +++ b/source/source_io/module_parameter/read_input_item_elec_stru.cpp @@ -702,7 +702,7 @@ For systems that are difficult to converge, one could try increasing the value o item.description = "At n-th iteration which is calculated by drho=0"); read_sync_bool(input.mixing_dmr); this->add_item(item); } @@ -760,7 +760,7 @@ In the current implementation, the automatic bypass thresholds are fixed indepen * >0: Angle mixing for the modulus with mixing_angle=1.0)"; item.default_value = "-10.0"; item.unit = ""; - item.availability = "Only relevant for non-colinear calculations nspin=4."; + item.set_availability("nspin==4"); read_sync_double(input.mixing_angle); this->add_item(item); } @@ -774,7 +774,7 @@ In the current implementation, the automatic bypass thresholds are fixed indepen * False: The kinetic energy density will not be mixed.)"; item.default_value = "False"; item.unit = ""; - item.availability = "Only relevant for meta-GGA calculations."; + item.availability = ""; read_sync_bool(input.mixing_tau); this->add_item(item); } @@ -788,7 +788,7 @@ In the current implementation, the automatic bypass thresholds are fixed indepen * False: The occupation matrices will not be mixed.)"; item.default_value = "False"; item.unit = ""; - item.availability = "Only relevant for DFT+U calculations."; + item.set_availability("dft_plus_u==1"); read_sync_bool(input.mixing_dftu); this->add_item(item); } @@ -805,7 +805,7 @@ In the current implementation, the automatic bypass thresholds are fixed indepen Note: If gamma_only is set to 1, the KPT file will be overwritten. So make sure to turn off gamma_only for multi-k calculations.)"; item.default_value = "0"; item.unit = ""; - item.availability = "Only used in localized orbitals set"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.gamma_only); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.basis_type == "pw" && para.input.gamma_only) @@ -1044,7 +1044,7 @@ soc_lambda, which has value range [0.0, 1.0], is used to modulate SOC effect: Use case: When experimental or high-level theoretical results suggest that the SOC effect is weaker or stronger than what full-relativistic pseudopotentials predict, you can adjust this parameter to match the target behavior.)"; item.default_value = "1.0"; item.unit = ""; - item.availability = "Only works when lspinorb=true"; + item.set_availability("lspinorb==true"); read_sync_double(input.soc_lambda); this->add_item(item); } @@ -1101,7 +1101,7 @@ Use case: When experimental or high-level theoretical results suggest that the S item.description = "If TRUE, the wavefunctions at k-point will be initialized from the converged wavefunctions at the nearest k-point, which can speed up the SCF convergence. Only works for PW basis."; item.default_value = "false"; item.unit = ""; - item.availability = "Used only for plane wave basis set."; + item.set_availability("basis_type==pw"); read_sync_bool(input.use_k_continuity); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.use_k_continuity && para.input.basis_type != "pw") { @@ -1130,7 +1130,7 @@ Use case: When experimental or high-level theoretical results suggest that the S item.description = "Only useful when you use ks_solver = cg/dav/dav_subspace/bpcg. It indicates the maximal iteration number for cg/david/dav_subspace/bpcg method."; item.default_value = "50"; item.unit = ""; - item.availability = "basis_type==pw, ks_solver==cg/dav/dav_subspace/bpcg"; + item.set_availability("basis_type==pw and ks_solver in [cg, dav, dav_subspace, bpcg]"); read_sync_int(input.pw_diag_nmax); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_exx_dftu.cpp b/source/source_io/module_parameter/read_input_item_exx_dftu.cpp index e4e2d4f4ec..af006a7bdc 100644 --- a/source/source_io/module_parameter/read_input_item_exx_dftu.cpp +++ b/source/source_io/module_parameter/read_input_item_exx_dftu.cpp @@ -193,7 +193,7 @@ void ReadInput::item_exx() item.description = "The maximal iteration number of the outer-loop, where the Fock exchange is calculated"; item.default_value = "100"; item.unit = ""; - item.availability = "exx_separate_loop==1"; + item.set_availability("exx_separate_loop==1"); read_sync_int(input.exx_hybrid_step); item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -212,7 +212,7 @@ void ReadInput::item_exx() item.description = "Mixing parameter for densty matrix in each iteration of the outer-loop"; item.default_value = "1.0"; item.unit = ""; - item.availability = "exx_separate_loop==1"; + item.set_availability("exx_separate_loop==1"); read_sync_double(input.exx_mixing_beta); this->add_item(item); } @@ -226,7 +226,7 @@ void ReadInput::item_exx() item.description = "It is used to compensate for divergence points at G=0 in the evaluation of Fock exchange using lcao_in_pw method."; item.default_value = "0.3"; item.unit = ""; - item.availability = "basis_type==lcao_in_pw"; + item.set_availability("basis_type==lcao_in_pw"); item.read_value = [](const Input_Item& item, Parameter& para) { para.input.exx_fock_lambda = item.str_values; @@ -411,7 +411,7 @@ void ReadInput::item_exx() item.description = "The maximum l of the spherical Bessel functions, when the radial part of opt-ABFs are generated as linear combinations of spherical Bessel functions. A reasonable choice is 2."; item.default_value = "0"; item.unit = ""; - item.availability = "calculation==gen_opt_abfs"; + item.set_availability("calculation==gen_opt_abfs"); read_sync_int(input.exx_opt_orb_lmax); this->add_item(item); } @@ -423,7 +423,7 @@ void ReadInput::item_exx() item.description = "The cut-off of plane wave expansion, when the plane wave basis is used to optimize the radial ABFs. A reasonable choice is 60."; item.default_value = "0"; item.unit = "Ry"; - item.availability = "calculation==gen_opt_abfs"; + item.set_availability("calculation==gen_opt_abfs"); read_sync_double(input.exx_opt_orb_ecut); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_opt_orb_ecut < 0) @@ -442,7 +442,7 @@ void ReadInput::item_exx() item.description = "The threshold when solving for the zeros of spherical Bessel functions. A reasonable choice is 1e-12."; item.default_value = "1E-12"; item.unit = ""; - item.availability = "calculation==gen_opt_abfs"; + item.set_availability("calculation==gen_opt_abfs"); read_sync_double(input.exx_opt_orb_tolerence); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_opt_orb_tolerence < 0) @@ -545,7 +545,7 @@ void ReadInput::item_exx() * True: rotate both D(k) and Hexx(R) to accelerate both diagonalization and EXX calculation)"; item.default_value = "True"; item.unit = ""; - item.availability = "symmetry==1 and exx calculation (dft_fuctional==hse/hf/pbe0/scan0 or rpa==True)"; + item.set_availability("symmetry==1 and (dft_functional in [hse, hf, pbe0, scan0] or rpa==true)"); read_sync_bool(input.exx_symmetry_realspace); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.symmetry != "1") { para.input.exx_symmetry_realspace = false; } @@ -659,7 +659,7 @@ void ReadInput::item_dftu() item.description = "Whether to enable DFT+DMFT calculation. True: DFT+DMFT; False: standard DFT calculation."; item.default_value = "False"; item.unit = ""; - item.availability = "basis_type==lcao"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.dft_plus_dmft); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.basis_type != "lcao" && para.input.dft_plus_dmft) @@ -787,7 +787,7 @@ void ReadInput::item_dftu() item.description = "The screen length of Yukawa potential. If left to default, the screen length will be calculated as an average of the entire system. It's better to stick to the default setting unless there is a very good reason."; item.default_value = "Calculated on the fly."; item.unit = ""; - item.availability = "DFT+U with yukawa_potential = True."; + item.set_availability("dft_plus_u==1 and yukawa_potential==true"); read_sync_double(input.yukawa_lambda); this->add_item(item); } @@ -799,7 +799,7 @@ void ReadInput::item_dftu() item.description = "Once uramping > 0.15 eV. DFT+U calculations will start SCF with U = 0 eV, namely normal LDA/PBE calculations. Once SCF restarts when drho0"); item.read_value = [](const Input_Item& item, Parameter& para) { para.input.uramping_eV = doublevalue; para.sys.uramping = para.input.uramping_eV / ModuleBase::Ry_to_eV; @@ -853,7 +853,7 @@ void ReadInput::item_dftu() * The modulation algorithm applies a smooth truncation to the orbital tail followed by normalization. A representative profile is $f(r)=\frac{1}{2}\left[1+\operatorname{erf}\!\left(\frac{r_c-r}{\sigma}\right)\right]$, where $r_c$ is the cutoff radius and $\sigma=\gamma r_c$ controls smoothness.)"; item.default_value = "3.0"; item.unit = "Bohr"; - item.availability = "dft_plus_u is set to 1"; + item.set_availability("dft_plus_u==1"); read_sync_double(input.onsite_radius); item.reset_value = [](const Input_Item& item, Parameter& para) { if ((para.input.dft_plus_u == 1 || para.input.sc_mag_switch) && para.input.onsite_radius == 0.0) diff --git a/source/source_io/module_parameter/read_input_item_md.cpp b/source/source_io/module_parameter/read_input_item_md.cpp index ac9054cc11..54d16a51f5 100644 --- a/source/source_io/module_parameter/read_input_item_md.cpp +++ b/source/source_io/module_parameter/read_input_item_md.cpp @@ -536,7 +536,7 @@ Note: It is a system-dependent empirical parameter. An improper choice might lea item.description = "Rescaling factor to use a temperature-dependent DP. Energy, stress and force calculated by DP will be multiplied by this factor."; item.default_value = "1.0"; item.unit = ""; - item.availability = "esolver_type = dp."; + item.set_availability("esolver_type==dp"); read_sync_double(input.mdp.dp_rescaling); this->add_item(item); } @@ -548,7 +548,7 @@ Note: It is a system-dependent empirical parameter. An improper choice might lea item.description = "The frame parameter for dp potential. The array size is dim_fparam, then all frames are assumed to be provided with the same fparam."; item.default_value = "{}"; item.unit = ""; - item.availability = "esolver_type = dp."; + item.set_availability("esolver_type==dp"); item.read_value = [](const Input_Item& item, Parameter& para) { size_t count = item.get_size(); para.input.mdp.dp_fparam.resize(count); @@ -568,7 +568,7 @@ Note: It is a system-dependent empirical parameter. An improper choice might lea item.description = "The atomic parameter for dp potential. The array size can be (1) natoms x dim_aparam, then all frames are assumed to be provided with the same aparam; (2) dim_aparam, then all frames and atoms are assumed to be provided with the same aparam."; item.default_value = "{}"; item.unit = ""; - item.availability = "esolver_type = dp."; + item.set_availability("esolver_type==dp"); item.read_value = [](const Input_Item& item, Parameter& para) { size_t count = item.get_size(); para.input.mdp.dp_aparam.resize(count); @@ -672,7 +672,7 @@ Note: It is a system-dependent empirical parameter. An improper choice might lea "stronger coupling. Recommended value: 100 * md_dt."; item.default_value = "100.0"; item.unit = "fs"; - item.availability = "md_thermostat = csvr"; + item.set_availability("md_thermostat==csvr"); read_sync_double(input.mdp.md_csvr_tau); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_model.cpp b/source/source_io/module_parameter/read_input_item_model.cpp index 2b29a9b5ec..9eeb785a43 100644 --- a/source/source_io/module_parameter/read_input_item_model.cpp +++ b/source/source_io/module_parameter/read_input_item_model.cpp @@ -36,7 +36,7 @@ void ReadInput::item_model() [NOTE] Note: If you do not want any electric field, the parameter efield_amp should be set to zero. This should ONLY be used in a slab geometry for surface calculations, with the discontinuity FALLING IN THE EMPTY SPACE.)"; item.default_value = "False"; item.unit = ""; - item.availability = "With dip_cor_flag = True and efield_flag = True."; + item.set_availability("dip_cor_flag==true and efield_flag==true"); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.dip_cor_flag && !para.input.efield_flag) { @@ -57,7 +57,7 @@ void ReadInput::item_model() * 2: parallel to the third reciprocal lattice vector)"; item.default_value = "2"; item.unit = ""; - item.availability = "with efield_flag = True."; + item.set_availability("efield_flag==true"); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.gate_flag && para.input.efield_flag && !para.input.dip_cor_flag) { @@ -78,7 +78,7 @@ void ReadInput::item_model() item.description = "Position of the maximum of the saw-like potential along crystal axis efield_dir, within the unit cell, 0 <= efield_pos_max < 1."; item.default_value = "Autoset to center of vacuum - width of vacuum / 20"; item.unit = ""; - item.availability = "with efield_flag = True."; + item.set_availability("efield_flag==true"); read_sync_double(input.efield_pos_max); this->add_item(item); } @@ -90,7 +90,7 @@ void ReadInput::item_model() item.description = "Zone in the unit cell where the saw-like potential decreases, 0 < efield_pos_dec < 1."; item.default_value = "Autoset to width of vacuum / 10"; item.unit = ""; - item.availability = "with efield_flag = True."; + item.set_availability("efield_flag==true"); read_sync_double(input.efield_pos_dec); this->add_item(item); } @@ -104,7 +104,7 @@ void ReadInput::item_model() [NOTE] Note: The change of slope of this potential must be located in the empty region, or else unphysical forces will result.)"; item.default_value = "0.0"; item.unit = "a.u., 1 a.u. = 51.4220632*10^10 V/m."; - item.availability = "with efield_flag = True."; + item.set_availability("efield_flag==true"); read_sync_double(input.efield_amp); this->add_item(item); } @@ -209,7 +209,7 @@ void ReadInput::item_model() item.description = "The relative permittivity of the bulk solvent, 80 for water"; item.default_value = "80"; item.unit = ""; - item.availability = "imp_sol is true."; + item.set_availability("imp_sol==true"); read_sync_double(input.eb_k); this->add_item(item); } @@ -279,7 +279,7 @@ void ReadInput::item_model() If set to default, ABACUS infers the functional name from dft_functional or pseudopotential metadata.)"; item.default_value = "default"; item.unit = ""; - item.availability = "vdw_method is set to d4"; + item.set_availability("vdw_method==d4"); read_sync_string(input.vdw_d4_xc); this->add_item(item); } @@ -294,7 +294,7 @@ Available options are: * d4s: smooth D4S model)"; item.default_value = "d4"; item.unit = ""; - item.availability = "vdw_method is set to d4"; + item.set_availability("vdw_method==d4"); read_sync_string(input.vdw_d4_model); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.vdw_d4_model != "d4" && para.input.vdw_d4_model != "d4s" @@ -313,7 +313,7 @@ Available options are: item.description = "This scale factor is used to optimize the interaction energy deviations in van der Waals (vdW) corrected calculations. The recommended values of this parameter are dependent on the chosen vdW correction method and the DFT functional being used. For DFT-D2, the recommended values are 0.75 (PBE), 1.2 (BLYP), 1.05 (B-P86), 1.0 (TPSS), and 1.05 (B3LYP). If not set, will use values of PBE functional. For DFT-D3, recommended values with different DFT functionals can be found on the here. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value."; item.default_value = ""; item.unit = ""; - item.availability = "vdw_method is set to d2, d3_0, or d3_bj"; + item.set_availability("vdw_method in [d2, d3_0, d3_bj]"); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.vdw_s6 == "default") { @@ -338,7 +338,7 @@ Available options are: item.description = "This scale factor is relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value."; item.default_value = ""; item.unit = ""; - item.availability = "vdw_method is set to d3_0 or d3_bj"; + item.set_availability("vdw_method in [d3_0, d3_bj]"); item.reset_value = [](const Input_Item& item, Parameter& para) { // if (para.input.vdw_s8 == "default") // { @@ -363,7 +363,7 @@ Available options are: item.description = "This damping function parameter is relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value."; item.default_value = ""; item.unit = ""; - item.availability = "vdw_method is set to d3_0 or d3_bj"; + item.set_availability("vdw_method in [d3_0, d3_bj]"); item.reset_value = [](const Input_Item& item, Parameter& para) { // if (para.input.vdw_a1 == "default") // { @@ -388,7 +388,7 @@ Available options are: item.description = "This damping function parameter is only relevant for D3(0) and D3(BJ) van der Waals (vdW) correction methods. The recommended values of this parameter with different DFT functionals can be found on the webpage. If not set, will search in ABACUS built-in dataset based on the dft_functional keywords. User set value will overwrite the searched value."; item.default_value = ""; item.unit = ""; - item.availability = "vdw_method is set to d3_0 or d3_bj"; + item.set_availability("vdw_method in [d3_0, d3_bj]"); item.reset_value = [](const Input_Item& item, Parameter& para) { // if (para.input.vdw_a2 == "default") // { @@ -413,7 +413,7 @@ Available options are: item.description = "Controls the damping rate of the damping function in the DFT-D2 method."; item.default_value = "20"; item.unit = ""; - item.availability = "vdw_method is set to d2"; + item.set_availability("vdw_method==d2"); read_sync_double(input.vdw_d); this->add_item(item); } @@ -427,7 +427,7 @@ Available options are: * False: The three-body term is not included.)"; item.default_value = "False"; item.unit = ""; - item.availability = "vdw_method is set to d3_0 or d3_bj"; + item.set_availability("vdw_method in [d3_0, d3_bj]"); read_sync_bool(input.vdw_abc); this->add_item(item); } @@ -443,7 +443,7 @@ H 0.1 Si 9.0 Namely, each line contains the element name and the corresponding parameter.)"; item.default_value = "default"; item.unit = ""; - item.availability = "vdw_method is set to d2"; + item.set_availability("vdw_method==d2"); read_sync_string(input.vdw_C6_file); this->add_item(item); } @@ -457,7 +457,7 @@ Namely, each line contains the element name and the corresponding parameter.)"; * eVA (eV Angstrom))"; item.default_value = "Jnm6/mol"; item.unit = ""; - item.availability = "vdw_C6_file is not default"; + item.set_availability("vdw_C6_file!=default"); read_sync_string(input.vdw_C6_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_C6_unit != "Jnm6/mol") && (para.input.vdw_C6_unit != "eVA6")) @@ -479,7 +479,7 @@ Li 1.0 Cl 2.0 Namely, each line contains the element name and the corresponding parameter.)"; item.default_value = "default"; item.unit = ""; - item.availability = "vdw_method is set to d2"; + item.set_availability("vdw_method==d2"); read_sync_string(input.vdw_R0_file); this->add_item(item); } @@ -493,7 +493,7 @@ Namely, each line contains the element name and the corresponding parameter.)"; * Bohr)"; item.default_value = "A"; item.unit = ""; - item.availability = "vdw_R0_file is not default"; + item.set_availability("vdw_R0_file!=default"); read_sync_string(input.vdw_R0_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_R0_unit != "A") && (para.input.vdw_R0_unit != "Bohr")) @@ -531,7 +531,7 @@ Namely, each line contains the element name and the corresponding parameter.)"; item.description = "Defines the radius of the cutoff sphere when vdw_cutoff_type is set to radius. The default values depend on the chosen vdw_method."; item.default_value = ""; item.unit = "defined by vdw_radius_unit (default Bohr)"; - item.availability = "vdw_cutoff_type is set to radius"; + item.set_availability("vdw_cutoff_type==radius"); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.vdw_cutoff_radius == "default") { @@ -575,7 +575,7 @@ Namely, each line contains the element name and the corresponding parameter.)"; * Bohr)"; item.default_value = "Bohr"; item.unit = ""; - item.availability = "vdw_cutoff_type is set to radius"; + item.set_availability("vdw_cutoff_type==radius"); read_sync_string(input.vdw_radius_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_radius_unit != "A") && (para.input.vdw_radius_unit != "Bohr")) @@ -593,7 +593,7 @@ Namely, each line contains the element name and the corresponding parameter.)"; item.description = "The three integers supplied here explicitly specify the extent of the supercell in the directions of the three basis lattice vectors."; item.default_value = "3 3 3"; item.unit = ""; - item.availability = "vdw_cutoff_type is set to period"; + item.set_availability("vdw_cutoff_type==period"); item.read_value = [](const Input_Item& item, Parameter& para) { size_t count = item.get_size(); if (count == 3) @@ -632,7 +632,7 @@ Namely, each line contains the element name and the corresponding parameter.)"; item.description = "The cutoff radius when calculating coordination numbers."; item.default_value = "40"; item.unit = "defined by vdw_cn_thr_unit (default: Bohr)"; - item.availability = "vdw_method is set to d3_0, d3_bj, or d4"; + item.set_availability("vdw_method in [d3_0, d3_bj, d4]"); item.reset_value = [](const Input_Item& item, Parameter& para) { if (!item.is_read() && para.input.vdw_method == "d4") { diff --git a/source/source_io/module_parameter/read_input_item_ofdft.cpp b/source/source_io/module_parameter/read_input_item_ofdft.cpp index 46647a7bed..afc7551c2b 100644 --- a/source/source_io/module_parameter/read_input_item_ofdft.cpp +++ b/source/source_io/module_parameter/read_input_item_ofdft.cpp @@ -28,7 +28,7 @@ void ReadInput::item_ofdft() * cpn5: CPN5 KEDF (automatically sets ml parameters))"; item.default_value = "wt"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.check_value = [](const Input_Item& item, const Parameter& para) { #ifndef __MLALGO if (para.input.of_kinetic == "ml" || para.input.of_kinetic == "mpn" || para.input.of_kinetic == "cpn5") @@ -124,7 +124,7 @@ void ReadInput::item_ofdft() * tn: Truncated Newton algorithm.)"; item.default_value = "tn"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_string(input.of_method); this->add_item(item); } @@ -139,7 +139,7 @@ void ReadInput::item_ofdft() * both: Both energy and potential must satisfy the convergence criterion.)"; item.default_value = "energy"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_string(input.of_conv); this->add_item(item); } @@ -152,7 +152,7 @@ void ReadInput::item_ofdft() item.description = "Tolerance of the energy change for determining the convergence."; item.default_value = "2e-6"; item.unit = "Ry"; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_double(input.of_tole); this->add_item(item); } @@ -165,7 +165,7 @@ void ReadInput::item_ofdft() item.description = "Tolerance of potential for determining the convergence."; item.default_value = "1e-5"; item.unit = "Ry"; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_double(input.of_tolp); this->add_item(item); } @@ -177,7 +177,7 @@ void ReadInput::item_ofdft() item.description = "Weight of TF KEDF (kinetic energy density functional)."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=tf, tf+, wt, ext-wt, xwm"; + item.set_availability("esolver_type==ofdft and of_kinetic in [tf, tf+, wt, ext-wt, xwm]"); read_sync_double(input.of_tf_weight); this->add_item(item); } @@ -189,7 +189,7 @@ void ReadInput::item_ofdft() item.description = "Weight of vW KEDF (kinetic energy density functional)."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=vw, tf+, wt, ext-wt, lkt, xwm"; + item.set_availability("esolver_type==ofdft and of_kinetic in [vw, tf+, wt, ext-wt, lkt, xwm]"); read_sync_double(input.of_vw_weight); this->add_item(item); } @@ -201,7 +201,7 @@ void ReadInput::item_ofdft() item.description = "Parameter alpha of WT KEDF (kinetic energy density functional)."; item.default_value = ""; item.unit = ""; - item.availability = "OFDFT with of_kinetic=wt, ext-wt"; + item.set_availability("esolver_type==ofdft and of_kinetic in [wt, ext-wt]"); read_sync_double(input.of_wt_alpha); this->add_item(item); } @@ -213,7 +213,7 @@ void ReadInput::item_ofdft() item.description = "Parameter beta of WT KEDF (kinetic energy density functional)."; item.default_value = ""; item.unit = ""; - item.availability = "OFDFT with of_kinetic=wt, ext-wt"; + item.set_availability("esolver_type==ofdft and of_kinetic in [wt, ext-wt]"); read_sync_double(input.of_wt_beta); this->add_item(item); } @@ -225,7 +225,7 @@ void ReadInput::item_ofdft() item.description = "Parameter kappa for EXT-WT KEDF."; item.default_value = "1.0 / (2.0 * std::pow(4./3., 1./3.) - 1.0)"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=ext-wt"; + item.set_availability("esolver_type==ofdft and of_kinetic==ext-wt"); read_sync_double(input.of_extwt_kappa); this->add_item(item); } @@ -237,7 +237,7 @@ void ReadInput::item_ofdft() item.description = "The average density of system."; item.default_value = "0.0"; item.unit = "Bohr^-3"; - item.availability = "OFDFT with of_kinetic=wt"; + item.set_availability("esolver_type==ofdft and of_kinetic==wt"); read_sync_double(input.of_wt_rho0); this->add_item(item); } @@ -253,7 +253,7 @@ void ReadInput::item_ofdft() * False: rho0 will change if volume of system has changed.)"; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=wt"; + item.set_availability("esolver_type==ofdft and of_kinetic==wt"); read_sync_bool(input.of_hold_rho0); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.of_wt_rho0 != 0) @@ -271,7 +271,7 @@ void ReadInput::item_ofdft() item.description = "Parameter a of LKT KEDF (kinetic energy density functional)."; item.default_value = "1.3"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=lkt"; + item.set_availability("esolver_type==ofdft and of_kinetic==lkt"); read_sync_double(input.of_lkt_a); this->add_item(item); } @@ -283,7 +283,7 @@ void ReadInput::item_ofdft() item.description = "Reference charge density for XWM kinetic energy functional. If set to 0, the program will use average charge density."; item.default_value = "0.0"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=xwm"; + item.set_availability("esolver_type==ofdft and of_kinetic==xwm"); read_sync_double(input.of_xwm_rho_ref); this->add_item(item); } @@ -295,7 +295,7 @@ void ReadInput::item_ofdft() item.description = "Parameter for XWM kinetic energy functional. See PHYSICAL REVIEW B 100, 205132 (2019) for optimal values."; item.default_value = "0.0"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=xwm"; + item.set_availability("esolver_type==ofdft and of_kinetic==xwm"); read_sync_double(input.of_xwm_kappa); this->add_item(item); } @@ -311,7 +311,7 @@ void ReadInput::item_ofdft() * False: The kernel of WT KEDF (kinetic energy density functional) will be filled from formula.)"; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT with of_kinetic=wt"; + item.set_availability("esolver_type==ofdft and of_kinetic==wt"); read_sync_bool(input.of_read_kernel); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.of_kinetic != "wt") @@ -329,7 +329,7 @@ void ReadInput::item_ofdft() item.description = "The name of WT kernel file."; item.default_value = "WTkernel.txt"; item.unit = ""; - item.availability = "OFDFT with of_read_kernel=True"; + item.set_availability("esolver_type==ofdft and of_read_kernel==true"); read_sync_string(input.of_kernel_file); this->add_item(item); } @@ -344,7 +344,7 @@ void ReadInput::item_ofdft() * False: Only use the planewaves inside ecut, the same as KSDFT.)"; item.default_value = "True"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_full_pw); this->add_item(item); } @@ -363,7 +363,7 @@ void ReadInput::item_ofdft() Note: Even dimensions may cause slight errors in FFT. It should be ignorable in ofdft calculation, but it may make Cardinal B-spline interpolation unstable, so please set of_full_pw_dim = 1 if nbspline != -1.)"; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT with of_full_pw = True"; + item.set_availability("esolver_type==ofdft and of_full_pw==true"); read_sync_int(input.of_full_pw_dim); item.reset_value = [](const Input_Item& item, Parameter& para) { if (!para.input.of_full_pw) @@ -381,7 +381,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Controls the generation of machine learning training data. When enabled, training data in .npy format will be saved in the directory OUT.${suffix}/."; item.default_value = "False"; item.unit = ""; - item.availability = "Used only for KSDFT with plane wave basis"; + item.set_availability("esolver_type==ksdft and basis_type==pw"); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.of_ml_gene_data && (para.input.esolver_type != "ksdft" || para.input.basis_type != "pw" || GlobalV::NPROC != 1)) @@ -404,7 +404,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in * gpu: GPU)"; item.default_value = "cpu"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_string(input.of_ml_device); this->add_item(item); } @@ -419,7 +419,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in * 3: Incorporate the FEG limit by nonlinear transformation using softplus function.)"; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_int(input.of_ml_feg); this->add_item(item); } @@ -431,7 +431,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Number of kernel functions."; item.default_value = "1"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.of_ml_nkernel > 0) { @@ -469,7 +469,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in * 3: Truncated kinetic kernel (TKK), the file containing TKK is specified by of_ml_kernel_file.)"; item.default_value = "1"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_kernel); }; @@ -484,7 +484,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the RECIPROCAL of scaling parameter of the i-th kernel function."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_kernel_scaling); }; @@ -499,7 +499,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the parameter alpha of i-th kernel function. ONLY used for Yukawa kernel function."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_yukawa_alpha); }; @@ -514,7 +514,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the file containing the i-th kernel function. ONLY used for TKK."; item.default_value = "none"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { size_t count = item.get_size(); for (int i = 0; i < count; i++) @@ -533,7 +533,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Local descriptor: gamma = (rho / rho0)^(1/3)."; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_ml_gamma); this->add_item(item); } @@ -545,7 +545,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Semi-local descriptor: p = |nabla rho|^2 / [2 (3 pi^2)^(1/3) rho^(4/3)]^2."; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_ml_p); this->add_item(item); } @@ -557,7 +557,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Semi-local descriptor: q = nabla^2 rho / [4 (3 pi^2)^(2/3) rho^(5/3)]."; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_ml_q); this->add_item(item); } @@ -569,7 +569,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Semi-local descriptor: tanhp = tanh(chi_p * p)."; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_ml_tanhp); this->add_item(item); } @@ -581,7 +581,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Semi-local descriptor: tanhq = tanh(chi_q * q)."; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_ml_tanhq); this->add_item(item); } @@ -593,7 +593,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Hyperparameter chi_p: tanhp = tanh(chi_p * p)."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_double(input.of_ml_chi_p); this->add_item(item); } @@ -605,7 +605,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Hyperparameter chi_q: tanhq = tanh(chi_q * q)."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_double(input.of_ml_chi_q); this->add_item(item); } @@ -617,7 +617,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor gammanl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_gammanl); }; @@ -632,7 +632,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor pnl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_pnl); }; @@ -647,7 +647,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor qnl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_qnl); }; @@ -662,7 +662,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor xi defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_xi); }; @@ -677,7 +677,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhxi defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_tanhxi); }; @@ -692,7 +692,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhxi_nl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_tanhxi_nl); }; @@ -707,7 +707,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanh_pnl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_tanh_pnl); }; @@ -722,7 +722,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanh_qnl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_tanh_qnl); }; @@ -737,7 +737,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhp_nl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_tanhp_nl); }; @@ -752,7 +752,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element controls the non-local descriptor tanhq_nl defined by the i-th kernel function."; item.default_value = "0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_tanhq_nl); }; @@ -767,7 +767,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_xi of non-local descriptor tanhxi defined by the i-th kernel function."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_chi_xi); }; @@ -782,7 +782,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_pnl of non-local descriptor tanh_pnl defined by the i-th kernel function."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_chi_pnl); }; @@ -797,7 +797,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "Containing nkernel (see of_ml_nkernel) elements. The i-th element specifies the hyperparameter chi_qnl of non-local descriptor tanh_qnl defined by the i-th kernel function."; item.default_value = "1.0"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.of_ml_chi_qnl); }; @@ -812,7 +812,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in item.description = "FOR TEST. Read in the density, and output the F and Pauli potential."; item.default_value = "False"; item.unit = ""; - item.availability = "OFDFT"; + item.set_availability("esolver_type==ofdft"); read_sync_bool(input.of_ml_local_test); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_other.cpp b/source/source_io/module_parameter/read_input_item_other.cpp index 99aeda824b..acd7e66284 100644 --- a/source/source_io/module_parameter/read_input_item_other.cpp +++ b/source/source_io/module_parameter/read_input_item_other.cpp @@ -56,7 +56,7 @@ void ReadInput::item_others() item.description = "Convergence criterion of spin-constrained iteration (RMS) in uB"; item.default_value = "1.0e-6"; item.unit = "uB"; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_double(input.sc_thr); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_thr < 0) @@ -74,7 +74,7 @@ void ReadInput::item_others() item.description = "Maximal number of spin-constrained iteration"; item.default_value = "100"; item.unit = ""; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_int(input.nsc); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nsc <= 0) @@ -92,7 +92,7 @@ void ReadInput::item_others() item.description = "Minimum number of spin-constrained iteration"; item.default_value = "2"; item.unit = ""; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_int(input.nsc_min); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nsc_min <= 0) @@ -110,7 +110,7 @@ void ReadInput::item_others() item.description = "Initial trial step size for lambda in eV/uB^2"; item.default_value = "0.01"; item.unit = "eV/uB^2"; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_double(input.alpha_trial); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.alpha_trial <= 0) @@ -128,7 +128,7 @@ void ReadInput::item_others() item.description = "Maximal step size for lambda in eV/uB"; item.default_value = "3.0"; item.unit = "eV/uB"; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_double(input.sccut); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sccut <= 0) @@ -146,7 +146,7 @@ void ReadInput::item_others() item.description = "Convergence criterion ratio of lambda iteration in Spin-constrained DFT"; item.default_value = "1.0e-2"; item.unit = ""; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_double(input.sc_drop_thr); this->add_item(item); } @@ -158,7 +158,7 @@ void ReadInput::item_others() item.description = "Density error threshold for inner loop of spin-constrained SCF"; item.default_value = "1.0e-4"; item.unit = ""; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_double(input.sc_scf_thr); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_scf_thr <= 0.0) @@ -178,7 +178,7 @@ void ReadInput::item_others() When false (default), both the direction and magnitude of the magnetic moment are constrained to the target values.)"; item.default_value = "False"; item.unit = ""; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_bool(input.sc_direction_only); this->add_item(item); } @@ -195,7 +195,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar * linear_scan: linear sweep of lambda for testing magnetic moment response)"; item.default_value = "bfgs"; item.unit = ""; - item.availability = "sc_mag_switch is true"; + item.set_availability("sc_mag_switch==true"); read_sync_string(input.sc_lambda_strategy); item.check_value = [](const Input_Item& item, const Parameter& para) { const std::vector valid = {"bfgs", "bfgs2", "linear_response", "augmented_lagrangian", "hybrid_delayed", "linear_scan"}; @@ -214,7 +214,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar item.description = "Starting lambda value for linear_scan strategy. Only used when sc_lambda_strategy=linear_scan."; item.default_value = "0.0"; item.unit = "eV/uB"; - item.availability = "sc_lambda_strategy is linear_scan"; + item.set_availability("sc_lambda_strategy==linear_scan"); read_sync_double(input.sc_scan_lambda_start); this->add_item(item); } @@ -226,7 +226,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar item.description = "Ending lambda value for linear_scan strategy. Only used when sc_lambda_strategy=linear_scan."; item.default_value = "1.0"; item.unit = "eV/uB"; - item.availability = "sc_lambda_strategy is linear_scan"; + item.set_availability("sc_lambda_strategy==linear_scan"); read_sync_double(input.sc_scan_lambda_end); this->add_item(item); } @@ -238,7 +238,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar item.description = "Number of lambda values to scan. Only used when sc_lambda_strategy=linear_scan."; item.default_value = "20"; item.unit = ""; - item.availability = "sc_lambda_strategy is linear_scan"; + item.set_availability("sc_lambda_strategy==linear_scan"); read_sync_int(input.sc_scan_steps); this->add_item(item); } @@ -845,7 +845,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar item.description = "Atomic basis set size for each atom type (with the same order as in STRU) in FHI-aims."; item.default_value = "{} (empty list, where ABACUS use its own basis set size)"; item.unit = ""; - item.availability = "ri_hartree_benchmark = aims"; + item.set_availability("ri_hartree_benchmark==aims"); item.read_value = [](const Input_Item& item, Parameter& para) { size_t count = item.get_size(); for (int i = 0; i < count; i++) @@ -917,7 +917,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar * False: Use the traditional method to calculate the Fock exchange operator.)"; item.default_value = "True"; item.unit = ""; - item.availability = "exx_separate_loop==True."; + item.set_availability("exx_separate_loop==true"); read_sync_bool(input.exxace); this->add_item(item); } @@ -982,7 +982,7 @@ When false (default), both the direction and magnitude of the magnetic moment ar item.description = "The threshold for the change of exact exchange energy to judge convergence of the outer loop in the separate loop EXX calculation."; item.default_value = "1e-5"; item.unit = "Ry"; - item.availability = "exx_thr_type==energy"; + item.set_availability("exx_thr_type==energy"); read_sync_double(input.exx_ene_thr); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_ene_thr <= 0) diff --git a/source/source_io/module_parameter/read_input_item_output.cpp b/source/source_io/module_parameter/read_input_item_output.cpp index 15868d0eb4..d8a267ce43 100644 --- a/source/source_io/module_parameter/read_input_item_output.cpp +++ b/source/source_io/module_parameter/read_input_item_output.cpp @@ -191,7 +191,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr * In 3.10-LTS, the corresponding keyword is out_dm, and the output files are SPIN1_DM and SPIN2_DM, etc.)"; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_dmk needs at least 1 value"); @@ -222,7 +222,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr [NOTE] In the 3.10-LTS version, the parameter is named out_dm1, and the file names are data-DMR-sparse_SPIN0.csr and data-DMR-sparse_SPIN1.csr, etc.)"; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis (multi-k points)"; + item.set_availability("basis_type==lcao and gamma_only==0"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_dmr needs at least 1 value"); @@ -267,7 +267,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr [NOTE] In the 3.10-LTS version, the file names are WAVEFUNC1.dat, WAVEFUNC2.dat, etc.)"; item.default_value = "0"; item.unit = ""; - item.availability = "Output electronic wave functions in plane wave basis, or transform the real-space electronic wave function into plane wave basis (see get_wf option in calculation with NAO basis)"; + item.set_availability("basis_type==pw or (basis_type==lcao and calculation==get_wf)"); read_sync_int(input.out_wfc_pw); this->add_item(item); } @@ -292,7 +292,7 @@ Also controled by out_freq_ion and out_app_flag. [NOTE] In the 3.10-LTS version, the file names are WFC_NAO_GAMMA1_ION1.txt and WFC_NAO_K1_ION1.txt, etc.)"; item.default_value = "0"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_int(input.out_wfc_lcao); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.qo_switch) @@ -551,7 +551,7 @@ When out_app_flag is false, g followed by the one-based ionic-step index is inse [NOTE] In the 3.10-LTS version, the file names are data-0-H and data-0-S, etc.)"; item.default_value = "0 8"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1 || count > 2) @@ -594,7 +594,7 @@ When out_app_flag is false, g followed by the one-based ionic-step index is inse item.description = "Legacy alias for out_hsk 1, which outputs Hamiltonian and overlap matrices in reciprocal space for each k-point. The optional second integer controls text precision. If both out_hsk and out_mat_hs are present, out_hsk takes precedence."; item.default_value = "False 8"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_hs needs at least 1 value"); @@ -622,7 +622,7 @@ For multi-k calculations, the output contains the individual real-space blocks s [NOTE] In the 3.10-LTS version, the file names are data-HR-sparse_SPIN0.csr and data-SR-sparse_SPIN0.csr, etc.)"; item.default_value = "0 8"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1 || count > 2) @@ -674,7 +674,7 @@ For multi-k calculations, the output contains the individual real-space blocks s item.description = "Legacy alias for out_hsr 1, which outputs Hamiltonian and overlap matrices in real space indexed by the Bravais lattice vector R. The optional second integer controls text precision. If both out_hsr and out_mat_hs2 are present, out_hsr takes precedence."; item.default_value = "False 8"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_hs2 needs at least 1 value"); @@ -695,7 +695,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file names are data-TR-sparse_SPIN0.csr, etc."; item.default_value = "False [8]"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_tk needs at least 1 value"); @@ -717,7 +717,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file name is data-rR-sparse.csr."; item.default_value = "False 8"; item.unit = "Bohr"; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_r needs at least 1 value"); @@ -756,7 +756,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr."; item.default_value = "False 8"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_t needs at least 1 value"); @@ -785,7 +785,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on."; item.default_value = "0 8"; item.unit = "Ry/Bohr"; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_dh needs at least 1 value"); @@ -1184,7 +1184,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on."; item.default_value = "False 8"; item.unit = "Ry/Bohr"; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_ds needs at least 1 value"); @@ -1218,7 +1218,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file name is k-$k-Vxc and so on."; item.default_value = "False"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital (NAO) and NAO-in-PW basis"; + item.set_availability("basis_type in [lcao, lcao_in_pw]"); read_sync_bool(input.out_mat_xc); this->add_item(item); } @@ -1231,7 +1231,7 @@ For multi-k calculations, the output contains the individual real-space blocks s "\n\n[NOTE] In the 3.10-LTS version, the file name is Vxc_R_spin$s and so on."; item.default_value = "False 8"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital (NAO) basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_xc2 needs at least 1 value"); @@ -1258,7 +1258,7 @@ For multi-k calculations, the output contains the individual real-space blocks s item.description = "Whether to print the expectation value of the angular momentum operator , , and in the basis of the localized atomic orbitals. The files are named OUT.{suffix}_Lx.dat, OUT.{suffix}_Ly.dat, and OUT.{suffix}_Lz.dat. The second integer controls the precision of the output."; item.default_value = "False 8"; item.unit = ""; - item.availability = "Numerical atomic orbital (NAO) basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count < 1) ModuleBase::WARNING_QUIT("ReadInput", "out_mat_l needs at least 1 value"); @@ -1320,7 +1320,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Whether to print the band energy terms separately in the file OUT.{term}_out.dat. The terms include the kinetic, pseudopotential (local + nonlocal), Hartree and exchange-correlation (including exact exchange if calculated)."; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.out_eband_terms); this->add_item(item); } @@ -1332,7 +1332,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Whether to print Hamiltonian matrices H(R) in NPZ format as hrs1_nao.npz and, for nspin = 2, hrs2_nao.npz. This feature does not work for gamma-only calculations."; item.default_value = "False"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); read_sync_bool(input.out_hr_npz); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.out_hr_npz) @@ -1354,7 +1354,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Legacy alias for out_hsr 3, writing hrs1_nao.npz, hrs2_nao.npz when needed, and sr_nao.npz. If both out_hsr and out_hsr_npz are present, out_hsr takes precedence. Gamma-only calculations write the folded R = (0, 0, 0) representation."; item.default_value = "False"; item.unit = "Ry"; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); item.read_value = [](const Input_Item& item, Parameter& para) { para.input.out_hsr_npz = assume_as_boolean(item.str_values[0]); }; @@ -1378,7 +1378,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Whether to print density matrices DM(R) in npz format. This feature does not work for gamma-only calculations."; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); read_sync_bool(input.out_dm_npz); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.out_dm_npz) @@ -1400,7 +1400,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Whether to print the Mulliken population analysis result into OUT.${suffix}/mulliken.txt. In molecular dynamics calculations, the output frequency is controlled by out_freq_ion."; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.out_mul); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.basis_type == "pw" && para.input.out_mul) @@ -1419,7 +1419,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Whether to output r(R), H(R), S(R), T(R), dH(R), dS(R), and wfc matrices in an append manner during molecular dynamics calculations. Check input parameters out_mat_r, out_hsr, out_mat_t, out_mat_dh, out_hsk and out_wfc_lcao for more information."; item.default_value = "true"; item.unit = ""; - item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + item.set_availability("basis_type==lcao and gamma_only==0"); read_sync_bool(input.out_app_flag); this->add_item(item); } @@ -1431,7 +1431,7 @@ The circle order of the charge density on real space grids is: x is the outer lo item.description = "Controls the length of decimal part of output data, such as charge density, Hamiltonian matrix, Overlap matrix and so on."; item.default_value = "8"; item.unit = ""; - item.availability = "out_hsk 1 case presently."; + item.set_availability("out_hsk==1"); read_sync_int(input.out_ndigits); this->add_item(item); } @@ -1458,7 +1458,7 @@ The circle order of the charge density on real space grids is: x is the outer lo If EXX(exact exchange) is calculated (i.e. dft_fuctional==hse/hf/pbe0/scan0 or rpa==True), the Hexx(R) files for each processor will also be saved in the above folder, which can be read in EXX calculation with restart_load==True.)"; item.default_value = "False"; item.unit = ""; - item.availability = "Numerical atomic orbital basis"; + item.set_availability("basis_type==lcao"); read_sync_bool(input.restart_save); this->add_item(item); } @@ -1486,7 +1486,7 @@ If EXX(exact exchange) is calculated (i.e. dft_fuctional==hse/hf/pbe0/scan0 or r item.description = R"(Specifies the electronic states to calculate the charge densities with state index for, using a space-separated string of 0s and 1s. Each digit in the string corresponds to a state, starting from the first state. A 1 indicates that the charge density should be calculated for that state, while a 0 means the state will be ignored. The parameter allows a compact and flexible notation (similar to ocp_set), for example the syntax 1 4*0 5*1 0 is used to denote the selection of states: 1 means calculate for the first state, 4*0 skips the next four states, 5*1 means calculate for the following five states, and the final 0 skips the next state. It's essential that the total count of states does not exceed the total number of states (nbands); otherwise, it results in an error, and the process exits. The input string must contain only numbers and the asterisk (*) for repetition, ensuring correct format and intention of state selection. The outputs comprise multiple .cube files following the naming convention pchgi[state]s[spin]k[kpoint].cube.)"; item.default_value = "none"; item.unit = ""; - item.availability = "For both PW and LCAO. When basis_type = lcao, used when calculation = get_pchg."; + item.set_availability("basis_type==pw or (basis_type==lcao and calculation==get_pchg)"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.out_pchg); }; item.get_final_value = [](Input_Item& item, const Parameter& para) { @@ -1506,7 +1506,7 @@ If EXX(exact exchange) is calculated (i.e. dft_fuctional==hse/hf/pbe0/scan0 or r item.description = "Specifies the electronic states to calculate the real-space wave function modulus (norm, or known as the envelope function) with state index. The syntax and state selection rules are identical to out_pchg, but the output is the norm of the wave function. The outputs comprise multiple .cube files following the naming convention wfi[state]s[spin]k[kpoint].cube."; item.default_value = "none"; item.unit = ""; - item.availability = "For both PW and LCAO. When basis_type = lcao, used when calculation = get_wf."; + item.set_availability("basis_type==pw or (basis_type==lcao and calculation==get_wf)"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.out_wfc_norm); }; @@ -1527,7 +1527,7 @@ If EXX(exact exchange) is calculated (i.e. dft_fuctional==hse/hf/pbe0/scan0 or r item.description = "Specifies the electronic states to calculate the real and imaginary parts of the wave function with state index. The syntax and state selection rules are identical to out_pchg, but the output contains both the real and imaginary components of the wave function. The outputs comprise multiple .cube files following the naming convention wfi[state]s[spin]k[kpoint][re/im].cube."; item.default_value = "none"; item.unit = ""; - item.availability = "For both PW and LCAO. When basis_type = lcao, used when calculation = get_wf."; + item.set_availability("basis_type==pw or (basis_type==lcao and calculation==get_wf)"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.out_wfc_re_im); }; @@ -1549,7 +1549,7 @@ If EXX(exact exchange) is calculated (i.e. dft_fuctional==hse/hf/pbe0/scan0 or r item.description = "Specifies whether to write the partial charge densities for all k-points to individual files or merge them. Warning: Enabling symmetry may produce unwanted results due to reduced k-point weights and symmetry operations in real space. Therefore when calculating partial charge densities, if you are not sure what you want exactly, it is strongly recommended to set symmetry = -1. It is noteworthy that your symmetry setting should remain the same as that in the SCF procedure."; item.default_value = "false"; item.unit = ""; - item.availability = "For both PW and LCAO. When basis_type = pw, used if out_pchg is set. When basis_type = lcao, used only when calculation = get_pchg and gamma_only = 0."; + item.set_availability("basis_type==pw and out_pchg!=none or basis_type==lcao and calculation==get_pchg and gamma_only==0"); read_sync_bool(input.if_separate_k); this->add_item(item); } @@ -1575,7 +1575,7 @@ The second integer controls the precision of the kinetic energy density output, In molecular dynamics calculations, the output frequency is controlled by out_freq_ion.)"; item.default_value = "0 3"; item.unit = ""; - item.availability = "Only for Kohn-Sham DFT and Orbital Free DFT."; + item.set_availability("esolver_type in [ksdft, ofdft]"); item.read_value = [](const Input_Item& item, Parameter& para) { const size_t count = item.get_size(); if (count >= 1) @@ -1605,7 +1605,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr item.description = "This output is only intentively needed by the ABACUS numerical atomic orbital generation workflow. This parameter is used to control whether to output the overlap integrals between truncated spherical Bessel functions (TSBFs) and plane-wave basis expanded wavefunctions (named as OVERLAP_Q), and between TSBFs (named as OVERLAP_Sq), also their first order derivatives. The output files are named starting with orb_matrix. A value of 2 would enable the output."; item.default_value = "0"; item.unit = ""; - item.availability = "Only for Kohn-Sham DFT with plane-wave basis."; + item.set_availability("esolver_type==ksdft and basis_type==pw"); read_sync_int(input.out_spillage); this->add_item(item); } @@ -1634,7 +1634,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr * 2: Use the full Hamiltonian to construct the generalized velocity matrix in a nonorthogonal NAO basis, $\widetilde{v}_{\alpha}=\partial_{\alpha}H+\mathrm{i}HS^{-1}\mathcal{R}_{\alpha}-\mathrm{i}\mathcal{R}_{\alpha}S^{-1}H-HS^{-1}\partial_{\alpha}S$. This includes all contributions available in the real-space Hamiltonian matrix when enabled. This method is more general but more expensive. The total current is written to OUT.{suffix}/current_tot_comm.txt.)"; item.default_value = "0"; item.unit = ""; - item.availability = "basis_type==lcao and esolver_type==tddft"; + item.set_availability("basis_type==lcao and esolver_type==tddft"); read_sync_int(input.out_current); this->add_item(item); } @@ -1648,7 +1648,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr * False: Output only current_tot.txt for out_current=1 or current_tot_comm.txt for out_current=2.)"; item.default_value = "False"; item.unit = ""; - item.availability = "basis_type==lcao and esolver_type==tddft and out_current>0"; + item.set_availability("basis_type==lcao and esolver_type==tddft and out_current>0"); read_sync_bool(input.out_current_k); this->add_item(item); } @@ -1662,7 +1662,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr * False: Do not output electric-field values.)"; item.default_value = "False"; item.unit = ""; - item.availability = "esolver_type==tddft and td_vext==true"; + item.set_availability("esolver_type==tddft and td_vext==true"); read_sync_bool(input.out_efield); this->add_item(item); } @@ -1676,7 +1676,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr * False: Do not output the vector potential.)"; item.default_value = "False"; item.unit = ""; - item.availability = "basis_type==lcao and esolver_type==tddft"; + item.set_availability("basis_type==lcao and esolver_type==tddft"); read_sync_bool(input.out_vecpot); this->add_item(item); } @@ -1722,7 +1722,7 @@ In molecular dynamics calculations, the output frequency is controlled by out_fr item.description = "The directory to save the spillage files."; item.default_value = "\"./\""; item.unit = ""; - item.availability = "Used only for plane wave basis set."; + item.set_availability("basis_type==pw"); read_sync_string(input.spillage_outdir); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_postprocess.cpp b/source/source_io/module_parameter/read_input_item_postprocess.cpp index aad6f47a85..d51a225872 100644 --- a/source/source_io/module_parameter/read_input_item_postprocess.cpp +++ b/source/source_io/module_parameter/read_input_item_postprocess.cpp @@ -170,7 +170,7 @@ void ReadInput::item_postprocess() item.description = "Whether to calculate electronic conductivities."; item.default_value = "False"; item.unit = ""; - item.availability = "basis_type = pw"; + item.set_availability("basis_type==pw"); read_sync_bool(input.cal_cond); this->add_item(item); } @@ -182,7 +182,7 @@ void ReadInput::item_postprocess() item.description = "Control the error of Chebyshev expansions for conductivities."; item.default_value = "1e-8"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_double(input.cond_che_thr); this->add_item(item); } @@ -194,7 +194,7 @@ void ReadInput::item_postprocess() item.description = "Frequency interval () for frequency-dependent conductivities."; item.default_value = "0.1"; item.unit = "eV"; - item.availability = "basis_type = pw"; + item.set_availability("basis_type==pw"); read_sync_double(input.cond_dw); this->add_item(item); } @@ -206,7 +206,7 @@ void ReadInput::item_postprocess() item.description = "Cutoff frequency for frequency-dependent conductivities."; item.default_value = "10.0"; item.unit = "eV"; - item.availability = "basis_type = pw"; + item.set_availability("basis_type==pw"); read_sync_double(input.cond_wcut); this->add_item(item); } @@ -218,7 +218,7 @@ void ReadInput::item_postprocess() item.description = "Time interval () to integrate Onsager coefficients."; item.default_value = "0.02"; item.unit = "a.u."; - item.availability = "basis_type = pw"; + item.set_availability("basis_type==pw"); read_sync_double(input.cond_dt); this->add_item(item); } @@ -231,7 +231,7 @@ void ReadInput::item_postprocess() * If cond_dtbatch = 0: Autoset this parameter to make expansion orders larger than 100.)"; item.default_value = "0"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_int(input.cond_dtbatch); this->add_item(item); } @@ -257,7 +257,7 @@ void ReadInput::item_postprocess() item.description = "FWHM for conductivities. For Gaussian smearing, ; for Lorentzian smearing, ."; item.default_value = "0.4"; item.unit = "eV"; - item.availability = "basis_type = pw"; + item.set_availability("basis_type==pw"); read_sync_double(input.cond_fwhm); this->add_item(item); } @@ -271,7 +271,7 @@ void ReadInput::item_postprocess() * False: .)"; item.default_value = "True"; item.unit = ""; - item.availability = "basis_type = pw"; + item.set_availability("basis_type==pw"); read_sync_bool(input.cond_nonlocal); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_relax.cpp b/source/source_io/module_parameter/read_input_item_relax.cpp index b038674551..39b64f27a8 100644 --- a/source/source_io/module_parameter/read_input_item_relax.cpp +++ b/source/source_io/module_parameter/read_input_item_relax.cpp @@ -87,7 +87,7 @@ The second element is not accepted by other methods. item.description = "The paramether controls the size of the first conjugate gradient step. A smaller value means the first step along a new CG direction is smaller. This might be helpful for large systems, where it is safer to take a smaller initial step to prevent the collapse of the whole configuration."; item.default_value = "0.5"; item.unit = ""; - item.availability = "Only used when relax_method is cg 2"; + item.set_availability("relax_method in [cg 2]"); read_sync_double(input.relax_scale_force); this->add_item(item); } @@ -130,7 +130,7 @@ The second element is not accepted by other methods. item.description = "When relax_method is set to cg_bfgs, a mixed algorithm of conjugate gradient (CG) and Broyden–Fletcher–Goldfarb–Shanno (BFGS) is used. The ions first move according to the CG method, then switch to the BFGS method when the maximum force on atoms is reduced below this threshold."; item.default_value = "0.5"; item.unit = "eV/Angstrom"; - item.availability = "Only used when relax_method is cg_bfgs"; + item.set_availability("relax_method==cg_bfgs"); read_sync_double(input.relax_cg_thr); this->add_item(item); } @@ -198,7 +198,7 @@ The second element is not accepted by other methods. item.description = "Controls the Wolfe condition for the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm used in geometry relaxation. This parameter sets the sufficient decrease condition (c1 in Wolfe conditions). For more information, see Phys. Chem. Chem. Phys., 2000, 2, 2177."; item.default_value = "0.01"; item.unit = ""; - item.availability = "Only used when relax_method is bfgs or cg_bfgs"; + item.set_availability("relax_method in [bfgs, cg_bfgs]"); read_sync_double(input.relax_bfgs_w1); this->add_item(item); } @@ -210,7 +210,7 @@ The second element is not accepted by other methods. item.description = "Controls the Wolfe condition for the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm used in geometry relaxation. This parameter sets the curvature condition (c2 in Wolfe conditions). For more information, see Phys. Chem. Chem. Phys., 2000, 2, 2177."; item.default_value = "0.5"; item.unit = ""; - item.availability = "Only used when relax_method is bfgs or cg_bfgs"; + item.set_availability("relax_method in [bfgs, cg_bfgs]"); read_sync_double(input.relax_bfgs_w2); this->add_item(item); } @@ -222,7 +222,7 @@ The second element is not accepted by other methods. item.description = "Maximum allowed total displacement of all atoms during geometry optimization. The sum of atomic displacements can increase during optimization steps but cannot exceed this value."; item.default_value = "0.8"; item.unit = "Bohr"; - item.availability = "Only used when relax_method is bfgs or cg_bfgs"; + item.set_availability("relax_method in [bfgs, cg_bfgs]"); read_sync_double(input.relax_bfgs_rmax); this->add_item(item); } @@ -234,7 +234,7 @@ The second element is not accepted by other methods. item.description = "Minimum allowed total displacement of all atoms. When the total atomic displacement falls below this value and force convergence is not achieved, the calculation will terminate. Note: This parameter is not used in the default BFGS algorithm (relax_method = bfgs 2 or bfgs)."; item.default_value = "1e-5"; item.unit = "Bohr"; - item.availability = "Only used when relax_method is bfgs 1 (traditional BFGS)"; + item.set_availability("relax_method in [bfgs 1]"); read_sync_double(input.relax_bfgs_rmin); this->add_item(item); } @@ -246,7 +246,7 @@ The second element is not accepted by other methods. item.description = "Initial total displacement of all atoms in the first BFGS step. This sets the scale for the initial movement."; item.default_value = "0.5"; item.unit = "Bohr"; - item.availability = "Only used when relax_method is bfgs or cg_bfgs"; + item.set_availability("relax_method in [bfgs, cg_bfgs]"); read_sync_double(input.relax_bfgs_init); this->add_item(item); } @@ -322,7 +322,7 @@ With relax_method set to cg 1, bfgs, lbfgs, sd, or cg_bfgs, None and a, b, c, ab [NOTE] For VASP users, see the ISIF correspondence table in the geometry optimization documentation.)"; item.default_value = "None"; item.unit = ""; - item.availability = "Only used when calculation is set to cell-relax"; + item.set_availability("calculation==cell-relax"); read_sync_string(input.fixed_axes); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.fixed_axes == "shape" || para.input.fixed_axes == "volume") @@ -344,7 +344,7 @@ With relax_method set to cg 1, bfgs, lbfgs, sd, or cg_bfgs, None and a, b, c, ab [NOTE] Note: it is possible to use fixed_ibrav with fixed_axes, but please make sure you know what you are doing. For example, if we are doing relaxation of a simple cubic lattice (latname = "sc"), and we use fixed_ibrav along with fixed_axes = "volume", then the cell is never allowed to move and as a result, the relaxation never converges. When both are used, fixed_ibrav is applied first, then fixed_axes = "volume" rescaling is applied.)"; item.default_value = "False"; item.unit = ""; - item.availability = "Only used with relax_method = cg 2. A specific latname must be provided."; + item.set_availability("relax_method in [cg 2] and latname != none"); read_sync_bool(input.fixed_ibrav); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.fixed_ibrav && !para.input.uses_simultaneous_relaxation()) diff --git a/source/source_io/module_parameter/read_input_item_sdft.cpp b/source/source_io/module_parameter/read_input_item_sdft.cpp index 2df4f2d661..5b4fb08364 100644 --- a/source/source_io/module_parameter/read_input_item_sdft.cpp +++ b/source/source_io/module_parameter/read_input_item_sdft.cpp @@ -22,7 +22,7 @@ void ReadInput::item_sdft() * other: use 2)"; item.default_value = "2"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_int(input.method_sto); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.method_sto != 1 && para.input.method_sto != 2) @@ -43,7 +43,7 @@ void ReadInput::item_sdft() * all: All complete basis sets are used to replace stochastic orbitals with the Chebyshev method (CT), resulting in the same results as KSDFT without stochastic errors.)"; item.default_value = "256"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); item.read_value = [](const Input_Item& item, Parameter& para) { std::string nbandsto_str = strvalue; if (nbandsto_str != "all") @@ -97,7 +97,7 @@ void ReadInput::item_sdft() item.description = "Chebyshev expansion orders for stochastic DFT."; item.default_value = "100"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_int(input.nche_sto); this->add_item(item); } @@ -110,7 +110,7 @@ void ReadInput::item_sdft() item.description = "Trial energy to guess the lower bound of eigen energies of the Hamiltonian Operator."; item.default_value = "0.0"; item.unit = "Ry"; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_double(input.emin_sto); this->add_item(item); } @@ -123,7 +123,7 @@ void ReadInput::item_sdft() item.description = "Trial energy to guess the upper bound of eigen energies of the Hamiltonian Operator."; item.default_value = "0.0"; item.unit = "Ry"; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_double(input.emax_sto); this->add_item(item); } @@ -139,7 +139,7 @@ void ReadInput::item_sdft() * -1: the seed is decided by time(NULL).)"; item.default_value = "0"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_int(input.seed_sto); this->add_item(item); } @@ -151,7 +151,7 @@ void ReadInput::item_sdft() item.description = R"(Stochastic wave functions are initialized in a large box generated by "4*initsto_ecut". initsto_ecut should be larger than ecutwfc. In this method, SDFT results are the same when using different cores. Besides, coefficients of the same G are the same when ecutwfc is rising to initsto_ecut. If it is smaller than ecutwfc, it will be turned off.)"; item.default_value = "0.0"; item.unit = "Ry"; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_double(input.initsto_ecut); this->add_item(item); } @@ -165,7 +165,7 @@ void ReadInput::item_sdft() * 0: Never change stochastic orbitals.)"; item.default_value = "0"; item.unit = ""; - item.availability = "esolver_type = sdft"; + item.set_availability("esolver_type==sdft"); read_sync_int(input.initsto_freq); this->add_item(item); } @@ -177,7 +177,7 @@ void ReadInput::item_sdft() item.description = "Make memory cost to 1/npart_sto times of the previous one when running the post process of SDFT like DOS or conductivities."; item.default_value = "1"; item.unit = ""; - item.availability = "method_sto = 2 and out_dos = 1 or cal_cond = True"; + item.set_availability("method_sto==2 and out_dos==1 or cal_cond==true"); read_sync_int(input.npart_sto); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_system.cpp b/source/source_io/module_parameter/read_input_item_system.cpp index 68a066637f..53936ebda8 100644 --- a/source/source_io/module_parameter/read_input_item_system.cpp +++ b/source/source_io/module_parameter/read_input_item_system.cpp @@ -258,7 +258,7 @@ void ReadInput::item_system() "* False: quit with an error message\n" "* True: automatically set symmetry to 0 and continue running without symmetry analysis"; item.default_value = "True"; - item.availability = "symmetry==1"; + item.set_availability("symmetry==1"); read_sync_bool(input.symmetry_autoclose); this->add_item(item); } @@ -545,7 +545,7 @@ Available options are: * 0: no memory saving techniques are used. * 1: a memory saving technique will be used for many k point calculations.)"; item.default_value = "0"; - item.availability = "Used only for nscf calculations with plane wave basis set."; + item.set_availability("calculation==nscf and basis_type==pw"); read_sync_int(input.mem_saver); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.mem_saver == 1) @@ -591,7 +591,7 @@ Available options are: item.description = R"(* 0: it will be set to the number of MPI processes. * >0: it specifies the number of processes used for carrying out diagonalization. Must be less than or equal to total number of MPI processes.)"; item.default_value = "0"; - item.availability = "Used only for plane wave basis set."; + item.set_availability("basis_type==pw"); read_sync_int(input.diago_proc); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.diago_proc == 0) @@ -771,7 +771,7 @@ Available options are: * single: single precision * double: double precision)"; item.default_value = "double"; - item.availability = "Used only for plane wave basis set."; + item.set_availability("basis_type==pw"); read_sync_string(input.precision); item.check_value = [](const Input_Item& item, const Parameter& para) { std::vector avail_list = {"single", "double"}; @@ -809,7 +809,7 @@ Available options are: * double: double precision * mix: mixed precision, starting from single precision and switching to double precision when the SCF residual becomes small enough)"; item.default_value = "double"; - item.availability = "Used only for LCAO basis set."; + item.set_availability("basis_type==lcao"); read_sync_string(input.gint_precision); item.check_value = [](const Input_Item& item, const Parameter& para) { std::vector avail_list = {"single", "double", "mix"}; @@ -1162,7 +1162,7 @@ Available options are: item.type = "Integer"; item.description = "Specify the random seed to initialize wave functions. Only positive integers are available."; item.default_value = "0"; - item.availability = "Only used for plane wave basis."; + item.set_availability("basis_type==pw"); read_sync_int(input.pw_seed); this->add_item(item); } @@ -1323,7 +1323,7 @@ Available options are: item.description = "If restart_save is set to true and an electronic iteration is finished, calculations can be " "restarted from the charge density file, which are saved in the former calculation."; item.default_value = "False"; - item.availability = "Used only when numerical atomic orbitals are employed as basis set."; + item.set_availability("basis_type==lcao"); read_sync_bool(input.restart_load); this->add_item(item); } diff --git a/source/source_io/module_parameter/read_input_item_tddft.cpp b/source/source_io/module_parameter/read_input_item_tddft.cpp index 50f10eccef..47837a3d13 100644 --- a/source/source_io/module_parameter/read_input_item_tddft.cpp +++ b/source/source_io/module_parameter/read_input_item_tddft.cpp @@ -360,7 +360,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Ordinary frequency $f$ in the Gaussian-pulse formula, with $\omega=2\pi f$. Supply exactly one value for each td_ttype 0 occurrence, in occurrence order.)"; item.default_value = "22.13"; item.unit = "1/fs"; - item.availability = "td_ttype contains 0"; + item.set_availability("td_ttype contains 0"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_gauss_freq); }; @@ -375,7 +375,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Carrier phase $\varphi$ in the Gaussian-pulse formula. Supply exactly one value for each td_ttype 0 occurrence, in occurrence order.)"; item.default_value = "0.0"; item.unit = "rad"; - item.availability = "td_ttype contains 0"; + item.set_availability("td_ttype contains 0"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_gauss_phase); }; @@ -390,7 +390,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Nonzero standard deviation $\sigma$ of the Gaussian envelope. Supply exactly one value for each td_ttype 0 occurrence, in occurrence order.)"; item.default_value = "30.0"; item.unit = "fs"; - item.availability = "td_ttype contains 0"; + item.set_availability("td_ttype contains 0"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_gauss_sigma); }; @@ -405,7 +405,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electronic-step position of the Gaussian center, which defines $t_0=\mathtt{td\_gauss\_t0}\Delta t$. Supply exactly one value for each td_ttype 0 occurrence, in occurrence order.)"; item.default_value = "100"; item.unit = ""; - item.availability = "td_ttype contains 0"; + item.set_availability("td_ttype contains 0"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_gauss_t0); }; @@ -420,7 +420,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electric-field scale $E_0$ in the Gaussian-pulse formula. Supply exactly one value for each td_ttype 0 occurrence, in occurrence order.)"; item.default_value = "0.25"; item.unit = "V/Angstrom"; - item.availability = "td_ttype contains 0"; + item.set_availability("td_ttype contains 0"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_gauss_amp); }; @@ -435,7 +435,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Ordinary carrier frequency $f$ in the trapezoid-pulse formula, with $\omega=2\pi f$. Supply exactly one value for each td_ttype 1 occurrence, in occurrence order.)"; item.default_value = "1.60"; item.unit = "1/fs"; - item.availability = "td_ttype contains 1"; + item.set_availability("td_ttype contains 1"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trape_freq); }; @@ -450,7 +450,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Carrier phase $\varphi$ in the trapezoid-pulse formula. Supply exactly one value for each td_ttype 1 occurrence, in occurrence order.)"; item.default_value = "0.0"; item.unit = "rad"; - item.availability = "td_ttype contains 1"; + item.set_availability("td_ttype contains 1"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trape_phase); }; @@ -465,7 +465,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electronic step defining the end of the linear rise, $t_1=\mathtt{td\_trape\_t1}\Delta t$. Each field must satisfy td_trape_t1 <= td_trape_t2 <= td_trape_t3. Supply exactly one value for each td_ttype 1 occurrence, in occurrence order.)"; item.default_value = "1875"; item.unit = ""; - item.availability = "td_ttype contains 1"; + item.set_availability("td_ttype contains 1"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trape_t1); }; @@ -480,7 +480,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electronic step defining the end of the plateau, $t_2=\mathtt{td\_trape\_t2}\Delta t$. Each field must satisfy td_trape_t1 <= td_trape_t2 <= td_trape_t3. Supply exactly one value for each td_ttype 1 occurrence, in occurrence order.)"; item.default_value = "5625"; item.unit = ""; - item.availability = "td_ttype contains 1"; + item.set_availability("td_ttype contains 1"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trape_t2); }; @@ -495,7 +495,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electronic step defining the end of the linear fall, $t_3=\mathtt{td\_trape\_t3}\Delta t$. Each field must satisfy td_trape_t1 <= td_trape_t2 <= td_trape_t3. Supply exactly one value for each td_ttype 1 occurrence, in occurrence order.)"; item.default_value = "7500"; item.unit = ""; - item.availability = "td_ttype contains 1"; + item.set_availability("td_ttype contains 1"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trape_t3); }; @@ -510,7 +510,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electric-field scale $E_0$ in the trapezoid-pulse formula. Supply exactly one value for each td_ttype 1 occurrence, in occurrence order.)"; item.default_value = "2.74"; item.unit = "V/Angstrom"; - item.availability = "td_ttype contains 1"; + item.set_availability("td_ttype contains 1"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trape_amp); }; @@ -525,7 +525,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(First ordinary frequency $f_1$ in the trigonometric-pulse formula, with $\omega_1=2\pi f_1$. Supply exactly one value for each td_ttype 2 occurrence, in occurrence order.)"; item.default_value = "1.164656"; item.unit = "1/fs"; - item.availability = "td_ttype contains 2"; + item.set_availability("td_ttype contains 2"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trigo_freq1); }; @@ -540,7 +540,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Second ordinary frequency $f_2$ in the trigonometric-pulse formula, with $\omega_2=2\pi f_2$. Supply exactly one value for each td_ttype 2 occurrence, in occurrence order.)"; item.default_value = "0.029116"; item.unit = "1/fs"; - item.availability = "td_ttype contains 2"; + item.set_availability("td_ttype contains 2"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trigo_freq2); }; @@ -555,7 +555,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Carrier phase $\varphi_1$ in the cosine factor of the trigonometric-pulse formula. Supply exactly one value for each td_ttype 2 occurrence, in occurrence order.)"; item.default_value = "0.0"; item.unit = "rad"; - item.availability = "td_ttype contains 2"; + item.set_availability("td_ttype contains 2"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trigo_phase1); }; @@ -570,7 +570,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Envelope phase $\varphi_2$ in the sine-squared factor of the trigonometric-pulse formula. Supply exactly one value for each td_ttype 2 occurrence, in occurrence order.)"; item.default_value = "0.0"; item.unit = "rad"; - item.availability = "td_ttype contains 2"; + item.set_availability("td_ttype contains 2"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trigo_phase2); }; @@ -585,7 +585,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electric-field scale $E_0$ in the trigonometric-pulse formula. Supply exactly one value for each td_ttype 2 occurrence, in occurrence order.)"; item.default_value = "2.74"; item.unit = "V/Angstrom"; - item.availability = "td_ttype contains 2"; + item.set_availability("td_ttype contains 2"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_trigo_amp); }; @@ -600,7 +600,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electronic switch step $n_0$ in the Heaviside-pulse definition. The field is $E_0$ for $n\lt n_0$ and zero for $n\geqslant n_0$. Supply exactly one value for each td_ttype 3 occurrence, in occurrence order.)"; item.default_value = "100"; item.unit = ""; - item.availability = "td_ttype contains 3"; + item.set_availability("td_ttype contains 3"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_heavi_t0); }; @@ -615,7 +615,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electric-field scale $E_0$ in the Heaviside-pulse definition. Supply exactly one value for each td_ttype 3 occurrence, in occurrence order.)"; item.default_value = "1.0"; item.unit = "V/Angstrom"; - item.availability = "td_ttype contains 3"; + item.set_availability("td_ttype contains 3"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_heavi_amp); }; @@ -630,7 +630,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Carrier electric-field scale $E_0$ of each supersine pulse. This is not a normalization of the complete waveform maximum, because the envelope-derivative term also contributes. Supply exactly one value for each td_ttype 4 occurrence, in occurrence order.)"; item.default_value = "0.27"; item.unit = "V/Angstrom"; - item.availability = "td_ttype contains 4"; + item.set_availability("td_ttype contains 4"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_supsine_amp); }; @@ -645,7 +645,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Nonzero ordinary carrier frequency $f$ of each supersine pulse, with $\omega=2\pi f$. Supply exactly one value for each td_ttype 4 occurrence, in occurrence order.)"; item.default_value = "0.18737028625"; item.unit = "1/fs"; - item.availability = "td_ttype contains 4"; + item.set_availability("td_ttype contains 4"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_supsine_freq); }; @@ -660,7 +660,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Electric-field carrier phase $\varphi$ at the center of each supersine envelope. A value of 0 places a cosine carrier maximum at the envelope center. Supply exactly one value for each td_ttype 4 occurrence, in occurrence order.)"; item.default_value = "0.0"; item.unit = "rad"; - item.availability = "td_ttype contains 4"; + item.set_availability("td_ttype contains 4"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_supsine_phase); }; @@ -675,7 +675,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Dimensionless shape parameter $\sigma$ of each supersine envelope. It must satisfy $0\lt\sigma\lt\pi/2$ so that the electric field approaches zero at the pulse boundaries. Supply exactly one value for each td_ttype 4 occurrence, in occurrence order.)"; item.default_value = "0.75"; item.unit = ""; - item.availability = "td_ttype contains 4"; + item.set_availability("td_ttype contains 4"); item.read_value = [](const Input_Item& item, Parameter& para) { parse_expression(item.str_values, para.input.td_supsine_sigma); }; @@ -690,7 +690,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Integer electronic step at the left, exactly zero boundary of each supersine pulse, defining $t_{\mathrm{s}}=\mathtt{td\_supsine\_tstart}\Delta t$. Supply exactly one integer or default token for each td_ttype 4 occurrence, in occurrence order; each default token inherits td_tstart. The complete pulse support must lie inside the inclusive global td_tstart to td_tend interval; hard truncation of a supersine pulse is rejected.)"; item.default_value = "default"; item.unit = ""; - item.availability = "td_ttype contains 4"; + item.set_availability("td_ttype contains 4"); item.reset_value = [](const Input_Item& item, Parameter& para) { para.input.td_supsine_tstart = parse_supersine_steps(item, para.input.td_tstart); }; @@ -708,7 +708,7 @@ In the velocity and hybrid gauges, ABACUS obtains the vector potential actually item.description = R"(Integer electronic step at the right, exactly zero boundary of each supersine pulse, defining $t_{\mathrm{e}}=\mathtt{td\_supsine\_tend}\Delta t$. Supply exactly one integer or default token for each td_ttype 4 occurrence, in occurrence order; each default token inherits td_tend. The complete pulse support must lie inside the inclusive global td_tstart to td_tend interval; hard truncation of a supersine pulse is rejected.)"; item.default_value = "default"; item.unit = ""; - item.availability = "td_ttype contains 4"; + item.set_availability("td_ttype contains 4"); item.reset_value = [](const Input_Item& item, Parameter& para) { para.input.td_supsine_tend = parse_supersine_steps(item, para.input.td_tend); }; @@ -787,7 +787,7 @@ void ReadInput::item_tdofdft() * False: Not added the CD potential.)"; item.default_value = "False"; item.unit = ""; - item.availability = "TDOFDFT"; + item.set_availability("esolver_type==tdofdft"); read_sync_bool(input.of_cd); this->add_item(item); } @@ -799,7 +799,7 @@ void ReadInput::item_tdofdft() item.description = "The value of the parameter alpha in modified CD potential method. mCDPotential=alpha*CDPotential (proposed in paper PhysRevB.98.144302)"; item.default_value = "1.0"; item.unit = ""; - item.availability = "TDOFDFT"; + item.set_availability("esolver_type==tdofdft"); read_sync_double(input.of_mCD_alpha); this->add_item(item); } diff --git a/source/source_io/test_serial/CMakeLists.txt b/source/source_io/test_serial/CMakeLists.txt index a985cc7eef..a6de46807d 100644 --- a/source/source_io/test_serial/CMakeLists.txt +++ b/source/source_io/test_serial/CMakeLists.txt @@ -39,6 +39,15 @@ AddTest( SOURCES read_input_item_test.cpp ) +# availability parser is dependency-free; test it directly against +# source/source_io/module_parameter/availability.cpp +AddTest( + TARGET MODULE_IO_availability_serial + LIBS base + SOURCES availability_test.cpp + ../module_parameter/availability.cpp +) + AddTest( TARGET MODULE_IO_read_input_tool SOURCES read_input_tool_test.cpp diff --git a/source/source_io/test_serial/availability_test.cpp b/source/source_io/test_serial/availability_test.cpp new file mode 100644 index 0000000000..e3f66fca4c --- /dev/null +++ b/source/source_io/test_serial/availability_test.cpp @@ -0,0 +1,102 @@ +/// Unit tests for the INPUT availability parser. +/// +/// availability.{h,cpp} is dependency-free (only the C++ standard library), so +/// this test exercises the actual parser used by Input_Item directly. +#include "source_io/module_parameter/availability.h" + +#include "gtest/gtest.h" + +namespace ModuleIO +{ + +TEST(AvailabilityParser, LeafEqualityRoundTrip) +{ + const AvailabilityExpr e = parse_availability("basis_type==pw"); + EXPECT_TRUE(e.is_leaf()); + EXPECT_EQ(e.condition.param, "basis_type"); + EXPECT_EQ(e.condition.op, "=="); + EXPECT_EQ(e.condition.values, (std::vector{"pw"})); + EXPECT_EQ(e.to_string(), "basis_type==pw"); +} + +TEST(AvailabilityParser, InListRoundTrip) +{ + const AvailabilityExpr e = parse_availability("vdw_method in [d2, d3_0]"); + EXPECT_TRUE(e.is_leaf()); + EXPECT_EQ(e.condition.op, "in"); + EXPECT_EQ(e.condition.values, (std::vector{"d2", "d3_0"})); + EXPECT_EQ(e.to_string(), "vdw_method in [d2, d3_0]"); +} + +TEST(AvailabilityParser, ContainsVectorSemantics) +{ + // td_ttype is a Vector; "contains 2" is containment and must stay distinct + // from scalar membership "in [2]". + const AvailabilityExpr e = parse_availability("td_ttype contains 2"); + EXPECT_TRUE(e.is_leaf()); + EXPECT_EQ(e.condition.op, "contains"); + EXPECT_EQ(e.condition.values, (std::vector{"2"})); + EXPECT_EQ(e.to_string(), "td_ttype contains 2"); +} + +TEST(AvailabilityParser, AndGroup) +{ + const AvailabilityExpr e = parse_availability("basis_type==lcao and esolver_type==tddft"); + EXPECT_FALSE(e.is_leaf()); + EXPECT_EQ(e.op, "and"); + ASSERT_EQ(e.children.size(), 2u); + EXPECT_TRUE(e.children[0].is_leaf()); + EXPECT_EQ(e.children[0].condition.param, "basis_type"); + EXPECT_TRUE(e.children[1].is_leaf()); + EXPECT_EQ(e.children[1].condition.param, "esolver_type"); + EXPECT_EQ(e.to_string(), "basis_type==lcao and esolver_type==tddft"); +} + +TEST(AvailabilityParser, ParenthesisedOrNesting) +{ + // "and" binds looser than "or"; the grouped "(A or B)" stays a sub-tree. + const AvailabilityExpr e = parse_availability( + "symmetry==1 and (dft_functional in [hse, hf] or rpa==true)"); + EXPECT_FALSE(e.is_leaf()); + EXPECT_EQ(e.op, "and"); + ASSERT_EQ(e.children.size(), 2u); + EXPECT_TRUE(e.children[0].is_leaf()); + EXPECT_EQ(e.children[0].condition.param, "symmetry"); + const AvailabilityExpr& or_node = e.children[1]; + EXPECT_FALSE(or_node.is_leaf()); + EXPECT_EQ(or_node.op, "or"); + ASSERT_EQ(or_node.children.size(), 2u); + EXPECT_EQ(or_node.children[0].condition.param, "dft_functional"); + EXPECT_EQ(or_node.children[1].condition.param, "rpa"); + EXPECT_EQ(e.to_string(), + "symmetry==1 and (dft_functional in [hse, hf] or rpa==true)"); +} + +TEST(AvailabilityParser, EmptyIsAlwaysAvailable) +{ + const AvailabilityExpr e = parse_availability(""); + EXPECT_TRUE(e.is_leaf()); + EXPECT_TRUE(e.condition.param.empty()); +} + +TEST(AvailabilityParser, KeywordsNearStringEndDoNotCrash) +{ + // Exercise inputs where a keyword ("and"/"or") sits at/just before the + // string end, which previously could index past the buffer. + const char* edge_cases[] = { + "and", + " or", + "basis_type==pw or", + "a and", + " and basis_type==pw", + "basis_type==lcao and esolver_type==tddft or ", + }; + for (const char* s : edge_cases) + { + const AvailabilityExpr e = parse_availability(s); + // Parser must not crash; result is either empty or a parseable tree. + EXPECT_NO_THROW(e.to_string()); + } +} + +} // namespace ModuleIO diff --git a/tools/03_code_analysis/availability_parser.py b/tools/03_code_analysis/availability_parser.py index 6609ef3779..d898ee699a 100644 --- a/tools/03_code_analysis/availability_parser.py +++ b/tools/03_code_analysis/availability_parser.py @@ -83,7 +83,7 @@ def __repr__(self): _CONTAINS = re.compile(r"\bcontains\b", re.IGNORECASE) _IN = re.compile(r"\bin\b", re.IGNORECASE) -_PARAM_LIKE = re.compile(r"^[a-z][a-z0-9_]*$") +_PARAM_LIKE = re.compile(r"^[A-Za-z][A-Za-z0-9_]*$") def _canonical_value(v): @@ -115,30 +115,57 @@ def _split_values_tokens(tokens): def _parse_single_condition(text, param_regex): """Try to parse ``text`` (a single atom) as ``param ``. - Returns a Condition or None. + Returns a Condition or None. Handles the canonical grammar (==, >=, <=, + !=, >, <, ``in [a, b]``) plus the historical spellings (``=``, + ``is set to``, ``is``, ``contains``). """ text = text.strip().strip('"').strip() if not text: return None - # param == value / param = value - for op in ("==", "="): - idx = text.find(op) - if idx > 0: - param = text[:idx].strip() - rhs = text[idx + len(op):].strip() - if param_regex(param) and rhs: + # canonical comparison operators (longest/most specific first) + for op in ("==", ">=", "<=", "!=", ">", "<"): + pos = text.find(op) + if pos > 0: + param = text[:pos].strip() + rhs = text[pos + len(op):].strip() + if not (param_regex(param) and rhs): + return None + if op == "==": + # equality may carry a slash/comma-separated value list values = _split_values_tokens([t for t in re.split(r"[/,]", rhs)]) values = [v for v in values if v] - if values: - return Condition(param, "==", values) - return None + if not values: + return None + return Condition(param, "==", values) + return Condition(param, op, [rhs]) + + # legacy single '=' as equality + pos = text.find("=") + if pos > 0: + param = text[:pos].strip() + rhs = text[pos + 1:].strip() + if param_regex(param) and rhs: + values = _split_values_tokens([t for t in re.split(r"[/,]", rhs)]) + values = [v for v in values if v] + if values: + return Condition(param, "==", values) + return None - # param is set to / param is / param contains - for marker, op in ( - (_IS_SETTO, "=="), - (_CONTAINS, "in"), - ): + # canonical in-list: param in [v1, v2] + m_in = re.search(r"\bin\s*\[", text, re.IGNORECASE) + if m_in: + param = text[:m_in.start()].strip() + rest = text[m_in.end():].strip() + if rest.endswith("]") and param_regex(param): + values = [v.strip().strip('"').strip("'").rstrip(".") for v in rest[:-1].split(",")] + values = [v for v in values if v] + if values: + return Condition(param, "in", values) + return None + + # historical: is set to / contains / is + for marker, op in ((_IS_SETTO, "=="), (_CONTAINS, "contains")): m = marker.search(text) if m: param = text[: m.start()].strip() @@ -159,7 +186,6 @@ def _parse_single_condition(text, param_regex): values = _split_values_tokens([t for t in re.split(r"[,/]", rhs)]) values = [v for v in values if v] if values: - # "param is true/false" -> ==; otherwise treat as membership op = "==" if len(values) == 1 else "in" return Condition(param, op, values) return None @@ -167,64 +193,138 @@ def _parse_single_condition(text, param_regex): return None -def _tokenise_bool(text): - """Split a boolean expression at top-level ``and``/``or``/``,``. +def _split_top_level(text, keywords): + """Split ``text`` on the given keywords at bracket/paren depth 0. - Returns a list of ``(atom_text, sep)`` pairs where ``sep`` is the - connecting keyword that followed the atom (``and``/``or``/``,``), or - ``None`` for the last atom. + Comma counts as a separator; word keywords (and/or) require word + boundaries. Everything inside ``(...)`` or ``[...]`` is kept intact. """ - tokens = re.split(r"(\band\b|\bor\b|,)", text, flags=re.IGNORECASE) + keywords = sorted(keywords, key=len, reverse=True) parts = [] - pending_sep = None - for t in tokens: - t = t.strip() - if not t: + depth = 0 + start = 0 + n = len(text) + i = 0 + while i < n: + c = text[i] + if c in "([": + depth += 1 + i += 1 continue - low = t.lower() - if low in ("and", "or", ","): - # separator that binds the *previous* atom to the next one - pending_sep = low if low != "," else "and" + if c in ")]": + depth = max(0, depth - 1) + i += 1 continue - parts.append((t, pending_sep)) - pending_sep = None + if depth == 0: + matched = False + for kw in keywords: + if kw == ",": + if c == ",": + seg = text[start:i].strip() + if seg: + parts.append(seg) + start = i + 1 + i = start + matched = True + break + else: + prev_bound = (i == 0) or text[i - 1].isspace() + next_bound = (i + len(kw) >= n) or text[i + len(kw)].isspace() \ + or text[i + len(kw)] in "([" + if prev_bound and next_bound and text.startswith(kw, i): + seg = text[start:i].strip() + if seg: + parts.append(seg) + start = i + len(kw) + i = start + matched = True + break + if matched: + continue + i += 1 + seg = text[start:].strip() + if seg: + parts.append(seg) return parts +def _build_expr(text, param_regex): + """Recursively build an Expr/leaf from a boolean availability string. + + Returns a Condition/Expr or None if any part is not parseable. + """ + text = text.strip() + if not text: + return None + + # Unwrap a parenthesized group that wraps the entire expression. + if text.startswith("(") and text.endswith(")"): + depth = 0 + wraps_all = True + for k, ch in enumerate(text): + if ch == "(": + depth += 1 + elif ch == ")": + depth -= 1 + if depth == 0 and k != len(text) - 1: + wraps_all = False + break + if wraps_all: + return _build_expr(text[1:-1], param_regex) + + # OR (top level) + or_parts = _split_top_level(text, ["or"]) + if len(or_parts) > 1: + children = [_build_expr(p, param_regex) for p in or_parts] + if all(children): + return Expr("or", children) + return None + + # AND (top level, including comma) + and_parts = _split_top_level(text, ["and", ","]) + if len(and_parts) > 1: + children = [_build_expr(p, param_regex) for p in and_parts] + if all(children): + return Expr("and", children) + return None + + # A single atom (which may itself be a parenthesized group). + atom = text.strip() + if atom.startswith("(") and atom.endswith(")"): + return _build_expr(atom[1:-1], param_regex) + return _parse_single_condition(atom, param_regex) + + def parse_availability(text, param_regex=_PARAM_LIKE.match): """Parse an availability string into an :class:`Availability`. :param text: raw availability string (may be empty). :param param_regex: callable ``(str) -> bool`` used to decide whether a leading token is a plausible parameter name. Defaults to a loose - lowercase identifier check. + identifier check. """ text = (text or "").strip() if not text: return Availability("Label", text=text) + # Canonical label form: "label: " + if len(text) >= 6 and text[:6].lower() == "label:": + return Availability("Label", label=text[6:].strip(), text=text) + # Cheap rejection of obvious prose / bare labels (no operator present). has_operator = re.search( - r"==|=| in | in$| is set to|\bis\b|\bcontains\b", text, re.IGNORECASE + r"==|=| in | in\[| in$| is set to|\bis\b|\bcontains\b|>=|<=|!=|\b>\b|\b<\b", + text, re.IGNORECASE, ) if not has_operator: return Availability("Label", label=text.strip('"').rstrip('.'), text=text) - # Try to interpret as a boolean condition over atoms. - atoms = _tokenise_bool(text) - conds = [] - for atom, sep in atoms: - c = _parse_single_condition(atom, param_regex) - if c is None: - # Not parseable -> whole thing is unstructured. - return Availability("Unstructured", text=text) - conds.append((c, sep)) - - if not conds: + expr = _build_expr(text, param_regex) + if expr is None: return Availability("Unstructured", text=text) - - # Build an AND/OR expression tree from the parsed atoms and connectors. - nodes = [c for c, _ in conds] - expr = Expr("and", nodes) # flat AND; OR connectors are recorded but not - # given a separate tree node (no parenthesised precedence in current data). + # Always expose a top-level Expr node so that consumers can iterate + # ``expr.children`` (matching the historical flat-AND shape for simple + # conditions). + if isinstance(expr, Condition): + expr = Expr("and", [expr]) return Availability("Expression", expr=expr, text=text) diff --git a/tools/03_code_analysis/test_availability_parser.py b/tools/03_code_analysis/test_availability_parser.py index dfd17cbb3b..eb0948651e 100644 --- a/tools/03_code_analysis/test_availability_parser.py +++ b/tools/03_code_analysis/test_availability_parser.py @@ -84,6 +84,80 @@ def test_text_preserved(self): r = parse_availability("basis_type==lcao") self.assertEqual(r.text, "basis_type==lcao") + def test_in_list(self): + r = parse_availability("vdw_method in [d2, d3_0, d3_bj]") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), + ("vdw_method", "in", ["d2", "d3_0", "d3_bj"])) + + def test_comparison_operator(self): + r = parse_availability("vdw_C6_file!=default") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), ("vdw_C6_file", "!=", ["default"])) + + def test_label_prefix(self): + r = parse_availability("label: Numerical atomic orbital basis") + self.assertEqual(r.kind, "Label") + self.assertEqual(r.label, "Numerical atomic orbital basis") + + def test_parens_or_group(self): + r = parse_availability( + "symmetry==1 and (dft_functional in [hse, hf, pbe0, scan0] or rpa==true)") + self.assertEqual(r.kind, "Expression") + root = r.expr + # "and" binds looser than "or"; the grouped "(A or B)" must stay a + # separate child so precedence is preserved. + self.assertIsInstance(root, Expr) + self.assertEqual(root.op, "and") + self.assertEqual(len(root.children), 2) + c0, c1 = root.children + self.assertIsInstance(c0, Condition) + self.assertEqual((c0.param, c0.op, c0.values), ("symmetry", "==", ["1"])) + self.assertIsInstance(c1, Expr) + self.assertEqual(c1.op, "or") + self.assertEqual(len(c1.children), 2) + d, rpa = c1.children + self.assertEqual((d.param, d.op, d.values), + ("dft_functional", "in", ["hse", "hf", "pbe0", "scan0"])) + self.assertEqual((rpa.param, rpa.op, rpa.values), ("rpa", "==", ["true"])) + + def test_contains_vector_semantics(self): + # td_ttype is a Vector: "contains 2" is containment, distinct from + # scalar membership ("in [2]"), so the operator must be preserved. + r = parse_availability("td_ttype contains 2") + self.assertEqual(r.kind, "Expression") + c = _conds(r)[0] + self.assertEqual((c.param, c.op, c.values), ("td_ttype", "contains", ["2"])) + + def test_parameters_yaml_availability_are_all_expression(self): + """Every non-empty availability in the canonical parameters.yaml must be + a concrete boolean Expression. Any Label/Unstructured (prose) non-empty + value fails the PR build: we do not silently accept non-expressions. + """ + try: + import yaml + except ImportError: + self.skipTest("PyYAML not available") + yaml_path = REPO_ROOT / "docs" / "parameters.yaml" + if not yaml_path.exists(): + self.skipTest("docs/parameters.yaml not present") + data = yaml.safe_load(yaml_path.read_text()) + params = data.get("parameters", []) + bad = [] + for p in params: + avail = (p.get("availability") or "").strip() + if not avail: + continue + r = parse_availability(avail) + if r.kind != "Expression": + bad.append((p.get("name"), avail, r.kind)) + self.assertEqual(bad, [], + "non-Expression availability present (not all " + "availability are machine-evaluable conditions): " + + repr(bad)) + if __name__ == "__main__": unittest.main()