#  Copyright (C) 2017 The authors of Py-ChemShell
#
#  This file is part of Py-ChemShell.
#
#  Py-ChemShell is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation, either version 3 of the
#  License, or (at your option) any later version.
#
#  Py-ChemShell is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with Py-ChemShell.  If not, see
#  <http://www.gnu.org/licenses/>.

from numpy  import zeros, float64
from .xyz   import _XYZ

class Field(_XYZ):
    '''Electrostatic field'''

    _kwargs = {
                'grid'     : zeros(shape=(1,3), dtype=float64),
                'pot'      : zeros(shape=(1,) , dtype=float64),
                'efield'   : zeros(shape=(1,3), dtype=float64),
                'npoints'  : 0
              }

    # fields of <nputils.RecArray _master>: the order matters!
    _fields = 'grid', 'pot', 'efield'

    synons = { 'npoints'  : 'npts',
               'grid'     : 'xyz'
             }
    _synons = {
                'grid'     : 'xyz',
                'npoints'  : 'npts'
              }

    @property
    def npoints(self):
        '''Number of points'''
        return self.natoms

    @npoints.setter
    def npoints(self, val):
        ''''''
        self.natoms = val

    # grid points
    @property
    def grid(self):
        '''grid points'''

        return self._master.xyz

    @grid.setter
    @_XYZ._resize
    def grid(self, val):
        '''setter of grid'''

        self._master.setField(val, field='xyz')

    # electrostatic potential
    @property
    def pot(self):
        '''Charges'''

        return self._master.pot

    @pot.setter
    def pot(self, val):
        '''Setter of pot'''

        self._master.setField(val, field='pot')

    # electrostatic field
    @property
    def efield(self):
        '''Electric field'''

        return self._master.efield

    @efield.setter
    def efield(self, val):
        '''Setter of efield'''

        self._master.setField(val, field='efield')

    __all__ = 'grid', 'pot', 'efield'



