Example #1
0
#Protonation of distal oxygens, any number in [0,1,2], where 1 means singly protonated, two means doubly protonated
PROTONATION_DISTAL_OXYGEN=[[0,0]]*len(pickup_index)
#--------------------------------------------------#
#/bond_valence_constraint/end#

#/setup_group_scheme/begin#
GROUPING_SCHEMES=[]#eg[[2,1]]domain tag of first domain is 1 (Domain2=Domain1)
GROUPING_DEPTH=[[0, 10]]#means I will group top 10 (range(0,10)) layers of domain2 to those of domain1
commands_surface=domain_creator.generate_commands_for_surface_atom_grouping_new(np.array(GROUPING_SCHEMES),\
                                                                   domain_creator.translate_domain_type(GROUPING_SCHEMES,half_layer+full_layer),\
                                                                   GROUPING_DEPTH)
#/setup_group_scheme/end#

#/setup_slabs/begin#
bulk = model.Slab(T_factor='B')
domain_creator.add_atom_in_slab(bulk,os.path.join(batch_path_head,'hematite_rcut','bulk.str'))
for i in range(DOMAIN_NUMBER):
    domain_tag_ = int(int(DOMAIN[i])==1)
    file_prefix = ['full_layer','half_layer'][domain_tag_]
    pick_case = [full_layer_pick,half_layer_pick][domain_tag_]
    tag_slab_ = [2,3][int(pick_case[i]==[0,2][domain_tag_])]
    vars()['domain_class_'+str(int(i+1))]=\
        domain_creator.domain_creator.add_atom_in_slab(slab = model.Slab(c = 1.0,T_factor='B'),\
                                                       terminated_layer=0, N_layers = 5, \
                                                       domain_tag='_D'+str(int(i+1)),\
                                                       new_var=vars()['rgh_domain'+str(int(i+1))],\
                                                       filename = os.path.join(batch_path_head,'hematite_rcut','{}{}.str'.format(file_prefix,tag_slab_)))

    #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])):
##want to output the data for plotting?##
PLOT=not running_mode
##want to print out the protonation status?##
PRINT_PROTONATION=not running_mode
##want to print bond valence?##
PRINT_BV=not running_mode
##want to print the xyz files to build a 3D structure?##
PRINT_MODEL_FILES=not running_mode

################################################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      #
################################################################################################################
batch_path_head=batch_path.module_path_locator()
domain_creator.add_atom_in_slab(bulk,os.path.join(batch_path_head,'bulk.str'))
domain_creator.add_atom_in_slab(ref_L_domain1,os.path.join(batch_path_head,'half_layer2.str'))
domain_creator.add_atom_in_slab(ref_S_domain1,os.path.join(batch_path_head,'half_layer3.str'))
domain_creator.add_atom_in_slab(ref_L_domain2,os.path.join(batch_path_head,'full_layer2.str'))
domain_creator.add_atom_in_slab(ref_S_domain2,os.path.join(batch_path_head,'full_layer3.str'))

##set up Fourier pars if there are RAXR datasets
#Fourier component looks like A_Dn0_n1, where n0, n1 are used to specify the index for domain, and spectra, respectively
#Each spectra will have its own set of A and P list, and each domain has its own set of P and A list
rgh_raxr,F1F2=setup_domain_hematite_rcut.setup_raxr_pars(NUMBER_SPECTRA,batch_path_head,F1F2_FILE,RESONANT_EL_LIST)

###################create domain classes and initiate the chemical equivalent domains####################
##id list according to the order in the reference domain (used to set up ref domain)
ref_id_list_L_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_S_1=["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",\
Example #3
0
E0=18007#Adsorption edge energy
NUMBER_RAXS_SPECTRA=21#total number of RAXR spectra
RAXR_FIT_MODE='MI'#'MI' for model-independent, and 'MD' for model-dependent
FREEZE=True#FREEZE=True will have resonant el make no influence on the non-resonant structure factor. And it will otherwise.
NUMBER_DOMAIN,COHERENCE=2,True
HEIGHT_OFFSET=-2.6685#if set to 0, the top atomic layer is at 2.6685 in fractional unit before relaxation (should not be changed)
XY_OFFSET=[0,0]#takes effect only for structural atoms (not include Gaussian atoms)
GROUP_SCHEME=[[1,0]]#means group Domain1 and Domain2 for inplane and out of plane movement, set Domain2=Domain1 in side sim func

##<setting slabs>##
wal=0.7749136#wavelength,set this number right each time (read it from nQc data file)
c_lattice=20.04156#correct c each time (use q-corrected c),c_lattice=c_projected/sin(180-beta)
unitcell = model.UnitCell(5.1988, 9.0266, c_lattice, 90, 95.782, 90)#a,b,c,alpha,beta,gamma, 
inst = model.Instrument(wavel = wal, alpha = 2.0)
bulk, Domain1, Domain2 = model.Slab(T_factor='u'), model.Slab(c = 1.0,T_factor='u'), model.Slab(c = 1.0,T_factor='u')
domain_creator.add_atom_in_slab(bulk,os.path.join(BATCH_PATH_HEAD,'muscovite_001_bulk_u_corrected_new.str'),height_offset=HEIGHT_OFFSET)
domain_creator.add_atom_in_slab(Domain1,os.path.join(BATCH_PATH_HEAD,'muscovite_001_surface_Al_u_corrected_new.str'),attach='_D1',height_offset=HEIGHT_OFFSET)
domain_creator.add_atom_in_slab(Domain2,os.path.join(BATCH_PATH_HEAD,'muscovite_001_surface_Si_u_corrected_new.str'),attach='_D2',height_offset=HEIGHT_OFFSET)

##<experimental constants>##
L_max=17.34#maximum L value
sig_eff=2*np.pi/(2*np.pi/(unitcell.c*np.sin(np.pi-unitcell.beta))*L_max)/5.66#intrinsic width (due to sig) with resolution width
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)

