def build_instance(cls,xyzu_oc_m = [0.5, 0.5, 1.5, 0.1, 1, 1], els = ['O','C','C','O'], flat_down_index = [2],anchor_index_list = [1, None, 1, 2 ], lat_pars = [3.615, 3.615, 3.615, 90, 90, 90]): domain = model_2.Slab(T_factor = 'u') ids_all = deepcopy(els) for each in set(els): index_temp_all = list(np.where(np.array(els) == each)[0]) for index_temp in index_temp_all: ids_all[index_temp] = "{}{}".format(ids_all[index_temp], index_temp_all.index(index_temp)+1) for i in range(len(ids_all)): domain.add_atom(ids_all[i],els[i],*xyzu_oc_m) ids = deepcopy(ids_all) del(ids[anchor_index_list.index(None)]) anchor_id = ids_all[anchor_index_list.index(None)] flat_down_index_new = [[i,i-1][int(i>anchor_index_list.index(None))] for i in flat_down_index] r_list_names = [] gamma_list_names = [] delta_list_names = [] for i in range(len(anchor_index_list)): each = anchor_index_list[i] if each != None: #if i not in flat_down_index: delta_list_names.append("delta_{}_{}".format(ids_all[i],ids_all[each])) if each != None: r_list_names.append("r_{}_{}".format(ids_all[i],ids_all[each])) gamma_list_names.append("gamma_{}_{}".format(ids_all[i],ids_all[each])) rgh = UserVars() rgh.new_var('gamma',0) rgh.new_var('rot_ang_x',0) rgh.new_var('rot_ang_y',0) for r in r_list_names: rgh.new_var(r, 1.5) for i in range(len(delta_list_names)): delta = delta_list_names[i] if i in flat_down_index_new: rgh.new_var(delta, 0) else: rgh.new_var(delta, 20) #for gamma in gamma_list_names: # rgh.new_var(gamma, 10) instance = cls(domain, ids, anchor_id, flat_down_index = flat_down_index_new, lat_pars = lat_pars) instance.rgh = rgh instance.r_list_names = r_list_names instance.delta_list_names = delta_list_names instance.gamma_list_names = gamma_list_names instance.gamma_handedness = [1]*anchor_index_list.index(None)+[0]*(len(anchor_index_list)-anchor_index_list.index(None)-1) instance.new_anchor_list = [ids_all[i] for i in anchor_index_list if i!=None] instance.rot_ang_x_list = [0] * len(instance.ids) instance.rot_ang_y_list = [0] * len(instance.ids) return instance
#Adding sorbates to domainA and domainB sorbate_methods = {0:"setup_sorbate_OS_new", 1:"setup_sorbate_MD_new", 2:"setup_sorbate_BD_new", 3:"setup_sorbate_TD_new"} for j in range(sum(SORBATE_NUMBER[i])): method_ = getattr(setup_domain_hematite_rcut,sorbate_methods[len(SORBATE_ATTACH_ATOM[i][j])]) return_list = method_(vars(),i,j) vars()['gp_sorbates_set'+str(j+1)+'_D'+str(int(i+1))],vars()['gp_HO_set'+str(j+1)+'_D'+str(int(i+1))]=return_list #setup water layers water_gp_names,water_groups=setup_domain_hematite_rcut.setup_layer_structure(vars(),i) for iii in range(len(water_groups)):vars()[water_gp_names[iii]]=water_groups[iii] #/setup_slabs/end# #/setup_rgh_global/begin# rgh=UserVars() rgh.new_var('beta', 0.0)#roughness factor rgh.new_var('mu',1)#liquid film thickness scales=['scale_CTR'] for scale in scales: rgh.new_var(scale,1.) #/setup_rgh_global/end# #/build_parameter/begin# O_N,binding_mode=setup_domain_hematite_rcut.setup_fit_table(O_NUMBER,DOMAIN_NUMBER,SORBATE_ATTACH_ATOM) make_grid.make_structure(list(map(sum,SORBATE_NUMBER)),O_N,WATER_NUMBER,DOMAIN, Metal=SORBATE,binding_mode=binding_mode,\ long_slab=full_layer_pick,long_slab_HL=half_layer_pick,\ local_structure=LOCAL_STRUCTURE,add_distal_wild=ADD_DISTAL_LIGAND_WILD,\ use_domains=[1]*DOMAIN_NUMBER,N_raxr=NUMBER_SPECTRA,domain_raxr_el=RESONANT_EL_LIST,\ layered_water=layered_water_pars['yes_OR_no'],layered_sorbate=layered_sorbate_pars['yes_OR_no'],\
sorbate_instance_head, i + 1)].make_atom_group() #/sorbateproperties/end# #/sorbatestructure/begin# #OCCO # O1 O2 # \ / # C1-C2 #=================== #/sorbatestructure/end# #--set rgh--# #/rgh/begin# #/rgh/global/begin# rgh = UserVars() rgh.new_var('beta', 0.0) #roughness factor rgh.new_var('mu', 1) #liquid film thickness scales = ['scale_nonspecular_rods', 'scale_specular_rod'] for scale in scales: rgh.new_var(scale, 0.0005) #/rgh/global/end# #/rgh/layer_water/begin# rgh_lw = UserVars() pars = ['u0', 'ubar', 'd_w', 'first_layer_height', 'density_w'] rgh_lw.new_var('u0', 2) rgh_lw.new_var('ubar', 2) rgh_lw.new_var('first_layer_height', 2) rgh_lw.new_var('d_w', 2) rgh_lw.new_var('density_w', 0.033)
#domain1 BUILD_GRID=3#FOR cubic structure only LEVEL,CAP,EXTRA_SORBATE=13,[],[] SYMMETRY,SWITCH_EXTRA_SORBATE=False,[True]*10 MIRROR_EXTRA_SORBATE=[True]*10 #NUMBER_SORBATE_LAYER,NUMBER_EL_MOTIF=1,LEVEL+len(CAP)*2+len(EXTRA_SORBATE)#1 if monomer, 2 if dimmer and so on, for square_antiprism only NUMBER_SORBATE_LAYER=0 NUMBER_EL_MOTIF=None if type(BUILD_GRID)==type([]): NUMBER_EL_MOTIF=len(BUILD_GRID) elif type(BUILD_GRID)==int(1): NUMBER_EL_MOTIF=BUILD_GRID**3 INFO_LIB={'basis':BASIS,'sorbate_el':'Zr','coordinate_el':'O','T':T,'T_INV':T_INV,'oligomer_type':'polymer'}#polymer_new_rot if square_antiprism for i in range(NUMBER_SORBATE_LAYER): vars()['rgh_domain1_set'+str(i+1)]=UserVars() geo_lib_domain1={'cent_point_offset_x':0,'cent_point_offset_y':0,'cent_point_offset_z':0,'r':2.2,'theta':59.2641329,'rot_x':0,'rot_y':0,'rot_z':0,'shift_btop':0,'shift_mid':0,'shift_cap':0,'rot_ang_attach1':0,'rot_ang_attach2':0,'rot_ang_attach3':0} Domain1,vars()['rgh_domain1_set'+str(i+1)]=domain_creator.add_sorbate_new(domain=Domain1,anchored_atoms=[],func=domain_creator_sorbate.OS_cubic_oligomer,geo_lib=geo_lib_domain1,info_lib=INFO_LIB,domain_tag='_D1',rgh=vars()['rgh_domain1_set'+str(i+1)],index_offset=[i*2*NUMBER_EL_MOTIF,NUMBER_EL_MOTIF+i*2*NUMBER_EL_MOTIF],xy_offset=XY_OFFSET,height_offset=HEIGHT_OFFSET,symmetry_couple=SYMMETRY,level=LEVEL,cap=CAP,attach_sorbate_number=EXTRA_SORBATE,first_or_second=SWITCH_EXTRA_SORBATE,mirror=MIRROR_EXTRA_SORBATE,build_grid=BUILD_GRID) ##<Adding Gaussian peaks>## NUMBER_GAUSSIAN_PEAK=6#how many gaussian peaks would you like to add? EL_GAUSSIAN_PEAK=['O']*NUMBER_GAUSSIAN_PEAK#the element of each gaussian peak FIRST_PEAK_HEIGHT=1 GAUSSIAN_OCC_INIT, GAUSSIAN_LAYER_SPACING, GAUSSIAN_U_INIT=1,2,0.1 GAUSSIAN_SHAPE, GAUSSIAN_RMS='Flat',2 Domain1, Gaussian_groups,Gaussian_group_names=domain_creator.add_gaussian(domain=Domain1,el=EL_GAUSSIAN_PEAK,number=NUMBER_GAUSSIAN_PEAK,first_peak_height=FIRST_PEAK_HEIGHT,spacing=GAUSSIAN_LAYER_SPACING,u_init=GAUSSIAN_U_INIT,occ_init=GAUSSIAN_OCC_INIT,height_offset=HEIGHT_OFFSET,c=unitcell.c,domain_tag='_D1',shape=GAUSSIAN_SHAPE,gaussian_rms=GAUSSIAN_RMS) for i in range(len(Gaussian_groups)):vars()[Gaussian_group_names[i]]=Gaussian_groups[i] rgh_gaussian=domain_creator.define_gaussian_vars(rgh=UserVars(),domain=Domain1,shape=GAUSSIAN_SHAPE) '''WARNING! Choose one way to freeze element. Errors will appear if using both ways.''' ##<Freeze Elements by specifing values>##
water_scaling_file=os.path.join(PATH,"water_scaling") water_scaling=pickle.load(open(water_scaling_file,"rb"))[-1] print 'water_scaling=',water_scaling else: h=np.array([ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ]) k=np.array([ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ]) l=np.array([ 0.41,0.53,0.61,0.75,0.88,1.15,1.45,1.71,2.31,2.64,2.85,3.21,3.55,4.24,4.55,5.61,6.25,7.31,9.15,10.31,11.15 ]) zs=np.array([ 1.5,3.65,5.85,7.7,9.7,11.75,17.05,19.1,21.1,23.1,25.25,27.45,29.55,32.0,34.45,36.5,38.6,40.65,42.55,44.65,48.0,49.85 ]) water_scaling= 0.33 ##cal q list q_list=np.array(create_plots.q_list_func(h,k,l)) ##define fitting parameters rgh_u=UserVars() rgh_oc=UserVars() rgh_dz=UserVars() for i in range(len(zs)): rgh_u.new_var('u'+str(i+1),0.2) rgh_oc.new_var('oc'+str(i+1),0.) rgh_dz.new_var('dz'+str(i+1),0.) def Sim(data): u_list=[] oc_list=[] z_list=[] ##<Extract pars>## for i in range(len(zs)): u_list.append(getattr(rgh_u,'getU'+str(0+1))()) oc_list.append(getattr(rgh_oc,'getOc'+str(i+1))())
el_gaussian_peak=['O']*number_gaussian_peak#the element of each gaussian peak gaussian_shape = 'Flat' surface_1, Gaussian_groups,Gaussian_group_names=domain_creator.add_gaussian(domain=surface_1,el=el_gaussian_peak,\ number=number_gaussian_peak,\ first_peak_height= 1 ,\ spacing=2,\ u_init=0.1,\ occ_init=1,\ height_offset=height_offset,\ c=unitcell.c, \ domain_tag='_D1',\ shape=gaussian_shape,\ gaussian_rms=2) for i in range(len(Gaussian_groups)): vars()[Gaussian_group_names[i]]=Gaussian_groups[i] rgh_gaussian=domain_creator.define_gaussian_vars(rgh=UserVars(),domain=surface_1,shape=gaussian_shape) #/gaussian_type1/end# ##<Freeze Elements using adding_gaussian function>## #/gaussian_type2/begin# number_gaussian_peak_freeze=6#number of resonant element peaks first_peak_height_freeze = 5 gaussian_shape_freeze = 'Flat' surface_1, Gaussian_groups_freeze,Gaussian_group_names_freeze=domain_creator.add_gaussian(domain=surface_1,el=raxr_el,\ number=number_gaussian_peak_freeze,\ first_peak_height = 5,\ spacing = 2,\ u_init = 0.1,\ occ_init = 1,\ height_offset=height_offset,\ c=unitcell.c,domain_tag='_D1',\