Skip to content

Implemented the chemical fragmentation based on Van der Waals radii #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Feb 3, 2025

Conversation

mcocdawc
Copy link
Contributor

@mcocdawc mcocdawc commented Jan 24, 2025

Implemented chemically motivated fragmentation

  • uses van der Waals radii (relies on chemcoord)
  • separate fragmentation from the assignment of AO indices
  • Is very fast. On the big molecule of @lweisburn and @mscho527 (342 atoms) the BE3 fragmentation takes on my notebook 17 ms.¹ ²

Nice properties:

  • Explicit assumptions about the indices are encoded in the type system. This means that there is a clear distinction in the type between a center index, an edge index or the index of an atomic orbital. At runtime they are of course plain old integers.
  • All data structures are immutable.
  • Nearly everything is just a concatenation of pure, side-effect free functions and/or dictionary comprehensions. Makes it very easy to parallelize, if performance would ever become an issue.
  • Fully generalized to arbitrary n-BE >= 1. Also strange input such as nBE == 20 for an octane just works and produces one fragment.
  • Fully generalized the motif concept such that one can decide if hydrogens are also centers. This means that the hydrogen chain is just a special case of the code which requires no adaptations. This means that any nBE >= 1 for hydrogen chains is also possible.
  • In-code documentation of the terms that are also nicely typeset in the user documentation, see the attached screenshot. Screenshot from 2025-01-26 16-36-04

Still to do:

  • The assignment of AO indices is still missing. Is done separately to not have a huge single PR.
  • The types such as AtomIdx are probably useful for other code as well and should be moved to shared.typing.

¹ For comparison:

  • autogen takes 312 ms.
  • graphgen with cutoff=70 takes 35 s.

Note that this is not a fair comparison, because both autogen and graphgen also create the AO indices per fragment.

² The first execution might take longer, because perfomance-relevant code is jitted.

Squashed commit of the following:

commit 2ee0b81
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 16:58:53 2025 -0500

    make the test more expressive

commit 7758a12
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 16:56:53 2025 -0500

    improved the documentation

commit 172ba79
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 15:43:31 2025 -0500

    finished tests for fragmentation

commit a37f291
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 15:40:33 2025 -0500

    import Self from typing_extensions

commit dbb4fb8
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 15:40:02 2025 -0500

    finished fragmented molecule test

commit 787b8a1
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 15:37:30 2025 -0500

    Revert "use binary set operators"

    This reverts commit 36b93e4.

commit 9eac60f
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 15:28:15 2025 -0500

    ignore OrderedSet

commit 36b93e4
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 15:05:31 2025 -0500

    use binary set operators

commit 73e85d4
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 13:59:15 2025 -0500

    added more tests

commit dda22ad
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 13:45:49 2025 -0500

    added tests for chemical fragmentation

commit 08cf11a
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 13:09:18 2025 -0500

    Fragmented molecule works

commit b086d53
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 12:58:09 2025 -0500

    cleanly get edges per fragment

commit 9b58985
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 12:47:32 2025 -0500

    revert back some of the last changes

commit d8b4cce
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 24 12:36:06 2025 -0500

    get edge idx

commit f9b9eda
Author: Oskar Weser <[email protected]>
Date:   Thu Jan 23 19:12:36 2025 -0500

    cleanup of comments

commit 2e952f6
Author: Oskar Weser <[email protected]>
Date:   Thu Jan 23 19:04:05 2025 -0500

    finished FragmentedMolecule :D

commit 9478649
Author: Oskar Weser <[email protected]>
Date:   Thu Jan 23 17:27:48 2025 -0500

    ignore ordered set from missing links in the documentation

commit ece0c97
Author: Oskar Weser <[email protected]>
Date:   Thu Jan 23 14:16:53 2025 -0500

    fixed mypy issues

commit 5f565d4
Merge: 46e86a9 b747e0c
Author: Oskar Weser <[email protected]>
Date:   Wed Jan 22 22:51:00 2025 -0500

    Merge branch 'main' of github.com:troyvvgroup/quemb into improve_fragmentation

commit 46e86a9
Author: Oskar Weser <[email protected]>
Date:   Wed Jan 22 21:19:46 2025 -0500

    construct bond dictionary once and pass it on

commit 60d06e9
Merge: c6a1d10 14d443f
Author: Oskar Weser <[email protected]>
Date:   Wed Jan 22 15:21:51 2025 -0500

    Merge branch 'graphgen_fixes' of github.com:troyvvgroup/quemb into improve_fragmentation

