Skip to content

Multiwfn (multiwfn.py)

The core engine for building and running Multiwfn sequences.

pymultiwfn.api.multiwfn

Configuration interaction with Multiwfn.

This class relates to the actual Multiwfn executable (e.g., executable path), rather than the details of a specific job/analysis (e.g., timeout and parsing).

Multiwfn

Configuration for Multiwfn execution.

Attributes

exe_path : Path, optional Explicit path to Multiwfn executable. If not provided, looks for executable in bin/ directory relative to this package.

Examples

Simple configuration

multiwfn = Multiwfn()

Source code in src/pymultiwfn/api/multiwfn.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class Multiwfn:
    """Configuration for Multiwfn execution.

    Attributes
    ----------
    exe_path : Path, optional
        Explicit path to Multiwfn executable. If not provided,
        looks for executable in bin/ directory relative to this package.

    Examples
    --------
    >>> # Simple configuration
    >>> multiwfn = Multiwfn()

    """

    def __init__(
        self,
        exe_path: Path | None = None,
    ) -> None:
        self.exe_path = self._parse_exe(exe_path)

    def _parse_exe(self, exe_path: Path | None) -> Path:
        """Parse the executable path."""
        if exe_path:
            if exe_path.resolve().exists():
                return exe_path.resolve()
            raise MultiwfnError(
                f"Specified executable not found: {self.exe_path.resolve()}"
            )

        if platform.system() == "Windows":
            bin_path = Path(str(files("pymultiwfn") / "bin" / "Multiwfn.exe"))

        elif platform.system() == "Linux":
            bin_path = Path(str(files("pymultiwfn") / "bin" / "Multiwfn"))

        else:
            raise MultiwfnError(
                f"No Multiwfn executable found for {platform.system()} OS."
            )

        if bin_path.exists():
            return bin_path

        else:
            raise MultiwfnError(
                f"Multiwfn executable not found at {bin_path}. "
                "Please specify the executable path."
            )

    def __str__(self) -> str:
        return f"{self.exe_path}"

    def __repr__(self) -> str:
        return f"pymultiwfn.Multiwfn(exe_path={self.exe_path})"