Esempio n. 1
0
    def __init__(self, binsize=None):
        """
        Constructor for the time step distribution analysis object.

        :param binsize: The size of the bins in the histogram.
        :type binsize: float
        """
        # Check the input parameters.
        self.__binsize = checkPositiveFloat(binsize, 1.0, "binsize")

        # Setup an initial histogram of 10 entries.
        self.__histogram = numpy.zeros(10, dtype=int)
Esempio n. 2
0
    def __init__(self, coordinates=None, basis_sites=None, rate_constant=None):
        """
        Constructor for the KMCBaseProcess.

        :param coordinates: The local coordinates, corresponding to the lattice
                            positions of the surrounding of the center where
                            the process will be preformed.

        :param basis_sites: The basis sites in the lattice at which the process
                            can possibly be applied. Only if the length of this
                            list is 1 can implicit wildcards be used for the
                            matching.

        :param rate_constant: The rate constant associated with this process.
        :type rate_constant: float

        """
        # Check the coordinates.
        coordinates = checkCoordinateList(coordinates)

        # Center the coordinates on the first entry.
        center = 0
        self._coordinates = centerCoordinates(coordinates, center)

        # Check the list of basis sites.
        basis_sites = checkSequenceOfPositiveIntegers(
            basis_sites,
            msg="The basis_sites must be given as a list of positive integers."
        )

        if len(basis_sites) == 0:
            msg = "The list of available basis sites for a process may not be empty."

        # Passed the  tests.
        self._basis_sites = basis_sites

        # Check the rate constant.
        self._rate_constant = checkPositiveFloat(
            rate_constant,
            default_parameter=None,
            parameter_name="rate_constant")

        # To be updated by the derrived classes.
        self._elements_before = None
        self._elements_after = None
        self._move_vectors = None
        self._all_present_types = None
        self._local_configurations = None
Esempio n. 3
0
    def __init__(self, time_interval=None):
        """
        Constructor for the composition analysis.

        :param time_interval: Time interval for binning results. Defaults to
                              1.0 if not specified.
        :type time_interval: float
        """
        # Check and set the input.
        self.__time_interval = checkPositiveFloat(time_interval, 1.0,
                                                  'time_interval')

        # Done checking.
        self.__current_steps = 0
        self.__last_time = 0.0
        self.__data = []
        self.__current_count = None
        self.__empty_count = None
Esempio n. 4
0
    def __init__(self,
                 history_steps=None,
                 n_bins=None,
                 t_max=None,
                 track_type=None):
        """
        Constructor for the OnTheFlyMSD.

        :param history_steps: The number of steps per atom to store in the
                              history buffer.
        :type history_steps: int

        :param n_bins: The nuber of bins in the histogram.
        :type n_bins: int

        :param t_max: The starting value of the last bin.
        :type t_max: float

        :param track_type: The atom type to track during the simulation.
        :type track_type: str
        """
        # Check and set the history steps input.
        self.__history_steps = checkPositiveInteger(history_steps, 5,
                                                    "history_step")

        # Check and set the number of bins.
        self.__n_bins = checkPositiveInteger(n_bins, 100, "n_bins")

        # Check and set the time maximum.
        self.__t_max = checkPositiveFloat(t_max, 100.0, "t_max")

        # Check that the track type.
        if not isinstance(track_type, str):
            raise Error("The 'track_type' parameter must be a string.")
        self.__track_type = track_type

        # Calculate and store the binsize.
        self.__binsize = self.__t_max / self.__n_bins

        # Set the step counter to zero.
        self.__n_steps = 0

        # Set the blocksize to zero.
        self.__blocksize = 0
Esempio n. 5
0
    def __init__(self,
                 coordinates=None,
                 elements_before=None,
                 elements_after=None,
                 move_vectors=None,
                 basis_sites=None,
                 rate_constant=None):
        """
        Constructor for the KMCProcess.

        :param coordinates: The local coordinates, corresponding to the lattice
                            positions of the surrounding of the center where
                            the process will be preformed.

        :param elements_before: The elements, as a list of strings,
                                before the process is preformed.
                                This list of elements will be used to match the
                                local surroundings of each center in the
                                simulation, to determine at which sites the
                                process can be performed.

        :param elements_after: The elements, as a list of strings,
                               after the process is preformed.
                               This list of elements will be used to update the
                               local surrounding of the site where the process
                               is performed.

        :param move_vectors: A set of vectors in the local coordinates that define
                             which elements are moved to which place in the move.
                             The vectors are given as a list of tuples, where the first
                             element in each tuple indicates which index is moved and
                             the second element in the tuple is a vector in local coordinates
                             indicating where the move is to.

        :param basis_sites: The basis sites in the lattice at which the process
                            can possibly be applied. Only if the length of this
                            list is 1 can implicit wildcards be used for the
                            matching.

        :param rate_constant: The rate constant associated with this process.
        :type rate_constant: float

        """
        # Call the base class constructor.
        super(KMCProcess, self).__init__(coordinates, basis_sites,
                                         rate_constant)

        # Check the types.
        elements_before = checkTypes(elements_before, len(coordinates))
        elements_after = checkTypes(elements_after, len(coordinates))

        # Check that the elements represents a valid move.
        self.__checkValidMoveElements(elements_before, elements_after)

        # All types checking done.
        self._elements_before = elements_before
        self._elements_after = elements_after

        # Check that the move vectors are compatible with the elements.
        self._move_vectors = self.__checkValidMoveVectors(move_vectors)

        # Sort the coordinates and co-sort the elements and move vectors.
        self.__sortCoordinatesElementsAndMoveVectors()

        # Check the list of basis sites.
        basis_sites = checkSequenceOfPositiveIntegers(
            basis_sites,
            msg="The basis_sites must be given as a list of positive integers."
        )

        if len(basis_sites) == 0:
            msg = "The list of available basis sites for a process may not be empty."

        # Passed the  tests.
        self.__basis_sites = basis_sites

        # Check the rate constant.
        self.__rate_constant = checkPositiveFloat(
            rate_constant,
            default_parameter=None,
            parameter_name="rate_constant")
        # Setup the local configurations.
        center = 0
        c1 = KMCLocalConfiguration(self._coordinates, self._elements_before,
                                   center)
        c2 = KMCLocalConfiguration(self._coordinates, self._elements_after,
                                   center)
        self._local_configurations = (c1, c2)

        self._all_present_types = list(
            set(self.elementsBefore() + self.elementsAfter()))