##<coordination system definition>##
x0_v,y0_v,z0_v=np.array([1.,0.,0.]),np.array([0.,1.,0.]),np.array([0.,0.,1.])
#                                                                                                              #
#                           You seldomly need to touch script lines hereafter!!!                               #
#                                                                                                              #
#                                                                                                              #
#                                                                                                              #
################################################################################################################
#depository path for output files(structure model files(.xyz,.cif), optimized values (CTR,RAXR,E_Density) for plotting
output_file_path = output_path.module_path_locator()

################################################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      #
################################################################################################################
batch_path_head = batch_path.module_path_locator()
domain_creator.add_atom_in_slab(
    bulk, os.path.join(batch_path_head, 'Cu100_bulk.str'))
domain_creator.add_atom_in_slab(
    surface, os.path.join(batch_path_head, 'Cu100_surface.str'))

###################################fitting function part##########################################
VARS = vars()  #pass local variables to sim function
if COUNT_TIME: t_1 = datetime.now()


def Sim(data, VARS=VARS):
    for command in commands:
        eval(command)
    VARS = VARS
    F = []
    bv = 0
    bv_container = {}
##<global handles>##
RUN=1
BATCH_PATH_HEAD,OUTPUT_FILE_PATH=batch_path.module_path_locator(),output_path.module_path_locator()
F1F2=np.loadtxt(os.path.join(BATCH_PATH_HEAD,'Zr_K_edge.f1f2'))#the energy column should NOT have duplicate values after rounding up to 0 digit. If so, cut off rows of duplicate energy!
RAXR_EL,E0,NUMBER_RAXS_SPECTRA,RAXR_FIT_MODE,FREEZE='Zr',18007,21,'MI',True#FREEZE=True will have resonant el make no influence on the non-resonant structure factor. And it will otherwise.
NUMBER_DOMAIN,COHERENCE=2,True
HEIGHT_OFFSET=-2.6685#if set to 0, the top atomic layer is at 2.6685 in fractional unit before relaxation (should not be changed)
XY_OFFSET=[0,0]#takes effect only for structural atoms (not include Gaussian atoms)
GROUP_SCHEME=[[1,0]]#means group Domain1 and Domain2 for inplane and out of plane movement, set Domain2=Domain1 in side sim func

##<setting slabs>##
wal=0.7749136#wavelength,set this number right each time (read it from nQc data file)
unitcell = model.UnitCell(5.1988, 9.0266, 20.04156, 90, 95.782, 90)#a,b,c,alpha,beta,gamma, correct c each time (use q-corrected c),c=c_projected/sin(180-beta)
inst = model.Instrument(wavel = wal, alpha = 2.0)
bulk, Domain1, Domain2 = model.Slab(T_factor='u'), model.Slab(c = 1.0,T_factor='u'), model.Slab(c = 1.0,T_factor='u')
domain_creator.add_atom_in_slab(bulk,os.path.join(BATCH_PATH_HEAD,'muscovite_001_bulk_u_corrected_new.str'),height_offset=HEIGHT_OFFSET)
domain_creator.add_atom_in_slab(Domain1,os.path.join(BATCH_PATH_HEAD,'muscovite_001_surface_Al_u_corrected_new.str'),attach='_D1',height_offset=HEIGHT_OFFSET)
domain_creator.add_atom_in_slab(Domain2,os.path.join(BATCH_PATH_HEAD,'muscovite_001_surface_Si_u_corrected_new.str'),attach='_D2',height_offset=HEIGHT_OFFSET)

