### Install from Source Source: https://pysisyphus.readthedocs.io/en/latest/installation.html Clone the repository and perform an editable installation for development purposes. ```bash git clone https://github.com/eljost/pysisyphus.git $install_dir cd $install_dir # Install with -e if you want an editable installation python -m pip install [-e] . # Installation of extras is also possible. 'sphinx' is only needed if you # want to build the documentation. # python -m pip install [-e] .[test] ``` ```bash git switch dev ``` -------------------------------- ### Install pysisyphus from Source Source: https://pysisyphus.readthedocs.io/en/latest/_sources/installation.rst.txt Clone the repository and install pysisyphus from source. Use the '-e' flag for an editable installation, which is useful for development. Extras like 'test' or 'sphinx' can also be installed. ```bash git clone https://github.com/eljost/pysisyphus.git $install_dir cd $install_dir # Install with -e if you want an editable installation python -m pip install [-e] . # Installation of extras is also possible. 'sphinx' is only needed if you # want to build the documentation. # python -m pip install [-e] .[test] ``` -------------------------------- ### Start Interactive Shell Source: https://pysisyphus.readthedocs.io/en/latest/nix.html Launch an interactive shell environment with pysisyphus installed. ```bash nix shell github:eljost/pysisyphus ``` -------------------------------- ### YAML Calculator Configuration Example Source: https://pysisyphus.readthedocs.io/en/latest/calculators.html Example of a YAML input file demonstrating common keywords for calculator type, resources, and excited-state calculations. Ensure keywords are valid for the chosen calculator. ```yaml geom: [... omitted ...] calc: type: orca # Calculator type, e.g. g09/g16/openmolcas/ # orca/pyscf/turbomole/dftb+/mopac/psi4/xtb pal: 1 # Number of CPU cores mem: 1000 # Memory per core charge: 0 # Charge mult: 1 # Multiplicity # Keywords for ES calculations track: False # Activate ES tracking ovlp_type: tden # Tracking algorithm ovlp_with: previous # Reference cycle selection # Additional calculator specific keywords [... omitted ...] opt: [... omitted ...] ``` -------------------------------- ### Configure Layered Optimization in YAML Source: https://pysisyphus.readthedocs.io/en/latest/_sources/microiterations.rst.txt Example configuration for a layered optimization setup using the LayerOpt class. ```yaml geom: type: cartesian fn: [filename of initial geometry] calc: type: oniom: ... opt: type: layer: [layers: - # dummy for layer 0 (real system) ``` -------------------------------- ### Install via Pip Source: https://pysisyphus.readthedocs.io/en/latest/installation.html Install the latest stable release from PyPI or upgrade the pip package manager. ```bash python -m pip install pysisyphus # Installation of additional optional dependencies is also possible # python -m pip install pysisyphus[test] ``` ```bash python -m pip install --upgrade pip ``` -------------------------------- ### Install pysisyphus from PyPI Source: https://pysisyphus.readthedocs.io/en/latest/_sources/installation.rst.txt Install the latest stable release of pysisyphus using pip. This is the recommended method for users not involved in development. Optional dependencies can be installed with extras. ```bash python -m pip install pysisyphus # Installation of additional optional dependencies is also possible # python -m pip install pysisyphus[test] ``` -------------------------------- ### External Potential Configuration (DFTD3 Example) Source: https://pysisyphus.readthedocs.io/en/latest/_sources/calculators.rst.txt Example of how to configure an external potential, specifically the D3 dispersion correction, within the pysisyphus input structure. ```APIDOC ## External Potential Configuration Example ### Description This snippet shows the general input structure for defining external potentials, with a specific example for the D3 dispersion correction. ### Method N/A (Configuration Example) ### Endpoint N/A (Configuration Example) ### Parameters N/A (Configuration Example) ### Request Example ```yaml calc: type: ext # Multiple potentials could be specified here as a list potentials: # Add atom-pairwise D3 dispersion correction as a differentiable, external potential - type: d3 # Functional is specified in TURBOMOLE format, all lower case. functional: pbe # Optional Becke-Johnson damping, default false, recommended true bjdamping: true calc: type: [actual calculator that is wrapped by ExternalPotential] ``` ### Response N/A (Configuration Example) ``` -------------------------------- ### ER-Diabatization Example for OMP3 Source: https://pysisyphus.readthedocs.io/en/latest/_sources/diabatization.rst.txt This example demonstrates ER-diabatization for *trans*-OMP3. It requires setting unlimited stack size and then executing the diabatization command. The calculation involves adiabatic states and detachment-attachment densities. ```shell #!/bin/bash ulimit -s unlimited ``` -------------------------------- ### Verify pysisyphus Installation with Pytest Source: https://pysisyphus.readthedocs.io/en/latest/_sources/installation.rst.txt Executes a series of tests to verify the calculator setup for pysisyphus. Requires pyscf and pytest to be installed. ```bash pytest -v --pyargs pysisyphus.tests ``` -------------------------------- ### Development Setup Source: https://pysisyphus.readthedocs.io/en/latest/_sources/nix.rst.txt Clone the repository and enter a development shell for hacking on Pysisyphus. ```bash git clone https://github.com/eljost/pysisyphus.git && cd pysisyphus ``` ```bash nix develop ``` -------------------------------- ### Initialize Shells and Backend Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/shells.html Handles the setup of integral backends and shell indexing. Requires valid shell objects and ordering parameters. ```python backend: Union[str, IntegralBackend] = IntegralBackend.NUMBA_MULTIPOLE, ): self.shells = shells self.ordering = ordering self.screen = screen # Start integral backend setup try: self.backend = IntegralBackend(backend) # ValueError is raised when backend is a string, not an Enum except ValueError: self.backend = IntegralBackend[backend.upper()] # Only ever import (and compile) numba backend when actually requested, # as the compilation/setup takes quite some time. if self.backend == IntegralBackend.NUMBA: try: from pysisyphus.wavefunction import backend_numba _backend_modules[IntegralBackend.NUMBA] = backend_numba except ModuleNotFoundError: print( "numba integral backend was requested but numba package is " "not installed!.\n Falling back to python backend." ) self.backend = IntegralBackend.PYTHON elif self.backend == IntegralBackend.NUMBA_MULTIPOLE: try: from pysisyphus.wavefunction import backend_numba_multipole _backend_modules[IntegralBackend.NUMBA_MULTIPOLE] = ( backend_numba_multipole ) except ModuleNotFoundError: print( "numba integral backend was requested but numba package is " "not installed!.\n Falling back to python backend." ) self.backend = IntegralBackend.PYTHON # Pick the actual backend module self.backend_module = _backend_modules[self.backend] # End integral backend setup """ 'native' refers to the original ordering, as used in the QC program. The ordering will be reflected in the MO coefficient ordering. With 'native' the integrals calculated by pysisyphus must be reorderd, to match the native ordering of the MO coefficients. """ assert ordering in ("pysis", "native") # Now that we have all Shell objects, we can set their starting indices shell_index = 0 index = 0 sph_index = 0 for shell in self.shells: shell.shell_index = shell_index shell.index = index shell.sph_index = sph_index shell_index += 1 # TODO: rename to cart_index index += shell.size sph_index += shell.sph_size # Try to construct Cartesian permutation matrix from cart_order, if defined. self._P_cart = None self._P_sph = None try: self.cart_Ps = permut_for_order(self.cart_order) except AttributeError: pass self.atoms, self.coords3d = self.atoms_coords3d # Precontract & store coefficients for reordering spherical basis functions # and converting them from Cartesian basis functions. self.reorder_c2s_coeffs = self.P_sph @ self.cart2sph_coeffs self._numba_shells = None self._numba_shellstructs = None ``` -------------------------------- ### Get Zimmerman Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves data for the Zimmerman benchmark. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_zimmerman_data() ``` -------------------------------- ### Get Baker Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves data for the Baker benchmark. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_baker_data() ``` -------------------------------- ### Get S22 Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves data for the S22 benchmark dataset. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_s22_data() ``` -------------------------------- ### Initialize Infrastructure Parameters Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/io/mol2.html Configures the infrastructure object using a dictionary of parameters and rendering options. ```python charge_type=d["charge_type"], atoms_xyzs=d["atoms_xyzs"], bonds=d["bond"], render_xyz=render_xyz, ) return rendered ``` -------------------------------- ### Get XTB RX Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves data for the XTB RX benchmark. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_xtb_rx_data() ``` -------------------------------- ### Run Generation Process Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/gen_ints.html Main entry point for setting up the environment and initiating integral generation. ```python [docs] def run(): args = parse_args(sys.argv[1:]) l_max = args.lmax l_aux_max = args.lauxmax out_dir = Path(args.out_dir if not args.write else ".") keys = args.keys if keys is None: keys = list() try: os.mkdir(out_dir) except FileExistsError: pass try: global CART2SPH CART2SPH = cart2sph_coeffs(max(l_max, l_aux_max), zero_small=True) except NameError: print("cart2sph_coeffs import is deactivated or pysisyphus is not installed.") # Cartesian basis function centers A and B. center_A = get_center("A") center_B = get_center("B") center_C = get_center("C") center_D = get_center("D") # center_R = get_center("R") Xa, Ya, Za = symbols("Xa Ya Za") # Orbital exponents a, b, c, d. a, b, c, d = symbols("a b c d", real=True) # These maps will be used to convert {Ax, Ay, ...} to array quantities # in the generated code. This way an iterable/np.ndarray can be used as # function argument instead of (Ax, Ay, Az, Bx, By, Bz). A, A_map = get_map("A", center_A) B, B_map = get_map("B", center_B) C, C_map = get_map("C", center_C) D, D_map = get_map("D", center_D) boys_import = ("from pysisyphus.wavefunction.ints.boys import boys",) ################# # Cartesian GTO # ################# def cart_gto(): def cart_gto_doc_func(L_tot): (La_tot,) = L_tot ``` -------------------------------- ### Get Birkholz RX Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves data for the Birkholz RX benchmark. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_birkholz_rx_data() ``` -------------------------------- ### Get Baker TS Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves time-series data for the Baker benchmark. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_baker_ts_data() ``` -------------------------------- ### Execute main function Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/ints/boys.html Standard entry point for running the script. ```python if __name__ == "__main__": run() ``` -------------------------------- ### pysisyphus.intcoords.setup_fast Module Functions Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.intcoords.html Fast methods for finding geometric relationships and setting up internal coordinates. ```APIDOC ## pysisyphus.intcoords.setup_fast.find_bends ### Description Finds bend internal coordinates within a 3D coordinate set. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_coords3d_** (type) - Description - **_bonds_** (type) - Description - **_min_deg_** (type) - Description - **_max_deg_** (type) - Description - **_logger =None_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.find_bonds ### Description Finds bond internal coordinates based on atomic information and distances. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_atoms_** (type) - Description - **_coords3d_** (type) - Description - **_covalent_radii =None_** (type) - Description - **_bond_factor =1.3_** (type) - Description - **_min_dist =0.1_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.find_bonds_bends ### Description Finds both bond and bend internal coordinates for a given geometry. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_geom_** (type) - Description - **_bond_factor =1.3_** (type) - Description - **_min_deg =15_** (type) - Description - **_max_deg =175_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.find_bonds_for_geom ### Description Finds bond internal coordinates specifically for a given geometry. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_geom_** (type) - Description - **_bond_factor =1.3_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.find_dihedrals ### Description Finds dihedral internal coordinates within a 3D coordinate set, given existing bonds and bends. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_coords3d_** (type) - Description - **_bonds_** (type) - Description - **_bends_** (type) - Description - **_max_deg_** (type) - Description - **_logger =None_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.get_bend_candidates ### Description Generates candidate bend internal coordinates from a list of bonds. Note that this function yields duplicates, e.g., [a, b, c] and [c, b, a]. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_bonds_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.get_bond_vec_getter ### Description Retrieves a function to get bond vectors, optimized for internal coordinate calculations. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_atoms_** (type) - Description - **_covalent_radii_** (type) - Description - **_bonds_for_inds_** (type) - Description - **_no_bonds_with =None_** (type) - Description - **_bond_factor =1.3_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup_fast.get_max_bond_dists ### Description Calculates the maximum possible bond distances based on atomic radii and a bond factor. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_atoms_** (type) - Description - **_bond_factor_** (type) - Description - **_covalent_radii =None_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Get Precon Pos Rot Data Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.benchmarks.html Retrieves data for the Precon Pos Rot benchmark. Requires no specific setup. ```python pysisyphus.benchmarks.data.get_precon_pos_rot_data() ``` -------------------------------- ### Initialize Constraints and Thermostat Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/dynamics/driver.html Sets up constraints and thermostatting for molecular dynamics. Handles fixed degrees of freedom and prepares the RATTLE closure if constraints are active. ```python if constraint_kwargs is None: constraint_kwargs = dict() # Fixed degrees of freedom fixed_dof = 0 if remove_com_v: print("Removing center-of-mass velocity.") fixed_dof += 3 constrained_md = constraints is not None # Get RATTLE function from closure for constrained MD if constrained_md: fixed_dof += len(constraints) rattle = rattle_closure( geom, constraints, dt, energy_forces_getter=energy_forces_getter, **constraint_kwargs, ) print(f"Fixed degrees of freedom: {fixed_dof}") dof = len(geom.coords) - fixed_dof if thermostat is not None: sigma = kinetic_energy_for_temperature(len(geom.atoms), T, fixed_dof=fixed_dof) thermo_func = THERMOSTATS[thermostat](sigma, dof, dt=dt, tau=timecon) ``` -------------------------------- ### Prepare directory and write input Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/calculators/Calculator.html Prepares a directory and writes the provided input string to the calculator's input file. ```python if not self.path_already_prepared: path = self.prepare_path() else: path = self.path_already_prepared # Calculators like Turbomole got no input. if inp: inp_path = path / self.inp_fn with open(inp_path, "w") as handle: handle.write(inp) return path ``` -------------------------------- ### Instanton Class Initialization Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.irc.html Initializes an Instanton object with images, a calculator getter, and temperature. ```APIDOC ## Instanton Class Initialization ### Description Creates a new instance of the Instanton class to represent a periodic path. ### Parameters - **images** (list) - Required - List of molecular images. - **calc_getter** (callable) - Required - Function to retrieve the calculator. - **T** (float) - Required - Temperature for the instanton calculation. ``` -------------------------------- ### prepare Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/calculators/Calculator.html Prepares a temporary directory and writes the provided input string to a file within that directory. ```APIDOC ## POST /prepare ### Description Prepare a temporary directory and write input. Similar to prepare_path, but the input is also written into the prepared directory. ### Method POST ### Endpoint /prepare ### Parameters #### Query Parameters - **inp** (str) - Required - Input to be written into the file ``self.inp_fn`` in the prepared directory. ### Response #### Success Response (200) - **path** (Path) - Prepared directory. ### Request Example ```json { "inp": "This is the input content." } ``` ### Response Example ```json { "path": "/tmp/pysisyphus_001_abcdef123456" } ``` ``` -------------------------------- ### Z-Matrix Example Source: https://pysisyphus.readthedocs.io/en/latest/_sources/coordinate_systems.rst.txt Example of a Z-matrix format for defining molecular geometry. Indexing is 1-based, and variable substitution is not supported. ```text C N 1 1.35 H 1 1.0 2 105.0 H 2 1.4 1 105.0 3 150.0 H 2 1.4 1 110.0 3 -160.0 ``` -------------------------------- ### pysisyphus.intcoords.setup Functions Source: https://pysisyphus.readthedocs.io/en/latest/api/pysisyphus.intcoords.html Functions for setting up internal coordinates from geometric data. ```APIDOC ## pysisyphus.intcoords.setup.setup_redundant_from_geom ### Description Sets up redundant internal coordinates from a given geometry. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_geom_** (type) - Description - **_* args_** (type) - Description - **_** kwargs_** (type) - Description ### Request Example (Not applicable) ### Response (Not specified) ``` ```APIDOC ## pysisyphus.intcoords.setup.sort_by_prim_type ### Description Sorts internal coordinate primitives by their type. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a Python function) ### Parameters - **_to_sort =None_** (type) - The list of primitives to sort. ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Upgrade pip Source: https://pysisyphus.readthedocs.io/en/latest/_sources/installation.rst.txt Ensure you have a recent version of pip installed to avoid potential issues during package installation. Run this command to upgrade pip. ```bash python -m pip install --upgrade pip ``` -------------------------------- ### Configure Binary Cache Source: https://pysisyphus.readthedocs.io/en/latest/_sources/nix.rst.txt Use Cachix to fetch pre-built quantum chemistry codes and reduce build times. ```bash nix run nixpkgs#cachix use pysisyphus ``` -------------------------------- ### YAML Configuration for RFOptimizer Source: https://pysisyphus.readthedocs.io/en/latest/_sources/min_optimization.rst.txt Example YAML input for the RFOptimizer, illustrating key parameters for controlling optimization cycles, convergence, Hessian calculation, and line searches. ```yaml opt: type: rfo # Optimization algorithm max_cycles: 50 # Maximum number of optimization cycles overachieve_factor: 2 # Indicate convergence, regardless of the # proposed step when max(grad) and rms(grad) # are overachieved by factor [n] do_hess: True # Calculate the hessian at the final geometry # after the optimization. #hessian_recalc: None # Recalculate exact hessian every n-th cylce #hessian_recalc_adapt: None # Expects a float. Recalculate exact hessian # whenever the gradient norms drops below # 1/[n] of the gradient norm at the last hessian # recalculation. #hessian_init: fischer # Type of model hessian. Other options are: 'calc, # simple, xtb, lindh, swart, unit' #hessian_update: bfgs # Hessian-update. Other options are: 'flowchart, # damped_bfgs, bofill'. bofill is not recommended # for minimum searches. #small_eigval_thresh: 1e-8 # Neglect eigenvalues and corresponding eigenvectors # below this threshold. #max_micro_cycles: 50 # No. of micro cycles for the RS-variants. Does not apply # to TRIM. #trust_radius: 0.3 # Initial trust radius. #trust_max: 1.0 # Max. trust radius #trust_min: 0.1 # Min. trust radius #line_search: True # Do line search #gdiis_thresh: 0.0025 # May do GDIIS if rms(step) falls below this threshold #gediis_thresh: 0.01 # May do GEDIIS if rms(grad) falls below this threshold ``` -------------------------------- ### Get 2-Center 2-Electron Integrals (Spherical) Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/shells.html A convenience method to get 2-center 2-electron integrals in spherical coordinates by calling `get_1el_ints_sph` with the appropriate key. ```python def get_2c2el_ints_sph(self): return self.get_1el_ints_sph("int2c2e") ``` -------------------------------- ### Get 2-Center 2-Electron Integrals (Cartesian) Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/shells.html A convenience method to get 2-center 2-electron integrals in Cartesian coordinates by calling `get_1el_ints_cart` with the appropriate key. ```python def get_2c2el_ints_cart(self): return self.get_1el_ints_cart("int2c2e") ``` -------------------------------- ### Inline XYZ Input Example Source: https://pysisyphus.readthedocs.io/en/latest/_sources/coordinate_systems.rst.txt Example of inline coordinate input for XYZ format using the 'redund' coordinate system type. Ensure proper indentation. ```yaml geom: type: redund fn: | 2 H 0.0 0.0 0.0 H 0.0 0.0 0.7 ``` -------------------------------- ### Initialize Integral Backend Modules Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/shells.html Sets up a dictionary mapping IntegralBackend enum values to their corresponding Python modules. ```python IntegralBackend = Enum("IntegralBackend", ["PYTHON", "NUMBA", "NUMBA_MULTIPOLE"]) _backend_modules = { IntegralBackend.PYTHON: backend_python, } ``` -------------------------------- ### Obtain Development Shell Source: https://pysisyphus.readthedocs.io/en/latest/nix.html Enter a development environment configured for pysisyphus. ```bash nix develop ``` -------------------------------- ### Configure ONIOM2 optimization with native implementation Source: https://pysisyphus.readthedocs.io/en/latest/_sources/microiterations.rst.txt Example configuration for an ONIOM2 optimization of Hexaphenylethane using the native pysisyphus ONIOM calculator. ```yaml - geom: type: cartesian: opt: type: lbfgs: ] ``` -------------------------------- ### Example Usage of generate_wilson Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/intcoords/generate_derivatives.html Demonstrates how to call the `generate_wilson` function to create derivative files. It shows two examples: one using standard math and another using mpmath for higher precision. ```python if __name__ == "__main__": generate_wilson(out_fn="derivatives.py", use_mpmath=False) # print() generate_wilson(out_fn="mp_derivatives.py", use_mpmath=True) # generate_wilson(out_fn="lindisp.py", use_mpmath=False) ``` -------------------------------- ### Instanton Class Initialization Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/irc/Instanton.html Initializes the Instanton class with images, a calculator getter, and temperature. Pre-calculates action prefactors and indices. ```python import numpy as np import scipy as sp from pysisyphus.Geometry import Geometry class Instanton: def __init__(self, images, calc_getter, T): self.images = images self.calc_getter = calc_getter for image in self.images: image.set_calculator(calc_getter()) self.T = T # Pre-calculate action prefactors for the given temperature beta = 1 / (sp.constants.Boltzmann * self.T) # Joule beta_hbar = beta * sp.constants.hbar # seconds beta_hbar_fs = beta_hbar * 1e15 # fs self.beta_hbar = beta_hbar_fs self.P_over_beta_hbar = self.P / self.beta_hbar self.P_bh = self.P_over_beta_hbar """The Instanton is periodic: the first image is connected to the last image. At k=0 the index k-1 will be -1, which points to the last image. Below we pre-calculate some indices (assuming N images). unshifted indices ks: k = {0, 1, .. , N-1} shifted indices ksm1: k-1 = {-1, 0, 1, .. , N-2} shifted indices ksp1: k+1 = {1, 2, .. , N-1, 0} """ self.ks = np.arange(self.P) self.ksm1 = self.ks - 1 self.ksp1 = self.ks + 1 self.ksp1[-1] = 0 # k+1 for the last image points to the first image self.coord_type = "mwcartesian" self.internal = None @property def P(self): return len(self.images) ``` -------------------------------- ### GET /V Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/wavefunction/wavefunction.html Retrieves 1-electron Coulomb integrals. ```APIDOC ## GET /V ### Description Calculates 1-electron Coulomb integrals based on provided 3D coordinates and charges. ### Method GET ### Parameters #### Query Parameters - **coords3d** (array) - Required - 3D coordinates of the system. - **charges** (array) - Required - Charges associated with the coordinates. ``` -------------------------------- ### Initialize Wigner Sampler Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/dynamics/wigner.html Sets up a sampler function for Wigner sampling based on molecular geometry, masses, and Hessian matrix. ```python @functools.singledispatch def get_wigner_sampler( atoms, coords3d: np.ndarray, masses: np.ndarray, hessian: np.ndarray, temperature: float = 0.0, nu_thresh: float = 0.0, stddevs: float = 6.0, seed: Optional[int] = None, ) -> tuple[Callable, int]: assert coords3d.shape == (len(masses), 3) assert hessian.shape == (coords3d.size, coords3d.size) if seed is None: seed = secrets.randbits(128) rng = np.random.default_rng(seed) tmp_geom = Geometry(atoms, coords3d) tmp_geom.masses = masses tmp_geom.cart_hessian = hessian # nus, eigvals, mw_cart_displs (v), cart_displs nus, _, v, _ = tmp_geom.get_normal_modes() nnus = len(nus) # Number of non-zero wavenumbers imag_nus = nus <= nu_thresh nimag_nus = imag_nus.sum() use_nu_inds = np.arange(nnus)[~imag_nus] if nimag_nus: warnings.warn( f"Detected {nimag_nus} imaginary wavenumber(s)! They will be ignored in the sampling." ) # Square root of angular frequencies in atomic units. Required to convert the # dimensionless Q and P values into atomic units. ang_freqs_au_sqrt = np.sqrt(nus * NU2ANGFREQAU) ang_freqs_au_sqrt[imag_nus] = 1.0 span = 2 * stddevs # Pre-calculate some of the Laguerre polynomials # We use some shortcuts for n == 0 and n == 1 laguerres = { 0: lambda _: 1.0, 1: lambda x: 1.0 - x, } def get_laguerre(n): lag_coeffs = np.zeros(n + 1) lag_coeffs[n] = 1.0 return Laguerre(lag_coeffs) # Precompute some often accessed Laguere polynomials for i in range(2, 11): laguerres[i] = get_laguerre(i) mm_sqrt_au = np.sqrt(tmp_geom.masses_rep * AMU2AU) M_inv_au = np.diag(1 / mm_sqrt_au) def sampler() -> WignerSample: qs_nodim = np.zeros(nnus) ps_nodim = np.zeros(nnus) # Modes that are ignored will not be part of 'use_nu_inds' and their associated # sampled normal coordinates and momenta will stay at 0.0 throughout. for i in use_nu_inds: n = get_vib_state(nus[i], rng, temperature=temperature) try: lag = laguerres[n] except KeyError: lag = get_laguerre(n) laguerres[n] = lag # According to eq. (31) in [3], the absolute value of the Wigner function is ``` -------------------------------- ### Initialize batch calculation function Source: https://pysisyphus.readthedocs.io/en/latest/_modules/pysisyphus/marcus_dim/fit.html Sets up the environment and partial functions required for batch property calculations. ```python def get_batch_calc_func( geom, calc_getter: Callable, property: mdtypes.Property, fragments: List[Tuple[int]], scheduler, cart_displs: np.ndarray, temperature: float, seed=None, out_dir=Path("."), ): assert temperature >= 0.0, f"{temperature=} must be positive!" # Dump fragments fragments_trj = "\n".join( get_fragment_xyzs(geom, fragments, with_geom=True, with_dummies=True) ) fragment_trj_fn = "fragments.trj" with open(out_dir / fragment_trj_fn, "w") as handle: handle.write(fragments_trj) print(f"Wrote fragments to '{fragment_trj_fn}'") property_funcs = { property.EPOS_IAO: epos_property_iao, property.EPOS_MULLIKEN: epos_property_mulliken, property.EEXC: en_exc_property, } property_func = property_funcs[property] try: charge = geom.calculator.charge mult = geom.calculator.mult except AttributeError: charge = None mult = None if (charge is not None) and (mult is not None): print(f" Charge: {charge}") print(f" Multiplicity: {mult}") print(f" Temperature: {temperature:.2f} K") print(f" Property: {property}") # Calculate wavefunction at equilibrium geometry print("Starting calculation at equilibrium geometry") # TODO: figure out why this is even needed here ... probably because the calculations aren't done # inside the property function(s). gs_energy_eq, *_ = geom.all_energies # TODO: using 'geom.calc_wavefunction()' leads to a pickling-error later on prop_eq = property_func(geom, fragments) print("Finished calculation at equilibrium geometry") eq_results = {"property_eq": prop_eq, "gs_energy_eq": gs_energy_eq} client, pal, calc_msg = setup_calc_client(geom, scheduler) print(calc_msg) calculate_property_wrapped = functools.partial( calculate_property, geom=geom, calc_getter=calc_getter, pal=pal, fragments=fragments, prop_eq=prop_eq, property_func=property_func, ) # Function that create displaced geometries by drawing from a Wigner distribution wigner_sampler, seed = get_wigner_sampler(geom, temperature=temperature, seed=seed) sampler_wrapped = functools.partial( get_displaced_coordinates, wigner_sampler=wigner_sampler, cart_displs=cart_displs, ``` -------------------------------- ### Plotting Source: https://pysisyphus.readthedocs.io/en/latest/index.html Examples and functionalities for plotting various calculation results. ```APIDOC ## Plotting ### Description This section provides examples and guidance on visualizing the results of different types of calculations. ### Examples - Diels-Alder reaction - Plotting optimization progress - Plotting COS optimization progress - Plotting TS-optimization progress - Plotting the Intrinsic Reaction Coordinate - AFIR - Excited State Tracking ``` -------------------------------- ### Configure Growing String Method (GSM) Optimization Source: https://pysisyphus.readthedocs.io/en/latest/_sources/chainofstates.rst.txt Example YAML input for setting up a Growing String Method optimization with specific node and climbing image parameters. ```yaml precontr: # Preconditioning of translation & rotation preopt: # Preoptimize inital and final geometry cos: type: gs # Do a growing string max_nodes: 9 # Total string will have 9 + 2 == 11 images climb: False # Enable climbing image (CI), usually a good idea. climb_rms: 0.005 # rms(forces) threshold for enabling CI climb_lanczos: False # Use tangent obtained from Lanczos algorithm for CI. climb_lanczos_rms: 0.005 # rms(forces) threshold for enabling Lanczos algorithm. reparam_check: rms # Criterian for growing new frontier nodes (rms/norm). perp_thresh: 0.05 # Threshold for growing new frontier nodes. reparam_every: 2 # Reparametrize every n-th cycle when NOT fully grown. reparam_every_full: 3 # Reparametrize every n-th cycle when fully grown. ```