def determine_grid(self): #key = [self.inputs['dim'], self.inputs['kmax'], self.inputs['lmax'], self.inputs['mmax'], self.inputs['nmax']] key = list(self.inputs.values()) tab1 = bootstrap.ConformalBlockTable(*key) tab2 = bootstrap.ConvolvedBlockTable(tab1) # Instantiate a Grid object with appropriate input values. grid = Grid(*key, [], []) for sig in self.sig_values: for eps in self.eps_values: sdp = bootstrap.SDP(sig, tab2) sdp.set_bound(0, float(self.gap)) sdp.add_point(0, eps) result = sdp.iterate() if result: grid.allowed_points.append((sig, eps)) else: grid.disallowed_points.append((sig, eps)) # Now append this grid object to the IsingGap table. # Note we will need to implement a look up table to retrieve desired data. self.table.append(grid)
def plot_grid(self, par_name, par_value, table): start_time=time.time() start_cpu=time.clock() allowed_sig=[] allowed_eps=[] disallowed_sig=[] disallowed_eps=[] for sig in self.sig_values: for eps in self.eps_values: sdp=bootstrap.SDP(sig,table) sdp.set_bound(0,float(self.gap)) sdp.add_point(0,eps) result=sdp.iterate() if result: allowed_sig.append(sig) allowed_eps.append(eps) else: disallowed_sig.append(sig) disallowed_eps.append(eps) end_time=time.time() end_cpu=time.clock() run_time=time.strftime("%H:%M:%S",time.gmtime(end_time-start_time)) cpu_time=time.strftime("%H:%M:%S",time.gmtime(end_cpu-start_cpu)) plt.plot(allowed_sig,allowed_eps,'r+') plt.plot(disallowed_sig,disallowed_eps,'b+') plt.title(par_name+"="+str(par_value)+". Time Taken: "+run_time+". CPU Time: "+cpu_time) plt.show()
def find_bounds(table1, table2, lower, upper, tol, channel): dim_phi = 0.5 x = [] y = [] while dim_phi < 0.6: sdp = bootstrap.SDP(dim_phi, table2) result = sdp.bisect(lower, upper, tol, channel) x.append(dim_phi) y.append(result) dim_phi += 0.002 plt.plot(x, y)
def plot_grid(dim, table, sig_range, eps_range): allowed_sig = [] allowed_eps = [] disallowed_sig = [] disallowed_eps = [] for sig in sig_range: for eps in eps_range: sdp = bootstrap.SDP(sig, table) sdp.set_bound(0, float(dim)) sdp.add_point(0, eps) result = sdp.iterate() if result: allowed_sig.append(sig) allowed_eps.append(eps) else: disallowed_sig.append(sig) disallowed_eps.append(eps) plt.plot(allowed_sig, allowed_eps, 'r+') plt.plot(disallowed_sig, disallowed_eps, 'b+') plt.show()
def determine_grid(self, key): #if self.get_grid_index(key) != -1: start_time=time.time() start_cpu=time.clock() tab1 = bootstrap.ConformalBlockTable(self.dim, *key) tab2 = bootstrap.ConvolvedBlockTable(tab1) # Instantiate a Grid object with appropriate input values. # grid=Grid(*key, [], []) grid = Grid(*(key + [[], [], 0, 0])) for sig in self.sig_values: for eps in self.eps_values: sdp = bootstrap.SDP(sig, tab2) # SDPB will naturally try to parallelize across 4 cores / slots. # To prevent this, we set its 'maxThreads' option to 1. # See 'common.py' for the list of SDPB option strings, as well as their default values. sdp.set_option("maxThreads", 1) sdp.set_bound(0, float(self.gap)) sdp.add_point(0, eps) result = sdp.iterate() if result: grid.allowed_points.append((sig, eps)) else: grid.disallowed_points.append((sig, eps)) # Now append this grid object to the IsingGap table. # Note we will need to implement a look up table to retrieve desired data. end_time=time.time() end_cpu=time.clock() run_time=end_time-start_time cpu_time=end_cpu-start_cpu run_time = datetime.timedelta(seconds = int(end_time - start_time)) cpu_time = datetime.timedelta(seconds = int(end_cpu - start_cpu)) grid.run_time = run_time grid.cpu_time = cpu_time self.table.append(grid) self.save_grid(grid, self.name)
print("Time taken: " + str(CB_time)) print("CPU_time: " + str(CB_cpu)) vec3 = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 4, 1, 0], [-1, 2, 0, 0], [1, 3, 0, 0]] vec2 = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 4, 1, 0], [1, 2, 0, 0], [-1, 3, 0, 0]] m1 = [[[1, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0]]] m2 = [[[0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [1, 0, 1, 1]]] m3 = [[[0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0]]] m4 = [[[0, 0, 0, 0], [0.5, 0, 0, 1]], [[0.5, 0, 0, 1], [0, 0, 0, 0]]] m5 = [[[0, 1, 0, 0], [0.5, 1, 0, 1]], [[0.5, 1, 0, 1], [0, 1, 0, 0]]] vec1 = [m1, m2, m3, m4, m5] info = [[vec1, 0, "z2-even-l-even"], [vec2, 0, "z2-odd-l-even"], [vec3, 1, "z2-odd-l-odd"]] if reference_sdp == None: sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=info) reference_sdp = sdp else: sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=info, prototype=reference_sdp) sdp.set_bound([0, "z2-even-l-even"], 3) sdp.set_bound([0, "z2-odd-l-even"], 3) sdp.add_point([0, "z2-even-l-even"], eps) sdp.add_point([0, "z2-odd-l-even"], sig) sdp.set_option("maxThreads", 16) sdp.set_option("dualErrorThreshold", 1e-15) print("Testing point " + "(" + sig.__str__() + ", " + eps.__str__() + ")...")
def determine_points(self, key): # Define two 'lattice vectors', v1, and v2. v1 moves us along a diagonal. v2 moves up a diagonal. v1 = [self.sig_step, self.eps_step] v2 = [self.eps_step] reference_sdp = None if type(self.sig_range) != list: self.sig_range = [self.sig_range, self.sig_range] if type(self.eps_range) != list: self.eps_range = [self.eps_range, self.eps_range] # Constant sig-eps lines: eps = sig - c. # Choose a starting point for each line. (0.5179, 1.4110). # g_tab1 and g_tab3 don't change on a given line of constant delta{sig,eps}. sig_values = np.arange(self.sig_range[0], self.sig_range[1] + self.sig_step, self.sig_step).tolist() for eps in np.arange(self.eps_range[0], self.eps_range[1] + self.eps_step, self.eps_step).tolist(): # sig_values = [] eps_values = [] # For each value of x along this line: for sig in sig_values: # sig_values.append(sig) eps_values.append(eps + (sig - self.sig_range[0])) # Could initiate all blocks prior to loop here using sig_values[0]. # However, want to capture the timing of this within the first point? blocks_initiated = False for i in range(len(sig_values)): sig = sig_values[i] eps = eps_values[i] global start_time start_time = time.time() global start_cpu start_cpu = time.clock() # Generate three conformal block tables, two of which depend on the dimension differences. # They need only be calculated once for any given diagonal. They remain constant along this line. # Uses the function above to return the 5 ConvolvedConformalBlocks we need. # The ConvolvedConformalBlock objects inherits the dimension differences from ConformalBlockTable. # We set odd_spins = True for odd those ConvolvedConformalBlocks appearing in odd-sector-odd-spins. # We set symmetric = True where required. if blocks_initiated == False: g_tab1 = bootstrap.ConformalBlockTable(self.dim, *key) g_tab2 = bootstrap.ConformalBlockTable( self.dim, *(key + [eps - sig, sig - eps, "odd_spins = True"])) g_tab3 = bootstrap.ConformalBlockTable( self.dim, *(key + [sig - eps, sig - eps, "odd_spins = True"])) tab_list = self.convolved_table_list( g_tab1, g_tab2, g_tab3) for tab in [g_tab1, g_tab2, g_tab3]: tab.dump("tab_" + str(tab.delta_12) + "_" + str(tab.delta_34)) del tab blocks_initiated = True global now global now_clock global CB_time global CB_cpu now = time.time() now_clock = time.clock() CB_time = datetime.timedelta(seconds=int(now - start_time)) CB_cpu = datetime.timedelta(seconds=int(now_clock - start_cpu)) print( "The calculation of the required conformal blocks has successfully completed." ) print("Time taken: " + str(CB_time)) print("CPU_time: " + str(CB_cpu)) # N.B vec3 & vec2 are 'raw' quads, which will be converted to 1x1 matrices automatically. # Third vector: 0, 0, 1 * table4 with one of each dimension, -1 * table2 with only pair[0] dimensions, 1 * table3 with only pair[0] dimensions vec3 = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 4, 1, 0], [-1, 2, 0, 0], [1, 3, 0, 0]] # Second vector: 0, 0, 1 * table4 with one of each dimension, 1 * table2 with only pair[0] dimensions, -1 * table3 with only pair[0] dimensions vec2 = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 4, 1, 0], [1, 2, 0, 0], [-1, 3, 0, 0]] # The first vector has five components as well but they are matrices of quads, not just the quads themselves. m1 = [[[1, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0]]] m2 = [[[0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [1, 0, 1, 1]]] m3 = [[[0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0, 0]]] m4 = [[[0, 0, 0, 0], [0.5, 0, 0, 1]], [[0.5, 0, 0, 1], [0, 0, 0, 0]]] m5 = [[[0, 1, 0, 0], [0.5, 1, 0, 1]], [[0.5, 1, 0, 1], [0, 1, 0, 0]]] vec1 = [m1, m2, m3, m4, m5] # The first rep must be the singlet even channel, where the unit operator resides. # After this, the order doesn't matter. # Spins for these again go even, even, odd. # The Z2 even sector has only even spins, Z2 odd sector runs over even and odd spins. info = [[vec1, 0, "z2-even-l-even"], [vec2, 0, "z2-odd-l-even"], [vec3, 1, "z2-odd-l-odd"]] # We instantiate the SDP object, inputting our vectorial sum info. # dim_list, convolved_block_table_list, vector_types (how they combine to compose sum rule). # We use the first calculated SDP object as a prototype for all the rest. # This is because some bounds remain unchanged, no need to recalculate basis. # Basis is independent of external scaling dimensions, cares only of the bounds on particular operators. sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=info) if reference_sdp == None: sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=info) reference_sdp = sdp else: sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=info, prototype=reference_sdp) # We assume the continuum in both Z2 odd / even sectors begins at the dimension=3. sdp.set_bound([0, "z2-even-l-even"], self.dim) sdp.set_bound([0, "z2-odd-l-even"], self.dim) # Except for the two lowest dimension scalar operators in each sector. sdp.add_point([0, "z2-even-l-even"], eps) sdp.add_point([0, "z2-odd-l-even"], sig) # We expect these calculations to be computationally intensive. # We set maxThreads=16 to parallelise SDPB for all runs. # See 'common.py' for the list of SDPB option strings, as well as their default values. sdp.set_option("maxThreads", 16) sdp.set_option("dualErrorThreshold", 1e-15) # Run the SDP to determine if the current operator spectrum is permissable. print("Testing point " + "(" + sig.__str__() + ", " + eps.__str__() + ")...") result = sdp.iterate() end_time = time.time() end_cpu = time.clock() global sdp_time global sdp_cpu sdp_time = datetime.timedelta(seconds=int(end_time - bootstrap.now2)) sdp_cpu = datetime.timedelta(seconds=int(end_cpu - bootstrap.now2_clock)) run_time = datetime.timedelta(seconds=int(end_time - start_time)) cpu_time = datetime.timedelta(seconds=int(end_cpu - start_cpu)) print("The SDP has finished running.") print("Time taken: " + str(sdp_time)) print("CPU_time: " + str(sdp_cpu)) print( "See point file for more information. Check the times are consistent" ) point = Point(*([sig, eps] + key + [ result, run_time, cpu_time, CB_time, CB_cpu, bootstrap.xml_time, bootstrap.xml_cpu, sdp_time, sdp_cpu ])) self.point_table.append(point) point.save(self.point_file)
def determine_row(self, key, row): # Will be called with a given row_lists[i] # row = row_lists[row_index] reference_sdp = None blocks_initiated = False for i in range(len(row[0])): sig = row[0][i] eps = row[1][i] start = time.time() start_cpu = time.clock() # Generate three conformal block tables, two of which depend on the dimension differences. # They need only be calculated once for any given diagonal. They remain constant along this line. # Uses the function above to return the 5 ConvolvedConformalBlocks we need. # The ConvolvedConformalBlock objects inherits the dimension differences from ConformalBlockTable. # We set odd_spins = True for odd those ConvolvedConformalBlocks appearing in odd-sector-odd-spins. # We set symmetric = True where required. if blocks_initiated == False: g_tab1 = bootstrap.ConformalBlockTable(self.dim, *key) g_tab2 = bootstrap.ConformalBlockTable( self.dim, *(key + [eps - sig, sig - eps, "odd_spins = True"])) g_tab3 = bootstrap.ConformalBlockTable( self.dim, *(key + [sig - eps, sig - eps, "odd_spins = True"])) tab_list = self.convolved_table_list(g_tab1, g_tab2, g_tab3) for tab in [g_tab1, g_tab2, g_tab3]: tab.dump("tab_" + str(tab.delta_12) + "_" + str(tab.delta_34)) del tab blocks_initiated = True max_dimension = 0 for tab in tab_list: max_dimension = max(max_dimension, len(tab.table[0].vector)) print("kmax should be around " + max_dimension.__str__() + ".") print("It is: " + key[0].__str__() + ".") #N.B NEED TO AMMEND THIS CALCULATION FOR THE NO OF COMPONENTS!!!!! components = (4 * len(tab_list[0].table[0].vector)) + ( 1 * len(tab_list[1].table[0].vector)) bootstrap.cb_end = time.time() bootstrap.cb_end_cpu = time.clock() cb_time = datetime.timedelta(seconds=int(bootstrap.cb_end - start)) cb_cpu = datetime.timedelta(seconds=int(bootstrap.cb_end_cpu - start_cpu)) print( "The calculation of the required conformal blocks has successfully completed." ) print("Time taken: " + str(cb_time)) print("CPU_time: " + str(cb_cpu)) # We instantiate the SDP object, inputting our vectorial sum info. # dim_list, convolved_block_table_list, vector_types (how they combine to compose sum rule). # We use the first calculated SDP object as a prototype for all the rest. # This is because some bounds remain unchanged, no need to recalculate basis. # Basis is independent of external scaling dimensions, cares only of the bounds on particular operators. # sdp = bootstrap.SDP([sig, eps], tab_list, vector_types = info) if reference_sdp == None: sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=self.info) reference_sdp = sdp else: sdp = bootstrap.SDP([sig, eps], tab_list, vector_types=self.info, prototype=reference_sdp) # We assume the continuum in both Z2 odd / even sectors begins at the dimension=3. sdp.set_bound([0, "z2-even-l-even"], self.dim) sdp.set_bound([0, "z2-odd-l-even"], self.dim) # Except for the two lowest dimension scalar operators in each sector. sdp.add_point([0, "z2-even-l-even"], eps) sdp.add_point([0, "z2-odd-l-even"], sig) # We expect these calculations to be computationally intensive. # We set maxThreads=16 to parallelise SDPB for all runs. # See 'common.py' for the list of SDPB option strings, as well as their default values. sdp.set_option("maxThreads", 16) sdp.set_option("dualErrorThreshold", 1e-15) sdp.set_option("maxIterations", 1000) # Run the SDP to determine if the current operator spectrum is permissable. print("Testing point " + "(" + sig.__str__() + ", " + eps.__str__() + ")" + " with " + components.__str__() + " components.") result = sdp.iterate() end = time.time() end_cpu = time.clock() sdp_time = datetime.timedelta(seconds=int(end - bootstrap.xml_end)) sdp_cpu = datetime.timedelta(seconds=int(end_cpu - bootstrap.xml_end_cpu)) run_time = datetime.timedelta(seconds=int(end - start)) cpu_time = datetime.timedelta(seconds=int(end_cpu - start_cpu)) print("The SDP has finished running.") print("Time taken: " + str(sdp_time)) print("CPU_time: " + str(sdp_cpu)) print( "See point file for more information. Check the times are consistent." ) point = Point(*([sig, eps] + key + [ components, max_dimension, result, run_time, cpu_time, cb_time, cb_cpu, bootstrap.xml_time, bootstrap.xml_cpu, sdp_time, sdp_cpu ])) self.point_table.append(point) point.save(self.point_file)
for tab in tab_list: max_dimension = max(max_dimension, len(tab.table[0].vector)) print("Number of components (dim of PolynomialVectorMatrices) : " + dimension.__str__() + ".") print("Kmax should be around (max dimension of convolved block tables): " + max_dimension.__str__() + ".") print("It is: " + key[0].__str__() + ".") cb_end = time.time() cb_end_cpu = time.clock() cb_time = datetime.timedelta(seconds = int(cb_end - start)) cb_cpu = datetime.timedelta(seconds = int(cb_end_cpu - start_cpu)) print("The calculation of the required conformal blocks has successfully completed.") print("Time taken: " + str(cb_time)) print("CPU_time: " + str(cb_cpu)) print("Creating SDP and writing XML file.") sdp = bootstrap.SDP([phi, sing], tab_list, vector_types = mixed.info) # We assume the continuum in both even vector and even singlet sectors begins at the dimension=3. sdp.set_bound([0, 0], 3) sdp.set_bound([0, 3], 3) # Except for the two lowest dimension scalar operators in each sector. sdp.add_point([0, 0], sing) sdp.add_point([0, 3], phi) sdp.set_option("maxThreads", 16) sdp.set_option("dualErrorThreshold", 1e-15) sdp.set_option("maxIterations", 1000) # Run the SDP to determine if the current operator spectrum is permissable. print("Testing point " + "(" + phi.__str__() + ", " + sing.__str__() + ") " + "with " + dimension.__str__() + " components.")
dim = 3 # Dictates the number of poles to keep and therefore the accuracy of a conformal block. k_max = 20 # Says that conformal blocks for spin-0 up to and including spin-14 should be computed. l_max = 14 # Conformal blocks are functions of (a, b) and as many derivatives of each should be kept for strong bounds. # This says to keep derivatives up to fourth order in b. n_max = 4 # For a given n, this states how many a derivatives should be included beyond 2 * (n - n_max). m_max = 2 # Generates the table. table1 = bootstrap.ConformalBlockTable(dim, k_max, l_max, m_max, n_max) # Computes the convolution. table2 = bootstrap.ConvolvedBlockTable(table1) # Sets up a semidefinite program that we can use to study this. sdp = bootstrap.SDP(dim_phi, table2) # We think it is perfectly find for all internal scalars coupling to our external one to have dimension above 0.7. lower = 0.7 # Conversely, we think it is a problem for crossing symmetry if they all have dimension above 1.7. upper = 1.7 # The boundary between these regions will be found within an error of 0.01. tol = 0.01 # The 0.7 and 1.7 are our guesses for scalars, not some other type of operator. channel = 0 # Calls SDPB to compute the bound. result = sdp.bisect(lower, upper, tol, channel) cprint( "If crossing symmetry and unitarity hold, the maximum gap we can have for Z2-even scalars is: " + str(result)) cprint( "Checking if (" + str(dim_phi) + ", " + str(result) +
def determine_row(self, key, row): # Will be called with a given row_lists[i] # Use generate_rows() method to build row_lists. # row = row_lists[row_index] reference_sdp = None blocks_initiated = False for i in range(len(row[0])): phi = eval_mpfr(row[0][i], bootstrap.prec) sing = eval_mpfr(row[1][i], bootstrap.prec) # phi_sing = eval_mpfr(phi - sing, bootstrap.prec) # sing_phi = eval_mpfr(sing - phi, bootstrap.prec) start = time.time() start_cpu = time.clock() if blocks_initiated == False: g_tab1 = bootstrap.ConformalBlockTable( self.dim, *(key + [0, 0, "odd_spins = True"])) g_tab2 = bootstrap.ConformalBlockTable( self.dim, *(key + [phi - sing, phi - sing, "odd_spins = True"])) g_tab3 = bootstrap.ConformalBlockTable( self.dim, *(key + [sing - phi, phi - sing, "odd_spins = True"])) f_tab1a = bootstrap.ConvolvedBlockTable(g_tab1) f_tab1s = bootstrap.ConvolvedBlockTable(g_tab1, symmetric=True) f_tab2a = bootstrap.ConvolvedBlockTable(g_tab2) f_tab3a = bootstrap.ConvolvedBlockTable(g_tab3) f_tab3s = bootstrap.ConvolvedBlockTable(g_tab3, symmetric=True) tab_list = [f_tab1a, f_tab1s, f_tab2a, f_tab3a, f_tab3s] for tab in [g_tab1, g_tab2, g_tab3]: # tab.dump("tab_" + str(tab.delta_12) + "_" + str(tab.delta_34)) del tab blocks_initiated = True max_dimension = 0 for tab in tab_list: max_dimension = max(max_dimension, len(tab.table[0].vector)) print("kmax should be around " + max_dimension.__str__() + ".") dimension = (5 * len(f_tab1a.table[0].vector)) + ( 2 * len(f_tab1s.table[0].vector)) bootstrap.cb_end = time.time() bootstrap.cb_end_cpu = time.clock() cb_time = datetime.timedelta(seconds=int(bootstrap.cb_end - start)) cb_cpu = datetime.timedelta(seconds=int(bootstrap.cb_end_cpu - start_cpu)) print( "The calculation of the required conformal blocks has successfully completed." ) print("Time taken: " + str(cb_time)) print("CPU_time: " + str(cb_cpu)) if reference_sdp == None: sdp = bootstrap.SDP([phi, sing], tab_list, vector_types=self.info) reference_sdp = sdp else: sdp = bootstrap.SDP([phi, sing], tab_list, vector_types=self.info, prototype=reference_sdp) # We assume the continuum in both even vector and even singlet sectors begins at the dimension=3. sdp.set_bound([0, 0], self.dim) sdp.set_bound([0, 3], self.dim) # Except for the two lowest dimension scalar operators in each sector. sdp.add_point([0, 0], sing) sdp.add_point([0, 3], phi) sdp.set_option("maxThreads", 16) sdp.set_option("dualErrorThreshold", 1e-15) sdp.set_option("maxIterations", 1000) # Run the SDP to determine if the current operator spectrum is permissable. print("Testing point " + "(" + phi.__str__() + ", " + sing.__str__() + ")" + " with " + dimension.__str__() + " components.") result = sdp.iterate() end = time.time() end_cpu = time.clock() sdp_time = datetime.timedelta(seconds=int(end - bootstrap.xml_end)) sdp_cpu = datetime.timedelta(seconds=int(end_cpu - bootstrap.xml_end_cpu)) run_time = datetime.timedelta(seconds=int(end - start)) cpu_time = datetime.timedelta(seconds=int(end_cpu - start_cpu)) print("The SDP has finished running.") print("Time taken: " + str(sdp_time)) print("CPU_time: " + str(sdp_cpu)) print( "See point file for more information. Check the times are consistent." ) point = Point(*([phi, sing] + key + [ components, max_dimension, result, run_time, cpu_time, cb_time, cb_cpu, bootstrap.xml_time, bootstrap.xml_cpu, sdp_time, sdp_cpu ])) self.point_table.append(point) point.save(self.point_file)