def main(argv=sys.argv): argv = sys.argv args = read_inputs(argv[1:]) in_files_path = args.infiles #Import silver data wave_s, diel_rs, diel_is = numpy.loadtxt( '../data/wave_silver_diel_3700-4000.txt', skiprows=1, unpack=True) #Import water data wave_w, diel_rw, diel_iw = numpy.loadtxt( '../data/wave_water_diel_3700-4000.txt', skiprows=1, unpack=True) #Creating dielectric list first dielectric outside, then inside diel_list = [ list(eps) for eps in zip(diel_rw + 1j * diel_iw, diel_rs + 1j * diel_is) ] #Set enviornment variable for PyGBe folder_path = in_files_path + 'BSA_sensorR8_d=infty' full_path = os.path.abspath(folder_path) + '/' os.environ['PYGBE_PROBLEM_FOLDER'] = full_path #Creating dictionary field. We will modify the 'E' key in the for loop. field_dict_Ag = read_fields(full_path + 'sph_sensor.config') #Calculate Cext(lambda) for silver tic_ss = time.time() e_field = -0.0037 wave, Cext_silver = Cext_wave_scan(e_field, wave_s, diel_list, field_dict_Ag, full_path) toc_ss = time.time() #Calculate Cext_analytical(lambda) for silver, radius of sphere=8 nm tic_sa = time.time() r = 8. #Silver Cext_an_silver = Cext_analytical(r, wave_s / 10, diel_rw + 1j * diel_iw, diel_rs + 1j * diel_is) toc_sa = time.time() #Save wavelength, Cext, Cext_analytical, error #Silver numpy.savetxt('../results/lambda_Cext_Cext_an_silver.txt', list(zip(wave / 10, Cext_silver, Cext_an_silver)), fmt='%.5f %.5f %.5f ', header='lambda [ang], Cext, Cext_analytical') time_simulation = (toc_ss - tic_ss) time_analytical = (toc_sa - tic_sa) time_silver = (toc_ss - tic_ss) + (toc_sa - tic_sa) with open('../results/time_verification.txt', 'w') as f: print('time_total: {} s (simulation: {} + analytical: {}) '.format( time_silver, time_simulation, time_analytical), file=f)
def initialize_field(filename, param, field=None): """ Initialize all the regions in the surface to be solved. Arguments --------- filename : name of the file that contains the surface information. param : class, parameters related to the surface. field : dictionary with preloaded field values for programmatic interaction with PyGBe Returns ------- field_array: array, contains the Field classes of each region on the surface. """ if not field: field = read_fields(filename) for key in ['E', 'kappa']: for i, e in enumerate(field[key]): if not numpy.iscomplexobj(e) and not isinstance(e, str): field[key][i] = param.REAL(field[key][i]) Nfield = len(field['LorY']) field_array = [] Nchild_aux = 0 for i in range(Nfield): field_aux = Field(field['LorY'][i], field['kappa'][i], field['E'][i], field['coulomb'][i], field['pot'][i]) if int(field['charges'][i]) == 1: # if there are charges field_aux.load_charges(field['qfile'][i], param.REAL) if int(field['Nparent'][i]) == 1: # if it is an enclosed region field_aux.parent.append(int(field['parent'][i])) # pointer to parent surface (enclosing surface) if int(field['Nchild'][i]) > 0: # if there are enclosed regions inside for j in range(int(field['Nchild'][i])): field_aux.child.append(int( field['child'][Nchild_aux + j])) # Loop over children to get pointers Nchild_aux += int( field['Nchild'][i]) # Point to child for next surface if field['pot'][i] == 1: param.E_field.append(i) # Field where surface energy is calculated field_array.append(field_aux) return field_array
def initialize_field(filename, param, field=None): """ Initialize all the regions in the surface to be solved. Arguments --------- filename : name of the file that contains the surface information. param : class, parameters related to the surface. field : dictionary with preloaded field values for programmatic interaction with PyGBe Returns ------- field_array: array, contains the Field classes of each region on the surface. """ if not field: field = read_fields(filename) for key in ['E', 'kappa']: for i, e in enumerate(field[key]): if not numpy.iscomplexobj(e) and not isinstance(e, str): field[key][i] = param.REAL(field[key][i]) Nfield = len(field['LorY']) field_array = [] Nchild_aux = 0 for i in range(Nfield): field_aux = Field(field['LorY'][i], field['kappa'][i], field['E'][i], field['coulomb'][i], field['pot'][i]) if int(field['charges'][i]) == 1: # if there are charges field_aux.load_charges(field['qfile'][i], param.REAL) if int(field['Nparent'][i]) == 1: # if it is an enclosed region field_aux.parent.append(int(field['parent'][i])) # pointer to parent surface (enclosing surface) if int(field['Nchild'][i]) > 0: # if there are enclosed regions inside for j in range(int(field['Nchild'][i])): field_aux.child.append(int(field['child'][Nchild_aux + j]) ) # Loop over children to get pointers Nchild_aux += int(field['Nchild'][i]) # Point to child for next surface if field['pot'][i] == 1: param.E_field.append(i) # Field where surface energy is calculated field_array.append(field_aux) return field_array
def main(argv=sys.argv): argv = sys.argv args = read_inputs(argv[1:]) in_files_path = args.infiles #Import surface data wave_s, diel_rs, diel_is = numpy.loadtxt( '../dielectric_data/4H-SIC_permittivity_10-12_microns.csv', skiprows=1, unpack=True) air_diel = [1. + 1j * 0.] * len(wave_s) #Creating dielectric list first dielectric outside, then inside diel_list = [list(eps) for eps in zip(air_diel, diel_rs + 1j * diel_is)] #Set enviornment variable for PyGBe folder_path = in_files_path + 'prism_reg_SE' full_path = os.path.abspath(folder_path) + '/' os.environ['PYGBE_PROBLEM_FOLDER'] = full_path #Creating dictionary field. We will modify the 'E' key in the for loop. field_dict_pillars = read_fields(full_path + 'prism_reg_38K.config') #Calculate Cext(lambda) for pillars' surface tic_ss = time.time() e_field = -1. wave, Cext_pillars = Cext_wave_scan(e_field, wave_s, diel_list, field_dict_pillars, full_path) toc_ss = time.time() numpy.savetxt('../results_data/prism_regular_SE_LE_res/' + 'prism_reg_38K_short_edge' + '10-20microns.txt', list(zip(wave, Cext_pillars)), fmt='%.9f %.9f', header='lambda [Ang], Cext [nm^2]') time_simulation = (toc_ss - tic_ss) with open( '../results_data/prism_regular_SE_LE_res/Time_' + 'prism_reg_38K_short_edge' + '.txt', 'w') as f: print('time_total: {} s'.format(time_simulation), file=f)
try: all(l_w == l_s) & all(l_s == l_p) wavelength = l_w except: raise ValueError( 'The wavelength ranges are not equal, check data generation') #Complex dielectric assembly e_w = er_w + 1j * ei_w #water e_s = er_s + 1j * ei_s #silver e_p = er_p + 1j * ei_p #protein #Building E field for single sphere dictionary E_field_single = [list(eps) for eps in zip(e_w, e_s)] field_dict_single = read_fields( '../../../pygbe/examples/BSA_sensor_d=infty/sph_sensor.config') tic_single = time.time() elec_field = -1 wave_single, Cext_single = Cext_wave_scan( elec_field, wavelength, E_field_single, field_dict_single, '../../../pygbe/examples/BSA_sensor_d=infty') toc_single = time.time() numpy.savetxt('../../data/wave_cext_d_prot_sensor/wave_cext_d_infty.txt', list(zip(wave_single, Cext_single)), fmt='%.1f %.8f', header='lambda [Ang], Cext, d=infty') #Building E field for dictionary (protein) E_field = [list(eps) for eps in zip(e_w, e_s, e_p)]
def main(argv=sys.argv): '''Creates lspr response data for the following cases: BSA_sensorR8_2pz_d=0.5_00, BSA_sensorR8_2pz_d=1_00, BSA_sensorR8_2pz_d=2_00 and for the case of no protein BSA_sensorR8_d=infty. Arguments passed (read docs of read_inputs) ---------------- infiles: str, absolute path where the input files are located. For example: if input_problem_folders was downloaded in the directory home/Downloads, then the path will be: home/Downloads/input_problem_folders/ ''' argv = sys.argv args = read_inputs(argv[1:]) in_files_path = args.infiles #Importing dielectrics data l_w, er_w, ei_w = numpy.loadtxt( '../dielectrics_data/wave_ang_water_diel_3820-3870.txt', unpack=True) l_s, er_s, ei_s = numpy.loadtxt( '../dielectrics_data/wave_ang_silver_diel_3820-3870.txt', unpack=True) l_p, er_p, ei_p = numpy.loadtxt( '../dielectrics_data/wave_ang_prot_diel_3820-3870.txt', unpack=True) #Check the wavelength ranges are all equal try: all(l_w == l_s) & all(l_s == l_p) wavelength = l_w except: raise ValueError( 'The wavelength ranges are not equal, check data generation') #Complex dielectric assembly e_w = er_w + 1j * ei_w #water e_s = er_s + 1j * ei_s #silver e_p = er_p + 1j * ei_p #protein #Building E field for single sphere dictionary E_field_single = [list(eps) for eps in zip(e_w, e_s)] field_dict_single = read_fields(in_files_path + 'BSA_sensorR8_d=infty/sph_sensor.config') tic_single = time.time() elec_field = -0.0037 wave_single, Cext_single = Cext_wave_scan( elec_field, wavelength, E_field_single, field_dict_single, in_files_path + 'BSA_sensorR8_d=infty/') toc_single = time.time() numpy.savetxt( '../Cext_variation_with_distance_two_bsa_z_results/BSA_sensorR8_d=infty_3820-3870ang.txt', list(zip(wave_single, Cext_single)), fmt='%.1f %.8f', header='lambda [Ang],Cext_' + 'BSA_sensorR8_d=infty') #Building E field for dictionary (one protein) uncomment the following line #E_field = [list(eps) for eps in zip(e_w, e_s, e_p) #If only one protein comment the following 4 lines of code #Building E field for dictionary for case of 2 proteins e_list = [list(eps) for eps in zip(e_w, e_s, e_p)] E_field = [] for lst in e_list: E_field.append(lst + [lst[-1]] * 1) #works for 2 proteins, if n proteins # needed replace lst+[lst[-1]]*1 by #lst+[lst[-1]]*(n-1) distance_path_folders = [ 'BSA_sensorR8_2pz_d=0.5_00', 'BSA_sensorR8_2pz_d=1_00', 'BSA_sensorR8_2pz_d=2_00' ] tic_d = time.time() elec_field = -0.0037 for path in distance_path_folders: folder_path = in_files_path + path full_path = os.path.abspath(folder_path) + '/' os.environ['PYGBE_PROBLEM_FOLDER'] = full_path field_dict = read_fields(folder_path + '/sphere_bsa.config') wave, Cext = Cext_wave_scan(elec_field, wavelength, E_field, field_dict, in_files_path + path) numpy.savetxt('../Cext_variation_with_distance_two_bsa_z_results/' + path + '_3820-3870ang.txt', list(zip(wave, Cext)), fmt='%.1f %.8f', header='lambda [Ang], Cext_' + path) toc_d = time.time() with open( '../Cext_variation_with_distance_two_bsa_z_results/Time_Cext_variation_with_distance_two_bsa_z.txt', 'w') as f: print('single sphere run time: {}'.format((toc_single - tic_single)), file=f) print('sphere-bsa run time: {}'.format((toc_d - tic_d)), file=f) print('total run time: {}'.format((toc_single - tic_single) + (toc_d - tic_d)), file=f)
lambda_75, ns_75, ks_75, nw_75, kw_75 = numpy.loadtxt('../../data/lambda_n_k_silver-7.5.txt', unpack = True) #Import gold case lambda_76, ng_76, kg_76, nw_76, kw_76 = numpy.loadtxt('../../data/lambda_n_k_gold-7.6.txt', unpack = True) #Creating dielectric list for silver diel_wat_75, diel_sil_75, diel_list_75 = create_diel_list(nw_75, kw_75, ns_75, ks_75) #Creating dielectric list for gold diel_wat_76, diel_gold_76, diel_list_76 = create_diel_list(nw_76, kw_76, ng_76, kg_76) #Creating dictionary field. We will modify the 'E' key in the for loop. field_dict_Ag = read_fields('../../../pygbe_dev/pygbe/examples/lspr_silver/sphereAg_complex.config') field_dict_Au = read_fields('../../../pygbe_dev/pygbe/examples/lspr_gold/sphereAu_complex.config') #Calculate Cext(lambda) for silver tic_s = time.time() wave_s, Cext_silver = Cext_wave_scan(lambda_75, diel_list_75, field_dict_Ag, '../../../pygbe_dev/pygbe/examples/lspr_silver') toc_s = time.time() #Calculate Cext(lambda) for gold tic_g = time.time() wave_g, Cext_gold = Cext_wave_scan(lambda_76, diel_list_76, field_dict_Au, '../../../pygbe_dev/pygbe/examples/lspr_gold') toc_g = time.time() #Calculate Cext_analytical(lambda) for silver and gold, radius of sphere=10 nm
try: all(l_w == l_s) & all(l_s == l_p) wavelength = l_w except: raise ValueError( 'The wavelength ranges are not equal, check data generation') #Complex dielectric assembly e_w = er_w + 1j * ei_w #water e_s = er_s + 1j * ei_s #silver e_p = er_p + 1j * ei_p #protein #Building E field for single sphere dictionary E_field_single = [list(eps) for eps in zip(e_w, e_s)] field_dict_single = read_fields( '../../../pygbe_dev/pygbe/examples/lspr/sphere_complex.config') tic_single = time.time() wave_single, Cext_single = Cext_wave_scan( wavelength, E_field_single, field_dict_single, '../../../pygbe_dev/pygbe/examples/lspr') toc_single = time.time() numpy.savetxt('../../data/wave_cext_d/wave_cext_d_infty.txt', list(zip(wave_single, Cext_single)), fmt='%.3f %.8f', header='lambda [nm], Cext, d=infty') #Building E field for dictionary (protein) e_list = [list(eps) for eps in zip(e_w, e_s, e_p)]
numpy.savetxt( '../../data/lambda_refrac_water_silv_gold.txt', list(zip(lambda_wsg, n_w, k_w, n_s, k_s, n_g, k_g)), fmt='%.8f %.8e %.8e %.8e %.8e %.8e %.8e', header= 'lambda [nm], refrac_real_water, refrac_imag_water, refrac_real_silver, refrac_imag_silver, refrac_real_gold, refrac_imag_gold' ) #Creating dielectric list for silver diel_wat_s, diel_sil, diel_list_silv = create_diel_list(n_w, k_w, n_s, k_s) #Creating dielectric list for gold diel_wat_g, diel_gold, diel_list_gold = create_diel_list(n_w, k_w, n_g, k_g) #Creating dictionary field. We will modify the 'E' key in the for loop. field_dict = read_fields( '../../../pygbe_dev/pygbe/examples/lspr/sphere_complex.config') #Calculate Cext(lambda) for silver tic_s = time.time() wave_s, Cext_silver = Cext_wave_scan(lambda_wsg, diel_list_silv, field_dict, '../../../pygbe_dev/pygbe/examples/lspr') toc_s = time.time() #Calculate Cext(lambda) for gold tic_g = time.time() wave_g, Cext_gold = Cext_wave_scan(lambda_wsg, diel_list_gold, field_dict, '../../../pygbe_dev/pygbe/examples/lspr') toc_g = time.time() #Calculate Cext_analytical(lambda) for silver and gold, radius of sphere=10 nm r = 10.