##<experimental constants>##
L_max=17.34#maximum L value
sig_eff=2*np.pi/(2*np.pi/(unitcell.c*np.sin(np.pi-unitcell.beta))*L_max)/5.66#intrinsic width (due to sig) with resolution width
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)

##<coordination system definition>##
x0_v,y0_v,z0_v=np.array([1.,0.,0.]),np.array([0.,1.,0.]),np.array([0.,0.,1.])
F1F2=np.loadtxt(BATCH_PATH_HEAD+'f1f2_temp.f1f2')
E0=18007##to be set##(absorbtion edge in eV)
NUMBER_RAXS_SPECTRA=28##to be set##
NUMBER_DOMAIN=2##to be set##
COHERENCE=True
RAXR_EL='Zr'##to be set##
RAXR_FIT_MODE='MD'##to be set##
HEIGHT_OFFSET=-2.6685#if set to 0, the top atomic layer is at 2.6685 in fractional unit before relaxation
INFO_LIB={'basis':BASIS,'sorbate_el':'Zr','coordinate_el':'O','T':T,'T_INV':T_INV,'oligomer_type':'tetramer'}##to be set##
GROUP_SCHEME=[[1,0]]#means group Domain1 and Domain2 for inplane and out of plane movement, set Domain2=Domain1 in side sim func

##<setting slabs>##
unitcell = model.UnitCell(5.1988, 9.0266, 20.1058, 90, 95.782, 90)
inst = model.Instrument(wavel = .833, alpha = 2.0)
bulk = model.Slab(T_factor='u')#bulk
domain_creator.add_atom_in_slab(bulk,BATCH_PATH_HEAD+'muscovite_001_bulk.str',height_offset=HEIGHT_OFFSET)
Domain1 =  model.Slab(c = 1.0,T_factor='u')#surface slabs-Domain1
domain_creator.add_atom_in_slab(Domain1,BATCH_PATH_HEAD+'muscovite_001_surface_Al.str',attach='_D1',height_offset=HEIGHT_OFFSET)
Domain2 =  model.Slab(c = 1.0,T_factor='u')#surface slabs-Domain2
domain_creator.add_atom_in_slab(Domain2,BATCH_PATH_HEAD+'muscovite_001_surface_Si.str',attach='_D2',height_offset=HEIGHT_OFFSET)
#You can add more domains

##<Adding sorbates>##to be set##
#domain1
rgh_domain1=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}
Domain1,rgh_domain1=domain_creator.add_sorbate(domain=Domain1,anchored_atoms=[],func=domain_creator_sorbate.OS_sqr_antiprism_oligomer,geo_lib=geo_lib_domain1,info_lib=INFO_LIB,domain_tag='_D1',rgh=rgh_domain1,index_offset=[0,1],height_offset=HEIGHT_OFFSET)
#domain2
rgh_domain2=UserVars()
geo_lib_domain2={'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}
Domain2,rgh_domain2=domain_creator.add_sorbate(domain=Domain2,anchored_atoms=[],func=domain_creator_sorbate.OS_sqr_antiprism_oligomer,geo_lib=geo_lib_domain2,info_lib=INFO_LIB,domain_tag='_D2',rgh=rgh_domain2,index_offset=[0,1],height_offset=HEIGHT_OFFSET)
Example #7
0
##want to output the data for plotting?##
PLOT=not running_mode
##want to print out the protonation status?##
PRINT_PROTONATION=not running_mode
##want to print bond valence?##
PRINT_BV=not running_mode
##want to print the xyz files to build a 3D structure?##
PRINT_MODEL_FILES=not running_mode

################################################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      #
################################################################################################################
batch_path_head=batch_path.module_path_locator()
domain_creator.add_atom_in_slab(bulk,os.path.join(batch_path_head,'bulk.str'))
domain_creator.add_atom_in_slab(ref_L_domain1,os.path.join(batch_path_head,'half_layer2.str'))
domain_creator.add_atom_in_slab(ref_S_domain1,os.path.join(batch_path_head,'half_layer3.str'))
domain_creator.add_atom_in_slab(ref_L_domain2,os.path.join(batch_path_head,'full_layer2.str'))
domain_creator.add_atom_in_slab(ref_S_domain2,os.path.join(batch_path_head,'full_layer3.str'))

##set up Fourier pars if there are RAXR datasets
#Fourier component looks like A_Dn0_n1, where n0, n1 are used to specify the index for domain, and spectra, respectively
#Each spectra will have its own set of A and P list, and each domain has its own set of P and A list
rgh_raxr,F1F2=setup_domain_hematite_rcut.setup_raxr_pars(NUMBER_SPECTRA,batch_path_head,F1F2_FILE,RESONANT_EL_LIST)

###################create domain classes and initiate the chemical equivalent domains####################
##id list according to the order in the reference domain (used to set up ref domain)
ref_id_list_L_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_S_1=["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",\