line_energy.py 974 Bytes
Newer Older
1
2
3
4
5
6
# -*- coding: utf-8 -*-

from .energy import Energy


class LineEnergy(Energy):
7
    def __init__(self, position, energy, line_direction, zero_point=None):
8
        super(LineEnergy, self).__init__(position=position)
9
10
11
12
13
14
15
16
        self.line_direction = line_direction

        if zero_point is None:
            zero_point = energy.position
        self._zero_point = zero_point

        position_on_line = self._zero_point + self.position*line_direction
        self.energy = energy.at(position=position_on_line)
17
18

    def at(self, position):
19
20
21
22
        return self.__class__(position,
                              self.energy,
                              self.line_direction,
                              zero_point=self._zero_point)
23
24
25
26
27
28
29
30
31
32
33
34

    @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