def __init__(self,
                 processes=None,
                 time_interval=None,
                 spatially_resolved=None,
                 transientTime=None):
        """
        Constructor for the process statistics analysis.

        :param processes: List of process numbers to collect statistics from.
        :param time_interval: Time interval for binning results. Defaults to
                              1.0 if not specified.
        :type time_interval: float
        :param spatially_resolved: True if spatially resolved information about
                                   the total number of events per site should
                                   be collected. Defaults to False.
        :type spatially_resovled: bool
        """
        # Check and set the input.
        msg = "The 'processes' parameter must be given as a list of process numbers."
        self.__processes = checkSequenceOfPositiveIntegers(processes, msg)
        self.__time_interval = checkPositiveFloat(time_interval, 1.0, 'time_interval')
	self.__transientTime = checkPositiveFloat(transientTime, 1.0, 'transientTime')
        if (spatially_resolved is None):
            spatially_resolved = False
        elif not isinstance(spatially_resolved, bool):
            raise Error("The 'spatially_resolved' parameter to the ProcessStatistics analysis must be given as a bool.")

        # Done checking.
        self.__spatially_resolved = spatially_resolved
        self.__last_time = 0.0
        self.__data = []
        self.__spatial_data = None
        self.__current_count = 0
Example #2
0
    def __init__(self,
                 processes=None,
                 time_interval=None,
                 spatially_resolved=None):
        """
        Constructor for the process statistics analysis.

        :param processes: List of process numbers to collect statistics from.
        :param time_interval: Time interval for binning results. Defaults to
                              1.0 if not specified.
        :type time_interval: float
        :param spatially_resolved: True if spatially resolved information about
                                   the total number of events per site should
                                   be collected. Defaults to False.
        :type spatially_resovled: bool
        """
        # Check and set the input.
        msg = "The 'processes' parameter must be given as a list of process numbers."
        self.__processes = checkSequenceOfPositiveIntegers(processes, msg)
        self.__time_interval = checkPositiveFloat(time_interval, 1.0,
                                                  'time_interval')
        if (spatially_resolved is None):
            spatially_resolved = False
        elif not isinstance(spatially_resolved, bool):
            raise Error(
                "The 'spatially_resolved' parameter to the ProcessStatistics analysis must be given as a bool."
            )

        # Done checking.
        self.__spatially_resolved = spatially_resolved
        self.__last_time = 0.0
        self.__data = []
        self.__spatial_data = None
        self.__current_count = 0
Example #3
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)
Example #4
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)
Example #5
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
Example #6
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
Example #7
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
    def __init__(self,
                 processes=None,
                 time_interval=None,
                 spatially_resolved=None,
                 anal_Interval=None,
                 resultsPlace=None,
                 processesObject=None):
        """
        Constructor for the process statistics analysis.

        :param processes: List of process numbers to collect statistics from.
        :param time_interval: Time interval for binning results. Defaults to
                              1.0 if not specified.
        :type time_interval: float
        :param spatially_resolved: True if spatially resolved information about
                                   the total number of events per site should
                                   be collected. Defaults to False.
        :type spatially_resovled: bool
        """
        # Check and set the input.
        msg = "The 'processes' parameter must be given as a list of process numbers."
        self.__processes = checkSequenceOfPositiveIntegers(processes, msg)
        self.__time_interval = checkPositiveFloat(time_interval, 1.0, 'time_interval')
        self.__analInterval = checkPositiveInteger(anal_Interval, 1, 'anal_Interval')
        self.__resultsPlace = resultsPlace
        self.__processesObject = processesObject
        
        if (self.__resultsPlace is not None):
            if(self.__processesObject is None):
                raise Error("If this is the trajRecord-keeping processStatistics analysis instance, you need to specify what the processes are!")
            self.__trajRecord = open(self.__resultsPlace+'/trajRecord.tr', 'w')
        self.__floatAnalInterval = float(self.__analInterval)
        if (spatially_resolved is None):
            spatially_resolved = False
        elif not isinstance(spatially_resolved, bool):
            raise Error("The 'spatially_resolved' parameter to the ProcessStatistics analysis must be given as a bool.")

        # Done checking.
        self.__spatially_resolved = spatially_resolved
        self.__last_time = 0.0
        self.__data = []
        self.__spatial_data = None
        self.__current_count = 0
Example #9
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
Example #10
0
    def testCheckPositiveFloat(self):
        """ Test that the positive float checking works. """
        # Test pass.
        float0 = checkPositiveFloat(21.0, 1.234, "float0")
        self.assertEqual(float0, 21.0)

        float0 = checkPositiveFloat(0.0, 1.234, "float0")
        self.assertEqual(float0, 0.0)

        # Test default.
        float0 = checkPositiveFloat(None, 1.234, "float0")
        self.assertEqual(float0, 1.234)

        # Test fail negative.
        self.assertRaises(Error, lambda: checkPositiveFloat(-1.0, 1.2, "fail"))

        # Test fail wrong type.
        self.assertRaises(Error, lambda: checkPositiveFloat(1, 1.2, "fail"))

        # Test fail wrong type.
        self.assertRaises(Error,
                          lambda: checkPositiveFloat("1.1", 1.2, "fail"))
Example #11
0
    def testCheckPositiveFloat(self):
        """ Test that the positive float checking works. """
        # Test pass.
        float0 = checkPositiveFloat(21.0, 1.234, "float0")
        self.assertEqual(float0, 21.0)

        float0 = checkPositiveFloat(0.0, 1.234, "float0")
        self.assertEqual(float0, 0.0)

        # Test default.
        float0 = checkPositiveFloat(None, 1.234, "float0")
        self.assertEqual(float0, 1.234)

        # Test fail negative.
        self.assertRaises( Error,
                           lambda: checkPositiveFloat(-1.0, 1.2, "fail") )

        # Test fail wrong type.
        self.assertRaises( Error,
                           lambda: checkPositiveFloat(1, 1.2, "fail") )

        # Test fail wrong type.
        self.assertRaises( Error,
                           lambda: checkPositiveFloat("1.1", 1.2, "fail") )
Example #12
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

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

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

        # 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.
        c1 = KMCLocalConfiguration(self.__coordinates, self.__elements_before, center)
        c2 = KMCLocalConfiguration(self.__coordinates, self.__elements_after,  center)
        self.__local_configurations = (c1, c2)