예제 #1
0
def file_names(stage, s=0, p=0):
    """ Returns a dictionary of file names corresponding to each stage of the program """

    # Get the correct names for p, s
    sname, pname = ini.naming_system(s, p)

    if stage in ('input', 'output'):
        leaf = pname[0] + sname[0] + ".out"
    elif stage == 'scomb':
        leaf = pname[0] + sname[1] + ".out"
    else:
        error(this_file, "Invalid argument: " + stage)

    cuts = "cuts" + leaf
    accepts = "accepts" + leaf
    dmu = "dmu" + leaf
    dmu_acc = "dmu_acc" + leaf
    dE = "dE" + leaf
    dE_acc = "dE_acc" + leaf
    minimat = "minimat" + leaf
    round_trips = "round_trips" + leaf

    return_dict =  {'cu': cuts, 'ac': accepts, \
                    'dm': dmu, 'dma': dmu_acc, \
                    'de': dE, 'dea': dE_acc, \
                    'rt': round_trips}

    if TRAP == True:
        return_dict['mm'] = minimat

    return return_dict
예제 #2
0
def file_names(stage, s=0, p=0):
    """ Retuns a dictionary of file names corresponding to each stage of the program """

    # Get the correct names for p, s
    sname, pname = ini.naming_system(s, p)

    if stage == 'input':
        # Input file names include appropriate '_pY_sX'
        disp_in = "disp" + pname[0] + sname[0] + ".out"
        weights_in = "weights_TM" + pname[1] + sname[0] + ".out" # pcomb: combined within each subdom
        hist_in = "hist_TM" + pname[0] + sname[0] + ".out"
        Cmat_in = "Cmat_TM" + pname[0] + sname[0] + ".out"
        return {'d': disp_in, 'w': weights_in, 'h': hist_in, 'c': Cmat_in}
    
    elif stage == 'output':
        # Output file names include appropriate '_pY_sX'
        disp_out = "disp" + pname[0] + sname[0] + ".out"
        weights_out = "weights_TM" + pname[0] + sname[0] + ".out"
        hist_out = "hist_TM" + pname[0] + sname[0] + ".out"
        Cmat_out = "Cmat_TM" + pname[0] + sname[0] + ".out"
        eigvec_out = "eigvec_TM" + pname[0] + sname[0] + ".out"
        series_out = "series_TM" + pname[0] + sname[0] + ".out"
        return {'d': disp_out, 'w': weights_out, 'h': hist_out, \
                'c': Cmat_out, 's': series_out}

    elif stage == 'pcomb':
        # After combined over processors
        weights_pcomb = "weights_TM" + pname[1] + sname[0] + ".out"
        hist_pcomb = "hist_TM" + pname[1] + sname[0] + ".out"
        Cmat_pcomb = "Cmat_TM" + pname[1] + sname[0] + ".out"
        eigvec_pcomb = "eigvec_TM" + pname[1] + sname[0] + ".out"
        series_pcomb = "series_TM" + pname[1] + sname[0] + ".out"
        return {'w': weights_pcomb, 'h': hist_pcomb, \
                'c': Cmat_pcomb, 's': series_pcomb}

    elif stage == 'scomb':
        # After subdomain join
        weights_scomb = "weights_TM" + pname[1] + sname[1] + ".out"
        hist_scomb = "hist_TM" + pname[1] + sname[1] + ".out"
        Cmat_scomb = "Cmat_TM" + pname[1] + sname[1] + ".out"
        eigvec_scomb = "eigvec_TM" + pname[1] + sname[1] + ".out"
        return {'w': weights_scomb, 'h': hist_scomb, 'c': Cmat_scomb}

    elif stage == 'dF':
        # dF estimate
        dF_file = "deltaF_TM.out"
        return dF_file
    
    else:
        error(this_file, "Invalid argument: "+stage)
예제 #3
0
def file_names(stage, s=0, p=0):
    """ Retuns a dictionary of file names corresponding to each stage of the program """

    # Get the correct names for p, s
    sname, pname = ini.naming_system(s, p)

    if stage == 'input':
        # Input file names include appropriate '_pY_sX'
        disp_in = "disp" + pname[0] + sname[0] + ".out"
        weights_in = ini.rename_inputs(params_weights_file, sname[0], '')
        hist_in = "hist_MC" + pname[0] + sname[0] + ".out"  # same as output
        return {'d': disp_in, 'w': weights_in, 'h': hist_in}

    elif stage == 'output':
        # Out file names include appropriate '_pY_sX'
        disp_out = "disp" + pname[0] + sname[0] + ".out"
        hist_out = "hist_MC" + pname[0] + sname[0] + ".out"
        series_out = "series_MC" + pname[0] + sname[0] + ".out"
        return {'d': disp_out, 'h': hist_out, 's': series_out}

    elif stage == 'pcomb':
        # After combined over processors
        hist_pcomb = "hist_MC" + pname[1] + sname[0] + ".out"
        series_pcomb = "series_MC" + pname[1] + sname[0] + ".out"
        return {'h': hist_pcomb, 's': series_pcomb}

    elif stage == 'unfld':
        # After unfolding
        hist_unfld = "hist_MC" + "_unfld" + sname[0] + ".out"
        series_unfld = "series_MC" + "_unfld" + sname[0] + ".out"
        return {'h': hist_unfld, 's': series_unfld}

    elif stage == 'scomb':
        # After subdomain join
        hist_scomb = "hist_MC" + "_unfld" + sname[1] + ".out"
        return {'h': hist_scomb}

    elif stage == 'dF':
        # dF estimate
        dF_file = "deltaF_MC.out"
        return dF_file

    else:
        error(this_file, "Invalid argument: " + stage)
