Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
62f1a99
test qvcc with numerical differentiation
equationW Nov 28, 2024
34d4f4e
numerical differentiation deleted
equationW Nov 28, 2024
e5f893e
unnecessary packages deleted
equationW Dec 3, 2024
4ac6159
naive qvdcd added
equationW Dec 12, 2024
31cd839
qvdcd v2.0
equationW Mar 4, 2025
d4aeb11
qvdcd v2.2
equationW Mar 5, 2025
723354d
tests in QVCCD/DCD
equationW Mar 27, 2025
4ca3704
test deleted, qvdcd v3.0
equationW Mar 27, 2025
7196012
merge to main
equationW Mar 27, 2025
f4c1eb0
fix something wrong in merge
equationW Mar 27, 2025
b40596c
qvdcd v4.1 debug version
equationW Apr 22, 2025
947155f
QVDCD v4.2 complete version
equationW Apr 29, 2025
7e0a102
cleanned up
equationW May 5, 2025
e2304eb
Merge branch 'main' into qvccd
equationW May 5, 2025
28c15be
extra deps removed
equationW May 5, 2025
adad9e1
orbital optimization added, reorganized
equationW May 9, 2025
64d80f1
AU equations
ChRickert May 12, 2025
b25fa3f
Add working eom-ccs
dnkats May 12, 2025
0d25d86
Merge branch 'EOM-DCSD' into eom
ChRickert May 12, 2025
8604342
added EOM prefix in @dfcc
ChRickert May 12, 2025
e4e66bc
bug fix
ChRickert May 12, 2025
a67aead
First debugging of AU equations & making it callable with @dfcc eom-s…
ChRickert May 12, 2025
308ccca
DF-CIS quickly implemented version seems to be functioning (attention…
ChRickert May 13, 2025
e77429d
Add eom-ccsd and eom-dcsd
dnkats May 13, 2025
ceb0dbe
CIS(D) (D) residuals added
ChRickert May 13, 2025
354d0bf
Merge branch 'charlotte_eom' into eom
ChRickert May 13, 2025
b3f2618
a little bit buggy EOM-SVD-DCSD added
ChRickert May 14, 2025
4de4b04
Add custom dot functions to davidson
dnkats May 15, 2025
812f7fe
one bug fixed eom-svd-dcsd
ChRickert May 15, 2025
2d29fe7
Merge branch 'charlotte_eom' into eom
ChRickert May 15, 2025
cdf0de4
Fix the last bug in svd-eom-dcsd
dnkats May 15, 2025
65666de
bugfix CIS(D)
ChRickert May 15, 2025
ec30e20
Use eom ampsvdtol option
dnkats May 16, 2025
2de4741
orbital optimization modified
equationW May 16, 2025
9de5e76
Use project_vovo_t2=1 for eom
dnkats May 19, 2025
6c21040
Add Laplace quadrature
dnkats Jun 4, 2025
9ed576f
Set development version
dnkats Jul 3, 2025
4b95394
Initial plan
Copilot Jul 12, 2025
2387739
Implement Levenshtein distance basis set suggestions
Copilot Jul 12, 2025
9bed3bc
Finalize Levenshtein distance basis set suggestions - all tests pass
Copilot Jul 12, 2025
454b731
Merge pull request #279 from fkfest/copilot/fix-221
dnkats Jul 12, 2025
3e5bb85
Add levenshtein test to runtests
dnkats Jul 12, 2025
17e1a96
Initial plan
Copilot Jul 12, 2025
1778b8b
Implement TREX format interface with comprehensive functionality
Copilot Jul 12, 2025
17ae3b4
Fix TREX interface exports and orbital loading with comprehensive tes…
Copilot Jul 12, 2025
1dc3547
Add implementation summary and finalize TREX format support
Copilot Jul 12, 2025
ec1b28c
Add TREX format documentation to doc build and update main index
Copilot Jul 12, 2025
a76364f
Add basis set information storage to TREX format when orbitals are wr…
Copilot Jul 13, 2025
10ac83e
Update TREX basis storage to follow TREXIO standard specification
Copilot Jul 13, 2025
0adf8c0
Fix TREX documentation reference in index.md
Copilot Jul 13, 2025
e9dc6f5
Add missing outputs.md to documentation build
Copilot Jul 13, 2025
489d99e
Add missing TrexInterface docstrings to documentation
Copilot Jul 13, 2025
6f7e0f4
Fix duplicate documentation for TrexFile type
Copilot Jul 13, 2025
60f3019
Rename TREX to TREXIO across entire codebase as requested
Copilot Jul 13, 2025
a43e59b
Merge pull request #281 from fkfest/copilot/fix-280
dnkats Jul 13, 2025
32075b2
Improve storing orbitals in trexio
dnkats Jul 13, 2025
6c49d51
Improve trexio docs
dnkats Jul 13, 2025
bcc285c
Fix writing and reading basis
dnkats Jul 14, 2025
ac7011a
Initial plan
Copilot Jul 14, 2025
3f3e2ae
Create standalone TREXIO module with full test coverage
Copilot Jul 14, 2025
d08eb8a
Integrate standalone TREXIO module with ElemCo interface layer
Copilot Jul 14, 2025
18ced57
Complete TREXIO separation with comprehensive testing and documentation
Copilot Jul 14, 2025
c04b6c5
Add documentation for standalone TREXIO module to fix missing docstrings
Copilot Jul 14, 2025
a063834
Implement TREXIO naming convention with trexio_[has|read|write]_<grou…
Copilot Jul 14, 2025
4910bf3
Merge pull request #283 from fkfest/copilot/fix-282
dnkats Jul 14, 2025
88b1f05
oqv works right
equationW Jul 28, 2025
5bad8bc
orbital optimization optimized
equationW Aug 20, 2025
7b6c947
a little change to git push
equationW Aug 20, 2025
5b3a243
Add automatic augmentation of the basis sets and several checks
dnkats Aug 21, 2025
8089907
Merge pull request #284 from fkfest/augbasis
dnkats Aug 21, 2025
583f194
Merge branch 'main' into qvccd
equationW Aug 21, 2025
45e5827
Add clear error message if fitbasis guess is not possible
dnkats Aug 21, 2025
ec743ac
Merge pull request #285 from fkfest/fitguess
dnkats Aug 21, 2025
d9de4cd
fix some little stuff
equationW Aug 21, 2025
d7dd45e
Merge branch 'main' into qvccd
equationW Aug 21, 2025
e5d784b
delete transIntEveryInter, and restore gradient
equationW Aug 21, 2025
a9d67bc
Add functions to print basis sets and add aug-jkfit basis to library
dnkats Aug 22, 2025
e106666
Merge pull request #286 from fkfest/augjkfit
dnkats Aug 22, 2025
d83431e
integrals can be not transformed for oqv, options added
equationW Aug 22, 2025
aba54c1
into integral calculated from fd.int2
equationW Sep 1, 2025
ec9fdec
D2 copy changed
equationW Sep 1, 2025
c4a1c61
remove D2_r def
equationW Sep 1, 2025
7fea212
remove D2_r eliminate
equationW Sep 1, 2025
0f3696e
Merge pull request #271 from fkfest/qvccd
dnkats Sep 1, 2025
7d6d9e4
Add a proper trexio implementation
dnkats Sep 5, 2025
6da13f5
Merge branch 'main' into trexio
dnkats Sep 5, 2025
2586cfb
Fix the docs
dnkats Sep 5, 2025
c9a72ea
Merge pull request #287 from fkfest/trexio
dnkats Sep 5, 2025
dc9776d
Remove ecdump
dnkats Sep 8, 2025
55b6756
Store orbitals in trexio dump file
dnkats Sep 8, 2025
860fb58
Switch to dump files for orbitals
dnkats Sep 12, 2025
54ab5c5
Fix @loadwf macro
dnkats Sep 12, 2025
4ec30cf
Add a new-system check to recalculate/reload integrals
dnkats Sep 16, 2025
08b0d63
Separate mtensor to a new module, improve integral transform in dump
dnkats Sep 18, 2025
8fc8890
Initial plan
Copilot Sep 18, 2025
015fd40
Add comprehensive Copilot instructions for ElemCo.jl
Copilot Sep 18, 2025
18abcc0
Update .copilot-instructions.md
dnkats Sep 18, 2025
809eeb5
Merge pull request #289 from fkfest/copilot/fix-288
dnkats Sep 18, 2025
4ed86e9
Move copilot-instructions.md to .github
dnkats Sep 18, 2025
292639f
Fix dummy atoms handling in the new implementation
dnkats Sep 19, 2025
5142f48
Add macros to save and copy wf dumps
dnkats Sep 19, 2025
077266a
Add fci files and equations
dnkats Oct 9, 2025
42ab547
Update and add new instructions
dnkats Oct 9, 2025
04750e0
Add hci macro
dnkats Oct 10, 2025
13002a3
Fix heat-bath selection in hci
dnkats Oct 12, 2025
00464d4
Use previous vectors as initial guess in hci iterations
dnkats Oct 12, 2025
dcc9687
Clean up some comments in hci/fci
dnkats Oct 12, 2025
330efc1
Fix bohf hcore starting guess
dnkats Oct 13, 2025
e51b166
Merge pull request #291 from fkfest/fix_bohf
dnkats Oct 13, 2025
b9dc100
Improve type stability
dnkats Oct 13, 2025
8758680
Decouple hci from fci
dnkats Oct 15, 2025
403c612
Move hci/fci options to main elemcoil options
dnkats Oct 16, 2025
b518945
Use QFDump in fci/hci
dnkats Oct 16, 2025
b0f6c48
Add option to set ref.det. for fci
dnkats Oct 16, 2025
d3b4375
Add fci/hci tests
dnkats Oct 20, 2025
632d842
Add BufVec structure for preallocated vectors
dnkats Oct 21, 2025
93f30e6
Refactoring hci code
dnkats Oct 22, 2025
11cec8a
Move precomp. intermediates to HEvalData structure
dnkats Oct 23, 2025
3ec4e04
Refactor selected ci code further
dnkats Oct 24, 2025
5bb9ff0
Precompute H for selected determinants in hci
dnkats Oct 24, 2025
4f3f882
Fix target_selection in hci, set it to 1Mil
dnkats Oct 24, 2025
ee91488
Add some stylistic changes to hci code
dnkats Oct 24, 2025
640d579
Use physicist index order in fcidump in fci/hci
dnkats Oct 24, 2025
4781290
Use gamma^pq_rs order of indices in 2RDM in fci
dnkats Oct 27, 2025
870a4ff
Use always pchb in selected ci
dnkats Oct 27, 2025
d935d1a
Use hci to precompute Hc for perturbative selection
dnkats Oct 28, 2025
4efecdd
Merge pull request #292 from fkfest/fci
dnkats Oct 28, 2025
a458f4d
Fix norms of bo orbitals to more balanced way
dnkats Oct 31, 2025
7238c9d
Merge pull request #293 from fkfest/fix_bonorms
dnkats Oct 31, 2025
8f98100
Use VecDict as SelectedHamiltonianRow
dnkats Nov 3, 2025
15a3b04
Speed up hamiltonian computation
dnkats Nov 5, 2025
813adf4
Store all connections in hci
dnkats Nov 5, 2025
b530268
Use occupation vectors for fock matrix calculation in hci
dnkats Nov 5, 2025
a9b89f5
Update docs on how we calculate the H matrix in hci
dnkats Nov 5, 2025
9da5d14
Merge pull request #295 from fkfest/hci
dnkats Nov 5, 2025
299c2a8
Calculate connections in extend! instead of in DetLookUpIndex
dnkats Nov 5, 2025
e076ed1
Merge pull request #296 from fkfest/hci
dnkats Nov 5, 2025
0729bcf
Pass SelectedCIContext to heatbath_selection instead of a vector of d…
dnkats Nov 6, 2025
0558450
Generate heat-bath candidates only for new determinants
dnkats Nov 6, 2025
a276f58
Merge pull request #297 from fkfest/hci
dnkats Nov 6, 2025
0d9dc3f
Make orbpattern a parametric type in fci/hci
dnkats Nov 7, 2025
f7d78b4
Merge pull request #298 from fkfest/orbpattern
dnkats Nov 7, 2025
4a080be
Simplify buffers in hci
dnkats Nov 12, 2025
5e77c78
Merge pull request #299 from fkfest/hci_bufs
dnkats Nov 12, 2025
14969c4
Calculate coefs on-the-fly using EN denominators
dnkats Nov 13, 2025
7954814
Add option to use MP2 instead of EN2 in hci
dnkats Nov 13, 2025
93da8d3
Divide sci code into several files
dnkats Nov 14, 2025
73eab1e
Add prescreening of T2 in PT2 in hci (epsilon_pt2_c)
dnkats Nov 17, 2025
1c9f460
Merge pull request #300 from fkfest/hci_en2
dnkats Nov 17, 2025
f3e35e1
Extend hci to non-hermitian hamiltonians
dnkats Nov 19, 2025
55c9330
Merge pull request #301 from fkfest/tc-hci
dnkats Nov 19, 2025
50a775e
Add extrapolate function for extrapolation
dnkats Nov 27, 2025
ee79167
Merge pull request #303 from fkfest/hci_extrapolate
dnkats Nov 27, 2025
c2d7f67
Fix neglected pt2 estimation, add 2-step selection
dnkats Nov 28, 2025
0c86ba3
Merge pull request #304 from fkfest/hci_fixes
dnkats Nov 28, 2025
8eb9e9b
Add laplace weights
dnkats Dec 2, 2025
7a24a47
Laplace_newai started
ChRickert Dec 2, 2025
c07eb6e
in laplace_noai full Laplace algorithm written, but not debugged yet
ChRickert Dec 2, 2025
d73d69c
Fix laplace noai with ai
dnkats Dec 3, 2025
bc230d6
starting points with Chebichev nodes 2nd order
ChRickert Dec 3, 2025
64740b9
Start sos-mp2
dnkats Dec 3, 2025
56e112a
fixed bug in reading in points t and weights w and changed starting g…
ChRickert Dec 3, 2025
b3f1cce
changed tolerance back to 1.e-6
ChRickert Dec 3, 2025
c0c9126
Add sos-mp2
dnkats Dec 4, 2025
681218f
New starting guess for U's for SVD-DCSD, not debugged yet
ChRickert Dec 4, 2025
bb8412d
Small refactorization of svd space from laplace
dnkats Dec 5, 2025
0dbb4d3
Update laplace_points for inital guess
dnkats Dec 5, 2025
008cd1f
added differnt decomposition approaches as the SVD basis starting gue…
ChRickert Dec 6, 2025
eda6747
5 test methods present to avoid decomposing full U2
ChRickert Dec 7, 2025
eda34fa
Merge branch 'eom' of github.com:fkfest/ElemCo.jl-devel into eom
dnkats Dec 8, 2025
c74ce18
Store T2 in T_vvoo in svd-dcsd
dnkats Dec 8, 2025
5e27a73
Fix eom-dcsd
dnkats Dec 8, 2025
0355932
option for selection of different SVD basis for EOM
ChRickert Dec 8, 2025
5afd1e1
Merge branch 'main' into eom
dnkats Dec 10, 2025
c017893
Fix docs etc
dnkats Dec 10, 2025
56d29a3
Merge pull request #305 from fkfest/eom
dnkats Dec 10, 2025
81f0ca8
Update equations.pdf
dnkats Dec 10, 2025
ab3a889
Replace internal Base.replace_ref_begin_end! with our own implementation
dnkats Dec 10, 2025
9b5d3df
Merge pull request #306 from fkfest/endmview
dnkats Dec 10, 2025
a8ad2d4
Restrict rotate2real in davidson to nstates
dnkats Dec 11, 2025
02a239a
Add [aug-]sigma[x]z0 basis sets
dnkats Dec 15, 2025
9ea2e91
Fix linter problems
dnkats Dec 28, 2025
9fef217
Merge branch 'main' of github.com:fkfest/ElemCo.jl-devel
dnkats Dec 28, 2025
ca36846
Merge branches 'main' and 'trexio'
dnkats Jan 9, 2026
a865bb7
Enhance TREXIO support for HDF5 attributes and datasets; implement sp…
dnkats Jan 9, 2026
1518ad2
Rename wf.dump_new option to wf.store
dnkats Jan 9, 2026
5c36940
Add local options handling in calculation macros
dnkats Jan 11, 2026
5fd67b0
Update changelog
dnkats Jan 13, 2026
c7fbd58
Add option to store and start for amplitudes
dnkats Jan 15, 2026
7145e3a
Fix for amplitudes restart
dnkats Jan 16, 2026
3538ed2
Move input utils from main file to a separate file
dnkats Jan 19, 2026
499ce91
Refactor parse options block
dnkats Jan 19, 2026
ee86e93
Add store/start for hci
dnkats Jan 20, 2026
839fdac
Rename hci to ciphi
dnkats Jan 21, 2026
0c3c15a
Fix docs
dnkats Jan 22, 2026
02a1abb
Merge pull request #308 from fkfest/trexio
dnkats Jan 22, 2026
cee718a
Update @loadwf/@savewf/@copywf for amplitudes and CI
dnkats Jan 22, 2026
c0bfbd7
Improve doc string for loadwf
dnkats Jan 22, 2026
df03274
Merge pull request #309 from fkfest/loadwf
dnkats Jan 22, 2026
a982658
Fix svd-dc-ccsdt test
dnkats Jan 23, 2026
af0b1a5
Merge pull request #310 from fkfest/fixtest
dnkats Jan 23, 2026
bd834b2
Use pseudo-canonicalization in (T) for non-diagonal Fock matrices
dnkats Jan 28, 2026
659cbc4
Add an option to skip (T) in SVD-DC-CCSDT calculations
dnkats Jan 28, 2026
91aac0a
Add testjobs for non-canonical (T)
dnkats Jan 28, 2026
0ad6a98
Merge branch 'main' into pseudocan_t
dnkats Jan 28, 2026
2e598c5
Cosmetic changes
dnkats Jan 29, 2026
d46a285
Merge pull request #312 from fkfest/pseudocan_t
dnkats Jan 29, 2026
a336ff1
Fix loading orbitals in df-lt-sos-mp2
dnkats Jan 29, 2026
c56e518
Use symmetrized Fock in canonical check
dnkats Jan 29, 2026
bf245ee
Update the testjob for TC-CCSD(T)
dnkats Jan 29, 2026
675562a
Fix #272 UCCSD/UDCSD for no beta electrons
dnkats Jan 30, 2026
1c3dc42
Fix testjob
dnkats Jan 30, 2026
e708e34
Merge pull request #313 from fkfest/fix272
dnkats Jan 30, 2026
526ab9b
Fix type stability issues introduced in recent commits
dnkats Feb 3, 2026
63e669a
Add fixes suggested by copilot
dnkats Feb 3, 2026
bff75fd
Merge pull request #314 from fkfest/typestability
dnkats Feb 3, 2026
4e6cad4
Update runtests.jl from lib/TREXIO
dnkats Feb 4, 2026
033b081
Update README
dnkats Feb 5, 2026
4e4ab1f
Add dependabot
dnkats Feb 5, 2026
5bef0b8
Bump julia-actions/setup-julia from 1 to 2
dependabot[bot] Feb 5, 2026
d37f491
Bump actions/checkout from 4 to 6
dependabot[bot] Feb 5, 2026
49ae288
Merge pull request #315 from fkfest/dependabot/github_actions/julia-a…
dnkats Feb 5, 2026
15b1144
Merge pull request #316 from fkfest/dependabot/github_actions/actions…
dnkats Feb 5, 2026
fb402ad
Release v0.15.0
dnkats Feb 5, 2026
9db06c5
Merge pull request #317 from fkfest/main
dnkats Feb 5, 2026
c81b855
Merge remote-tracking branch 'source/stable' into auto/from-devel-repo
actions-user Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
329 changes: 329 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
# ElemCo.jl Copilot Instructions

This repository contains **ElemCo.jl** (*elemcoil*), a Julia package for electronic structure calculations and quantum chemistry computations, with a focus on coupled cluster methods and electron correlation techniques.

## Project Overview

ElemCo.jl is a scientific computing package that provides:
- Coupled cluster methods (CCSD, DCSD, CCSDT, etc.)
- Density-fitted Hartree-Fock (DF-HF) calculations
- Post-Hartree-Fock methods including MP2
- Quantum chemistry interfaces (Molpro, TREXIO, FCIDUMP)
- Advanced tensor operations and orbital tools
- DMRG (Density Matrix Renormalization Group) integration
- Full Configuration Interaction (FCI) with Selected CI and Heat-Bath CI

## Architecture Overview

### Core Data Flow
1. **System Definition** → 2. **Integrals** → 3. **SCF** → 4. **CC/Post-HF** → 5. **Properties**
- `MSystems` (molecular geometry, basis sets) → `Integrals` (FCIDUMP or DF) → `DFHF`/`BOHF` (orbitals) → `CoupledCluster` (amplitudes) → `CCTools` (properties)

### Central State Object: `ECInfo`
- **Location**: `src/infos/ecinfos.jl`
- **Purpose**: Global state container for all calculations
- **Key fields**:
- `EC.system`: Molecular system (`MSystems.MolecularSystem`)
- `EC.fd`: FCIDUMP integrals (`FciDumps.FciDump`)
- `EC.options`: All calculation options (nested structure: `scf`, `cc`, `cholesky`, `wf`, etc.)
- `EC.space`: Orbital space dictionary (`'o'` = occupied, `'v'` = virtual, etc.)
- **Usage**: Always passed as first argument: `function_name(EC::ECInfo, ...)`

### Module Organization
```
src/
├── ElemCo.jl # Main module, includes all submodules, defines macros
├── infos/ # ECInfo, Options, ECMethod
├── system/ # MolecularSystem, BasisSet, Elements
├── integrals/ # FciDump, DumpTools, DFTools
├── scf/ # DFHF, BOHF, DFMCSCF, OrbTools, FockFactory
├── cc/ # CoupledCluster, CCTools, Drivers, DMRG
├── fci/ # FCI, Davidson, Selected CI, Heat-Bath CI
├── solvers/ # DIIS, Davidson
├── tools/ # TensorTools, QMTensors, MIO, Utils
└── interfaces/ # Molpro, TREXIO, Molden
```

## Code Style and Format

### Julia Conventions

**General Style:**
- Use 2-space indentation consistently
- Follow Julia standard naming conventions:
- `snake_case` for functions and variables
- `PascalCase` for types and modules
- `UPPER_CASE` for constants
- Line length: aim for 80-100 characters, but scientific formulas may exceed this
- Use descriptive variable names, especially for physical quantities

**Function Documentation:**
- Use Julia docstrings with triple quotes `"""`
- Include mathematical formulas using LaTeX notation when relevant
- Document parameters, return values, and provide examples for complex functions
- Use proper LaTeX formatting for equations, e.g., `[``units``]` for units

**Example:**
```julia
"""
calc_ccsd_energy(EC::ECInfo, T1, T2)

Calculate the CCSD correlation energy using cluster amplitudes.

# Arguments
- `EC::ECInfo`: Electronic structure information object
- `T1`: Single excitation amplitudes [``T_i^a``]
- `T2`: Double excitation amplitudes [``T_{ij}^{ab}``]

# Returns
- `Float64`: CCSD correlation energy in atomic units

# Example
```julia
T1 = load2idx(EC, "T_vo")
T2 = load4idx(EC, "T_vvoo")
E_corr = calc_ccsd_energy(EC, T1, T2)
```
"""
```

**Macros:**
- The package uses domain-specific macros extensively (e.g., `@dfhf`, `@cc`, `@set`)
- Macro names use lowercase with underscores
- Reserved variable names: `fcidump`, `geometry`, `basis`
- Always include `@print_input` at the beginning of input scripts

**Tensor Operations:**
- Use `@mtensor` macro for tensor contractions (wraps `TensorOperations.@tensor`)
- Follow Einstein summation notation in comments
- Include LaTeX expressions for tensor equations in comments
- Example: `# R_e^m += D_{id}^{el} (\\hat v_{ml}^{di}-\\hat v_{lm}^{di})`
- Example code: `@mtensor A[p,q,L] = B[p,r,L] * C[r,q]`
- Use `@mview` for memory-efficient array views (based on `StridedViews`)

### Domain-Specific Language (DSL)
ElemCo uses **macro-based DSL** for user-facing API (see `src/ElemCo.jl` lines 250-600):

**Key Macros:**
- `@ECinit` / `@tryECinit` - Initialize `EC::ECInfo` global state
- `@print_input` - prints input for reproducibility
- `@dfhf` / `@dfuhf` / `@dfmcscf` - Run SCF calculations, store orbitals in `EC.options.wf.orb`
- `@cc <method>` - Run CC calculations (automatically calls `@dfints` if needed)
- `@dfcc <method>` - Run CC with on-the-fly density fitting
- `@set <opt> <key>=<val>` - Set options (e.g., `@set scf thr=1.e-14 maxit=100`)
- `@fci` - Run FCI calculation

**Reserved Variables:**
- `fcidump::String` - Path to FCIDUMP file
- `geometry::String` - Molecular geometry (Cartesian or Z-matrix)
- `basis::String` or `Dict` - Basis set specification
- `EC::ECInfo` - Global state object (auto-created by macros)

**Example Input Pattern:**
```julia
using ElemCo
@print_input # Always first!

geometry = "O 0 0 0; H 0 0 1.8; H 0 1.8 0"
basis = "cc-pVDZ"
@dfhf # Run HF, stores orbitals
@cc dcsd # Run DCSD using stored orbitals
```

### Module Structure

**File Organization:**
- Main module: `src/ElemCo.jl`
- Submodules organized by functionality:
- `cc/` - Coupled cluster methods (see `drivers.jl` for entry points)
- `scf/` - Self-consistent field methods
- `integrals/` - Integral handling and transformations
- `system/` - Molecular systems and basis sets
- `tools/` - Utilities and tensor operations
- `interfaces/` - External program interfaces (Molpro, TREXIO)
- `fci/` - Full CI implementation

**Constants and Physical Units:**
- Define physical constants in `Constants` module
- Include proper units in docstrings: `[``m~s^{-1}``]`
- Use atomic units as the default unit system

## Development Guidelines

### Testing
- Tests are located in `test/` directory
- Use descriptive test names that indicate the method being tested
- Test files follow pattern: `method_system.jl` (e.g., `h2o_dcsd.jl`)
- Tests use `@testset` with energy comparisons and numerical thresholds
- Standard test pattern:
```julia
@testset "System Method Test" begin
epsilon = 1.e-6
E_ref = -75.6457645933 # Reference energy

@print_input
fcidump = joinpath(@__DIR__, "files", "system.FCIDUMP")
energies = @cc method

@test abs(energies["METHOD"] - E_ref) < epsilon
end
```
- Run tests with: `julia --project=. test/runtests.jl`
- Quick tests available via: `julia --project=. test/runtests.jl quick`

### Dependencies
- Minimize external dependencies
- Use `LinearAlgebra`, `TensorOperations` for mathematical operations
- HDF5 for data storage, XML for configuration files
- `libcint_jll` for integral calculations

### Performance Considerations
- **Type stability is essential**: All performance-critical functions must be type-stable
- Ensure return types are inferrable from input types at compile time
- Use `@code_warntype` to check for type instabilities
- Avoid abstract types in struct fields (use parametric types or concrete types)
- Use `Val{N}` for dimension-dependent code (see `mioload` in `src/tools/myio.jl`)
- Example: Return `Array{Float64,N}` not `Array` from functions
- Use in-place operations where possible (functions ending with `!`)
- Leverage BLAS operations via `LinearAlgebra`
- Memory management is crucial for large tensor operations
- Use `load4idx()` (`load3idx`, `load2idx`, etc) and `save4idx()` (`save3idx()`, `save2idx()`, etc) for tensor disk I/O

### Type Stability Checking with JET

Use **JET.jl** for comprehensive type stability analysis. The analysis script is in `profile/jet.jl`.

**Running JET Analysis:**
```bash
julia --project=. profile/jet.jl
```

**How it works:**
- Uses `@report_opt` to analyze optimization issues and runtime dispatches
- Targets all ElemCo modules to catch type instabilities across the codebase
- Reports "possible errors" which are typically runtime dispatches due to type instability

**Fixing Type Instabilities - Key Principles:**

1. **Minimize type annotations**: Do NOT add return type annotations as a first solution
2. **Find and fix the root cause**: Trace the instability back to its origin
3. **Common root causes:**
- Functions returning abstract types (e.g., `Matrix{T} where T` instead of `Matrix{Float64}`)
- Closures with `f::Function` abstract type preventing inference
- Type-unstable data flowing through multiple function calls
- Reading data from files/interfaces without concrete type conversion

4. **Fixing strategies (in order of preference):**
- Fix the source function to return concrete types
- Add explicit type conversion at data boundaries (e.g., `Matrix{Float64}(data)`)
- Use concrete types in struct fields
- Only as last resort: add return type annotations

5. **Known acceptable instabilities:**
- `kwcall` runtime dispatch (inherent Julia limitation with keyword arguments)
- Dynamic dispatch in initialization code (not performance-critical)

**Example - Fixing at the source:**
```julia
# BAD: Adding annotation to hide the problem
function process_data(data)::Matrix{Float64}
return compute(data) # compute() returns abstract type
end

# GOOD: Fix compute() to return concrete type
function compute(data)
result = some_operation(data)
return Matrix{Float64}(result) # Convert at the source
end

function process_data(data)
return compute(data) # Now type-stable without annotation
end
```

**After making changes:**
- Re-run `profile/jet.jl` to verify improvements
- Run test suite to ensure correctness: `julia --project=. test/runtests.jl`

## Quantum Chemistry Specifics

### Mathematical Notation
- Use standard quantum chemistry notation
- Greek letters for spin indices (α, β)
- Latin letters for spatial orbitals (i,j,k... occupied, a,b,c... virtual)
- Tensor indices follow physicist's notation

### Method Implementations
- Coupled cluster amplitudes: T1 (singles), T2 (doubles), T3 (triples)
- Density matrices: 1RDM, 2RDM with proper symmetry
- Fock matrices with density fitting approximations
- Molecular orbital coefficients and transformations

### Input File Format
Standard input files should start with:
```julia
using ElemCo
@print_input

# Option 1: Using FCIDUMP file
fcidump = "path/to/file.FCIDUMP"
@cc dcsd

# Option 2: Define molecular system
geometry = "H 0.0 0.0 0.0
H 0.0 0.0 1.0"
basis = "cc-pVDZ"
@dfhf
@cc dcsd

# Option 3: Using ccdriver function
EC = ECInfo()
energies = ElemCo.ccdriver(EC, "ccsd(t)"; fcidump="file.FCIDUMP")
```

**Key Input Patterns:**
- Always include `@print_input` for reproducibility
- Use `fcidump`, `geometry`, `basis` as reserved variable names
- Methods: `dcsd`, `ccsd`, `ccsd(t)`, `λccsd(t)`, `mp2`, etc.
- Options set via `@set` macro: `@set scf maxit=50`
- Occupation can be specified: `@cc dcsd occa="1-5" occb="1-4"`

## Common Patterns

### Error Handling
- Use Julia's exception system
- Provide meaningful error messages with context
- Include suggestions for fixing common user errors

### Logging and Output
- Use `println()` for user-facing output
- Include timing information for expensive operations
- Progress reporting for iterative methods
- ASCII art headers for major calculation sections

### Memory Management
- Use `NOTHING4idx` (`NOTHING3idx`, `NOTHING2idx`, etc) constant for clearing large tensors
- Implement scratch directory management (default: system temp dir + "elemcojlscr")
- Handle temporary files appropriately
- Memory-mapped I/O for large tensors via `MIO` module (`miosave`, `mioload`, `miommap`)

## Contributing Guidelines

### Code Reviews
- Ensure mathematical correctness of implementations
- Verify numerical stability and convergence
- Check performance implications of changes
- Validate against reference implementations when available

### Documentation
- Update docstrings for any API changes
- Include examples in documentation
- Mathematical derivations should be clear and complete
- Reference papers and methods appropriately

### Backward Compatibility
- Maintain compatibility with existing input files
- Deprecate features gracefully with warnings
- Preserve numerical results for regression testing

Remember: This is scientific software where correctness and numerical stability are paramount. Always validate implementations against established quantum chemistry references and test with multiple molecular systems.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "julia"
directory: "/"
schedule:
interval: "weekly"
# groups: # uncomment to group all julia package updates into a single PR
# all-julia-packages:
# patterns:
# - "*"
Loading
Loading