line_energy.py 835 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
29
30
31
# -*- coding: utf-8 -*-

from .energy import Energy


class LineEnergy(Energy):
    def __init__(self, position, energy, line_direction):
        self.energy = energy
        self.line_direction = line_direction
        super(LineEnergy, self).__init__(position=position)

    def at(self, position):
        if position == 0:
            return self
        else:
            full_position = self.position + self.line_direction*position
            return self.__class__(full_position,
                                  self.energy,
                                  self.line_direction)

    @property
    def value(self):
        return self.energy.value

    @property
    def gradient(self):
        return self.energy.gradient.dot(self.line_direction)

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