def generate_single_lookup(self, param_index): """ For a single parameter value with given index, create a list of the dressed-state indices corresponding to the canonical bare-state product states (whenever possible). Parameters ---------- param_index: int Returns ------- list of int dressed-state indices """ overlap_matrix = convert_esys_to_ndarray( self.dressed_specdata.state_table[param_index] ) # overlap amplitudes dressed_indices = [] for bare_basis_index in range( self.hilbertspace.dimension ): # for given bare basis index, find dressed index max_position = (np.abs(overlap_matrix[:, bare_basis_index])).argmax() max_overlap = np.abs(overlap_matrix[max_position, bare_basis_index]) if max_overlap < 0.5: # overlap too low, make no assignment dressed_indices.append(None) else: dressed_indices.append(max_position) return dressed_indices
def _generate_single_mapping(self, param_index): """ For a single parameter value with index `param_index`, create a list of the dressed-state indices in an order that corresponds one to one to the canonical bare-state product states with largest overlap (whenever possible). Parameters ---------- param_index: int Returns ------- list of int dressed-state indices """ overlap_matrix = spec_utils.convert_esys_to_ndarray(self._dressed_specdata.state_table[param_index]) dressed_indices = [] for bare_basis_index in range(self._hilbertspace.dimension): # for given bare basis index, find dressed index max_position = (np.abs(overlap_matrix[:, bare_basis_index])).argmax() max_overlap = np.abs(overlap_matrix[max_position, bare_basis_index]) if max_overlap < 0.5: # overlap too low, make no assignment dressed_indices.append(None) else: dressed_indices.append(max_position) return dressed_indices
def generate_state_lookup_table(self, spectrum_data, param_index=0): """ Create a lookup table that associates each dressed-state index with the corresponding bare-state product state index (whenever possible). Usually to be saved as self.state_lookup_table. Parameters ---------- spectrum_data: SpectrumData param_index: int indices > 0 become relevant when using ParameterSweep Returns ------- list(int), list(tuple) dressed indices, corresponding bare indices """ dims = self.subsystem_dims product_dim = np.prod(dims) overlap_matrix = convert_esys_to_ndarray(spectrum_data.state_table[param_index]) dressed_indices = [] for bare_basis_index in range(product_dim): max_position = (np.abs(overlap_matrix[:, bare_basis_index])).argmax() max_overlap = np.abs(overlap_matrix[max_position, bare_basis_index]) if max_overlap < 0.5: dressed_indices.append(None) else: dressed_indices.append(max_position) basis_label_ranges = [list(range(dims[subsys_index])) for subsys_index in range(self.subsystem_count)] basis_labels_list = list(itertools.product(*basis_label_ranges)) return [dressed_indices, basis_labels_list]
def convert_to_ndarray(entity): """Convert the object `entity` to a numpy ndarray of numerical dtype. This is needed in the routines for writing content of DataStores and SpectrumData to disk. Parameters ---------- entity: array_like """ if is_numerical_ndarray(entity): return entity if is_qutip_eigenstates(entity): # entity is output from qt.eigenstates return convert_esys_to_ndarray(entity) if isinstance(entity, (list, np.ndarray)) and is_qutip_eigenstates(entity[0]): # entity is a list of qt.eigenstates return np.asarray([convert_esys_to_ndarray(entry) for entry in entity]) # possibly we have a list of numerical values or a list of ndarrays converted_entity = np.asarray(entity) if converted_entity.dtype.kind not in set('biufc'): raise TypeError('Unable to convert data to numerical numpy array: ', entity) return converted_entity
def _serialize(self, writer): """ Parameters ---------- writer: BaseWriter """ np_state_table = None if isinstance(self.state_table, list): np_state_table = np.asarray([convert_esys_to_ndarray(esys_qutip) for esys_qutip in self.state_table]) elif isinstance(self.state_table, np.ndarray): np_state_table = self.state_table metadata_dict = self._get_metadata_dict() writer.create_meta(metadata_dict) writer.add_dataset('energy_table', self.energy_table) if self.state_table is not None: writer.add_dataset('state_table', np_state_table) if self.matrixelem_table is not None: writer.add_dataset('matrixelem_table', self.matrixelem_table)