예제 #4
0
def file_names(stage, s=0, p=0):
    """ Retuns a dictionary of file names corresponding to each stage of the program """

    # Get the correct names for p, s
    sname, pname = ini.naming_system(s, p)

    if stage == 'input':
        # Input file names include appropriate '_pY_sX'
        disp_in = "disp" + sname[0] + ".out"
        weights_in = ini.rename_inputs(params_weights_file, sname[0], '')
        return {'d': disp_in, 'w': weights_in}

    elif stage == 'output':
        # Output file names include appropriate '_pY_sX'
        disp_out = "disp" + sname[0] + ".out"
        weights_out = "weights_WL" + sname[
            0] + ".out"  # probably don't need pname
        hist_out = "hist_WL" + sname[0] + ".out"
        series_out = "series_WL" + sname[0] + ".out"
        return {
            'd': disp_out,
            'w': weights_out,
            'h': hist_out,
            's': series_out
        }

    elif stage == 'scomb':
        # After subdomain join
        weights_scomb = "weights_WL" + sname[1] + ".out"
        hist_scomb = "hist_WL" + sname[1] + ".out"
        return {'w': weights_scomb, 'h': hist_scomb}

    elif stage == 'dF':
        # dF estimate
        dF_file = "deltaF_WL.out"
        return dF_file

    else:
        error(this_file, "Invalid argument: " + stage)
예제 #5
0
def gen_input_files():
    """ If starting a new fixed-weights simulation, empty files will need
    to be created to be imported during the first loop iteration. """
   
    if algorithm not in ('multicanonical', 'transition'):
        return

    print ""

    for p in range(Np):
        # Map to subdomain index
        s = ini.map_proc_to_subdom(p)

        # Input files as decided by program
        input_files = alg.file_names('input', s, p)

        sname, pname = ini.naming_system(s, p)

        # User input files from params
        params_input_files = {'d': None,
                           'w': params_weights_file,
                           'h': params_hist_file,
                           'c': params_Cmat_file,
                           's': params_series_file,}
        # Check if we need to add '_pY_sX'
        params_weights_file_alt = ini.rename_inputs(params_weights_file, sname[0], '')
        params_hist_file_alt = ini.rename_inputs(params_hist_file, sname[0], pname[0])
        params_Cmat_file_alt = ini.rename_inputs(params_Cmat_file, sname[0], pname[0])
        params_series_file_alt = ini.rename_inputs(params_series_file, sname[0], pname[0])
        params_input_files_alt = {'d': None,
                               'w': params_weights_file_alt, 
                               'h': params_hist_file_alt,
                               'c': params_Cmat_file_alt,
                               's': params_series_file_alt}

        # Correct sizes
        size = ini.get_size(s)
        start_files = {'d': np.zeros((Natoms, 3)), 
                'w': np.zeros(size), 'h': np.zeros(size), 
                'c': np.zeros((size,size)), 's': [np.ones(5)*-1,]}
      
        for key in params_input_files.keys():
            # If an input file has been given in params.py
            if params_input_files[key] != None:
                # If the default input file doesn't yet exist,
                # We need to save a copy of the params file to this name
                if os.path.exists(input_files[key]) == False:
                    # First check for the params file modified by '_pY_sX'
                    if os.path.exists(params_input_files_alt[key]) == True:
                        tmp = np.loadtxt(params_input_files_alt[key])
                        print "     Copying %s -> %s" %(params_input_files_alt[key], input_files[key])
                        np.savetxt(input_files[key], tmp)
                    # Then check for the exact file name given in params.py 
                    elif os.path.exists(params_input_files[key]) == True:
                        tmp = np.loadtxt(params_input_files[key])
                        print "     Copying %s -> %s" %(params_input_files[key], input_files[key])
                        np.savetxt(input_files[key], tmp)
                    # Error if params file hasn't been found
                    else:
                        error(this_file, "     Neither files %s or %s not found." %(params_input_files_alt[key],params_input_files[key]))

                # If the default input file does exist, leave it alone
                else: 
                    print "     File %s exists and will be read as input" %input_files[key]
        
    
    print ""

    print "File check completed. "
    return