commit 14d443f
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 22 15:12:22 2025 -0500

    A truly inconsequential change to `euclidean_norm`.

commit c6a1d10
Author: Oskar Weser <[email protected]>
Date:   Wed Jan 22 14:59:00 2025 -0500

    get rid of hlist and add_centers in return

    this was discussed with Leah; they actually don't need it for mixed BE

commit 8a9413a
Author: Oskar Weser <[email protected]>
Date:   Wed Jan 22 10:00:45 2025 -0500

    made add_back H nicer

commit a64bf10
Author: Oskar Weser <[email protected]>
Date:   Tue Jan 21 17:40:37 2025 -0500

    ignore wrong mypy error

commit 7c0dd2a
Author: Oskar Weser <[email protected]>
Date:   Tue Jan 21 17:28:47 2025 -0500

    added merge sets

commit bbfdca4
Author: Oskar Weser <[email protected]>
Date:   Tue Jan 21 17:20:51 2025 -0500

    finished get_fs

commit 15e8156
Author: Oskar Weser <[email protected]>
Date:   Tue Jan 21 15:27:36 2025 -0500

    added get_fs function

commit 39dbd51
Author: Oskar Weser <[email protected]>
Date:   Tue Jan 21 15:09:32 2025 -0500

    keep info about centers that were removed because they are subsets

commit f3042cd
Author: Shaun Weatherly <[email protected]>
Date:   Mon Jan 20 12:48:09 2025 -0500

    Expose other keywords and update docstrings

commit 4af68ae
Author: Shaun Weatherly <[email protected]>
Date:   Mon Jan 20 12:36:14 2025 -0500

    Modify docstrings.

commit 47a1c4e
Author: Shaun Weatherly <[email protected]>
Date:   Mon Jan 20 11:51:44 2025 -0500

    Indexing fixes, optimization, and etc.

commit 1b7bd8f
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 19:49:20 2025 -0500

    extracting information from the fragments

commit cb7f8e7
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 16:41:36 2025 -0500

    removed wrong merge

commit 4664380
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 16:40:05 2025 -0500

    rename FragPart back to fragpart to have less changed files

    do that in another commit or at the end

commit 53d7faf
Merge: 2df5ea6 8c410c4
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 16:39:09 2025 -0500

    Merge branch 'main' of github.com:troyvvgroup/quemb into improve_fragmentation

commit 2df5ea6
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 16:32:38 2025 -0500

    updated chem frag

commit 2699304
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 14:21:17 2025 -0500

    removed # noqa E501 in fragmentation test

commit cfe71cf
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 14:18:38 2025 -0500

    follow PEP8 for class names fragpart -> FragPart

commit 78bb218
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 14:02:17 2025 -0500

    explicitly exclude python versions >=3.13

commit 0f00f02
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 13:58:33 2025 -0500

    use python 3.12 for the time being

commit e07822d
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 13:42:59 2025 -0500

    added intersphinx dependency for chemcoord

commit 6035f44
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 13:35:00 2025 -0500

    chemcoord dependency

commit 172f838
Merge: e4a7b31 af8a8cf
Author: Oskar Weser <[email protected]>
Date:   Fri Jan 17 13:31:03 2025 -0500

    Merge branch 'new_graphgen' into improve_fragmentation

commit af8a8cf
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:28:59 2025 -0500

    Update `molbe_ppp`

commit 32a1eff
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:25:52 2025 -0500

    Final formatting.

commit 5cc31d7
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:24:24 2025 -0500

    Ruff fixes.

commit bbbbe9b
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:21:05 2025 -0500

    Finish renaming `valence_basis` to `iao_valence_basis`

commit 5b2108b
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:13:02 2025 -0500

    Rename `valence_basis` to `iao_valence_basis`

commit e07aa2d
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:06:19 2025 -0500

    Test removing `fragment_map` from nitpick exceptions.

commit fcf5c23
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 18:02:10 2025 -0500

    More strict typing for `adjacency_mat`

commit b8f1eaa
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 17:56:46 2025 -0500

    Test `intersphinxlink`

commit 1eab146
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 17:51:07 2025 -0500

    Formatting.

commit d9fee42
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 17:20:38 2025 -0500

    Update `graphgen` docstring

commit 0fddbff
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 17:19:00 2025 -0500

    Add checks for IAOs in `graphgen`

commit 5a6ec5b
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 16:02:38 2025 -0500

    Add unit tests for energy comparisons across `autogen` and `graphgen`

