|
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# Author: Yi Deng <yideng@uchicago.edu> |
| 4 | +# |
| 5 | + |
| 6 | +"""Density-fitted GASSCF for the septet Kremer's dimer, with a CD reference.""" |
| 7 | + |
| 8 | +from pathlib import Path |
| 9 | + |
| 10 | +import numpy |
| 11 | + |
| 12 | +from pyscf import gto, scf |
| 13 | +from pyscf.mcscf import gasscf |
| 14 | + |
| 15 | + |
| 16 | +# OpenMolcas reference input: |
| 17 | +# |
| 18 | +# &GATEWAY |
| 19 | +# ... (Geometry and basis are stored in the .npz file) |
| 20 | +# |
| 21 | +# &SEWARD |
| 22 | +# CHOLESKY |
| 23 | +# THRCholesky = 1.0d-6 |
| 24 | +# |
| 25 | +# &RASSCF |
| 26 | +# |
| 27 | +# LUMORB |
| 28 | +# FILEORB = kd_guessorb.INPORB |
| 29 | +# |
| 30 | +# Charge = 3 |
| 31 | +# Spin = 7 |
| 32 | +# Symmetry = 1 |
| 33 | +# |
| 34 | +# Nactel = 30 2 0 |
| 35 | +# Inactive = 117 |
| 36 | +# |
| 37 | +# Ras1 = 12 |
| 38 | +# Ras2 = 10 |
| 39 | +# |
| 40 | +# CIRoot = 1 1 1 |
| 41 | +# CIMX = 200 |
| 42 | +# ITERations = 100 100 |
| 43 | +# |
| 44 | +# OpenMolcas output: |
| 45 | +# |
| 46 | +# :: RASSCF root number 1 Total energy: -3345.73608985 |
| 47 | +# |
| 48 | + |
| 49 | +openmolcas_energy = -3345.73608985 |
| 50 | +auxbasis = "def2-universal-jkfit" |
| 51 | +target_s2 = 12.0 |
| 52 | + |
| 53 | +here = Path(__file__).resolve().parent |
| 54 | +with numpy.load(here / "data/kremer_dimer_df_mo.npz", allow_pickle=False) as data: |
| 55 | + mol = gto.loads(data["mol"].item()) |
| 56 | + mo_coeff = data["mo_coeff"] |
| 57 | + |
| 58 | +mol.max_memory = 64000 # MB |
| 59 | +mol.verbose = 4 |
| 60 | + |
| 61 | +# One-cycle DF-ROHF for mf generation. |
| 62 | +mf = scf.ROHF(mol).density_fit(auxbasis=auxbasis) |
| 63 | +mf.max_cycle = 1 |
| 64 | +mf.kernel() |
| 65 | +mf.mo_coeff = mo_coeff |
| 66 | + |
| 67 | +# RASSCF(30e,22o) |
| 68 | +mc = gasscf.GASSCF( |
| 69 | + mf, |
| 70 | + ncas=22, |
| 71 | + nelecas=(18,12), |
| 72 | + ncore=117, |
| 73 | + gas_orbs=(12,10,0), |
| 74 | + gas_restr={"max_holes": 2, "max_particles": 0}, |
| 75 | + gas_restr_type="ras", |
| 76 | +).density_fit(auxbasis=auxbasis) |
| 77 | + |
| 78 | +mc.verbose = 4 |
| 79 | +mc.max_memory = mol.max_memory |
| 80 | +mc.max_cycle_macro = 80 |
| 81 | +mc.conv_tol = 1e-8 |
| 82 | +mc.conv_tol_grad = 1e-5 |
| 83 | +mc.fcisolver.max_cycle = 300 |
| 84 | +mc.fcisolver.max_space = 30 |
| 85 | +mc.fcisolver.conv_tol = 1e-10 |
| 86 | +mc.fcisolver.conv_tol_residual = 1e-6 |
| 87 | + |
| 88 | +# fix spin |
| 89 | +mc.fix_spin_(shift=0.2, ss=target_s2) |
| 90 | +mc.kernel(mo_coeff) |
| 91 | + |
| 92 | +report = mc.spin_energy_report() |
| 93 | +pyscf_energy = report["physical"] |
| 94 | +ss, _ = mc.spin_square() |
| 95 | + |
| 96 | +print() |
| 97 | +print("OpenMolcas CD / PySCF DF GASSCF comparison") |
| 98 | +print(f"Auxiliary basis : {auxbasis}") |
| 99 | +print(f"GASSCF converged : {mc.converged}") |
| 100 | +print(f"GAS determinant count : {numpy.asarray(mc.ci).size}") |
| 101 | +print(f"E(OpenMolcas CD) / Eh : {openmolcas_energy:.12f}") |
| 102 | +print(f"E(PySCF DF, physical) : {pyscf_energy:.12f}") |
| 103 | +print(f"DF - CD / Eh : {pyscf_energy - openmolcas_energy:+.6e}") |
| 104 | +print(f"Spin penalty / Eh : {report['penalty']:.3e}") |
| 105 | +print(f"<S^2> : {ss:.10f}") |
| 106 | + |
| 107 | +# DF and CD use different integral approximations. Their energies need not |
| 108 | +# agree to the orbital-optimization tolerance; report the measured difference. |
| 109 | +# |
| 110 | +# Example output (last digits may depend on platform): |
| 111 | +# |
| 112 | +# GASSCF converged : True |
| 113 | +# E(OpenMolcas CD) / Eh : -3345.736089850000 |
| 114 | +# E(PySCF DF, physical) : -3345.735665001314 |
| 115 | +# DF - CD / Eh : +4.248487e-04 |
| 116 | +# <S^2> : 12.0000000000 |
| 117 | + |
0 commit comments