def _parse_td_protocol(self, td_protocol_name):
     """Input must be a string, parsed to figure out the protocol to use."""
     if td_protocol_name == 'doublebang':
         self.td_protocol = protocol_ansatz.DoubleBangProtocolAnsatz()
     elif td_protocol_name == 'bangramp':
         self.td_protocol = protocol_ansatz.BangRampProtocolAnsatz()
     elif td_protocol_name == 'triplebang':
         self.td_protocol = protocol_ansatz.TripleBangProtocolAnsatz()
     else:
         raise ValueError('Other protocols must be given explicitly.')
Exemplo n.º 2
0

# ------ set up logger
output_file_name = 'scan_{}spins_bound{}.csv'.format(num_spins, bound[1])
logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s]"
                                 "[%(levelname)-5.5s]  %(message)s")
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.DEBUG)
fileHandler = logging.FileHandler(output_file_name[:-4] + '.log')
fileHandler.setFormatter(logFormatter)
fileHandler.setLevel(logging.DEBUG)
rootLogger.addHandler(fileHandler)
logging.info('Output file name will be "{}"'.format(output_file_name))

# ------ GOGOGOGO
logging.info('Starting iteration loop')
results = np.zeros(shape=(len(tf_list) * len(time_ratios_list), 3))
idx = 0
for out_idx, tf in enumerate(tf_list):
    logging.info('Starting iteration {}/{}'.format(out_idx + 1, len(list(tf_list))))
    for ratio in time_ratios_list:
        protocol = protocols.DoubleBangProtocolAnsatz()
        protocol.fill_hyperpar_value(tf=tf)
        fun = protocol.time_dependent_fun(np.asarray([bound[1], ratio * tf, bound[0]]))
        output_state = optimization.evolve_state([lmg.H0, [lmg.H1, fun]], initial_state, tf)
        results[idx] = [tf, ratio, qutip.fidelity(output_state, target_state)**2]
        idx += 1
results = pd.DataFrame(results, columns=['tf', 'ratio', 'fid'])

results.to_csv('scan_{}spins_bound{}.csv'.format(num_spins, bound[1]))