Skip to content
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

Make use of libcommute and update C++ API accordingly #44

Merged
merged 30 commits into from
May 21, 2021

Conversation

krivenko
Copy link
Collaborator

@krivenko krivenko commented Apr 14, 2021

There is still a lot of stuff to be done before this PR can be merged. I decided to open and update it incrementally so that we can discuss the development progress step by step.

Most of the library has already been ported, except for the classes related to the 2-particle GF and susceptibility. I have temporarily commented out compilation of all unit tests and added a new one. It is an adapted copy of GF4siteTest, and I suggest we use it to discuss the updated API.

Some highlights of the proposed changes

  • Require libcommute >= 0.6.2 as an external dependency.
  • Remove the Operator class and introduce a namespace Pomerol::Operators, which simply imports some types and functions from libcommute.
  • IndexClassification is templated on the types of the indices now. This change lifts the restriction of fermionic degrees of freedom being always addressed by the (site,orbital,spin) triplets.
  • I believe Lattice and IndexHamiltonian have no real use now and should go. LatticePresets should become a namespace with a bunch of free functions returning libcommute::expression objects.
  • Symmetrizer has been replaced with HilbertSpace, which is responsible for automatic partitioning of the Hilbert space into sectors. No explicit integrals of motion are required by the new algorithm.
  • I have removed all functionality related to quantum numbers from StatesClassification as they are not needed anymore (see the previous point). We may decide to put it back later on and just for informational purposes (better screen output).
  • Rename FieldOperator[Part] -> MonomialOperator[Part] and allow for a wider class of operators: Any product of c and c_dag with a prefactor, i.e. a monomial as it still generates only one-to-one connections between sectors.
  • HamiltonianPart and MonomialOperatorPart use type erasure to switch between real and complex stored matrices at runtime.

There is still a huge mess in the details of the reworked implementation and I shall start cleaning it out once we have agreed on the new API.

This header features a new namespace, Pomerol::Operators imports a few
libcommute classes and functions.
…ion`

Drop the bit field based type FockState in favor of unsigned integers.
All needed bit fiddling will be done by libcommute.
`HamiltonianPart` is now templated on the matrix storage type (real or
complex elements), while `Hamiltonian` employs type erasure and stores
parts as a vector of `std::shared_ptr<void>`.

The Hamiltonian expression is not stored in `Hamiltonian`. Instead, it
is only passed to `prepare()` to construct a matrix representation.

Since the matrix representation is now generated by means of libcommute,
a new header `LibcommuteEigen.h` has been added to teach libcommute
how to use Eigen vectors and blocks as StateVector's.
Now type type erasure is used only to store the actual Eigen matrix and
a reference to the `libcommute::loperator` object.
@krivenko krivenko marked this pull request as draft April 14, 2021 12:41
@krivenko krivenko changed the title Libcommute [WIP] Make use of libcommute and update C++ API accordingly Apr 14, 2021
…st_libcommute

`GF4siteTest_libcommute` fully compiles and gives correct results now.
This is the first version of Clang to offer a reasonable resolution of
the C++ Core Language Defect Report 253. Earlier versions of Clang
complain about the 'hc' object from libcommute.

http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#253
@krivenko krivenko force-pushed the libcommute branch 4 times, most recently from 94096b1 to 83b3efe Compare April 18, 2021 12:20
`LatticePresets` is a namespace with a bunch of free functions now.
… revealed bugs

Also remove outdated tests `NOperatorTest` and `SzOperatorTest`.
Some of the unit tests have been removed as they would not make sense
anymore.
@krivenko krivenko requested a review from aeantipov May 4, 2021 13:45
@krivenko krivenko marked this pull request as ready for review May 4, 2021 13:49
@krivenko
Copy link
Collaborator Author

krivenko commented May 4, 2021

Contents of the tutorial directory has not been ported yet. This will be done as part of a greater effort to update documentation.

Copy link
Collaborator

@aeantipov aeantipov left a comment

Choose a reason for hiding this comment

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

I read through it. No objections from me. Thanks for reworking it all!

@@ -50,7 +51,7 @@ class GreensFunction : public Thermal, public ComputableObject {
/** A list of pointers to parts (every part corresponds to a part of the annihilation operator
* and a part of the creation operator).
*/
std::list<GreensFunctionPart*> parts;
std::vector<GreensFunctionPart> parts;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed sometimes we use a shared pointer and some time instances. What's the rationale?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A couple of classes were storing parts in vectors of smart pointers because I forgot to change them to plain instances.
Those are updated in the latest commit.

@krivenko krivenko changed the title [WIP] Make use of libcommute and update C++ API accordingly Make use of libcommute and update C++ API accordingly May 20, 2021
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