commit 432efcc
Author: Shaun Weatherly <[email protected]>
Date:   Thu Jan 16 15:23:54 2025 -0500

    Remove defaults in `FragmentMap` init.

commit 5ebb8d4
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:51:52 2025 -0500

    Add `fragmentation_test` to mypy blacklist

commit c5b60d9
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:46:45 2025 -0500

    Ruff formatting yet again.

commit d21a66a
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:39:16 2025 -0500

    Add ruff exclusion rule for `fragmentation_tests`

commit 546ee00
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:33:07 2025 -0500

    Suppress E501 in `fragmentation_test`

commit 79a0627
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:28:25 2025 -0500

    Long line fix.

commit e9d5db9
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:25:02 2025 -0500

    Add unit tests for `autogen` and `graphgen`

commit 815f0fe
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 15:24:05 2025 -0500

    Fixes for `FragmentMap`

commit 7d4e7b5
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:54:12 2025 -0500

    Organize imports.

commit 98b4f72
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:52:34 2025 -0500

    Use `np.floating[Any]`

commit 31186f7
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:48:41 2025 -0500

    Remove unfinished code.

commit bfa1273
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:47:24 2025 -0500

    `FragmentMap` Docstring edits.

commit 083e275
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:43:14 2025 -0500

    Additions to `nitpick_exceptions`.

commit a4333a6
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:25:21 2025 -0500

    Final formatting

commit 79dce30
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:23:17 2025 -0500

    Fix formatting

commit f94c164
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 12:02:00 2025 -0500

    Remove unused kwargs.

commit 7a4e53d
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 11:59:27 2025 -0500

    Edits to `FragmentMap` typing.

commit 5fec9ed
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 11:31:37 2025 -0500

    New `FragmentMap` data class.

commit 24adc16
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 10:31:13 2025 -0500

    `norm`

commit 49c20d5
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 10:30:19 2025 -0500

    Unsuppress mypy warnings

commit ec70e05
Author: Shaun Weatherly <[email protected]>
Date:   Wed Jan 15 10:29:11 2025 -0500

    Add types package for `networkx`

commit cff391d
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 13:32:28 2025 -0500

    Added complete docstring for `graphgen`.

commit cd77b7d
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 13:09:55 2025 -0500

    Remove debug prints

commit f0fd882
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 12:33:41 2025 -0500

    Suppress `mypy` for `networkx` imports.

commit 364ae2f
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 12:27:24 2025 -0500

    `mypy` static typing.

commit 865b9c2
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 12:18:52 2025 -0500

    Update dependencies.

commit 1f17bcd
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 12:16:23 2025 -0500

    Final formatting

commit a37a0e2
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 12:11:05 2025 -0500

    Formatting and removed unused code.

commit 17f1b84
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 11:53:56 2025 -0500

    Ruff fixes.

commit 61907e2
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 11:30:30 2025 -0500

    Fix reference to `frag_scratch` when `solver=="DMRG"`

commit cacf442
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 11:29:24 2025 -0500

    Fix reference to `mf.mol` when `lo_method="pipek"`

commit 4a3a4b3
Author: Shaun Weatherly <[email protected]>
Date:   Tue Jan 14 11:28:47 2025 -0500

    Added `graphgen` fragmentation.

commit e4a7b31
Author: Oskar Weser <[email protected]>
Date:   Mon Jan 13 13:38:12 2025 -0500

    added chemical fragmentation

    - use van der Waals radii (relies on chemcoord)
    - much nicer code
@mcocdawc mcocdawc marked this pull request as ready for review January 25, 2025 01:04
@mcocdawc
Copy link
Contributor Author

Since this is a long PR I would add @ShaunWeatherly and one of you (@lweisburn or @mscho527 ) as reviewers.

Copy link
Member

@mscho527 mscho527 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, nice work!

typo found by Minsik

Co-authored-by: Minsik <[email protected]>
Copy link
Member

@mscho527 mscho527 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                                                          .  
   ___    __.    __.    __.    __.    __.    __.    __.   |  
 .'   ` .'   \ .'   \ .'   \ .'   \ .'   \ .'   \ .'   \  |  
 |      |    | |    | |    | |    | |    | |    | |    |  |  
  `._.'  `._.'  `._.'  `._.'  `._.'  `._.'  `._.'  `._.' /\__
                                                             

@mcocdawc mcocdawc merged commit 767f470 into main Feb 3, 2025
4 checks passed
@mcocdawc mcocdawc deleted the chemical_fragmentation branch February 3, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants