Ejemplo n.º 1
0
def markersColors(numColors):
    '''return the markers and colors used for plotting.'''

    # He4 Pore PRL Colors
#    colors = ['#556270','#1C3249','#4ECDC4','#19857D','#C7F464','#FF6B6B','#A62323'] #556270

    # http://www.graphviz.org/content/color-names
    if numColors == 1:
        numColors+=1;
    #colors  = loadgmt.getColorList('cb/div','Spectral_08',numColors)
    #colors  = loadgmt.getColorList('cb/div','PiYG_07',numColors)
    colors  = loadgmt.getColorList('cb/qual','Set1_09',numColors)

    # colors.reverse()
    markers = loadgmt.getMarkerList()

    return markers,colors
Ejemplo n.º 2
0
def markersColors(numColors):
    '''return the markers and colors used for plotting.'''

    # He4 Pore PRL Colors
    #    colors = ['#556270','#1C3249','#4ECDC4','#19857D','#C7F464','#FF6B6B','#A62323'] #556270

    # http://www.graphviz.org/content/color-names
    if numColors == 1:
        numColors += 1
    #colors  = loadgmt.getColorList('cb/div','Spectral_08',numColors)
    #colors  = loadgmt.getColorList('cb/div','PiYG_07',numColors)
    colors = loadgmt.getColorList('cb/qual', 'Set1_09', numColors)

    # colors.reverse()
    markers = loadgmt.getMarkerList()

    return markers, colors
Ejemplo n.º 3
0
def main():

    # define the mapping between short names and label names 
    shortFlags = ['n','T','N','t','u','V','L','W','D']
    parMap = {'n':'Initial Density', 'T':'Temperature', 'N':'Initial Number Particles',
              't':'Imaginary Time Step', 'u':'Chemical Potential', 'V':'Container Volume',
              'L':'Container Length', 'W':'Virial Window', 'M':'Update Length'}  #'M':'Update Slices (Mbar)'}

    # setup the command line parser options 
    parser = OptionParser() 
    parser.add_option("-T", "--temperature", dest="T", type="float",
                      help="simulation temperature in Kelvin") 
    parser.add_option("-N", "--number-particles", dest="N", type="int",
                      help="number of particles") 
    parser.add_option("-n", "--density", dest="n", type="float",
                      help="number density in Angstroms^{-d}")
    parser.add_option("-t", "--imag-time-step", dest="tau", type="float",
                      help="imaginary time step")
    parser.add_option("-u", "--chemical-potential", dest="mu", type="float",
                      help="chemical potential in Kelvin") 
    parser.add_option("-L", "--Lz", dest="L", type="float",
                      help="Length in Angstroms") 
    parser.add_option("-V", "--volume", dest="V", type="float",
                      help="volume in Angstroms^d") 
    parser.add_option("-r", "--reduce", dest="reduce",
                      choices=['T','N','n','u','t','L','V','W','M'], 
                      help="variable name for reduction [T,N,n,u,t,L,V,W,M]") 
    parser.add_option("--canonical", action="store_true", dest="canonical",
                      help="are we in the canonical ensemble?")
    parser.add_option("-p", "--plot", action="store_true", dest="plot",
                      help="do we want to produce data plots?") 
    parser.add_option("-R", "--radius", dest="R", type="float",
                      help="radius in Angstroms") 
    parser.add_option("-s", "--skip", dest="skip", type="int",
                      help="number of measurements to skip") 
    parser.add_option("-e", "--estimator", dest="estimator", type="str",
                      help="specify a single estimator to reduce") 
    parser.add_option("-i", "--pimcid", dest="pimcid", type="str",
                      help="specify a single pimcid") 
    parser.set_defaults(canonical=False)
    parser.set_defaults(plot=False)
    parser.set_defaults(skip=0)

    # parse the command line options and get the reduce flag
    (options, args) = parser.parse_args() 

    # Determine the working directory
    if args:
        baseDir = args[0]
        if baseDir == '.':
            baseDir = ''
    else:
        baseDir = ''

    skip = options.skip
    
    if (not options.reduce):
        parser.error("need a correct reduce flag (-r,--reduce): [T,N,n,u,t,L,V,W,D]")

    # Check that we are in the correct ensemble
    pimchelp.checkEnsemble(options.canonical)

    dataName,outName = pimchelp.getFileString(options)
    reduceFlag = []
    reduceFlag.append(options.reduce)
    reduceFlag.append(parMap[options.reduce])

    # Create the PIMC analysis helper and fill up the simulation parameters maps
    pimc = pimchelp.PimcHelp(dataName,options.canonical,baseDir=baseDir)
    pimc.getSimulationParameters()

    # Form the full output file name
    if options.R == None:
        outName += '.dat'
    else:
        outName += '-R-%04.1f.dat' % options.R

    # possible types of estimators we may want to reduce
    estList = ['estimator', 'super', 'obdm', 'pair', 'radial', 'number', 
               'radwind', 'radarea', 'planedensity', 'planearea',
               'planewind','virial','linedensity','linepotential']
    estDo = {e:False for e in estList}

    # if we specify a single estimator, only do that one
    if options.estimator:
        estDo[options.estimator] = True
    # otherwise test to see if the file exists
    else:
        for e in estList:
            if pimc.getFileList(e):
                estDo[e] = True
            else:
                estDo[e] = False

    # We first reduce the scalar estimators and output them to disk
    if estDo['estimator']:
        head1,scAve1,scErr1 = getScalarEst('estimator',pimc,outName,reduceFlag,skip=skip)

    if estDo['virial']:
        head1,scAve1,scErr1 = getScalarEst('virial',pimc,outName,reduceFlag,skip=skip)

    if estDo['super']:
        head2,scAve2,scErr2 = getScalarEst('super',pimc,outName,reduceFlag,skip=skip)

    # Now we do the normalized one body density matrix
    if estDo['obdm']:
        x1,ave1,err1 = getVectorEst('obdm',pimc,outName,reduceFlag,'r [A]','n(r)',skip=skip)

    # Now we do the pair correlation function
    if estDo['pair']:
        x2,ave2,err2 = getVectorEst('pair',pimc,outName,reduceFlag,'r [A]','g(r)',skip=skip)

    # The radial Density
    if estDo['radial']:
        x3,ave3,err3 = getVectorEst('radial',pimc,outName,reduceFlag,'r [A]','rho(r)',skip=skip)

    # Compute the number distribution function and compressibility if we are in
    # the grand canonical ensemble
    if estDo['number']:
        x4,ave4,err4 = getVectorEst('number',pimc,outName,reduceFlag,'N','P(N)',skip=skip)

# I don't know why this isn't working, MCStat is giving me an error, will
    # return to this later. AGD 
        #kappa,kappaErr = getKappa(pimc,outName,reduceFlag)

    # The radially averaged Winding superfluid density
    if estDo['radwind']:
        x5,ave5,err5 = getVectorEst('radwind',pimc,outName,reduceFlag,'r [A]','rho_s(r)',skip=skip)

    # The radially averaged area superfliud density
    if estDo['radarea']:
        x6,ave6,err6 = getVectorEst('radarea',pimc,outName,reduceFlag,'r [A]','rho_s(r)',skip=skip)

    if estDo['planewind']:
        x7,ave7,err7 = getVectorEst('planewind',pimc,outName,reduceFlag,'n','rho_s(r)',skip=skip)

    if estDo['planearea']:
        x8,ave8,err8 = getVectorEst('planearea',pimc,outName,reduceFlag,'n','rho_s(r)',skip=skip)

    if estDo['planedensity']:
        x9,ave9,err9 = getVectorEst('planedensity',pimc,outName,reduceFlag,'n','rho(r)',skip=skip)

    if estDo['linedensity']:
        x10,ave10,err10 = getVectorEst('linedensity',pimc,outName,reduceFlag,\
                                       'r [A]','rho1d(r)',skip=skip)
    if estDo['linepotential']:
        x11,ave11,err11 = getVectorEst('linepotential',pimc,outName,reduceFlag,\
                                       'r [A]','V1d(r)',skip=skip)

    # Do we show plots?
    if options.plot:

        figNum = 1
        # Get the changing parameter that we are plotting against
        param = []
        for ID in pimc.id:
            param.append(float(pimc.params[ID][reduceFlag[1]]))
        numParams = len(param)
        markers = loadgmt.getMarkerList()
        colors  = loadgmt.getColorList('cw/1','cw1-029',10)

        # -----------------------------------------------------------------------------
        # Plot the averaged data
        # -----------------------------------------------------------------------------
        if estDo['estimator']:

            headLab = ['E/N','K/N','V/N','N', 'diagonal']
            dataCol = []
            for head in headLab:
                n = 0
                for h in head1:
                    if head == h:
                        dataCol.append(n)
                        break
                    n += 1
            yLabelCol = ['Energy / N', 'Kinetic Energy / N', 'Potential Energy / N',\
                    'Number Particles', 'Diagonal Fraction']

        
            # ============================================================================
            # Figure -- Various thermodynamic quantities
            # ============================================================================
            for n in range(len(dataCol)):
                figure(figNum)
                connect('key_press_event',kevent.press)
        
                errorbar(param, scAve1[:,dataCol[n]], yerr=scErr1[:,dataCol[n]],\
                        color=colors[n],marker=markers[n],markeredgecolor=colors[n],\
                        markersize=8,linestyle='None',capsize=4)
        
                xlabel('%s'%options.reduce)
                ylabel(yLabelCol[n])
                tight_layout()
                figNum += 1
    
        # ============================================================================
        # Figure -- The superfluid density
        # ============================================================================
        if estDo['super']:
            figure(figNum)
            connect('key_press_event',kevent.press)
        
            errorbar(param, scAve2[:,0], yerr=scErr2[:,0],\
                    color=colors[0],marker=markers[0],markeredgecolor=colors[0],\
                    markersize=8,linestyle='None',capsize=4)
        
            tight_layout()
            xlabel('%s'%options.reduce)
            ylabel('Superfluid Density')
    
        # ============================================================================
        # Figure -- The one body density matrix
        # ============================================================================
        if estDo['obdm']:
            figNum += 1
            figure(figNum)
            connect('key_press_event',kevent.press)
            ax = subplot(111)
    
            for n in range(numParams):
                lab = '%s = %s' % (options.reduce,param[n])
                errorbar(x1[n,:], (ave1[n,:]+1.0E-15), err1[n,:],color=colors[n],marker=markers[0],\
                        markeredgecolor=colors[n], markersize=8,linestyle='None',label=lab)
    
                #axis([0,21,1.0E-5,1.1])
            xlabel('r [Angstroms]')
            ylabel('One Body Density Matrix')
            tight_layout()
            legend(loc='best', frameon=False, prop={'size':16},ncol=2)
    
        # ============================================================================
        # Figure -- The pair correlation function
        # ============================================================================
        if estDo['pair']:
            figNum += 1
            figure(figNum)
            connect('key_press_event',kevent.press)
        
            for n in range(numParams):
                lab = '%s = %s' % (options.reduce,param[n])
                errorbar(x2[n,:], ave2[n,:], yerr=err2[n,:],color=colors[n],marker=markers[0],\
                        markeredgecolor=colors[n], markersize=8,linestyle='None',label=lab,capsize=6)
        
                #   axis([0,256,1.0E-5,1.2])
            xlabel('r [Angstroms]')
            ylabel('Pair Correlation Function')
            legend(loc='best', frameon=False, prop={'size':16},ncol=2)
            tight_layout()
    
        # We only plot the compressibility if we are in the grand-canonical ensemble
        if not options.canonical:
    
            # ============================================================================
            # Figure -- The Number distribution
            # ============================================================================
            if estDo['number']:
                figNum += 1
                figure(figNum)
                connect('key_press_event',kevent.press) 

                # Find which column contains the average number of particles
                for hn,h in enumerate(head1):
                    if h == 'N':
                        break

                for n in range(numParams): 
                    lab = '%s = %s' % (options.reduce,param[n]) 
                    aN = scAve1[n,hn] 
                    errorbar(x4[n,:]-aN, ave4[n,:], err4[n,:],color=colors[n],marker=markers[0],\
                             markeredgecolor=colors[n],\
                             markersize=8,linestyle='None',label=lab,capsize=6) 
        
                axis([-30,30,0.0,1.2])
                xlabel(r'$N-\langle N \rangle$')
                ylabel('P(N)')
                tight_layout()
                legend(loc='best', frameon=False, prop={'size':16},ncol=2)
        
                # ============================================================================
                # Figure -- The Compressibility
                # ============================================================================
                #figNum += 1
                #figure(figNum)
                #connect('key_press_event',kevent.press)

                #errorbar(param, kappa, yerr=kappaErr, color=colors[0],marker=markers[0],\
                #        markeredgecolor=colors[0], markersize=8,linestyle='None',capsize=6)
        
                #tight_layout()
                #xlabel('%s'%options.reduce)
                #ylabel(r'$\rho^2 \kappa$')
    
        # ============================================================================
        # Figure -- The radial density
        # ============================================================================
        if len(glob.glob('CYLINDER')) > 0:
            figNum += 1
            figure(figNum)
            connect('key_press_event',kevent.press)
            ax = subplot(111)
    
            for n in range(numParams):
                lab = '%s = %s' % (options.reduce,param[n])
                errorbar(x3[n,:], (ave3[n,:]+1.0E-15), err3[n,:],color=colors[n],marker=markers[0],\
                        markeredgecolor=colors[n], markersize=8,linestyle='None',label=lab)
    
                #axis([0,21,1.0E-5,1.1])
            tight_layout()
            xlabel('r [Angstroms]')
            ylabel('Radial Density')
            legend(loc='best', frameon=False, prop={'size':16},ncol=2)
    
        show()