def initialize_edges(self): '''Initialize self.edges and self.leak_flux_matrix attributes. This method initializes the self.edges attribute based on the v_min, v_max, and dv settings, and creates a corresponding leak flux matrix based on this voltage discretization. ''' # Voltage edges and leak matrix construction self.tau_m = util.discretize_if_needed(self.tau_m) if np.sum(self.tau_m.xk <= 0) > 0: raise Exception('Negative tau_m values detected: %s' % self.tau_m.xk) # pragma: no cover # Voltage edges and leak matrix construction self.edges = util.get_v_edges(self.v_min, self.v_max, self.dv) # Different leak matrices for different solvers: self.leak_flux_matrix_dict = {} self.leak_flux_matrix_dict['dense'] = util.leak_matrix( self.edges, self.tau_m) # Backward Euler sparse: lfm_csrbe = sps.eye( np.shape(self.leak_flux_matrix_dict['dense'])[0], format='csr' ) - self.simulation.dt * self.leak_flux_matrix_dict['dense'] M_I, M_J = np.where(np.array(lfm_csrbe) != 0) M_val = lfm_csrbe[M_I, M_J] self.leak_flux_matrix_dict['sparse'] = (M_I, M_J, M_val)
def initialize_edges(self): '''Initialize self.edges and self.leak_flux_matrix attributes. This method initializes the self.edges attribute based on the v_min, v_max, and dv settings, and creates a corresponding leak flux matrix based on this voltage discretization. ''' # Voltage edges and leak matrix construction self.tau_m = util.discretize_if_needed(self.tau_m) if np.sum(self.tau_m.xk <= 0) > 0: raise Exception('Negative tau_m values detected: %s' % self.tau_m.xk) # pragma: no cover # Voltage edges and leak matrix construction self.edges = util.get_v_edges(self.v_min, self.v_max, self.dv) # Different leak matrices for different solvers: self.leak_flux_matrix_dict = {} self.leak_flux_matrix_dict['dense'] = util.leak_matrix(self.edges, self.tau_m) # Backward Euler sparse: lfm_csrbe = sps.eye(np.shape(self.leak_flux_matrix_dict['dense'])[0], format='csr') - self.simulation.dt*self.leak_flux_matrix_dict['dense'] M_I, M_J = np.where(np.array(lfm_csrbe) != 0) M_val = lfm_csrbe[M_I, M_J] self.leak_flux_matrix_dict['sparse'] = (M_I, M_J, M_val)
def initialize_edges(self): '''Initialize self.edges and self.leak_flux_matrix attributes. This method initializes the self.edges attribute based on the v_min, v_max, and dv settings, and creates a corresponding leak flux matrix based on this voltage discretization. ''' # Voltage edges and leak matrix construction self.edges = util.get_v_edges(self.v_min, self.v_max, self.dv) self.leak_flux_matrix = util.leak_matrix(self.edges, self.tau_m)
def initialize_edges(self): '''Initialize self.edges and self.leak_flux_matrix attributes. This method initializes the self.edges attribute based on the v_min, v_max, and dv settings, and creates a corresponding leak flux matrix based on this voltage discretization. ''' # Voltage edges and leak matrix construction self.tau_m = util.discretize_if_needed(self.tau_m) if np.sum(self.tau_m.xk <= 0) > 0: raise Exception('Negative tau_m values detected: %s' % self.tau_m.xk) # pragma: no cover self.edges = util.get_v_edges(self.v_min, self.v_max, self.dv) self.leak_flux_matrix = util.leak_matrix(self.edges, self.tau_m)