def binding_energy(): print('Binding Energy -------------') d = np.linspace(5, 25, 5).tolist() data = {} means = [] errors = [] time_data = [] for i in d: variable_finals = [] for _ in range(3): number_of_seconds = 1 # i.e. 1 hour = 3600 seconds model = Master(dimension=1000, binding_energy=int(i), time_unit=10e-3, number_of_receptors=2, receptor_length=100, number_of_nanoparticles=1, nanoparticle_radius=50, number_of_ligands=2, ligand_length=7, binding_distance=4, receptor_radius=3, ligand_radius=3, cell_diffusion_coef=1) model.create_receptors() # 100 nm for receptor model.create_nanoparticles_and_ligands( ) # 1-2 nm for ligand # 95 particles print( f'{model.dimension/1000} μm\u00b3 system, {model.binding_energy} binding energy, {model.number_of_nanoparticles} Nanoparticles,\n' f'{model.nanoparticle_radius} nm Nanoparticle Radius, {model.number_of_ligands} Ligands, Ligand length {model.ligand_length} nm,\n' f'{model.number_of_receptors} Receptors, {model.receptor_length} nm Receptor length, {model.binding_distance} Binding distance' ) model.run(steps=number_of_seconds) # 3600 for 1 hour print(f'The surface coverage is {model.surface_coverage}') variable_finals.append(model.surface_coverage) time_data.append(np.array(model.coverage)) mean_time = np.mean(time_data, axis=0) error_time = np.std(time_data, axis=0) data[f'{model.binding_energy} KT binding energy '] = np.array( [list(range(0, model.time + 1)), mean_time, error_time]) mean_coverage = np.mean(np.array(variable_finals)) print(f'The mean surface coverage is {mean_coverage}') errors.append(np.std(np.array(variable_finals))) means.append(np.mean(np.array(variable_finals))) plt.xlabel('Time (milliseconds)') plt.ylabel('Surface Coverage') for key, value in data.items(): plt.plot(value[0], value[1], label=key) plt.fill_between(value[0], value[1] - value[2], value[1] + value[2], alpha=0.2) plt.legend() plt.show() second_variable_plot('Binding energy (kt)', 'Surface Coverage', d, means, errors)
import sys import os import shutil sys.path.append('src') from Master import Master if os.path.exists('Testing/Master'): shutil.rmtree('Testing/Master') m = Master(name = 'Server01', debug=True, destination_folder='Testing/Master', expected_connections=2) m.setServer(host='localhost', port=8080) m.setDelimeter(':::') m.run()
if __name__ == '__main__': if len(sys.argv) != 2: print("ERROR: Expected 1 argument") sys.exit() mode = sys.argv[1] permitted_modes = ['word_count', 'inverted_index'] if mode not in permitted_modes: print("ERROR: Given mode not supported") print("Permitted Modes:") print(permitted_modes) sys.exit() f = open('config.json', 'r') config = json.loads(f.read()) config = config[mode] network_config = get_network_config(config['network_config']) input_data = config['input_data'] mapper_count = config['n_mappers'] reducer_count = config['n_reducers'] output_data = config['output_data'] map_fn = get_map_method(config['map_fn']) reduce_fn = get_reduce_method(config['reduce_fn']) master = Master(network_config, [], mapper_count, reducer_count, map_fn, reduce_fn, input_data, output_data) master.run()