Beispiel #1
0
    #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'],\
#setup grouping scheme
GROUPING_SCHEMES=[[1,0]]#domain tag of first domain is 0
GROUPING_DEPTH=[[0,10]]#means I will group top 10 (range(0,10)) layers of domain1 and domain2 together

#setting slabs##
wal=0.83345#wavelength of x ray
unitcell = model.UnitCell(5.038, 5.434, 7.3707, 90, 90, 90)
SURFACE_PARMS={'delta1':0.,'delta2':0.1391}#correction factor in surface unit cell
inst = model.Instrument(wavel = wal, alpha = 2.0)
bulk = model.Slab(T_factor='B')
ref_S_domain1 =  model.Slab(c = 1.0,T_factor='B')
ref_L_domain1 =  model.Slab(c = 1.0,T_factor='B')
ref_S_domain2 =  model.Slab(c = 1.0,T_factor='B')
ref_L_domain2 =  model.Slab(c = 1.0,T_factor='B')
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.)

#set up experimental constant#
re = 2.818e-5#electron radius
kvect=2*np.pi/wal#k vector
Egam = 6.626*(10**-34)*3*(10**8)/wal*10**10/1.602*10**19#energy in ev
LAM=1.5233e-22*Egam**6 - 1.2061e-17*Egam**5 + 2.5484e-13*Egam**4 + 1.6593e-10*Egam**3 + 1.9332e-06*Egam**2 + 1.1043e-02*Egam
exp_const = 4*kvect/LAM
auc=unitcell.a*unitcell.b*np.sin(unitcell.gamma)

#bond valence setup#
Beispiel #3
0
        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)
    vars()['sym_file_Pb_domain'+str(int(i+1))]=np.array(vars()['pb_list_domain'+str(int(i+1))+'a']+vars()['pb_list_domain'+str(int(i+1))+'b'])
    vars()['id_match_in_sym_domain'+str(int(i+1))]={'Fe':vars()['sym_file_Fe_domain'+str(int(i+1))],'O':vars()['sym_file_O_domain'+str(int(i+1))],'Pb':vars()['sym_file_Pb_domain'+str(int(i+1))]}

#id list according to the order in the reference domain   
ref_id_list_1=["O1_1_0","O1_2_0","Fe1_2_0","Fe1_3_0","O1_3_0","O1_4_0","Fe1_4_0","Fe1_6_0","O1_5_0","O1_6_0","O1_7_0","O1_8_0","Fe1_8_0","Fe1_9_0","O1_9_0","O1_10_0","Fe1_10_0","Fe1_12_0","O1_11_0","O1_12_0",\
'O1_1_1','O1_2_1','Fe1_2_1','Fe1_3_1','O1_3_1','O1_4_1','Fe1_4_1','Fe1_6_1','O1_5_1','O1_6_1','O1_7_1','O1_8_1','Fe1_8_1','Fe1_9_1','O1_9_1','O1_10_1','Fe1_10_1','Fe1_12_1','O1_11_1','O1_12_1']
ref_id_list_2=["O1_11_t","O1_12_t","O1_1_0","O1_2_0","Fe1_2_0","Fe1_3_0","O1_3_0","O1_4_0","Fe1_4_0","Fe1_6_0","O1_5_0","O1_6_0","O1_7_0","O1_8_0","Fe1_8_0","Fe1_9_0","O1_9_0","O1_10_0","Fe1_10_0","Fe1_12_0","O1_11_0","O1_12_0",\
'O1_1_1','O1_2_1','Fe1_2_1','Fe1_3_1','O1_3_1','O1_4_1','Fe1_4_1','Fe1_6_1','O1_5_1','O1_6_1','O1_7_1','O1_8_1','Fe1_8_1','Fe1_9_1','O1_9_1','O1_10_1','Fe1_10_1','Fe1_12_1','O1_11_1','O1_12_1']

###############################################setting slabs##################################################################    
unitcell = model.UnitCell(5.038, 5.434, 7.3707, 90, 90, 90)
inst = model.Instrument(wavel = .833, alpha = 2.0)
bulk = model.Slab(T_factor='B')
ref_domain1 =  model.Slab(c = 1.0,T_factor='B')
ref_domain2 =  model.Slab(c = 1.0,T_factor='B')
rgh=UserVars()
rgh.new_var('beta', 0.0)
################################################build up ref domains############################################
#add atoms for bulk and two ref domains (ref_domain1<half layer> and ref_domain2<full layer>)
#In those two reference domains, the atoms are ordered according to first hight (z values), then y values
#it is a super surface structure by stacking the surface slab on bulk slab, the repeat vector was counted 
try:
    add_atom_in_slab(bulk,batch_path_head+'bulk.str')
except:
    batch_path_head='D:\\Github\\batchfile\\'
    add_atom_in_slab(bulk,batch_path_head+'bulk.str')
