├── .codecov.yml ├── .editorconfig ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── documentation.yml │ ├── publish.yml │ └── tests.yml ├── .gitignore ├── .lgtm.yml ├── .pre-commit-config.yaml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── COPYING ├── Makefile ├── README.md ├── ccpy ├── __init__.py ├── _version.py ├── cc │ ├── __init__.py │ ├── accd.py │ ├── accsd.py │ ├── accsdt_p.py │ ├── cc2.py │ ├── cc3.py │ ├── cc4-old.py │ ├── cc4.py │ ├── ccd.py │ ├── ccsd.py │ ├── ccsd_chol.py │ ├── ccsdt.py │ ├── ccsdt_chol.py │ ├── ccsdt_p.py │ ├── ccsdt_p_chol.py │ ├── ccsdtq.py │ ├── eccc2.py │ └── meson.build ├── cholesky │ ├── __init__.py │ ├── cholesky.py │ ├── cholesky_builders.py │ └── meson.build ├── constants │ ├── __init__.py │ ├── constants.py │ └── meson.build ├── density │ ├── __init__.py │ ├── meson.build │ ├── natural_orbitals.py │ └── rdm1.py ├── drivers │ ├── __init__.py │ ├── adaptive.py │ ├── diis.py │ ├── driver.py │ ├── meson.build │ ├── solvers-bak.py │ └── solvers.py ├── energy │ ├── __init__.py │ ├── cc_energy.py │ ├── hf_energy.py │ ├── lrcc_energy.py │ └── meson.build ├── eom_guess │ ├── __init__.py │ ├── cis.py │ ├── cisd.py │ ├── cisd_chol.py │ ├── cisd_matrix.py │ ├── deacis.py │ ├── dipcis.py │ ├── eacis.py │ ├── eacisd.py │ ├── ipcis.py │ ├── ipcisd.py │ ├── meson.build │ ├── s2matrix.py │ └── sfcis.py ├── eomcc │ ├── __init__.py │ ├── deaeom2.py │ ├── deaeom3.py │ ├── deaeom4.py │ ├── deaeom4_intermediates.py │ ├── deaeom4_p.py │ ├── dipeom3.py │ ├── dipeom4.py │ ├── dipeom4_intermediates.py │ ├── dipeomccsdt.py │ ├── dipeomccsdta.py │ ├── eaeom2.py │ ├── eaeom3.py │ ├── eaeom3_intermediates.py │ ├── eaeom3_p.py │ ├── eaeomccsdt.py │ ├── eomcc2.py │ ├── eomcc3.py │ ├── eomcc3_intermediates.py │ ├── eomccsd.py │ ├── eomccsd_chol.py │ ├── eomccsd_intermediates.py │ ├── eomccsdt.py │ ├── eomccsdt_intermediates.py │ ├── eomccsdt_p.py │ ├── ipeom2.py │ ├── ipeom3.py │ ├── ipeom3_intermediates.py │ ├── ipeom3_p.py │ ├── ipeomccsdt.py │ ├── ipeomccsdt_p.py │ ├── ipeomccsdta.py │ ├── meson.build │ ├── sfeomcc23.py │ ├── sfeomcc23_intermediates.py │ ├── sfeomccsd.py │ └── teaeom2.py ├── extcorr │ ├── __init__.py │ ├── contractions_t3.py │ ├── contractions_t4.py │ ├── ecccp3.py │ ├── external_correction.py │ └── meson.build ├── extrapolation │ ├── __init__.py │ ├── goodson_extrapolation.py │ └── meson.build ├── hbar │ ├── __init__.py │ ├── debug │ │ ├── hbar_cc3_debug.py │ │ ├── hbar_ccsd_chol_debug.py │ │ ├── hbar_ccsd_debug.py │ │ └── hbar_ccsdt_p_debug.py │ ├── diagonal.py │ ├── hbar_cc2.py │ ├── hbar_cc3.py │ ├── hbar_cc4.py │ ├── hbar_ccs.py │ ├── hbar_ccsd.py │ ├── hbar_ccsd_chol.py │ ├── hbar_ccsd_debug.py │ ├── hbar_ccsdt.py │ ├── hbar_ccsdt1.py │ ├── hbar_ccsdt_p.py │ ├── hbar_ccsdta.py │ └── meson.build ├── interfaces │ ├── __init__.py │ ├── fcidump_tools.py │ ├── gamess_tools.py │ ├── meson.build │ ├── pyscf_tools.py │ └── qp2_tools.py ├── left │ ├── __init__.py │ ├── left_cc3.py │ ├── left_cc_intermediates.py │ ├── left_ccsd.py │ ├── left_ccsd_chol.py │ ├── left_ccsdt.py │ ├── left_ccsdt_p.py │ ├── left_ccsdt_p_slow.py │ ├── left_eaeom2.py │ ├── left_eaeom3.py │ ├── left_eaeom3_p.py │ ├── left_eaeom_intermediates.py │ ├── left_ipeom2.py │ ├── left_ipeom3.py │ ├── left_ipeom3_p.py │ ├── left_ipeom_intermediates.py │ └── meson.build ├── lib │ ├── __init__.py │ ├── core.py │ ├── fortran │ │ ├── Makefile │ │ ├── __init__.py │ │ ├── active_pspace.f90 │ │ ├── antisymmetrizers.f90 │ │ ├── backups │ │ │ ├── cc3_loops-bak.f90 │ │ │ ├── cc_active_loops-orig.f90 │ │ │ ├── ccp3_adaptive_loops.f90 │ │ │ ├── ccp_intermediates.f90 │ │ │ ├── ccp_linear_loops.f90 │ │ │ ├── ccp_linear_loops_omp.f90 │ │ │ ├── ccp_loops.f90 │ │ │ ├── ccp_matrix.f90 │ │ │ ├── ccp_opt_loops.f90 │ │ │ ├── ccp_opt_loops_v2.f90 │ │ │ ├── ccp_opt_loops_v3.f90 │ │ │ ├── ccp_quadratic_loops.f90 │ │ │ ├── ccp_quadratic_loops_direct.f90 │ │ │ ├── ccp_quadratic_loops_direct_031623-t3bpspacework.f90 │ │ │ ├── ccp_quadratic_loops_direct_h-backup.f90 │ │ │ ├── ccp_quadratic_loops_direct_h.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-031623-t3boptcompelte.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-3-15-2023-2.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-3-15-2023.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-h2b-vvvv-success.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-h2bvvvv-try-v2.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-h2bvvvv-try.f90 │ │ │ ├── ccp_quadratic_loops_direct_opt-pre-intent-change.f90 │ │ │ ├── ccp_quadratic_loops_omp.f90 │ │ │ ├── ccsdt_p_loops-before-cache-opt.f90 │ │ │ ├── clusteranalysis.f90_bak │ │ │ ├── einsum.f90 │ │ │ ├── eomcc_initial_guess.f90 │ │ │ ├── eomccsdt_p_loops.f90 │ │ │ ├── hbar_matrix_elements.f90 │ │ │ ├── slater.f90 │ │ │ └── sort_t3.f90 │ │ ├── cc3_loops.f90 │ │ ├── cc4_loops.f90 │ │ ├── cc_loops.f90 │ │ ├── cc_loops2.f90 │ │ ├── cc_loops_t4.f90 │ │ ├── ccp3_adaptive_loops.f90 │ │ ├── ccp3_full_correction.f90 │ │ ├── ccp3_full_correction_high_mem.f90 │ │ ├── ccp3_loops.f90 │ │ ├── ccp3_opt_loops.f90 │ │ ├── ccsdpt_loops.f90 │ │ ├── ccsdt_p_chol_loops.f90 │ │ ├── ccsdt_p_loops.f90 │ │ ├── cct3_loops.f90 │ │ ├── clusteranalysis.f90 │ │ ├── combinatorics.f90 │ │ ├── constants.f90 │ │ ├── crcc24_loops.f90 │ │ ├── crcc24_opt_loops.f90 │ │ ├── crcc_loops.f90 │ │ ├── creacc_loops.f90 │ │ ├── cripcc_loops.f90 │ │ ├── deaeom4_p_intermediates.f90 │ │ ├── deaeom4_p_loops.f90 │ │ ├── eaccp3_correction.f90 │ │ ├── eaccp3_loops.f90 │ │ ├── eaeom3_p_intermediates.f90 │ │ ├── eaeom3_p_loops.f90 │ │ ├── ecccp3_loops.f90 │ │ ├── eomcc_active_loops.f90 │ │ ├── eomccp3_adaptive_loops.f90 │ │ ├── eomccsdt_p_loops.f90 │ │ ├── hbar_cc3.f90 │ │ ├── hbar_ccsdt_p.f90 │ │ ├── ipccp3_loops.f90 │ │ ├── ipeom3_p_intermediates.f90 │ │ ├── ipeom3_p_loops.f90 │ │ ├── ipeomt_p_loops.f90 │ │ ├── leftccsdt_p_intermediates.f90 │ │ ├── leftccsdt_p_loops.f90 │ │ ├── lefteaeom3_p_intermediates.f90 │ │ ├── lefteaeom3_p_loops.f90 │ │ ├── leftipeom3_p_intermediates.f90 │ │ ├── leftipeom3_p_loops.f90 │ │ ├── mbgf_loops.f90 │ │ ├── mbpt_loops.f90 │ │ ├── mrcc_loops.f90 │ │ ├── object_information │ │ ├── reorder.f90 │ │ ├── updates.pyf │ │ └── vvvv_contraction.f90 │ ├── meson.build │ └── sort │ │ ├── qsort.c │ │ ├── qsort_module.f90 │ │ └── test.f90 ├── lrcc │ ├── __init__.py │ ├── lrccsd.py │ ├── lrccsd_intermediates.py │ └── meson.build ├── mbpt │ ├── __init__.py │ ├── mbgf.py │ ├── mbpt.py │ └── meson.build ├── meson.build ├── models │ ├── __init__.py │ ├── hilbert.py │ ├── integrals.py │ ├── meson.build │ ├── operators.py │ └── system.py ├── moments │ ├── __init__.py │ ├── ccp3.py │ ├── ccp3_bak.py │ ├── ccp3_chol.py │ ├── ccp4.py │ ├── cct3.py │ ├── cct3_chol.py │ ├── crcc23.py │ ├── crcc23_chol.py │ ├── crcc24-old.py │ ├── crcc24.py │ ├── crcc34.py │ ├── creacc23.py │ ├── creomcc23.py │ ├── creomcc23_chol.py │ ├── cripcc23.py │ ├── dipeomccsdta_star.py │ ├── eaccp3.py │ ├── eaeomccsdta_star.py │ ├── eccc23.py │ ├── eomccsdta_star.py │ ├── ipccp3.py │ ├── ipeomccsdta_star.py │ └── meson.build ├── mrcc │ ├── __init__.py │ ├── effective_hamiltonian.py │ ├── meson.build │ ├── mkmrccsd.py │ └── normal_order.py └── utilities │ ├── __init__.py │ ├── active_space.py │ ├── determinants.py │ ├── dumping.py │ ├── meson.build │ ├── permutations.py │ ├── printing.py │ ├── pspace.py │ ├── qspace.py │ ├── selection.py │ ├── symmetry.py │ └── utilities.py ├── devtools ├── README.md ├── ciwheels │ └── cibw_before_build_linux.sh ├── conda-envs │ └── test_env.yaml ├── f2cmap.py ├── f2py_script.sh ├── legacy-miniconda-setup │ └── before_install.sh ├── order_fortran_dependencies.py └── scripts │ └── create_conda_env.py ├── docs ├── Makefile ├── README.md ├── _static │ └── README.md ├── _templates │ └── README.md ├── cc_calculations.rst ├── ccpq_calculations.rst ├── computational_options.rst ├── conf.py ├── contact_information.rst ├── eccc_calculations.rst ├── getting_started.rst ├── index.rst ├── installation.rst ├── make.bat ├── references.rst ├── requirements.yaml └── walkthrough.rst ├── env.sh ├── environment.yml ├── meson.build ├── meson_options.txt ├── mkdocs.yml ├── pyproject.toml ├── readthedocs.yml ├── requirements-dev.txt ├── tests ├── allyl │ ├── test_eaeom3_allyl.py │ └── test_eaeomt3_allyl.py ├── c2 │ └── test_eaeomccsdt_c2.py ├── ch │ ├── test_ccsdt_ch.py │ ├── test_cct3_ch.py │ ├── test_eomccsd_ch.py │ ├── test_eomccsdt1_ch.py │ ├── test_eomccsdt_ch.py │ ├── test_eomcct3_ch.py │ └── test_eomcct3_ch_fcidump.py ├── ch2 │ ├── test_adaptive_ch2.py │ ├── test_cc2_ch2.py │ ├── test_cc3_ch2.py │ ├── test_deaeom4_ch2.py │ ├── test_deaeom4_p_ch2.py │ ├── test_dipeom4_ch2.py │ ├── test_dipeom4star_ch2.py │ ├── test_dipeomccsdt_ch2.py │ ├── test_sfeomcc23_ch2.py │ └── test_sfeomccsd_ch2.py ├── chplus │ ├── test_adaptiveSS_chplus.py │ ├── test_adaptive_chplus.py │ ├── test_cc3_chplus.py │ ├── test_creacc23_chplus.py │ ├── test_creom23_chplus.py │ ├── test_creom23_chplus_dav.py │ ├── test_creom23_chplus_sym.py │ ├── test_eaeom2_chplus.py │ ├── test_eaeom3_chplus.py │ ├── test_eaeomccsdtastar_chplus.py │ ├── test_eaeomt3_chplus.py │ ├── test_eomccsd_chplus.py │ ├── test_eomccsdt1_chplus.py │ ├── test_eomccsdt_chplus.py │ ├── test_eomccsdtastar_chplus.py │ ├── test_eomcct3_chplus.py │ ├── test_eomcct3_full_chplus.py │ ├── test_lefteaeom2_act_chplus.py │ ├── test_lefteaeom2_chplus.py │ ├── test_lefteaeom3_chplus.py │ ├── test_lefteaeom3a_chplus.py │ ├── test_lefteomccsdt_chplus.py │ └── test_lefteomccsdt_chplus_dav.py ├── cl2 │ ├── test_dipeom3_cl2.py │ ├── test_dipeom4_cl2.py │ ├── test_dipeom4star_cl2.py │ ├── test_dipeomccsdt_cl2.py │ └── test_dipeomccsdta_cl2.py ├── co │ ├── test_ipeomccsdt_co.py │ └── test_ipeomccsdt_p_co.py ├── data │ ├── ch │ │ ├── ch.FCIDUMP │ │ └── ch.log │ ├── ch2 │ │ ├── ch2-avdz-koch.FCIDUMP │ │ └── ch2-avdz-koch.log │ ├── chplus │ │ ├── chplus.FCIDUMP │ │ ├── chplus.log │ │ └── olsen.gbs │ ├── h2o │ │ ├── civecs-10k.dat │ │ ├── h2o-Re.log │ │ ├── h2o-tz-3.6.FCIDUMP │ │ ├── h2o-tz-3.6.log │ │ ├── onebody.inp │ │ ├── paldusTZ.gbs │ │ └── twobody.inp │ ├── hfhminus-triplet │ │ ├── hfhminus-triplet.FCIDUMP │ │ └── hfhminus-triplet.log │ └── n2 │ │ └── ano0.gbs ├── f2 │ ├── test_adaptive_chol_f2.py │ ├── test_adaptive_f2.py │ ├── test_cc3_f2.py │ ├── test_ccsd_chol_f2.py │ ├── test_ccsdt_f2.py │ ├── test_ccsdt_uhf_f2.py │ ├── test_cct3_p_chol_f2.py │ ├── test_cct3_p_f2.py │ ├── test_cct3full_p_f2.py │ ├── test_crcc23_chol_f2.py │ ├── test_crcc23_chol_triplet_f2.py │ ├── test_crcc23_f2.py │ ├── test_crcc23_triplet_f2.py │ ├── test_crcc23_uhf_f2.py │ ├── test_crcc24_f2.py │ ├── test_crcc34_f2.py │ ├── test_deaeom3_f2.py │ └── test_dipeom4_f2.py ├── glycine │ └── test_crcc23_glycine.py ├── h10 │ └── test_accsd_h10.py ├── h2o │ ├── test_cc3_h2o.py │ ├── test_cc4_h2o.py │ ├── test_ccsdt_h2o.py │ ├── test_ccsdtq_h2o.py │ ├── test_ccsdtq_uhf_h2o.py │ ├── test_cipsi-ccpq_h2o.py │ ├── test_crcc24_h2o.py │ ├── test_crcc34_h2o.py │ ├── test_creom23_chol_h2o.py │ ├── test_creom23_h2o.py │ ├── test_deaeom3_h2o.py │ ├── test_eccc23_h2o.py │ ├── test_eomcct3_h2o.py │ ├── test_extrapolation_h2o.py │ └── test_mpn_h2o.py ├── h4 │ ├── test_cc4_h4.py │ ├── test_ccsdt_h4.py │ └── test_ccsdtq_h4.py ├── h6 │ ├── test_acc23_h6.py │ └── test_acct3_h6.py ├── hf │ ├── test_cc3_hf.py │ └── test_lrccsd_hf.py ├── hfhminus │ ├── test_cc3_hfhminus.py │ ├── test_cct3_hfhminus.py │ ├── test_cct3full_hfhminus.py │ └── test_cct3full_hfhminus_fcidump.py ├── n2 │ ├── test_ipeomccsdt_n2.py │ └── test_ipeomccsdta_n2.py └── ohminus │ ├── test_cripcc23_ohminus.py │ ├── test_ipeom2_ohminus.py │ ├── test_ipeom3_ohminus.py │ ├── test_ipeom3a_ohminus.py │ ├── test_ipeomccsdtastar_ohminus.py │ └── test_ipeomt3a_ohminus.py └── versioneer.py /.codecov.yml: -------------------------------------------------------------------------------- 1 | # Codecov configuration to make it a bit less noisy 2 | coverage: 3 | status: 4 | patch: false 5 | project: 6 | default: 7 | threshold: 50% 8 | 9 | comment: 10 | layout: "header" 11 | require_changes: false 12 | branches: null 13 | behavior: default 14 | flags: null 15 | paths: null -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.py] 11 | indent_size = 4 12 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We welcome contributions from external contributors, and this document 4 | describes how to merge code changes into this mob_ml. 5 | 6 | ## Getting Started 7 | 8 | * Make sure you have a [GitHub account](https://github.com/signup/free). 9 | * [Fork](https://help.github.com/articles/fork-a-repo/) this repository on GitHub. 10 | * On your local machine, 11 | [clone](https://help.github.com/articles/cloning-a-repository/) your fork of 12 | the repository. 13 | 14 | ## Making Changes 15 | 16 | * Add some really awesome code to your local fork. It's usually a [good 17 | idea](http://blog.jasonmeridth.com/posts/do-not-issue-pull-requests-from-your-master-branch/) 18 | to make changes on a 19 | [branch](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/) 20 | with the branch name relating to the feature you are going to add. 21 | * When you are ready for others to examine and comment on your new feature, 22 | navigate to your fork of mob_ml on GitHub and open a [pull 23 | request](https://help.github.com/articles/using-pull-requests/) (PR). Note that 24 | after you launch a PR from one of your fork's branches, all 25 | subsequent commits to that branch will be added to the open pull request 26 | automatically. Each commit added to the PR will be validated for 27 | mergability, compilation and test suite compliance; the results of these tests 28 | will be visible on the PR page. 29 | * If you're providing a new feature, you must add test cases and documentation. 30 | * When the code is ready to go, make sure you run the test suite using pytest. 31 | * When you're ready to be considered for merging, check the "Ready to go" 32 | box on the PR page to let the mob_ml devs know that the changes are complete. 33 | The code will not be merged until this box is checked, the continuous 34 | integration returns checkmarks, 35 | and multiple core developers give "Approved" reviews. 36 | 37 | # Additional Resources 38 | 39 | * [General GitHub documentation](https://help.github.com/) 40 | * [PR best practices](http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github/) 41 | * [A guide to contributing to software packages](http://www.contribution-guide.org) 42 | * [Thinkful PR example](http://www.thinkful.com/learn/github-pull-request-tutorial/#Time-to-Submit-Your-First-PR) 43 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report 4 | label: Bug 5 | --- 6 | 7 | **Describe the bug** 8 | 9 | 10 | **To Reproduce** 11 | 14 | 15 | **Expected behavior** 16 | 17 | 18 | **Additional context** 19 | 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | label: Feature 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | 9 | 10 | **Describe the solution you'd like** 11 | 12 | 13 | **Describe alternatives you've considered** 14 | 15 | 16 | **Additional context** 17 | 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Changelog description 7 | 8 | 9 | ## Status 10 | 11 | - [ ] Ready to go 12 | -------------------------------------------------------------------------------- /.github/workflows/documentation.yml: -------------------------------------------------------------------------------- 1 | name: documentation 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | permissions: 6 | contents: write 7 | 8 | jobs: 9 | docs: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: actions/setup-python@v5 14 | with: 15 | python-version: '3.11' 16 | 17 | - name: Install dependencies 18 | run: | 19 | pip install sphinx sphinx_rtd_theme myst_parser 20 | 21 | - name: Sphinx build 22 | run: | 23 | sphinx-build docs _build 24 | 25 | - name: Deploy to GitHub Pages 26 | uses: peaceiris/actions-gh-pages@v3 27 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} 28 | with: 29 | publish_branch: gh-pages 30 | github_token: ${{ secrets.GITHUB_TOKEN }} 31 | publish_dir: _build/ 32 | force_orphan: true 33 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: 6 | # Note: editing the prerelease then marking as release does not trigger 7 | # this pipeline 8 | # - prereleased 9 | - released 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build_wheels: 14 | name: Build wheels on ${{ matrix.os }} 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | # macos-13 is an intel runner, macos-14 is apple silicon 19 | #os: [ubuntu-latest, windows-latest, macos-13, macos-14] 20 | os: [ubuntu-latest] 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Install dependencies 26 | run: | 27 | python -m pip install --upgrade pip 28 | pip install twine 29 | 30 | - name: Build wheels 31 | uses: pypa/cibuildwheel@v2.21.3 32 | # env: 33 | # CIBW_SOME_OPTION: value 34 | # ... 35 | # with: 36 | # package-dir: . 37 | # output-dir: wheelhouse 38 | # config-file: "{package}/pyproject.toml" 39 | 40 | - name: Publish PyPI 41 | env: 42 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 43 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 44 | run: | 45 | ls -lh wheelhouse 46 | twine upload wheelhouse/* 47 | 48 | 49 | - uses: actions/upload-artifact@v4 50 | with: 51 | name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} 52 | path: ./wheelhouse/*.whl -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build-and-test: 11 | 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | python-version: ["3.10", "3.11", "3.12", "3.13"] 16 | 17 | steps: 18 | - uses: actions/cache@v3 19 | with: 20 | path: ~/.cache/pip 21 | key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }} 22 | restore-keys: | 23 | ${{ runner.os }}-pip- 24 | 25 | - uses: actions/checkout@v3 26 | 27 | - name: Set up Python ${{ matrix.python-version }} 28 | uses: actions/setup-python@v4 29 | with: 30 | python-version: ${{ matrix.python-version }} 31 | 32 | - name: Install fortran 33 | run: | 34 | sudo apt install -y gfortran meson libopenblas-dev 35 | 36 | - name: Install python dependencies 37 | run: | 38 | python -m pip install --upgrade pip 39 | pip install -r requirements-dev.txt 40 | 41 | - name: Install ccpy 42 | run: | 43 | python -m pip install --verbose --no-build-isolation --editable . 44 | 45 | - name: Short test 46 | run: | 47 | pytest tests -v -m short 48 | if: github.event_name == 'pull_request' 49 | 50 | - name: Full test 51 | run: | 52 | pytest tests -v 53 | if: github.event_name != 'pull_request' 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | wheelhouse/ 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | .pytest_cache 45 | nosetests.xml 46 | coverage.xml 47 | *.cover 48 | .hypothesis/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | 103 | # profraw files from LLVM? Unclear exactly what triggers this 104 | # There are reports this comes from LLVM profiling, but also Xcode 9. 105 | *profraw 106 | 107 | # pycharm 108 | .idea 109 | 110 | # numpy save files 111 | .npy 112 | .npz 113 | 114 | .vscode/ 115 | .nfs* 116 | 117 | 118 | # Fortran 119 | *.mod 120 | *.o 121 | *.a 122 | -------------------------------------------------------------------------------- /.lgtm.yml: -------------------------------------------------------------------------------- 1 | # Configure LGTM for this package 2 | 3 | extraction: 4 | python: # Configure Python 5 | python_setup: # Configure the setup 6 | version: 3 # Specify Version 3 7 | path_classifiers: 8 | library: 9 | - versioneer.py # Set Versioneer.py to an external "library" (3rd party code) 10 | - devtools/* 11 | generated: 12 | - ccpy/_version.py 13 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | default_stages: [commit, push] 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v2.3.0 5 | hooks: 6 | - id: check-yaml 7 | - id: end-of-file-fixer 8 | - id: trailing-whitespace 9 | exclude: ^ccpy/utilities/updates/.*f90$ 10 | - repo: https://github.com/psf/black 11 | rev: 22.10.0 12 | hooks: 13 | - id: black 14 | - repo: local 15 | hooks: 16 | - id: fprettify 17 | name: Format fortran files 18 | language: system 19 | entry: fprettify 20 | args: 21 | - --whitespace-comma 22 | - --enable-decl 23 | - --whitespace-type 24 | - 'no' 25 | - --enable-replacements 26 | - --line-length 27 | - '140' 28 | - --whitespace 29 | - '4' 30 | types: [file] 31 | files: ^ccpy/utilities/updates/.*f90$ 32 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | pip install --no-build-isolation --verbose --editable . 2 | -------------------------------------------------------------------------------- /ccpy/__init__.py: -------------------------------------------------------------------------------- 1 | """A Python framework for coupled-cluster computations of molecular systems""" 2 | 3 | # Import the specific modules that form the CCpy API here 4 | #from . import * 5 | from ccpy.drivers.driver import Driver 6 | from ccpy.drivers.adaptive import AdaptDriver, AdaptEOMDriver, AdaptEOMDriverSS 7 | from ccpy.utilities.pspace import (get_active_triples_pspace, 8 | get_active_3h2p_pspace, 9 | get_active_3p2h_pspace, 10 | get_active_4p2h_pspace, 11 | get_pspace_from_qmc, 12 | get_triples_pspace_from_cipsi, 13 | get_quadruples_pspace_from_cipsi, 14 | ) 15 | 16 | # Handle versioneer 17 | from ._version import get_versions 18 | 19 | versions = get_versions() 20 | __version__ = versions["version"] 21 | __git_revision__ = versions["full-revisionid"] 22 | del get_versions, versions 23 | -------------------------------------------------------------------------------- /ccpy/cc/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["cc2", "ccd", "ccsd", "ccsd_chol", 2 | "accd", "accsd", "cc3", "ccsdt", "ccsdt_chol", "cc4-old", "cc4", "ccsdtq", "ccsdt_p", 3 | "ccsdt_p_chol", "accsdt_p", "eccc2"] 4 | MODULES = [module for module in __all__] 5 | -------------------------------------------------------------------------------- /ccpy/cc/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'accd.py', 4 | 'accsd.py', 5 | 'accsdt_p.py', 6 | 'cc2.py', 7 | 'cc3.py', 8 | 'cc4.py', 9 | 'ccd.py', 10 | 'ccsd_chol.py', 11 | 'ccsd.py', 12 | 'ccsdt_p_chol.py', 13 | 'ccsdt_p.py', 14 | 'ccsdt.py', 15 | 'ccsdtq.py', 16 | 'eccc2.py', 17 | ] 18 | 19 | py3.install_sources( 20 | python_sources, 21 | subdir: 'ccpy/cc' 22 | ) 23 | -------------------------------------------------------------------------------- /ccpy/cholesky/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/cholesky/__init__.py -------------------------------------------------------------------------------- /ccpy/cholesky/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'cholesky_builders.py', 4 | 'cholesky.py', 5 | ] 6 | 7 | py3.install_sources( 8 | python_sources, 9 | subdir: 'ccpy/cholesky' 10 | ) 11 | 12 | 13 | -------------------------------------------------------------------------------- /ccpy/constants/__init__.py: -------------------------------------------------------------------------------- 1 | from .constants import * 2 | -------------------------------------------------------------------------------- /ccpy/constants/constants.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | eVtohartree = 0.036749308136649 4 | hartreetoeV = 1.0/(eVtohartree) 5 | 6 | class LengthUnit(Enum): 7 | BOHR = 1 8 | ANGSTROM = 2 9 | 10 | class Symmetry(Enum): 11 | C1 = 1 12 | C2V = 2 13 | D2H = 3 14 | 15 | 16 | -------------------------------------------------------------------------------- /ccpy/constants/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'constants.py' 4 | ] 5 | 6 | py3.install_sources( 7 | python_sources, 8 | subdir: 'ccpy/constants' 9 | ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /ccpy/density/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/density/__init__.py -------------------------------------------------------------------------------- /ccpy/density/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | 'natural_orbitals.py', 3 | '__init__.py', 4 | 'rdm1.py' 5 | ] 6 | 7 | py3.install_sources( 8 | python_sources, 9 | subdir: 'ccpy/density' 10 | ) 11 | 12 | 13 | -------------------------------------------------------------------------------- /ccpy/drivers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/drivers/__init__.py -------------------------------------------------------------------------------- /ccpy/drivers/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'solvers.py', 4 | 'adaptive.py', 5 | 'driver.py', 6 | 'diis.py' 7 | ] 8 | 9 | py3.install_sources( 10 | python_sources, 11 | subdir: 'ccpy/drivers' 12 | ) -------------------------------------------------------------------------------- /ccpy/energy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/energy/__init__.py -------------------------------------------------------------------------------- /ccpy/energy/lrcc_energy.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def get_lrcc_energy(T1, W, T, H): 4 | """Calculate the CC correlation energy <0|(H_N e^T)_C|0>.""" 5 | w1a = np.einsum("me,em->", W.a.ov, T.a, optimize=True) 6 | w1b = np.einsum("me,em->", W.b.ov, T.b, optimize=True) 7 | e1a = np.einsum("me,em->", H.a.ov, T1.a, optimize=True) 8 | e1b = np.einsum("me,em->", H.b.ov, T1.b, optimize=True) 9 | e2aa = 0.25 * np.einsum("mnef,efmn->", H.aa.oovv, T1.aa, optimize=True) 10 | e2ab = np.einsum("mnef,efmn->", H.ab.oovv, T1.ab, optimize=True) 11 | e2bb = 0.25 * np.einsum("mnef,efmn->", H.bb.oovv, T1.bb, optimize=True) 12 | Ecorr = w1a + w1b + e1a + e1b + e2aa + e2ab + e2bb 13 | return Ecorr -------------------------------------------------------------------------------- /ccpy/energy/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'hf_energy.py', 4 | 'cc_energy.py', 5 | 'lrcc_energy.py', 6 | ] 7 | 8 | py3.install_sources( 9 | python_sources, 10 | subdir: 'ccpy/energy' 11 | ) 12 | 13 | 14 | -------------------------------------------------------------------------------- /ccpy/eom_guess/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["cis", "cisd", "cisd_chol", "cisd_matrix", "sfcis", "deacis", "dipcis", "ipcis", "ipcisd", "eacis", "eacisd"] 2 | 3 | MODULES = [module for module in __all__] 4 | -------------------------------------------------------------------------------- /ccpy/eom_guess/eacis.py: -------------------------------------------------------------------------------- 1 | ''' 2 | EA-EOMCCSD(1p) Guess Routine for EA-EOMCC 3 | ''' 4 | 5 | import numpy as np 6 | from ccpy.eom_guess.s2matrix import build_s2matrix_1p, spin_adapt_guess 7 | 8 | def run_diagonalization(system, H, multiplicity, roots_per_irrep, nacto, nactu, debug=False, use_symmetry=False): 9 | 10 | nroot = 0 11 | for irrep, nroot_irrep in roots_per_irrep.items(): 12 | nroot += nroot_irrep 13 | 14 | Hmat = build_1p_hamiltonian(H, system) 15 | S2mat = build_s2matrix_1p(system) 16 | omega, V = spin_adapt_guess(S2mat, Hmat, multiplicity, debug=debug) 17 | return omega[:nroot], V[:, :nroot] 18 | 19 | def build_1p_hamiltonian(H, system): 20 | 21 | nua = system.nunoccupied_alpha 22 | Hmat = np.zeros((nua, nua)) 23 | for a in range(nua): 24 | for b in range(nua): 25 | Hmat[a, b] = H.a.vv[a, b] 26 | return Hmat -------------------------------------------------------------------------------- /ccpy/eom_guess/ipcis.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IP-EOMCCSD(1h) Guess Routine for IP-EOMCC 3 | ''' 4 | 5 | import numpy as np 6 | from ccpy.eom_guess.s2matrix import build_s2matrix_1h, spin_adapt_guess 7 | 8 | def run_diagonalization(system, H, multiplicity, roots_per_irrep, nacto, nactu, debug=False, use_symmetry=False): 9 | 10 | nroot = 0 11 | for irrep, nroot_irrep in roots_per_irrep.items(): 12 | nroot += nroot_irrep 13 | 14 | Hmat = build_1h_hamiltonian(H, system) 15 | S2mat = build_s2matrix_1h(system) 16 | omega, V = spin_adapt_guess(S2mat, Hmat, multiplicity, debug=debug) 17 | return omega[:nroot], V[:, :nroot] 18 | 19 | def build_1h_hamiltonian(H, system): 20 | 21 | noa = system.noccupied_alpha 22 | Hmat = np.zeros((noa, noa)) 23 | for i in range(noa): 24 | for j in range(noa): 25 | Hmat[i, j] = -H.a.oo[j, i] 26 | return Hmat 27 | 28 | -------------------------------------------------------------------------------- /ccpy/eom_guess/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'ipcisd.py', 4 | 'ipcis.py', 5 | 'cis.py', 6 | 'cisd_chol.py', 7 | 'dipcis.py', 8 | 'eacis.py', 9 | 'deacis.py', 10 | 'eacisd.py', 11 | 'cisd.py', 12 | 's2matrix.py', 13 | 'sfcis.py' 14 | ] 15 | 16 | py3.install_sources( 17 | python_sources, 18 | subdir: 'ccpy/eom_guess' 19 | ) 20 | 21 | 22 | -------------------------------------------------------------------------------- /ccpy/eom_guess/sfcis.py: -------------------------------------------------------------------------------- 1 | ''' 2 | SF-CIS Guess Routine for SF-EOMCC 3 | ''' 4 | 5 | import numpy as np 6 | from ccpy.eom_guess.s2matrix import build_s2matrix_sfcis, spin_adapt_guess 7 | 8 | def run_diagonalization(system, H, multiplicity, roots_per_irrep, nacto, nactu, debug=False, use_symmetry=False): 9 | 10 | nroot = 0 11 | for irrep, nroot_irrep in roots_per_irrep.items(): 12 | nroot += nroot_irrep 13 | 14 | Hmat = build_sfcis_hamiltonian(H, system) 15 | S2mat = build_s2matrix_sfcis(system, Ms=-1) 16 | omega, V = spin_adapt_guess(S2mat, Hmat, multiplicity) 17 | return omega[:nroot], V[:, :nroot] 18 | 19 | def build_sfcis_hamiltonian(H, system): 20 | 21 | n1b = system.noccupied_alpha * system.nunoccupied_beta 22 | 23 | Hbb = np.zeros((n1b, n1b)) 24 | ct1 = 0 25 | for a in range(system.nunoccupied_beta): 26 | for i in range(system.noccupied_alpha): 27 | ct2 = 0 28 | for b in range(system.nunoccupied_beta): 29 | for j in range(system.noccupied_alpha): 30 | Hbb[ct1, ct2] = ( 31 | H.b.vv[a, b] * (i == j) 32 | - H.a.oo[j, i] * (a == b) 33 | - H.ab.ovov[j, a, i, b] 34 | ) 35 | ct2 += 1 36 | ct1 += 1 37 | 38 | return Hbb 39 | -------------------------------------------------------------------------------- /ccpy/eomcc/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ["eomcc2", "eomccsd", "eomccsd_chol", "eomcc3", "eomccsdt", "eomccsdt_p", 3 | "ipeom2", "ipeom3", "ipeom3_p", "ipeomccsdta", "ipeomccsdt_p", "ipeomccsdt", 4 | "eaeom2", "eaeom3", "eaeom3_p", "eaeomccsdt", 5 | "sfeomccsd", "sfeomcc23", "deaeom2", "deaeom3", "deaeom4", "deaeom4_p", 6 | "dipeom3", "dipeom4", "dipeomccsdt", 7 | "dipeomccsdta", 'teaeom2'] 8 | 9 | MODULES = [module for module in __all__] 10 | -------------------------------------------------------------------------------- /ccpy/eomcc/deaeom2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Double Electron Attachment Equation-of-Motion Coupled-Cluster 3 | Method with 2p Excitations on top of CCSD [DEA-EOMCCSD(2p)] 4 | ''' 5 | 6 | import numpy as np 7 | from ccpy.lib.core import cc_loops2 8 | 9 | def update(R, omega, H, RHF_symmetry, system): 10 | R.ab = cc_loops2.update_r_2p( 11 | R.ab, 12 | omega, 13 | H.a.vv, 14 | H.b.vv, 15 | 0.0, 16 | ) 17 | return R 18 | 19 | def HR(dR, R, T, H, flag_RHF, system): 20 | 21 | # update R2 22 | dR.ab = build_HR_2B(R, T, H) 23 | return dR.flatten() 24 | 25 | def build_HR_2B(R, T, H): 26 | x2b = np.einsum("ae,eb->ab", H.a.vv, R.ab, optimize=True) 27 | x2b += np.einsum("be,ae->ab", H.b.vv, R.ab, optimize=True) 28 | x2b += np.einsum("abef,ef->ab", H.ab.vvvv, R.ab, optimize=True) 29 | return x2b 30 | 31 | -------------------------------------------------------------------------------- /ccpy/eomcc/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'deaeom2.py', 4 | 'deaeom3.py', 5 | 'deaeom4.py', 6 | 'deaeom4_p.py', 7 | 'deaeom4_intermediates.py', 8 | 'dipeom3.py', 9 | 'dipeom4.py', 10 | 'dipeom4_intermediates.py', 11 | 'dipeomccsdt.py', 12 | 'dipeomccsdta.py', 13 | 'eaeom2.py', 14 | 'eaeom3.py', 15 | 'eaeom3_intermediates.py', 16 | 'eaeom3_p.py', 17 | 'eaeomccsdt.py', 18 | 'eomcc2.py', 19 | 'eomcc3.py', 20 | 'eomcc3_intermediates.py', 21 | 'eomccsd.py', 22 | 'eomccsd_chol.py', 23 | 'eomccsd_intermediates.py', 24 | 'eomccsdt.py', 25 | 'eomccsdt_intermediates.py', 26 | 'eomccsdt_p.py', 27 | 'ipeom2.py', 28 | 'ipeom3.py', 29 | 'ipeom3_intermediates.py', 30 | 'ipeom3_p.py', 31 | 'ipeomccsdt_p.py', 32 | 'ipeomccsdt.py', 33 | 'ipeomccsdta.py', 34 | 'sfeomcc23.py', 35 | 'sfeomcc23_intermediates.py', 36 | 'sfeomccsd.py', 37 | 'teaeom2.py', 38 | ] 39 | 40 | py3.install_sources( 41 | python_sources, 42 | subdir: 'ccpy/eomcc' 43 | ) 44 | -------------------------------------------------------------------------------- /ccpy/eomcc/teaeom2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Triple Electron Attachment Equation-of-Motion Coupled-Cluster 3 | Method with 3p Excitations on top of CCSD [TEA-EOMCCSD(3p)] 4 | ''' 5 | 6 | import numpy as np 7 | from ccpy.lib.core import cc_loops2 8 | 9 | def update(R, omega, H, RHF_symmetry, system): 10 | R.aab = cc_loops2.update_r_3p( 11 | R.aab, 12 | omega, 13 | H.a.vv, 14 | H.b.vv, 15 | 0.0, 16 | ) 17 | return R 18 | 19 | def HR(dR, R, T, H, flag_RHF, system): 20 | 21 | # update R2 22 | dR.aab = build_HR_3B(R, T, H) 23 | return dR.flatten() 24 | 25 | def build_HR_3B(R, T, H): 26 | x3b = np.einsum("ae,ebc->abc", H.a.vv, R.aab, optimize=True) 27 | x3b += 0.5 * np.einsum("ce,abe->abc", H.b.vv, R.aab, optimize=True) 28 | x3b += 0.25 * np.einsum("abef,efc->abc", H.aa.vvvv, R.aab, optimize=True) 29 | x3b += np.einsum("bcef,aef->abc", H.ab.vvvv, R.aab, optimize=True) 30 | # antisymmetrize A(ab) 31 | x3b -= np.transpose(x3b, (1, 0, 2)) 32 | return x3b 33 | 34 | -------------------------------------------------------------------------------- /ccpy/extcorr/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/extcorr/__init__.py -------------------------------------------------------------------------------- /ccpy/extcorr/contractions_t3.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def contract_vt3_singles(H, T_ext, system): 5 | 6 | x1a = np.zeros((system.nunoccupied_alpha, system.noccupied_alpha)) 7 | x1b = np.zeros((system.nunoccupied_beta, system.noccupied_beta)) 8 | 9 | x1a = 0.25 * np.einsum("mnef,aefimn->ai", H.aa.oovv, T_ext.aaa, optimize=True) 10 | x1a += np.einsum("mnef,aefimn->ai", H.ab.oovv, T_ext.aab, optimize=True) 11 | x1a += 0.25 * np.einsum("mnef,aefimn->ai", H.bb.oovv, T_ext.abb, optimize=True) 12 | 13 | x1b = 0.25 * np.einsum("mnef,aefimn->ai", H.bb.oovv, T_ext.bbb, optimize=True) 14 | x1b += 0.25 * np.einsum("mnef,efamni->ai", H.aa.oovv, T_ext.aab, optimize=True) 15 | x1b += np.einsum("mnef,efamni->ai", H.ab.oovv, T_ext.abb, optimize=True) 16 | 17 | return x1a, x1b 18 | 19 | 20 | -------------------------------------------------------------------------------- /ccpy/extcorr/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'ecccp3.py', 4 | 'contractions_t3.py', 5 | 'contractions_t4.py', 6 | 'external_correction.py' 7 | ] 8 | 9 | py3.install_sources( 10 | python_sources, 11 | subdir: 'ccpy/extcorr' 12 | ) 13 | 14 | 15 | -------------------------------------------------------------------------------- /ccpy/extrapolation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/extrapolation/__init__.py -------------------------------------------------------------------------------- /ccpy/extrapolation/goodson_extrapolation.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def goodson_extrapolation(e_ref, e_ccsd, e_ccsdt, approximant): 4 | delta1 = e_ref 5 | delta2 = e_ccsd - e_ref 6 | delta3 = e_ccsdt - e_ccsd 7 | 8 | if approximant == "ccq": 9 | return quadratic_pade_approximant(delta1, delta2, delta3) 10 | elif approximant == "ccr": 11 | return rational_pade_approximant(delta1, delta2, delta3) 12 | elif approximant == "cccf": 13 | return continued_fraction_approximant(delta1, delta2, delta3) 14 | else: 15 | return 0.0 16 | 17 | def quadratic_pade_approximant(delta1, delta2, delta3): 18 | 19 | extrap_ccq = ( 20 | delta1 21 | + 0.5 * delta2**2/delta3 * (1.0 - math.sqrt(1.0 - 4 * delta3/delta2)) 22 | ) 23 | return extrap_ccq 24 | 25 | def rational_pade_approximant(delta1, delta2, delta3): 26 | 27 | extrap_ccr = ( 28 | delta1 * (1.0 + delta2/delta1 - delta3/delta2)/(1 - delta3/delta2) 29 | ) 30 | return extrap_ccr 31 | 32 | def continued_fraction_approximant(delta1, delta2, delta3): 33 | 34 | extrap_cccf = ( 35 | delta1/(1.0 - delta2/delta1/(1.0 - delta3/delta2)) 36 | ) 37 | return extrap_cccf 38 | -------------------------------------------------------------------------------- /ccpy/extrapolation/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'goodson_extrapolation.py' 4 | ] 5 | 6 | py3.install_sources( 7 | python_sources, 8 | subdir: 'ccpy/extrapolation' 9 | ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /ccpy/hbar/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ["hbar_ccs", "hbar_cc2", "hbar_ccsd", "hbar_ccsd_chol", "hbar_cc3", "hbar_ccsdta", "hbar_ccsdt", "hbar_ccsdt1", "hbar_ccsdt_p"] 3 | MODULES = [module for module in __all__] 4 | -------------------------------------------------------------------------------- /ccpy/hbar/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'hbar_ccs.py', 4 | 'hbar_ccsd.py', 5 | 'hbar_ccsd_chol.py', 6 | 'hbar_ccsdt.py', 7 | 'hbar_ccsdt1.py', 8 | 'hbar_ccsdta.py', 9 | 'hbar_ccsdt_p.py', 10 | 'hbar_cc3.py', 11 | 'hbar_cc4.py', 12 | 'diagonal.py', 13 | ] 14 | 15 | py3.install_sources( 16 | python_sources, 17 | subdir: 'ccpy/hbar' 18 | ) 19 | 20 | 21 | -------------------------------------------------------------------------------- /ccpy/interfaces/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/interfaces/__init__.py -------------------------------------------------------------------------------- /ccpy/interfaces/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'fcidump_tools.py', 4 | 'qp2_tools.py', 5 | 'gamess_tools.py', 6 | 'pyscf_tools.py', 7 | ] 8 | 9 | py3.install_sources( 10 | python_sources, 11 | subdir: 'ccpy/interfaces' 12 | ) 13 | 14 | 15 | -------------------------------------------------------------------------------- /ccpy/interfaces/qp2_tools.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from ccpy.utilities.permutations import calculate_permutation_parity 3 | 4 | def hex2bin(hex_string): 5 | bin_string = bin(int(hex_string, 16))[2:] 6 | return bin_string 7 | 8 | def process_cipsi_vectors(inFile, system): 9 | 10 | nlines_det_print = 5 # Each determinant in the QP2 output is printed in 5 lines, starting with the flag "Determinant" 11 | offset = nlines_det_print - 1 # Useful offset to jump from the Determinant line to the CI coefficient 12 | 13 | outFile = open(inFile + "_proc", "w") 14 | with open(inFile) as f: 15 | ndet = 0 16 | lines = f.readlines() 17 | for j in range(len(lines) - offset): 18 | line = lines[j] 19 | 20 | if "Determinant" in line.split(): 21 | 22 | ndet += 1 23 | 24 | alpha = hex2bin(lines[j + 1].split("|")[0])[::-1] 25 | beta = hex2bin(lines[j + 1].split("|")[1])[::-1] 26 | coef = float(lines[j + offset].split()[0]) 27 | 28 | occ_alpha = [2 * i + 1 for i in range(len(alpha)) if alpha[i] == "1"] 29 | occ_beta = [2 * i + 2 for i in range(len(beta)) if beta[i] == "1"] 30 | det_occ = occ_alpha + occ_beta # determinant in aaa...|bbb... ordering 31 | permutation = list(np.argsort(det_occ)) # permutation to print into ababa... ordering 32 | det_occ = [det_occ[i] for i in permutation] 33 | sign = calculate_permutation_parity(permutation) # compute sign of permutation from aabb -> abab 34 | coef *= sign 35 | 36 | det_occ_correlated = [det_occ[i + 2 * system.nfrozen] - 2 * system.nfrozen for i in range(system.nelectrons)] 37 | 38 | 39 | outLine = [ndet, coef] + det_occ_correlated 40 | outFile.write(" ") 41 | outFile.writelines(str(x).ljust(10, " ") for x in outLine[:1]) 42 | outFile.writelines(str(x).ljust(20, " ") for x in outLine[1:2]) 43 | outFile.writelines(" ") 44 | outFile.writelines(str(x).ljust(4, " " ) for x in outLine[2:]) 45 | outFile.write("\n") 46 | outFile.close() 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ccpy/left/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __all__ = ["left_ccsd", "left_ccsd_chol", "left_ccsdt", "left_ccsdt_p", "left_ipeom2", "left_ipeom3", "left_ipeom3_p", "left_eaeom2", "left_eaeom3", "left_eaeom3_p"] 3 | 4 | MODULES = [module for module in __all__] 5 | -------------------------------------------------------------------------------- /ccpy/left/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'left_eaeom2.py', 4 | 'left_ipeom3.py', 5 | 'left_eaeom_intermediates.py', 6 | 'left_cc_intermediates.py', 7 | 'left_ipeom_intermediates.py', 8 | 'left_ipeom2.py', 9 | 'left_ccsdt_p.py', 10 | 'left_eaeom3_p.py', 11 | 'left_cc3.py', 12 | 'left_eaeom3.py', 13 | 'left_ccsd.py', 14 | 'left_ccsd_chol.py', 15 | 'left_ccsdt.py', 16 | 'left_ipeom3_p.py' 17 | ] 18 | 19 | py3.install_sources( 20 | python_sources, 21 | subdir: 'ccpy/left' 22 | ) 23 | 24 | 25 | -------------------------------------------------------------------------------- /ccpy/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/lib/__init__.py -------------------------------------------------------------------------------- /ccpy/lib/core.py: -------------------------------------------------------------------------------- 1 | try: 2 | from ._fortran import * 3 | except ImportError: 4 | from .fortran import * 5 | -------------------------------------------------------------------------------- /ccpy/lib/fortran/__init__.py: -------------------------------------------------------------------------------- 1 | from .cc_loops import * 2 | from .cc_loops2 import * 3 | from .crcc_loops import * 4 | from .cripcc_loops import * 5 | from .creacc_loops import * 6 | from .ccsdpt_loops import * 7 | from .crcc24_loops import * 8 | from .crcc24_opt_loops import * 9 | from .cc3_loops import * 10 | from .hbar_cc3 import * 11 | from .mbgf_loops import * 12 | from .mbpt_loops import * 13 | from .ccsdt_p_loops import * 14 | from .eomccsdt_p_loops import * 15 | from .leftccsdt_p_loops import * 16 | from .leftccsdt_p_intermediates import * 17 | from .eaeom3_p_loops import * 18 | from .eaeom3_p_intermediates import * 19 | from .ipeom3_p_loops import * 20 | from .ipeomt_p_loops import * 21 | from .ipeom3_p_intermediates import * 22 | from .lefteaeom3_p_loops import * 23 | from .lefteaeom3_p_intermediates import * 24 | from .leftipeom3_p_loops import * 25 | from .leftipeom3_p_intermediates import * 26 | from .deaeom4_p_loops import * 27 | from .hbar_ccsdt_p import * 28 | from .eomcc_active_loops import * 29 | from .cc_active_loops import * 30 | from .cct3_loops import * 31 | from .cc_loops_t4 import * 32 | from .ccp3_loops import * 33 | from .ccp3_opt_loops import * 34 | from .ccp3_adaptive_loops import * 35 | from .eaccp3_loops import * 36 | from .ipccp3_loops import * 37 | from .clusteranalysis import * 38 | from .ecccp3_loops import * 39 | from .reorder import * 40 | from .vvvv_contraction import * -------------------------------------------------------------------------------- /ccpy/lib/fortran/active_pspace.f90: -------------------------------------------------------------------------------- 1 | module active_pspace 2 | 3 | implicit none 4 | 5 | contains 6 | 7 | subroutine get_active_triples_aaa(excitations_aaa,& 8 | orbsym,& 9 | num_active,& 10 | target_irrep,& 11 | n3aaa,noa,nua,norb) 12 | 13 | ! input variables 14 | integer, intent(in) :: noa, nua, norb, n3aaa 15 | integer, intent(in) :: num_active 16 | integer, intent(in) :: target_irrep 17 | integer, intent(in) :: orbsym(norb) 18 | ! output variable 19 | integer, intent(out) :: excitations_aaa(n3aaa,6) 20 | ! local variables 21 | integer :: i, j, k, a, b, c 22 | 23 | do i=1,noa 24 | isym = orbsym(i) 25 | do j=i+1,noa 26 | jsym = orbsym(j) 27 | do k=j+1,noa 28 | ksym = orbsym(k) 29 | do a=1,nua 30 | asym = orbsym(a + noa) 31 | do b=a+1,nua 32 | bsym = orbsym(b + noa) 33 | do c=b+1,nua 34 | csym = orbsym(c + noa) 35 | end do 36 | end do 37 | end do 38 | end do 39 | end do 40 | end do 41 | 42 | 43 | end subroutine get_active_triples_aaa 44 | 45 | end module active_pspace 46 | -------------------------------------------------------------------------------- /ccpy/lib/fortran/constants.f90: -------------------------------------------------------------------------------- 1 | module constants 2 | 3 | implicit none 4 | 5 | ! 32-bit (4-byte) integer 6 | integer, parameter :: int_32 = selected_int_kind(6) 7 | ! 64-bit (8-byte) integer 8 | integer, parameter :: int_64 = selected_int_kind(15) 9 | 10 | ! 32-bit (4-byte) real 11 | integer, parameter :: sp = selected_real_kind(6, 37) 12 | ! 64-bit (8-byte) real 13 | integer, parameter :: dp = selected_real_kind(15, 307) 14 | ! 128-bit (16-byte) real 15 | integer, parameter :: qp = selected_real_kind(33, 4931) 16 | ! Selected precision 17 | integer, parameter :: p = dp 18 | 19 | 20 | end module constants 21 | -------------------------------------------------------------------------------- /ccpy/lib/fortran/object_information: -------------------------------------------------------------------------------- 1 | object dump *.so -s or -m 2 | -------------------------------------------------------------------------------- /ccpy/lib/sort/test.f90: -------------------------------------------------------------------------------- 1 | program main 2 | use qsort_module 3 | implicit none 4 | double precision :: A(10) 5 | integer :: iorder(10) 6 | 7 | integer :: i 8 | do i=1,10 9 | A(i) = 10-i 10 | enddo 11 | print *, A 12 | 13 | do i=1,10 14 | iorder(i) = i 15 | enddo 16 | call dsort(A, iorder, 10) 17 | 18 | print *, iorder 19 | print *, A 20 | 21 | end 22 | 23 | -------------------------------------------------------------------------------- /ccpy/lrcc/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["lrccsd"] 2 | MODULES = [module for module in __all__] 3 | -------------------------------------------------------------------------------- /ccpy/lrcc/lrccsd_intermediates.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def get_lrccsd_intermediates(X, H, R, system): 4 | """Calculate the H*(R1+R2) intermediates for LRCCSD.""" 5 | 6 | X.a.oo = ( 7 | #np.einsum("me,ej->mj", H.a.ov, R.a, optimize=True) 8 | + np.einsum("mnjf,fn->mj", H.aa.ooov, R.a, optimize=True) 9 | + np.einsum("mnjf,fn->mj", H.ab.ooov, R.b, optimize=True) 10 | + 0.5 * np.einsum("mnef,efjn->mj", H.aa.oovv, R.aa, optimize=True) 11 | + np.einsum("mnef,efjn->mj", H.ab.oovv, R.ab, optimize=True) 12 | ) 13 | 14 | X.a.vv = ( 15 | #-1.0 * np.einsum("me,bm->be", H.a.ov, R.a, optimize=True) 16 | + np.einsum("bnef,fn->be", H.aa.vovv, R.a, optimize=True) 17 | + np.einsum("bnef,fn->be", H.ab.vovv, R.b, optimize=True) 18 | - 0.5 * np.einsum("mnef,bfmn->be", H.aa.oovv, R.aa, optimize=True) 19 | - np.einsum("mnef,bfmn->be", H.ab.oovv, R.ab, optimize=True) 20 | ) 21 | 22 | X.b.oo = ( 23 | #np.einsum("me,ek->mk", H.b.ov, R.b, optimize=True) 24 | + np.einsum("nmfk,fn->mk", H.ab.oovo, R.a, optimize=True) 25 | + np.einsum("mnkf,fn->mk", H.bb.ooov, R.b, optimize=True) 26 | + np.einsum("nmfe,fenk->mk", H.ab.oovv, R.ab, optimize=True) 27 | + 0.5 * np.einsum("mnef,efkn->mk", H.bb.oovv, R.bb, optimize=True) 28 | ) 29 | 30 | X.b.vv = ( 31 | #-1.0 * np.einsum("me,cm->ce", H.b.ov, R.b, optimize=True) 32 | + np.einsum("ncfe,fn->ce", H.ab.ovvv, R.a, optimize=True) 33 | + np.einsum("cnef,fn->ce", H.bb.vovv, R.b, optimize=True) 34 | - 1.0 * np.einsum("nmfe,fcnm->ce", H.ab.oovv, R.ab, optimize=True) 35 | - 0.5 * np.einsum("mnef,fcnm->ce", H.bb.oovv, R.bb, optimize=True) 36 | ) 37 | return X -------------------------------------------------------------------------------- /ccpy/lrcc/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'lrccsd_intermediates.py', 4 | 'lrccsd.py', 5 | ] 6 | 7 | py3.install_sources( 8 | python_sources, 9 | subdir: 'ccpy/lrcc', 10 | ) 11 | 12 | 13 | -------------------------------------------------------------------------------- /ccpy/mbpt/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ccpy/mbpt/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | 'mbpt.py', 3 | '__init__.py', 4 | 'mbgf.py' 5 | ] 6 | 7 | py3.install_sources( 8 | python_sources, 9 | subdir: 'ccpy/mbpt' 10 | ) 11 | 12 | 13 | -------------------------------------------------------------------------------- /ccpy/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | '_version.py', 4 | ] 5 | 6 | py3.install_sources( 7 | python_sources, 8 | subdir: 'ccpy' 9 | ) 10 | 11 | subdir('cc') 12 | subdir('cholesky') 13 | subdir('constants') 14 | subdir('density') 15 | subdir('drivers') 16 | subdir('energy') 17 | subdir('eomcc') 18 | subdir('eom_guess') 19 | subdir('extcorr') 20 | subdir('extrapolation') 21 | subdir('hbar') 22 | subdir('interfaces') 23 | subdir('left') 24 | subdir('lib') 25 | subdir('lrcc') 26 | subdir('mbpt') 27 | subdir('models') 28 | subdir('moments') 29 | subdir('mrcc') 30 | subdir('utilities') 31 | -------------------------------------------------------------------------------- /ccpy/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .system import System 2 | -------------------------------------------------------------------------------- /ccpy/models/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'integrals.py', 4 | 'hilbert.py', 5 | 'system.py', 6 | 'operators.py' 7 | ] 8 | 9 | py3.install_sources( 10 | python_sources, 11 | subdir: 'ccpy/models' 12 | ) 13 | 14 | 15 | -------------------------------------------------------------------------------- /ccpy/moments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/moments/__init__.py -------------------------------------------------------------------------------- /ccpy/moments/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'ccp3.py', 4 | 'ccp3_chol.py', 5 | 'ccp4.py', 6 | 'cct3.py', 7 | 'cct3_chol.py', 8 | 'crcc23.py', 9 | 'crcc23_chol.py', 10 | 'crcc24.py', 11 | 'crcc34.py', 12 | 'creacc23.py', 13 | 'creomcc23.py', 14 | 'creomcc23_chol.py', 15 | 'cripcc23.py', 16 | 'eaccp3.py', 17 | 'eaeomccsdta_star.py', 18 | 'eccc23.py', 19 | 'eomccsdta_star.py', 20 | 'ipccp3.py', 21 | 'ipeomccsdta_star.py', 22 | 'dipeomccsdta_star.py', 23 | ] 24 | 25 | py3.install_sources( 26 | python_sources, 27 | subdir: 'ccpy/moments' 28 | ) 29 | 30 | 31 | -------------------------------------------------------------------------------- /ccpy/mrcc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/mrcc/__init__.py -------------------------------------------------------------------------------- /ccpy/mrcc/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'effective_hamiltonian.py', 4 | 'normal_order.py', 5 | 'mkmrccsd.py' 6 | ] 7 | 8 | py3.install_sources( 9 | python_sources, 10 | subdir: 'ccpy/mrcc' 11 | ) 12 | 13 | 14 | -------------------------------------------------------------------------------- /ccpy/mrcc/normal_order.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from ccpy.energy.hf_energy import calc_hf_energy_unsorted 3 | 4 | def shift_normal_order(H, occ_a, occ_b, occ_a_prev, occ_b_prev): 5 | 6 | # de-normal order Z = F - G 7 | if occ_a_prev: # if occ_a_prev /= [] 8 | H.a -= np.einsum("piqi->pq", H.aa[:, occ_a_prev, :, occ_a_prev], optimize=True) 9 | H.b -= np.einsum("ipiq->pq", H.ab[occ_a_prev, :, occ_a_prev, :], optimize=True) 10 | if occ_b_prev: # if occ_b_prev /= [] 11 | H.a -= np.einsum("piqi->pq", H.ab[:, occ_b_prev, :, occ_b_prev], optimize=True) 12 | H.b -= np.einsum("piqi->pq", H.bb[:, occ_b_prev, :, occ_b_prev], optimize=True) 13 | 14 | # compute reference energy with bare Hamiltonian 15 | reference_energy = calc_hf_energy_unsorted(H, occ_a, occ_b) 16 | 17 | # normal order F = Z + G 18 | H.a += np.einsum("piqi->pq", H.aa[:, occ_a, :, occ_a], optimize=True) 19 | H.b += np.einsum("ipiq->pq", H.ab[occ_a, :, occ_a, :], optimize=True) 20 | H.a += np.einsum("piqi->pq", H.ab[:, occ_b, :, occ_b], optimize=True) 21 | H.b += np.einsum("piqi->pq", H.bb[:, occ_b, :, occ_b], optimize=True) 22 | 23 | return H, reference_energy 24 | 25 | 26 | if __name__ == "__main__": 27 | 28 | from ccpy.models.hilbert import Determinant 29 | 30 | model_space = [ 31 | Determinant(), 32 | ] 33 | 34 | d = len(model_space) 35 | 36 | occ_prev_a = [] 37 | occ_prev_b = [] 38 | 39 | for q in range(d): 40 | 41 | occ_a, unocc_a, occ_b, unocc_b = model_space[q].get_orbital_partitioning(system) 42 | 43 | H, e_ref = shift_normal_order(H, occ_a, occ_b, occ_prev_a, occ_prev_b) 44 | 45 | occ_prev_a = occ_a.copy() 46 | occ_prev_b = occ_b.copy() -------------------------------------------------------------------------------- /ccpy/utilities/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piecuch-group/ccpy/f0e3c31d93a0519f19f2375368264f4dc6b3612b/ccpy/utilities/__init__.py -------------------------------------------------------------------------------- /ccpy/utilities/determinants.py: -------------------------------------------------------------------------------- 1 | 2 | def calculate_permutation_parity(lst): 3 | """Given a permutation of the digits 0..N in order as a list, 4 | returns its parity (or sign): +1 for even parity; -1 for odd.""" 5 | parity = 1.0 6 | for i in range(0, len(lst) - 1): 7 | if lst[i] != i: 8 | parity *= -1.0 9 | mn = min(range(i, len(lst)), key=lst.__getitem__) 10 | lst[i], lst[mn] = lst[mn], lst[i] 11 | return parity 12 | 13 | def get_excit_rank(D, D0): 14 | return len(set(D) - set(D0)) 15 | 16 | 17 | def get_excits_from(D, D0): 18 | return list(set(D0) - set(D)) 19 | 20 | 21 | def get_excits_to(D, D0): 22 | return list(set(D) - set(D0)) 23 | 24 | 25 | def spatial_orb_idx(x): 26 | if x % 2 == 1: 27 | return int((x + 1) / 2) 28 | else: 29 | return int(x / 2) 30 | 31 | 32 | def get_spincase(excits_from, excits_to): 33 | assert (len(excits_from) == len(excits_to)) 34 | 35 | num_alpha_occ = sum([i % 2 for i in excits_from]) 36 | num_alpha_unocc = sum([i % 2 for i in excits_to]) 37 | 38 | assert (num_alpha_occ == num_alpha_unocc) 39 | 40 | spincase = 'a' * num_alpha_occ + 'b' * (len(excits_from) - num_alpha_occ) 41 | 42 | return spincase 43 | 44 | def calculate_excitation_difference(f1, f2, spintype1, spintype2): 45 | 46 | if spintype1 == 'aaa': 47 | if spintype2 == 'aaa': 48 | return get_number_difference(f1[:3], f2[:3]) + get_number_difference(f1[3:], f2[3:]) 49 | if spintype2 == 'aab': 50 | return get_number_difference(f1[:3], f2[:2]) + get_number_difference(f1[3:], f2[3:5]) 51 | if spintype2 == 'abb': 52 | return 4 53 | if spintype2 == 'bbb': 54 | return 6 55 | 56 | if spintype1 == 'aab': 57 | if spintype2 == 'aaa': 58 | return get_number_difference(f1[:2], f2[:3]) + get_number_difference(f1[3:5], f2[3:]) 59 | if spintype2 == 'aab': 60 | return get_number_difference(f1[:2], f2[:2]) + get_number_difference(f1[3], f2[3])\ 61 | +get_number_difference(f1[3:5], f2[3:5]) + get_number_difference(f1[5], f2[5]) 62 | if spintype2 == 'abb': 63 | return get_number_difference(f1[:2], f2[3]) + get_number_difference(f1[3], f2[1:3])\ 64 | +get_number_difference(f1[3:5], f2[3]) + get_number_difference(f1[5], f2[4:]) 65 | if spintype2 == 'bbb': 66 | return get_number_difference(f1[3], f2[:3]) + get_number_difference(f1[5], f2[3:]) 67 | 68 | def get_number_difference(f1, f2): 69 | return len( set(f1) ^ set(f2) ) 70 | -------------------------------------------------------------------------------- /ccpy/utilities/meson.build: -------------------------------------------------------------------------------- 1 | python_sources = [ 2 | '__init__.py', 3 | 'active_space.py', 4 | 'determinants.py', 5 | 'dumping.py', 6 | 'permutations.py', 7 | 'printing.py', 8 | 'pspace.py', 9 | 'qspace.py', 10 | 'selection.py', 11 | 'symmetry.py', 12 | 'utilities.py', 13 | ] 14 | 15 | py3.install_sources( 16 | python_sources, 17 | subdir: 'ccpy/utilities' 18 | ) 19 | -------------------------------------------------------------------------------- /ccpy/utilities/permutations.py: -------------------------------------------------------------------------------- 1 | 2 | def calculate_permutation_parity(lst): 3 | """Given a permutation of the digits 0..N in order as a list, 4 | returns its parity (or sign): +1 for even parity; -1 for odd.""" 5 | parity = 1.0 6 | for i in range(0, len(lst) - 1): 7 | if lst[i] != i: 8 | parity *= -1.0 9 | mn = min(range(i, len(lst)), key=lst.__getitem__) 10 | lst[i], lst[mn] = lst[mn], lst[i] 11 | return parity 12 | 13 | def do_lineup_permutation(f1, f2): 14 | """Given two lists f1 and f2, returns their sorted counterparts in 15 | order of maximum coincidence along with the associated phase of permutation 16 | for each list.""" 17 | 18 | f1 = list(sorted(f1)) 19 | f2 = list(sorted(f2)) 20 | 21 | # find the positions of the indices common to both lists 22 | i, j = 0, 0 23 | idx_common_1 = [] 24 | idx_common_2 = [] 25 | # merge sort O( n*log(m) ), where n 26 | while i < len(f1) and j < len(f2): 27 | if f1[i] == f2[j]: 28 | idx_common_1.append(i) 29 | idx_common_2.append(j) 30 | i += 1 31 | j += 1 32 | elif f1[i] < f2[j]: 33 | i += 1 34 | else: 35 | j += 1 36 | idx_different_1 = [i for i in range(len(f1)) if i not in idx_common_1] 37 | idx_different_2 = [i for i in range(len(f2)) if i not in idx_common_2] 38 | 39 | p1 = idx_common_1 + idx_different_1 40 | p2 = idx_common_2 + idx_different_2 41 | 42 | return [f1[i] for i in p1], [f2[i] for i in p2], calculate_permutation_parity(p1), calculate_permutation_parity(p2) 43 | -------------------------------------------------------------------------------- /devtools/ciwheels/cibw_before_build_linux.sh: -------------------------------------------------------------------------------- 1 | set -xe 2 | 3 | NIGHTLY_FLAG="" 4 | 5 | if [ "$#" -eq 1 ]; then 6 | PROJECT_DIR="$1" 7 | elif [ "$#" -eq 2 ] && [ "$1" = "--nightly" ]; then 8 | NIGHTLY_FLAG="--nightly" 9 | PROJECT_DIR="$2" 10 | else 11 | echo "Usage: $0 [--nightly] " 12 | exit 1 13 | fi 14 | 15 | printenv 16 | 17 | ulimit -n 1024000 18 | yum install -y --nogpgcheck openblas-devel.x86_64 gcc 19 | 20 | python -m pip install ninja meson-python 21 | -------------------------------------------------------------------------------- /devtools/conda-envs/test_env.yaml: -------------------------------------------------------------------------------- 1 | name: test 2 | channels: 3 | 4 | - conda-forge 5 | 6 | - defaults 7 | dependencies: 8 | # Base depends 9 | - python 10 | - pip 11 | 12 | # Testing 13 | - pytest 14 | - pytest-cov 15 | - codecov 16 | 17 | # Pip-only installs 18 | #- pip: 19 | # - codecov 20 | 21 | -------------------------------------------------------------------------------- /devtools/f2cmap.py: -------------------------------------------------------------------------------- 1 | { 2 | "real": { 3 | "p": "double", 4 | }, 5 | } 6 | -------------------------------------------------------------------------------- /devtools/f2py_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCES=() 4 | while [[ $# > 1 ]] 5 | do 6 | key="$1" 7 | shift 8 | 9 | case "$key" in 10 | '--source-root') 11 | SOURCE_ROOT="$1" 12 | shift 13 | ;; 14 | '--f2py-exe') 15 | F2PY_EXE="$1" 16 | shift 17 | ;; 18 | '--build-dir') 19 | BUILD_DIR="$1" 20 | shift 21 | ;; 22 | *) 23 | SOURCES+=("$key") 24 | ;; 25 | esac 26 | done 27 | 28 | 29 | echo "Finding fortan dependencies" 30 | ORDERED_SOURCES=$(python3 $SOURCE_ROOT/devtools/order_fortran_dependencies.py ${SOURCES[@]}) 31 | 32 | echo "Building PYF" 33 | $F2PY_EXE --quiet $ORDERED_SOURCES -m _fortran -h _fortran.pyf --overwrite-signature --build-dir $BUILD_DIR 34 | 35 | echo "Building wrappers" 36 | $F2PY_EXE --quiet --f2cmap $SOURCE_ROOT/devtools/f2cmap.py --build-dir $BUILD_DIR $BUILD_DIR/_fortran.pyf 37 | -------------------------------------------------------------------------------- /devtools/legacy-miniconda-setup/before_install.sh: -------------------------------------------------------------------------------- 1 | # Temporarily change directory to $HOME to install software 2 | pushd . 3 | cd $HOME 4 | # Make sure some level of pip is installed 5 | python -m ensurepip 6 | 7 | # Install Miniconda 8 | if [ "$TRAVIS_OS_NAME" == "osx" ]; then 9 | # Make OSX md5 mimic md5sum from linux, alias does not work 10 | md5sum () { 11 | command md5 -r "$@" 12 | } 13 | MINICONDA=Miniconda3-latest-MacOSX-x86_64.sh 14 | else 15 | MINICONDA=Miniconda3-latest-Linux-x86_64.sh 16 | fi 17 | MINICONDA_HOME=$HOME/miniconda 18 | MINICONDA_MD5=$(wget -qO- https://repo.anaconda.com/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *\(.*\)<\/td> */\1/p') 19 | wget -q https://repo.anaconda.com/miniconda/$MINICONDA 20 | if [[ $MINICONDA_MD5 != $(md5sum $MINICONDA | cut -d ' ' -f 1) ]]; then 21 | echo "Miniconda MD5 mismatch" 22 | exit 1 23 | fi 24 | bash $MINICONDA -b -p $MINICONDA_HOME 25 | 26 | # Configure miniconda 27 | export PIP_ARGS="-U" 28 | # New to conda >=4.4 29 | echo ". $MINICONDA_HOME/etc/profile.d/conda.sh" >> ~/.bashrc # Source the profile.d file 30 | echo "conda activate" >> ~/.bashrc # Activate conda 31 | source ~/.bashrc # source file to get new commands 32 | #export PATH=$MINICONDA_HOME/bin:$PATH # Old way, should not be needed anymore 33 | 34 | conda config --add channels conda-forge 35 | 36 | conda config --set always_yes yes 37 | conda install conda conda-build jinja2 anaconda-client 38 | conda update --quiet --all 39 | 40 | # Restore original directory 41 | popd 42 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = ccpy 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Compiling CCpy's Documentation 2 | 3 | The docs for this project are built with [Sphinx](http://www.sphinx-doc.org/en/master/). 4 | To compile the docs, first ensure that Sphinx and the ReadTheDocs theme are installed. 5 | 6 | 7 | ```bash 8 | conda install sphinx sphinx_rtd_theme 9 | ``` 10 | 11 | 12 | Once installed, you can use the `Makefile` in this directory to compile static HTML pages by 13 | ```bash 14 | make html 15 | ``` 16 | 17 | The compiled docs will be in the `_build` directory and can be viewed by opening `index.html` (which may itself 18 | be inside a directory called `html/` depending on what version of Sphinx is installed). 19 | -------------------------------------------------------------------------------- /docs/_static/README.md: -------------------------------------------------------------------------------- 1 | # Static Doc Directory 2 | 3 | Add any paths that contain custom static files (such as style sheets) here, 4 | relative to the `conf.py` file's directory. 5 | They are copied after the builtin static files, 6 | so a file named "default.css" will overwrite the builtin "default.css". 7 | 8 | The path to this folder is set in the Sphinx `conf.py` file in the line: 9 | ```python 10 | templates_path = ['_static'] 11 | ``` 12 | 13 | ## Examples of file to add to this directory 14 | * Custom Cascading Style Sheets 15 | * Custom JavaScript code 16 | * Static logo images 17 | -------------------------------------------------------------------------------- /docs/_templates/README.md: -------------------------------------------------------------------------------- 1 | # Templates Doc Directory 2 | 3 | Add any paths that contain templates here, relative to 4 | the `conf.py` file's directory. 5 | They are copied after the builtin template files, 6 | so a file named "page.html" will overwrite the builtin "page.html". 7 | 8 | The path to this folder is set in the Sphinx `conf.py` file in the line: 9 | ```python 10 | html_static_path = ['_templates'] 11 | ``` 12 | 13 | ## Examples of file to add to this directory 14 | * HTML extensions of stock pages like `page.html` or `layout.html` 15 | -------------------------------------------------------------------------------- /docs/cc_calculations.rst: -------------------------------------------------------------------------------- 1 | Coupled-Cluster Options 2 | ####################### 3 | 4 | Ground-State Calculations 5 | ************************* 6 | 7 | CCD 8 | === 9 | 10 | CCSD 11 | ==== 12 | 13 | CCSD(T) 14 | ======= 15 | 16 | CC3 17 | === 18 | 19 | CCSDt 20 | ===== 21 | 22 | CCSDT 23 | ===== 24 | 25 | CCSDTQ 26 | ====== 27 | 28 | Excited-State Calculations 29 | ************************** 30 | 31 | EOMCCSD 32 | ======= 33 | 34 | EOM-CC3 35 | ======= 36 | 37 | EOMCCSDt 38 | ======== 39 | 40 | EOMCCSDT 41 | ======== 42 | 43 | Electron-Ionizing Calculations 44 | ****************************** 45 | 46 | IP-EOMCCSD(2h-1p) 47 | ================= 48 | 49 | IP-EOMCCSD(3h-2p) 50 | ================= 51 | 52 | Electron-Attaching Calculations 53 | ******************************* 54 | 55 | EA-EOMCCSD(2p-1h) 56 | ================= 57 | 58 | EA-EOMCCSD(3p-2h) 59 | ================= 60 | 61 | DEA-EOMCCSD(2p) 62 | =============== 63 | 64 | DEA-EOMCCSD(3p-1h) 65 | ================== 66 | 67 | DEA-EOMCCSD(4p-2h) 68 | ================== 69 | 70 | Spin-Flip Calculations 71 | ********************** 72 | 73 | SF-EOMCCSD 74 | ========== 75 | -------------------------------------------------------------------------------- /docs/ccpq_calculations.rst: -------------------------------------------------------------------------------- 1 | CC(*P* ;\ *Q*) Methodologies 2 | ############################ 3 | 4 | Ground-State Calculations 5 | ************************* 6 | 7 | CR-CC(2,3) 8 | ========== 9 | 10 | CR-CC(2,4) 11 | ========== 12 | 13 | CC(t;3) 14 | ======= 15 | 16 | CIPSI-driven CC(*P* ;\ *Q*) aimed at converging CCSDT 17 | ===================================================== 18 | 19 | Adaptive CC(*P* ;\ *Q*) aimed at converging CCSDT 20 | ================================================= 21 | 22 | Excited-State Calculations 23 | ************************** 24 | 25 | CR-EOMCC(2,3) and :math:`\delta`-CR-EOMCC(2,3) 26 | ============================================== 27 | 28 | -------------------------------------------------------------------------------- /docs/contact_information.rst: -------------------------------------------------------------------------------- 1 | CCpy Development Team 2 | ##################### 3 | 4 | | Karthik Gururangan (e-mail: gururang@msu.edu) 5 | | Doctoral student, Department of Chemistry, Michigan State University 6 | 7 | | Dr. J. Emiliano Deustua 8 | | COO and Co-founder, Examol 9 | 10 | | Professor Piotr Piecuch 11 | | University Distinguished Professor and Michigan State University Foundation Professor, Department of Chemistry, Michigan State University 12 | | Adjunct Professor, Department of Physics and Astronomy, Michigan State University 13 | 14 | CCpy is an open-source code under the `GPLv3 `_ license. 15 | It is developed and maintained by the `Piecuch Group `_ 16 | at Michigan State University. In addition to using GitHub's Issues feature, feel free to send an e-mail 17 | to gururang@msu.edu if you have any questions about using CCpy or are seeking additional information 18 | about its functionality. 19 | -------------------------------------------------------------------------------- /docs/eccc_calculations.rst: -------------------------------------------------------------------------------- 1 | Externally Corrected Coupled-Cluster 2 | #################################### 3 | 4 | Selected-Configuration-Interaction-Based Approaches 5 | *************************************************** 6 | 7 | ec-CC-II 8 | ======== 9 | 10 | ec-CC-II\ :sub:`3` 11 | ================== 12 | 13 | ec-CC-II\ :sub:`3,4` 14 | ==================== 15 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. ccpy documentation master file, created by 2 | sphinx-quickstart on Tue Oct 17 13:30:35 2023. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | CCpy: A coupled-cluster package written in Python 7 | ================================================= 8 | CCpy is a research-level Python package for performing non-relativistic electronic structure 9 | calculations for molecular systems using methods based on the ground-state coupled-cluster 10 | (CC) theory and its equation-of-motion (EOM) extension to electronic excited, attached, 11 | and ionized states. As a design philosophy, CCpy favors simplicity over efficiency, and this 12 | is reflected in the usage of computational routines that are transparent enough so that they 13 | can be easily used, modified, and extended, while still maintaining reasonable efficiency. 14 | To this end, CCpy employs a hybrid Python-Fortran programming approach made possible with the 15 | :code:`f2py` package, which allows one to compile Fortran code into shared object libraries 16 | containing subroutines that are callable from Python and interoperable with Numpy arrays. 17 | 18 | .. toctree:: 19 | :maxdepth: 3 20 | :caption: Contents: 21 | 22 | installation 23 | getting_started 24 | computational_options 25 | walkthrough 26 | references 27 | contact_information 28 | 29 | .. Indices and tables 30 | ================== 31 | * :ref:`genindex` 32 | * :ref:`modindex` 33 | * :ref:`search` 34 | .. 35 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ############ 3 | 4 | CCpy is currently run and tested on Linux and Mac OS devices. Linux users (including WSL users) 5 | can choose to install a pre-compiled version of CCpy from the PyPI server (simplest option) or 6 | download the source code and install it manually. For now, Mac OS users must download and install 7 | the source code (wheels for Mac OS will be uploaded to PyPI in the near future). 8 | 9 | Installing from PyPI 10 | -------------------- 11 | For Linux machines, the 12 | latest version of CCpy available on PyPI is obtained by running :: 13 | 14 | pip install coupled-cluster-py 15 | 16 | Installing via Source Code 17 | -------------------------- 18 | 19 | Clone the CCpy repository and enter the :code:`ccpy` directory: :: 20 | 21 | git clone https://piecuch-group/ccpy.git 22 | cd ccpy 23 | 24 | We recommend creating a new environment for CCpy by running the following command :: 25 | 26 | conda create --name=ccpy_env python=3.12 27 | 28 | and installing all of the dependencies listed in :code:`requirements-dev.txt` via :: 29 | 30 | pip install -r requirements-dev.txt 31 | 32 | Additionally, it is useful to install :code:`cmake` and :code:`pkgconfig` specific to your 33 | Conda environment by running :: 34 | 35 | conda install pkgconfig cmake 36 | 37 | Then, you can install CCpy using :: 38 | 39 | pip install --no-build-isolation --verbose --editable . 40 | 41 | The Meson backend will automatically locate the needed libraries with the help of :code:`pkgconfig`. 42 | If you are having issues finding :code:`openblas`, make sure that the environment variable :code:`PKG_CONFIG_PATH` points to 43 | the directory that includes the :code:`openblas.pc` file. This should be located within :code:`openblas/lib`, 44 | or something similar. After installing in editable mode (via :code:`--editable`), the package will 45 | automatically update with any changes you make without additional installation steps. 46 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=ccpy 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docs/references.rst: -------------------------------------------------------------------------------- 1 | References 2 | ---------------------------- 3 | [1] J. Olsen, P. Jørgensen, H. Koch, A. Balkova, and R. J. Bartlett, *J. Chem. Phys.* **104**, 8007 (1996). -------------------------------------------------------------------------------- /docs/requirements.yaml: -------------------------------------------------------------------------------- 1 | name: docs 2 | channels: 3 | dependencies: 4 | # Base depends 5 | - python 6 | - pip 7 | 8 | 9 | 10 | # Pip-only installs 11 | #- pip: 12 | 13 | -------------------------------------------------------------------------------- /env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$0" = "bash" ]; then 4 | SOURCE_ROOT="$BASH_SOURCE" 5 | else 6 | SOURCE_ROOT="$0" 7 | fi 8 | 9 | PROJECT_PATH=$(realpath $(dirname "$SOURCE_ROOT")) 10 | 11 | source $PROJECT_PATH/../ccpyvenv/bin/activate 12 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: ccpy-dev 2 | channels: 3 | - conda-forge 4 | - defaults 5 | dependencies: 6 | - python=3.9 7 | - compilers 8 | - mkl 9 | - mkl-service 10 | - libblas=*=*mkl 11 | - bblas=*=*mkl 12 | - pkg-config 13 | - meson 14 | - meson-python 15 | - ninja 16 | - pandas 17 | - numpy 18 | - scipy 19 | - periodictable 20 | - pydantic 21 | - pip 22 | - setuptools 23 | - ipython 24 | - pyscf 25 | # Testing and lint 26 | - flake8 27 | - pytest 28 | - pytest-cov 29 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'ccpy', 3 | 'c', 4 | 'fortran', 5 | version: '0.0.5', 6 | license: 'GPL-3', 7 | meson_version: '>= 1.1.0', 8 | default_options: [ 9 | 'fortran_std=legacy', 10 | 'c_std=c17', 11 | 'blas=openblas', 12 | 'lapack=openblas' 13 | ], 14 | ) 15 | 16 | py3 = import('python').find_installation(pure: false) 17 | py3_dep = py3.dependency() 18 | 19 | f2py_script = find_program('devtools/f2py_script.sh') 20 | 21 | min_numpy_version = '2.0.0' # keep in sync with pyproject.toml 22 | 23 | add_languages('fortran', native: false) 24 | ff = meson.get_compiler('fortran') 25 | if ff.has_argument('-Wno-conversion') 26 | add_project_arguments('-Wno-conversion', language: 'fortran') 27 | endif 28 | add_project_arguments('-Wno-unused-dummy-argument', language: 'fortran') 29 | add_project_arguments('-Wno-unused-variable', language: 'fortran') 30 | 31 | subdir('ccpy') 32 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('blas', type: 'string', value: 'openblas', 2 | description: 'option for BLAS library switching') 3 | option('lapack', type: 'string', value: 'openblas', 4 | description: 'option for LAPACK library switching') 5 | option('use-g77-abi', type: 'boolean', value: false, 6 | description: 'If set to true, forces using g77 compatibility wrappers ' + 7 | 'for LAPACK functions. The default is to use gfortran ' + 8 | 'ABI for all LAPACK libraries except MKL.') 9 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: ccpy 2 | theme: 3 | name: material 4 | 5 | markdown_extensions: 6 | - markdown.extensions.codehilite: 7 | guess_lang: false 8 | - markdown_include.include: 9 | base_path: docs 10 | - admonition 11 | - codehilite 12 | - extra 13 | - pymdownx.extra 14 | - pymdownx.arithmatex: 15 | generic: true 16 | 17 | nav: 18 | - Home: 'index.md' 19 | - Quickstart: 'quickstart.md' 20 | - Installation: 'installation.md' 21 | -------------------------------------------------------------------------------- /readthedocs.yml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | # readthedocs.yml 4 | 5 | # Required 6 | version: 2 7 | 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.11" 12 | 13 | python: 14 | version: 3.8 15 | install: 16 | - method: pip 17 | path : . 18 | 19 | conda: 20 | environment: docs/requirements.yaml 21 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | cclib==1.8.1 2 | h5py==3.12.1 3 | iniconfig==2.0.0 4 | meson==1.6.0 5 | meson-python==0.17.1 6 | numpy==2.1.2 7 | packaging==24.1 8 | periodictable==1.7.1 9 | pluggy==1.5.0 10 | psutil==6.1.0 11 | pyparsing==3.2.0 12 | pyproject-metadata==0.9.0 13 | pyscf==2.7.0 14 | pytest==8.3.3 15 | scipy==1.14.1 16 | setuptools==75.2.0 17 | -------------------------------------------------------------------------------- /tests/allyl/test_eaeom3_allyl.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver 4 | 5 | def test_eaeom3_allyl(): 6 | 7 | mol = gto.M( 8 | atom='''C 0.00000000 0.00000000 0.83050732 9 | C 0.00000000 2.30981224 -0.38722841 10 | C 0.00000000 -2.30981224 -0.38722841 11 | H 0.00000000 0.00000000 2.87547067 12 | H 0.00000000 4.06036949 0.65560561 13 | H 0.00000000 -4.06036949 0.65560561 14 | H 0.00000000 2.41059890 -2.42703281 15 | H 0.00000000 -2.41059890 -2.42703281''', 16 | basis="6-31g", 17 | spin=0, 18 | charge=1, 19 | symmetry="C2V", 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=3) 26 | driver.system.print_info() 27 | driver.run_cc(method="ccsd") 28 | driver.run_hbar(method="ccsd") 29 | 30 | driver.system.set_active_space(nact_occupied=0, nact_unoccupied=2) 31 | driver.run_guess(method="eacisd", nact_occupied=5, nact_unoccupied=8, multiplicity=-1, 32 | roots_per_irrep={"A2": 1, "B1": 1, "A1": 1}) 33 | driver.run_eaeomcc(method="eaeom3", state_index=[0, 1, 2]) 34 | 35 | # 36 | # Check the results 37 | # 38 | expected_vee = [-0.28237593, -0.14922026, -0.00087619] 39 | for i, vee in enumerate(expected_vee): 40 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 41 | 42 | if __name__ == "__main__": 43 | test_eaeom3_allyl() 44 | -------------------------------------------------------------------------------- /tests/allyl/test_eaeomt3_allyl.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver, get_active_3p2h_pspace 4 | 5 | def test_eaeom3a_allyl(): 6 | 7 | mol = gto.M( 8 | atom='''C 0.00000000 0.00000000 0.83050732 9 | C 0.00000000 2.30981224 -0.38722841 10 | C 0.00000000 -2.30981224 -0.38722841 11 | H 0.00000000 0.00000000 2.87547067 12 | H 0.00000000 4.06036949 0.65560561 13 | H 0.00000000 -4.06036949 0.65560561 14 | H 0.00000000 2.41059890 -2.42703281 15 | H 0.00000000 -2.41059890 -2.42703281''', 16 | basis="6-31g", 17 | spin=0, 18 | charge=1, 19 | symmetry="C2V", 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=3) 26 | driver.system.print_info() 27 | driver.run_cc(method="ccsd") 28 | driver.run_hbar(method="ccsd") 29 | 30 | driver.system.set_active_space(nact_occupied=0, nact_unoccupied=2) 31 | 32 | irreps = ["A2", "B1", "A1"] 33 | nroots = [1, 1, 1] 34 | driver.run_guess(method="eacisd", nact_occupied=5, nact_unoccupied=8, multiplicity=-1, 35 | roots_per_irrep=dict(zip(irreps, nroots))) 36 | 37 | for i, sym in enumerate(irreps): 38 | r3_excitations = get_active_3p2h_pspace(driver.system, target_irrep=sym) 39 | driver.run_eaeomccp(method="eaeom3_p", state_index=i, r3_excitations=r3_excitations) 40 | driver.run_lefteaeomccp(method="left_eaeom3_p", state_index=i, r3_excitations=r3_excitations) 41 | driver.run_eaccp3(method="eaccp3", state_index=i, r3_excitations=r3_excitations) 42 | 43 | # 44 | # Check the results 45 | # 46 | expected_vee = [-0.28050484, -0.14827956, 0.00067634] 47 | expected_deltaD = [-0.0019126694, -0.0009361803, -0.0014588215] 48 | for i, (vee, vee_d) in enumerate(zip(expected_vee, expected_deltaD)): 49 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 50 | assert np.allclose(driver.deltap3[i]["D"], vee_d) 51 | 52 | if __name__ == "__main__": 53 | 54 | test_eaeom3a_allyl() 55 | -------------------------------------------------------------------------------- /tests/c2/test_eaeomccsdt_c2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | EA-EOMCCSDT for C2 in cc-pVDZ basis set 3 | M. Musial and R. J. Bartlett, J. Chem. Phys 119, 1901 (2003) 4 | ''' 5 | import numpy as np 6 | from pyscf import gto, scf 7 | 8 | def test_eaeomccsdt_c2(): 9 | from ccpy import Driver, get_active_triples_pspace 10 | from ccpy.utilities.utilities import convert_t3_from_pspace 11 | 12 | geom = [["C", (0.0, 0.0, 0.0)], 13 | ["C", (0.0, 0.0, 1.243)]] 14 | 15 | state_index = [0] 16 | 17 | mol = gto.M(atom=geom, 18 | basis="cc-pvdz", 19 | charge=0, 20 | symmetry="D2H", 21 | cart=False, 22 | spin=0, 23 | unit="Angstrom") 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=2) 28 | driver.system.print_info() 29 | # 30 | driver.system.set_active_space(nact_occupied=driver.system.noccupied_alpha, nact_unoccupied=driver.system.nunoccupied_alpha) 31 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="AG") 32 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 33 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 34 | # 35 | convert_t3_from_pspace(driver, t3_excitations) 36 | # 37 | driver.run_guess(method="eacisd", nact_occupied=0, nact_unoccupied=0, 38 | multiplicity=-1, roots_per_irrep={"AG": 7}, use_symmetry=False) 39 | driver.run_eaeomcc(method="eaeomccsdt", state_index=state_index) 40 | 41 | ea_energy = np.zeros(len(state_index)) 42 | for i, istate in enumerate(state_index): 43 | print(f"\nState {istate}") 44 | print("-----") 45 | ea_energy[i] = (driver.vertical_excitation_energy[istate])* 27.2114 46 | print(f"EA Energy = {ea_energy[i]} eV") 47 | 48 | expected_ea = [-2.30] 49 | for w_calc, w_exp in zip(ea_energy, expected_ea): 50 | assert np.allclose(w_calc, w_exp, atol=1.0e-02) 51 | 52 | if __name__ == "__main__": 53 | 54 | test_eaeomccsdt_c2() 55 | 56 | -------------------------------------------------------------------------------- /tests/ch/test_ccsdt_ch.py: -------------------------------------------------------------------------------- 1 | """CCSDT computation on open-shell CH molecule.""" 2 | 3 | import pytest 4 | from pathlib import Path 5 | import numpy as np 6 | from ccpy import Driver 7 | 8 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 9 | 10 | @pytest.mark.short 11 | def test_ccsdt_ch(): 12 | driver = Driver.from_gamess( 13 | logfile=TEST_DATA_DIR + "/ch/ch.log", 14 | fcidump=TEST_DATA_DIR + "/ch/ch.FCIDUMP", 15 | nfrozen=1, 16 | ) 17 | driver.system.print_info() 18 | 19 | driver.options["RHF_symmetry"] = False 20 | driver.run_cc(method="ccsdt") 21 | 22 | # Check reference energy 23 | assert np.allclose(driver.system.reference_energy, -38.2713247488, atol=1.0e-07) 24 | # Check CCSDT energy 25 | assert np.allclose(driver.correlation_energy, -0.1164237849, atol=1.0e-07) 26 | assert np.allclose( 27 | driver.system.reference_energy + driver.correlation_energy, -38.3877485336, atol=1.0e-07 28 | ) 29 | 30 | if __name__ == "__main__": 31 | test_ccsdt_ch() 32 | -------------------------------------------------------------------------------- /tests/ch/test_cct3_ch.py: -------------------------------------------------------------------------------- 1 | """CC(t;3) computation on open-shell CH molecule.""" 2 | 3 | import pytest 4 | from pathlib import Path 5 | import numpy as np 6 | from ccpy import Driver, get_active_triples_pspace 7 | 8 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 9 | 10 | @pytest.mark.short 11 | def test_cct3_ch(): 12 | driver = Driver.from_gamess( 13 | logfile=TEST_DATA_DIR + "/ch/ch.log", 14 | fcidump=TEST_DATA_DIR + "/ch/ch.FCIDUMP", 15 | nfrozen=1, 16 | ) 17 | driver.system.set_active_space(nact_occupied=1, nact_unoccupied=2) 18 | driver.system.print_info() 19 | 20 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="B2") 21 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 22 | driver.run_hbar(method="ccsd") 23 | driver.run_leftcc(method="left_ccsd") 24 | driver.run_ccp3(method="cct3") 25 | 26 | # Check reference energy 27 | assert np.allclose(driver.system.reference_energy, -38.2713247488, atol=1.0e-07) 28 | # Check CCSDt energy 29 | assert np.allclose(driver.correlation_energy, -0.11469532, atol=1.0e-07) 30 | assert np.allclose( 31 | driver.system.reference_energy + driver.correlation_energy, -38.38602007, atol=1.0e-07 32 | ) 33 | # Check CC(t;3)_A energy 34 | assert np.allclose( 35 | driver.correlation_energy + driver.deltap3[0]["A"], -0.1160181452, atol=1.0e-07 36 | ) 37 | assert np.allclose( 38 | driver.system.reference_energy 39 | + driver.correlation_energy 40 | + driver.deltap3[0]["A"], 41 | -38.3873428940, 42 | atol=1.0e-07 43 | ) 44 | # Check CC(t;3)_D energy 45 | assert np.allclose( 46 | driver.correlation_energy + driver.deltap3[0]["D"], -0.1162820915, atol=1.0e-07 47 | ) 48 | assert np.allclose( 49 | driver.system.reference_energy 50 | + driver.correlation_energy 51 | + driver.deltap3[0]["D"], 52 | -38.3876068402, 53 | atol=1.0e-07 54 | ) 55 | 56 | if __name__ == "__main__": 57 | test_cct3_ch() 58 | -------------------------------------------------------------------------------- /tests/ch/test_eomccsd_ch.py: -------------------------------------------------------------------------------- 1 | """EOMCCSD computation for the open-shell CH molcule.""" 2 | 3 | import pytest 4 | from pathlib import Path 5 | import numpy as np 6 | from ccpy import Driver 7 | 8 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 9 | 10 | @pytest.mark.short 11 | def test_eomccsd_ch(): 12 | driver = Driver.from_gamess( 13 | logfile=TEST_DATA_DIR + "/ch/ch.log", 14 | fcidump=TEST_DATA_DIR + "/ch/ch.FCIDUMP", 15 | nfrozen=0, 16 | ) 17 | driver.system.print_info() 18 | 19 | driver.run_cc(method="ccsd") 20 | driver.run_hbar(method="ccsd") 21 | driver.run_guess(method="cis", multiplicity=2, roots_per_irrep={"A1": 1, "B1": 1, "B2": 0, "A2": 1}) 22 | driver.run_eomcc(method="eomccsd", state_index=[1, 2, 3]) 23 | 24 | expected_vee = [0.0, 0.12122133, 0.00016954, 0.11798458] 25 | expected_total_energy = [-38.38631169 + omega for omega in expected_vee] 26 | 27 | # Check reference energy 28 | assert np.allclose(driver.system.reference_energy, -38.27132475, atol=1.0e-07) 29 | for n in range(4): 30 | if n == 0: 31 | # Check CCSD energy 32 | assert np.allclose(driver.correlation_energy, -0.11498694, atol=1.0e-07) 33 | assert np.allclose( 34 | driver.system.reference_energy + driver.correlation_energy, -38.38631169, atol=1.0e-07 35 | ) 36 | else: 37 | # Check EOMCCSD energy 38 | assert np.allclose(driver.vertical_excitation_energy[n], expected_vee[n], atol=1.0e-07) 39 | assert np.allclose( 40 | driver.system.reference_energy 41 | + driver.correlation_energy 42 | + driver.vertical_excitation_energy[n], 43 | expected_total_energy[n], atol=1.0e-07 44 | ) 45 | if __name__ == "__main__": 46 | test_eomccsd_ch() 47 | -------------------------------------------------------------------------------- /tests/ch/test_eomccsdt1_ch.py: -------------------------------------------------------------------------------- 1 | """EOMCCSDt computation for the open-shell CH molcule.""" 2 | 3 | import pytest 4 | from pathlib import Path 5 | import numpy as np 6 | from ccpy import Driver, get_active_triples_pspace 7 | 8 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 9 | 10 | @pytest.mark.short 11 | def test_eomccsdt1_ch(): 12 | driver = Driver.from_gamess( 13 | logfile=TEST_DATA_DIR + "/ch/ch.log", 14 | fcidump=TEST_DATA_DIR + "/ch/ch.FCIDUMP", 15 | nfrozen=1, 16 | ) 17 | driver.system.print_info() 18 | driver.system.set_active_space(nact_occupied=1, nact_unoccupied=1) 19 | 20 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="B2") 21 | 22 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 23 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 24 | driver.run_guess(method="cis", multiplicity=2, roots_per_irrep={"A1": 1, "B1": 1, "B2": 0, "A2": 1}) 25 | 26 | r3_excitations = get_active_triples_pspace(driver.system, target_irrep=None) 27 | for istate in [1, 2, 3]: 28 | driver.run_eomccp(method="eomccsdt_p", state_index=istate, r3_excitations=r3_excitations, t3_excitations=t3_excitations) 29 | 30 | expected_vee = [0.0, 0.11287040, 0.00015539, 0.12326569] 31 | expected_total_energy = [-38.38596742 + omega for omega in expected_vee] 32 | 33 | # Check reference energy 34 | assert np.allclose(driver.system.reference_energy, -38.2713247488, atol=1.0e-07) 35 | for n in range(4): 36 | if n == 0: 37 | # Check CCSDt energy 38 | assert np.allclose(driver.correlation_energy, -0.11464267, atol=1.0e-07) 39 | assert np.allclose( 40 | driver.system.reference_energy + driver.correlation_energy, -38.38596742, atol=1.0e-07 41 | ) 42 | else: 43 | # Check EOMCCSDt energy 44 | assert np.allclose(driver.vertical_excitation_energy[n], expected_vee[n], atol=1.0e-07) 45 | assert np.allclose( 46 | driver.system.reference_energy 47 | + driver.correlation_energy 48 | + driver.vertical_excitation_energy[n], 49 | expected_total_energy[n], atol=1.0e-07 50 | ) 51 | 52 | if __name__ == "__main__": 53 | test_eomccsdt1_ch() 54 | -------------------------------------------------------------------------------- /tests/ch/test_eomccsdt_ch.py: -------------------------------------------------------------------------------- 1 | """ EOMCCSDT computation for the CH+ molecule at R = Re, where 2 | Re = 2.13713 bohr described using the Olsen basis set.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_eomccsdt_ch(): 13 | 14 | driver = Driver.from_gamess( 15 | logfile=TEST_DATA_DIR + "/ch/ch.log", 16 | fcidump=TEST_DATA_DIR + "/ch/ch.FCIDUMP", 17 | nfrozen=1, 18 | ) 19 | driver.system.print_info() 20 | driver.options["maximum_iterations"] = 100 21 | driver.options["davidson_max_subspace_size"] = 50 22 | driver.run_cc(method="ccsdt") 23 | driver.run_hbar(method="ccsdt") 24 | driver.run_guess(method="cis", multiplicity=2, roots_per_irrep={"A1": 1, "B1": 1, "B2": 0, "A2": 1}) 25 | driver.run_eomcc(method="eomccsdt", state_index=[1, 2, 3]) 26 | # Run left CCSDT for ground and excited states 27 | driver.options["energy_shift"] = 0.0 28 | driver.run_leftcc(method="left_ccsdt", state_index=[0, 1, 2, 3]) 29 | 30 | expected_ref_energy = -38.27132475 31 | expected_cc_energy = -38.38774854 32 | expected_corr_energy = -0.11642379 33 | expected_vee = [0.0, 0.11075965, 0.00001342, 0.12216165] 34 | expected_total_energy = [expected_cc_energy + omega for omega in expected_vee] 35 | 36 | # Check reference energy 37 | assert np.allclose(driver.system.reference_energy, expected_ref_energy, atol=1.0e-07) 38 | for n in range(len(expected_vee)): 39 | if n == 0: 40 | # Check CCSDT energy 41 | assert np.allclose(driver.correlation_energy, expected_corr_energy, atol=1.0e-07) 42 | assert np.allclose( 43 | driver.system.reference_energy + driver.correlation_energy, expected_cc_energy, 44 | atol=1.0e-07 45 | ) 46 | else: 47 | # Check EOMCCSDT energy 48 | assert np.allclose(driver.vertical_excitation_energy[n], expected_vee[n], atol=1.0e-07) 49 | assert np.allclose( 50 | driver.system.reference_energy 51 | + driver.correlation_energy 52 | + driver.vertical_excitation_energy[n], 53 | expected_total_energy[n], atol=1.0e-07 54 | ) 55 | 56 | if __name__ == "__main__": 57 | test_eomccsdt_ch() 58 | -------------------------------------------------------------------------------- /tests/ch2/test_adaptive_ch2.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import numpy as np 3 | from ccpy.drivers.driver import Driver 4 | from ccpy.drivers.adaptive import AdaptEOMDriverSS 5 | 6 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 7 | 8 | def test_adaptive_ch2(): 9 | driver = Driver.from_gamess( 10 | logfile=TEST_DATA_DIR + "/ch2/ch2-avdz-koch.log", 11 | fcidump=TEST_DATA_DIR + "/ch2/ch2-avdz-koch.FCIDUMP", 12 | nfrozen=0, 13 | ) 14 | driver.system.print_info() 15 | 16 | adaptdriver = AdaptEOMDriverSS(driver, state_index=1, roots_per_irrep={"B1": 1}, multiplicity=1, 17 | nacto=3, nactu=3, 18 | percentage=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) 19 | adaptdriver.options["energy_tolerance"] = 1.0e-09 20 | 21 | adaptdriver.run() 22 | 23 | if __name__ == "__main__": 24 | test_adaptive_ch2() 25 | -------------------------------------------------------------------------------- /tests/ch2/test_cc2_ch2.py: -------------------------------------------------------------------------------- 1 | """ CC2 computation for the singlet ground state of the 2 | CH2 molecule using a customized aug-cc-pVDZ basis set that 3 | takes the Dunning cc-pVDZ basis set and adds a diffuse s 4 | function to both the C and H atoms. 5 | Reference: Chem. Phys. Lett. 244, 75 (1995) 6 | """ 7 | 8 | from pathlib import Path 9 | import numpy as np 10 | from ccpy.drivers.driver import Driver 11 | 12 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 13 | 14 | def test_cc2_ch2(): 15 | driver = Driver.from_gamess( 16 | logfile=TEST_DATA_DIR + "/ch2/ch2-avdz-koch.log", 17 | fcidump=TEST_DATA_DIR + "/ch2/ch2-avdz-koch.FCIDUMP", 18 | nfrozen=0, 19 | ) 20 | driver.system.print_info() 21 | 22 | driver.options["RHF_symmetry"] = False 23 | driver.run_cc(method="cc2") 24 | #driver.run_hbar(method="cc2") 25 | #driver.run_guess(method="cisd", roots_per_irrep={"A1": 3, "B1": 3, "B2": 2, "A2": 1}, multiplicity=1, nact_occupied=2, nact_unoccupied=4) 26 | #driver.run_eomcc(method="eomcc2", state_index=[1, 2, 3, 4, 5, 6, 7, 8, 9]) 27 | 28 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -38.99447317, atol=1.0e-07) 29 | 30 | if __name__ == "__main__": 31 | test_cc2_ch2() 32 | -------------------------------------------------------------------------------- /tests/ch2/test_cc3_ch2.py: -------------------------------------------------------------------------------- 1 | """ CC3 computation for the singlet ground state of the 2 | CH2 molecule using a customized aug-cc-pVDZ basis set that 3 | takes the Dunning cc-pVDZ basis set and adds a diffuse s 4 | function to both the C and H atoms. 5 | Reference: Chem. Phys. Lett. 244, 75 (1995) 6 | """ 7 | 8 | from pathlib import Path 9 | import numpy as np 10 | from ccpy.drivers.driver import Driver 11 | 12 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 13 | 14 | def test_cc3_ch2(): 15 | driver = Driver.from_gamess( 16 | logfile=TEST_DATA_DIR + "/ch2/ch2-avdz-koch.log", 17 | fcidump=TEST_DATA_DIR + "/ch2/ch2-avdz-koch.FCIDUMP", 18 | nfrozen=0, 19 | ) 20 | driver.system.print_info() 21 | 22 | #driver.options["diis_out_of_core"] = True 23 | #driver.options["davidson_out_of_core"] = True 24 | driver.run_cc(method="cc3") 25 | 26 | # Check the CC3 total energy 27 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -39.024868, atol=1.0e-07) 28 | 29 | driver.run_hbar(method="cc3") 30 | driver.run_guess(method="cisd", roots_per_irrep={"A1": 3, "B1": 3, "B2": 2, "A2": 1}, multiplicity=1, nact_occupied=2, nact_unoccupied=4) 31 | #driver.options["RHF_symmetry"] = False 32 | driver.run_eomcc(method="eomcc3", state_index=[1, 2, 3, 4, 5, 6, 7, 8, 9]) 33 | 34 | expected_ref_energy = -38.88142579 35 | expected_corr_energy = -0.14344228 36 | expected_vee = [0.0, 37 | 0.18837284, # 38 | 0.23924155, # 39 | 0.31138281, # 40 | 0.06571101, # 41 | 0.06571101, # 0.34831055, this was changed when orthonormalized B0 matrix was removed 42 | 0.06571101, # 43 | 0.28371563, # 44 | 0.31357745, # 45 | 0.21528220] # 46 | 47 | for i in range(10): 48 | computed_total_energy = driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[i] 49 | expected_total_energy = expected_ref_energy + expected_corr_energy + expected_vee[i] 50 | assert np.allclose(computed_total_energy, expected_total_energy, atol=1.0e-07) 51 | 52 | if __name__ == "__main__": 53 | test_cc3_ch2() 54 | -------------------------------------------------------------------------------- /tests/ch2/test_deaeom4_ch2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_deaeom4_ch2(): 6 | 7 | mol = gto.M(atom=[["C", (0.0, 0.0, 0.0)], 8 | ["H", (0.0, 1.644403, -1.32213)], 9 | ["H", (0.0, -1.644403, -1.32213)]], 10 | basis="6-31g", 11 | charge=2, 12 | symmetry="C2V", 13 | cart=True, 14 | spin=0, 15 | unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.system.print_info() 21 | 22 | driver.options["davidson_out_of_core"] = True 23 | driver.run_cc(method="ccsd") 24 | driver.run_hbar(method="ccsd") 25 | driver.run_guess(method="deacis", multiplicity=-1, nact_unoccupied=5, roots_per_irrep={"A1": 6}, use_symmetry=False) 26 | driver.run_deaeomcc(method="deaeom4", state_index=[0, 1, 2, 3, 4, 5]) 27 | 28 | expected_vee = [-1.20632891, -1.22803218, -1.14348083, -1.04281182, -0.91190576, -0.88424966] 29 | for i in range(len(expected_vee)): 30 | assert np.allclose(expected_vee[i], driver.vertical_excitation_energy[i], atol=1.0e-07) 31 | 32 | if __name__ == "__main__": 33 | test_deaeom4_ch2() 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/ch2/test_deaeom4_p_ch2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver, get_active_4p2h_pspace 4 | 5 | def test_deaeom4_p_ch2(): 6 | 7 | mol = gto.M(atom=[["C", (0.0, 0.0, 0.0)], 8 | ["H", (0.0, 1.644403, -1.32213)], 9 | ["H", (0.0, -1.644403, -1.32213)]], 10 | basis="6-31g", 11 | charge=2, 12 | symmetry="C2V", 13 | cart=True, 14 | spin=0, 15 | unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.system.set_active_space(nact_occupied=0, nact_unoccupied=driver.system.nunoccupied_alpha) 21 | driver.system.print_info() 22 | 23 | driver.options["davidson_out_of_core"] = True 24 | driver.run_cc(method="ccsd") 25 | driver.run_hbar(method="ccsd") 26 | driver.run_guess(method="deacis", multiplicity=-1, nact_unoccupied=5, roots_per_irrep={"A1": 6}, use_symmetry=False) 27 | 28 | r3_excitations = get_active_4p2h_pspace(driver.system, target_irrep=None) 29 | for i in [0, 1, 2, 3, 4, 5]: 30 | driver.run_deaeomccp(method="deaeom4_p", state_index=i, r3_excitations=r3_excitations) 31 | 32 | expected_vee = [-1.20632891, -1.22803218, -1.14348083, -1.04281182, -0.91190576, -0.88424966] 33 | for i in range(len(expected_vee)): 34 | assert np.allclose(expected_vee[i], driver.vertical_excitation_energy[i], atol=1.0e-07) 35 | 36 | if __name__ == "__main__": 37 | test_deaeom4_p_ch2() 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/ch2/test_dipeom4_ch2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_dipeom4_ch2(): 6 | 7 | mol = gto.M(atom=[["C", (0.0, 0.0, 0.0)], 8 | ["H", (0.0, 1.644403, -1.32213)], 9 | ["H", (0.0, -1.644403, -1.32213)]], 10 | basis="6-31g", 11 | charge=-2, 12 | symmetry="C2V", 13 | cart=True, 14 | spin=0, 15 | unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.options["RHF_symmetry"] = False 21 | 22 | driver.run_cc(method="ccsd") 23 | driver.run_hbar(method="ccsd") 24 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"A1": 6}, use_symmetry=False) 25 | driver.run_dipeomcc(method="dipeom4", state_index=[0, 1, 2, 3, 4, 5]) 26 | 27 | # 28 | # Check the results 29 | # 30 | expected_vee = [-0.47006858, -0.44903598, -0.38539205, -0.28546072, -0.25449691, -0.22891625] 31 | for i in range(len(expected_vee)): 32 | assert np.allclose(expected_vee[i], driver.vertical_excitation_energy[i], atol=1.0e-07) 33 | 34 | if __name__ == "__main__": 35 | test_dipeom4_ch2() 36 | -------------------------------------------------------------------------------- /tests/ch2/test_dipeom4star_ch2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_dipeom4star_ch2(): 6 | 7 | mol = gto.M(atom=[["C", (0.0, 0.0, 0.0)], 8 | ["H", (0.0, 1.644403, -1.32213)], 9 | ["H", (0.0, -1.644403, -1.32213)]], 10 | basis="6-31g", 11 | charge=-2, 12 | symmetry="C2V", 13 | cart=True, 14 | spin=0, 15 | unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.options["RHF_symmetry"] = False 21 | 22 | driver.run_cc(method="ccsd") 23 | driver.run_hbar(method="ccsdta") 24 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"A1": 6}, use_symmetry=False) 25 | driver.run_dipeomcc(method="dipeom3", state_index=[0, 1]) 26 | driver.run_dipccp4(method="dipeomccsdta_star", state_index=[0, 1]) 27 | 28 | # 29 | # Check the results 30 | # 31 | expected_vee = [-0.456636415364, -0.440094626855] 32 | expected_correction = [-0.021716102147627467, -0.022139900346410033] 33 | # 34 | # Check the results 35 | # 36 | assert np.allclose(driver.correlation_energy, -0.10559024413233081) 37 | for i in range(len(expected_vee)): 38 | assert np.allclose(driver.vertical_excitation_energy[i], expected_vee[i]) 39 | assert np.allclose(driver.deltap4[i]["A"], expected_correction[i]) 40 | 41 | if __name__ == "__main__": 42 | test_dipeom4star_ch2() 43 | -------------------------------------------------------------------------------- /tests/ch2/test_sfeomcc23_ch2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_sfeomcc23_ch2(): 6 | 7 | mol = gto.M(atom=[["C", (0.0, 0.0, 0.0)], 8 | ["H", (0.0, 1.644403, -1.32213)], 9 | ["H", (0.0, -1.644403, -1.32213)]], 10 | basis="6-31g", 11 | charge=0, 12 | symmetry="C2V", 13 | cart=True, 14 | spin=2, 15 | unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="sfcis", multiplicity=1, roots_per_irrep={"A1": 2}, nact_occupied=0, nact_unoccupied=0) 23 | driver.run_sfeomcc(method="sfeomcc23", state_index=[0, 1]) 24 | 25 | if __name__ == "__main__": 26 | test_sfeomcc23_ch2() -------------------------------------------------------------------------------- /tests/ch2/test_sfeomccsd_ch2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_sfeomccsd_ch2(): 6 | 7 | mol = gto.M(atom=[["C", (0.0, 0.0, 0.0)], 8 | ["H", (0.0, 1.644403, -1.32213)], 9 | ["H", (0.0, -1.644403, -1.32213)]], 10 | basis="cc-pVDZ", 11 | charge=0, 12 | symmetry="C2V", 13 | cart=True, 14 | spin=2, 15 | unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="sfcis", multiplicity=1, roots_per_irrep={"A1": 2}, nact_occupied=0, nact_unoccupied=0) 23 | driver.run_sfeomcc(method="sfeomccsd", state_index=[0, 1]) 24 | 25 | if __name__ == "__main__": 26 | test_sfeomccsd_ch2() -------------------------------------------------------------------------------- /tests/chplus/test_adaptiveSS_chplus.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import numpy as np 3 | from ccpy import Driver, AdaptEOMDriverSS 4 | 5 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 6 | 7 | def test_adaptive_chplus(): 8 | driver = Driver.from_gamess( 9 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 10 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 11 | nfrozen=0, 12 | ) 13 | driver.system.print_info() 14 | driver.options["maximum_iterations"] = 500 15 | 16 | adaptdriver = AdaptEOMDriverSS(driver, state_index=2, roots_per_irrep={"B1": 2}, multiplicity=1, 17 | nacto=3, nactu=3, 18 | percentage=[0.0, 1.0, 2.0]) 19 | adaptdriver.options["energy_tolerance"] = 1.0e-09 20 | adaptdriver.run() 21 | 22 | # 23 | # Check the results 24 | # 25 | expected_ccp_energy = np.array([[-38.0176701646, -38.0188907303, -38.0191328777], 26 | [-37.4864870005, -37.4950227271, -37.4964737979]]) # nstates x niter 27 | 28 | expected_ccpq_energy = np.array([[-38.0194527234, -38.0194961897, -38.0195020270], 29 | [-37.4953377145, -37.4976835560, -37.4979710033]]) # nstates x niter 30 | 31 | for imacro in range(expected_ccpq_energy.shape[1]): 32 | assert np.allclose(expected_ccp_energy[0, imacro], adaptdriver.ccp_energy[imacro], atol=1.0e-07) 33 | assert np.allclose(expected_ccpq_energy[0, imacro], adaptdriver.ccpq_energy[imacro], atol=1.0e-07) 34 | assert np.allclose(expected_ccp_energy[1, imacro], adaptdriver.eomccp_energy[imacro], atol=1.0e-07) 35 | assert np.allclose(expected_ccpq_energy[1, imacro], adaptdriver.eomccpq_energy[imacro], atol=1.0e-07) 36 | 37 | if __name__ == "__main__": 38 | test_adaptive_chplus() 39 | -------------------------------------------------------------------------------- /tests/chplus/test_adaptive_chplus.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from pathlib import Path 3 | import numpy as np 4 | from ccpy import Driver, AdaptEOMDriver 5 | 6 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 7 | 8 | @pytest.mark.short 9 | def test_adaptive_chplus(): 10 | driver = Driver.from_gamess( 11 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 12 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 13 | nfrozen=0, 14 | ) 15 | driver.system.print_info() 16 | driver.options["maximum_iterations"] = 500 17 | 18 | adaptdriver = AdaptEOMDriver(driver, state_index=[2, 3, 4], roots_per_irrep={"A1": 4}, multiplicity=1, 19 | nacto=3, nactu=3, 20 | percentage=[0.0, 1.0, 2.0], 21 | unify=False) 22 | adaptdriver.options["energy_tolerance"] = 1.0e-09 23 | adaptdriver.run() 24 | 25 | # 26 | # Check the results 27 | # 28 | expected_ccp_energy = np.array([[-38.0176701646, -38.0188907303, -38.0191328777], 29 | [-37.6829267747, -37.6912855965, -37.6943482722], 30 | [-37.5186014338, -37.5201713506, -37.5215116130], 31 | [-37.3813352631, -37.3850813316, -37.3857913733]]) # nstates x niter 32 | 33 | expected_ccpq_energy = np.array([[-38.0194527234, -38.0194961897, -38.0195020270], 34 | [-37.7012481973, -37.7018945048, -37.7021483576], 35 | [-37.5216701032, -37.5222483557, -37.5223309649], 36 | [-37.3859179808, -37.3868390816, -37.3867279384]]) # nstates x niter 37 | 38 | for istate, (e_ccp, e_ccpq) in enumerate(zip(expected_ccp_energy, expected_ccpq_energy)): 39 | for imacro in range(len(e_ccp)): 40 | assert np.allclose(e_ccp[imacro], adaptdriver.ccp_energy[istate, imacro], atol=1.0e-07) 41 | assert np.allclose(e_ccpq[imacro], adaptdriver.ccpq_energy[istate, imacro], atol=1.0e-07) 42 | 43 | 44 | if __name__ == "__main__": 45 | test_adaptive_chplus() 46 | -------------------------------------------------------------------------------- /tests/chplus/test_cc3_chplus.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import numpy as np 3 | from ccpy import Driver 4 | 5 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 6 | 7 | def test_cc3_chplus(): 8 | driver = Driver.from_gamess( 9 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 10 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 11 | nfrozen=0, 12 | ) 13 | driver.system.print_info() 14 | driver.options["RHF_symmetry"] = True # left CC(P) for 4 Sigma^+ needs (4,4) guess space 15 | driver.options["maximum_iterations"] = 500 16 | 17 | # Run CC3 18 | driver.run_cc(method="cc3") 19 | driver.run_hbar(method="cc3") 20 | 21 | # Initial guess 22 | driver.run_guess(method="cisd", multiplicity=1, roots_per_irrep={"A1": 4, "B1": 2, "B2": 0, "A2": 2}, nact_occupied=3, nact_unoccupied=11) 23 | # Run excited-state CC3 24 | roots = [2, 3, 4, 5, 6, 7, 8] 25 | irreps = ["A1", "A1", "A1", "A1", "B1", "B1", "A2", "A2"] 26 | driver.run_eomcc(method="eomcc3", state_index=roots) 27 | 28 | # 29 | # Check the results 30 | # 31 | energy_ccsdt = [-38.019516, -37.702621, -37.522457, -37.386872, # sigma states 32 | -37.900921, -37.498143, # pi states 33 | -37.762113, -37.402308] # delta states 34 | 35 | energy_cc3 = [(driver.system.reference_energy 36 | + driver.correlation_energy 37 | + driver.vertical_excitation_energy[i]) for i in [0] + roots] 38 | 39 | for i, (ecc3, eccsdt) in enumerate(zip(energy_cc3, energy_ccsdt)): 40 | print(f"Error in root {i}, ({irreps[i]}) = {np.round((ecc3 - eccsdt) * 1000, 4)} mEh") 41 | 42 | if __name__ == "__main__": 43 | test_cc3_chplus() 44 | -------------------------------------------------------------------------------- /tests/chplus/test_creacc23_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSD(2h-1p) computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_eaeom2_chplus(): 13 | driver = Driver.from_gamess( 14 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 15 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 16 | nfrozen=0, 17 | ) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 23 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2}) 24 | driver.run_eaeomcc(method="eaeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 25 | driver.run_lefteaeomcc(method="left_eaeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 26 | driver.run_eaccp3(method="creacc23", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 27 | 28 | # 29 | # Check the results 30 | # 31 | expected_vee = [-0.19558721, -0.16826126, -0.37794266, -0.08109635, -0.37794266, -0.08109635, -0.29285023, -0.19558721] 32 | expected_crcc23 = [-38.2862219438, -38.2467552810, -38.3950222424, -38.0988834026, -38.3950222424, -38.0988834026, -38.3741059608, -38.2881834536] 33 | for i, (vee, veep3) in enumerate(zip(expected_vee, expected_crcc23)): 34 | assert np.allclose(driver.vertical_excitation_energy[i], vee, atol=1.0e-07, rtol=1.0e-07) 35 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[i] + driver.deltap3[i]["D"], veep3, atol=1.0e-07, rtol=1.0e-07) 36 | 37 | if __name__ == "__main__": 38 | test_eaeom2_chplus() 39 | -------------------------------------------------------------------------------- /tests/chplus/test_eaeom2_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSD(2h-1p) computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_eaeom2_chplus(): 13 | driver = Driver.from_gamess( 14 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 15 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 16 | nfrozen=0, 17 | ) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 23 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2}) 24 | driver.run_eaeomcc(method="eaeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 25 | 26 | # 27 | # Check the results 28 | # 29 | expected_vee = [-0.19558721, -0.16826126, -0.37794266, -0.08109635, -0.37794266, -0.08109635, -0.29285023, -0.19558721] 30 | for i, vee in enumerate(expected_vee): 31 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 32 | 33 | if __name__ == "__main__": 34 | test_eaeom2_chplus() 35 | -------------------------------------------------------------------------------- /tests/chplus/test_eaeom3_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSD(3p-2h) computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_eaeom3_chplus(): 13 | driver = Driver.from_gamess( 14 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 15 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 16 | nfrozen=0, 17 | ) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 23 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2}) 24 | driver.run_eaeomcc(method="eaeom3", state_index=[0, 1, 2, 3, 4, 5, 6]) 25 | 26 | # 27 | # Check the results 28 | # 29 | expected_vee = [-0.26411607, -0.22435764, -0.37815570, -0.08130247, -0.37815570, -0.08130247, -0.35696964] 30 | for i, vee in enumerate(expected_vee): 31 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 32 | 33 | if __name__ == "__main__": 34 | test_eaeom3_chplus() 35 | -------------------------------------------------------------------------------- /tests/chplus/test_eaeomccsdtastar_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSDT(a)* computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | import numpy as np 5 | from ccpy import Driver 6 | from pyscf import gto, scf 7 | 8 | def test_eaeomccsdtastar_chplus(): 9 | 10 | # Define molecule geometry and basis set 11 | basis = '6-31g' 12 | geom = [["C", (0.0, 0.0, 0.0)], 13 | ["H", (0.0, 0.0, 2.13713)]] 14 | 15 | mol = gto.M(atom=geom, basis=basis, spin=0, symmetry="C2V", charge=1, unit="Bohr") 16 | mf = scf.RHF(mol) 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=0) 20 | driver.system.print_info() 21 | 22 | driver.run_cc(method="ccsd") 23 | driver.run_hbar(method="ccsdta") 24 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 25 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 0, "A2": 2}) 26 | driver.run_eaeomcc(method="eaeom2", state_index=[0, 1, 2, 3, 4, 5]) 27 | driver.run_lefteaeomcc(method="left_eaeom2", state_index=[0, 1, 2, 3, 4, 5]) 28 | driver.run_eaccp3(method="eaeomccsdta_star", state_index=[0, 1, 2, 3, 4, 5]) 29 | 30 | # 31 | # Check the results 32 | # 33 | expected_vee = [-0.2328008158291373, 34 | -0.1993847903983961, 35 | -0.3641487642700113, 36 | -0.04101898766682737, 37 | -0.34036045427281636, 38 | -0.23280077881783232] 39 | 40 | for i, vee in enumerate(expected_vee): 41 | assert np.allclose(driver.vertical_excitation_energy[i] + driver.deltap3[i]["A"], vee, atol=1.0e-06) 42 | 43 | if __name__ == "__main__": 44 | test_eaeomccsdtastar_chplus() 45 | -------------------------------------------------------------------------------- /tests/chplus/test_eomccsdt_chplus.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import numpy as np 3 | from pathlib import Path 4 | from ccpy import Driver 5 | 6 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 7 | 8 | @pytest.mark.short 9 | def test_eomccsdt_chplus(): 10 | driver = Driver.from_gamess( 11 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 12 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 13 | nfrozen=0, 14 | ndelete=0, 15 | ) 16 | driver.system.print_info() 17 | driver.run_cc(method="ccsdt") 18 | driver.run_hbar(method="ccsdt") 19 | driver.run_guess(method="cisd", multiplicity=1, roots_per_irrep={"A1": 4, "B1": 2, "B2": 0, "A2": 2}, nact_occupied=3, nact_unoccupied=7) 20 | 21 | driver.options["davidson_max_subspace_size"] = 50 22 | driver.run_eomcc(method="eomccsdt", state_index=[2, 3, 4, 5, 6, 7, 8]) 23 | 24 | expected_ref_energy = -37.90276818 25 | expected_cc_energy = -38.01951563 26 | expected_corr_energy = -0.11674744 27 | expected_vee = [0.0, 0.0, 0.31689457, 0.49705838, 0.63264386, 0.11859434, 0.52137274, 0.25740252, 0.61720742] 28 | expected_total_energy = [expected_cc_energy + omega for omega in expected_vee] 29 | 30 | # Check reference energy 31 | assert np.allclose(driver.system.reference_energy, expected_ref_energy, atol=1.0e-07) 32 | for n in [0, 1, 2, 3, 4, 5, 6, 7, 8]: 33 | if n == 0: 34 | # Check CCSDT energy 35 | assert np.allclose(driver.correlation_energy, expected_corr_energy, atol=1.0e-07) 36 | assert np.allclose( 37 | driver.system.reference_energy + driver.correlation_energy, expected_cc_energy, 38 | atol=1.0e-07 39 | ) 40 | else: 41 | # Check EOMCCSDT energy 42 | assert np.allclose(driver.vertical_excitation_energy[n], expected_vee[n], atol=1.0e-07) 43 | assert np.allclose( 44 | driver.system.reference_energy 45 | + driver.correlation_energy 46 | + driver.vertical_excitation_energy[n], 47 | expected_total_energy[n], 48 | atol=1.0e-07 49 | ) 50 | 51 | 52 | if __name__ == "__main__": 53 | test_eomccsdt_chplus() 54 | -------------------------------------------------------------------------------- /tests/chplus/test_eomccsdtastar_chplus.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pathlib import Path 3 | from ccpy import Driver 4 | from ccpy.constants.constants import hartreetoeV 5 | 6 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 7 | 8 | def test_eomccsdtastar_chplus(): 9 | driver = Driver.from_gamess( 10 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 11 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 12 | nfrozen=0, 13 | ndelete=0, 14 | ) 15 | driver.system.print_info() 16 | # Run ground-state CC calculation 17 | driver.run_cc(method="ccsd") 18 | driver.run_hbar(method="ccsdta") 19 | # Run excited-state EOMCC calculation 20 | driver.run_guess(method="cisd", multiplicity=1, roots_per_irrep={"A1": 4, "B1": 2, "B2": 0, "A2": 2}, nact_occupied=3, nact_unoccupied=7) 21 | driver.run_eomcc(method="eomccsd", state_index=[2, 3, 4, 5, 6, 7, 8]) 22 | driver.run_lefteomcc(method="left_ccsd", state_index=[2, 3, 4, 5, 6, 7, 8]) 23 | # Compute EOMCCSDT(a)* excited-state corrections 24 | driver.run_ccp3(method="eomccsdta_star", state_index=[0, 2, 3, 4, 5, 6, 7, 8]) 25 | 26 | # 27 | # Check the results 28 | # 29 | assert np.allclose(driver.correlation_energy, -0.11587601076883182) 30 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -38.018644194459256) 31 | # 32 | expected_vee_eomccsd = [0.3354923755, 0.4997656842, 0.6371275358, 0.1205517602, 0.5321109625, 0.2907349366, 0.6509314995] 33 | expected_delta_star = [-0.0132113073, -0.0025074237, -0.0036117876, -0.0017407286, -0.0047324606, -0.0235589830, -0.0230871240] 34 | for i, istate in enumerate([2, 3, 4, 5, 6, 7, 8]): 35 | assert np.allclose(driver.vertical_excitation_energy[istate], expected_vee_eomccsd[i]) 36 | assert np.allclose(driver.deltap3[istate]["A"], expected_delta_star[i]) 37 | 38 | # 39 | # Compare EOMCCSDT(a)* and EOMCCSDT vertical excitation energies 40 | # 41 | print("") 42 | e0_ccsdt = -38.019516 43 | exc_ccsdt = [-37.702621, -37.522457, -37.386872, -37.900921, -37.498143, -37.762113, -37.402308] 44 | for i, istate in enumerate([2, 3, 4, 5, 6, 7, 8]): 45 | vee_ccsdt = (exc_ccsdt[i] - e0_ccsdt) * hartreetoeV 46 | vee_star = (driver.vertical_excitation_energy[istate] + driver.deltap3[istate]["A"]) * hartreetoeV 47 | print(f" Root {i + 1}: EOMCCSDT(a)* = {np.round(vee_star, 4)} eV EOMCCSDT = {np.round(vee_ccsdt, 4)} eV") 48 | 49 | 50 | if __name__ == "__main__": 51 | test_eomccsdtastar_chplus() 52 | -------------------------------------------------------------------------------- /tests/chplus/test_lefteaeom2_act_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSD(2h-1p) computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | from pathlib import Path 5 | import numpy as np 6 | from ccpy import Driver, get_active_3p2h_pspace 7 | 8 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 9 | 10 | def test_eaeom2_chplus(): 11 | 12 | driver = Driver.from_gamess( 13 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 14 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 15 | nfrozen=0, 16 | ) 17 | driver.system.print_info() 18 | 19 | driver.run_cc(method="ccsd") 20 | driver.run_hbar(method="ccsd") 21 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 22 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2}) 23 | driver.system.set_active_space(0, 0) 24 | r3_excitations = get_active_3p2h_pspace(driver.system, 1, target_irrep=None) 25 | for istate in [0, 1, 2, 3, 4, 5, 6, 7]: 26 | driver.run_eaeomccp(method="eaeom3_p", state_index=istate, r3_excitations=r3_excitations) 27 | driver.run_lefteaeomccp(method="left_eaeom3_p", state_index=istate, r3_excitations=r3_excitations) 28 | driver.run_eaccp3(method="creacc23", state_index=[istate]) 29 | # 30 | # Check the results 31 | # 32 | expected_vee = [-0.19558721, -0.16826126, -0.37794266, -0.08109635, -0.37794266, -0.08109635, -0.29285023, -0.19558721] 33 | for i, vee in enumerate(expected_vee): 34 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 35 | 36 | if __name__ == "__main__": 37 | test_eaeom2_chplus() 38 | -------------------------------------------------------------------------------- /tests/chplus/test_lefteaeom2_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSD(2h-1p) computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | import pytest 5 | from ccpy import Driver 6 | from pyscf import gto, scf 7 | 8 | @pytest.mark.short 9 | def test_eaeom2_chplus(): 10 | 11 | mol = gto.M( 12 | atom='''C 0.0 0.0 0.0 13 | H 0.0 0.0 1.1197868''', 14 | basis="aug-cc-pvdz", 15 | unit="angstrom", 16 | spin=0, 17 | charge=1, 18 | symmetry="c2v", 19 | ) 20 | mf = scf.RHF(mol) 21 | mf.kernel() 22 | 23 | driver = Driver.from_pyscf(mf, nfrozen=1) 24 | driver.system.print_info() 25 | 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 29 | roots_per_irrep={"B1": 1, "A1": 4, "A2": 1}) 30 | driver.run_eaeomcc(method="eaeom2", state_index=[0, 1, 2, 3, 4, 5]) 31 | driver.run_lefteaeomcc(method="left_eaeom2", state_index=[0, 1, 2, 3, 4, 5]) 32 | driver.run_eaccp3(method="creacc23", state_index=[0, 1, 2, 3, 4, 5]) 33 | 34 | if __name__ == "__main__": 35 | test_eaeom2_chplus() 36 | -------------------------------------------------------------------------------- /tests/chplus/test_lefteaeom3_chplus.py: -------------------------------------------------------------------------------- 1 | """EA-EOMCCSD(3p-2h) computation used to describe the spectrum of the 2 | open-shell CH molecule by attaching an electron to closed-shell CH+.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_eaeom3_chplus(): 13 | driver = Driver.from_gamess( 14 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 15 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 16 | nfrozen=0, 17 | ) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 23 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2}) 24 | driver.run_eaeomcc(method="eaeom3", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 25 | driver.run_lefteaeomcc(method="left_eaeom3", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 26 | 27 | # 28 | # Check the results 29 | # 30 | expected_vee = [-0.26411607, -0.22435764, -0.37815570, -0.08130247, -0.37815570, -0.08130247, -0.35696964] 31 | for i, vee in enumerate(expected_vee): 32 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 33 | 34 | if __name__ == "__main__": 35 | test_eaeom3_chplus() 36 | -------------------------------------------------------------------------------- /tests/chplus/test_lefteaeom3a_chplus.py: -------------------------------------------------------------------------------- 1 | """Active-space EA-EOMCCSD(3p-2h){Nu} (also known as EA-EOMCCSDt) calculation to 2 | describe the vertical excitation spectrum of the open-shell CH molecule by attaching 3 | an electron to CH+ closed shell.""" 4 | 5 | import pytest 6 | from pathlib import Path 7 | import numpy as np 8 | from ccpy import Driver, get_active_3p2h_pspace 9 | 10 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 11 | 12 | @pytest.mark.short 13 | def test_eaeom3a_chplus(): 14 | # Obtain the Driver from GAMESS logfile and FCIDUMP 15 | driver = Driver.from_gamess( 16 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 17 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 18 | nfrozen=0, 19 | ) 20 | driver.system.print_info() 21 | 22 | # Perform CCSD for the closed-shell core 23 | driver.run_cc(method="ccsd") 24 | # Obtain the CCSD-level similarity-transformed Hamiltonian 25 | driver.run_hbar(method="ccsd") 26 | 27 | # Set the number of active unoccupied orbitals used to define the r_{Abc}^{jk} operator 28 | driver.system.set_active_space(nact_unoccupied=3, nact_occupied=0) 29 | 30 | # Perform guess vectors by diagonalizaing within the 1p + active 2p-1h space 31 | driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8, 32 | roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2}) 33 | # Loop over all guess vectors and perform the EA-EOMCSDt calculation 34 | syms = ["A1", "A1", "B1", "B1", "B2", "B2", "A2", "A2"] 35 | for i in [0, 1, 2, 3, 4, 5, 6]: 36 | # Obtain the active-space 3p2h list 37 | r3_excitations = get_active_3p2h_pspace(driver.system, num_active=1, target_irrep=syms[i]) 38 | 39 | driver.run_eaeomccp(method="eaeom3_p", state_index=i, r3_excitations=r3_excitations) 40 | driver.run_lefteaeomccp(method="left_eaeom3_p", state_index=i, r3_excitations=r3_excitations) 41 | driver.run_eaccp3(method="eaccp3", state_index=i, r3_excitations=r3_excitations) 42 | 43 | # 44 | # Check the results 45 | # 46 | expected_vee = [-0.26354074, -0.22337561, -0.37674145, -0.08128328, -0.37674145, -0.08128328, -0.35640329] 47 | for i, vee in enumerate(expected_vee): 48 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 49 | 50 | if __name__ == "__main__": 51 | test_eaeom3a_chplus() 52 | -------------------------------------------------------------------------------- /tests/chplus/test_lefteomccsdt_chplus.py: -------------------------------------------------------------------------------- 1 | """ EOMCCSDT computation for the CH+ molecule at R = Re, where 2 | Re = 2.13713 bohr described using the Olsen basis set.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_lefteomccsdt_chplus(): 13 | 14 | driver = Driver.from_gamess( 15 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 16 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 17 | nfrozen=0, 18 | ) 19 | driver.system.print_info() 20 | driver.options["maximum_iterations"] = 600 21 | driver.options["davidson_max_subspace_size"] = 50 22 | # Run CCSDT calculation 23 | driver.run_cc(method="ccsdt") 24 | # Run CCSDT HBar 25 | driver.run_hbar(method="ccsdt") 26 | # Run EOMCCSDT 27 | driver.run_guess(method="cis", multiplicity=1, roots_per_irrep={"A1": 1, "B1": 2}) 28 | driver.run_eomcc(method="eomccsdt", state_index=[1, 2, 3]) 29 | # Run left CCSDT for ground and excited states 30 | driver.options["energy_shift"] = 0.3 31 | driver.run_leftcc(method="left_ccsdt", state_index=[0, 1, 2, 3]) 32 | 33 | expected_ref_energy = -37.90276818 34 | expected_cc_energy = -38.01951563 35 | expected_corr_energy = -0.11674744 36 | expected_vee = [0.0, 0.49705838, 0.11859434, 0.52137274] 37 | expected_total_energy = [expected_cc_energy + omega for omega in expected_vee] 38 | 39 | # Check reference energy 40 | assert np.allclose(driver.system.reference_energy, expected_ref_energy, atol=1.0e-07) 41 | for n in [0, 1, 2, 3]: 42 | if n == 0: 43 | # Check CCSDT energy 44 | assert np.allclose(driver.correlation_energy, expected_corr_energy, atol=1.0e-07) 45 | assert np.allclose( 46 | driver.system.reference_energy + driver.correlation_energy, expected_cc_energy, 47 | atol=1.0e-07 48 | ) 49 | else: 50 | # Check EOMCCSDT energy 51 | assert np.allclose(driver.vertical_excitation_energy[n], expected_vee[n], atol=1.0e-07) 52 | assert np.allclose( 53 | driver.system.reference_energy 54 | + driver.correlation_energy 55 | + driver.vertical_excitation_energy[n], 56 | expected_total_energy[n], 57 | atol=1.0e-07 58 | ) 59 | 60 | if __name__ == "__main__": 61 | test_lefteomccsdt_chplus() 62 | -------------------------------------------------------------------------------- /tests/chplus/test_lefteomccsdt_chplus_dav.py: -------------------------------------------------------------------------------- 1 | """ EOMCCSDT computation for the CH+ molecule at R = Re, where 2 | Re = 2.13713 bohr described using the Olsen basis set.""" 3 | 4 | import pytest 5 | from pathlib import Path 6 | import numpy as np 7 | from ccpy import Driver 8 | 9 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 10 | 11 | @pytest.mark.short 12 | def test_lefteomccsdt_chplus(): 13 | 14 | driver = Driver.from_gamess( 15 | logfile=TEST_DATA_DIR + "/chplus/chplus.log", 16 | fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP", 17 | nfrozen=0, 18 | ) 19 | driver.system.print_info() 20 | driver.options["maximum_iterations"] = 600 21 | driver.options["davidson_max_subspace_size"] = 50 22 | # Run CCSDT calculation 23 | driver.run_cc(method="ccsdt") 24 | # Run CCSDT HBar 25 | driver.run_hbar(method="ccsdt") 26 | # Run ground-state left-CCSDT 27 | driver.run_leftcc(method="left_ccsdt", state_index=[0]) 28 | # Run EOMCCSDT 29 | driver.run_guess(method="cis", multiplicity=1, roots_per_irrep={"A1": 1, "B1": 2}) 30 | driver.run_eomcc(method="eomccsdt", state_index=[1, 2, 3]) 31 | driver.run_lefteomcc(method="left_ccsdt", state_index=[1, 2, 3]) 32 | 33 | expected_ref_energy = -37.90276818 34 | expected_cc_energy = -38.01951563 35 | expected_corr_energy = -0.11674744 36 | expected_vee = [0.0, 0.49705838, 0.11859434, 0.52137274] 37 | expected_total_energy = [expected_cc_energy + omega for omega in expected_vee] 38 | 39 | # Check reference energy 40 | assert np.allclose(driver.system.reference_energy, expected_ref_energy, atol=1.0e-07) 41 | for n in [0, 1, 2, 3]: 42 | if n == 0: 43 | # Check CCSDT energy 44 | assert np.allclose(driver.correlation_energy, expected_corr_energy, atol=1.0e-07) 45 | assert np.allclose( 46 | driver.system.reference_energy + driver.correlation_energy, expected_cc_energy, 47 | atol=1.0e-07 48 | ) 49 | else: 50 | # Check EOMCCSDT energy 51 | assert np.allclose(driver.vertical_excitation_energy[n], expected_vee[n], atol=1.0e-07) 52 | assert np.allclose( 53 | driver.system.reference_energy 54 | + driver.correlation_energy 55 | + driver.vertical_excitation_energy[n], 56 | expected_total_energy[n], 57 | atol=1.0e-07 58 | ) 59 | 60 | if __name__ == "__main__": 61 | test_lefteomccsdt_chplus() 62 | -------------------------------------------------------------------------------- /tests/cl2/test_dipeom3_cl2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_dipeom3_cl2(): 6 | 7 | nfrozen = 10 8 | 9 | geom = [["Cl", (0.0, 0.0, 0.0)], 10 | ["Cl", (0.0, 0.0, 1.9870)]] 11 | 12 | mol = gto.M(atom=geom, basis="cc-pvdz", symmetry="D2H", unit="Angstrom", cart=False, charge=0) 13 | mf = scf.RHF(mol) 14 | mf = mf.x2c() # use SFX2C-1e scalar relativity 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=nfrozen) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | 23 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"AG": 10}, use_symmetry=False) 24 | driver.run_dipeomcc(method="dipeom3", state_index=[0, 1, 3, 4]) 25 | 26 | # 27 | # Check the results 28 | # 29 | assert np.allclose(driver.vertical_excitation_energy[0], 1.13053655, atol=1.0e-07, rtol=1.0e-07) # X ^{3}Sigma_g- 30 | assert np.allclose(driver.vertical_excitation_energy[1], 1.15018242, atol=1.0e-07, rtol=1.0e-07) # a ^{1}Delta_g 31 | assert np.allclose(driver.vertical_excitation_energy[3], 1.16267899, atol=1.0e-07, rtol=1.0e-07) # b ^{1}Sigma_g+ 32 | assert np.allclose(driver.vertical_excitation_energy[4], 1.20140782, atol=1.0e-07, rtol=1.0e-07) # c ^{1}Sigma_u- 33 | 34 | if __name__ == "__main__": 35 | test_dipeom3_cl2() 36 | -------------------------------------------------------------------------------- /tests/cl2/test_dipeom4_cl2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_dipeom4_cl2(): 6 | 7 | nfrozen = 10 8 | 9 | geom = [["Cl", (0.0, 0.0, 0.0)], 10 | ["Cl", (0.0, 0.0, 1.9870)]] 11 | 12 | mol = gto.M(atom=geom, basis="cc-pvdz", symmetry="D2H", unit="Angstrom", cart=False, charge=0) 13 | mf = scf.RHF(mol) 14 | mf = mf.x2c() # use SFX2C-1e scalar relativity 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=nfrozen) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | 23 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"A1": 10}, use_symmetry=False) 24 | driver.run_dipeomcc(method="dipeom4", state_index=[0, 1, 3, 4]) 25 | 26 | # 27 | # Check the results 28 | # 29 | assert np.allclose(driver.vertical_excitation_energy[0], 1.11368277, atol=1.0e-07, rtol=1.0e-07) # X ^{3}Sigma_g- 30 | assert np.allclose(driver.vertical_excitation_energy[1], 1.13436974, atol=1.0e-07, rtol=1.0e-07) # a ^{1}Delta_g 31 | assert np.allclose(driver.vertical_excitation_energy[3], 1.14727205, atol=1.0e-07, rtol=1.0e-07) # b ^{1}Sigma_g+ 32 | assert np.allclose(driver.vertical_excitation_energy[4], 1.18607765, atol=1.0e-07, rtol=1.0e-07) # c ^{1}Sigma_u- 33 | 34 | if __name__ == "__main__": 35 | test_dipeom4_cl2() 36 | -------------------------------------------------------------------------------- /tests/cl2/test_dipeom4star_cl2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver 4 | 5 | def test_dipeom4_cl2(): 6 | 7 | basis = '6-31g' 8 | nfrozen = 10 9 | 10 | geom = [["Cl", (0.0, 0.0, 0.0)], 11 | ["Cl", (0.0, 0.0, 1.9870)]] 12 | 13 | mol = gto.M(atom=geom, basis=basis, spin=0, symmetry="D2H", unit="Angstrom") 14 | mf = scf.RHF(mol).x2c() 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=nfrozen) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsdta") 22 | driver.run_guess(method="dipcis", multiplicity=-1, roots_per_irrep={"AG": 10}, nact_occupied=driver.system.noccupied_alpha, use_symmetry=False) 23 | # picks up: 0 -> triplet 3\Sigma_{g}^− 24 | # 1 & 2 -> singlet \Delta_{g} (2x degenerate) 25 | # 3 -> singlet \Sigma_{g}^+ 26 | # 4 -> singlet \Sigma_{u}^- 27 | driver.run_dipeomcc(method="dipeom3", state_index=[0, 1, 3, 4]) 28 | driver.run_dipccp4(method="dipeomccsdta_star", state_index=[0, 1, 3, 4]) 29 | 30 | if __name__ == "__main__": 31 | test_dipeom4_cl2() 32 | -------------------------------------------------------------------------------- /tests/cl2/test_dipeomccsdt_cl2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | from ccpy.utilities.pspace import get_active_triples_pspace 5 | from ccpy.utilities.utilities import convert_t3_from_pspace 6 | 7 | def test_dipeomccsdt_cl2(): 8 | 9 | nfrozen = 10 10 | 11 | geom = [["Cl", (0.0, 0.0, 0.0)], 12 | ["Cl", (0.0, 0.0, 1.9870)]] 13 | 14 | mol = gto.M(atom=geom, basis="cc-pvdz", symmetry="D2H", unit="Angstrom", cart=False, charge=0) 15 | mf = scf.RHF(mol) 16 | mf = mf.x2c() # Use SFX2C-1e treatment of scalar relativity 17 | mf.kernel() 18 | 19 | driver = Driver.from_pyscf(mf, nfrozen=nfrozen) 20 | driver.system.print_info() 21 | driver.system.set_active_space(nact_occupied=driver.system.noccupied_alpha, nact_unoccupied=driver.system.nunoccupied_alpha) 22 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="AG") 23 | 24 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 25 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 26 | convert_t3_from_pspace(driver, t3_excitations) 27 | 28 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"A1": 10}, use_symmetry=False) 29 | driver.run_dipeomcc(method="dipeomccsdt", state_index=[0, 1, 3, 4]) 30 | 31 | # 32 | # Check the results 33 | # 34 | assert np.allclose(driver.vertical_excitation_energy[0], 1.11738442, atol=1.0e-07, rtol=1.0e-07) # X ^{3}Sigma_g- 35 | assert np.allclose(driver.vertical_excitation_energy[1], 1.13790671, atol=1.0e-07, rtol=1.0e-07) # a ^{1}Delta_g 36 | assert np.allclose(driver.vertical_excitation_energy[3], 1.15068438, atol=1.0e-07, rtol=1.0e-07) # b ^{1}Sigma_g+ 37 | assert np.allclose(driver.vertical_excitation_energy[4], 1.18912831, atol=1.0e-07, rtol=1.0e-07) # c ^{1}Sigma_u- 38 | 39 | if __name__ == "__main__": 40 | test_dipeomccsdt_cl2() 41 | -------------------------------------------------------------------------------- /tests/cl2/test_dipeomccsdta_cl2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy.drivers.driver import Driver 4 | 5 | def test_dipeomccsdta_cl2(): 6 | 7 | nfrozen = 10 8 | 9 | geom = [["Cl", (0.0, 0.0, 0.0)], 10 | ["Cl", (0.0, 0.0, 1.9870)]] 11 | 12 | mol = gto.M(atom=geom, basis="cc-pvdz", symmetry="D2H", unit="Angstrom", cart=False, charge=0) 13 | mf = scf.RHF(mol) 14 | mf = mf.x2c() # use SFX2C-1e treatment of scalar relativity 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=nfrozen) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsdta") 22 | 23 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"A1": 10}, use_symmetry=False) 24 | driver.run_dipeomcc(method="dipeomccsdta", state_index=[0, 1, 3, 4]) 25 | 26 | # 27 | # Check the results 28 | # 29 | assert np.allclose(driver.vertical_excitation_energy[0], 1.11710195, atol=1.0e-07, rtol=1.0e-07) # X ^{3}Sigma_g- 30 | assert np.allclose(driver.vertical_excitation_energy[1], 1.13764771, atol=1.0e-07, rtol=1.0e-07) # a ^{1}Delta_g 31 | assert np.allclose(driver.vertical_excitation_energy[3], 1.15045610, atol=1.0e-07, rtol=1.0e-07) # b ^{1}Sigma_g+ 32 | assert np.allclose(driver.vertical_excitation_energy[4], 1.18895140, atol=1.0e-07, rtol=1.0e-07) # c ^{1}Sigma_u- 33 | 34 | if __name__ == "__main__": 35 | test_dipeomccsdta_cl2() 36 | -------------------------------------------------------------------------------- /tests/co/test_ipeomccsdt_co.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IP-EOMCCSDT for CO in cc-pVDZ basis set 3 | M. Musial, S. A. Kucharski, and R. J. Bartlett, J. Chem. Phys 118, 1128 (2003) 4 | ''' 5 | import numpy as np 6 | from pyscf import gto, scf 7 | 8 | def test_ipeomccsdt_co(): 9 | from ccpy import Driver, get_active_triples_pspace 10 | from ccpy.utilities.utilities import convert_t3_from_pspace 11 | 12 | geom = [["C", (0.0, 0.0, 0.0)], 13 | ["O", (0.0, 0.0, 1.128323)]] 14 | 15 | state_index = [0, 1, 3] 16 | 17 | mol = gto.M(atom=geom, 18 | basis="cc-pvdz", 19 | charge=0, 20 | symmetry="C2V", 21 | cart=False, 22 | spin=0, 23 | unit="Angstrom") 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.system.print_info() 29 | # 30 | driver.system.set_active_space(nact_occupied=driver.system.noccupied_alpha, nact_unoccupied=driver.system.nunoccupied_alpha) 31 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="A1") 32 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 33 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 34 | # 35 | convert_t3_from_pspace(driver, t3_excitations) 36 | # 37 | driver.run_guess(method="ipcisd", nact_occupied=0, nact_unoccupied=0, 38 | multiplicity=-1, roots_per_irrep={"A1": 5}, use_symmetry=False) 39 | driver.run_ipeomcc(method="ipeomccsdt", state_index=state_index) 40 | 41 | ip_energy = np.zeros(len(state_index)) 42 | for i, istate in enumerate(state_index): 43 | print(f"\nState {istate}") 44 | print("-----") 45 | ip_energy[i] = (driver.vertical_excitation_energy[istate])* 27.2114 46 | print(f"IP Energy = {ip_energy[i]} eV") 47 | 48 | expected_ip = [13.58, 16.71, 19.33] 49 | for w_calc, w_exp in zip(ip_energy, expected_ip): 50 | assert np.allclose(w_calc, w_exp, atol=1.0e-02) 51 | 52 | if __name__ == "__main__": 53 | 54 | test_ipeomccsdt_co() 55 | 56 | -------------------------------------------------------------------------------- /tests/co/test_ipeomccsdt_p_co.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IP-EOMCCSDT for CO in cc-pVDZ basis set 3 | M. Musial, S. A. Kucharski, and R. J. Bartlett, J. Chem. Phys 118, 1128 (2003) 4 | ''' 5 | import numpy as np 6 | from pyscf import gto, scf 7 | 8 | def test_ipeomccsdt_co(): 9 | from ccpy import Driver, get_active_triples_pspace, get_active_3h2p_pspace 10 | from ccpy.utilities.utilities import convert_t3_from_pspace 11 | 12 | geom = [["C", (0.0, 0.0, 0.0)], 13 | ["O", (0.0, 0.0, 1.128323)]] 14 | 15 | state_index = [0, 1, 3] 16 | 17 | mol = gto.M(atom=geom, 18 | basis="cc-pvdz", 19 | charge=0, 20 | symmetry="C2V", 21 | cart=False, 22 | spin=0, 23 | unit="Angstrom") 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.system.print_info() 29 | # 30 | driver.system.set_active_space(nact_occupied=driver.system.noccupied_alpha, nact_unoccupied=driver.system.nunoccupied_alpha) 31 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="A1") 32 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 33 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 34 | # 35 | driver.run_guess(method="ipcisd", nact_occupied=0, nact_unoccupied=0, 36 | multiplicity=-1, roots_per_irrep={"A1": 5}, use_symmetry=False) 37 | driver.system.set_active_space(nact_occupied=driver.system.noccupied_alpha, nact_unoccupied=driver.system.nunoccupied_alpha) 38 | r3_excitations = get_active_3h2p_pspace(driver.system, target_irrep=None) 39 | for i in state_index: 40 | driver.run_ipeomccp(method="ipeomccsdt_p", state_index=i, r3_excitations=r3_excitations, t3_excitations=t3_excitations) 41 | 42 | ip_energy = np.zeros(len(state_index)) 43 | for i, istate in enumerate(state_index): 44 | print(f"\nState {istate}") 45 | print("-----") 46 | ip_energy[i] = (driver.vertical_excitation_energy[istate])* 27.2114 47 | print(f"IP Energy = {ip_energy[i]} eV") 48 | 49 | expected_ip = [13.58, 16.71, 19.33] 50 | for w_calc, w_exp in zip(ip_energy, expected_ip): 51 | assert np.allclose(w_calc, w_exp, atol=1.0e-02) 52 | 53 | if __name__ == "__main__": 54 | 55 | test_ipeomccsdt_co() 56 | 57 | -------------------------------------------------------------------------------- /tests/data/chplus/olsen.gbs: -------------------------------------------------------------------------------- 1 | spherical 2 | 3 | **** 4 | C 0 5 | S 9 1.00 6 | 6.665000D+03 6.920000D-04 7 | 1.000000D+03 5.329000D-03 8 | 2.280000D+02 2.707700D-02 9 | 6.471000D+01 1.017180D-01 10 | 2.106000D+01 2.747400D-01 11 | 7.495000D+00 4.485640D-01 12 | 2.797000D+00 2.850740D-01 13 | 5.215000D-01 1.520400D-02 14 | 1.596000D-01 -3.191000D-03 15 | S 9 1.00 16 | 6.665000D+03 -1.460000D-04 17 | 1.000000D+03 -1.154000D-03 18 | 2.280000D+02 -5.725000D-03 19 | 6.471000D+01 -2.331200D-02 20 | 2.106000D+01 -6.395500D-02 21 | 7.495000D+00 -1.499810D-01 22 | 2.797000D+00 -1.272620D-01 23 | 5.215000D-01 5.445290D-01 24 | 1.596000D-01 5.804960D-01 25 | S 1 1.00 26 | 1.596000D-01 1.000000D+00 27 | S 1 1.00 28 | 0.0469000 1.0000000 29 | P 1 1.00 30 | 1.517000D-01 1.000000D+00 31 | P 1 1.00 32 | 0.0404100 1.0000000 33 | D 1 1.00 34 | 5.500000D-01 1.0000000 35 | **** 36 | 37 | -------------------------------------------------------------------------------- /tests/data/h2o/paldusTZ.gbs: -------------------------------------------------------------------------------- 1 | spherical 2 | 3 | **** 4 | H 0 5 | S 3 1.0 6 | 33.8700000 0.0060680 7 | 5.0950000 0.0453080 8 | 1.1590000 0.2028220 9 | S 1 1.0 10 | 0.3258000 1.0000000 11 | S 1 1.0 12 | 0.1027000 1.0000000 13 | **** 14 | O 0 15 | S 8 1.0 16 | 15330.0000000 0.0005080 17 | 2299.0000000 0.0039290 18 | 522.4000000 0.0202430 19 | 147.3000000 0.0791810 20 | 47.5500000 0.2306870 21 | 16.7600000 0.4331180 22 | 6.2070000 0.3502600 23 | 0.6882000 -0.0081540 24 | S 8 1.0 25 | 15330.0000000 -0.0001150 26 | 2299.0000000 -0.0008950 27 | 522.4000000 -0.0046360 28 | 147.3000000 -0.0187240 29 | 47.5500000 -0.0584630 30 | 16.7600000 -0.1364630 31 | 6.2070000 -0.1757400 32 | 0.6882000 0.6034180 33 | S 1 1.0 34 | 1.7520000 1.0000000 35 | S 1 1.0 36 | 0.2384000 1.0000000 37 | P 3 1.0 38 | 34.4600000 0.0159280 39 | 7.7490000 0.0997400 40 | 2.2800000 0.3104920 41 | P 1 1.0 42 | 0.7156000 1.0000000 43 | P 1 1.0 44 | 0.2140000 1.0000000 45 | **** 46 | 47 | -------------------------------------------------------------------------------- /tests/f2/test_adaptive_chol_f2.py: -------------------------------------------------------------------------------- 1 | """Adaptive CC(P;Q) aimed at converging CCSDT computation: 2 | F2 / cc-pVDZ at R = 2.0Re, where Re = 2.66816 bohr using RHF. 3 | Cartesian orbitals are used for the d orbitals in the cc-pVTZ basis. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | import numpy as np 6 | from pyscf import scf, gto 7 | from ccpy import Driver, AdaptDriver 8 | 9 | def test_adaptive_f2(): 10 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 11 | mol = gto.M( 12 | atom=geometry, 13 | basis="cc-pvdz", 14 | charge=0, 15 | spin=0, 16 | symmetry="D2H", 17 | cart=False, 18 | unit="Bohr", 19 | ) 20 | mf = scf.RHF(mol) 21 | mf.kernel() 22 | 23 | percentages = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] 24 | driver = Driver.from_pyscf(mf, nfrozen=2, use_cholesky=True, cholesky_tol=1.0e-07) 25 | driver.system.print_info() 26 | driver.options["RHF_symmetry"] = False 27 | adaptdriver = AdaptDriver(driver, percentage=percentages) 28 | adaptdriver.options["energy_tolerance"] = 1.0e-08 29 | adaptdriver.options["two_body_approx"] = True 30 | adaptdriver.run() 31 | 32 | # expected results using left-CCSD 2BA and no RHF symmetry (i.e., aaa/bbb and aab/abb spaces unbalanced slightly) 33 | expected_ccp = [ 34 | -199.0086195664, 35 | -199.0527329286, 36 | -199.0530779791, 37 | -199.0532073849, 38 | -199.0533070429, 39 | -199.0533798878, 40 | -199.0534507830, 41 | -199.0535185251, 42 | -199.0535755404, 43 | -199.0536243499, 44 | -199.0536676910, 45 | ] 46 | 47 | expected_ccpq = [ 48 | -199.0521040880, 49 | -199.0537746730, 50 | -199.0538819064, 51 | -199.0538670594, 52 | -199.0538628056, 53 | -199.0538564991, 54 | -199.0538697374, 55 | -199.0538861417, 56 | -199.0538948473, 57 | -199.0539047901, 58 | -199.0539150156, 59 | ] 60 | 61 | for imacro in range(len(percentages)): 62 | assert np.allclose(expected_ccp[imacro], adaptdriver.ccp_energy[imacro], rtol=1.0e-07) 63 | assert np.allclose(expected_ccpq[imacro], adaptdriver.ccpq_energy[imacro], rtol=1.0e-07) 64 | 65 | if __name__ == "__main__": 66 | test_adaptive_f2() 67 | -------------------------------------------------------------------------------- /tests/f2/test_adaptive_f2.py: -------------------------------------------------------------------------------- 1 | """Adaptive CC(P;Q) aimed at converging CCSDT computation: 2 | F2 / cc-pVDZ at R = 2.0Re, where Re = 2.66816 bohr using RHF. 3 | Cartesian orbitals are used for the d orbitals in the cc-pVTZ basis. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | import numpy as np 6 | from pyscf import scf, gto 7 | from ccpy import Driver, AdaptDriver 8 | 9 | def test_adaptive_f2(): 10 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 11 | mol = gto.M( 12 | atom=geometry, 13 | basis="cc-pvdz", 14 | charge=0, 15 | spin=0, 16 | symmetry="D2H", 17 | cart=True, 18 | unit="Bohr", 19 | ) 20 | mf = scf.RHF(mol) 21 | mf.kernel() 22 | 23 | percentages = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] 24 | driver = Driver.from_pyscf(mf, nfrozen=2) 25 | driver.system.print_info() 26 | driver.options["RHF_symmetry"] = False 27 | adaptdriver = AdaptDriver(driver, percentage=percentages) 28 | adaptdriver.options["energy_tolerance"] = 1.0e-08 29 | adaptdriver.options["two_body_approx"] = True 30 | adaptdriver.run() 31 | 32 | # expected results using left-CCSD 2BA and no RHF symmetry (i.e., aaa/bbb and aab/abb spaces unbalanced slightly) 33 | expected_ccp = [ 34 | -199.0125625783, 35 | -199.0568996806, 36 | -199.0572252039, 37 | -199.0573744420, 38 | -199.0574860760, 39 | -199.0575741030, 40 | -199.0576471614, 41 | -199.0577178858, 42 | -199.0577747214, 43 | -199.0578204962, 44 | -199.0578586940, 45 | ] 46 | 47 | expected_ccpq = [ 48 | -199.0563392932, 49 | -199.0580212546, 50 | -199.0581020430, 51 | -199.0580922836, 52 | -199.0580801695, 53 | -199.0580881229, 54 | -199.0580913749, 55 | -199.0580995675, 56 | -199.0581037187, 57 | -199.0581058065, 58 | -199.0581113016, 59 | ] 60 | 61 | for imacro in range(len(percentages)): 62 | assert np.allclose(expected_ccp[imacro], adaptdriver.ccp_energy[imacro], rtol=1.0e-07) 63 | assert np.allclose(expected_ccpq[imacro], adaptdriver.ccpq_energy[imacro], rtol=1.0e-07) 64 | 65 | if __name__ == "__main__": 66 | test_adaptive_f2() 67 | -------------------------------------------------------------------------------- /tests/f2/test_cc3_f2.py: -------------------------------------------------------------------------------- 1 | """ CC3 computation for the stretched F2 molecule at interatomic 2 | separation R = 2.0Re, where Re = 2.66816 bohr. The cc-pVDZ basis set 3 | is used with Cartesian components for the d orbitals. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_cc3_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 12 | mol = gto.M( 13 | atom=geometry, 14 | basis="cc-pvdz", 15 | charge=0, 16 | spin=0, 17 | symmetry="D2H", 18 | cart=True, 19 | unit="Bohr", 20 | ) 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | 24 | driver = Driver.from_pyscf(mf, nfrozen=2) 25 | driver.system.print_info() 26 | 27 | driver.options["RHF_symmetry"] = True 28 | #driver.options["diis_out_of_core"] = True 29 | driver.run_cc(method="cc3") 30 | 31 | assert np.allclose(driver.correlation_energy, -0.63843220, atol=1.0e-07) 32 | 33 | 34 | if __name__ == "__main__": 35 | test_cc3_f2() 36 | -------------------------------------------------------------------------------- /tests/f2/test_ccsd_chol_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_ccsd_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvtz", 16 | charge=0, 17 | spin=0, 18 | symmetry="D2H", 19 | cart=False, 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2, use_cholesky=True, cholesky_tol=1.0e-07) 26 | driver.system.print_info() 27 | driver.options["RHF_symmetry"] = False 28 | driver.run_cc(method="ccsd_chol") 29 | 30 | # Check reference energy 31 | assert np.allclose(driver.system.reference_energy, -198.48327030, atol=1.0e-07) 32 | # Check CCSD energy 33 | assert np.allclose(driver.correlation_energy, -0.69225474, atol=1.0e-07) 34 | assert np.allclose( 35 | driver.system.reference_energy + driver.correlation_energy, -199.17552504, 36 | atol=1.0e-07 37 | ) 38 | 39 | if __name__ == "__main__": 40 | test_ccsd_f2() 41 | -------------------------------------------------------------------------------- /tests/f2/test_ccsdt_f2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import scf, gto 3 | from ccpy import Driver 4 | 5 | def test_ccsdt_f2(): 6 | geometry = [["F", (0.0, 0.0, -2.66816)], 7 | ["F", (0.0, 0.0, 2.66816)]] 8 | mol = gto.M( 9 | atom=geometry, 10 | basis="cc-pvdz", 11 | charge=0, 12 | spin=0, 13 | symmetry="D2H", 14 | cart=False, 15 | unit="Bohr", 16 | ) 17 | mf = scf.RHF(mol) 18 | mf.kernel() 19 | 20 | driver = Driver.from_pyscf(mf, nfrozen=2) 21 | driver.run_cc(method="ccsdt") 22 | 23 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.05400663, rtol=1.0e-07) 24 | 25 | if __name__ == "__main__": 26 | test_ccsdt_f2() 27 | -------------------------------------------------------------------------------- /tests/f2/test_ccsdt_uhf_f2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import scf, gto 3 | from ccpy import Driver 4 | 5 | def test_ccsdt_f2(): 6 | geometry = [["F", (0.0, 0.0, -2.66816)], 7 | ["F", (0.0, 0.0, 2.66816)]] 8 | mol = gto.M( 9 | atom=geometry, 10 | basis="cc-pvdz", 11 | charge=0, 12 | spin=0, 13 | symmetry="D2H", 14 | cart=True, 15 | unit="Bohr", 16 | ) 17 | mf = scf.UHF(mol) 18 | mf.kernel() 19 | driver = Driver.from_pyscf(mf, nfrozen=2, uhf=True) 20 | driver.system.print_info() 21 | 22 | driver.options["RHF_symmetry"] = False 23 | driver.run_cc(method="ccsdt") 24 | 25 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.058201, rtol=1.0e-07, atol=1.0e-07) 26 | 27 | if __name__ == "__main__": 28 | test_ccsdt_f2() 29 | -------------------------------------------------------------------------------- /tests/f2/test_cct3_p_chol_f2.py: -------------------------------------------------------------------------------- 1 | """ CC(t;3) computation for the stretched F2 molecule at interatomic 2 | separation R = 2.0Re, where Re = 2.66816 bohr. The cc-pVDZ basis set 3 | is used with Cartesian components for the d orbitals. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver, get_active_triples_pspace 9 | 10 | def test_cct3_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 12 | mol = gto.M( 13 | atom=geometry, 14 | basis="cc-pvdz", 15 | charge=0, 16 | spin=0, 17 | symmetry="D2H", 18 | cart=False, 19 | unit="Bohr", 20 | ) 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | 24 | driver = Driver.from_pyscf(mf, nfrozen=2, use_cholesky=True, cholesky_tol=1.0e-07) 25 | driver.system.print_info() 26 | driver.system.set_active_space(nact_occupied=5, nact_unoccupied=1) 27 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="AG") 28 | 29 | driver.run_ccp(method="ccsdt_p_chol", t3_excitations=t3_excitations) 30 | driver.run_hbar(method="ccsd_chol") 31 | driver.run_leftcc(method="left_ccsd_chol") 32 | driver.run_ccp3(method="cct3_chol") 33 | 34 | # Check reference energy 35 | assert np.allclose(driver.system.reference_energy, -198.41983912, rtol=1.0e-07) 36 | # Check CCSDt energy 37 | assert np.allclose(driver.correlation_energy, -0.63244508, rtol=1.0e-07) 38 | assert np.allclose( 39 | driver.system.reference_energy + driver.correlation_energy, -199.05228420, 40 | rtol=1.0e-07 41 | ) 42 | # Check CC(t;3)_A energy 43 | assert np.allclose( 44 | driver.correlation_energy + driver.deltap3[0]["A"], -0.6337332279, rtol=1.0e-07 45 | ) 46 | assert np.allclose( 47 | driver.system.reference_energy 48 | + driver.correlation_energy 49 | + driver.deltap3[0]["A"], 50 | -199.0535722189, 51 | rtol=1.0e-07 52 | ) 53 | # Check CC(t;3)_D energy 54 | assert np.allclose( 55 | driver.correlation_energy + driver.deltap3[0]["D"], -0.6338844036, rtol=1.0e-07 56 | ) 57 | assert np.allclose( 58 | driver.system.reference_energy 59 | + driver.correlation_energy 60 | + driver.deltap3[0]["D"], 61 | -199.0537233946, 62 | rtol=1.0e-07 63 | ) 64 | 65 | if __name__ == "__main__": 66 | test_cct3_f2() 67 | -------------------------------------------------------------------------------- /tests/f2/test_cct3_p_f2.py: -------------------------------------------------------------------------------- 1 | """ CC(t;3) computation for the stretched F2 molecule at interatomic 2 | separation R = 2.0Re, where Re = 2.66816 bohr. The cc-pVDZ basis set 3 | is used with Cartesian components for the d orbitals. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver, get_active_triples_pspace 9 | 10 | def test_cct3_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 12 | mol = gto.M( 13 | atom=geometry, 14 | basis="cc-pvdz", 15 | charge=0, 16 | spin=0, 17 | symmetry="D2H", 18 | cart=True, 19 | unit="Bohr", 20 | ) 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | 24 | driver = Driver.from_pyscf(mf, nfrozen=2) 25 | driver.system.print_info() 26 | driver.system.set_active_space(nact_occupied=5, nact_unoccupied=1) 27 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="AG") 28 | 29 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 30 | driver.run_hbar(method="ccsd") 31 | driver.run_leftcc(method="left_ccsd") 32 | driver.run_ccp3(method="cct3") 33 | 34 | # Check reference energy 35 | assert np.allclose(driver.system.reference_energy, -198.4200962814, atol=1.0e-07) 36 | # Check CCSDt energy 37 | assert np.allclose(driver.correlation_energy, -0.6363154135, atol=1.0e-07) 38 | assert np.allclose( 39 | driver.system.reference_energy + driver.correlation_energy, -199.0564116949, 40 | atol=1.0e-07 41 | ) 42 | # Check CC(t;3)_A energy 43 | assert np.allclose( 44 | driver.correlation_energy + driver.deltap3[0]["A"], -0.6376818524, atol=1.0e-07 45 | ) 46 | assert np.allclose( 47 | driver.system.reference_energy 48 | + driver.correlation_energy 49 | + driver.deltap3[0]["A"], 50 | -199.0577781338, 51 | atol=1.0e-07 52 | ) 53 | # Check CC(t;3)_D energy 54 | assert np.allclose( 55 | driver.correlation_energy + driver.deltap3[0]["D"], -0.6378384699, atol=1.0e-07 56 | ) 57 | assert np.allclose( 58 | driver.system.reference_energy 59 | + driver.correlation_energy 60 | + driver.deltap3[0]["D"], 61 | -199.0579347513, 62 | atol=1.0e-07 63 | ) 64 | 65 | if __name__ == "__main__": 66 | test_cct3_f2() 67 | -------------------------------------------------------------------------------- /tests/f2/test_crcc23_chol_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD(T) computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc23_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvtz", 16 | charge=0, 17 | spin=0, 18 | symmetry="D2H", 19 | cart=False, 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2, use_cholesky=True, cholesky_tol=1.0e-07, cmax=10) 26 | driver.run_cc(method="ccsd_chol") 27 | driver.run_hbar(method="ccsd_chol") 28 | driver.run_leftcc(method="left_ccsd_chol") 29 | driver.run_ccp3(method="crcc23_chol") 30 | 31 | # Check reference energy 32 | assert np.allclose(driver.system.reference_energy, -198.48327030, rtol=1.0e-07) 33 | # Check CCSD energy 34 | assert np.allclose(driver.correlation_energy, -0.69225474, rtol=1.0e-07) 35 | assert np.allclose( 36 | driver.system.reference_energy + driver.correlation_energy, -199.17552504, 37 | rtol=1.0e-07 38 | ) 39 | # Check CR-CC(2,3)D energy 40 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -199.2340905242, rtol=1.0e-07) 41 | 42 | if __name__ == "__main__": 43 | test_crcc23_f2() 44 | -------------------------------------------------------------------------------- /tests/f2/test_crcc23_chol_triplet_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD(T) computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc23_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvdz", 16 | charge=0, 17 | spin=2, 18 | symmetry="D2H", 19 | cart=False, 20 | unit="Bohr", 21 | ) 22 | mf = scf.ROHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2, use_cholesky=True, cholesky_tol=1.0e-07) 26 | driver.run_cc(method="ccsd_chol") 27 | driver.run_hbar(method="ccsd_chol") 28 | driver.run_leftcc(method="left_ccsd_chol") 29 | driver.run_ccp3(method="crcc23_chol") 30 | 31 | # Check that CCSD total energy is correct 32 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.0007818156, rtol=1.0e-07) 33 | # Check that CR-CC(2,3)_D total energy is correct 34 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -199.0485115081, rtol=1.0e-07) 35 | 36 | if __name__ == "__main__": 37 | test_crcc23_f2() 38 | -------------------------------------------------------------------------------- /tests/f2/test_crcc23_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD(T) computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc23_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvdz", 16 | charge=0, 17 | spin=0, 18 | symmetry="D2H", 19 | cart=True, 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2) 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | driver.run_leftcc(method="left_ccsd") 29 | driver.run_ccp3(method="crcc23") 30 | 31 | # Check that CCSD total energy is correct 32 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.0125625694, atol=1.0e-07) 33 | # Check that CR-CC(2,3)_D total energy is correct 34 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -199.0563392841, atol=1.0e-07) 35 | 36 | driver.run_rdm1() 37 | driver.transform_to_natorb(0) 38 | driver.system.print_info() 39 | 40 | driver.run_cc(method="ccsd") 41 | driver.run_hbar(method="ccsd") 42 | driver.run_leftcc(method="left_ccsd") 43 | driver.run_ccp3(method="crcc23") 44 | 45 | if __name__ == "__main__": 46 | test_crcc23_f2() 47 | -------------------------------------------------------------------------------- /tests/f2/test_crcc23_triplet_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD(T) computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc23_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvdz", 16 | charge=0, 17 | spin=2, 18 | symmetry="D2H", 19 | cart=True, 20 | unit="Bohr", 21 | ) 22 | mf = scf.ROHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2) 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | driver.run_leftcc(method="left_ccsd") 29 | driver.run_ccp3(method="crcc23") 30 | 31 | # Check that CCSD total energy is correct 32 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.0046529156, rtol=1.0e-07) 33 | # Check that CR-CC(2,3)_D total energy is correct 34 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -199.0526995878, rtol=1.0e-07) 35 | 36 | if __name__ == "__main__": 37 | test_crcc23_f2() 38 | -------------------------------------------------------------------------------- /tests/f2/test_crcc23_uhf_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD(T) computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc23_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvdz", 16 | charge=0, 17 | spin=0, 18 | symmetry="D2H", 19 | cart=True, 20 | unit="Bohr", 21 | ) 22 | mf = scf.UHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2, uhf=True) 26 | # Important: Set RHF flag to false manually for UHF references 27 | driver.options["RHF_symmetry"] = False 28 | driver.system.print_info() 29 | driver.run_cc(method="ccsd") 30 | driver.run_hbar(method="ccsd") 31 | driver.run_leftcc(method="left_ccsd") 32 | driver.run_ccp3(method="crcc23") 33 | 34 | # Check that CCSD total energy is correct 35 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.0125625694, atol=1.0e-07) 36 | # Check that CR-CC(2,3)_D total energy is correct 37 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -199.0563392841, atol=1.0e-07) 38 | 39 | if __name__ == "__main__": 40 | test_crcc23_f2() 41 | -------------------------------------------------------------------------------- /tests/f2/test_crcc24_f2.py: -------------------------------------------------------------------------------- 1 | """CR-CC(2,4) computation for the stretched F2 molecule at 2 | interatomic separation R = 2.0Re, where Re = 2.66816 bohr, 3 | described using the cc-pVDZ basis set with Cartesian 4 | components used for the d orbitals. 5 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 6 | 7 | import numpy as np 8 | from pyscf import gto, scf 9 | from ccpy import Driver 10 | 11 | def test_crcc24_f2(): 12 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="cc-pvdz", 16 | charge=0, 17 | spin=0, 18 | symmetry="D2H", 19 | cart=True, 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2) 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | driver.run_leftcc(method="left_ccsd") 29 | driver.run_ccp3(method="crcc23") 30 | driver.run_ccp4(method="crcc24") 31 | 32 | # Check reference energy 33 | assert np.allclose(driver.system.reference_energy, -198.420096282673, atol=1.0e-07) 34 | # Check CCSD energy 35 | assert np.allclose(driver.correlation_energy, -0.59246629, atol=1.0e-07) 36 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.01256257, atol=1.0e-07) 37 | # Check CR-CC(2,3)_D energy 38 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -199.0563392841, atol=1.0e-07) 39 | # Check CR-CC(2,4)_AA energy 40 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["A"] + driver.deltap4[0]["A"], -199.05642649630002, atol=1.0e-07) 41 | # Check CR-CC(2,4)_DA energy 42 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"] + driver.deltap4[0]["A"], -199.0609214773, atol=1.0e-07) 43 | # Check CR-CC(2,4)_DD energy 44 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"] + driver.deltap4[0]["D"], -199.06133761, atol=1.0e-07) 45 | 46 | if __name__ == "__main__": 47 | test_crcc24_f2() 48 | -------------------------------------------------------------------------------- /tests/f2/test_crcc34_f2.py: -------------------------------------------------------------------------------- 1 | """CCSD(T) computation for the stretched F2 molecule at at 2 | interatomic distance of R = 2Re, where Re = 2.66816 bohr, 3 | described using the cc-pVTZ basis set. 4 | Reference: Chem. Phys. Lett. 344, 165 (2001).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc34_f2(): 11 | geometry = [["F", (0.0, 0.0, -2.66816)], 12 | ["F", (0.0, 0.0, 2.66816)]] 13 | mol = gto.M( 14 | atom=geometry, 15 | basis="6-31g", 16 | charge=0, 17 | spin=0, 18 | symmetry="D2H", 19 | cart=True, 20 | unit="Bohr", 21 | ) 22 | mf = scf.RHF(mol) 23 | mf.kernel() 24 | 25 | driver = Driver.from_pyscf(mf, nfrozen=2) 26 | driver.run_cc(method="ccsdt") 27 | driver.run_hbar(method="ccsdt") 28 | driver.run_leftcc(method="left_ccsdt") 29 | driver.run_ccp4(method="crcc34") 30 | 31 | # 32 | # Check the results 33 | # 34 | # Check that CCSDT total energy is correct 35 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -198.8922018713, atol=1.0e-07) 36 | # Check that CR-CC(3,4)_A = CCSDT(2)_Q total energy is correct 37 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap4[0]["A"], -198.8933446977, atol=1.0e-07) 38 | 39 | if __name__ == "__main__": 40 | test_crcc34_f2() 41 | -------------------------------------------------------------------------------- /tests/f2/test_deaeom3_f2.py: -------------------------------------------------------------------------------- 1 | """DEA-EOMCCSD(3p-1h) computation used to describe the spectrum of F2 2 | by attaching two electrons to the doubly ionized F2^(2+) cation.""" 3 | 4 | import numpy as np 5 | from pyscf import gto, scf 6 | from ccpy import Driver 7 | 8 | def test_deaeom3_f2(): 9 | 10 | geometry = [["F", (0.0, 0.0, -2.66816)], ["F", (0.0, 0.0, 2.66816)]] 11 | mol = gto.M( 12 | atom=geometry, 13 | basis="cc-pvdz", 14 | charge=2, 15 | spin=0, 16 | symmetry="D2H", 17 | cart=True, 18 | unit="Bohr", 19 | ) 20 | mf = scf.RHF(mol) 21 | mf.kernel() 22 | 23 | driver = Driver.from_pyscf(mf, nfrozen=2) 24 | driver.run_cc(method="ccsd") 25 | driver.run_hbar(method="ccsd") 26 | driver.run_guess(method="deacis", nact_unoccupied=4, roots_per_irrep={"AG": 3}, multiplicity=1, use_symmetry=False) 27 | driver.run_deaeomcc(method="deaeom3", state_index=[0, 1, 2]) 28 | 29 | expected_vee = [-1.42489070, 30 | -1.39495074, 31 | -1.39407860] 32 | 33 | expected_total_energy = [-199.02088039, 34 | -198.99094042, 35 | -198.99006829] 36 | 37 | # Check that the CCSD energy of F2^{2+} is correct 38 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -197.59598969, atol=1.0e-07) 39 | for i in [0, 1, 2]: 40 | # Check that DEA-EOMCC EA energy is correct 41 | assert np.allclose(driver.vertical_excitation_energy[i], expected_vee[i], atol=1.0e-07) 42 | # Check that total state energy is correct 43 | assert np.allclose(driver.vertical_excitation_energy[i] 44 | +driver.system.reference_energy + driver.correlation_energy, expected_total_energy[i], atol=1.0e-07) 45 | 46 | if __name__ == "__main__": 47 | test_deaeom3_f2() 48 | -------------------------------------------------------------------------------- /tests/f2/test_dipeom4_f2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver 4 | 5 | def test_dipeom4_f2(): 6 | 7 | mol = gto.M(atom=[["F", (0.0, 0.0, -2.66816)], 8 | ["F", (0.0, 0.0, 2.66816)]], 9 | basis="6-31g", 10 | charge=-2, 11 | symmetry="D2H", 12 | cart=True, 13 | spin=0, 14 | unit="Bohr") 15 | mf = scf.RHF(mol) 16 | mf.kernel() 17 | 18 | driver = Driver.from_pyscf(mf, nfrozen=2) 19 | 20 | driver.run_cc(method="ccsd") 21 | driver.run_hbar(method="ccsd") 22 | driver.run_guess(method="dipcis", multiplicity=-1, nact_occupied=driver.system.noccupied_alpha, roots_per_irrep={"AG": 5}, use_symmetry=False) 23 | 24 | driver.options["davidson_out_of_core"] = True 25 | driver.run_dipeomcc(method="dipeom4", state_index=[0, 1]) 26 | 27 | # 28 | # Check the results 29 | # 30 | expected_vee = [-0.133359091568, -0.133336529768] 31 | for i, vee in enumerate(expected_vee): 32 | assert np.allclose(driver.vertical_excitation_energy[i], vee, atol=1.0e-07) 33 | 34 | 35 | if __name__ == "__main__": 36 | test_dipeom4_f2() 37 | -------------------------------------------------------------------------------- /tests/h2o/test_cc3_h2o.py: -------------------------------------------------------------------------------- 1 | """ CC3 computation for the stretched HF molecule at interatomic 2 | separation R = 1.6 angstrom.""" 3 | 4 | import numpy as np 5 | from pyscf import scf, gto 6 | from ccpy import Driver 7 | 8 | def test_cc3_h2o(): 9 | geometry = [["O", (0.0, 0.0, -0.0180)], 10 | ["H", (0.0, 3.030526, -2.117796)], 11 | ["H", (0.0, -3.030526, -2.117796)]] 12 | mol = gto.M( 13 | atom=geometry, 14 | basis="6-31g", 15 | charge=0, 16 | spin=0, 17 | symmetry="C2V", 18 | cart=True, 19 | unit="Bohr", 20 | ) 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | 24 | driver = Driver.from_pyscf(mf, nfrozen=0) 25 | 26 | driver.options["RHF_symmetry"] = False 27 | driver.run_cc(method="cc3") 28 | 29 | driver.run_hbar(method="cc3") 30 | driver.run_guess(method="cis", roots_per_irrep={"A1": 0, "B1": 1, "B2": 0, "A2": 0}, multiplicity=1, use_symmetry=False) 31 | driver.run_eomcc(method="eomcc3", state_index=[1]) 32 | 33 | # Check the CC3 correlation energy 34 | assert np.allclose(driver.correlation_energy, -0.3047279747, atol=1.0e-07) 35 | # Check the CC3 total energy 36 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -75.87813718, atol=1.0e-07) 37 | # Check the CC3 vertical excitation energy of 1st singlet excited state without symmetry control 38 | assert np.allclose(driver.vertical_excitation_energy[1], 0.0282254899, atol=1.0e-07) 39 | # Check the CC3 total energy of 1st singlet excited state 40 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[1], -75.84991169, atol=1.0e-07) 41 | 42 | 43 | if __name__ == "__main__": 44 | test_cc3_h2o() 45 | -------------------------------------------------------------------------------- /tests/h2o/test_cc4_h2o.py: -------------------------------------------------------------------------------- 1 | """Closed-shell CC4 calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_cc4_h2o(): 11 | # 2 Re 12 | geometry = [["O", (0.0, 0.0, -0.0180)], 13 | ["H", (0.0, 3.030526, -2.117796)], 14 | ["H", (0.0, -3.030526, -2.117796)]] 15 | mol = gto.M( 16 | atom=geometry, 17 | basis="dz", 18 | charge=0, 19 | spin=0, 20 | symmetry="C2V", 21 | cart=False, 22 | unit="Bohr", 23 | ) 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.run_cc(method="cc4") 29 | 30 | # 31 | # Check the results 32 | # 33 | assert np.allclose(driver.correlation_energy, -0.31209954) 34 | 35 | if __name__ == "__main__": 36 | test_cc4_h2o() 37 | -------------------------------------------------------------------------------- /tests/h2o/test_ccsdt_h2o.py: -------------------------------------------------------------------------------- 1 | """Closed-shell CCSDT calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_ccsdt_h2o(): 11 | 12 | mol = gto.M( 13 | atom=[["O", (0.0, 0.0, -0.0180)], 14 | ["H", (0.0, 3.030526, -2.117796)], 15 | ["H", (0.0, -3.030526, -2.117796)]], 16 | basis="dz", 17 | symmetry="C2v", 18 | charge=0, 19 | spin=0, 20 | cart=False, 21 | unit="Bohr", 22 | verbose=5, 23 | ) 24 | mf = scf.UHF(mol) 25 | mf.conv_tol = 1e-14 26 | mf.kernel() 27 | 28 | driver = Driver.from_pyscf(mf, nfrozen=0, uhf=True) 29 | driver.system.print_info() 30 | 31 | # Important: Set RHF flag to false manually for UHF references 32 | driver.options["RHF_symmetry"] = False 33 | driver.options["energy_convergence"] = 1.0e-09 34 | driver.options["amp_convergence"] = 1.0e-08 35 | driver.options["maximum_iterations"] = 80 36 | 37 | driver.run_cc(method="ccsdt") 38 | driver.run_hbar(method="ccsdt") 39 | driver.run_guess(method="cisd", roots_per_irrep={"B1": 2, "A1": 2}, multiplicity=-1, nact_occupied=3, nact_unoccupied=3) 40 | driver.run_eomcc(method="eomccsdt", state_index=[1, 2, 3, 4]) 41 | 42 | # 43 | # Check the results 44 | # 45 | expected_vee = [0.02728992, 0.03205095, 0.03301541, 0.14402798] 46 | assert np.allclose(driver.correlation_energy, -0.31227673, rtol=1.0e-07, atol=1.0e-07) 47 | for i, vee in enumerate(expected_vee): 48 | assert np.allclose(driver.vertical_excitation_energy[i + 1], expected_vee[i], rtol=1.0e-07, atol=1.0e-7) 49 | 50 | if __name__ == "__main__": 51 | test_ccsdt_h2o() 52 | -------------------------------------------------------------------------------- /tests/h2o/test_ccsdtq_h2o.py: -------------------------------------------------------------------------------- 1 | """Closed-shell CCSDTQ calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_ccsdtq_h2o(): 11 | # 2 Re 12 | geometry = [["O", (0.0, 0.0, -0.0180)], 13 | ["H", (0.0, 3.030526, -2.117796)], 14 | ["H", (0.0, -3.030526, -2.117796)]] 15 | mol = gto.M( 16 | atom=geometry, 17 | basis="dz", 18 | charge=0, 19 | spin=0, 20 | symmetry="C2V", 21 | cart=False, 22 | unit="Bohr", 23 | ) 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.system.print_info() 29 | 30 | driver.run_cc(method="ccsdtq") 31 | 32 | # Check CCSDTQ correlation energy 33 | assert np.allclose(driver.correlation_energy, -0.30995754, atol=1.0e-07) 34 | # Check CCSDTQ total energy 35 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -75.90513822, atol=1.0e-07) 36 | 37 | if __name__ == "__main__": 38 | test_ccsdtq_h2o() 39 | -------------------------------------------------------------------------------- /tests/h2o/test_ccsdtq_uhf_h2o.py: -------------------------------------------------------------------------------- 1 | """Closed-shell CCSDTQ calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_ccsdtq_h2o(): 11 | # 2 Re 12 | geometry = [["O", (0.0, 0.0, -0.0180)], 13 | ["H", (0.0, 3.030526, -2.117796)], 14 | ["H", (0.0, -3.030526, -2.117796)]] 15 | mol = gto.M( 16 | atom=geometry, 17 | basis="dz", 18 | charge=0, 19 | spin=0, 20 | symmetry="C2V", 21 | cart=False, 22 | unit="Bohr", 23 | ) 24 | mf = scf.UHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0, uhf=True) 28 | driver.system.print_info() 29 | 30 | # Important: Set RHF flag to false manually for UHF references 31 | driver.options["RHF_symmetry"] = False 32 | driver.run_cc(method="ccsdtq") 33 | 34 | # Check CCSDTQ correlation energy 35 | assert np.allclose(driver.correlation_energy, -0.30995754, atol=1.0e-07) 36 | # Check CCSDTQ total energy 37 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -75.90513822, atol=1.0e-07) 38 | 39 | if __name__ == "__main__": 40 | test_ccsdtq_h2o() 41 | -------------------------------------------------------------------------------- /tests/h2o/test_cipsi-ccpq_h2o.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import numpy as np 3 | from ccpy import Driver, get_triples_pspace_from_cipsi 4 | 5 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 6 | 7 | def test_cipsi_ccpq_h2o(): 8 | 9 | driver = Driver.from_gamess( 10 | logfile=TEST_DATA_DIR + "/h2o/h2o-Re.log", 11 | onebody=TEST_DATA_DIR + "/h2o/onebody.inp", 12 | twobody=TEST_DATA_DIR + "/h2o/twobody.inp", 13 | nfrozen=0, 14 | ) 15 | 16 | civecs = TEST_DATA_DIR + "/h2o/civecs-10k.dat" 17 | t3_excitations, _ = get_triples_pspace_from_cipsi(civecs, driver.system) 18 | 19 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 20 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 21 | driver.run_leftccp(method="left_ccsdt_p", t3_excitations=t3_excitations) 22 | driver.run_ccp3(method="ccp3", state_index=0, t3_excitations=t3_excitations) 23 | 24 | # Check CC(P) total energy 25 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -76.2396274886, atol=1.0e-07) 26 | # Check CC(P;Q) total energy 27 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -76.2414725396, atol=1.0e-07) 28 | 29 | 30 | if __name__ == "__main__": 31 | 32 | test_cipsi_ccpq_h2o() -------------------------------------------------------------------------------- /tests/h2o/test_crcc24_h2o.py: -------------------------------------------------------------------------------- 1 | """CR-CC(2,4) calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc24_h2o(): 11 | # 2 Re 12 | geometry = [["O", (0.0, 0.0, -0.0180)], 13 | ["H", (0.0, 3.030526, -2.117796)], 14 | ["H", (0.0, -3.030526, -2.117796)]] 15 | mol = gto.M( 16 | atom=geometry, 17 | basis="dz", 18 | charge=0, 19 | spin=0, 20 | symmetry="C2V", 21 | cart=False, 22 | unit="Bohr", 23 | ) 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.run_cc(method="ccsd") 29 | driver.run_hbar(method="ccsd") 30 | driver.run_leftcc(method="left_ccsd") 31 | driver.run_ccp3(method="crcc23") 32 | driver.run_ccp4(method="crcc24") 33 | 34 | # Check CCSD energy 35 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -75.8959141002, atol=1.0e-07) 36 | # Check CR-CC(2,3)_A energy 37 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["A"], -75.9047403064, atol=1.0e-07) 38 | # Check CR-CC(2,3)_D energy 39 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"], -75.9076522384) 40 | # Check CR-CC(2,4)_AA energy 41 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["A"] + driver.deltap4[0]["A"], -75.90617829971033) 42 | # Check CR-CC(2,4)_DA energy 43 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"] + driver.deltap4[0]["A"], -75.90909023171034) 44 | # Check CR-CC(2,4)_DD energy 45 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap3[0]["D"] + driver.deltap4[0]["D"], -75.9094507817) 46 | 47 | if __name__ == "__main__": 48 | test_crcc24_h2o() 49 | -------------------------------------------------------------------------------- /tests/h2o/test_crcc34_h2o.py: -------------------------------------------------------------------------------- 1 | """Closed-shell CCSDTQ calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_crcc34_h2o(): 11 | # 2 Re 12 | geometry = [["O", (0.0, 0.0, -0.0180)], 13 | ["H", (0.0, 3.030526, -2.117796)], 14 | ["H", (0.0, -3.030526, -2.117796)]] 15 | mol = gto.M( 16 | atom=geometry, 17 | basis="cc-pvdz", 18 | charge=0, 19 | spin=0, 20 | symmetry="C2V", 21 | cart=False, 22 | unit="Bohr", 23 | ) 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.system.print_info() 29 | 30 | driver.run_cc(method="ccsdt") 31 | driver.run_hbar(method="ccsdt") 32 | driver.run_leftcc(method="left_ccsdt") 33 | driver.run_ccp4(method="crcc34") 34 | 35 | # 36 | # Check the results 37 | # 38 | # Check that CCSDT total energy is correct 39 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -75.9530698378, atol=1.0e-07) 40 | # Check that CR-CC(3,4)_A = CCSDT(2)_Q total energy is correct 41 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.deltap4[0]["A"], -75.9521955199, atol=1.0e-07) 42 | 43 | 44 | if __name__ == "__main__": 45 | test_crcc34_h2o() 46 | -------------------------------------------------------------------------------- /tests/h2o/test_deaeom3_h2o.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | from pyscf import scf, gto 4 | from ccpy import Driver 5 | 6 | def test_deaeom3_h2o(): 7 | geometry = [["O", (0.0, 0.0, -0.0180)], 8 | ["H", (0.0, 3.030526, -2.117796)], 9 | ["H", (0.0, -3.030526, -2.117796)]] 10 | mol = gto.M( 11 | atom=geometry, 12 | basis="cc-pvdz", 13 | charge=2, 14 | spin=0, 15 | symmetry="C2V", 16 | cart=False, 17 | unit="Bohr", 18 | ) 19 | mf = scf.RHF(mol) 20 | mf.kernel() 21 | 22 | driver = Driver.from_pyscf(mf, nfrozen=0) 23 | driver.system.print_info() 24 | 25 | driver.run_cc(method="ccsd") 26 | assert np.allclose(-74.7347458944, driver.correlation_energy + driver.system.reference_energy, atol=1.0e-07) 27 | 28 | driver.run_hbar(method="ccsd") 29 | driver.run_guess(method="deacis", roots_per_irrep={"A1": 5, "B1": 0, "B2": 0, "A2": 0}, multiplicity=1, nact_unoccupied=4, use_symmetry=False) 30 | driver.run_deaeomcc(method="deaeom3", state_index=[0, 1, 2, 3, 4]) 31 | 32 | expected_ea_energy = [-1.0587336648, -1.1435694430, -1.1147055248, -0.7502349476, -0.7505287522] 33 | 34 | for n in [0, 1, 2, 3, 4]: 35 | assert np.allclose(driver.vertical_excitation_energy[n], expected_ea_energy[n], atol=1.0e-07) 36 | 37 | if __name__ == "__main__": 38 | test_deaeom3_h2o() 39 | -------------------------------------------------------------------------------- /tests/h2o/test_extrapolation_h2o.py: -------------------------------------------------------------------------------- 1 | """CR-CC(2,4) calculation for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the Dunning DZ basis set. 4 | Reference: Mol. Phys, 115, 2860 (2017).""" 5 | 6 | from pyscf import scf, gto 7 | from ccpy import Driver 8 | from ccpy.extrapolation.goodson_extrapolation import (rational_pade_approximant, 9 | quadratic_pade_approximant, 10 | continued_fraction_approximant) 11 | 12 | def test_extrapolation_h2o(): 13 | geometry = [["O", (0.0, 0.0, -0.0180)], 14 | ["H", (0.0, 3.030526, -2.117796)], 15 | ["H", (0.0, -3.030526, -2.117796)]] 16 | #geometry = [["O", (0.0, 0.0, -0.0270)], 17 | # ["H", (0.0, 4.545789, -3.176694)], 18 | # ["H", (0.0, -4.545789, -3.176694)]] 19 | mol = gto.M( 20 | atom=geometry, 21 | basis="cc-pvdz", 22 | charge=0, 23 | spin=0, 24 | symmetry="C2V", 25 | cart=False, 26 | unit="Bohr", 27 | ) 28 | mf = scf.RHF(mol) 29 | mf.kernel() 30 | 31 | driver = Driver.from_pyscf(mf, nfrozen=0) 32 | 33 | # reference energy 34 | e_ref = driver.system.reference_energy 35 | # CCSD energy 36 | driver.run_cc(method="ccsd") 37 | e_ccsd = driver.correlation_energy + e_ref 38 | driver.T = None 39 | driver.correlation_energy = 0.0 40 | # CCSDT energy 41 | driver.run_cc(method="ccsdt") 42 | e_ccsdt = driver.correlation_energy + e_ref 43 | 44 | 45 | delta1 = e_ref 46 | delta2 = e_ccsd - e_ref 47 | delta3 = e_ccsdt - e_ccsd 48 | 49 | ex_ccq = quadratic_pade_approximant(delta1, delta2, delta3) 50 | ex_ccr = rational_pade_approximant(delta1, delta2, delta3) 51 | ex_cccf = continued_fraction_approximant(delta1, delta2, delta3) 52 | 53 | print("ex-CCq = ", ex_ccq) 54 | print("ex-CCr = ", ex_ccr) 55 | print("ex-CCcf = ", ex_cccf) 56 | 57 | 58 | if __name__ == "__main__": 59 | test_extrapolation_h2o() 60 | -------------------------------------------------------------------------------- /tests/h2o/test_mpn_h2o.py: -------------------------------------------------------------------------------- 1 | """MPn calculations (n = 2,3,4) for the symmetrically stretched 2 | H2O molecule with R(OH) = 2Re, where Re = 1.84345 bohr, described 3 | using the spherical cc-pVDZ basis set. 4 | Reference: J. Chem. Phys. 104, 8007 (1996).""" 5 | 6 | import numpy as np 7 | from pyscf import scf, gto 8 | from ccpy import Driver 9 | 10 | def test_mpn_h2o(): 11 | # 2 Re 12 | geometry = [["O", (0.0, 0.0, -0.0180)], 13 | ["H", (0.0, 3.030526, -2.117796)], 14 | ["H", (0.0, -3.030526, -2.117796)]] 15 | mol = gto.M( 16 | atom=geometry, 17 | basis="cc-pvdz", 18 | charge=0, 19 | spin=0, 20 | symmetry="C2V", 21 | cart=False, 22 | unit="Bohr", 23 | ) 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | # Check reference energy 29 | assert np.allclose( 30 | driver.system.reference_energy, -75.587711, 31 | atol=1.0e-07 32 | ) 33 | driver.run_mbpt(method="mp2") 34 | # Check MP2 total energy 35 | assert np.allclose( 36 | driver.system.reference_energy + driver.correlation_energy, -75.896935, atol=1.0e-07 37 | ) 38 | driver.run_mbpt(method="mp3") 39 | # Check MP3 total energy 40 | assert np.allclose( 41 | driver.system.reference_energy + driver.correlation_energy, -75.882569, atol=1.0e-07 42 | ) 43 | # [TODO]: MP4 METHOD IS NOT WORKING YET 44 | driver.run_mbpt(method="mp4") 45 | # Check MP4 total energy 46 | #assert np.allclose( 47 | # driver.system.reference_energy + driver.correlation_energy, -75.935619 48 | #) 49 | 50 | if __name__ == "__main__": 51 | test_mpn_h2o() 52 | -------------------------------------------------------------------------------- /tests/h4/test_cc4_h4.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver 4 | 5 | def test_cc4_h4(): 6 | 7 | Re = 1.0 8 | geom = [['H', (-Re, -Re, 0.000)], 9 | ['H', (-Re, Re, 0.000)], 10 | ['H', (Re, -Re, 0.000)], 11 | ['H', (Re, Re, 0.000)]] 12 | 13 | mol = gto.M(atom=geom, basis="dz", spin=0, symmetry="D2H", unit="Bohr") 14 | mf = scf.RHF(mol) 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=0) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="cc4") 21 | 22 | print(f"CC4 Correlation Energy: {driver.correlation_energy}") 23 | print("CCSDTQ Correlation Energy: -0.064295914558") 24 | # 25 | # Check the results 26 | # 27 | assert np.allclose(driver.correlation_energy, -0.06412230, atol=1.0e-07) 28 | 29 | if __name__ == "__main__": 30 | test_cc4_h4() 31 | -------------------------------------------------------------------------------- /tests/h4/test_ccsdt_h4.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver 4 | 5 | def test_ccsdt_h4(): 6 | 7 | Re = 1.0 8 | geom = [['H', (-Re, -Re, 0.000)], 9 | ['H', (-Re, Re, 0.000)], 10 | ['H', (Re, -Re, 0.000)], 11 | ['H', (Re, Re, 0.000)]] 12 | 13 | mol = gto.M(atom=geom, basis="dz", spin=0, symmetry="D2H", unit="Bohr") 14 | mf = scf.RHF(mol) 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=0) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsdt") 21 | 22 | # 23 | # Check the results 24 | # 25 | assert np.allclose(driver.correlation_energy, -0.06350719, atol=1.0e-07) 26 | 27 | if __name__ == "__main__": 28 | test_ccsdt_h4() 29 | -------------------------------------------------------------------------------- /tests/h4/test_ccsdtq_h4.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyscf import gto, scf 3 | from ccpy import Driver 4 | 5 | def test_ccsdtq_h4(): 6 | 7 | Re = 1.0 8 | geom = [['H', (-Re, -Re, 0.000)], 9 | ['H', (-Re, Re, 0.000)], 10 | ['H', (Re, -Re, 0.000)], 11 | ['H', (Re, Re, 0.000)]] 12 | 13 | mol = gto.M(atom=geom, basis="dz", spin=0, symmetry="D2H", unit="Bohr") 14 | mf = scf.RHF(mol) 15 | mf.kernel() 16 | 17 | driver = Driver.from_pyscf(mf, nfrozen=0) 18 | driver.system.print_info() 19 | 20 | driver.run_cc(method="ccsdtq") 21 | 22 | # 23 | # Check the results 24 | # 25 | assert np.allclose(driver.correlation_energy, -0.064295914558, atol=1.0e-07) 26 | 27 | if __name__ == "__main__": 28 | test_ccsdtq_h4() -------------------------------------------------------------------------------- /tests/hf/test_cc3_hf.py: -------------------------------------------------------------------------------- 1 | """ CC3 computation for the stretched HF molecule at interatomic 2 | separation R = 1.6 angstrom.""" 3 | 4 | import numpy as np 5 | from pyscf import scf, gto 6 | from ccpy import Driver 7 | 8 | def test_cc3_hf(): 9 | geometry = [["H", (0.0, 0.0, -0.8)], ["F", (0.0, 0.0, 0.8)]] 10 | mol = gto.M( 11 | atom=geometry, 12 | basis="6-31g", 13 | charge=0, 14 | spin=0, 15 | symmetry="C2V", 16 | cart=True, 17 | unit="Angstrom", 18 | ) 19 | mf = scf.RHF(mol) 20 | mf.kernel() 21 | 22 | driver = Driver.from_pyscf(mf, nfrozen=0) 23 | 24 | driver.options["RHF_symmetry"] = False 25 | driver.run_cc(method="cc3") 26 | driver.run_hbar(method="cc3") 27 | driver.run_guess(method="cis", roots_per_irrep={"A1": 0, "B1": 1, "B2": 0, "A2": 0}, multiplicity=1) 28 | driver.run_eomcc(method="eomcc3", state_index=[1]) 29 | 30 | # Check CC3 correlation energy 31 | assert np.allclose(driver.correlation_energy, -0.178932834091, atol=1.0e-07) 32 | # Check CC3 total energy 33 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -100.00884041, atol=1.0e-07) 34 | # Check EOMCC3 vertical excitation energy 35 | assert np.allclose(driver.vertical_excitation_energy[1], 0.10083870, atol=1.0e-07) 36 | # Check EOMCC3 total energy 37 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[1], -99.90800171, atol=1.0e-07) 38 | 39 | if __name__ == "__main__": 40 | test_cc3_hf() 41 | -------------------------------------------------------------------------------- /tests/hf/test_lrccsd_hf.py: -------------------------------------------------------------------------------- 1 | """ LR-CCSD computation for the stretched HF molecule at interatomic 2 | separation R = 1.6 angstrom.""" 3 | 4 | import numpy as np 5 | from pyscf import scf, gto 6 | from ccpy import Driver 7 | from ccpy.interfaces.pyscf_tools import get_multipole_integral 8 | 9 | def test_lrccsd_hf(): 10 | geom = [['H', (0.0, 0.0, -1.7330)], 11 | ['F', (0.0, 0.0, 1.7330)]] 12 | mol = gto.M( 13 | atom=geom, 14 | basis="cc-pvtz", 15 | charge=0, 16 | spin=0, 17 | symmetry="C2V", 18 | cart=True, 19 | unit="Bohr", 20 | ) 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | 24 | driver = Driver.from_pyscf(mf, nfrozen=1) 25 | mu, mu_ref = get_multipole_integral(1, mol, mf, driver.system) 26 | 27 | driver.run_cc(method="ccsd") 28 | driver.run_hbar(method="ccsd") 29 | 30 | mu_cc = np.zeros(3) 31 | for i in range(3): 32 | driver.run_lrcc(method="lrccsd", prop=mu[i]) 33 | mu_cc[i] = driver.correlation_property 34 | mu_cc += mu_ref 35 | 36 | print("") 37 | print(" Reference Dipole Moment") 38 | print(f" x: {mu_ref[0]}") 39 | print(f" y: {mu_ref[1]}") 40 | print(f" z: {mu_ref[2]}") 41 | print(" LR-CCSD Dipole Moment") 42 | print(f" x: {mu_cc[0]}") 43 | print(f" y: {mu_cc[1]}") 44 | print(f" z: {mu_cc[2]}") 45 | 46 | if __name__ == "__main__": 47 | test_lrccsd_hf() 48 | -------------------------------------------------------------------------------- /tests/hfhminus/test_cc3_hfhminus.py: -------------------------------------------------------------------------------- 1 | """ CC3 computation for the open-shell (HFH)- molecule in the triplet 2 | ground state using the D2H-symmetric H-F distance of 2.0 angstrom described 3 | using the 6-31g(1d,1p) basis set. Active space consists of (2,2). 4 | Reference: J. Chem. Theory Comput. 8, 4968 (2012) 5 | """ 6 | 7 | from pathlib import Path 8 | import numpy as np 9 | from ccpy import Driver 10 | 11 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 12 | 13 | def test_cc3_hfhminus(): 14 | driver = Driver.from_gamess( 15 | logfile=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.log", 16 | fcidump=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.FCIDUMP", 17 | nfrozen=1, 18 | ) 19 | driver.system.print_info() 20 | 21 | driver.run_cc(method="cc3") 22 | 23 | # Check reference energy 24 | assert np.allclose(driver.system.reference_energy, -100.3591573557, atol=1.0e-07) 25 | # Check CC3 energy 26 | assert np.allclose(driver.correlation_energy, -0.19371334, atol=1.0e-07) 27 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -100.55287069, atol=1.0e-07) 28 | 29 | if __name__ == "__main__": 30 | test_cc3_hfhminus() 31 | -------------------------------------------------------------------------------- /tests/hfhminus/test_cct3_hfhminus.py: -------------------------------------------------------------------------------- 1 | """ CC(t;3) computation for the open-shell (HFH)- molecule in the triplet 2 | ground state using the D2H-symmetric H-F distance of 2.0 angstrom described 3 | using the 6-31g(1d,1p) basis set. Active space consists of (2,2). 4 | Reference: J. Chem. Theory Comput. 8, 4968 (2012) 5 | """ 6 | 7 | from pathlib import Path 8 | import numpy as np 9 | from ccpy import Driver, get_active_triples_pspace 10 | 11 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 12 | 13 | def test_cct3_hfhminus(): 14 | driver = Driver.from_gamess( 15 | logfile=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.log", 16 | fcidump=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.FCIDUMP", 17 | nfrozen=1, 18 | ) 19 | driver.system.set_active_space(nact_unoccupied=2, nact_occupied=2) 20 | driver.system.print_info() 21 | 22 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep=None) 23 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 24 | driver.run_hbar(method="ccsd") 25 | driver.run_leftcc(method="left_ccsd") 26 | driver.run_ccp3(method="cct3") 27 | 28 | # Check reference energy 29 | assert np.allclose(driver.system.reference_energy, -100.3591573557, atol=1.0e-07) 30 | # Check CCSDt energy 31 | assert np.allclose(driver.correlation_energy, -0.19275952, atol=1.0e-07) 32 | assert np.allclose( 33 | driver.system.reference_energy + driver.correlation_energy, -100.5519168770, 34 | atol=1.0e-07 35 | ) 36 | # Check CC(t;3)_A energy 37 | assert np.allclose( 38 | driver.correlation_energy + driver.deltap3[0]["A"], -0.1936570574, atol=1.0e-07 39 | ) 40 | assert np.allclose( 41 | driver.system.reference_energy 42 | + driver.correlation_energy 43 | + driver.deltap3[0]["A"], 44 | -100.5528144130, 45 | atol=1.0e-07 46 | ) 47 | # Check CC(t;3)_D energy 48 | assert np.allclose( 49 | driver.correlation_energy + driver.deltap3[0]["D"], -0.1938411916, atol=1.0e-07 50 | ) 51 | assert np.allclose( 52 | driver.system.reference_energy 53 | + driver.correlation_energy 54 | + driver.deltap3[0]["D"], 55 | -100.5529985472, 56 | atol=1.0e-07 57 | ) 58 | 59 | if __name__ == "__main__": 60 | test_cct3_hfhminus() 61 | -------------------------------------------------------------------------------- /tests/hfhminus/test_cct3full_hfhminus.py: -------------------------------------------------------------------------------- 1 | """ CC(t;3) computation for the open-shell (HFH)- molecule in the triplet 2 | ground state using the D2H-symmetric H-F distance of 2.0 angstrom described 3 | using the 6-31g(1d,1p) basis set. Active space consists of (2,2). 4 | Reference: J. Chem. Theory Comput. 8, 4968 (2012) 5 | """ 6 | 7 | from pathlib import Path 8 | import numpy as np 9 | from ccpy import Driver, get_active_triples_pspace 10 | 11 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 12 | 13 | def test_cct3_hfhminus(): 14 | driver = Driver.from_gamess( 15 | logfile=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.log", 16 | fcidump=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.FCIDUMP", 17 | nfrozen=1, 18 | ) 19 | driver.system.print_info() 20 | driver.system.set_active_space(nact_unoccupied=2, nact_occupied=2) 21 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="B1U") 22 | 23 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 24 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 25 | driver.run_leftccp(method="left_ccsdt_p", t3_excitations=t3_excitations) 26 | driver.run_ccp3(method="ccp3", state_index=0, two_body_approx=False, t3_excitations=t3_excitations) 27 | 28 | # Check reference energy 29 | assert np.allclose(driver.system.reference_energy, -100.3591573557, atol=1.0e-07) 30 | # Check CCSDt energy 31 | assert np.allclose(driver.correlation_energy, -0.19275952, atol=1.0e-07) 32 | assert np.allclose( 33 | driver.system.reference_energy + driver.correlation_energy, -100.5519168770, 34 | atol=1.0e-07 35 | ) 36 | # Check CC(t;3)_A energy 37 | assert np.allclose( 38 | driver.correlation_energy + driver.deltap3[0]["A"], -0.1936283410, atol=1.0e-07 39 | ) 40 | assert np.allclose( 41 | driver.system.reference_energy 42 | + driver.correlation_energy 43 | + driver.deltap3[0]["A"], 44 | -100.5527856967, 45 | atol=1.0e-07 46 | ) 47 | # Check CC(t;3)_D energy 48 | assert np.allclose( 49 | driver.correlation_energy + driver.deltap3[0]["D"], -0.1938060944, atol=1.0e-07 50 | ) 51 | assert np.allclose( 52 | driver.system.reference_energy 53 | + driver.correlation_energy 54 | + driver.deltap3[0]["D"], 55 | -100.5529634501, 56 | atol=1.0e-07 57 | ) 58 | 59 | if __name__ == "__main__": 60 | test_cct3_hfhminus() 61 | -------------------------------------------------------------------------------- /tests/hfhminus/test_cct3full_hfhminus_fcidump.py: -------------------------------------------------------------------------------- 1 | """ CC(t;3) computation for the open-shell (HFH)- molecule in the triplet 2 | ground state using the D2H-symmetric H-F distance of 2.0 angstrom described 3 | using the 6-31g(1d,1p) basis set. Active space consists of (2,2). 4 | Reference: J. Chem. Theory Comput. 8, 4968 (2012) 5 | """ 6 | 7 | from pathlib import Path 8 | import numpy as np 9 | from ccpy import Driver, get_active_triples_pspace 10 | 11 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 12 | 13 | def test_cct3_hfhminus(): 14 | driver = Driver.from_fcidump( 15 | fcidump=TEST_DATA_DIR + "/hfhminus-triplet/hfhminus-triplet.FCIDUMP", 16 | nfrozen=1, 17 | charge=-1, 18 | rohf_canonicalization="Roothaan", 19 | ) 20 | driver.system.print_info() 21 | driver.system.set_active_space(nact_unoccupied=2, nact_occupied=2) 22 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="A") 23 | 24 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 25 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 26 | driver.run_leftccp(method="left_ccsdt_p", t3_excitations=t3_excitations) 27 | driver.run_ccp3(method="ccp3", state_index=0, two_body_approx=False, t3_excitations=t3_excitations) 28 | 29 | # Check reference energy 30 | assert np.allclose(driver.system.reference_energy, -100.3591573557, atol=1.0e-07) 31 | # Check CCSDt energy 32 | assert np.allclose(driver.correlation_energy, -0.19275952, atol=1.0e-07) 33 | assert np.allclose( 34 | driver.system.reference_energy + driver.correlation_energy, -100.5519168770, 35 | atol=1.0e-07 36 | ) 37 | # Check CC(t;3)_A energy 38 | assert np.allclose( 39 | driver.correlation_energy + driver.deltap3[0]["A"], -0.1936283410, atol=1.0e-07 40 | ) 41 | assert np.allclose( 42 | driver.system.reference_energy 43 | + driver.correlation_energy 44 | + driver.deltap3[0]["A"], 45 | -100.5527856967, 46 | atol=1.0e-07 47 | ) 48 | # Check CC(t;3)_D energy 49 | assert np.allclose( 50 | driver.correlation_energy + driver.deltap3[0]["D"], -0.1938060944, atol=1.0e-07 51 | ) 52 | assert np.allclose( 53 | driver.system.reference_energy 54 | + driver.correlation_energy 55 | + driver.deltap3[0]["D"], 56 | -100.5529634501, 57 | atol=1.0e-07 58 | ) 59 | 60 | if __name__ == "__main__": 61 | test_cct3_hfhminus() 62 | -------------------------------------------------------------------------------- /tests/n2/test_ipeomccsdt_n2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IP-EOMCCSDT for N2 in cc-pVDZ basis set 3 | M. Musial, S. A. Kucharski, and R. J. Bartlett, J. Chem. Phys 118, 1128 (2003) 4 | ''' 5 | import numpy as np 6 | from pyscf import gto, scf 7 | 8 | def test_ipeomccsdt_n2(): 9 | from ccpy import Driver, get_active_triples_pspace 10 | from ccpy.utilities.utilities import convert_t3_from_pspace 11 | 12 | geom = [["N", (0.0, 0.0, 0.0)], 13 | ["N", (0.0, 0.0, 1.097685)]] 14 | 15 | state_index = [0, 1, 3] 16 | 17 | mol = gto.M(atom=geom, 18 | basis="cc-pvdz", 19 | charge=0, 20 | symmetry="D2H", 21 | cart=False, 22 | spin=0, 23 | unit="Angstrom") 24 | mf = scf.RHF(mol) 25 | mf.kernel() 26 | 27 | driver = Driver.from_pyscf(mf, nfrozen=0) 28 | driver.system.print_info() 29 | # 30 | driver.system.set_active_space(nact_occupied=driver.system.noccupied_alpha, nact_unoccupied=driver.system.nunoccupied_alpha) 31 | t3_excitations = get_active_triples_pspace(driver.system, target_irrep="AG") 32 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 33 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 34 | # 35 | convert_t3_from_pspace(driver, t3_excitations) 36 | # 37 | driver.run_guess(method="ipcisd", nact_occupied=0, nact_unoccupied=0, 38 | multiplicity=-1, roots_per_irrep={"AG": 7}, use_symmetry=False) 39 | driver.run_ipeomcc(method="ipeomccsdt", state_index=state_index) 40 | 41 | ip_energy = np.zeros(len(state_index)) 42 | for i, istate in enumerate(state_index): 43 | print(f"\nState {istate}") 44 | print("-----") 45 | ip_energy[i] = (driver.vertical_excitation_energy[istate])* 27.2114 46 | print(f"IP Energy = {ip_energy[i]} eV") 47 | 48 | expected_ip = [15.10, 16.64, 18.35] 49 | for w_calc, w_exp in zip(ip_energy, expected_ip): 50 | assert np.allclose(w_calc, w_exp, atol=1.0e-02) 51 | 52 | if __name__ == "__main__": 53 | 54 | test_ipeomccsdt_n2() 55 | 56 | -------------------------------------------------------------------------------- /tests/n2/test_ipeomccsdta_n2.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IP-EOMCCSD(T)(a) for N2 in ANO basis set 3 | D. A. Matthews and J. F. Stanton, J. Chem. Phys 145, 124102 (2016) 4 | ''' 5 | from pathlib import Path 6 | import numpy as np 7 | from pyscf import gto, scf 8 | from ccpy import Driver 9 | from pyscf.gto.basis import parse_gaussian 10 | 11 | TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data") 12 | 13 | def test_ipeomccsdta_n2(): 14 | 15 | ANO0 = { 16 | 'N': parse_gaussian.load(TEST_DATA_DIR + '/n2/ano0.gbs', 'N'), 17 | } 18 | 19 | geom = [["N", (0.0, 0.0, 0.0)], 20 | ["N", (0.0, 0.0, 1.094)]] 21 | 22 | state_index = list(range(7)) 23 | 24 | mol = gto.M(atom=geom, 25 | basis=ANO0, 26 | charge=0, 27 | symmetry="D2H", 28 | cart=False, 29 | spin=0, 30 | unit="Angstrom") 31 | mf = scf.RHF(mol) 32 | mf.kernel() 33 | 34 | driver = Driver.from_pyscf(mf, nfrozen=0) 35 | driver.system.print_info() 36 | 37 | driver.run_cc(method="ccsd") 38 | driver.run_hbar(method="ccsdta") 39 | 40 | driver.run_guess(method="ipcisd", nact_occupied=0, nact_unoccupied=0, 41 | multiplicity=2, roots_per_irrep={"AG": 7}, use_symmetry=False) 42 | 43 | driver.options["amp_convergence"] = 1.0e-05 44 | driver.run_ipeomcc(method="ipeomccsdta", state_index=state_index) 45 | 46 | for istate in state_index: 47 | print(f"\nState {istate}") 48 | print("-----") 49 | print(f"IP Energy = {(driver.vertical_excitation_energy[istate])* 27.2114} eV") 50 | 51 | if __name__ == "__main__": 52 | test_ipeomccsdta_n2() -------------------------------------------------------------------------------- /tests/ohminus/test_cripcc23_ohminus.py: -------------------------------------------------------------------------------- 1 | """ 2 | IP-EOMCCSD(2h-1p) calculation to obtain the vertical excitation spectrum of 3 | the open-shell OH radical, as by described by the 6-31G** basis set, by removing 4 | one electron from the (OH)- closed shell. 5 | Reference: J. Chem. Phys. 123, 134113 (2005) 6 | """ 7 | 8 | import numpy as np 9 | from pyscf import scf, gto 10 | from ccpy import Driver 11 | 12 | def test_cripcc23_ohminus(): 13 | mol = gto.M(atom='''O 0.0 0.0 -0.96966/2 14 | H 0.0 0.0 0.96966/2''', 15 | basis="6-31g**", 16 | charge=-1, 17 | spin=0, 18 | cart=False, 19 | symmetry="C2V", 20 | unit="Angstrom") 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | driver = Driver.from_pyscf(mf, nfrozen=1) 24 | driver.system.print_info() 25 | 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | driver.run_guess(method="ipcisd", multiplicity=-1, nact_occupied=4, nact_unoccupied=6, 29 | roots_per_irrep={"B1": 2, "B2": 0, "A1": 4, "A2": 2}) 30 | driver.run_ipeomcc(method="ipeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 31 | driver.run_leftipeomcc(method="left_ipeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 32 | driver.run_ipccp3(method="cripcc23", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 33 | 34 | # 35 | # Check the results 36 | # 37 | expected_vee = [-0.02049758, 0.56909275, 0.14122875, 0.60699750, 0.61645987, 0.70904961, 0.51783683, 0.58412700] 38 | expected_crcc23 = [-75.5437471773, -75.1404066669, -75.3840902578, -75.1776050392, -75.0853359523, -74.8867671659, -75.2687622370, -75.2408992393] 39 | for i, (vee, veep3) in enumerate(zip(expected_vee, expected_crcc23)): 40 | assert np.allclose(driver.vertical_excitation_energy[i], vee, atol=1.0e-07, rtol=1.0e-07) 41 | assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[i] + driver.deltap3[i]["D"], veep3, atol=1.0e-07, rtol=1.0e-07) 42 | 43 | 44 | if __name__ == "__main__": 45 | test_cripcc23_ohminus() 46 | -------------------------------------------------------------------------------- /tests/ohminus/test_ipeom2_ohminus.py: -------------------------------------------------------------------------------- 1 | """ 2 | IP-EOMCCSD(2h-1p) calculation to obtain the vertical excitation spectrum of 3 | the open-shell OH radical, as by described by the 6-31G** basis set, by removing 4 | one electron from the (OH)- closed shell. 5 | Reference: J. Chem. Phys. 123, 134113 (2005) 6 | """ 7 | 8 | import numpy as np 9 | from pyscf import scf, gto 10 | from ccpy import Driver 11 | 12 | def test_ipeom2_ohminus(): 13 | mol = gto.M(atom='''O 0.0 0.0 -0.96966/2 14 | H 0.0 0.0 0.96966/2''', 15 | basis="6-31g**", 16 | charge=-1, 17 | spin=0, 18 | cart=False, 19 | symmetry="C2V", 20 | unit="Angstrom") 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | driver = Driver.from_pyscf(mf, nfrozen=1) 24 | driver.system.print_info() 25 | 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | driver.run_guess(method="ipcisd", multiplicity=-1, nact_occupied=4, nact_unoccupied=6, 29 | roots_per_irrep={"B1": 2, "B2": 0, "A1": 4, "A2": 2}) 30 | driver.run_ipeomcc(method="ipeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 31 | driver.run_leftipeomcc(method="left_ipeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 32 | 33 | # 34 | # Check the results 35 | # 36 | expected_vee = [-0.02049758, 0.56909275, 0.14122875, 0.60699750, 0.61645987, 0.70904961, 0.51783683, 0.58412700] 37 | for i, vee in enumerate(expected_vee): 38 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 39 | en = driver.vertical_excitation_energy[i] - driver.vertical_excitation_energy[0] 40 | print(f"root {i} = {en*27.2114} eV") 41 | 42 | if __name__ == "__main__": 43 | test_ipeom2_ohminus() 44 | -------------------------------------------------------------------------------- /tests/ohminus/test_ipeom3_ohminus.py: -------------------------------------------------------------------------------- 1 | """ 2 | IP-EOMCCSD(3h-2p) calculation to obtain the vertical excitation spectrum 3 | of the open-shell OH radical, as by described by the 6-31G** basis set, by 4 | removing one electron from the (OH)- closed shell. 5 | Reference: J. Chem. Phys. 123, 134113 (2005) 6 | """ 7 | 8 | import numpy as np 9 | from pyscf import scf, gto 10 | from ccpy import Driver 11 | 12 | def test_ipeom3_ohminus(): 13 | mol = gto.M(atom='''O 0.0 0.0 -0.96966/2 14 | H 0.0 0.0 0.96966/2''', 15 | basis="6-31g**", 16 | charge=-1, 17 | spin=0, 18 | cart=False, 19 | symmetry="C2V", 20 | unit="Angstrom") 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | driver = Driver.from_pyscf(mf, nfrozen=1) 24 | driver.system.print_info() 25 | 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsd") 28 | # Perform guess vectors by diagonalizaing within the 1h + active 2h-1p space 29 | driver.run_guess(method="ipcisd", multiplicity=-1, nact_occupied=4, nact_unoccupied=6, 30 | roots_per_irrep={"B1": 2, "B2": 0, "A1": 4, "A2": 2}) 31 | driver.run_ipeomcc(method="ipeom3", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 32 | driver.run_leftipeomcc(method="left_ipeom3", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 33 | 34 | # 35 | # Check the results 36 | # 37 | expected_vee = [-0.01598430, 0.40930363, 0.14381607, 0.38859076, 0.43203093, 0.66870088, 0.29502178, 0.33376960] 38 | for i, vee in enumerate(expected_vee): 39 | assert np.allclose(driver.vertical_excitation_energy[i], vee) 40 | en = driver.vertical_excitation_energy[i] - driver.vertical_excitation_energy[0] 41 | print(f"Root {i} = {en*27.2114} eV") 42 | 43 | if __name__ == "__main__": 44 | test_ipeom3_ohminus() 45 | -------------------------------------------------------------------------------- /tests/ohminus/test_ipeomccsdtastar_ohminus.py: -------------------------------------------------------------------------------- 1 | """ 2 | IP-EOMCCSDT(a)* calculation to obtain the vertical excitation spectrum of 3 | the open-shell OH radical, as by described by the 6-31G basis set, by removing 4 | one electron from the (OH)- closed shell. 5 | Reference: J. Chem. Phys. 123, 134113 (2005) 6 | """ 7 | 8 | import numpy as np 9 | from pyscf import scf, gto 10 | from ccpy import Driver 11 | 12 | def test_ipeomccsdtastar_ohminus(): 13 | mol = gto.M(atom='''O 0.0 0.0 -0.8 14 | H 0.0 0.0 0.8''', 15 | basis="6-31g", 16 | charge=-1, 17 | spin=0, 18 | cart=False, 19 | symmetry="C2V", 20 | unit="Angstrom") 21 | mf = scf.RHF(mol) 22 | mf.kernel() 23 | driver = Driver.from_pyscf(mf, nfrozen=0) 24 | driver.system.print_info() 25 | 26 | driver.run_cc(method="ccsd") 27 | driver.run_hbar(method="ccsdta") 28 | driver.run_guess(method="ipcisd", multiplicity=-1, nact_occupied=4, nact_unoccupied=6, 29 | roots_per_irrep={"B1": 2, "B2": 0, "A1": 4, "A2": 2}) 30 | driver.run_ipeomcc(method="ipeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 31 | driver.run_leftipeomcc(method="left_ipeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 32 | driver.run_ipccp3(method="ipeomccsdta_star", state_index=[0, 1, 2, 3, 4, 5, 6, 7]) 33 | 34 | # 35 | # Check the results 36 | # 37 | expected_vee = [-0.003347942028767371, 38 | 0.10492491595761046, 39 | 0.12214269570376851, 40 | 0.3465144798386487, 41 | 0.2437123658196561, 42 | 0.30641350125651096, 43 | 0.1501940563414676, 44 | 0.20678796226069587, 45 | ] 46 | for i, vee in enumerate(expected_vee): 47 | assert np.allclose(driver.vertical_excitation_energy[i] + driver.deltap3[i]["A"], vee) 48 | 49 | if __name__ == "__main__": 50 | test_ipeomccsdtastar_ohminus() 51 | -------------------------------------------------------------------------------- /tests/ohminus/test_ipeomt3a_ohminus.py: -------------------------------------------------------------------------------- 1 | """ 2 | Reference: J. Chem. Phys. 123, 134113 (2005) 3 | """ 4 | 5 | import numpy as np 6 | from pyscf import scf, gto 7 | from ccpy import Driver, get_active_triples_pspace, get_active_3h2p_pspace 8 | 9 | def test_ipeomt3a_ohminus(): 10 | mol = gto.M(atom='''O 0.0 0.0 -0.96966/2 11 | H 0.0 0.0 0.96966/2''', 12 | basis="6-31g**", 13 | charge=-1, 14 | spin=0, 15 | cart=False, 16 | symmetry="C2V", 17 | unit="Angstrom") 18 | mf = scf.RHF(mol) 19 | mf.kernel() 20 | driver = Driver.from_pyscf(mf, nfrozen=1) 21 | driver.system.print_info() 22 | 23 | # Set the active space used to define the t_{Abc}^{ijK} operator 24 | # No = 2 includes the 1 pi_x and 1 pi_y orbitals in the active space 25 | driver.system.set_active_space(nact_unoccupied=2, nact_occupied=2) 26 | # Obtain the active-space 3h2p list 27 | t3_excitations = get_active_triples_pspace(driver.system, num_active=1) 28 | # Perform CCSDt for the closed-shell core 29 | driver.run_ccp(method="ccsdt_p", t3_excitations=t3_excitations) 30 | # Obtain the CCSD-level similarity-transformed Hamiltonian 31 | driver.run_hbar(method="ccsdt_p", t3_excitations=t3_excitations) 32 | 33 | # Set the number of active occupied orbitals used to define the r_{bc}^{ijK} operator 34 | # No = 2 includes the 1 pi_x and 1 pi_y orbitals in the active space 35 | driver.system.set_active_space(nact_unoccupied=0, nact_occupied=2) 36 | # Obtain the active-space 3h2p list 37 | r3_excitations = get_active_3h2p_pspace(driver.system, num_active=1) 38 | 39 | # Perform guess vectors by diagonalizaing within the 1h + active 2h-1p space 40 | driver.run_guess(method="ipcisd", multiplicity=-1, nact_occupied=4, nact_unoccupied=6, 41 | roots_per_irrep={"B1": 2, "B2": 0, "A1": 4, "A2": 2}) 42 | # Loop over all guess vectors and perform the IP-EOMCSDt calculation 43 | for istate in [0, 1, 2, 3, 4, 5, 6, 7]: 44 | driver.run_ipeomccp(method="ipeomccsdt_p", state_index=istate, r3_excitations=r3_excitations, t3_excitations=t3_excitations) 45 | 46 | if __name__ == "__main__": 47 | test_ipeomt3a_ohminus() 48 | --------------------------------------------------------------------------------