quadratic_potential.py 681 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-

from nifty import Energy


class QuadraticPotential(Energy):
    def __init__(self, position, eigenvalues):
        super(QuadraticPotential, self).__init__(position)
        self.eigenvalues = eigenvalues

    def at(self, position):
        return self.__class__(position,
                              eigenvalues=self.eigenvalues)

    @property
    def value(self):
        H = 0.5 * self.position.vdot(
                    self.eigenvalues(self.position))
        return H.real

    @property
    def gradient(self):
        g = self.eigenvalues(self.position)
        return g

    @property
    def curvature(self):
        return self.eigenvalues