add_atom_in_slab(ref_domain1,batch_path_head+'half_layer2.str')
add_atom_in_slab(ref_domain2,batch_path_head+'full_layer2.str')
#symmetry library, note the Fe output file is the same, but O and Pb output file is different due to different sorbate configuration
for i in range(DOMAIN_NUMBER): 
    vars()['sym_file_domain'+str(int(i+1))]={'Fe':batch_path_head+'Fe output file for Genx reading.txt',\
Beispiel #5
0
#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>##
Beispiel #6
0
    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.345508,0.465508,0.545508,0.685508,0.815508,1.08551,1.38551,1.64551,2.24551
            ,2.57551,2.78551,3.14551,3.48551,4.17551,4.48551,5.54551,6.18551,7.24551,9.08551
            ,10.2455,11.0855])
    zs=np.array([  2. ,   4.8,   7.6,  10.4,  13.2,  16. ,  18.8,  21.6,  24.4,
        27.2,  30. ])
    water_scaling= 0.376587994184
    
##cal q list
q_list=np.array(create_plots.q_list_func(h,k,l))

##define fitting parameters
rgh_u=UserVars()
rgh_oc=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),1.)

def Sim(data):
    u_list=[]
    oc_list=[]
    ##<Extract pars>##
    for i in range(len(zs)):
        u_list.append(getattr(rgh_u,'getU'+str(i+1))())
        oc_list.append(getattr(rgh_oc,'getOc'+str(i+1))())
    
    ##<calculate e density>##
    F,fom_scaler=[],[]
#/sorbateproperties/end#

#/sorbatestructure/begin#
#1         C1
#2         |
#3      C2-O1-C3
#4         |
#5         C4
# ===================
#/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, 1.)
#/rgh/global/end#

#/rgh/domain_weight/begin#
rgh_wt = UserVars()
for i in range(num_surface_slabs):
    rgh_wt.new_var('wt_domain{}'.format(i + 1), 1)
#/rgh/domain_weight/end#
#/rgh/end#

#/atmgroup/begin#
    vars()['sym_file_Pb_domain'+str(int(i+1))]=np.array(vars()['pb_list_domain'+str(int(i+1))+'a']+vars()['pb_list_domain'+str(int(i+1))+'b'])
    vars()['id_match_in_sym_domain'+str(int(i+1))]={'Fe':vars()['sym_file_Fe_domain'+str(int(i+1))],'O':vars()['sym_file_O_domain'+str(int(i+1))],'Pb':vars()['sym_file_Pb_domain'+str(int(i+1))]}

##id list according to the order in the reference domain (used to set up ref domain)  
ref_id_list_1=["O1_1_0","O1_2_0","Fe1_2_0","Fe1_3_0","O1_3_0","O1_4_0","Fe1_4_0","Fe1_6_0","O1_5_0","O1_6_0","O1_7_0","O1_8_0","Fe1_8_0","Fe1_9_0","O1_9_0","O1_10_0","Fe1_10_0","Fe1_12_0","O1_11_0","O1_12_0",\
'O1_1_1','O1_2_1','Fe1_2_1','Fe1_3_1','O1_3_1','O1_4_1','Fe1_4_1','Fe1_6_1','O1_5_1','O1_6_1','O1_7_1','O1_8_1','Fe1_8_1','Fe1_9_1','O1_9_1','O1_10_1','Fe1_10_1','Fe1_12_1','O1_11_1','O1_12_1']
ref_id_list_2=["O1_11_t","O1_12_t","O1_1_0","O1_2_0","Fe1_2_0","Fe1_3_0","O1_3_0","O1_4_0","Fe1_4_0","Fe1_6_0","O1_5_0","O1_6_0","O1_7_0","O1_8_0","Fe1_8_0","Fe1_9_0","O1_9_0","O1_10_0","Fe1_10_0","Fe1_12_0","O1_11_0","O1_12_0",\
'O1_1_1','O1_2_1','Fe1_2_1','Fe1_3_1','O1_3_1','O1_4_1','Fe1_4_1','Fe1_6_1','O1_5_1','O1_6_1','O1_7_1','O1_8_1','Fe1_8_1','Fe1_9_1','O1_9_1','O1_10_1','Fe1_10_1','Fe1_12_1','O1_11_1','O1_12_1']

###############################################setting slabs##################################################################    
unitcell = model.UnitCell(5.038, 5.434, 7.3707, 90, 90, 90)
inst = model.Instrument(wavel = .833, alpha = 2.0)
bulk = model.Slab(T_factor='B')
ref_domain1 =  model.Slab(c = 1.0,T_factor='B')
ref_domain2 =  model.Slab(c = 1.0,T_factor='B')
rgh=UserVars()
rgh.new_var('beta', 0.0)
scales=['scale_CTR','scale_RAXS']
for scale in scales:
    rgh.new_var(scale,1.)
    
################################################build up ref domains############################################
#add atoms for bulk and two ref domains (ref_domain1<half layer> and ref_domain2<full layer>)
#In those two reference domains, the atoms are ordered according to first hight (z values), then y values
#it is a super surface structure by stacking the surface slab on bulk slab, the repeat vector was counted 

#only two possible path(one for runing in pacman, the other in local laptop)
try:
    add_atom_in_slab(bulk,batch_path_head+'bulk.str')
except:
    batch_path_head='D:\\Github\\batchfile\\'
    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))())
Beispiel #10
0
    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
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',\