Пример #1
0
def Measure(para, Observable,Factory, G0, W0, G, W, SigmaDeltaT, Sigma, Polar, Determ, ChiTensor):
    log.info("Measuring...")
    ChiTensor=calc.Add_ChiTensor_ZerothOrder(ChiTensor, G, Map)
    Chi = calc.Calculate_Chi(ChiTensor, Map)

    ##########OUTPUT AND FILE SAVE ####################
    spinUP=Map.Spin2Index(UP,UP)
    spinDOWN=Map.Spin2Index(DOWN,DOWN)

    Polar.FFT("R","T")
    W0.FFT("R")
    W.FFT("R","T")
    G0.FFT("R","T")
    G.FFT("R","T")
    SigmaDeltaT.FFT("R")
    Sigma.FFT("R","T")
    Chi.FFT("R","T")

    #print "Polar[UP,UP]=\n", Polar.Data[spinUP,0,spinUP,0,0,:]
    #print "Polar[DOWN, DOWN]=\n", Polar.Data[spinDOWN,0,spinDOWN,0,0,:]
    #print "W0=\n", W0.Data[spinUP,0,spinUP,1,0]
    #print "G0[UP,UP]=\n", G0.Data[UP,0,UP,0,0,:]
    #print "G0[DOWN,DOWN]=\n", G0.Data[DOWN,0,DOWN,0,0,:]
    #print "G[UP,UP]=\n", G.Data[UP,0,UP,0,0,:]
    #print "G[DOWN,DOWN]=\n", G.Data[DOWN,0,DOWN,0,0,:]
    #print "SigmaDeltaT[UP,UP]=\n", SigmaDeltaT.Data[UP,0,UP,0,0]
    #print "SigmaDeltaT[DOWN,DOWN]=\n", SigmaDeltaT.Data[DOWN,0,DOWN,0,0]
    #print "Sigma=\n", Sigma.Data[UP,0,UP,0,0,:]
    #print "Chi=\n", Chi.Data[0,0,0,0,0,:]
    #print "Chi=\n", Chi.Data[0,0,0,0,1,:]

    data={}
    data["Chi"]=Chi.ToDict()
    data["G"]=G.ToDict()
    data["W"]=W.ToDict()
    data["W"].update(W0.ToDict())
    data["SigmaDeltaT"]=SigmaDeltaT.ToDict()
    data["Sigma"]=Sigma.ToDict()
    data["Polar"]=Polar.ToDict()
    Observable.Measure(Chi, Determ, G, Factory.NearestNeighbor)

    with DelayedInterrupt():
        try:
            log.info("Save weights into {0} File".format(WeightFile))
            IO.SaveBigDict(WeightFile, data)
            parameter.Save(ParaFile, para)  #Save Parameters
            Observable.Save(OutputFile)

            #plot what you are interested in
            plot.PlotChiAlongPath(Chi, Lat)
            plot.PlotTime("G", G, UP, 0, UP, 0, 0)
            plot.PlotTime("G0UPUP", G0, UP, 0, UP, 0, 0)
            plot.PlotTime("G0DOWNDOWN", G0, DOWN, 0, DOWN, 0, 0)
            plot.PlotTime("Sigma", Sigma, DOWN, 1, DOWN, 1, 0)
            plot.PlotTime("Polar", Polar, UP, 0, UP, 0, 0)
            plot.PlotSpatial(Chi, Lat, 0, 0) 
            plot.PlotChi_2D(Chi, Lat)
            plot.PlotWeightvsR("\chi", Chi,Lat,0,0)
        except:
            log.info(blue("Output fails due to\n {0}".format(traceback.format_exc())))
Пример #2
0
    global MessageFile
    MessageFile=job["MessageFile"]
    global OutputFile
    OutputFile=job["OutputFile"]
    global StatisFile
    StatisFile=os.path.join(workspace, "statis_total")

    IsNewCalculation=not os.path.exists(WeightFile+".hkl")
    if not IsNewCalculation: 
        try:
            log.info(green("Try to load previous DYSHON_para file"))
            para=parameter.LoadPara(ParaFile)
            log.info("{0} para file is loaded".format(ParaFile))
        except:
            log.warning(red("Previous DYSHON_para file does not exist, use _in_DYSON_ file as para instead"))
            parameter.Save(ParaFile, para)  #Save Parameters

    WeightPara={"NSublat": para["Lattice"]["NSublat"], "L":para["Lattice"]["L"],
                "Beta": float(para["Tau"]["Beta"]), "MaxTauBin": para["Tau"]["MaxTauBin"]}
    Map=weight.IndexMap(**WeightPara)
    Lat=lat.Lattice(para["Lattice"]["Name"], Map)

    if args.collect:
        log.info("Collect statistics only...")
        SigmaMC, PolarMC=collect.CollectStatis(Map)
        collect.UpdateWeight((SigmaMC, PolarMC), para["Dyson"]["ErrorThreshold"], para["Dyson"]["OrderAccepted"])
        data ={}
        data["Sigma"] = {"Histogram": SigmaMC.ToDict()}
        data["Polar"] = {"Histogram": PolarMC.ToDict()}
        with DelayedInterrupt():
            IO.SaveBigDict(StatisFile, data)
