def __init__(self, n_particles, n_steps, dt, x_max, trans_matrix_v, trans_matrix_theta, mapping, init_count_v, init_count_theta, inj_location = "start", verbose = True): """ :param n_particles: number of particles :param n_steps: number of steps :param dt: stencil time :param x_max: maximum length of the domain :param trans_matrix: :param mapping: :param init_class_count: :param inj_location: :param verbose: """ super(DispModelIndependent,self).__init__(n_particles, n_steps, inj_location, verbose) self.y_array = np.zeros(self.x_array.shape) self.trans_matrix_v = trans_matrix_v self.trans_matrix_theta = trans_matrix_theta self.fix_matrix_types() self.mapping = mapping self.dt = dt self.x_max = x_max # cdf for initial classes for whatever state definition being used self.init_class_cdf_v = get_cdf(init_count_v) self.init_class_cdf_theta = get_cdf(init_count_theta) self.blocked_particles = [] self._switched_classes = {} print 'Normalizing transition matrices...' self.normalize_trans_mat_colums(self.trans_matrix_theta) self.normalize_trans_mat_colums(self.trans_matrix_v)
def choose_next_class(self, current_class): indptr = self.trans_matrix.indptr start = indptr[current_class] end = indptr[current_class + 1] rows = self.trans_matrix.indices[start:end] values = self.trans_matrix.data[start:end] if len(values) == 0: return -12 cdf = get_cdf(values) return rows[bs.bisect_left(cdf, random.random())]
def __init__(self, n_particles, n_steps, dt, x_max, trans_matrix, class_velocity, init_class_count, inj_location="start", verbose=True): super(dispModelCorrelatedStencil, self).__init__(n_particles, n_steps, inj_location, verbose) self.trans_matrix = trans_matrix self.init_class_count = init_class_count self.class_velocity = class_velocity self.dt = dt self.x_max = x_max self.init_class_cdf = get_cdf(init_class_count) self.cdf_matrix = np.cumsum(trans_matrix, axis=0)
def __init__(self, n_particles, n_steps, dt, x_max, trans_matrix, mapping, init_class_count, inj_location="start", verbose=True): super(dispModelTime3d, self).__init__(n_particles, n_steps, inj_location, verbose) self.trans_matrix = trans_matrix self.init_class_count = init_class_count self.mapping = mapping self.dt = dt self.x_max = x_max self.init_class_cdf = get_cdf(init_class_count) self.n_class = np.sqrt(trans_matrix.shape[0]) self.blocked_particles = []
def __init__(self, n_particles, n_steps, dx, x_max, trans_matrix, class_log_edges, init_class_count, inj_location="start", verbose=True): super(dispModelCorrelatedSpaceKang, self).__init__(n_particles, n_steps, inj_location, verbose) self.trans_matrix = trans_matrix self.init_class_count = init_class_count self.class_log_edges = class_log_edges self.class_velocity = self.get_class_velocity(class_log_edges) self.dx = dx self.x_max = x_max self.init_class_cdf = get_cdf(init_class_count) self.cdf_matrix = np.cumsum(trans_matrix, axis=0)
def __init__(self, n_particles, n_steps, dx, x_max, trans_matrix, class_log_edges, init_class_count, inj_location="start", verbose=True): super(dispModelOrderTwo, self).__init__(n_particles, n_steps, inj_location, verbose) self.trans_matrix = trans_matrix self.init_class_count = init_class_count self.class_log_edges = class_log_edges self.class_velocity = self.get_class_velocity(class_log_edges) self.dx = dx self.x_max = x_max self.init_class_cdf = get_cdf(init_class_count) self.n_class = np.sqrt(trans_matrix.shape[0]) self.blocked_particles = []