Repository navigation
Add generalized active space CI solver with OpenMP C kernels #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
900992f
fci: add core GAS FCI C kernels
yideng2025 bb8ee90
build: add CMake target for GAS FCI kernels
yideng2025 c0c298d
feat(mcscf): add GASCI solver
yideng2025 661b773
fix(mcscf): finalize GASCI kernel and Python interfaces
yideng2025 c19f834
test(mcscf): add GASCI tests and examples
yideng2025 64a2d7d
fix(mcscf): propagate solver spin through GASCI
yideng2025 4bb49e3
fix(mcscf): address GASCI review feedback
yideng2025 39bf496
fix(mcscf): label GASCI kernel output
yideng2025 830cefc
examples: validate GASCI energies against OpenMolcas
yideng2025 9b05539
mcscf: add O2 GASCI energy regression test
yideng2025 635e413
mcscf: add OpenMolcas GASCI regression coverage
yideng2025 3b845a4
Merge upstream master into feature/gasci
yideng2025 83e2ba7
mcscf: add GAS-FCI projection validation
yideng2025 be5ca13
mcscf: unify GAS Hamiltonian contraction plans
yideng2025 8fa10f9
mcscf: move spin-free GAS RDM assembly to Python
yideng2025 2b1443c
mcscf: manage GAS contraction intermediates in Python
yideng2025 dded087
mcscf: reuse PySCF electron-count unpacking
yideng2025 9569800
mcscf: require integer GAS restriction inputs
yideng2025 e928f40
mcscf: simplify GAS scalar validation
yideng2025 336a2d2
mcscf: inline GAS CAS block construction
yideng2025 088d544
mcscf: remove unused GAS helper
yideng2025 93604c7
mcscf: align GAS diagonal selection with PySCF
yideng2025 bcdc313
mcscf: reuse GAS space for CI initial guesses
yideng2025 73bede5
mcscf: reuse CASCI one-electron Hamiltonian helper
yideng2025 f72f9f9
mcscf: add transition metal RASCI example
yideng2025 8934119
fix(mcscf): update Al2FeO4+ RASCI orbitals
yideng2025 2c540a7
refactor(mcscf): make GAS binomial table static
yideng2025 9f7520a
style(mcscf): clean up GAS comments and spacing
yideng2025 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # Author: Yi Deng <yideng@uchicago.edu> | ||
| # | ||
|
|
||
| """Fixed-orbital GASCI with an explicit spin-supergroup set D.""" | ||
|
|
||
| import numpy | ||
|
|
||
| from pyscf import gto | ||
| from pyscf import scf | ||
| from pyscf.mcscf import gasci | ||
|
|
||
|
|
||
| mol = gto.M( | ||
| atom="N 0 0 0; N 0 0 1.10", | ||
| basis="sto-3g", | ||
| spin=0, | ||
| verbose=0, | ||
| ) | ||
| mf = scf.RHF(mol).run() | ||
|
|
||
| # Each row is (alpha occupations, beta occupations). Rows are normalized to | ||
| # lexicographic order and duplicates are removed before entering the C kernel. | ||
| gas_restr = numpy.asarray([ | ||
| [0, 2, 2, 0], | ||
| [1, 1, 1, 1], | ||
| [2, 0, 0, 2], | ||
| ], dtype=numpy.int32) | ||
|
|
||
| mc = gasci.GASCI( | ||
| mf, 4, (2, 2), ncore=5, | ||
| gas_orbs=(2, 2), | ||
| gas_restr=gas_restr, | ||
| gas_restr_type="spin-supergroup", | ||
| ) | ||
| mc.verbose = 4 | ||
| e_tot, e_gas, ci, _, _ = mc.kernel() | ||
|
|
||
| print("GASCI total energy = %.12f" % e_tot) | ||
| print("GASCI active-space energy = %.12f" % e_gas) | ||
| print("GAS determinant count = %d" % ci.size) | ||
| print("GAS space information = %s" % mc.gas_space_info()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # Author: Yi Deng <yideng@uchicago.edu> | ||
| # | ||
|
|
||
| """Normalize the four supported GAS restriction input formats.""" | ||
|
|
||
| import numpy | ||
|
|
||
| from pyscf.mcscf import addons_gas | ||
|
|
||
|
|
||
| gas_orbs = (2, 2) | ||
| nelec = (2, 2) | ||
|
|
||
| spin_supergroups = numpy.asarray([ | ||
| [2, 0, 0, 2], | ||
| [1, 1, 1, 1], | ||
| [0, 2, 2, 0], | ||
| [1, 1, 1, 1], # Duplicate rows are removed. | ||
| ]) | ||
| supergroups = numpy.asarray([[2, 2]]) | ||
| cumulative_occ = numpy.asarray([[2, 2], [4, 4]]) | ||
|
|
||
| for restriction_type, restriction in ( | ||
| ("spin-supergroup", spin_supergroups), | ||
| ("supergroup", supergroups), | ||
| ("cumulative-occ", cumulative_occ)): | ||
| blocks = addons_gas.normalize_gas_restr( | ||
| gas_orbs, nelec, restriction, restriction_type) | ||
| print("%-17s ->\n%s" % (restriction_type, blocks)) | ||
|
|
||
| ras_blocks = addons_gas.normalize_gas_restr( | ||
| (1, 2, 1), nelec, | ||
| {"max_holes": 1, "max_particles": 1}, | ||
| "ras", | ||
| ) | ||
| print("ras ->\n%s" % ras_blocks) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # Author: Yi Deng <yideng@uchicago.edu> | ||
| # | ||
|
|
||
| """Multiroot GASCI with cumulative restrictions and state-resolved RDMs.""" | ||
|
|
||
| import numpy | ||
|
|
||
| from pyscf import gto | ||
| from pyscf import scf | ||
| from pyscf.mcscf import gasci | ||
|
|
||
|
|
||
| mol = gto.M( | ||
| atom="N 0 0 0; N 0 0 1.10", basis="sto-3g", spin=0, verbose=0) | ||
| mf = scf.RHF(mol).run() | ||
|
|
||
| # Each row gives the lower and upper cumulative electron occupation after | ||
| # adding the corresponding GAS subspace. | ||
| mc = gasci.GASCI( | ||
| mf, 4, (2, 2), ncore=5, | ||
| gas_orbs=(2, 2), | ||
| gas_restr=[[1, 3], [4, 4]], | ||
| gas_restr_type="cumulative-occ", | ||
| ) | ||
| mc.fcisolver.nroots = 3 | ||
| mc.verbose = 4 | ||
| energies, _, _, _, _ = mc.kernel() | ||
|
|
||
| for state, energy in enumerate(numpy.asarray(energies).reshape(-1)): | ||
| dm1, dm2 = mc.make_gasdm12(state=state) | ||
| ss, multiplicity = mc.spin_square(state=state) | ||
| pair_trace = numpy.einsum("pprr", dm2).real | ||
| print("state %d E = %.12f Tr(D1) = %.8f S^2 = %.8f mult = %.4f" % | ||
| (state, energy, numpy.trace(dm1), ss, multiplicity)) | ||
| print("state %d Tr_pair(D2) = %.8f" % (state, pair_trace)) | ||
|
|
||
| tdm1, tdm2 = mc.trans_gasdm12(bra_state=0, ket_state=2) | ||
| print("transition 0 -> 2: ||D1|| = %.8f ||D2|| = %.8f" % | ||
| (numpy.linalg.norm(tdm1), numpy.linalg.norm(tdm2))) | ||
|
|
||
| _, natural_occ = mc.get_gas_natorb(state=0) | ||
| _, pseudo_occ = mc.get_gas_pseudo_natorb(state=0) | ||
| print("natural occupations = %s" % natural_occ) | ||
| for igas, occupations in enumerate(pseudo_occ): | ||
| print("GAS%d pseudo-natural occupations = %s" % | ||
| (igas + 1, occupations)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.