Example #1
0
def load_inputs(s, p):
    """ Load the correct input files for the extra info """

    input_files = file_names('input', s, p)

    size = ini.get_size(s)

    # Load/initialise binned data in the usual way
    cuts = ini.file_input(input_files['cu'], size)
    accepts = ini.file_input(input_files['ac'], size)
    dmu = ini.file_input(input_files['dm'], size)
    dmu_acc = ini.file_input(input_files['dma'], size)
    dE = ini.file_input(input_files['de'], size)
    dE_acc = ini.file_input(input_files['dea'], size)

    round_trips = ini.file_input(input_files['rt'], 5)
    if int(round_trips[-1] == 0):
        round_trips[-1] = 1  # initialise round trip flag

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

    # Fine-grained matrix only works for TRAP == True (due to indexing issues)
    if TRAP == True:
        mm_size = (minibins_per_window, size)
        minimat = ini.file_input(input_files['mm'], mm_size)
        return_dict['mm'] = minimat

    return return_dict
Example #2
0
def load_inputs(s, p):
    """ Load the correct input files for a Wang Landau simulation """

    input_files = file_names('input', s, p)

    disp = ini.file_input(input_files['d'], (Natoms, 3))

    size = ini.get_size(s)
    weights = ini.file_input(input_files['w'], size)
    hist = ini.file_input(None, size)

    return disp, {'w': weights, 'h': hist}
def load_inputs(s, p):
    """ Load the correct input files for a Transition Matrix simulation """

    input_files = file_names('input', s, p)

    disp = ini.file_input(input_files['d'], (Natoms, 3))

    size = ini.get_size(s)
    weights = ini.file_input(input_files['w'], size)
    hist = ini.file_input(input_files['h'], size)
    Cmat = ini.file_input(input_files['c'], (size,size) )

    return disp, {'w': weights, 'h': hist, 'c': Cmat}
Example #4
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
Example #5
0
    fig3, ax3 = plt.subplots()
    ax3.set_title("Log of diffusivity")
    ax3.set_xlabel(r"$\mu \times \beta/N$")
    ax3.set_ylabel("log(Diffusivity)")
    ax3.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

    if save == True:
        global_diffusivity = []

    # ------------------------- #
    #  Iterate over subdomains  #
    # ------------------------- #
    for s in range(Ns_eff):

        # Initialise arrays for combined data within subdom
        size = ini.get_size(s)
        hist = np.zeros(size)
        cuts = np.zeros(size)

        for p in p_list[s::Ns_eff]:
            # Get file names to load
            input_files = alg.file_names('output', s, p)
            extra_input_files = dyn.file_names('output', s, p)

            # Load input files
            this_hist = np.loadtxt(input_files['h'])
            this_cuts = np.loadtxt(extra_input_files['cu'])
            
            # Add to combined
            hist = hist + this_hist
            cuts = cuts + this_cuts