Пример #3
0
def Measure(para,
            Observable,
            Factory,
            G0,
            W0,
            G,
            W,
            SigmaDeltaT,
            Sigma,
            Polar,
            Determ,
            ChiTensor,
            GGGammaG=None,
            WWGammaW=None):
    log.info("Measuring...")
    Map = G0.Map
    ChiTensor = calc.Add_ChiTensor_ZerothOrder(ChiTensor, G, Map)
    Chi = calc.Calculate_Chi(ChiTensor, Map)

    if para["Gamma3"]:
        BKChiTensor, _ = gamma3.FullGGGammaG(GGGammaG, W0, Map)
        BKChi = gamma3.Calculate_Chi(BKChiTensor, Map)
    else:
        BKChi = Chi

    ##########OUTPUT AND FILE SAVE ####################
    spinUP = Map.Spin2Index(UP, UP)
    spinDOWN = Map.Spin2Index(DOWN, DOWN)

    Polar.FFT("R", "T")
    W0.FFT("R")
    W.FFT("R", "T")
    G0.FFT("R", "T")
    G.FFT("R", "T")
    SigmaDeltaT.FFT("R")
    Sigma.FFT("R", "T")
    Chi.FFT("R", "T")

    print "Chi=\n", np.sum(Chi.Data[0, 0, 0, 0, :, :], axis=0)

    #print "Polar[UP,UP]=\n", Polar.Data[spinUP,0,spinUP,0,0,:]
    #print "Polar[DOWN, DOWN]=\n", Polar.Data[spinDOWN,0,spinDOWN,0,0,:]
    #print "W0=\n", W0.Data[spinUP,0,spinUP,0,1]
    # print "G0[UP,UP]=\n", G0.Data[UP,0,UP,0,0,:]
    # beta=0.5
    # Nt=16
    # t=np.array([(i+0.5)*beta/Nt for i in range(Nt)])
    # print np.exp(np.pi/2.0/beta*t*1j)/(1+1j)
    #print "G0[DOWN,DOWN]=\n", G0.Data[DOWN,0,DOWN,0,0,:]
    # G.FFT("K","T")
    # print "G[UP,UP]=\n", G.Data[UP,0,UP,0,:,-1]
    # print "G[DOWN,DOWN]=\n", G.Data[DOWN,0,DOWN,0,0,:]
    #print "SigmaDeltaT[UP,UP]=\n", SigmaDeltaT.Data[UP,0,UP,0,0]
    #print "SigmaDeltaT[DOWN,DOWN]=\n", SigmaDeltaT.Data[DOWN,0,DOWN,0,0]
    # for i in range(Map.MaxTauBin):
    # n=Sigma.Data[UP,0,UP,0,0,i]
    # print '%05f %05f %05f' % (i*Map.Beta/Map.MaxTauBin, n.real, n.imag)

    # if WWGammaW is not None:
    # RestoredWWGammaW=gamma3.UnCompressGammaW(WWGammaW, Map)
    # # RestoredWWGammaW=WWGammaW
    # print RestoredWWGammaW[0,1,0,0,:]
    # print RestoredWWGammaW[1,1,0,0,:]
    # print RestoredWWGammaW[0,0,0,0,:]
    # print RestoredWWGammaW[0,0,1,0,:]
    # print WWGammaW.shape

    data = {}
    data["Chi"] = Chi.ToDict()
    data["G"] = G.ToDict()
    data["W"] = W.ToDict()
    data["W"].update(W0.ToDict())
    data["SigmaDeltaT"] = SigmaDeltaT.ToDict()
    data["Sigma"] = Sigma.ToDict()
    data["Polar"] = Polar.ToDict()
    if Map.Dim == 2:
        TauSqueeze, TauRestore, TauSymFactor, TauFlag, RSqueeze, RRestore, RSymFactor = gamma3.SymmetryMapping(
            Map)
    if para["Gamma3"]:
        data["WWGammaW"] = {
            "TauSqueeze": TauSqueeze.flatten().tolist(),
            "TauSymFactor": TauSymFactor.flatten().tolist(),
            "TauFlag": TauFlag.flatten().tolist(),
            "RSqueeze": RSqueeze.flatten().tolist(),
            "RSymFactor": RSymFactor.flatten().tolist(),
            "RSize": len(RRestore),
            "TauSize": len(TauRestore)
        }
        BKChiTensor.FFT("R", "T")
        BKChi.FFT("R", "T")
        print "BKChi=\n", np.sum(BKChi.Data[0, 0, 0, 0, :, :], axis=0)

        data["BKChi"] = BKChi.ToDict()
        data["GGGammaG"] = {"SmoothT": GGGammaG}
        if WWGammaW is not None:
            data["WWGammaW"]["SmoothT"] = gamma3.CompressGammaW(WWGammaW, Map)

    Observable.Measure(Chi, BKChi, Determ, G, Factory.NearestNeighbor)

    with DelayedInterrupt():
        try:
            log.info("Save weights into {0} File".format(WeightFile))

            IO.SaveBigDict(WeightFile, data)

            parameter.Save(ParaFile, para)  #Save Parameters
            Observable.Save(OutputFile)

            #plot what you are interested in
            # plot.PlotChiAlongPath(Chi, Lat)
            plot.PlotTime("G", G, UP, 0, UP, 0, 0)
            plot.PlotTime("G0UPUP", G0, UP, 0, UP, 0, 0)
            plot.PlotTime("G0DOWNDOWN", G0, DOWN, 0, DOWN, 0, 0)
            plot.PlotTime("Sigma", Sigma, DOWN, 0, DOWN, 0, 0)
            plot.PlotTime("Polar", Polar, spinUP, 0, spinUP, 0, 0)
            plot.PlotSpatial(Chi, Lat, 0, 0)
            plot.PlotChi_2D(Chi, Lat)
            # plot.PlotWeightvsR("\chi", Chi,Lat,0,0)
            plot.PlotBand(G0, Lat)
        except:
            log.warning(
                blue("Output fails due to\n {0}".format(
                    traceback.format_exc())))