Currently, you can set up sums of operators kind of conveniently. However, there are two things missing:
- Efficiency: If you sum up for example two Potential1D operators along the same degree of freedom, you get two operators, each of which multiplies its potential with the wave function. It would be far more efficient to have just one operator that represents the sum of the potentials.
- Convenience: Here and there, adding simple terms (e.g., constants) is cumbersome: You first need to wrap the constant into a Constant operator.
This ticket is the first step towards being able to manipulate a given Hamiltonian for internal reasons. In particular, the following issues should be tackled:
- Sum and product operators should be able to hold an arbitrary number of summands and factors.
- There should be convenience functionality (overloaded operator+ and operator*) so that you can multiply an operator with a constant and vice versa.
- There should be a function / framework for contracting operators. The point of contraction (or whatever you name it) is to increase the efficiency and simplify the structure of a given Hamiltonian. For now, the following handling should be implemented:
- streamline the sum or product structure of the Hamiltonian (instead of sums of sums of sums or so, make a single sum)
- Combine multiple Potential1D acting along the same degree of freedom into a single operator.
- absorb constants into appropriate potential terms
- Study if it makes sense to introduce/use a PotentialND instead of a Potential1D for typical use-cases. Somehow, multiplication/scaling of the tensors seems to be the place where most computation time is spent, so maybe blowing up the tensor into an N-dimensional potential and multiplying elementwise can speed up a calculation. Try this out, and if this is a good idea, add a corresponding contraction for this use-case.
Potentials are now properly combined if they can be (summands or neighboring factors). There was a lot of other refactoring; most notably all potential-like operators now derive from DvrPrimitive. Speedup was about 20% in several demos.
Constants have not been included in the simplification. See [#143] for additional possible extensions.
Diff:
Related
Tickets: #143
Diff:
Related
Tickets: #143