### Install Vayesta using pip Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/install.rst Clone the repository, navigate to the directory, and install using pip. This method automatically installs required Python packages like NumPy and PySCF. ```console [~]$ git clone https://github.com/BoothGroup/Vayesta [~]$ cd Vayesta [~]$ pip install . ``` -------------------------------- ### Install Vayesta from Source Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/install.rst Clone the repository, navigate to the 'libs' directory, and use cmake and make to compile. Ensure required packages like NumPy, SciPy, PySCF, and h5py are installed. ```console [~]$ git clone https://github.com/BoothGroup/Vayesta . [~]$ cd Vayesta/vayesta/libs [~]$ mkdir build && cd build [~]$ cmake .. [~]$ make ``` -------------------------------- ### Build and Install OpenBLAS Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/faq/blas.rst Compiles OpenBLAS using 4 parallel jobs and installs it to a specified directory with OpenMP support. The library will be located in the path defined by OPENBLAS_DIR. ```console [~]$ OPENBLAS_DIR=$HOME/work/openblas [~]$ make -j4 BINARY=64 INTERFACE=64 LIBNAMESUFFIX=openmp [~]$ make PREFIX=$OPENBLAS_DIR LIBNAMESUFFIX=openmp install ``` -------------------------------- ### Run Vayesta Tests Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/install.rst After installation, run the test suite using pytest to verify the installation. Navigate to the Vayesta directory and execute the pytest command. ```console [~]$ pytest vayesta/tests ``` -------------------------------- ### Install Vayesta Package Source: https://github.com/boothgroup/vayesta/blob/master/README.md Install the Vayesta package using pip from the top-level directory after cloning. This command requires CMake. ```bash python -m pip install . --user ``` -------------------------------- ### Atomic Fragmentation Setup Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/ewf.rst Demonstrates how to explicitly set up atomic fragmentation for the EWF class, which is the default behavior when no fragmentation scheme is provided. ```python with emb.iao_fragmentation() as f: f.add_all_atomic_fragments() ``` ```python with emb.iao_fragmentation() as f: for atom in range(mol.natm): f.add_atomic_fragment(atom) ``` -------------------------------- ### Install mpi4py Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/faq/mpi4py.rst Use this command to build and install the mpi4py library locally. Ensure the MPICC environment variable is set to your mpicc compiler path. ```bash env MPICC=/../mpicc python -m pip install --force --user mpi4py ``` -------------------------------- ### Configure pip Installation Directory Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/faq/env.rst Set environment variables to direct pip installations to a specified directory. This ensures that packages are installed in a consistent location. ```bash [~]$ export PYTHONUSERBASE=${WORK}/.local [~]$ export PATH=$PYTHONUSERBASE/bin:$PATH [~]$ export PYTHONPATH=$PYTHONUSERBASE/lib/pythonX.X/site-packages:$PYTHONPATH ``` -------------------------------- ### Custom Fragments Example Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/fragmentation.rst This example demonstrates how to add atomic fragments with orbital filtering capabilities using the add_atomic_fragment method within a fragmentation context manager. ```python import vayesta.ewf from vayesta.core.fragmentation import IAO, IAOPAO, SAO # Load the molecule mol = vayesta.ewf.EWF("molecule.mol") # Define fragments using IAO with mol.iao_fragmentation() as f: f.add_atomic_fragment(0, "H") # Add atom 0 (H) f.add_atomic_fragment(1, "O") # Add atom 1 (O) f.add_atomic_fragment(2, "O") # Add atom 2 (O) # Add fragments based on orbital types f.add_orbital_fragment(IAO(0, "s")) # Add IAO s-orbital of atom 0 f.add_orbital_fragment(IAO(1, "pz")) # Add IAO pz-orbital of atom 1 # Add fragments based on atom indices and orbital filters f.add_atomic_fragment(3, orbital_filter=lambda x: x.endswith("p")) # Add atom 3, filtering for p orbitals # Define fragments using IAO+PAO with mol.iaopao_fragmentation() as f: f.add_atomic_fragment(0) f.add_atomic_fragment(1) f.add_atomic_fragment(2) # Define fragments using SAO with mol.sao_fragmentation() as f: f.add_atomic_fragment(0) f.add_atomic_fragment(1) f.add_atomic_fragment(2) # Define fragments for lattice models # with mol.site_fragmentation() as f: # f.add_site_fragment(0) # f.add_site_fragment(1) # Perform calculation # mol.kernel() ``` -------------------------------- ### Import Vayesta Modules Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Import the necessary modules from Vayesta for creating custom Hamiltonians. This is the initial setup required for the subsequent steps. ```python from vayesta.lattmod import Hubbard1D from vayesta.core.linalg import EWS ``` -------------------------------- ### MPI Job Script Example Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/mpi.rst This script demonstrates how to run a Vayesta calculation in parallel using MPI. It includes configurations for unique output names, restricting SCF calculations to the master process, and conditional printing. ```python import vayesta.mpi from vayesta.mpi import mpi from vayesta.ewf import EWF from pyscf.gto import M from pyscf.scf import RHF # MPI setup if mpi.is_master: print("Running Vayesta with MPI") # Define molecule (unique output name for each MPI rank) mol = M(atom='O 0 0 0; H 0 0.757 0.586; H 0 -0.757 0.586',) mol.output = f"mol_rank_{mpi.rank}.out" mol.build() # Mean-field calculation (restricted to master process) mf = RHF(mol) mf = vayesta.mpi.mpi.scf(mf) # Quantum embedding calculation with EWF(mf, screens={'ccsd': {'kernel_kwargs': {'maxiter': 100}}}) as U: # Add fragments here # Example: U.add_fragment(smearing_type='gaussian', sigma_in=0.05, sigma_out=0.05) # Example: U.kernel() pass # Print output only on the master process if mpi.is_master: print("MPI calculation finished.") ``` -------------------------------- ### Set PYTHONPATH for Source Installation Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/install.rst Prepend the Vayesta installation location to the PYTHONPATH environment variable to ensure it is found by the Python interpreter. This command can be added to ~/.profile for persistent effect. ```console [~]$ export PYTHONPATH:"/path/to/vayesta":$PYTHONPATH ``` -------------------------------- ### Set Up Embedding Calculation (Single-Site) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Configure the embedding calculation using the EWF function. This example demonstrates a single-site embedding by setting fragment_type to 'sites' and using specific arguments for fragmentation. ```python from vayesta.core.linalg import site_fragmentation from vayesta.core.embedding import add_atomic_fragment emb = EWS(mf, bno_threshold=1e-3, fragment_type='sites') add_atomic_fragment(emb, 0, sym_factor=nsite) ``` -------------------------------- ### Initialize EDMET Function Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Declare the EDMET function and provide arguments derived from previous setup steps. ```python edmet = EDMET(mf, dmft) ``` -------------------------------- ### DMET Calculation for H6 Molecule (Self-Consistent) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dmet.rst Performs a self-consistent DMET calculation for an H6 molecule. Similar setup to the one-shot calculation, but without the 'maxiter=1' argument to allow for self-consistency cycles. ```python from vayesta.dmet import DMET from vayesta.mpi import mpi_init from vayesta.core.linalg import block_diag from pyscf.gto import Mole from pyscf.scf import RHF from pyscf.fci import FCI # Initialize MPI } # Define H6 molecule m = Mole() m.atom = [ ['H', (0., 0., 0.)], ['H', (0.74, 0., 0.)], ['H', (1.48, 0., 0.)], ['H', (2.22, 0., 0.)], ['H', (2.96, 0., 0.)], ['H', (3.70, 0., 0.)], ] m.basis = 'sto-3g' m.build() # Perform RHF calculation mf = RHF(m) mf.kernel() # Instantiate DMET calculation (self-consistent) dmet = DMET(mf, solver='FCI') # Define fragments using SAO fragmentation with dmet.sao_fragmentation() as f: f.add_atomic_fragment([0, 1]) f.add_atomic_fragment([2, 3]) f.add_atomic_fragment([4, 5]) # Solve the embedding problems and get total energy dmet.kernel() print(f'Total energy (self-consistent DMET): {dmet.e_tot}') ``` -------------------------------- ### Cubic Boron Nitride (cBN) Calculation Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/ewf.rst Calculates cubic boron nitride using EWF, demonstrating setup for solids with k-point sampled mean-field objects. Note that the basis set and k-point sampling are simplified for demonstration. ```python from vayesta.ewf import EWF from vayesta.core.linalg import solve_and_get_coeffs from vayesta.core.options import Options from pyscf.pbc import gto, scf cell = gto.Cell() cell.atom = "B 0 0 0; N 1.76 1.76 1.76" cell.basis = "sto-3g" cell.a = numpy.diag([3.52, 3.52, 3.52]) cell.mesh = [10, 10, 10] cell.build() mf = scf.RHF(cell).run() # EWF setup for k-point sampled mean-field emb = EWF(mf) emb.kernel() # Calculate density matrix and population analysis dm = emb.get_dm() pop = emb.get_population_analysis() print("\nPopulation analysis") print("-------------------") print(pop) ``` -------------------------------- ### Import PySCF and Vayesta Modules Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Load the necessary modules from PySCF and Vayesta to begin. ```python from pyscf import gto, scf, cc from vayesta.edmet import EDMET ``` -------------------------------- ### Create Local Directory for OpenBLAS Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/faq/blas.rst Creates a directory to store the OpenBLAS library locally and sets an environment variable to point to this directory. ```console [~]$ mkdir $HOME/work [~]$ export WORK=$HOME/work ``` -------------------------------- ### Set up Density Functional Theory (DFT) in PySCF Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Configure DFT parameters within PySCF, specifying the functional and other relevant variables. ```python mf = scf.RHF(mol) dmft = scf.addons.KRHF(mol) ``` -------------------------------- ### Set Up Embedding Calculation (Double-Site) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Configure a double-site embedding for the 1-D Hubbard model. This involves changing the arguments in add_atomic_fragment to include a dimerized cluster. ```python emb = EWS(mf, bno_threshold=1e-3, fragment_type='sites') add_atomic_fragment(emb, [0,1], sym_factor=nsite//2) ``` -------------------------------- ### Add Source Directory Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/core/CMakeLists.txt Includes the 'src' subdirectory for compilation. ```cmake add_subdirectory(src) ``` -------------------------------- ### Configure OpenMP and Compiler Options for OpenBLAS Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/faq/blas.rst Sets environment variables to enable OpenMP support, disable warm-up, and specify GNU compilers (gcc and gfortran) for building OpenBLAS. ```console [~]$ export USE_OPENMP=1 [~]$ export NO_WARMUP=1 [~]$ export BUILD_RELAPACK=0 [~]$ export DYNAMIC_ARCH=0 [~]$ export CC=gcc [~]$ export FC=gfortran [~]$ export HOSTCC=gcc ``` -------------------------------- ### Clone Vayesta Repository Source: https://github.com/boothgroup/vayesta/blob/master/README.md Clone the Vayesta repository from GitHub to your local machine. ```bash git clone https://github.com/BoothGroup/Vayesta.git ``` -------------------------------- ### Obtaining DMET Density Matrices Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dmet.rst Shows how to obtain the one- and two-body density matrices from a DMET calculation. These matrices are democratically partitioned and are fundamental for calculating expectation values. ```python from vayesta.dmet import DMET from vayesta.mpi import mpi_init from vayesta.core.linalg import block_diag from pyscf.gto import Mole from pyscf.scf import RHF from pyscf.fci import FCI # Initialize MPI } # Define H6 molecule m = Mole() m.atom = [ ['H', (0., 0., 0.)], ['H', (0.74, 0., 0.)], ['H', (1.48, 0., 0.)], ['H', (2.22, 0., 0.)], ['H', (2.96, 0., 0.)], ['H', (3.70, 0., 0.)], ] m.basis = 'sto-3g' m.build() # Perform RHF calculation mf = RHF(m) mf.kernel() # Instantiate DMET calculation dmet = DMET(mf, solver='FCI') # Define fragments with dmet.sao_fragmentation() as f: f.add_atomic_fragment([0, 1]) f.add_atomic_fragment([2, 3]) f.add_atomic_fragment([4, 5]) # Solve the embedding problems dmet.kernel() # Obtain one- and two-body density matrices rdm1 = dmet.make_rdm1() rdm2 = dmet.make_rdm2() print('One-body density matrix (rdm1):') print(rdm1) print('\nTwo-body density matrix (rdm2):') print(rdm2) ``` -------------------------------- ### Create 1D Hubbard Lattice Model Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Automatically create a 1-D Hubbard model using Vayesta's Hubbard1D function with the specified parameters. This function is specialized for this model. ```python mf = Hubbard1D(nsite=nsite, nelectron=nelectron, hubbard_u=hubbard_u) ``` -------------------------------- ### Declare Initial Conditions for Hubbard Model Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Define the initial parameters for the 1D Hubbard model, including the number of sites, electrons, and the Hubbard U value. These variables are used to construct the lattice model. ```python nsite = 20 nelectron = 10 hubbard_u = 4.0 ``` -------------------------------- ### Combine IAO and IAO+PAO Fragmentation Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/fragmentation.rst Demonstrates combining IAO and IAO+PAO fragmentation types. This is a valid combination as long as no atom is added twice. ```python with emb.iao_fragmentation() as f: f.add_atomic_fragment(0) with emb.iaopao_fragmentation() as f: f.add_atomic_fragment(1) ``` -------------------------------- ### Link Libraries and Directories Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/df/CMakeLists.txt Links necessary libraries (BLAS, HDF5) and includes directories for the 'df' target. ```cmake target_link_libraries(df ${BLAS_LIBRARIES} ${OPENMP_C_PROPERTIES}) target_include_directories(df PRIVATE ${HDF5_C_INCLUDE_DIRS}) target_link_libraries(df ${BLAS_LIBRARIES} ${HDF5_HL_LIBRARIES} ${OPENMP_C_PROPERTIES}) ``` -------------------------------- ### Add DF Library Source Files Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/df/src/CMakeLists.txt Specifies the C source files for the DF library to be included in the build. ```cmake target_sources(df PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/df_jk.c) ``` -------------------------------- ### Define Finite System (Water Molecule) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Declare the pertinent variables for a finite system, such as the water molecule, using PySCF. ```python mol = gto.M(atom='O 0 0 0; H 0 0 0.757; H 0 1.414 0.757', basis='sto-3g') mf = scf.RHF(mol) ``` -------------------------------- ### Dump Cluster Hamiltonians (Spin-Restricted) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dumpcluster.rst This snippet illustrates the structure of the HDF5 dump file for a spin-restricted calculation, showing the content of each fragment group. ```python import h5py with h5py.File("clusters.h5", "r") as f: # Example: Accessing data for fragment 0 fragment_0 = f["0"] print(f"Fragment 0 orbitals shape: {fragment_0['orbitals'].shape}") print(f"Fragment 0 integrals shape: {fragment_0['integrals'].shape}") # ... and so on for other fragments ``` -------------------------------- ### DMET with Rotational Symmetry Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dmet.rst Demonstrates how to incorporate rotational symmetry into DMET calculations. This allows solving for only one fragment when others are symmetry-related, reducing computational cost. ```python from vayesta.dmet import DMET from vayesta.mpi import mpi_init from vayesta.core.linalg import block_diag from pyscf.gto import Mole from pyscf.scf import RHF from pyscf.fci import FCI # Initialize MPI } # Define H6 molecule m = Mole() m.atom = [ ['H', (0., 0., 0.)], ['H', (0.74, 0., 0.)], ['H', (1.48, 0., 0.)], ['H', (2.22, 0., 0.)], ['H', (2.96, 0., 0.)], ['H', (3.70, 0., 0.)], ] m.basis = 'sto-3g' m.build() # Perform RHF calculation mf = RHF(m) mf.kernel() # Instantiate DMET calculation dmet = DMET(mf, solver='FCI') # Define fragments with rotational symmetry # Only one fragment needs to be solved due to symmetry with dmet.sao_fragmentation() as f: f.add_atomic_fragment([0, 1]) # Specify rotational symmetry for the fragments dmet.add_rotation_symmetry([0, 1, 2]) # Solve the embedding problems dmet.kernel() print(f'Total energy (DMET with symmetry): {dmet.e_tot}') ``` -------------------------------- ### Link Libraries Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/core/CMakeLists.txt Links the core library with BLAS and OpenMP libraries. ```cmake target_link_libraries(core ${BLAS_LIBRARIES} ${OPENMP_C_PROPERTIES}) ``` -------------------------------- ### Compute Energy Per Electron (MF and EWF) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Calculate the energy per electron for both the mean-field (MF) and the embedded (EWF) calculations. This allows for comparison of the methods. ```python energy_mf = mf.kernel() energy_ewf = emb.kernel() ``` -------------------------------- ### Define Core Library Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/core/CMakeLists.txt Defines the core library as a SHARED library. ```cmake add_library(core SHARED) ``` -------------------------------- ### Define Optimized Compiler Flags for OpenBLAS Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/faq/blas.rst Sets environment variables for common, C, and Fortran compiler optimization flags to enhance performance during the OpenBLAS build. ```console [~]$ export COMMON_OPT="-O3 -ftree-vectorize -fprefetch-loop-arrays --param prefetch-latency=300" [~]$ export CFLAGS="-O3 -ftree-vectorize -fprefetch-loop-arrays --param prefetch-latency=300" [~]$ export FCOMMON_OPT="-O3 -ftree-vectorize -fprefetch-loop-arrays --param prefetch-latency=300" [~]$ export FCFLAGS="-O3 -ftree-vectorize -fprefetch-loop-arrays --param prefetch-latency=300" ``` -------------------------------- ### Add Shared Library Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/df/CMakeLists.txt Defines the 'df' library as a shared library. ```cmake add_library(df SHARED) ``` -------------------------------- ### DMET Calculation for H6 Molecule (One-Shot) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dmet.rst Performs a one-shot DMET calculation for an H6 molecule. Sets up the molecule, performs RHF and FCI calculations for reference, instantiates DMET with FCI solver and skips self-consistency. Fragments are defined using SAO fragmentation. ```python from vayesta.dmet import DMET from vayesta.mpi import mpi_init from vayesta.core.linalg import block_diag from pyscf.gto import Mole from pyscf.scf import RHF from pyscf.fci import FCI # Initialize MPI } # Define H6 molecule m = Mole() m.atom = [ ['H', (0., 0., 0.)], ['H', (0.74, 0., 0.)], ['H', (1.48, 0., 0.)], ['H', (2.22, 0., 0.)], ['H', (2.96, 0., 0.)], ['H', (3.70, 0., 0.)], ] m.basis = 'sto-3g' m.build() # Perform RHF calculation mf = RHF(m) mf.kernel() # Perform FCI calculation for reference fci_mf = FCI(mf.mol, mf.mo_coeff) fci_mf.kernel() # Instantiate DMET calculation (one-shot) # Use FCI as solver and skip self-consistency (maxiter=1) dmet = DMET(mf, solver='FCI', maxiter=1) # Define fragments using SAO fragmentation # Split into three fragments, each containing two neighboring atoms with dmet.sao_fragmentation() as f: f.add_atomic_fragment([0, 1]) f.add_atomic_fragment([2, 3]) f.add_atomic_fragment([4, 5]) # Solve the embedding problems and get total energy dmet.kernel() print(f'Total energy (one-shot DMET): {dmet.e_tot}') ``` -------------------------------- ### Dump Cluster Hamiltonians (Spin-Unrestricted) Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dumpcluster.rst This snippet shows the structure of the HDF5 dump file for a spin-unrestricted calculation, highlighting the differences in shapes and dataset names compared to spin-restricted calculations. ```python import h5py with h5py.File("clusters.h5", "r") as f: # Example: Accessing data for fragment 0 fragment_0 = f["0"] print(f"Fragment 0 alpha orbitals shape: {fragment_0['orbitals_alpha'].shape}") print(f"Fragment 0 beta orbitals shape: {fragment_0['orbitals_beta'].shape}") print(f"Fragment 0 alpha integrals shape: {fragment_0['integrals_alpha'].shape}") print(f"Fragment 0 beta integrals shape: {fragment_0['integrals_beta'].shape}") # ... and so on for other fragments ``` -------------------------------- ### Set DF Library Target Properties Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/df/src/CMakeLists.txt Configures output directories and compiler/linker flags for the DF library target, including OpenMP flags. ```cmake set_target_properties(df PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_FLAGS ${OpenMP_C_FLAGS} LINK_FLAGS ${OpenMP_C_FLAGS}) ``` -------------------------------- ### Add embwf Library Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/ewf/CMakeLists.txt Defines the embwf library as a SHARED library. ```cmake add_library(embwf SHARED) ``` -------------------------------- ### DMET with Translational Symmetry for 1D Hubbard Model Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dmet.rst Applies translational symmetry to a DMET calculation of a 1D Hubbard model. This optimization allows solving for fewer fragments when translational symmetry is present between them. ```python from vayesta.dmet import DMET from vayesta.mpi import mpi_init from vayesta.lattmod import Hubbard1D # Initialize MPI } # Define 1D Hubbard model (10 sites, U=6) hubbard = Hubbard1D(n_sites=10, U=6.0) # Instantiate DMET calculation dmet = DMET(hubbard) # Define fragments based on lattice sites (two-site fragments) with dmet.site_fragmentation() as f: f.add_atomic_fragment([0, 1]) f.add_atomic_fragment([2, 3]) f.add_atomic_fragment([4, 5]) f.add_atomic_fragment([6, 7]) f.add_atomic_fragment([8, 9]) # Specify translational symmetry for the fragments dmet.add_translational_symmetry(n_sites=2) # Solve the embedding problems dmet.kernel() print(f'Total energy (1D Hubbard DMET with symmetry): {dmet.e_tot}') ``` -------------------------------- ### Set Custom Dump File Name Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dumpcluster.rst Adjust the name of the HDF5 file where cluster Hamiltonians are dumped by providing an additional solver option. ```python solver_options = { "filename": "my_clusters.h5" } ``` -------------------------------- ### Print Total Energy Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Extract and print relevant quantities, such as the total energy, from the computation results. ```python print('Total energy: %.5f' % ccsd.e_tot) print('EDMET energy: %.5f' % edmet.kernel()) ``` -------------------------------- ### Obtain Calculation Results Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Retrieve and display the final results of the embedding calculation. This step is performed after the kernel has been executed. ```python print(f"Energy per electron (MF): {energy_mf:.4f}") print(f"Energy per electron (EWS): {energy_ewf:.4f}") ``` -------------------------------- ### Verify Fragmentation Status Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/fragmentation.rst Check if a user-defined fragmentation is orthogonal and complete in the occupied/virtual space by looking for this line in the output. ```console Fragmentation: orthogonal= True, occupied-complete= True, virtual-complete= False ``` -------------------------------- ### Link Libraries to embwf Source: https://github.com/boothgroup/vayesta/blob/master/vayesta/libs/ewf/CMakeLists.txt Links the embwf target to BLAS and OpenMP libraries. ```cmake target_link_libraries(embwf ${BLAS_LIBRARIES} ${OPENMP_C_PROPERTIES}) ``` -------------------------------- ### Submit CCSD Reference Computation Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Submit the computation to obtain a reference result using Coupled Cluster Singles and Doubles (CCSD). ```python ccsd = cc.CCSD(mf) ccsd.kernel() ``` -------------------------------- ### Perform Mean-Field Calculation Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/1dhubbard.rst Carry out a mean-field calculation using the LatticeMF module. The method (HF or UHF) is automatically selected based on the total spin number. ```python from vayesta.core.linalg import LatticeMF mf = LatticeMF(mf) ``` -------------------------------- ### Convert DFT Object for EDMET Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Convert the DFT object from PySCF to ensure compatibility with EDMET features, as DFT objects differ from Hartree-Fock objects. ```python dmft = scf.addons.convert_dft_to_uhf(dmft) ``` -------------------------------- ### DMET Calculation for 1D Hubbard Model Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/dmet.rst Performs a DMET calculation for a 1D Hubbard model. Uses the Hubbard1D class and defines fragments based on lattice sites. The hopping parameter 't' is 1 by default, and U=6t is used. ```python from vayesta.dmet import DMET from vayesta.mpi import mpi_init from vayesta.lattmod import Hubbard1D # Initialize MPI } # Define 1D Hubbard model (10 sites, U=6) hubbard = Hubbard1D(n_sites=10, U=6.0) # Instantiate DMET calculation dmet = DMET(hubbard) # Define fragments based on lattice sites (two-site fragments) with dmet.site_fragmentation() as f: f.add_atomic_fragment([0, 1]) f.add_atomic_fragment([2, 3]) f.add_atomic_fragment([4, 5]) f.add_atomic_fragment([6, 7]) f.add_atomic_fragment([8, 9]) # Solve the embedding problems dmet.kernel() print(f'Total energy (1D Hubbard DMET): {dmet.e_tot}') ``` -------------------------------- ### Define Fragmentation Scheme Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/edmet.rst Specify the fragmentation scheme required for the EDMET calculation. ```python edmet.make_fragmentation(nbody=2, join_fragments=True) ``` -------------------------------- ### Simple Water Molecule CCSD Calculation Source: https://github.com/boothgroup/vayesta/blob/master/docs/source/quickstart/ewf.rst Performs an embedded wave function calculation for a water molecule using CCSD. Key differences from DMET include bath options for MP2 natural orbitals and default atomic fragmentation. ```python from vayesta.ewf import EWF from vayesta.core.linalg import solve_and_get_coeffs from vayesta.core.options import Options from pyscf.gto import Mole from pyscf.scf import RHF mol = Mole() mol.atom = "O 0 0 0; H 0 0 1; H 0 1 0" mol.basis = "sto-3g" mol.build() mf = RHF(mol).run() # EWF setup with MP2 bath options opts = Options() opts.ewf.bath = dict(threshold=1e-6) emb = EWF(mf, options=opts) emb.kernel() # Calculate density matrix and population analysis from vayesta.core.fragment import Fragment dm = emb.get_dm() pop = emb.get_population_analysis() print(pop) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.