|
| 1 | +import sage.cboot as cb |
| 2 | +context=cb.context_for_scalar(epsilon=0.5,Lambda=13) |
| 3 | + |
| 4 | +lmax=25 |
| 5 | +nu_max=12 |
| 6 | +cbs={} |
| 7 | +for spin in range(0,lmax,2): |
| 8 | + g=context.approx_cb(nu_max,spin) |
| 9 | + cbs.update({spin:g}) |
| 10 | + |
| 11 | +def make_F(delta,spin,gap_dict): |
| 12 | + mat_F=context.make_F_minus_matrix(delta) |
| 13 | + try: |
| 14 | + gap=context(gap_dict[spin]) |
| 15 | + except KeyError: |
| 16 | + if spin==0: |
| 17 | + gap=context.epsilon |
| 18 | + else: |
| 19 | + gap=2*context.epsilon+spin |
| 20 | + g_shift=cbs[spin].shift(gap) |
| 21 | + F=context.dot(mat_F,g_shift) |
| 22 | + return F |
| 23 | + |
| 24 | +def make_SDP(delta,gap_dict): |
| 25 | + delta=context(delta) |
| 26 | + Fs=[make_F(delta,spin,gap_dict) for spin in cbs.keys()] |
| 27 | + mat_F=context.make_F_minus_matrix(delta) |
| 28 | + norm=context.dot(mat_F,context.gBlock(0,0,0,0)) |
| 29 | + obj=norm*0 |
| 30 | + return context.SDP(norm,obj,Fs) |
| 31 | + |
| 32 | +from subprocess import Popen, PIPE |
| 33 | +import re |
| 34 | + |
| 35 | +sdpb="sdpb" |
| 36 | +sdpbparams=["--findPrimalFeasible","--findDualFeasible","--noFinalCheckpoint"] |
| 37 | +def bs(delta,upper=3,lower=1,sdp_method=make_SDP): |
| 38 | + upper=context(upper) |
| 39 | + lower=context(lower) |
| 40 | + while upper - lower > 0.001: |
| 41 | + D_try=(upper+lower)/2 |
| 42 | + prob=sdp_method(delta,{0:D_try}) |
| 43 | + prob.write("3d_Ising_binary.xml") |
| 44 | + sdpbargs=[sdpb,"-s","3d_Ising_binary.xml"]+sdpbparams |
| 45 | + out, err=Popen(sdpbargs,stdout=PIPE,stderr=PIPE).communicate() |
| 46 | + sol=re.compile(r'found ([^ ]+) feasible').search(out).groups()[0] |
| 47 | + if sol=="dual": |
| 48 | + print("(Delta_phi, Delta_epsilon)={0} is excluded."\ |
| 49 | + .format((float(delta),float(D_try)))) |
| 50 | + upper=D_try |
| 51 | + elif sol=="primal": |
| 52 | + print("(Delta_phi, Delta_epsilon)={0} is permitted."\ |
| 53 | + .format((float(delta),float(D_try)))) |
| 54 | + lower=D_try |
| 55 | + else: |
| 56 | + raise RuntimeError("Unexpected return from sdpb") |
| 57 | + return upper |
| 58 | + |
| 59 | +def make_SDP_for_cc(delta,gap_dict={0:1}): |
| 60 | + delta=context(delta) |
| 61 | + Fs=[make_F(delta,spin,gap_dict) for spin in cbs.keys()] |
| 62 | + mat_F=context.make_F_minus_matrix(delta) |
| 63 | + norm=context.dot(mat_F,context.gBlock(2,3,0,0)) |
| 64 | + obj=context.dot(mat_F,context.gBlock(0,0,0,0)) |
| 65 | + return context.SDP(norm,obj,Fs) |
| 66 | + |
| 67 | +def cc(delta): |
| 68 | + prob=make_SDP_for_cc(delta) |
| 69 | + prob.write("3d_Ising_cc.xml") |
| 70 | + sdpbargs=[sdpb,"-s","3d_Ising_cc.xml","--noFinalCheckpoint"] |
| 71 | + out, err=Popen(sdpbargs,stdout=PIPE,stderr=PIPE).communicate() |
| 72 | + sol=re.compile(r'primalObjective *= *([^ ]+) *$',re.MULTILINE)\ |
| 73 | + .search(out).groups()[0] |
| 74 | + return -delta**2/float(sol) |
| 75 | + |
| 76 | +def make_SDP_epsilon_prime(delta,gap_dict): |
| 77 | + delta=context(delta) |
| 78 | + Fs=[make_F(delta,spin,gap_dict) for spin in cbs.keys()] |
| 79 | + mat_F=context.make_F_minus_matrix(delta) |
| 80 | + Fs+=[context.dot(mat_F,context.gBlock(0,delta,0,0))] |
| 81 | + norm=context.dot(mat_F,context.gBlock(0,0,0,0)) |
| 82 | + obj=norm*0 |
| 83 | + return context.SDP(norm,obj,Fs) |
| 84 | + |
| 85 | +if __name__=='__main__': |
| 86 | + # The default example |
| 87 | + #delta=0.518 |
| 88 | + #print(bs(delta)) |
| 89 | + |
| 90 | + # =============================================== |
| 91 | + # if you want to derive the central charge lower bound, |
| 92 | + # uncomment the follwing lines. |
| 93 | + #delta=0.518 |
| 94 | + #print("central charge lower bound at delta={0} is {1}"\ |
| 95 | + # .format(delta,cc(delta))) |
| 96 | + |
| 97 | + # =============================================== |
| 98 | + # The upper bound on epsilon' dimension. |
| 99 | + Delta_epsilon=0.8 |
| 100 | + print(bs(Delta_epsilon,sdp_method=make_SDP_epsilon_prime)) |
0 commit comments