def get_sim_params(sp_cell, slab_t=100, sampling=np.array([512, 512]), d_cutoff=4, grid_steps=np.array([32, 32]), cell_dim=100, energy=100e3, orientation_num=3, beam_overlap=1): """ return a dict object to set params of simulation and write to h5. """ sim_params = dict() # scattering params hkls, dhkls = get_kinematic_reflection(sp_cell.structure, top=3) if hkls[0].size > 3: # hexagonal systems hkls = np.array([[itm[0], itm[1], itm[-1]] for itm in hkls]) cutoff = np.logical_and( dhkls < 5., dhkls > 1.) # not considering less than 5 ang. d-spacing if dhkls[cutoff].size > 2: hkls = hkls[cutoff] dhkls = dhkls[cutoff] if dhkls.size > orientation_num: dhkls = dhkls[:orientation_num] hkls = hkls[:orientation_num] y_dirs = np.array([get_cell_orientation(z_dir) for z_dir in hkls]) semi_angles, _, _ = overlap_params(0.5, dhkls, voltage2Lambda(energy)) sim_params['y_dirs'] = y_dirs sim_params['z_dirs'] = hkls sim_params['semi_angles'] = semi_angles * 1e-3 # mrad sim_params['d_hkl'] = dhkls sim_params['cell_dim'] = cell_dim # ang. sim_params['energy'] = energy * 1e-3 # keV sim_params['sampling'] = sampling sim_params['slab_t'] = slab_t # ang. sim_params['grid_steps'] = grid_steps # optics params sim_params['probe_params'] = { 'smooth_apert': True, 'scherzer': False, 'apert_smooth': 30, 'aberration_dict': { 'C1': 0., 'C3': 0, 'C5': 0. }, 'spherical_phase': True } return sim_params
def get_slice_thickness(sp_cell, direc=np.array([0, 0, 1])): hkls, dhkls = get_kinematic_reflection(sp_cell.structure, top=10) if hkls[0].size > 3: # hexagonal systems hkls = np.array([[itm[0], itm[1], itm[-1]] for itm in hkls]) idx = np.argmin(np.abs(np.cross(hkls, direc).sum(1))) return dhkls[idx]