diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
index ba84e2a3..3914dc7c
--- a/.gitignore
+++ b/.gitignore
@@ -1,36 +1,435 @@
-*.mexw64
-*.mexa64
-*.mexmaci64
-*.pdb
-*.o
-*.ilk
-*.asv
-*.deps
-*.wisdom
-*.exe
-*.dll
-*.asv
-*.7z
-*Copy*.cuh
-*Copy*.hpp
-*Copy*.cpp
-*tmp.m
-MULTEM_binary
-MULTEM_binary.rar
-MULTEM_binary.zip
-compile_mex_general.m
-mex_examples_general
-mex_files_general
-src_temporal
-mex_test
-.vs
-bugs
-design
-build-multem-Desktop_Qt_5_9_0_MSVC2015_64bit-Debug
-build-multem-Desktop_Qt_5_9_0_MSVC2015_64bit-Release
-gui_bin
-mex_bin
-EDX
-.vscode
-multem.zip
-multem_stable.zip
+*.mexw64
+*.mexa64
+*.mexmaci64
+*.pdb
+*.o
+*.ilk
+*.asv
+*.deps
+*.wisdom
+*.exe
+*.dll
+*.asv
+*.7z
+*Copy*.cuh
+*Copy*.hpp
+*Copy*.cpp
+build-multem-Desktop_Qt_5_9_0_MSVC2015_64bit-Debug
+build-multem-Desktop_Qt_5_9_0_MSVC2015_64bit-Release
+.vscode
+EDX
+multem.zip
+multem_stable.zip
+mex_example_test
+multem_binary
+multem_binary.rar
+multem_binary.zip
+compile_mex_general.m
+compile_mex_test.m
+mex_files_general
+mex_files_test
+matlab_functions_nn
+mex_examples_general
+others
+src_temporal
+tutorial
+bugs
+design
+src - Copy
+visual_studio_multem/.vs
+visual_studio_multem/x64
+visual_studio_multem/multem/x64
+mex_files_multem/mex_CUDA_glnxa64.xml
+mex_files_multem/mex_CUDA_maci64.xml
+mex_files_multem/mex_CUDA_win64.xml
+src/atomic_cross_section.cuh
+src/cb_spl_intrpl.hpp
+src/cpu_fcns_image.hpp
+src/cgpu_spt_ptc.cuh
+src/crystal_spec.hpp
+src/eval_fit_atomic_columns.hpp
+src/eval_fit_atomic_columns_c.hpp
+src/eval_fit_atomic_columns_c_old.hpp
+src/eval_fit_gaussians.hpp
+src/peak_finding.cuh
+src/incident_wave.cuh
+src/eval_fit_gaussians.hpp
+src/input_multislice.cuh
+src/input_tomography.cuh
+src/output_multem.hpp
+src/peak_finding.cuh
+src/projected_potential.cuh
+src/transmission_fcn.cuh
+src/wave_function.cuh
+src/propagator.cuh
+src/tem_simulation.cuh
+src/energy_loss.cuh
+src/microscope_effects.cuh
+matlab_functions/atomic_radius.mat
+matlab_functions/center_spec.m
+matlab_functions/extract_atomic_pos_lammps.m
+matlab_functions/fsd_parm_coef.mat
+matlab_functions/g_Grid.m
+matlab_functions/ilm_adapthisteq_3d.m
+matlab_functions/ilm_add_alpha_channel.m
+matlab_functions/ilm_add_filesep.m
+matlab_functions/ilm_angle_btw_vectors.m
+matlab_functions/ilm_apply_fs_3d_thr.m
+matlab_functions/ilm_apply_jitter_jitter.m
+matlab_functions/ilm_apply_mask_g_3d.m
+matlab_functions/ilm_apply_mtf_g.m
+matlab_functions/ilm_apply_pbc.m
+matlab_functions/ilm_apply_rs_3d_thr.m
+matlab_functions/ilm_apply_rs_3d_thr_2.m
+matlab_functions/ilm_apply_spatial_incoh_model.m
+matlab_functions/ilm_apply_tr_bw_mask.m
+matlab_functions/ilm_apply_wiener_filter.m
+matlab_functions/ilm_apply_wiener_filter_ast.m
+matlab_functions/ilm_astra_create_parallel3d_proj_geom.m
+matlab_functions/ilm_atoms_get_box_size.m
+matlab_functions/ilm_at_2_data.m
+matlab_functions/ilm_at_p_2_nr_grid.m
+matlab_functions/ilm_at_v_2_bd.m
+matlab_functions/ilm_bandwidth_limit.m
+matlab_functions/ilm_bd_2_data.m
+matlab_functions/ilm_bd_2_xy.m
+matlab_functions/ilm_bg_subtraction_3d.m
+matlab_functions/ilm_bining_image.m
+matlab_functions/ilm_build_ellip_par_interp2.m
+matlab_functions/ilm_calc_borders_using_at_v.m
+matlab_functions/ilm_center_tr_2d_using_at_v.m
+matlab_functions/ilm_chk_bound.m
+matlab_functions/ilm_chk_bound_eq.m
+matlab_functions/ilm_compile.m
+matlab_functions/ilm_cosine_loss.m
+matlab_functions/ilm_create_mtf_g.m
+matlab_functions/ilm_cubic_mask.m
+matlab_functions/ilm_cvt_at_v_2_A_txy.m
+matlab_functions/ilm_cvt_at_v_2_tr_scy_shx_v.m
+matlab_functions/ilm_cvt_at_v_bci_2_at_v_r.m
+matlab_functions/ilm_cvt_at_v_r_2_at_v_bci.m
+matlab_functions/ilm_cvt_A_txy_2_at_v.m
+matlab_functions/ilm_cylindrical_mask.m
+matlab_functions/ilm_damp_added_borders.m
+matlab_functions/ilm_data_2_stack_3d.m
+matlab_functions/ilm_data_2_stack_4d.m
+matlab_functions/ilm_defocus_depth.m
+matlab_functions/ilm_dflt_at_p.m
+matlab_functions/ilm_dir.m
+matlab_functions/ilm_dist_pt_2_ln_2d.m
+matlab_functions/ilm_dose.m
+matlab_functions/ilm_draw_line_mx.m
+matlab_functions/ilm_draw_line_mx_aa.m
+matlab_functions/ilm_draw_pol_mx.m
+matlab_functions/ilm_ellipsoid_butterworth.m
+matlab_functions/ilm_elliptical_gaussian_2d_fix_pos.m
+matlab_functions/ilm_eval_ellipse_2d.m
+matlab_functions/ilm_eval_ellip_interp2.m
+matlab_functions/ilm_eval_rad_mtf.m
+matlab_functions/ilm_extract_atomic_pos_lammps.m
+matlab_functions/ilm_extract_data.m
+matlab_functions/ilm_extract_region.m
+matlab_functions/ilm_extract_region_using_bd.m
+matlab_functions/ilm_extr_marg_frame_gfc.m
+matlab_functions/ilm_extr_sq_frame_gfc.m
+matlab_functions/ilm_fcc_001_xyc_2_xycg.m
+matlab_functions/ilm_fcc_110_xyc_2_xycg.m
+matlab_functions/ilm_fcn_butterworth.m
+matlab_functions/ilm_fcn_butterworth_3d.m
+matlab_functions/ilm_fcn_butterworth_rect.m
+matlab_functions/ilm_fd_neighbors.m
+matlab_functions/ilm_fd_tc_theta_using_sirt_3df.m
+matlab_functions/ilm_fd_tc_using_sirt_3df.m
+matlab_functions/ilm_fd_theta_at_p_using_sirt_3df.m
+matlab_functions/ilm_fd_theta_tc_0_using_sirt_3df.m
+matlab_functions/ilm_fd_theta_using_sirt_3df.m
+matlab_functions/ilm_fd_tr_2d_bi.m
+matlab_functions/ilm_fd_tr_2d_bi_tem.m
+matlab_functions/ilm_fd_tr_2d_ri.m
+matlab_functions/ilm_fd_tr_scy_shx_2d_bi.m
+matlab_functions/ilm_fd_tr_scy_shx_2d_ri.m
+matlab_functions/ilm_fd_tr_using_sirt_3df.m
+matlab_functions/ilm_fft2.m
+matlab_functions/ilm_find_center_radius_cbed.m
+matlab_functions/ilm_find_closest_pos.m
+matlab_functions/ilm_find_closest_xy_pos.m
+matlab_functions/ilm_fitting_xtl_structure_3d.m
+matlab_functions/ilm_fit_ellipse_2d.m
+matlab_functions/ilm_fit_elliptical_gaussian_2d_using_fix_pos.m
+matlab_functions/ilm_fit_gaussian_2d_using_fix_pos.m
+matlab_functions/ilm_fit_gaussian_exp_2d_using_fix_pos.m
+matlab_functions/ilm_fit_three_gaussian_2d_using_fix_pos.m
+matlab_functions/ilm_fit_two_gaussian_2d_using_fix_pos.m
+matlab_functions/ilm_fs_grid_2d.m
+matlab_functions/ilm_fs_spatial_incoh_model.m
+matlab_functions/ilm_gaussian_2d_fix_pos.m
+matlab_functions/ilm_gaussian_exp_2d_fix_pos.m
+matlab_functions/ilm_gaussian_win.m
+matlab_functions/ilm_gauss_cv_2_data.m
+matlab_functions/ilm_gen_lammps_bash.m
+matlab_functions/ilm_gen_lammps_relaxation_eam_bash.m
+matlab_functions/ilm_gen_lammps_relaxation_eam_in.m
+matlab_functions/ilm_gen_lammps_relaxation_sr_h_hs_q_qs_sr_in.m
+matlab_functions/ilm_gen_lammps_relaxation_sr_loop_h_hs_sr_in.m
+matlab_functions/ilm_gen_tmg_proj.m
+matlab_functions/ilm_geom_center_cp.m
+matlab_functions/ilm_get_bg.m
+matlab_functions/ilm_get_bin_shadow_image.m
+matlab_functions/ilm_get_center_tr_2d.m
+matlab_functions/ilm_get_ctr_rng.m
+matlab_functions/ilm_get_displacement_center.m
+matlab_functions/ilm_get_idx_0_idx_e.m
+matlab_functions/ilm_get_idx_0_idx_e_2d.m
+matlab_functions/ilm_get_idx_0_idx_e_3d.m
+matlab_functions/ilm_get_jitter.m
+matlab_functions/ilm_get_jitter_opt_flow.m
+matlab_functions/ilm_get_mask_3d_thr.m
+matlab_functions/ilm_gui_2d_segmentation.m
+matlab_functions/ilm_gui_3d_segmentation.m
+matlab_functions/ilm_gui_cbed_elliptical_fit.m
+matlab_functions/ilm_gui_g_max.m
+matlab_functions/ilm_gui_is_over_object.m
+matlab_functions/ilm_gui_pcf_sigma.m
+matlab_functions/ilm_gui_peak_finding.m
+matlab_functions/ilm_gui_rotate_image.m
+matlab_functions/ilm_gui_stem_registration.m
+matlab_functions/ilm_gui_tomo_aligment.m
+matlab_functions/ilm_g_ref_create_mask_gaussian_3d.m
+matlab_functions/ilm_g_ref_opt_individual_full.m
+matlab_functions/ilm_g_ref_opt_iso_A_3d.m
+matlab_functions/ilm_g_ref_opt_iso_A_sigma_3d.m
+matlab_functions/ilm_g_ref_opt_iso_sigma_3d.m
+matlab_functions/ilm_g_ref_opt_iso_xyz_3d.m
+matlab_functions/ilm_g_ref_opt_set_parm_0.m
+matlab_functions/ilm_g_ref_opt_vector_3d.m
+matlab_functions/ilm_g_ref_opt_vector_full.m
+matlab_functions/ilm_g_ref_opt_vector_set_par_0.m
+matlab_functions/ilm_g_ref_vector_create_mask_gaussian_3d.m
+matlab_functions/ilm_hanning_win.m
+matlab_functions/ilm_harm_osc_1d.m
+matlab_functions/ilm_harm_osc_2d.m
+matlab_functions/ilm_hysitron_video_proc.m
+matlab_functions/ilm_idx_2_meshgrid_2d.m
+matlab_functions/ilm_idx_2_meshgrid_3d.m
+matlab_functions/ilm_imagesc.m
+matlab_functions/ilm_image_4fold_replication.m
+matlab_functions/ilm_image_centroid.m
+matlab_functions/ilm_image_replication.m
+matlab_functions/ilm_inv_linear_interp.m
+matlab_functions/ilm_jitter_join_dxy.m
+matlab_functions/ilm_jitter_opt.m
+matlab_functions/ilm_jitter_opt_btw_2.m
+matlab_functions/ilm_jitter_opt_flow_analytic.m
+matlab_functions/ilm_jitter_rt.m
+matlab_functions/ilm_jitter_rti.m
+matlab_functions/ilm_jitter_rti_dxy.m
+matlab_functions/ilm_jitter_rt_dxy.m
+matlab_functions/ilm_jitter_xy.m
+matlab_functions/ilm_laguerre.m
+matlab_functions/ilm_linear_interp.m
+matlab_functions/ilm_line_intxn_2d.m
+matlab_functions/ilm_max_dist.m
+matlab_functions/ilm_mean_abs_fdata.m
+matlab_functions/ilm_mean_abs_fdata_at.m
+matlab_functions/ilm_mean_data.m
+matlab_functions/ilm_mean_data_at.m
+matlab_functions/ilm_mean_data_nr_grid.m
+matlab_functions/ilm_mean_fdata.m
+matlab_functions/ilm_mean_image.m
+matlab_functions/ilm_mean_std.m
+matlab_functions/ilm_mean_std_ni.m
+matlab_functions/ilm_mean_std_np.m
+matlab_functions/ilm_mfft3d_for_fitting.m
+matlab_functions/ilm_minmax_norm_image.m
+matlab_functions/ilm_min_dist.m
+matlab_functions/ilm_min_distance.m
+matlab_functions/ilm_min_max.m
+matlab_functions/ilm_min_max_ni.m
+matlab_functions/ilm_min_max_np.m
+matlab_functions/ilm_mrad_2_rAng.m
+matlab_functions/ilm_nr_grid_2_data.m
+matlab_functions/ilm_nz_data.m
+matlab_functions/ilm_orien_xyz.m
+matlab_functions/ilm_pca_mx.m
+matlab_functions/ilm_pctf.m
+matlab_functions/ilm_plot_bd.m
+matlab_functions/ilm_plot_circle.m
+matlab_functions/ilm_plot_circle_wc.m
+matlab_functions/ilm_plot_ellipse.m
+matlab_functions/ilm_plot_rectangle.m
+matlab_functions/ilm_plot_vectors_3d.m
+matlab_functions/ilm_pn_border.m
+matlab_functions/ilm_pn_fact.m
+matlab_functions/ilm_polyfit_w.m
+matlab_functions/ilm_proj_cube.m
+matlab_functions/ilm_propagator.m
+matlab_functions/ilm_rand.m
+matlab_functions/ilm_randa.m
+matlab_functions/ilm_randi_r.m
+matlab_functions/ilm_randn.m
+matlab_functions/ilm_rand_crack_2d.m
+matlab_functions/ilm_rand_gt.m
+matlab_functions/ilm_rand_gt_c.m
+matlab_functions/ilm_rand_im.m
+matlab_functions/ilm_rand_rect_shell.m
+matlab_functions/ilm_rand_spatial_incoh_coef.m
+matlab_functions/ilm_rand_u.m
+matlab_functions/ilm_rand_u_theta.m
+matlab_functions/ilm_rand_walk_2d.m
+matlab_functions/ilm_rAng_2_mrad.m
+matlab_functions/ilm_read_angles_cif.m
+matlab_functions/ilm_read_ap_cif.m
+matlab_functions/ilm_read_ap_dump_lammps.m
+matlab_functions/ilm_read_ap_lammps.m
+matlab_functions/ilm_read_ap_pdb.m
+matlab_functions/ilm_read_ap_xyz.m
+matlab_functions/ilm_read_blo.m
+matlab_functions/ilm_read_dm.m
+matlab_functions/ilm_read_emd.m
+matlab_functions/ilm_read_folder_as_3d.m
+matlab_functions/ilm_read_info_blo.m
+matlab_functions/ilm_read_info_dm.m
+matlab_functions/ilm_read_info_mib.m
+matlab_functions/ilm_read_info_ser.m
+matlab_functions/ilm_read_info_video.m
+matlab_functions/ilm_read_lat_parm_cif.m
+matlab_functions/ilm_read_mib.m
+matlab_functions/ilm_read_mib_4d_dir.m
+matlab_functions/ilm_read_mrc.m
+matlab_functions/ilm_read_ser.m
+matlab_functions/ilm_read_ser_old.m
+matlab_functions/ilm_read_ser_or_dm.m
+matlab_functions/ilm_read_tif.m
+matlab_functions/ilm_read_tif_mat.m
+matlab_functions/ilm_read_tif_or_mrc.m
+matlab_functions/ilm_read_video.m
+matlab_functions/ilm_read_x_hdf5.m
+matlab_functions/ilm_read_x_y_hdf5.m
+matlab_functions/ilm_read_y_hdf5.m
+matlab_functions/ilm_remove_atoms_pbc.m
+matlab_functions/ilm_remove_overlaping_xy.m
+matlab_functions/ilm_remove_overlaping_xyz.m
+matlab_functions/ilm_remove_points_fourier_space.m
+matlab_functions/ilm_remove_spike.m
+matlab_functions/ilm_replace_filesep.m
+matlab_functions/ilm_resc_tem_data.m
+matlab_functions/ilm_resize_2_data.m
+matlab_functions/ilm_retrieve_threshold.m
+matlab_functions/ilm_rot_3d_tr_2d.m
+matlab_functions/ilm_rot_cube_3d.m
+matlab_functions/ilm_rot_mx_2d.m
+matlab_functions/ilm_rot_mx_3d.m
+matlab_functions/ilm_rot_tr_2d_2_data.m
+matlab_functions/ilm_rs_grid_2d.m
+matlab_functions/ilm_rs_spatial_incoh_model.m
+matlab_functions/ilm_run.m
+matlab_functions/ilm_run_nr_stem.m
+matlab_functions/ilm_run_rg_stem.m
+matlab_functions/ilm_r_vector_create_mask_gaussian_3d.m
+matlab_functions/ilm_search_subdir.m
+matlab_functions/ilm_seeds_2_voronoi_polygon.m
+matlab_functions/ilm_seed_thr.m
+matlab_functions/ilm_select_atoms.m
+matlab_functions/ilm_select_atoms_in_box.m
+matlab_functions/ilm_select_atoms_out_box.m
+matlab_functions/ilm_select_pixels_around.m
+matlab_functions/ilm_series_images_filtering.m
+matlab_functions/ilm_series_images_remove.m
+matlab_functions/ilm_set_borders.m
+matlab_functions/ilm_set_bound.m
+matlab_functions/ilm_set_rng_state.m
+matlab_functions/ilm_sg_2_bl.m
+matlab_functions/ilm_show_lattice_par.m
+matlab_functions/ilm_show_pcf.m
+matlab_functions/ilm_show_proj_xtl.m
+matlab_functions/ilm_show_slicing.m
+matlab_functions/ilm_show_xtl.m
+matlab_functions/ilm_sigma_g_2_sigma_r.m
+matlab_functions/ilm_sinc_2d_interpolation.m
+matlab_functions/ilm_sirt_3df.m
+matlab_functions/ilm_sirt_3df_patch.m
+matlab_functions/ilm_sirt_3ds.m
+matlab_functions/ilm_sirt_cstr_3df.m
+matlab_functions/ilm_sizeof.m
+matlab_functions/ilm_size_data.m
+matlab_functions/ilm_size_mib.m
+matlab_functions/ilm_size_tif.m
+matlab_functions/ilm_size_tif_mat.m
+matlab_functions/ilm_snr.m
+matlab_functions/ilm_sort_files.m
+matlab_functions/ilm_spec_recenter.m
+matlab_functions/ilm_sphere_mask.m
+matlab_functions/ilm_split_range_idx.m
+matlab_functions/ilm_spt_gaussian_2d_xy.m
+matlab_functions/ilm_spt_gaussian_2d_xyc.m
+matlab_functions/ilm_spt_gaussian_2d_xyz.m
+matlab_functions/ilm_stack_3d_2_data.m
+matlab_functions/ilm_stack_4d_2_data.m
+matlab_functions/ilm_stem_4d_aligment.m
+matlab_functions/ilm_stem_det_resize.m
+matlab_functions/ilm_swap.m
+matlab_functions/ilm_TEM_Image_Model.m
+matlab_functions/ilm_three_gaussian_2d_fix_pos.m
+matlab_functions/ilm_tomo_dir.m
+matlab_functions/ilm_tomo_mfft_2d_from_data.m
+matlab_functions/ilm_tomo_mfft_2d_from_files.m
+matlab_functions/ilm_tomo_ts_align.m
+matlab_functions/ilm_tri_2d.m
+matlab_functions/ilm_tr_2d_2_data.m
+matlab_functions/ilm_tr_at_2d_2_data.m
+matlab_functions/ilm_tr_rot_2d_2_data.m
+matlab_functions/ilm_two_gaussian_2d_fix_pos.m
+matlab_functions/ilm_ucr_create_mask.m
+matlab_functions/ilm_ucr_opt_A.m
+matlab_functions/ilm_ucr_opt_p_c.m
+matlab_functions/ilm_ucr_opt_p_c_v.m
+matlab_functions/ilm_ucr_opt_R_u.m
+matlab_functions/ilm_ucr_opt_set_parm_0.m
+matlab_functions/ilm_ucr_opt_sigma.m
+matlab_functions/ilm_ucr_opt_v.m
+matlab_functions/ilm_unit_vctr_2d.m
+matlab_functions/ilm_unit_vctr_3d.m
+matlab_functions/ilm_vect_assign.m
+matlab_functions/ilm_write_ap_lammps.m
+matlab_functions/ilm_write_ap_pdb.m
+matlab_functions/ilm_write_blo.m
+matlab_functions/ilm_write_gif.m
+matlab_functions/ilm_write_mrc.m
+matlab_functions/ilm_write_tif.m
+matlab_functions/ilm_write_video.m
+matlab_functions/ilm_write_x_2y_hdf5.m
+matlab_functions/ilm_write_x_hdf5.m
+matlab_functions/ilm_write_x_y_hdf5.m
+matlab_functions/ilm_write_y_hdf5.m
+matlab_functions/ilm_xtl_build.m
+matlab_functions/ilm_xtl_build_base.m
+matlab_functions/ilm_xtl_csn_2_sgr.m
+matlab_functions/ilm_xtl_css_2_csn.m
+matlab_functions/ilm_xtl_css_2_sgr.m
+matlab_functions/ilm_xtl_dmt.m
+matlab_functions/ilm_xtl_dsm.m
+matlab_functions/ilm_xtl_dvect.m
+matlab_functions/ilm_xtl_dvect_2_rvect.m
+matlab_functions/ilm_xtl_omega.m
+matlab_functions/ilm_xtl_rmt.m
+matlab_functions/ilm_xtl_rsm.m
+matlab_functions/ilm_xtl_rvect.m
+matlab_functions/ilm_xtl_sgn_2_csn.m
+matlab_functions/ilm_xycg_2_atoms_symm.m
+matlab_functions/ilm_xycg_2_atoms_theta.m
+matlab_functions/ilm_xy_2_xyc.m
+matlab_functions/ilm_Z.m
+matlab_functions/ilm_Z_2_str.m
+matlab_functions/m2psi_tot_0.mat
+matlab_functions/mexBlasLapackCPU.m
+matlab_functions/multem_default_values.m
+matlab_functions/nvcc_g++.xml
+matlab_functions/PCTF.m
+matlab_functions/R_Grid.m
+matlab_functions/shape_spline.mat
+matlab_functions/ShowSlicing.m
+matlab_functions/show_crystal.m
+matlab_functions/space_groups.mat
+matlab_functions/tfm_check_stem_setup.m
+matlab_functions/ToDiffScale.m
+matlab_functions/xy_projected.mat
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
old mode 100644
new mode 100755
index 20d40b6b..3d90694a
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,674 +1,674 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
.
\ No newline at end of file
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
index 618cf176..b4e8118d
--- a/README.md
+++ b/README.md
@@ -1,108 +1,109 @@
-# MULTEM
-
-## Introduction
-**MULTEM** is a powerful and advanced software package designed to provide researchers with a versatile tool for simulating a wide range of electron microscopy experiments. Developed by Ivan Lobato (Ivanlh20@gmail.com), MULTEM is built on a collection of C++ routines with CUDA support, enabling it to perform efficient and accurate multislice simulations for various TEM experiments.
-
-MULTEM uses the widely adopted multislice method to simulate electron scattering and wave propagation in a crystal. This method involves dividing the crystal into thin slices and calculating the electron scattering and wave propagation in each slice. This allows for accurate and efficient simulations of various electron microscopy experiments such as high-resolution TEM (HRTEM), scanning TEM (STEM), imaging STEM (ISTEM), electron diffraction (ED), precession electron diffraction (PED), convergent beam electron diffraction (CBED), annular dark field-TEM (ADF-TEM), annular bright field Hollow Cone (ABF-HC), energy filtered TEM (EFTEM), and electron energy loss spectroscopy (EELS).
-
-MULTEM's implementation is further enhanced by its support for CUDA, a parallel computing platform developed by NVIDIA. This feature enables MULTEM to use graphics processing units (GPUs) for simulations, greatly reducing computation time and increasing simulation speed.
-
-Currently, there are three ways to use MULTEM::
-- C++: directly using the library
-- Matlab: using the provided mex interface
-- GUI: using the user-friendly graphical interface
-
-Please note that the library is under active development and subject to change. The Matlab interface is the recommended way for researchers to use MULTEM.
-
-## Remarks
-
-In order to use the GPU capability of MULTEM, you need a Nvidia Graphic card with **compute capability greater than 3.5** and **CUDA 11.8** installed in your operating system. You can check the compute capability of your graphic card using the following nvidia website: https://developer.nvidia.com/cuda-gpus.
-
-### Using precompiled GUI interface
-
-The precompiled GUI interface is only available for Windows operating system.
-
-- Go to [https://github.com/Ivanlh20/MULTEM/releases](https://github.com/Ivanlh20/MULTEM/releases) and download `MULTEM_binary.7z`.
-- Execute `vc_redist.x64.exe` located in `gui_bin` folder.
-- Execute `multem.exe`.
-
-### Using precompiled mexfiles for Matlab
-
-The precompiled mexfiles are only available for Windows operating system and Ubuntu 18.04-based Linux distributions.
-
-- Go to [https://github.com/Ivanlh20/MULTEM/releases](https://github.com/Ivanlh20/MULTEM/releases) and download `MULTEM.zip`.
-- Execute `vc_redist.x64.exe` located in `mex_bin` folder. (Windows only)
-- Add the following folders to the Matlab path: crystalline_materials, matlab_functions and mex_bin.
-- Run the examples located in 'mex_examples_multem'.
-
-### Building MULTEM for Matlab
-
-The following steps have been tested and found to work with Matlab 2022b and CUDA 11.8. It is assumed that a C++ compiler such as Visual Studio 2019 Community, g++11.3 or Clang (Xcode 10.x) is installed on your operating system. Additionally, MULTEM also requires the fftw3, BLAS, and LAPACK libraries to be installed.The following steps have been tested and found to work with Matlab 2022b and CUDA 11.8. It is assumed that a C++ compiler such as Visual Studio 2019 Community, g++11.3 or Clang (Xcode 10.x) is installed on your operating system. Additionally, MULTEM also requires the fftw3, BLAS, and LAPACK libraries to be installed.
-
-- Firstly, a C++ compiler must be set for Matlab by executing the following command: `mex -setup cpp`. It is important to note that Matlab 2022b only supports the compilers listed above.
-- Next, add the following folders to the Matlab path: crystalline_materials, matlab_functions, and mex_bin.
-- Run the script `compile_mex_multem.m`. This will create the necessary executable files to run the examples.
-- Finally, run the examples located in the `mex_examples_multem folder`.
-
-### Troubleshooting
-
-- If MULTEM does not compile with the above procedures, one of the following procedures might fix it
-
- **for Windows:**
-
- - Verify the installation of Visual studio 2019 community.
- - Verify the installation of Cuda 11.8 (https://developer.nvidia.com/cuda-downloads).
-
- **for Linux:**
-
- - Verify that gcc-11.3 and g++11.3 are the default compilers installed in your operating system. In Ubuntu, it can be installed by executing the following commands:
- ```bash
- sudo apt-get update
- sudo apt-get install gcc-11.3 g++-11.3
- ```
-
- - Verify the correct installation of Cuda 11.8 (https://developer.nvidia.com/cuda-downloads).
-
- - Verify the installation of fftw3 libraries. In Ubuntu, it can be installed by executing the following command:
- ```bash
- sudo apt-get install libfftw3-dev libfftw3-doc
- ```
-
- - Verify the installation of blas and lapack libraries. In Ubuntu, it can be installed by executing the following command:
- ```bash
- sudo apt-get install libblas-dev liblapack-dev
- ```
-
-- Verify the installation path of cuda 11.8, fftw3, blas and lapack. Their installation paths should be specified in the [ilm_mex.m](./matlab_functions/ilm_mex.m).
-
-**Please cite MULTEM in your publications if it helps your research:**
-```bibtex
- @article{LVAV16_1,
- Author = {I.Lobato and S.Van Aert and J.Verbeeck},
- Journal = {Ultramicroscopy},
- Title = {Progress and new advances in simulating electron microscopy datasets using MULTEM},
- Year = {2016},
- volume = {168},
- pages = {17-27}
- }
-
- @article{LD15_2,
- Author = {I. Lobato and D. Van Dyck},
- Journal = {Ultramicroscopy},
- Title = {MULTEM: A new multislice program to perform accurate and fast electron diffraction and imaging simulations using Graphics Processing Units with CUDA},
- Year = {2015},
- volume = {156},
- pages = {9-17}
- }
- ```
-**if you use our parameterization of the electronscattering factors, please cite the following article:**
-```bibtex
- @Article{LD14_1,
- Title = {{An accurate parameterization for the scattering factors, electron densities and electrostatic potentials for neutral atoms that obey all physical constraints}},
- Author = {I. Lobato and D. Van Dyck},
- Journal = {Acta Crystallographica Section A},
- Year = {2014},
- Pages = {636-649},
- Volume = {70}
- }
+# MULTEM
+
+## Introduction
+
+**MULTEM** is a collection of routines written in C++ with CUDA to perform accurate and fast multislice simulations for different TEM experiments as: HRTEM, STEM, ISTEM, ED, PED, CBED, ADF-TEM, ABF-HC, EFTEM and EELS. It is developed by Ivan Lobato (Ivanlh20@gmail.com).
+
+Currently, there are three supported ways to use MULTEM:
+- C++: using the library itself
+- Matlab: using the mex interface
+- GUI: using the user graphical interface
+
+The library is under heavy development and subject to change.
+The Matlab interface is the recommended way for researchers.
+
+## Remarks
+
+In order to use the GPU capability of MULTEM, you need a Nvidia Graphic card with **compute capability greater than 2.0** and **CUDA 11.0** installed in your operating system. You can check the compute capability of your graphic card using the following nvidia website: https://developer.nvidia.com/cuda-gpus.
+
+### Using precompiled GUI interface
+
+The precompiled GUI interface is only available for Windows operating system.
+
+- Go to [https://github.com/Ivanlh20/MULTEM/releases](https://github.com/Ivanlh20/MULTEM/releases) and download `MULTEM_binary.7z`.
+- Execute `vc_redist.x64.exe` located in `gui_bin` folder.
+- Execute `multem.exe`.
+
+### Using precompiled mexfiles for Matlab
+
+The precompiled mexfiles are only available for Windows operating system and Ubuntu 18.04-based Linux distributions.
+
+- Go to [https://github.com/Ivanlh20/MULTEM/releases](https://github.com/Ivanlh20/MULTEM/releases) and download `MULTEM.zip`.
+- Execute `vc_redist.x64.exe` located in `mex_bin` folder. (Windows only)
+- Add the following folders to the Matlab path: crystalline_materials, matlab_functions and mex_bin.
+- Run the examples located in 'mex_examples_multem'.
+
+### Building MULTEM for Matlab
+
+The following steps work using Matlab 2020b and CUDA 11.0. It assumes that Visual studio 2017 community, g++7.5 or Clang(Xcode 10.x) compiler is installed in your operating system. Additionally, Multem also requires fftw3, blas and lapack libraries.
+
+- Firstly, a C++ compiler must be set for Matlab by executing the following comand: `mex -setup cpp`. Be aware that Matlab 2020b only supports the above compilers.
+- Then add the following folders to the Matlab path: crystalline_materials, matlab_functions and mex_bin.
+- Run the `compile_mex_multem.m` script. This will create the required executable files to run the examples.
+- Run the examples located in `mex_examples_multem`.
+
+### Troubleshooting
+
+- If MULTEM does not compile with the above procedures, one of the following procedures might fix it
+- Currently (v2.2.3) some of the files in the Thrust library, that ships with Cuda 10.0 are incompatible with the Multem source code. To compile Multem, this library should be replaced with the Version of Cuda 8.0. [The files can be found in the MULTEM repository](./thrust.zip).
+
+ **for Windows:**
+
+ - Verify the installation of Visual studio 2017 community.
+ - Verify the installation of Cuda 11.0 (https://developer.nvidia.com/cuda-downloads).
+
+ **for Linux:**
+
+ - Verify that gcc-7.5 and g++7.5 are the default compilers installed in your operating system. In Ubuntu, it can be installed by executing the following commands:
+ ```bash
+ sudo apt-get update
+ sudo apt-get install gcc-7.5 g++-7.5
+ ```
+
+ - Verify the correct installation of Cuda 10.0 (https://developer.nvidia.com/cuda-downloads).
+
+ - Verify the installation of fftw3 libraries. In Ubuntu, it can be installed by executing the following command:
+ ```bash
+ sudo apt-get install libfftw3-dev libfftw3-doc
+ ```
+
+ - Verify the installation of blas and lapack libraries. In Ubuntu, it can be installed by executing the following command:
+ ```bash
+ sudo apt-get install libblas-dev liblapack-dev
+ ```
+
+ - Replace the Thrust library folder in location: /usr/local/cuda/include/thrust
+
+- Verify the installation path of cuda 11.0, fftw3, blas and lapack. Their installation paths should be specified in the [ilm_mex.m](./matlab_functions/ilm_mex.m).
+
+**Please cite MULTEM in your publications if it helps your research:**
+```bibtex
+ @article{LVAV16_1,
+ Author = {I.Lobato and S.Van Aert and J.Verbeeck},
+ Journal = {Ultramicroscopy},
+ Title = {Progress and new advances in simulating electron microscopy datasets using MULTEM},
+ Year = {2016},
+ volume = {168},
+ pages = {17-27}
+ }
+
+ @article{LD15_2,
+ Author = {I. Lobato and D. Van Dyck},
+ Journal = {Ultramicroscopy},
+ Title = {MULTEM: A new multislice program to perform accurate and fast electron diffraction and imaging simulations using Graphics Processing Units with CUDA},
+ Year = {2015},
+ volume = {156},
+ pages = {9-17}
+ }
+ ```
+**if you use our parameterization of the electronscattering factors, please cite the following article:**
+```bibtex
+ @Article{LD14_1,
+ Title = {{An accurate parameterization for the scattering factors, electron densities and electrostatic potentials for neutral atoms that obey all physical constraints}},
+ Author = {I. Lobato and D. Van Dyck},
+ Journal = {Acta Crystallographica Section A},
+ Year = {2014},
+ Pages = {636-649},
+ Volume = {70}
+ }
```
\ No newline at end of file
diff --git a/compile_mex_multem.m b/compile_mex_multem.m
old mode 100644
new mode 100755
index d660dfde..3f479606
--- a/compile_mex_multem.m
+++ b/compile_mex_multem.m
@@ -1,44 +1,66 @@
-clc; clear all;
-addpath('matlab_functions')
-
-files = {
- 'mex_lambda',...
- 'mex_sigma',...
- 'mex_gamma',...
- 'mex_fxeg_data',...
- 'mex_feg',...
- 'mex_fxg',...
- 'mex_pr',...
- 'mex_vz',...
- 'mex_vr',...
- 'mex_vp',...
- 'mex_gmax',...
- 'mex_min_spl',...
- 'mex_mrad_2_rAng',...
- 'mex_mrad_2_sigma',...
- 'mex_fwhm_2_sigma',...
- 'mex_hwhm_2_sigma',...
- 'mex_iehwgd_2_sigma',...
- 'mex_scherzer_defocus',...
- 'mex_scherzer_aperture',...
- 'mex_crystal_by_lays',...
- 'mex_rdf_3d',...
- 'mex_amorp_spec',...
- 'mex_add_amorp_lay',...
- 'mex_spec_rot',...
- 'mex_spec_planes',...
- 'mex_spec_slicing',...
- 'mex_incident_wave',...
- 'mex_propagate',...
- 'mex_microscope_aberrations',...
- 'mex_projected_potential',...
- 'mex_transmission_function',...
- 'mex_multem',...
- 'mex_wave_function',...
- 'mex_apply_ctf'
- };
-
-for file=files
- disp(['Compiling ' file{1}])
- run(['mex_files_multem/',file{1}])
+% Copyright 2021 Ivan Lobato
+clear;clc;
+
+addpath([ pwd '/matlab_functions'])
+
+if 0
+ files = {'mex_spec_planes', ...
+ 'mex_spec_slicing', ...
+ 'mex_incident_wave', ...
+ 'mex_propagate', ...
+ 'mex_microscope_aberrations', ...
+ 'mex_projected_potential', ...
+ 'mex_transmission_function', ...
+ 'mex_wave_function', ...
+ 'mex_multem'};
+else
+ files = {'mex_lambda', ...
+ 'mex_gamma', ...
+ 'mex_elec_interact_parm', ...
+ 'mex_transf_exp_factor', ...
+ 'mex_rangs_2_mrad', ...
+ 'mex_mrad_2_rangs', ...
+ 'mex_mrad_2_sigma', ...
+ 'mex_fwhm_2_sigma', ...
+ 'mex_hwhm_2_sigma', ...
+ 'mex_iehwgd_2_sigma', ...
+ 'mex_scherzer_defocus', ...
+ 'mex_scherzer_aperture', ...
+ 'mex_g_max', ...
+ 'mex_det_min_spl', ...
+ 'mex_rdf', ...
+ 'mex_min_dist', ...
+ 'mex_max_dist', ...
+ 'mex_atomic_radius', ...
+ 'mex_atomic_info', ...
+ 'mex_feg', ...
+ 'mex_fxg', ...
+ 'mex_pr', ...
+ 'mex_vz', ...
+ 'mex_vr', ...
+ 'mex_vzp', ...
+ 'mex_fxeg_data', ...
+ 'mex_xtl_csn_2_sgr', ...
+ 'mex_xtl_css_2_csn', ...
+ 'mex_xtl_css_2_sgr', ...
+ 'mex_xtl_sgn_2_csn', ...
+ 'mex_xtl_build_base', ...
+ 'mex_xtl_build', ...
+ 'mex_amorp_build', ...
+ 'mex_amorp_lay_add', ...
+ 'mex_spec_rot', ...
+ 'mex_spec_planes', ...
+ 'mex_spec_slicing', ...
+ 'mex_incident_wave', ...
+ 'mex_propagate', ...
+ 'mex_microscope_aberrations', ...
+ 'mex_projected_potential', ...
+ 'mex_transmission_function', ...
+ 'mex_wave_function', ...
+ 'mex_multem'};
+end
+
+for file=files
+ disp(['Compiling ' file{1}])
+ run(['mex_files_multem/', file{1}])
end
\ No newline at end of file
diff --git a/crystalline_materials/Ag001_xtl.m b/crystalline_materials/Ag001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Ag110_xtl.m b/crystalline_materials/Ag110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Al001_xtl.m b/crystalline_materials/Al001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Al110_xtl.m b/crystalline_materials/Al110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Au001_xtl.m b/crystalline_materials/Au001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Au110_xtl.m b/crystalline_materials/Au110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Cu001_xtl.m b/crystalline_materials/Cu001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Cu110_xtl.m b/crystalline_materials/Cu110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Diamond110_xtl.m b/crystalline_materials/Diamond110_xtl.m
old mode 100644
new mode 100755
index 7f6b60d2..11fceef8
--- a/crystalline_materials/Diamond110_xtl.m
+++ b/crystalline_materials/Diamond110_xtl.m
@@ -2,22 +2,36 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 3.56/sqrt(2);
- b = 3.56;
- c = sqrt(2)*3.56/2;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 2;
+
+ xtl_parm.a = 3.56/sqrt(2);
+ xtl_parm.b = 3.56;
+ xtl_parm.c = sqrt(2)*3.56/2;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
+
% C = 6
% Z x y z rmsd_3d occupancy charge
- xtl_parm.uLayer(1).atoms = [6, 0.00, 0.00, 0.00, rmsd_3d, occ, region, charge; 6, 0.50, 0.75, 0.00, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [6, 0.00, 0.25, 0.50, rmsd_3d, occ, region, charge; 6, 0.50, 0.50, 0.50, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ xtl_parm.base = [6, 0.00, 0.00, 0.00, rmsd_3d, occ, tag, charge;...
+ 6, 0.50, 0.75, 0.00, rmsd_3d, occ, tag, charge;...
+ 6, 0.00, 0.25, 0.50, rmsd_3d, occ, tag, charge;...
+ 6, 0.50, 0.50, 0.50, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/GaAs001_xtl.m b/crystalline_materials/GaAs001_xtl.m
old mode 100644
new mode 100755
index b4464984..4ab52012
--- a/crystalline_materials/GaAs001_xtl.m
+++ b/crystalline_materials/GaAs001_xtl.m
@@ -2,25 +2,40 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 5.6537;
- b = 5.6537;
- c = 5.6537;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 4;
+
+ xtl_parm.a = 5.6537;
+ xtl_parm.b = 5.6537;
+ xtl_parm.c = 5.6537;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
+
% Ga = 31, As = 33;
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [31, 0.00, 0.00, 0.00, rmsd_3d, occ, region, charge; 31, 0.50, 0.50, 0.00, rmsd_3d, occ, region, charge]; %Ga
- xtl_parm.uLayer(2).atoms = [33, 0.25, 0.25, 0.25, rmsd_3d, occ, region, charge; 33, 0.75, 0.75, 0.25, rmsd_3d, occ, region, charge]; %As
- xtl_parm.uLayer(3).atoms = [31, 0.00, 0.50, 0.50, rmsd_3d, occ, region, charge; 31, 0.50, 0.00, 0.50, rmsd_3d, occ, region, charge]; %Ga
- xtl_parm.uLayer(4).atoms = [33, 0.75, 0.25, 0.75, rmsd_3d, occ, region, charge; 33, 0.25, 0.75, 0.75, rmsd_3d, occ, region, charge]; %As
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [31, 0.00, 0.00, 0.00, rmsd_3d, occ, tag, charge;...
+ 31, 0.50, 0.50, 0.00, rmsd_3d, occ, tag, charge;...
+ 33, 0.25, 0.25, 0.25, rmsd_3d, occ, tag, charge;...
+ 33, 0.75, 0.75, 0.25, rmsd_3d, occ, tag, charge;...
+ 31, 0.00, 0.50, 0.50, rmsd_3d, occ, tag, charge;...
+ 31, 0.50, 0.00, 0.50, rmsd_3d, occ, tag, charge;...
+ 33, 0.75, 0.25, 0.75, rmsd_3d, occ, tag, charge;...
+ 33, 0.25, 0.75, 0.75, rmsd_3d, occ, tag, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/Ir001_xtl.m b/crystalline_materials/Ir001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Ir110_xtl.m b/crystalline_materials/Ir110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/LaAlO3001_xtl.m b/crystalline_materials/LaAlO3001_xtl.m
old mode 100644
new mode 100755
index 351728d3..5abb441c
--- a/crystalline_materials/LaAlO3001_xtl.m
+++ b/crystalline_materials/LaAlO3001_xtl.m
@@ -2,23 +2,38 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 3.7900;
- b = 3.79;
- c = 3.79;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 2;
+
+ xtl_parm.a = 3.79;
+ xtl_parm.b = 3.79;
+ xtl_parm.c = 3.79;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Sr = 38, Ti = 22; O = 8
- % La = 57, Al = 13; O = 8
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [57, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge; 8, 0.5, 0.5, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [8, 0.0, 0.5, 0.5, rmsd_3d, occ, region, charge; 8, 0.5, 0.0, 0.5, rmsd_3d, occ, region, charge; 13, 0.5, 0.5, 0.5, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+
+ % Sr = 38, Ti = 22;O = 8
+ % La = 57, Al = 13;O = 8
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [57, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ 8, 0.5, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ 8, 0.0, 0.5, 0.5, rmsd_3d, occ, tag, charge;...
+ 8, 0.5, 0.0, 0.5, rmsd_3d, occ, tag, charge;...
+ 13, 0.5, 0.5, 0.5, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/Mo001_xtl.m b/crystalline_materials/Mo001_xtl.m
old mode 100644
new mode 100755
index 9244c9a9..1160ffa0
--- a/crystalline_materials/Mo001_xtl.m
+++ b/crystalline_materials/Mo001_xtl.m
@@ -1,23 +1,10 @@
function [atoms, lx, ly, lz, a, b, c, dz] = Mo001_xtl(na, nb, nc, ncu, rmsd_3d)
- xtl_parm.na = na;
- xtl_parm.nb = nb;
- xtl_parm.nc = nc;
- a = 3.1470;
- b = 3.1470;
- c = 3.1470;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 2;
- occ = 1;
- region = 0;
- charge = 0;
- % Mo = 42
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [42, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [42, 0.5, 0.5, 0.5, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
-
- dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ if(nargin<5)
+ rmsd_3d = 0.085;
+ end
+
+ Z = ilm_Z('Mo');
+ a = 3.147;
+
+ [atoms, lx, ly, lz, a, b, c, dz] = bcc001_xtl(Z, a, na, nb, nc, ncu, rmsd_3d);
end
\ No newline at end of file
diff --git a/crystalline_materials/Ni001_xtl.m b/crystalline_materials/Ni001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Ni110_xtl.m b/crystalline_materials/Ni110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Pb001_xtl.m b/crystalline_materials/Pb001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Pb110_xtl.m b/crystalline_materials/Pb110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Pd001_xtl.m b/crystalline_materials/Pd001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Pd110_xtl.m b/crystalline_materials/Pd110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/PdH001_xtl.m b/crystalline_materials/PdH001_xtl.m
old mode 100644
new mode 100755
index ae70da44..4f4f2b02
--- a/crystalline_materials/PdH001_xtl.m
+++ b/crystalline_materials/PdH001_xtl.m
@@ -2,24 +2,40 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 4.025;
- b = 4.025;
- c = 4.025;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 2;
+
+ xtl_parm.a = 4.025;
+ xtl_parm.b = 4.025;
+ xtl_parm.c = 4.025;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
+
% Pd = 46, H = 1
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [46, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge; 46, 0.5, 0.5, 0.0, rmsd_3d, occ, region, charge;...
- 1, 0.5, 0.0, 0.0, rmsd_3d, occ, region, charge; 1, 0.0, 0.5, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [46, 0.0, 0.5, 0.5, rmsd_3d, occ, region, charge; 46, 0.5, 0.0, 0.5, rmsd_3d, occ, region, charge;...
- 1, 0.0, 0.0, 0.5, rmsd_3d, occ, region, charge; 1, 0.5, 0.5, 0.5, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [46, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ 46, 0.5, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ 1, 0.5, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ 1, 0.0, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ 46, 0.0, 0.5, 0.5, rmsd_3d, occ, tag, charge;...
+ 46, 0.5, 0.0, 0.5, rmsd_3d, occ, tag, charge;...
+ 1, 0.0, 0.0, 0.5, rmsd_3d, occ, tag, charge;...
+ 1, 0.5, 0.5, 0.5, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/Primitive_xtl.m b/crystalline_materials/Primitive_xtl.m
old mode 100644
new mode 100755
index 8e7244b0..ba415155
--- a/crystalline_materials/Primitive_xtl.m
+++ b/crystalline_materials/Primitive_xtl.m
@@ -2,23 +2,31 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 4.0780;
- b = 4.0780;
- c = 4.0780;
- a = 6.50;
- b = 6.50;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 1;
+
+ xtl_parm.a = 4.0780;
+ xtl_parm.b = 4.0780;
+ xtl_parm.c = 4.0780;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Au = 79
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [79, 0.5, 0.5, 0.0, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [79, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge];
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/Pt001_xtl.m b/crystalline_materials/Pt001_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Pt110_xtl.m b/crystalline_materials/Pt110_xtl.m
old mode 100644
new mode 100755
diff --git a/crystalline_materials/Si001_xtl.m b/crystalline_materials/Si001_xtl.m
old mode 100644
new mode 100755
index 30d41445..57c2b1e2
--- a/crystalline_materials/Si001_xtl.m
+++ b/crystalline_materials/Si001_xtl.m
@@ -2,24 +2,40 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 5.4307;
- b = 5.4307;
- c = 5.4307;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 4;
+
+ xtl_parm.a = 5.4307;
+ xtl_parm.b = 5.4307;
+ xtl_parm.c = 5.4307;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
+
% Si = 14
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [14, 0.00, 0.00, 0.00, rmsd_3d, occ, region, charge; 14, 0.50, 0.50, 0.00, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [14, 0.25, 0.25, 0.25, rmsd_3d, occ, region, charge; 14, 0.75, 0.75, 0.25, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(3).atoms = [14, 0.00, 0.50, 0.50, rmsd_3d, occ, region, charge; 14, 0.50, 0.00, 0.50, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(4).atoms = [14, 0.25, 0.75, 0.75, rmsd_3d, occ, region, charge; 14, 0.75, 0.25, 0.75, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [14, 0.00, 0.00, 0.00, rmsd_3d, occ, tag, charge;...
+ 14, 0.50, 0.50, 0.00, rmsd_3d, occ, tag, charge;...
+ 14, 0.25, 0.25, 0.25, rmsd_3d, occ, tag, charge;...
+ 14, 0.75, 0.75, 0.25, rmsd_3d, occ, tag, charge;...
+ 14, 0.00, 0.50, 0.50, rmsd_3d, occ, tag, charge;...
+ 14, 0.50, 0.00, 0.50, rmsd_3d, occ, tag, charge;...
+ 14, 0.25, 0.75, 0.75, rmsd_3d, occ, tag, charge;...
+ 14, 0.75, 0.25, 0.75, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/Si110_xtl.m b/crystalline_materials/Si110_xtl.m
old mode 100644
new mode 100755
index eb141581..34268964
--- a/crystalline_materials/Si110_xtl.m
+++ b/crystalline_materials/Si110_xtl.m
@@ -2,22 +2,36 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 5.4307/sqrt(2);
- b = 5.4307;
- c = sqrt(2)*5.4307/2;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 2;
+
+ xtl_parm.a = 5.4307/sqrt(2);
+ xtl_parm.b = 5.4307;
+ xtl_parm.c = sqrt(2)*5.4307/2;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
+
% Si = 14
% Z x y z rmsd_3d occupancy charge
- xtl_parm.uLayer(1).atoms = [14, 0.00, 0.00, 0.00, rmsd_3d, occ, region, charge; 14, 0.50, 0.75, 0.00, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [14, 0.00, 0.25, 0.50, rmsd_3d, occ, region, charge; 14, 0.50, 0.50, 0.50, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ xtl_parm.base = [14, 0.00, 0.00, 0.00, rmsd_3d, occ, tag, charge;...
+ 14, 0.50, 0.75, 0.00, rmsd_3d, occ, tag, charge;...
+ 14, 0.00, 0.25, 0.50, rmsd_3d, occ, tag, charge;...
+ 14, 0.50, 0.50, 0.50, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/SrTiO3001_xtl.m b/crystalline_materials/SrTiO3001_xtl.m
old mode 100644
new mode 100755
index ac1fc33b..319d5e7c
--- a/crystalline_materials/SrTiO3001_xtl.m
+++ b/crystalline_materials/SrTiO3001_xtl.m
@@ -2,22 +2,37 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 3.9050;
- b = 3.9050;
- c = 3.9050;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 2;
+
+ xtl_parm.a = 3.9050;
+ xtl_parm.b = 3.9050;
+ xtl_parm.c = 3.9050;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Sr = 38, Ti = 22; O = 8
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [38, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge; 8, 0.5, 0.5, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [8, 0.0, 0.5, 0.5, rmsd_3d, occ, region, charge; 8, 0.5, 0.0, 0.5, rmsd_3d, occ, region, charge; 22, 0.5, 0.5, 0.5, rmsd_3d, occ, region, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+
+ % Sr = 38, Ti = 22;O = 8
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [38, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ 8, 0.5, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ 8, 0.0, 0.5, 0.5, rmsd_3d, occ, tag, charge;...
+ 8, 0.5, 0.0, 0.5, rmsd_3d, occ, tag, charge;...
+ 22, 0.5, 0.5, 0.5, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/SrTiO3110_xtl.m b/crystalline_materials/SrTiO3110_xtl.m
old mode 100644
new mode 100755
index 87cbff1b..1d356e6f
--- a/crystalline_materials/SrTiO3110_xtl.m
+++ b/crystalline_materials/SrTiO3110_xtl.m
@@ -2,25 +2,42 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 3.9050;
- b = 3.9050*sqrt(2);
- c = 3.9050*sqrt(2);
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 4;
+
+ xtl_parm.a = 3.9050;
+ xtl_parm.b = 3.9050*sqrt(2);
+ xtl_parm.c = 3.9050*sqrt(2);
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Sr = 38, Ti = 22; O = 8
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [38, 0.50, 0.00, 0.00, rmsd_3d, occ, region, charge; 8, 0.50, 0.50, 0.00, rmsd_3d, occ, region, charge; 22, 0.0, 0.5, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [8, 0.00, 0.25, 0.25, rmsd_3d, occ, region, charge; 8, 0.00, 0.75, 0.25, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(3).atoms = [8, 0.50, 0.00, 0.50, rmsd_3d, occ, region, charge; 38, 0.50, 0.50, 0.50, rmsd_3d, occ, region, charge; 22, 0.00, 0.00, 0.50, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(4).atoms = [8, 0.00, 0.25, 0.75, rmsd_3d, occ, region, charge; 8, 0.00, 0.75, 0.75, rmsd_3d, occ, region, charge];
+
+ % Sr = 38, Ti = 22;O = 8
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [38, 0.50, 0.00, 0.00, rmsd_3d, occ, tag, charge;...
+ 8, 0.50, 0.50, 0.00, rmsd_3d, occ, tag, charge;...
+ 22, 0.0, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ 8, 0.00, 0.25, 0.25, rmsd_3d, occ, tag, charge...
+ 8, 0.00, 0.75, 0.25, rmsd_3d, occ, tag, charge;...
+ 8, 0.50, 0.00, 0.50, rmsd_3d, occ, tag, charge;...
+ 38, 0.50, 0.50, 0.50, rmsd_3d, occ, tag, charge;...
+ 22, 0.00, 0.00, 0.50, rmsd_3d, occ, tag, charge;...
+ 8, 0.00, 0.25, 0.75, rmsd_3d, occ, tag, charge;...
+ 8, 0.00, 0.75, 0.75, rmsd_3d, occ, tag, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/YH2001_xtl.m b/crystalline_materials/YH2001_xtl.m
old mode 100644
new mode 100755
index 29a92129..eb99b08c
--- a/crystalline_materials/YH2001_xtl.m
+++ b/crystalline_materials/YH2001_xtl.m
@@ -2,25 +2,44 @@
xtl_parm.na = na;
xtl_parm.nb = nb;
xtl_parm.nc = nc;
- a = 5.2000;
- b = 5.2000;
- c = 5.2000;
- xtl_parm.a = a;
- xtl_parm.b = b;
- xtl_parm.c = c;
- xtl_parm.nuLayer = 4;
+
+ xtl_parm.a = 5.2000;
+ xtl_parm.b = 5.2000;
+ xtl_parm.c = 5.2000;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Au = 79
+
+ %H = 1, Y = 39
% Z x y z rmsd_3d occupancy charge
- xtl_parm.uLayer(1).atoms = [39, 0.0, 0.0, 0.0, rmsd_3d_Y, occ, region, charge; 39, 0.5, 0.5, 0.0, rmsd_3d_Y, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [1, 0.25, 0.25, 0.25, rmsd_3d_H, occ, region, charge; 1, 0.75, 0.25, 0.25, rmsd_3d_H, occ, region, charge; 1, 0.25, 0.75, 0.25, rmsd_3d_H, occ, region, charge; 1, 0.75, 0.75, 0.25, rmsd_3d_H, occ, region, charge];
- xtl_parm.uLayer(3).atoms = [39, 0.0, 0.5, 0.5, rmsd_3d_Y, occ, region, charge; 39, 0.5, 0.0, 0.5, rmsd_3d_Y, occ, region, charge];
- xtl_parm.uLayer(4).atoms = [1, 0.25, 0.25, 0.75, rmsd_3d_H, occ, region, charge; 1, 0.75, 0.25, 0.75, rmsd_3d_H, occ, region, charge; 1, 0.25, 0.75, 0.75, rmsd_3d_H, occ, region, charge; 1, 0.75, 0.75, 0.75, rmsd_3d_H, occ, region, charge];
+ xtl_parm.base = [39, 0.0, 0.0, 0.0, rmsd_3d_Y, occ, tag, charge;...
+ 39, 0.5, 0.5, 0.0, rmsd_3d_Y, occ, tag, charge;...
+ 1, 0.25, 0.25, 0.25, rmsd_3d_H, occ, tag, charge;...
+ 1, 0.75, 0.25, 0.25, rmsd_3d_H, occ, tag, charge;...
+ 1, 0.25, 0.75, 0.25, rmsd_3d_H, occ, tag, charge;...
+ 1, 0.75, 0.75, 0.25, rmsd_3d_H, occ, tag, charge;...
+ 39, 0.0, 0.5, 0.5, rmsd_3d_Y, occ, tag, charge;...
+ 39, 0.5, 0.0, 0.5, rmsd_3d_Y, occ, tag, charge;...
+ 1, 0.25, 0.25, 0.75, rmsd_3d_H, occ, tag, charge;...
+ 1, 0.75, 0.25, 0.75, rmsd_3d_H, occ, tag, charge;...
+ 1, 0.25, 0.75, 0.75, rmsd_3d_H, occ, tag, charge;...
+ 1, 0.75, 0.75, 0.75, rmsd_3d_H, occ, tag, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
- lx = na*xtl_parm.a; ly = nb*xtl_parm.b; lz = nc*xtl_parm.c;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/bcc001_xtl.m b/crystalline_materials/bcc001_xtl.m
new file mode 100755
index 00000000..3646b9c0
--- /dev/null
+++ b/crystalline_materials/bcc001_xtl.m
@@ -0,0 +1,34 @@
+function [atoms, lx, ly, lz, a, b, c, dz] = bcc001_xtl(Z, l_c, na, nb, nc, ncu, rmsd_3d)
+ xtl_parm.na = na;
+ xtl_parm.nb = nb;
+ xtl_parm.nc = nc;
+
+ xtl_parm.a = l_c;
+ xtl_parm.b = l_c;
+ xtl_parm.c = l_c;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
+ occ = 1;
+ tag = 0;
+ charge = 0;
+
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [Z, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ Z, 0.5, 0.5, 0.5, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
+
+ dz = xtl_parm.c/ncu;
+ lx = na*xtl_parm.a;ly = nb*xtl_parm.b;lz = nc*xtl_parm.c;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
+end
\ No newline at end of file
diff --git a/crystalline_materials/fcc001_xtl.m b/crystalline_materials/fcc001_xtl.m
old mode 100644
new mode 100755
index ecb0106a..74a449b5
--- a/crystalline_materials/fcc001_xtl.m
+++ b/crystalline_materials/fcc001_xtl.m
@@ -11,18 +11,22 @@
xtl_parm.beta = 90;
xtl_parm.gamma = 90;
- xtl_parm.nuLayer = 2;
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [Z, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge; Z, 0.5, 0.5, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [Z, 0.0, 0.5, 0.5, rmsd_3d, occ, region, charge; Z, 0.5, 0.0, 0.5, rmsd_3d, occ, region, charge];
-
- atoms = ilc_crystal_by_lays(xtl_parm);
-
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [Z, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ Z, 0.5, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ Z, 0.0, 0.5, 0.5, rmsd_3d, occ, tag, charge;...
+ Z, 0.5, 0.0, 0.5, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
+
dz = xtl_parm.c/ncu;
lx = na*xtl_parm.a;
diff --git a/crystalline_materials/fcc110_xtl.m b/crystalline_materials/fcc110_xtl.m
old mode 100644
new mode 100755
index 4eeb5e7f..6677014e
--- a/crystalline_materials/fcc110_xtl.m
+++ b/crystalline_materials/fcc110_xtl.m
@@ -11,17 +11,19 @@
xtl_parm.beta = 90;
xtl_parm.gamma = 90;
- xtl_parm.nuLayer = 2;
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [Z, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge];
- xtl_parm.uLayer(2).atoms = [Z, 0.5, 0.5, 0.5, rmsd_3d, occ, region, charge];
-
- atoms = ilc_crystal_by_lays(xtl_parm);
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [Z, 0.00, 0.00, 0.00, rmsd_3d, occ, tag, charge;...
+ Z, 0.50, 0.50, 0.50, rmsd_3d, occ, tag, charge];
+
+ atoms = ilc_xtl_build(xtl_parm);
dz = xtl_parm.c/ncu;
diff --git a/crystalline_materials/graphene.m b/crystalline_materials/graphene.m
old mode 100644
new mode 100755
index 7d9ce193..289cc43d
--- a/crystalline_materials/graphene.m
+++ b/crystalline_materials/graphene.m
@@ -1,21 +1,37 @@
-function [atoms, lx, ly, lz] = graphene(n, a, rms)
+function [atoms, lx, ly, lz, a, b, c] = graphene(n, da, rms)
+ xtl_parm.a = 3*da;
+ xtl_parm.b = sqrt(3)*da;
+ xtl_parm.c = 2.0;
+
+ xtl_parm.alpha = 90;
+ xtl_parm.beta = 90;
+ xtl_parm.gamma = 90;
+
xtl_parm.na = n;
- xtl_parm.nb = round(3*n/sqrt(3));
+ xtl_parm.nb = round(n*xtl_parm.a/xtl_parm.b);
xtl_parm.nc = 0;
- xtl_parm.a = 3*a;
- xtl_parm.b = sqrt(3)*a;
- xtl_parm.c = 2;
- xtl_parm.nuLayer = 1;
+
+ xtl_parm.sgn = 1;
+ xtl_parm.pbc = false;
+ xtl_parm.asym_uc = [];
+
occ = 1;
- region = 0;
+ tag = 0;
charge = 0;
+
% C = 6
- % Z x y z rmsd_3d occupancy region charge
- xtl_parm.uLayer(1).atoms = [6, 0.0, 0.0, 0.0, rms, occ, region, charge;...
- 6, 1/3, 0.0, 0.0, rms, occ, region, charge; 6, 1/2, 1/2, 0.0, rms, occ, region, charge; 6, 5/6, 1/2, 0.0, rms, occ, region, charge];
+ % Z x y z rmsd_3d occupancy tag charge
+ xtl_parm.base = [6, 0.0, 0.0, 0.0, rms, occ, tag, charge;...
+ 6, 1/3, 0.0, 0.0, rms, occ, tag, charge;...
+ 6, 1/2, 1/2, 0.0, rms, occ, tag, charge;...
+ 6, 5/6, 1/2, 0.0, rms, occ, tag, charge];
- atoms = ilc_crystal_by_lays(xtl_parm);
+ atoms = ilc_xtl_build(xtl_parm);
lx = xtl_parm.a*xtl_parm.na;
ly = xtl_parm.b*xtl_parm.nb;
lz = 0.0;
+
+ a = xtl_parm.a;
+ b = xtl_parm.b;
+ c = xtl_parm.c;
end
\ No newline at end of file
diff --git a/crystalline_materials/readme.txt b/crystalline_materials/readme.txt
new file mode 100755
index 00000000..26e1c36f
--- /dev/null
+++ b/crystalline_materials/readme.txt
@@ -0,0 +1,2 @@
+Check out the following website to obtained the lattice parameters:
+http://periodictable.com/Properties/A/LatticeConstants.html
\ No newline at end of file
diff --git a/gui_multem/images/Pause.png b/gui_multem/images/Pause.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/copy.png b/gui_multem/images/copy.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/cross.png b/gui_multem/images/cross.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/cross_pointer.png b/gui_multem/images/cross_pointer.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/cut.png b/gui_multem/images/cut.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/default.png b/gui_multem/images/default.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/new.png b/gui_multem/images/new.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/open.png b/gui_multem/images/open.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/opt.png b/gui_multem/images/opt.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/paste.png b/gui_multem/images/paste.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/print.png b/gui_multem/images/print.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/save.png b/gui_multem/images/save.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/splash_screen.png b/gui_multem/images/splash_screen.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/start.png b/gui_multem/images/start.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/stop.png b/gui_multem/images/stop.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/undo.png b/gui_multem/images/undo.png
old mode 100644
new mode 100755
diff --git a/gui_multem/images/view.png b/gui_multem/images/view.png
old mode 100644
new mode 100755
diff --git a/gui_multem/main.cpp b/gui_multem/main.cpp
old mode 100644
new mode 100755
diff --git a/gui_multem/mainwindow.cpp b/gui_multem/mainwindow.cpp
old mode 100644
new mode 100755
index 268edc97..df95612c
--- a/gui_multem/mainwindow.cpp
+++ b/gui_multem/mainwindow.cpp
@@ -2,10 +2,10 @@
#include "memory_info.cuh"
#include "lin_alg_def.cuh"
#include "atomic_data.hpp"
-#include "atomic_data_mt.hpp"
+#include "atom_data.hpp"
#include "input_multislice.cuh"
#include "output_multislice.hpp"
-#include "tem_simulation.cuh"
+#include "multislice.cuh"
#include "multem.cu"
#include
@@ -24,7 +24,7 @@ MainWindow::MainWindow(): central_widget(new QLabel)
pb_timer = new PB_Timer(this);
- // set seed to generate cgpu_rand numbers
+ // set seed to generate random numbers
qsrand(QTime::currentTime().msec());
setWindowTitle(tr("MULTEM"));
@@ -2980,7 +2980,7 @@ void MainWindow::create_general_dock_widget()
/*******************************************************/
ckb_pn_auto_seed = new QCheckBox(tr("auto"));
- ckb_pn_auto_seed->setStatusTip(tr("Automatic cgpu_rand seed"));
+ ckb_pn_auto_seed->setStatusTip(tr("Automatic random seed"));
/*******************************************************/
auto lyg_frozen_phonon = new QGridLayout;
diff --git a/gui_multem/mainwindow.h b/gui_multem/mainwindow.h
old mode 100644
new mode 100755
diff --git a/gui_multem/multem.cu b/gui_multem/multem.cu
old mode 100644
new mode 100755
index e5838a92..293f7049
--- a/gui_multem/multem.cu
+++ b/gui_multem/multem.cu
@@ -1,6 +1,6 @@
/*
* This file is part of MULTEM.
- * Copyright 2020 Ivan Lobato
+ * Copyright 2017 Ivan Lobato
*
* MULTEM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
#include "stream.cuh"
#include "input_multislice.cuh"
#include "output_multislice.hpp"
-#include "tem_simulation.cuh"
+#include "multislice.cuh"
template
void mt_run_multislice(mt::System_Configuration &system_conf,
@@ -43,9 +43,9 @@ void mt_run_multislice(mt::System_Configuration &system_conf,
{
mt::Multislice::ext_stop_sim = false;
- mt::Multislice tem_simulation;
- tem_simulation.set_input_data(&input_multislice, &stream, &fft_2d);
- tem_simulation(output_multislice);
+ mt::Multislice multislice;
+ multislice.set_input_data(&input_multislice, &stream, &fft_2d);
+ multislice(output_multislice);
}
stream.synchronize();
diff --git a/gui_multem/multem.cuh b/gui_multem/multem.cuh
old mode 100644
new mode 100755
index ab4cd76f..35682de8
--- a/gui_multem/multem.cuh
+++ b/gui_multem/multem.cuh
@@ -1,6 +1,6 @@
/*
* This file is part of MULTEM.
- * Copyright 2020 Ivan Lobato
+ * Copyright 2017 Ivan Lobato
*
* MULTEM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
#include "stream.cuh"
#include "input_multislice.cuh"
#include "output_multislice.hpp"
-#include "tem_simulation.cuh"
+#include "multislice.cuh"
template
void run_multislice(mt::System_Configuration &system_conf,
@@ -39,9 +39,9 @@ void run_multislice(mt::System_Configuration &system_conf,
mt::FFT fft_2d;
fft_2d.create_plan_2d(input_multislice.grid_2d.ny, input_multislice.grid_2d.nx, system_conf.nstream);
- mt::Multislice tem_simulation;
- tem_simulation.set_input_data(&input_multislice, &stream, &fft_2d);
- tem_simulation(output_multislice);
+ mt::Multislice multislice;
+ multislice.set_input_data(&input_multislice, &stream, &fft_2d);
+ multislice(output_multislice);
stream.synchronize();
fft_2d.cleanup();
diff --git a/gui_multem/multem.pro b/gui_multem/multem.pro
old mode 100644
new mode 100755
diff --git a/gui_multem/multem.pro.user b/gui_multem/multem.pro.user
old mode 100644
new mode 100755
diff --git a/gui_multem/multem.qrc b/gui_multem/multem.qrc
old mode 100644
new mode 100755
diff --git a/gui_multem/q_colormap.h b/gui_multem/q_colormap.h
old mode 100644
new mode 100755
diff --git a/gui_multem/q_data_viewer.h b/gui_multem/q_data_viewer.h
old mode 100644
new mode 100755
diff --git a/gui_multem/q_image.h b/gui_multem/q_image.h
old mode 100644
new mode 100755
diff --git a/gui_multem/q_load_specimen.h b/gui_multem/q_load_specimen.h
old mode 100644
new mode 100755
diff --git a/gui_multem/q_types.h b/gui_multem/q_types.h
old mode 100644
new mode 100755
diff --git a/gui_multem/q_widget.cpp b/gui_multem/q_widget.cpp
old mode 100644
new mode 100755
diff --git a/gui_multem/q_widget.h b/gui_multem/q_widget.h
old mode 100644
new mode 100755
diff --git a/matlab_functions/+multem_input/detector.m b/matlab_functions/+multem_input/detector.m
deleted file mode 100644
index c951a58c..00000000
--- a/matlab_functions/+multem_input/detector.m
+++ /dev/null
@@ -1,11 +0,0 @@
-classdef detector
-% Detector object for Multem Input
- properties
- % STEM Detector
- % detector_type: eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
- type(1,1) uint64 {mustBeLessThanOrEqual(type,3),mustBePositive} = 1;
- cir = struct('inner_ang', 60, 'outer_ang', 180); % Inner & Outer angle(mrad)
- radial = struct('x', 0, 'fx', 0); % radial detector angle(mrad) & radial sensitivity value
- matrix = struct('R', 0, 'fR', 0); % 2D detector angle(mrad) & 2D sensitivity value
- end
-end
\ No newline at end of file
diff --git a/matlab_functions/+multem_input/parameters.m b/matlab_functions/+multem_input/parameters.m
deleted file mode 100644
index f21fd5cc..00000000
--- a/matlab_functions/+multem_input/parameters.m
+++ /dev/null
@@ -1,305 +0,0 @@
-classdef parameters
- % Default input class for multem
- % Contains short descriptions of all parameters and a function to
- % execute the simulation
-
- properties
- system_conf = multem_input.system_conf; % System Configuration
-
- %%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-
- interaction_model(1,1) uint64 {mustBeLessThanOrEqual(interaction_model,3),mustBePositive} = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
- potential_type(1,1) uint64 {mustBeLessThanOrEqual(potential_type,6),mustBePositive} = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
- operation_mode(1,1) uint64 {mustBeLessThanOrEqual(operation_mode,2),mustBePositive} = 1; % eOM_Normal = 1, eOM_Advanced = 2
- memory_size(1,1) uint64 {mustBeNonnegative} = 0; % memory size to be used(Mb)
- reverse_multislice(1,1) uint64 {mustBeLessThanOrEqual(reverse_multislice,1),mustBeNonnegative} = 0; % 1: true, 0:false
-
- %%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-
- pn_model(1,1) uint64 {mustBeLessThanOrEqual(pn_model,3),mustBePositive} = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
- pn_coh_contrib(1,1) uint64 {mustBeLessThanOrEqual(pn_coh_contrib,1),mustBeNonnegative} = 0; % 1: true, 0:false
- pn_single_conf(1,1) uint64 {mustBeLessThanOrEqual(pn_single_conf,1),mustBeNonnegative} = 0; % 1: true, 0:false (extract single configuration)
- pn_nconf(1,1) uint64 {mustBePositive} = 1; % true: specific phonon configuration, false: number of frozen phonon configurations
- pn_dim(1,1) uint64 {mustBePositive} = 110; % phonon dimensions (xyz)
- pn_seed(1,1) uint64 {mustBePositive} = 300183; % Random seed(frozen phonon)
- %%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-
- spec_atoms = []; % Specimen atoms
- spec_dz(1,1) double {mustBeNonnegative} = 0.25; % slice thick (Angstrom)
-
- spec_lx(1,1) double {mustBeNonnegative} = 10; % simulation box length in x direction (Angstrom)
- spec_ly(1,1) double {mustBeNonnegative} = 10; % simulation box length in y direction (Angstrom)
- spec_lz(1,1) double {mustBeNonnegative} = 10; % simulation box length gpuDEin z direction (Angstrom)
-
- spec_cryst_na(1,1) uint64 {mustBeNonnegative} = 1; % number of unit cell along a
- spec_cryst_nb(1,1) uint64 {mustBeNonnegative} = 1; % number of unit cell along b
- spec_cryst_nc(1,1) uint64 {mustBeNonnegative} = 1; % number of unit cell along c
- spec_cryst_a(1,1) double {mustBeNonnegative} = 0; % length along a (Angstrom)
- spec_cryst_b(1,1) double {mustBeNonnegative} = 0; % length along b (Angstrom)
- spec_cryst_c(1,1) double {mustBeNonnegative} = 0; % length along c (Angstrom)
- spec_cryst_x0(1,1) double = 0; % reference position along x direction (Angstrom)
- spec_cryst_y0(1,1) double = 0; % reference position along y direction (Angstrom)
-
- spec_amorp = struct('z_0', 0, 'z_e', 0, 'dz', 2.0); % Include slice of amorphous layer
- %%%%%%%%%%%%%%%%%%%%%%%%% Specimen Rotation %%%%%%%%%%%%%%%%%%%%%%%%
-
- spec_rot_theta(1,1) double {mustBeNonnegative} = 0; % angle (Degree)
- spec_rot_u0(3,1) double {mustBeNonnegative} = [0 0 1]; % unitary vector
- spec_rot_center_type(1,1) uint64 {mustBeLessThanOrEqual(spec_rot_center_type,2),mustBePositive} = 1; % 1: geometric center, 2: User define
- spec_rot_center_p(3,1) double {mustBeNonnegative} = [0 0 0]; % rotation point
- %%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-
- thick_type(1,1) uint64 {mustBeLessThanOrEqual(thick_type,3),mustBePositive} = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
- thick = 0; % Array of thickness (Angstrom)
- %%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-
- potential_slicing(1,1) uint64 {mustBeLessThanOrEqual(potential_slicing,4),mustBePositive} = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
- islice uint64 % retrieve the projected potential at given slices
- %%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- nx(1,1) double {mustBePositive} = 256; % number of pixels in x direction
- ny(1,1) double {mustBePositive} = 256; % number of pixels in y direction
- bwl(1,1) uint64 {mustBeLessThanOrEqual(bwl,1),mustBeNonnegative} = 0; % Band-width limit, 1: true, 0:false
-
- %%%%%%%%%%%%%%%%%%%%%%%% Simulation type %%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- % Simulation type
- % eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22,
- % eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42,
- % eTEMST_EWFS=51, eTEMST_EWRS=52, eTEMST_EELS=61, eTEMST_EFTEM=62,
- % eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,
- % eTEMST_TFFS=91, eTEMST_TFRS=92
- simulation_type(1,1) uint64 = 52; % Simulation type
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-
- iw_type(1,1) uint64 {mustBeLessThanOrEqual(iw_type,4),mustBePositive} = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
- iw_psi double = 0; % User defined incident wave. It will be only used if iw_type=3
- iw_x double = 0; % x position
- iw_y double = 0; % y position
- %%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-
- E_0(1,1) double = 300; % Acceleration Voltage (keV)
- theta(1,1) double = 0; % Polar angle (Angstrom)
- phi(1,1) double = 0; % Azimuthal angle (Angstrom)
- %%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-
- illumination_model(1,1) uint64 {mustBeLessThanOrEqual(illumination_model,4),mustBePositive} = 3; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
- temporal_spatial_incoh(1,1) uint64 {mustBeLessThanOrEqual(temporal_spatial_incoh,3),mustBePositive} = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
- %%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-
- cond_lens_m(1,1) double = 0.00; % Vortex momentum
-
- cond_lens_c_10(1,1) double = 14.0312; % [C1] Defocus (Angstrom)
- cond_lens_c_12(1,1) double = 0.00; % [A1] 2-fold astigmatism (Angstrom)
- cond_lens_phi_12(1,1) double = 0.00; % [phi_A1] Azimuthal angle of 2-fold astigmatism (Angstrom)
-
- cond_lens_c_21(1,1) double = 0.00; % [B2] Axial coma (Angstrom)
- cond_lens_phi_21(1,1) double = 0.00; % [phi_B2] Azimuthal angle of axial coma (Angstrom)
- cond_lens_c_23(1,1) double = 0.00; % [A2] 3-fold astigmatism (Angstrom)
- cond_lens_phi_23(1,1) double = 0.00; % [phi_A2] Azimuthal angle of 3-fold astigmatism (Angstrom)
-
- cond_lens_c_30(1,1) double = 1e-3; % [C3] 3rd order spherical aberration (mm)
- cond_lens_c_32(1,1) double = 0.00; % [S3] Axial star aberration (Angstrom)
- cond_lens_phi_32(1,1) double = 0.00; % [phi_S3] Azimuthal angle of axial star aberration (Angstrom)
- cond_lens_c_34(1,1) double = 0.00; % [A3] 4-fold astigmatism (Angstrom)
- cond_lens_phi_34(1,1) double = 0.00; % [phi_A3] Azimuthal angle of 4-fold astigmatism (Angstrom)
-
- cond_lens_c_41(1,1) double = 0.00; % [B4] 4th order axial coma (Angstrom)
- cond_lens_phi_41(1,1) double = 0.00; % [phi_B4] Azimuthal angle of 4th order axial coma (Angstrom)
- cond_lens_c_43(1,1) double = 0.00; % [D4] 3-lobe aberration (Angstrom)
- cond_lens_phi_43(1,1) double = 0.00; % [phi_D4] Azimuthal angle of 3-lobe aberration (Angstrom)
- cond_lens_c_45(1,1) double = 0.00; % [A4] 5-fold astigmatism (Angstrom)
- cond_lens_phi_45(1,1) double = 0.00; % [phi_A4] Azimuthal angle of 5-fold astigmatism (Angstrom)
-
- cond_lens_c_50(1,1) double = 0.00; % [C5] 5th order spherical aberration (mm)
- cond_lens_c_52(1,1) double = 0.00; % [S5] 5th order axial star aberration (Angstrom)
- cond_lens_phi_52(1,1) double = 0.00; % [phi_S5] Azimuthal angle of 5th order axial star aberration (Angstrom)
- cond_lens_c_54(1,1) double = 0.00; % [R5] 5th order rosette aberration (Angstrom)
- cond_lens_phi_54(1,1) double = 0.00; % [phi_R5] Azimuthal angle of 5th order rosette aberration (Angstrom)
- cond_lens_c_56(1,1) double = 0.00; % [A5] 6-fold astigmatism (Angstrom)
- cond_lens_phi_56(1,1) double = 0.00; % [phi_A5] Azimuthal angle of 6-fold astigmatism (Angstrom)
-
- cond_lens_inner_aper_ang(1,1) double = 0.00; % Inner aperture (mrad)
- cond_lens_outer_aper_ang(1,1) double = 21.0; % Outer aperture (mrad)
- %%%%%%%%%% source spread function %%%%%%%%%%%%
-
- cond_lens_si_a(1,1) double = 1.0 % Height proportion of a normalized Gaussian [0, 1]
- cond_lens_si_sigma(1,1) double = 0.0072; % standard deviation: For parallel ilumination(Angstrom^-1); otherwise (Angstrom)
- cond_lens_si_beta(1,1) double = 0.0; % Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
- cond_lens_si_rad_npts(1,1) uint64 = 4; % # of integration points. It will be only used if illumination_model=4
- cond_lens_si_azm_npts(1,1) uint64 = 4; % # of radial integration points. It will be only used if illumination_model=4
- %%%%%%%%% defocus spread function %%%%%%%%%%%%
-
- cond_lens_ti_a(1,1) double = 1.0; % Height proportion of a normalized Gaussian [0, 1]
- cond_lens_ti_sigma(1,1) double = 32.0; % standard deviation (Angstrom)
- cond_lens_ti_beta(1,1) double = 0.0; % Standard deviation of the defocus spread for the Exponential component
- cond_lens_ti_npts(1,1) uint64 = 10; % # of integration points. It will be only used if illumination_model=4
- %%%%%%%%% zero defocus reference %%%%%%%%%%%%
-
- cond_lens_zero_defocus_type(1,1) uint64 {mustBeLessThanOrEqual(cond_lens_zero_defocus_type,4),mustBePositive} = 1; % eZDT_First = 1, eZDT_User_Define = 4
- cond_lens_zero_defocus_plane(1,1) double = 0.00; % It will be only used if cond_lens_zero_defocus_type = eZDT_User_Define
- %%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-
- obj_lens_m(1,1) double = 0; % Vortex momentum
-
- obj_lens_c_10(1,1) double = 14.0312; % [C1] Defocus (Angstrom)
- obj_lens_c_12(1,1) double = 0.00; % [A1] 2-fold astigmatism (Angstrom)
- obj_lens_phi_12(1,1) double = 0.00; % [phi_A1] Azimuthal angle of 2-fold astigmatism (Angstrom)
-
- obj_lens_c_21(1,1) double = 0.00; % [B2] Axial coma (Angstrom)
- obj_lens_phi_21(1,1) double = 0.00; % [phi_B2] Azimuthal angle of axial coma (Angstrom)
- obj_lens_c_23(1,1) double = 0.00; % [A2] 3-fold astigmatism (Angstrom)
- obj_lens_phi_23(1,1) double = 0.00; % [phi_A2] Azimuthal angle of 3-fold astigmatism (Angstrom)
-
- obj_lens_c_30(1,1) double = 1e-03; % [C3] 3rd order spherical aberration (mm)
- obj_lens_c_32(1,1) double = 0.00; % [S3] Axial star aberration (Angstrom)
- obj_lens_phi_32(1,1) double = 0.00; % [phi_S3] Azimuthal angle of axial star aberration (Angstrom)
- obj_lens_c_34(1,1) double = 0.00; % [A3] 4-fold astigmatism (Angstrom)
- obj_lens_phi_34(1,1) double = 0.00; % [phi_A3] Azimuthal angle of 4-fold astigmatism (Angstrom)
-
- obj_lens_c_41(1,1) double = 0.00; % [B4] 4th order axial coma (Angstrom)
- obj_lens_phi_41(1,1) double = 0.00; % [phi_B4] Azimuthal angle of 4th order axial coma (Angstrom)
- obj_lens_c_43(1,1) double = 0.00; % [D4] 3-lobe aberration (Angstrom)
- obj_lens_phi_43(1,1) double = 0.00; % [phi_D4] Azimuthal angle of 3-lobe aberration (Angstrom)
- obj_lens_c_45(1,1) double = 0.00; % [A4] 5-fold astigmatism (Angstrom)
- obj_lens_phi_45(1,1) double = 0.00; % [phi_A4] Azimuthal angle of 5-fold astigmatism (Angstrom)
-
- obj_lens_c_50(1,1) double = 0.00; % [C5] 5th order spherical aberration (mm)
- obj_lens_c_52(1,1) double = 0.00; % [S5] 5th order axial star aberration (Angstrom)
- obj_lens_phi_52(1,1) double = 0.00; % [phi_S5] Azimuthal angle of 5th order axial star aberration (Angstrom)
- obj_lens_c_54(1,1) double = 0.00; % [R5] 5th order rosette aberration (Angstrom)
- obj_lens_phi_54(1,1) double = 0.00; % [phi_R5] Azimuthal angle of 5th order rosette aberration (Angstrom)
- obj_lens_c_56(1,1) double = 0.00; % [A5] 6-fold astigmatism (Angstrom)
- obj_lens_phi_56(1,1) double = 0.00; % [phi_A5] Azimuthal angle of 6-fold astigmatism (Angstrom)
-
- obj_lens_inner_aper_ang(1,1) double = 0.00; % Inner aperture (mrad)
- obj_lens_outer_aper_ang(1,1) double = 24.0; % Outer aperture (mrad)
- %%%%%%%%%% source spread function %%%%%%%%%%%%
-
- obj_lens_si_a(1,1) double = 1.0 % Height proportion of a normalized Gaussian [0, 1]
- obj_lens_si_sigma(1,1) double = 0.0072; % standard deviation: For parallel ilumination(Angstrom^-1); otherwise (Angstrom)
- obj_lens_si_beta(1,1) double = 0.0; % Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
- obj_lens_si_rad_npts(1,1) uint64 = 4; % # of integration points. It will be only used if illumination_model=4
- obj_lens_si_azm_npts(1,1) uint64 = 4; % # of radial integration points. It will be only used if illumination_model=4
- %%%%%%%%% defocus spread function %%%%%%%%%%%%
-
- obj_lens_ti_a(1,1) double = 1.0; % Height proportion of a normalized Gaussian [0, 1]
- obj_lens_ti_sigma(1,1) double = 32.0; % standard deviation (Angstrom)
- obj_lens_ti_beta(1,1) double = 0.0; % Standard deviation of the defocus spread for the Exponential component
- obj_lens_ti_npts(1,1) uint64 = 10; % # of integration points. It will be only used if illumination_model=4
-
- %%%%%%%%% zero defocus reference %%%%%%%%%%%%
-
- obj_lens_zero_defocus_type(1,1) uint64 {mustBeLessThanOrEqual(obj_lens_zero_defocus_type,4),mustBePositive} = 1; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
- obj_lens_zero_defocus_plane(1,1) double = 0.00; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
- % %%%%%%%%%%%%%%%%%%%%%%%%%% STEM Detector %%%%%%%%%%%%%%%%%%%%%%%%%%
-
- detector = multem_input.detector; % detector object
- %%%%%%%%%%%% Scanning area for ISTEM/STEM/EELS %%%%%%%%%%%%%%%%%
-
- scanning_type(1,1) uint64 {mustBeLessThanOrEqual(scanning_type,2),mustBePositive} = 2; % eST_Line = 1, eST_Area = 2
- scanning_periodic(1,1) uint64 {mustBeLessThanOrEqual(scanning_periodic,1),mustBeNonnegative} = 0; % 1: true, 0:false (periodic boundary conditions)
- scanning_square_pxs(1,1) uint64 {mustBeLessThanOrEqual(scanning_square_pxs,1),mustBeNonnegative} = 1; % 0: false, 1: true
- scanning_ns(1,1) uint64 {mustBePositive} = 10; % number of sampling points
- scanning_x0(1,1) double = 0.00; % x-starting point (Angstrom)
- scanning_y0(1,1) double = 0.00; % y-starting point (Angstrom)
- scanning_xe(1,1) double = 4.078; % x-final point (Angstrom)
- scanning_ye(1,1) double = 4.078; % y-final point (Angstrom)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- ped_nrot(1,1) double = 360; % Number of orientations
- ped_theta(1,1) double = 3.0; % Precession angle (degrees)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HCI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- hci_nrot(1,1) double = 360; % number of orientations
- hci_theta(1,1) double = 3.0; % Precession angle (degrees)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EELS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- eels_Z(1,1) uint64 = 79; % atomic type
- eels_E_loss(1,1) double = 80.0; % Energy loss (eV)
- eels_collection_angle(1,1) double = 100.0; % Collection half angle (mrad)
- eels_m_selection(1,1) double = 3; % selection rule
- eels_channelling_type(1,1) uint64 {mustBeLessThanOrEqual(eels_channelling_type,3),mustBePositive} = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EFTEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- eftem_Z(1,1) uint64 = 79; % atomic type
- eftem_E_loss(1,1) double = 80.0; % Energy loss (eV)
- eftem_collection_angle(1,1) double = 100.0; % Collection half angle (mrad)
- eftem_m_selection(1,1) double = 3; % selection rule
- eftem_channelling_type(1,1) uint64 {mustBeLessThanOrEqual(eftem_channelling_type,3),mustBePositive} = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-
- %%%%%%%%%%%%%%%%%%%%%%% OUTPUT REGION %%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%% This option is not used for eTEMST_STEM and eTEMST_EELS %%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- output_area_ix_0(1,1) double = 0.0; % x-starting in pixel
- output_area_iy_0(1,1) double = 0.0; % y-starting in pixel
- output_area_ix_e(1,1) double = 0.0; % x-final in pixel
- output_area_iy_e(1,1) double = 0.0; % y-final in pixel
- end
- methods
- function out_mt = ilc_incident_wave(obj)
- prms = obj.toStruct;
- clear ilc_incident_wave;
- out_mt = ilc_incident_wave(prms.system_conf, prms);
- end
- function out_mt = ilc_multem(obj)
- prms = obj.toStruct;
- clear ilc_multem;
- out_mt = ilc_multem(prms.system_conf, prms);
- end
- function out_mt = ilc_projected_potential(obj)
- prms = obj.toStruct;
- clear ilc_projected_potential;
- out_mt = ilc_projected_potential(prms.system_conf, prms);
- end
- function out_mt = ilc_propagate(obj)
- prms = obj.toStruct;
- clear ilc_propagate;
- out_mt = ilc_propagate(prms.system_conf, prms);
- end
- function out_mt = ilc_microscope_aberrations(obj)
- prms = obj.toStruct;
- clear ilc_microscope_aberrations;
- out_mt = ilc_microscope_aberrations(prms.system_conf, prms);
- end
- function out_mt = ilc_apply_ctf(obj)
- prms = obj.toStruct;
- clear ilc_propagate;
- out_mt = ilc_apply_ctf(prms.system_conf, prms);
- end
- function out_mt = ilc_transmission_function(obj)
- prms = obj.toStruct;
- clear ilc_transmission_function;
- out_mt = ilc_transmission_function(prms.system_conf, prms);
- end
- function out_mt = ilc_wave_function(obj)
- prms = obj.toStruct;
- clear ilc_wave_function;
- out_mt = ilc_wave_function(prms.system_conf, prms);
- end
- function s = toStruct(class)
- public_props = properties(class);
- s = struct();
- for fi = 1:numel(public_props)
- if isobject(class.(public_props{fi}))
- sub_props = properties(class.(public_props{fi}));
- for fi_s = 1:numel(sub_props)
- val = class.(public_props{fi}).(sub_props{fi_s});
- if isnumeric(val)
- val = double(val);
- end
- s.(public_props{fi}).(sub_props{fi_s}) = val;
- end
- else
- val = class.(public_props{fi});
- if isnumeric(val)
- val = double(val);
- end
- s.(public_props{fi}) = val;
- end
- end
- end
- end
-end
diff --git a/matlab_functions/+multem_input/system_conf.m b/matlab_functions/+multem_input/system_conf.m
deleted file mode 100644
index f7c09414..00000000
--- a/matlab_functions/+multem_input/system_conf.m
+++ /dev/null
@@ -1,17 +0,0 @@
-classdef system_conf
-% System Configuration object for Multem Input
- properties
- %%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-
- % eP_Float = 1, eP_double = 2
- precision(1,1) uint64 {mustBeLessThanOrEqual(precision,2),mustBePositive} = 1;
- % eD_CPU = 1, eD_GPU = 2
- device(1,1) uint64 {mustBeLessThanOrEqual(device,2),mustBePositive} = 2;
- % Number of Cores CPU (It will be used in the future)
- cpu_ncores
- % # of CPU Threads
- cpu_nthread(1,1) uint64 {mustBePositive} = 1;
- % Select GPU (for Multi-GPU Setups)
- gpu_device(1,1) uint64 {mustBeNonnegative} = 0;
- end
-end
\ No newline at end of file
diff --git a/matlab_functions/ilm_Z.m b/matlab_functions/ilm_Z.m
old mode 100644
new mode 100755
index f29a88a1..465a798e
--- a/matlab_functions/ilm_Z.m
+++ b/matlab_functions/ilm_Z.m
@@ -1,18 +1,18 @@
-function[Z] = ilm_Z(str_Z)
- a_str_Z = {'H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', ...
- 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', ...
- 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', ...
- 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', ...
- 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr'};
-
- if(ischar(str_Z))
- str_Z = {str_Z};
- end
- str_Z = strtrim(str_Z);
- a_str_Z = strtrim(a_str_Z);
- n_str_Z = numel(str_Z);
- Z = zeros(n_str_Z, 1);
- for ik=1:n_str_Z
- Z(ik) = find(strcmpi(str_Z{ik}, a_str_Z));
- end
+function[Z] = ilm_Z(str_Z)
+ a_str_Z = {'H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', ...
+ 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', ...
+ 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', ...
+ 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', ...
+ 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr'};
+
+ if(ischar(str_Z))
+ str_Z = {str_Z};
+ end
+ str_Z = strtrim(str_Z);
+ a_str_Z = strtrim(a_str_Z);
+ n_str_Z = numel(str_Z);
+ Z = zeros(n_str_Z, 1);
+ for ik=1:n_str_Z
+ Z(ik) = find(strcmpi(str_Z{ik}, a_str_Z));
+ end
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_apply_af_tf_2d.m b/matlab_functions/ilm_apply_af_tf_2d.m
new file mode 100755
index 00000000..e4cdf34a
--- /dev/null
+++ b/matlab_functions/ilm_apply_af_tf_2d.m
@@ -0,0 +1,34 @@
+% apply affine transformation
+function[im_o] = ilm_apply_af_tf_2d(system_config, im_i, dx, dy, A, txy, bg)
+ [ny, nx] = size(im_i, [1, 2]);
+ bsx = nx*dx;
+ bsy = ny*dy;
+
+ A = inv(A);
+ txy = -1*A*reshape(txy, [], 1);
+
+ [rx, ry, ~] = ilm_rs_grid_2d(nx, ny, bsx, bsy, 0);
+ p = [rx(:), ry(:)];
+ p = p*(A.') + txy.';
+ rx_o = reshape(p(:, 1), [ny, nx]);
+ ry_o = reshape(p(:, 2), [ny, nx]);
+
+
+% im_o = griddata(rx, ry, im_i, rx_o, ry_o, 'natural');
+ im_o = interp2(rx, ry, im_i, rx_o(:), ry_o(:), 'cubic', bg);
+ im_o = reshape(im_o, [ny, nx]);
+
+ im_o = max(min(im_i(:)), im_o);
+
+ if 0
+ figure(1);clf;
+ subplot(1, 2, 1);
+ imagesc(im_i);
+ axis image;
+ colormap jet;
+ subplot(1, 2, 2);
+ imagesc(im_o);
+ axis image;
+ colormap bone;
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_bd_2_rect.m b/matlab_functions/ilm_bd_2_rect.m
new file mode 100755
index 00000000..2e501a25
--- /dev/null
+++ b/matlab_functions/ilm_bd_2_rect.m
@@ -0,0 +1,3 @@
+function[rect] = ilm_bd_2_rect(lx, ly, bd_px)
+ rect = [bd_px(1), bd_px(3); lx-bd_px(2), ly-bd_px(4)];
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_build_ellip_parm_interp2.m b/matlab_functions/ilm_build_ellip_parm_interp2.m
new file mode 100755
index 00000000..7625ecdd
--- /dev/null
+++ b/matlab_functions/ilm_build_ellip_parm_interp2.m
@@ -0,0 +1,34 @@
+function [parm] = ilm_build_ellip_parm_interp2(coef, nx, ny, nx_r, ny_r, radius_r)
+ p_c_r = [nx_r, ny_r]/2 + 1;
+
+ p_c = coef(1:2);
+ rad_a = coef(3);
+ rad_b = coef(4);
+ theta = coef(5);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ mr = ilm_rot_mx_2d(-theta);
+ ms = [rad_a/radius_r, 0; 0 rad_b/radius_r];
+ msc = mr*ms*(mr.');
+ msc = msc.';
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ parm.radius_r = radius_r;
+ [rx_r, ry_r] = meshgrid((1:nx_r)-p_c_r(1), (1:ny_r)-p_c_r(2));
+ rxy_r = [rx_r(:), ry_r(:)]*msc;
+ parm.rx_r = reshape(rxy_r(:, 1), size(rx_r));
+ parm.ry_r = reshape(rxy_r(:, 2), size(ry_r));
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ [parm.rx, parm.ry] = meshgrid((1:nx)-p_c(1), (1:ny)-p_c(2));
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ parm.fltr_rs = ms(1)*ms(4);
+ parm.p_c_r = p_c_r;
+ nxh_r = nx_r/2;
+ nyh_r = ny_r/2;
+ parm.ax_r = (p_c_r(1)-nxh_r):1:(p_c_r(1)+nxh_r-1);
+ parm.ay_r = (p_c_r(2)-nyh_r):1:(p_c_r(2)+nyh_r-1);
+ parm.nx_r = nx_r;
+ parm.ny_r = ny_r;
+end
diff --git a/matlab_functions/ilm_center_spec.m b/matlab_functions/ilm_center_spec.m
deleted file mode 100644
index cdbc6a0d..00000000
--- a/matlab_functions/ilm_center_spec.m
+++ /dev/null
@@ -1,4 +0,0 @@
-function [atoms] = ilm_center_spec(atoms, lx, ly, lz)
- atoms(:, 2:4) = bsxfun(@minus, atoms(:, 2:4), min(atoms(:, 2:4)));
- atoms(:, 2:4) = bsxfun(@plus, atoms(:, 2:4), 0.5*([lx, ly, lz]-max(atoms(:, 2:4))));
-end
\ No newline at end of file
diff --git a/matlab_functions/ilm_chk_bound.m b/matlab_functions/ilm_chk_bound.m
old mode 100644
new mode 100755
index fd9b6cee..59e3b7cf
--- a/matlab_functions/ilm_chk_bound.m
+++ b/matlab_functions/ilm_chk_bound.m
@@ -1,3 +1,3 @@
-function[bb] = ilm_chk_bound(x, x_min, x_max)
- bb = (x_min<=x) && (x dgx = 2/nx;
+ %
+ drx = 0.5;
+ dry = 0.5;
+ [rx, ry] = meshgrid((-nxh:(nxh-1))*drx, (-nyh:(nyh-1))*dry);
+ r = sqrt(rx.^2+ry.^2);
+
+ % matlab sinc function is defines as sin(pi x)/(pi x)
+% mtf = mtf_par.fun(g);
+ mtf_rad = ilm_eval_rad_mtf(coef_mtf, r);
+
+ if support_bb
+ mtf = mtf_rad.*sinc(rx/2).*sinc(ry/2);
+ else
+ mtf = mtf_rad;
+ end
+
+ if shift_bb
+ mtf = fftshift(mtf);
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_dflt_input_multem.m b/matlab_functions/ilm_dflt_input_multem.m
old mode 100644
new mode 100755
index 9ecfd5cc..f36c11ca
--- a/matlab_functions/ilm_dflt_input_multem.m
+++ b/matlab_functions/ilm_dflt_input_multem.m
@@ -1,260 +1,250 @@
-function [input_multem] = ilm_dflt_input_multem()
- %%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
- input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
- input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.operation_mode = 1; % eOM_Normal = 1, eOM_Advanced = 2
- input_multem.memory_size = 0; % memory size to be used(Mb)
- input_multem.reverse_multislice = 0; % 1: true, 0:false
-
- %%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
- input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
- input_multem.pn_coh_contrib = 0; % 1: true, 0:false
- input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
- input_multem.pn_nconf = 1; % true: specific phonon configuration, false: number of frozen phonon configurations
- input_multem.pn_dim = 110; % phonon dimensions (xyz)
- input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
- %%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
- input_multem.spec_atoms = []; % simulation box length in x direction (Ã…)
- input_multem.spec_dz = 0.25; % slice thick (Ã…)
-
- input_multem.spec_lx = 10; % simulation box length in x direction (Ã…)
- input_multem.spec_ly = 10; % simulation box length in y direction (Ã…)
- input_multem.spec_lz = 10; % simulation box length gpuDEin z direction (Ã…)
-
- input_multem.spec_cryst_na = 1; % number of unit cell along a
- input_multem.spec_cryst_nb = 1; % number of unit cell along b
- input_multem.spec_cryst_nc = 1; % number of unit cell along c
- input_multem.spec_cryst_a = 0; % length along a (Ã…)
- input_multem.spec_cryst_b = 0; % length along b (Ã…)
- input_multem.spec_cryst_c = 0; % length along c (Ã…)
- input_multem.spec_cryst_x0 = 0; % reference position along x direction (Ã…)
- input_multem.spec_cryst_y0 = 0; % reference position along y direction (Ã…)
-
- input_multem.spec_amorp(1).z_0 = 0; % Starting z position of the amorphous layer (Ã…)
- input_multem.spec_amorp(1).z_e = 0; % Ending z position of the amorphous layer (Ã…)
- input_multem.spec_amorp(1).dz = 2.0; % slice thick of the amorphous layer (Ã…)
-
- %%%%%%%%%%%%%%%%%%%%%%%%% Specimen Rotation %%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.spec_rot_theta = 0; % angle (º)
- input_multem.spec_rot_u0 = [0 0 1]; % unitary vector
- input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
- input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
- %%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
- input_multem.thick = 0; % Array of thickness (Ã…)
-
- %%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
- %%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.nx = 256; % number of pixels in x direction
- input_multem.ny = 256; % number of pixels in y direction
- input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
- %%%%%%%%%%%%%%%%%%%%%%%% Simulation type %%%%%%%%%%%%%%%%%%%%%%%%%%%
- % eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22,
- % eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42,
- % eTEMST_EWFS=51, eTEMST_EWRS=52, eTEMST_EELS=61, eTEMST_EFTEM=62,
- % eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,
- % eTEMST_TFFS=91, eTEMST_TFRS=92
- input_multem.simulation_type = 52;
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
- input_multem.iw_psi = 0; % User define incident wave. It will be only used if User_Define=3
- input_multem.iw_x = 0.0; % x position
- input_multem.iw_y = 0.0; % y position
-
- %%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.E_0 = 300; % Acceleration Voltage (keV)
- input_multem.theta = 0.0; % Polar angle (°)
- input_multem.phi = 0.0; % Azimuthal angle (°)
-
- %%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.illumination_model = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
- input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % On the optimun probe in aberration corrected ADF-STEM
- % Ultramicroscopy 111(2014) 1523-1530
- % C_{nm} Krivanek --- {A, B, C, D, R}_{n} Haider notation
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- %%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.cond_lens_m = 0; % Vortex momentum
-
- input_multem.cond_lens_c_10 = 14.0312; % [C1] Defocus (Ã…)
- input_multem.cond_lens_c_12 = 0.00; % [A1] 2-fold astigmatism (Ã…)
- input_multem.cond_lens_phi_12 = 0.00; % [phi_A1] Azimuthal angle of 2-fold astigmatism (°)
-
- input_multem.cond_lens_c_21 = 0.00; % [B2] Axial coma (Ã…)
- input_multem.cond_lens_phi_21 = 0.00; % [phi_B2] Azimuthal angle of axial coma (°)
- input_multem.cond_lens_c_23 = 0.00; % [A2] 3-fold astigmatism (Ã…)
- input_multem.cond_lens_phi_23 = 0.00; % [phi_A2] Azimuthal angle of 3-fold astigmatism (°)
-
- input_multem.cond_lens_c_30 = 1e-03; % [C3] 3rd order spherical aberration (mm)
- input_multem.cond_lens_c_32 = 0.00; % [S3] Axial star aberration (Ã…)
- input_multem.cond_lens_phi_32 = 0.00; % [phi_S3] Azimuthal angle of axial star aberration (°)
- input_multem.cond_lens_c_34 = 0.00; % [A3] 4-fold astigmatism (Ã…)
- input_multem.cond_lens_phi_34 = 0.0; % [phi_A3] Azimuthal angle of 4-fold astigmatism (°)
-
- input_multem.cond_lens_c_41 = 0.00; % [B4] 4th order axial coma (Ã…)
- input_multem.cond_lens_phi_41 = 0.00; % [phi_B4] Azimuthal angle of 4th order axial coma (°)
- input_multem.cond_lens_c_43 = 0.00; % [D4] 3-lobe aberration (Ã…)
- input_multem.cond_lens_phi_43 = 0.00; % [phi_D4] Azimuthal angle of 3-lobe aberration (°)
- input_multem.cond_lens_c_45 = 0.00; % [A4] 5-fold astigmatism (Ã…)
- input_multem.cond_lens_phi_45 = 0.00; % [phi_A4] Azimuthal angle of 5-fold astigmatism (°)
-
- input_multem.cond_lens_c_50 = 0.00; % [C5] 5th order spherical aberration (mm)
- input_multem.cond_lens_c_52 = 0.00; % [S5] 5th order axial star aberration (Ã…)
- input_multem.cond_lens_phi_52 = 0.00; % [phi_S5] Azimuthal angle of 5th order axial star aberration (°)
- input_multem.cond_lens_c_54 = 0.00; % [R5] 5th order rosette aberration (Ã…)
- input_multem.cond_lens_phi_54 = 0.00; % [phi_R5] Azimuthal angle of 5th order rosette aberration (°)
- input_multem.cond_lens_c_56 = 0.00; % [A5] 6-fold astigmatism (Ã…)
- input_multem.cond_lens_phi_56 = 0.00; % [phi_A5] Azimuthal angle of 6-fold astigmatism (°)
-
- input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
- input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-
- %%%%%%%%% defocus spread function %%%%%%%%%%%%
- dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
- input_multem.cond_lens_ti_a = 1.0;
- input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation
- input_multem.cond_lens_ti_beta = 1;
- input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
- %%%%%%%%%% source spread function %%%%%%%%%%%%
- ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
- input_multem.cond_lens_si_a = 1.0;
- input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Ã…^-1); otherwise
- input_multem.cond_lens_si_beta = 1.0;
- input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
- input_multem.cond_lens_si_azm_npts = 12; % # of integration points. It will be only used if illumination_model=4
-
- %%%%%%%%% zero defocus reference %%%%%%%%%%%%
- input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
- input_multem.cond_lens_zero_defocus_plane = 0; % It will be only used if cond_lens_zero_defocus_type = eZDT_User_Define
-
- %%%%%%%%%%%%%%%%%%% condenser lens variable %%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%% it will be active in the future %%%%%%%%%%%%%%%%%
- % 1: Vortex momentum, 2: Defocus (Ã…), 2: Third order spherical aberration (mm)
- % 3: Third order spherical aberration (mm), 4: Fifth order spherical aberration (mm)
- % 5: Twofold astigmatism (Å), 2: Defocus (Å), 6: Azimuthal angle of the twofold astigmatism (°)
- % 7: Threefold astigmatism (Å), 8: Azimuthal angle of the threefold astigmatism (°)
- % 9: Inner aperture (mrad), 2: Defocus (Ã…), 10: Outer aperture (mrad)
- % input_multem.cdl_var_type = 0; % 0:off 1: m, 2: f, 3 Cs3, 4:Cs5, 5:mfa2, 6:afa2, 7:mfa3, 8:afa3, 9:inner_aper_ang , 10:outer_aper_ang
- % input_multem.cdl_var = [-2 -1 0 1 2]; % variable array
-
- %%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.obj_lens_m = 0; % Vortex momentum
-
- input_multem.obj_lens_c_10 = 14.0312; % [C1] Defocus (Ã…)
- input_multem.obj_lens_c_12 = 0.00; % [A1] 2-fold astigmatism (Ã…)
- input_multem.obj_lens_phi_12 = 0.00; % [phi_A1] Azimuthal angle of 2-fold astigmatism (°)
-
- input_multem.obj_lens_c_21 = 0.00; % [B2] Axial coma (Ã…)
- input_multem.obj_lens_phi_21 = 0.00; % [phi_B2] Azimuthal angle of axial coma (°)
- input_multem.obj_lens_c_23 = 0.00; % [A2] 3-fold astigmatism (Ã…)
- input_multem.obj_lens_phi_23 = 0.00; % [phi_A2] Azimuthal angle of 3-fold astigmatism (°)
-
- input_multem.obj_lens_c_30 = 1e-03; % [C3] 3rd order spherical aberration (mm)
- input_multem.obj_lens_c_32 = 0.00; % [S3] Axial star aberration (Ã…)
- input_multem.obj_lens_phi_32 = 0.00; % [phi_S3] Azimuthal angle of axial star aberration (°)
- input_multem.obj_lens_c_34 = 0.00; % [A3] 4-fold astigmatism (Ã…)
- input_multem.obj_lens_phi_34 = 0.0; % [phi_A3] Azimuthal angle of 4-fold astigmatism (°)
-
- input_multem.obj_lens_c_41 = 0.00; % [B4] 4th order axial coma (Ã…)
- input_multem.obj_lens_phi_41 = 0.00; % [phi_B4] Azimuthal angle of 4th order axial coma (°)
- input_multem.obj_lens_c_43 = 0.00; % [D4] 3-lobe aberration (Ã…)
- input_multem.obj_lens_phi_43 = 0.00; % [phi_D4] Azimuthal angle of 3-lobe aberration (°)
- input_multem.obj_lens_c_45 = 0.00; % [A4] 5-fold astigmatism (Ã…)
- input_multem.obj_lens_phi_45 = 0.00; % [phi_A4] Azimuthal angle of 5-fold astigmatism (°)
-
- input_multem.obj_lens_c_50 = 0.00; % [C5] 5th order spherical aberration (mm)
- input_multem.obj_lens_c_52 = 0.00; % [S5] 5th order axial star aberration (Ã…)
- input_multem.obj_lens_phi_52 = 0.00; % [phi_S5] Azimuthal angle of 5th order axial star aberration (°)
- input_multem.obj_lens_c_54 = 0.00; % [R5] 5th order rosette aberration (Ã…)
- input_multem.obj_lens_phi_54 = 0.00; % [phi_R5] Azimuthal angle of 5th order rosette aberration (°)
- input_multem.obj_lens_c_56 = 0.00; % [A5] 6-fold astigmatism (Ã…)
- input_multem.obj_lens_phi_56 = 0.00; % [phi_A5] Azimuthal angle of 6-fold astigmatism (°)
-
- input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
- input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
-
- %%%%%%%%% defocus spread function %%%%%%%%%%%%
- dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
- input_multem.obj_lens_ti_a = 1.0;
- input_multem.obj_lens_ti_sigma = dsf_sigma; % standard deviation
- input_multem.obj_lens_ti_beta = 1;
- input_multem.obj_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
- %%%%%%%%%% source spread function %%%%%%%%%%%%
- ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
- input_multem.obj_lens_si_a = 1.0;
- input_multem.obj_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Ã…^-1); otherwise
- input_multem.obj_lens_si_beta = 1.0;
- input_multem.obj_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
- input_multem.obj_lens_si_azm_npts = 12; % # of integration points. It will be only used if illumination_model=4
-
- %%%%%%%%% zero defocus reference %%%%%%%%%%%%
- input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
- input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
-
- %%%%%%%%%%%%%%%%%%%%%%%%%% STEM Detector %%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.detector.type = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
-
- input_multem.detector.cir(1).inner_ang = 60; % Inner angle(mrad)
- input_multem.detector.cir(1).outer_ang = 180; % Outer angle(mrad)
-
- input_multem.detector.radial(1).x = 0; % radial detector angle(mrad)
- input_multem.detector.radial(1).fx = 0; % radial sensitivity value
-
- input_multem.detector.matrix(1).R = 0; % 2D detector angle(mrad)
- input_multem.detector.matrix(1).fR = 0; % 2D sensitivity value
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%% Scanning area for ISTEM/STEM/EELS %%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.scanning_type = 1; % eST_Line = 1, eST_Area = 2
- input_multem.scanning_periodic = 1; % 1: true, 0:false (periodic boundary conditions)
- input_multem.scanning_square_pxs = 1; % 0: false, 1: true
- input_multem.scanning_ns = 10; % number of sampling points
- input_multem.scanning_x0 = 0.0; % x-starting point (Ã…)
- input_multem.scanning_y0 = 0.0; % y-starting point (Ã…)
- input_multem.scanning_xe = 4.078; % x-final point (Ã…)
- input_multem.scanning_ye = 4.078; % y-final point (Ã…)
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.ped_nrot = 360; % Number of orientations
- input_multem.ped_theta = 3.0; % Precession angle (degrees)
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HCI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.hci_nrot = 360; % number of orientations
- input_multem.hci_theta = 3.0; % Precession angle (degrees)
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EELS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.eels_Z = 79; % atomic type
- input_multem.eels_E_loss = 80; % Energy loss (eV)
- input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
- input_multem.eels_m_selection = 3; % selection rule
- input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EFTEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.eftem_Z = 79; % atomic type
- input_multem.eftem_E_loss = 80; % Energy loss (eV)
- input_multem.eftem_collection_angle = 100; % Collection half angle (mrad)
- input_multem.eftem_m_selection = 3; % selection rule
- input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-
- %%%%%%%%%%%%%%%%%%%%%%% OUTPUT REGION %%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%% This option is not use for eTEMST_STEM and eTEMST_EELS %%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- input_multem.output_area_ix_0 = 1; % x-starting in pixel
- input_multem.output_area_iy_0 = 1; % y-starting in pixel
- input_multem.output_area_ix_e = 1; % x-final in pixel
- input_multem.output_area_iy_e = 1; % y-final in pixel
-end
+function [input_multem] = ilm_dflt_input_multem()
+ %%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+ input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+ input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.operation_mode = 1; % eOM_Normal = 1, eOM_Advanced = 2
+ input_multem.memory_size = 0; % memory size to be used(Mb)
+ input_multem.reverse_multislice = 0; % 1: true, 0:false
+
+ %%%%%%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%%%%%
+ input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+ input_multem.atomic_vib_coh_contrib = 0; % 1: true, 0: false
+ input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+ input_multem.atomic_vib_nconf = 1; % true: specific phonon configuration, false: number of frozen phonon configurations
+ input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions [xyz]
+ input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+ %%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.spec_atoms = []; % simulation box length in x direction (Å)
+
+ input_multem.spec_bs_x = 10; % simulation box size in x direction (Å)
+ input_multem.spec_bs_y = 10; % simulation box size in y direction (Å)
+ input_multem.spec_bs_z = 10; % simulation box size in z direction (Å)
+
+ input_multem.spec_xtl_na = 1; % number of unit cell along a
+ input_multem.spec_xtl_nb = 1; % number of unit cell along b
+ input_multem.spec_xtl_nc = 1; % number of unit cell along c
+ input_multem.spec_xtl_a = 0; % length along a (Å)
+ input_multem.spec_xtl_b = 0; % length along b (Å)
+ input_multem.spec_xtl_c = 0; % length along c (Å)
+ input_multem.spec_xtl_x0 = 0; % reference position along x direction (Å)
+ input_multem.spec_xtl_y0 = 0; % reference position along y direction (Å)
+
+ %%%%%%%%%%%%%%%%%%%%%%%%% specimen rotation %%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.spec_rot_theta = 0; % angle (º)
+ input_multem.spec_rot_u_0 = [0 0 1]; % unitary vector
+ input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+ input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+ %%%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+ input_multem.spec_slic(1).sli_thick = 2.0; % slice thickness
+ input_multem.spec_slic(1).sel_typ = 1; % 1: by tag, 2: by z position
+ input_multem.spec_slic(1).sel_tag = 0; % tag
+ input_multem.spec_slic(1).sel_Z = 0; % 0: all atomic numbers
+ input_multem.spec_slic(1).sel_z_lim = [0, 0]; % [z_0, z_e]
+ input_multem.spec_slic(1).z_plns = []; % vector
+ %%%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+ input_multem.thick = 0; % Array of thickness (Å)
+
+ %%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.nx = 512; % number of pixels in x direction
+ input_multem.ny = 512; % number of pixels in y direction
+ input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+ %%%%%%%%%%%%%%%% electron microscopy simulation type %%%%%%%%%%%%%%%
+ % eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22,
+ % eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42,
+ % eTEMST_EWFS=51, eTEMST_EWRS=52, eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62,
+ % eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72,
+ % eTEMST_PPFS=81, eTEMST_PPRS=82, eTEMST_TFFS=91, eTEMST_TFRS=92
+ input_multem.em_sim_typ = 52; % electron microscopy simulation type
+
+ %%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.E_0 = 300; % Acceleration Voltage (keV)
+ input_multem.theta = 0.0; % Polar angle (º)
+ input_multem.phi = 0.0; % Azimuthal angle (º)
+
+ %%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.illum_mod = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+ input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % On the optimun probe in aberration corrected ADF-STEM
+ % Ultramicroscopy 111(2014) 1523-1530
+ % C_{nm} Krivanek --- {A, B, C, D, R}_{n} Haider notation
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ %%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.cond_lens_m = 0; % Vortex momentum
+
+ input_multem.cond_lens_c_10 = 14.0312; % [C1] Defocus (Å)
+ input_multem.cond_lens_c_12 = 0.00; % [A1] 2-fold astigmatism (Å)
+ input_multem.cond_lens_phi_12 = 0.00; % [phi_A1] Azimuthal angle of 2-fold astigmatism (º)
+
+ input_multem.cond_lens_c_21 = 0.00; % [B2] Axial coma (Å)
+ input_multem.cond_lens_phi_21 = 0.00; % [phi_B2] Azimuthal angle of axial coma (º)
+ input_multem.cond_lens_c_23 = 0.00; % [A2] 3-fold astigmatism (Å)
+ input_multem.cond_lens_phi_23 = 0.00; % [phi_A2] Azimuthal angle of 3-fold astigmatism (º)
+
+ input_multem.cond_lens_c_30 = 1e-03; % [C3] 3rd order spherical aberration (mm)
+ input_multem.cond_lens_c_32 = 0.00; % [S3] Axial star aberration (Å)
+ input_multem.cond_lens_phi_32 = 0.00; % [phi_S3] Azimuthal angle of axial star aberration (º)
+ input_multem.cond_lens_c_34 = 0.00; % [A3] 4-fold astigmatism (Å)
+ input_multem.cond_lens_phi_34 = 0.0; % [phi_A3] Azimuthal angle of 4-fold astigmatism (º)
+
+ input_multem.cond_lens_c_41 = 0.00; % [B4] 4th order axial coma (Å)
+ input_multem.cond_lens_phi_41 = 0.00; % [phi_B4] Azimuthal angle of 4th order axial coma (º)
+ input_multem.cond_lens_c_43 = 0.00; % [D4] 3-lobe aberration (Å)
+ input_multem.cond_lens_phi_43 = 0.00; % [phi_D4] Azimuthal angle of 3-lobe aberration (º)
+ input_multem.cond_lens_c_45 = 0.00; % [A4] 5-fold astigmatism (Å)
+ input_multem.cond_lens_phi_45 = 0.00; % [phi_A4] Azimuthal angle of 5-fold astigmatism (º)
+
+ input_multem.cond_lens_c_50 = 0.00; % [C5] 5th order spherical aberration (mm)
+ input_multem.cond_lens_c_52 = 0.00; % [S5] 5th order axial star aberration (Å)
+ input_multem.cond_lens_phi_52 = 0.00; % [phi_S5] Azimuthal angle of 5th order axial star aberration (º)
+ input_multem.cond_lens_c_54 = 0.00; % [R5] 5th order rosette aberration (Å)
+ input_multem.cond_lens_phi_54 = 0.00; % [phi_R5] Azimuthal angle of 5th order rosette aberration (º)
+ input_multem.cond_lens_c_56 = 0.00; % [A5] 6-fold astigmatism (Å)
+ input_multem.cond_lens_phi_56 = 0.00; % [phi_A5] Azimuthal angle of 6-fold astigmatism (º)
+
+ input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+ input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+
+ %%%%%%%%% defocus spread function %%%%%%%%%%%%
+ input_multem.cond_lens_tp_inc_a = 1.0; % Height proportion of a normalized Gaussian [0, 1]
+ input_multem.cond_lens_tp_inc_sigma = 0.5; % Standard deviation of the source defocus spread for the Gaussian component (Å)
+ input_multem.cond_lens_tp_inc_beta = 0.1; % Standard deviation of the source defocus spread for the Exponential component (Å)
+ input_multem.cond_lens_tp_inc_npts = 10; % Number of integration points. It will be only used if illum_mod=4
+
+ %%%%%%%%%% source spread function %%%%%%%%%%%%
+ input_multem.cond_lens_spt_inc_a = 1.0; % Height proportion of a normalized Gaussian [0, 1]
+ input_multem.cond_lens_spt_inc_sigma = 0.5; % Standard deviation of the source spread function for the Gaussian component: For parallel ilumination(Å^-1);otherwise (Å)
+ input_multem.cond_lens_spt_inc_beta = 0.1; % Standard deviation of the source spread function for the Exponential component: For parallel ilumination(Å^-1);otherwise (Å)
+ input_multem.cond_lens_spt_inc_rad_npts = 8; % Number of radial integration points. It will be only used if illum_mod=4
+ input_multem.cond_lens_spt_inc_azm_npts = 8; % Number of radial integration points. It will be only used if illum_mod=4
+
+ %%%%%%%%% zero defocus reference %%%%%%%%%%%%
+ input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+ input_multem.cond_lens_zero_def_plane = 0; % It will be only used if cond_lens_zero_def_typ = eZDT_User_Define
+
+ %%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.obj_lens_m = 0; % Vortex momentum
+
+ input_multem.obj_lens_c_10 = 14.0312; % [C1] Defocus (Å)
+ input_multem.obj_lens_c_12 = 0.00; % [A1] 2-fold astigmatism (Å)
+ input_multem.obj_lens_phi_12 = 0.00; % [phi_A1] Azimuthal angle of 2-fold astigmatism (º)
+
+ input_multem.obj_lens_c_21 = 0.00; % [B2] Axial coma (Å)
+ input_multem.obj_lens_phi_21 = 0.00; % [phi_B2] Azimuthal angle of axial coma (º)
+ input_multem.obj_lens_c_23 = 0.00; % [A2] 3-fold astigmatism (Å)
+ input_multem.obj_lens_phi_23 = 0.00; % [phi_A2] Azimuthal angle of 3-fold astigmatism (º)
+
+ input_multem.obj_lens_c_30 = 1e-03; % [C3] 3rd order spherical aberration (mm)
+ input_multem.obj_lens_c_32 = 0.00; % [S3] Axial star aberration (Å)
+ input_multem.obj_lens_phi_32 = 0.00; % [phi_S3] Azimuthal angle of axial star aberration (º)
+ input_multem.obj_lens_c_34 = 0.00; % [A3] 4-fold astigmatism (Å)
+ input_multem.obj_lens_phi_34 = 0.0; % [phi_A3] Azimuthal angle of 4-fold astigmatism (º)
+
+ input_multem.obj_lens_c_41 = 0.00; % [B4] 4th order axial coma (Å)
+ input_multem.obj_lens_phi_41 = 0.00; % [phi_B4] Azimuthal angle of 4th order axial coma (º)
+ input_multem.obj_lens_c_43 = 0.00; % [D4] 3-lobe aberration (Å)
+ input_multem.obj_lens_phi_43 = 0.00; % [phi_D4] Azimuthal angle of 3-lobe aberration (º)
+ input_multem.obj_lens_c_45 = 0.00; % [A4] 5-fold astigmatism (Å)
+ input_multem.obj_lens_phi_45 = 0.00; % [phi_A4] Azimuthal angle of 5-fold astigmatism (º)
+
+ input_multem.obj_lens_c_50 = 0.00; % [C5] 5th order spherical aberration (mm)
+ input_multem.obj_lens_c_52 = 0.00; % [S5] 5th order axial star aberration (Å)
+ input_multem.obj_lens_phi_52 = 0.00; % [phi_S5] Azimuthal angle of 5th order axial star aberration (º)
+ input_multem.obj_lens_c_54 = 0.00; % [R5] 5th order rosette aberration (Å)
+ input_multem.obj_lens_phi_54 = 0.00; % [phi_R5] Azimuthal angle of 5th order rosette aberration (º)
+ input_multem.obj_lens_c_56 = 0.00; % [A5] 6-fold astigmatism (Å)
+ input_multem.obj_lens_phi_56 = 0.00; % [phi_A5] Azimuthal angle of 6-fold astigmatism (º)
+
+ input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+ input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
+
+ %%%%%%%%% defocus spread function %%%%%%%%%%%%
+ input_multem.obj_lens_tp_inc_a = 1.0; % Height proportion of a normalized Gaussian [0, 1]
+ input_multem.obj_lens_tp_inc_sigma = 0.5; % Standard deviation of the source defocus spread for the Gaussian component (Å)
+ input_multem.obj_lens_tp_inc_beta = 0.1; % Standard deviation of the source defocus spread for the Exponential component (Å)
+ input_multem.obj_lens_tp_inc_npts = 10; % Number of integration points. It will be only used if illum_mod=4
+
+ %%%%%%%%% zero defocus reference %%%%%%%%%%%%
+ input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+ input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%% Scan tag for ISTEM/STEM/EELS %%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.scan_pat_typ = 1; % espt_line = 1, espt_area = 2, espt_user_def = 3
+ input_multem.scan_pat_pbc = 1; % periodic boundary conditions: 1: true, 0:false
+ input_multem.scan_pat_spxs = 1; % square pixel size: 1: true, 0:false
+ input_multem.scan_pat_nsp = 10; % number of sampling points
+ input_multem.scan_pat_r_0 = [0.0; 0.0]; % starting point (Å)
+ input_multem.scan_pat_r_e = [4.078; 4.078]; % final point (Å)
+ input_multem.scan_pat_r = []; % user define scanning pattern. It will be only used if User_Define=3
+
+ % if input_multem.scan_pat_typ = eST_User_Define, then the beam positions
+ % must be define in input_multem.beam_pos
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+ input_multem.incdt_wav_psi = 0; % User define incident wave. It will be only used if User_Define=3
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%% beam positions %%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.beam_pos = [0.0; 0.0]; % x-y positions
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%% STEM Detector %%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.detector.typ = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
+
+ input_multem.detector.cir(1).inner_ang = 60; % Inner angle(mrad)
+ input_multem.detector.cir(1).outer_ang = 180; % Outer angle(mrad)
+
+ input_multem.detector.radial(1).x = 0; % radial detector angle(mrad)
+ input_multem.detector.radial(1).fx = 0; % radial sensitivity value
+
+ input_multem.detector.matrix(1).R = 0; % 2D detector angle(mrad)
+ input_multem.detector.matrix(1).fR = 0; % 2D sensitivity value
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.ped_nrot = 360; % Number of orientations
+ input_multem.ped_theta = 3.0; % Precession angle (degrees)
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HCI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.hci_nrot = 360; % number of orientations
+ input_multem.hci_theta = 3.0; % Precession angle (degrees)
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%% STEM-EELS %%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.eels_Z = 79; % atomic type
+ input_multem.eels_E_loss = 80; % energy loss (eV)
+ input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+ input_multem.eels_m_selection = 3; % selection rule
+ input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%% EFTEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.eftem_Z = 79; % atomic type
+ input_multem.eftem_E_loss = 80; % energy loss (eV)
+ input_multem.eftem_collection_angle = 100; % Collection half angle (mrad)
+ input_multem.eftem_m_selection = 3; % selection rule
+ input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+
+ %%%%%%%%%%%%%%%%%%%%%%%%% output tag %%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%% This option is not used for eTEMST_STEM and eTEMST_STEM_EELS %%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ input_multem.output_area_ip_0 = [1; 1]; % Starting position in pixels
+ input_multem.output_area_ip_e = [1; 1]; % End position in pixels
+
+ %%%%%%%%%%%%%%%%%%% condenser lens variable %%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%% it will be active in the future %%%%%%%%%%%%%%%%%
+ % 1: Vortex momentum, 2: Defocus (Å), 2: Third order spherical aberration (mm)
+ % 3: Third order spherical aberration (mm), 4: Fifth order spherical aberration (mm)
+ % 5: Twofold astigmatism (Å), 2: Defocus (Å), 6: Azimuthal angle of the twofold astigmatism (º)
+ % 7: Threefold astigmatism (Å), 8: Azimuthal angle of the threefold astigmatism (º)
+ % 9: Inner aperture (mrad), 2: Defocus (Å), 10: Outer aperture (mrad)
+ % input_multem.cdl_var_type = 0; % 0:off 1: m, 2: f, 3 Cs3, 4:Cs5, 5:mfa2, 6:afa2, 7:mfa3, 8:afa3, 9:inner_aper_ang , 10:outer_aper_ang
+ % input_multem.cdl_var = [-2 -1 0 1 2]; % variable array
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_dflt_system_conf.m b/matlab_functions/ilm_dflt_system_conf.m
new file mode 100755
index 00000000..a9a3f7e5
--- /dev/null
+++ b/matlab_functions/ilm_dflt_system_conf.m
@@ -0,0 +1,21 @@
+function[system_config] = ilm_dflt_system_conf(device, id_gpu)
+ if(nargin<2)
+ id_gpu = 0;
+ end
+
+ if(nargin<1)
+ device = 2;
+ end
+
+ system_config.device = device; % eD_CPU = 1, eD_GPU = 2
+ system_config.precision = 1; % eP_Float = 1, eP_double = 2
+
+ %%%%%%%%%%%%%%%%%%%%%%%% cpu config %%%%%%%%%%%%%%%%%%%%%%%%
+ system_config.cpu_n_proc = 1;
+ system_config.cpu_n_thread = 1;
+
+ %%%%%%%%%%%%%%%%%%%%%%%% gpu config %%%%%%%%%%%%%%%%%%%%%%%%
+ system_config.gpu_device = id_gpu;
+% system_config.gpu_n_stream = 1;
+% system_config.gpu_device = 0;
+end
diff --git a/matlab_functions/ilm_draw_scan_area.m b/matlab_functions/ilm_draw_scan_area.m
new file mode 100755
index 00000000..a2e27b95
--- /dev/null
+++ b/matlab_functions/ilm_draw_scan_area.m
@@ -0,0 +1,17 @@
+% Draw area based p = [p_0;p_e]
+function[] = ilm_draw_scan_area(fig, p, c)
+ if(nargin<3)
+ c = '-r';
+ else
+ c = ['-', erase(c, '-')];
+ end
+ lxy = diff(p, 1, 1);
+
+ figure(fig);
+ hold on;
+ plot([p(1, 1), p(1, 1)+lxy(1)], [p(1, 2), p(1, 2)], c, ...
+ [p(1, 1)+lxy(1), p(1, 1)+lxy(1)], [p(1, 2), p(1, 2)+lxy(2)], c, ...
+ [p(1, 1)+lxy(1), p(1, 1)], [p(1, 2)+lxy(2), p(1, 2)+lxy(2)], c, ...
+ [p(1, 1), p(1, 1)], [p(1, 2)+lxy(2), p(1, 2)], c);
+ axis equal;
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_ePIE.m b/matlab_functions/ilm_ePIE.m
new file mode 100755
index 00000000..86dbad82
--- /dev/null
+++ b/matlab_functions/ilm_ePIE.m
@@ -0,0 +1,112 @@
+function [Obj, Probe, Psi] = ilm_ePIE(Obj_0, Probe_0, CBED, n_iter, alpha, beta)
+ CBED = single(CBED);
+ M = sqrt(ifftshift(CBED));
+
+ ifft2_sc = sqrt(size(CBED, 1)*size(CBED, 1));
+ cbed_sc = sqrt(sum(CBED, 'all'));
+
+ probe_0_sc = cbed_sc/sqrt(sum(abs(Probe_0).^2, 'all'));
+ Probe_0 = Probe_0*probe_0_sc;
+
+ obj_0_sc = cbed_sc/sqrt(sum(abs(Obj_0.*Probe_0).^2, 'all'));
+ Obj_0 = Obj_0*obj_0_sc;
+
+ for ik=1:n_iter
+ Psi_0 = Obj_0.*Probe_0;
+ Psi = fft2(ifftshift(Psi_0));
+ Psi = M.*exp(1j*angle(Psi));
+ Psi = fftshift(ifft2(Psi*ifft2_sc));
+
+ Obj_0_2 = abs(Obj_0).^2;
+ Probe = Probe_0 + beta*conj(Obj_0).*(Psi-Psi_0)./max(Obj_0_2, [], 'all');
+ Probe = Probe*cbed_sc/sqrt(sum(abs(Probe).^2, 'all'));
+
+ Probe_0_2 = abs(Probe_0).^2;
+ Obj = Obj_0 + alpha*conj(Probe_0).*(Psi-Psi_0)./max(Probe_0_2, [], 'all');
+ Obj = Obj*cbed_sc/sqrt(sum(abs(Obj.*Probe).^2, 'all'));
+
+% disp([sum(abs(psi_0(:)).^2), sum(abs(psi(:)).^2), sum(CBED(:))]/256^2)
+% disp([sum(abs(Probe_0(:)).^2), sum(abs(Probe(:)).^2)]/256^2)
+% disp([sum(abs(Obj_0.*Probe_0).^2, 'all'), sum(abs(Obj.*Probe).^2, 'all')]/256^2)
+
+ if 0
+ figure(2); clf;
+ subplot(2, 2, 1)
+ imagesc(abs(Psi_0));
+ axis image;
+ title('Module psi_0');
+ colorbar;
+ subplot(2, 2, 3)
+ imagesc(angle(Psi_0));
+ axis image;
+ colorbar;
+ title('Phase psi_0')
+
+ subplot(2, 2, 2)
+ imagesc(abs(Psi));
+ axis image;
+ title('Module psi');
+ colorbar;
+ subplot(2, 2, 4)
+ imagesc(angle(Psi));
+ axis image;
+ colorbar;
+ title('Phase psi');
+ end
+
+ if 0
+ figure(1); clf;
+ subplot(2, 4, 1)
+ imagesc(abs(Obj_0));
+ axis image;
+ title('Module Obj');
+ colorbar;
+ subplot(2, 4, 5)
+ imagesc(angle(Obj_0));
+ axis image;
+ colorbar;
+ title('Phase Obj')
+
+ subplot(2, 4, 2)
+ imagesc(abs(Probe_0));
+ axis image;
+ title('Module Probe');
+ colorbar;
+ subplot(2, 4, 6)
+ imagesc(angle(Probe_0));
+ axis image;
+ colorbar;
+ title('Phase Probe');
+
+ subplot(2, 4, 3)
+ imagesc(abs(Obj));
+ axis image;
+ title('Module Obj');
+ colorbar;
+ subplot(2, 4, 7)
+ imagesc(angle(Obj));
+ axis image;
+ colorbar;
+ title('Phase Obj')
+
+ subplot(2, 4, 4)
+ imagesc(abs(Probe));
+ axis image;
+ title('Module Probe');
+ colorbar;
+ subplot(2, 4, 8)
+ imagesc(angle(Probe));
+ axis image;
+ colorbar;
+ title('Phase Probe');
+ end
+
+ Obj_0 = Obj;
+ Probe_0 = Probe;
+ end
+
+
+ Probe = Probe/probe_0_sc;
+ Obj = Obj/obj_0_sc;
+ Psi = Psi/(obj_0_sc*probe_0_sc);
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_fd_tr_2d_runing_mean.m b/matlab_functions/ilm_fd_tr_2d_runing_mean.m
new file mode 100755
index 00000000..d55385b8
--- /dev/null
+++ b/matlab_functions/ilm_fd_tr_2d_runing_mean.m
@@ -0,0 +1,82 @@
+% find shifting between images
+function [at_p] = ilm_fd_tr_2d_runing_mean(system_config, data, p, sigma_g, radius, bd_0, at_p0, n_it, b_fit, ik_ref)
+ if(isstruct(data))
+ disp('Error: The data must be as 3d stack')
+ return;
+ end
+
+ [ny, nx, n_data] = ilm_size_data(data);
+
+ if(nargin<10)
+ ik_ref = 1; % It has to be implemented in the future
+ end
+
+ if(nargin<9)
+ b_fit = true;
+ end
+
+ if(nargin<8)
+ n_it = 1;
+ end
+
+ if(nargin<7)
+ at_p0 = ilm_dflt_at_p(n_data);
+ end
+
+ if(nargin<6)
+ bd_0 = zeros(1, 4);
+ end
+
+ % convert affine transformation to reference position
+ at_p = at_p0;
+ at_p(:,5:6) = at_p(:,5:6) - at_p(ik_ref, 5:6);
+
+ % find shift between images
+ dx = 1;
+ dy = 1;
+ for it = 1:n_it
+ ik = 1;
+ im_ik = double(data(:, :, ik));
+ im_rm = ilc_tr_2d(im_ik, 1, 1, at_p(ik, 5:6), 0);
+ tic;
+ for ik = 2:n_data
+ at_b = at_p(ik, :);
+ bd_t = ilm_at_v_2_bd(nx, ny, bd_0, at_p0(ik-1, :));
+ bd_ik = ilm_set_borders(at_b(5:6));
+ bd = max(bd_t, bd_ik);
+
+ [A, txy] = ilm_cvt_at_v_2_A_txy(at_b);
+ im_ik = double(data(:, :, ik));
+ at_p(ik, 5:6) = ilc_fd_tr_2d(system_config, im_rm/(ik-1), im_ik, dx, dy, A, txy, p, sigma_g, bd, 1, 0, b_fit, radius);
+
+ im_rm = im_rm + ilc_tr_2d(im_ik, 1, 1, at_p(ik, 5:6), 0);
+
+ if mod(ik, 10)==0
+ t_c = toc;
+ disp(['iter = ', num2str(it), ' calculating shift between images #', num2str(ik-1), '_', num2str(ik), '_time=', num2str(t_c, '%5.2f')]);
+ tic;
+ end
+
+ if 0
+ [i_min,i_max] = ilm_min_max(im_ik);
+ figure(3);
+ subplot(1, 3, 1);
+ imagesc(im_rm/(ik-1), [i_min,i_max]);
+ axis image off;
+ colormap jet;
+ title(['# =:', num2str(ik)])
+ subplot(1, 3, 2);
+ imagesc(im_ik,[i_min,i_max]);
+ axis image off;
+ colormap jet;
+ title(['txy = [', num2str(at_p(ik, 5), 2), ', ', num2str(at_p(ik, 6), 2), ']'])
+ subplot(1, 3, 3);
+ plot(at_p(1:ik, 5), at_p(1:ik, 6), '-or')
+ end
+ % ilm_show_pcf(system_config, double(data(:, :, ik-1)), double(data(:, :, ik)), at_b, at_p(ik, :), p, sigma_g, bd);
+ end
+
+ % transform affine transformations related to the reference image
+ at_p(:,5:6) = at_p(:,5:6) - at_p(ik_ref, 5:6);
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_find_closest_xy_pos.m b/matlab_functions/ilm_find_closest_xy_pos.m
old mode 100644
new mode 100755
diff --git a/matlab_functions/ilm_fit_pcf_2d.m b/matlab_functions/ilm_fit_pcf_2d.m
new file mode 100755
index 00000000..d8fef768
--- /dev/null
+++ b/matlab_functions/ilm_fit_pcf_2d.m
@@ -0,0 +1,14 @@
+function [pxy] = ilm_fit_pcf_2d(pcf_2d, dx, dy, sigma_g_px)
+ [ny, nx] = size(pcf_2d, [1, 2]);
+ bsx = nx*dx;
+ bsy = ny*dy;
+ sigma_g = sigma_g_px*min(1/bsx, 1/bsy);
+
+ [~, ixy] = max(pcf_2d(:));
+ [I_row, I_col] = ind2sub([ny, nx], ixy);
+ pxy = [I_col, I_row].*[dx, dy];
+ sigma_r = 1/(2*pi*sigma_g);
+ radius = 1.5*sigma_r;
+
+ pxy = ilc_fit_peak_pos_2d(pcf_2d, dx, dy, pxy, sigma_r, radius);
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_geom_center_cp.m b/matlab_functions/ilm_geom_center_cp.m
old mode 100644
new mode 100755
index cc27f6ba..8c86da12
--- a/matlab_functions/ilm_geom_center_cp.m
+++ b/matlab_functions/ilm_geom_center_cp.m
@@ -1,5 +1,3 @@
-function[p0]=ilm_geom_center_cp(atoms)
- p0 = mean(atoms); % rotation point
- [~, ii] = sort(sqrt(sum((atoms-p0).^2, 2)));
- p0 = atoms(ii(1), :);
+function[p0] = ilm_geom_center_cp(atoms)
+ p0 = ilm_find_closest_atom_pos(mean(atoms));
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_gui_stem_reg.m b/matlab_functions/ilm_gui_stem_reg.m
new file mode 100755
index 00000000..4b26e44c
--- /dev/null
+++ b/matlab_functions/ilm_gui_stem_reg.m
@@ -0,0 +1,1203 @@
+function[data, nr_grid, at_p] = ilm_gui_stem_reg(system_config, data_i, at_p0)
+ global n_data nx ny x_c y_c sigma_g_max p fim
+ global fz_t dx dy b_stop bb_nr p_rect_sel
+ global f_xy fs_ax fs_ay fs_x_c fs_y_c
+ global bb_shift_kpf bb_ctrl_kpf
+
+ close all
+
+ bb_shift_kpf = false;
+ bb_ctrl_kpf = false;
+ b_stop = false;
+
+ if(nargin<3)
+ n_data = ilm_nz_data(data_i);
+ at_p0 = ilm_dflt_at_p(n_data);
+ end
+
+ fy = 0.60;
+ fx = 0.75;
+ dm = get(0, 'MonitorPositions');
+ dm = dm(1, :);
+ w = fx*dm(3);
+ h = fy*dm(4);
+ x0 = (1-fx)*w/2;
+ y0 = (1-fy)*h/2;
+
+ fh = figure(1); clf;
+ set(fh, {'Name', 'Visible', 'units', 'position', 'CloseRequestFcn'}, {'STEM registration -- Software created by Ivan Lobato: Ivanlh20@gmail.com', 'on', 'pixels', [x0, y0, x0+w, y0+h], @cb_close})
+ set(fh, 'MenuBar', 'none');
+ set(fh, 'ToolBar', 'none');
+ movegui(fh, 'center');
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ ui_pnl_opt = uipanel('Parent', fh, 'Title', 'Options', 'Units', 'normalized', ...,
+ 'FontSize', 12, 'BackgroundColor', 'white', 'Position', [0.1 0.725 0.70 0.26]);
+
+ pnl_x_0 = 12;
+ pnl_y = 3 + (4:-1:0)*35;
+ pnl_d = 4;
+ pnl_h = 24;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
+ pnl_w = [80, 70, 70, 50, 50, 50, 65, 40, 40, 45, 55, 55, 75, 45];
+ pnl_n = length(pnl_w);
+ pnl_x = pnl_x_0*ones(1, pnl_n);
+
+ for it=2:pnl_n
+ pnl_x(it) = pnl_x(it-1) + pnl_d + pnl_w(it-1);
+ end
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Rigid Reg.', 'Position', [pnl_x(1) pnl_y(1) pnl_w(1) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Reset txy', 'Position', [pnl_x(2) pnl_y(1) pnl_w(2) pnl_h], 'Callback', @cb_reset_txy);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Reset A', 'Enable', 'off', 'Position', [pnl_x(3) pnl_y(1) pnl_w(3) pnl_h], 'Callback', @cb_reset_A);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Crt. tx', 'Position', [pnl_x(4) pnl_y(1) pnl_w(4) pnl_h], 'Callback', @(src, ev)cb_crt_txy(1));
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Crt. ty', 'Position', [pnl_x(5) pnl_y(1) pnl_w(5) pnl_h], 'Callback', @(src, ev)cb_crt_txy(2));
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Crt. txy', 'Position', [pnl_x(6) pnl_y(1) pnl_w(6) pnl_h], 'Callback', @(src, ev)cb_crt_txy(3));
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Crt. A_txy', 'Enable', 'off', 'Position', [pnl_x(7) pnl_y(1) pnl_w(7) pnl_h], 'Callback', @cb_crt_A_txy);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'n_it', 'Position', [pnl_x(8) pnl_y(1) pnl_w(8) pnl_h]);
+
+ ui_edt_rg_n_it = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '1', 'Position', [pnl_x(9) pnl_y(1) pnl_w(9) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'idx_ref', 'Position', [pnl_x(10) pnl_y(1) pnl_w(10) pnl_h]);
+
+ ui_pu_idx_ref = uicontrol('Parent', ui_pnl_opt, 'Style', 'popup', ...
+ 'String', num2cell(1:n_data), 'Value', 1, ...
+ 'Position', [pnl_x(11) pnl_y(1) pnl_w(11) pnl_h], 'Callback', @cb_idx_ref);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Preproc', 'Position', [pnl_x(12) pnl_y(1) pnl_w(12) pnl_h]);
+
+ ui_pu_preproc = uicontrol('Parent', ui_pnl_opt, 'Style', 'popup', ...
+ 'String', {'Raw', 'Laplacian', 'LCWT'}, 'Value', 2, ...
+ 'Position', [pnl_x(13) pnl_y(1) pnl_w(13) pnl_h], 'Callback', @cb_preproc);
+
+ ui_edt_preproc_sigma = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '4.0', 'Enable', 'off', 'Position', [pnl_x(14) pnl_y(1) pnl_w(14) pnl_h], 'Callback', @cb_show_sel_ui_lb_data);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ pnl_w = [80, 80, 80, 45, 55, 45, 55, 45, 55, 45, 60];
+ pnl_n = length(pnl_w);
+ pnl_x = pnl_x_0*ones(1, pnl_n);
+
+ for it=2:pnl_n
+ pnl_x(it) = pnl_x(it-1) + pnl_d + pnl_w(it-1);
+ end
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Non-Rigid Reg.', 'Position', [pnl_x(1) pnl_y(2) pnl_w(1) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Assign A-txy', 'Position', [pnl_x(2) pnl_y(2) pnl_w(2) pnl_h], 'Callback', @cb_assign_A_txy);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Crt. nr_grid', 'Position', [pnl_x(3) pnl_y(2) pnl_w(3) pnl_h], 'Callback', @cb_crt_nr_grid);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'n_it_i', 'Position', [pnl_x(4) pnl_y(2) pnl_w(4) pnl_h]);
+
+ ui_edt_nrg_n_it_i = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '10', 'Position', [pnl_x(5) pnl_y(2) pnl_w(5) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'n_it_o', 'Position', [pnl_x(6) pnl_y(2) pnl_w(6) pnl_h]);
+
+ ui_edt_nrg_n_it_o = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '8', 'Position', [pnl_x(7) pnl_y(2) pnl_w(7) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'alpha', 'Position', [pnl_x(8) pnl_y(2) pnl_w(8) pnl_h]);
+
+ ui_edt_alpha = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '0.5', 'Position', [pnl_x(9) pnl_y(2) pnl_w(9) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Opt.', 'Position', [pnl_x(10) pnl_y(2) pnl_w(10) pnl_h]);
+
+ ui_pu_opt = uicontrol('Parent', ui_pnl_opt, 'Style', 'popup', ...
+ 'String', {'Mean', 'Poly 1', 'Poly 2', 'orig.'}, 'Position', [pnl_x(11) pnl_y(2) pnl_w(11) pnl_h]);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % 1, 2, 3, 4, 5, 6, 7
+ pnl_w = [270, 50, 50, 50, 65, 100, 110];
+ pnl_n = length(pnl_w);
+ pnl_x = pnl_x_0*ones(1, pnl_n);
+
+ for it=2:pnl_n
+ pnl_x(it) = pnl_x(it-1) + pnl_d + pnl_w(it-1);
+ end
+
+ ui_bg_opt = uibuttongroup('Parent', ui_pnl_opt, 'units', 'Pixels', ...
+ 'Position', [pnl_x(1) pnl_y(3) pnl_w(1) pnl_h], 'SelectionChangedFcn', @cb_execute_selection);
+
+ ui_rb_select = uicontrol('Parent', ui_bg_opt, 'Style', 'radiobutton', ...
+ 'String', 'select', 'Position', [pnl_x_0 0 50 pnl_h]);
+
+ ui_rb_add_bd = uicontrol('Parent', ui_bg_opt, 'Style', 'radiobutton', ...
+ 'String', 'add bd', 'Position', [pnl_x_0+(60+pnl_d) 0 60 pnl_h]);
+
+ ui_rb_resize = uicontrol('Parent', ui_bg_opt, 'Style', 'radiobutton', ...
+ 'String', 'resize', 'Position', [pnl_x_0+(120+2*pnl_d) 0 60 pnl_h]);
+
+ ui_rb_crop = uicontrol('Parent', ui_bg_opt, 'Style', 'radiobutton', ...
+ 'String', 'crop', 'Position', [pnl_x_0+(180+3*pnl_d) 0 60 pnl_h]);
+
+ ui_edt_sampling_x = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '0', 'Position', [pnl_x(2) pnl_y(3) pnl_w(2) pnl_h]);
+
+ ui_edt_sampling_y = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '0', 'Position', [pnl_x(3) pnl_y(3) pnl_w(3) pnl_h]);
+
+ ui_pb_execute = uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Exec.', 'Position', [pnl_x(4) pnl_y(3) pnl_w(4) pnl_h], 'Callback', @cb_execute);
+
+ ui_cb_reg_typ = uicontrol('Parent', ui_pnl_opt, 'Style', 'checkbox', ...
+ 'String', 'Rig. Reg.', 'Value', 1, 'Position', [pnl_x(5) pnl_y(3) pnl_w(5) pnl_h], 'Callback', @cb_reg_typ);
+
+ ui_pb_show_data = uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Show rg data', 'Position', [pnl_x(6) pnl_y(3) pnl_w(6) pnl_h], 'Callback', @cb_show_data);
+
+ ui_pb_show_avg_data = uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'show avg rg data', 'Position', [pnl_x(7) pnl_y(3) pnl_w(7) pnl_h], 'Callback', @cb_show_avg_data);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ pnl_w = [75, 75, 60, 70, 60, 60, 60, 65, 165, 60, 60];
+ pnl_n = length(pnl_w);
+ pnl_x = pnl_x_0*ones(1, pnl_n);
+
+ for it=2:pnl_n
+ pnl_x(it) = pnl_x(it-1) + pnl_d + pnl_w(it-1);
+ end
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'Reset data', 'Position', [pnl_x(1) pnl_y(4) pnl_w(1) pnl_h], 'Callback', @cb_reset_data);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Sigma_g(px.)', 'Position', [pnl_x(2) pnl_y(4) pnl_w(2) pnl_h]);
+
+ ui_edt_sigma = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', num2str(sigma_g_max/2, '%5.2f'), 'Position', [pnl_x(3) pnl_y(4) pnl_w(3) pnl_h]);
+
+ ui_cb_rcfft = uicontrol('Parent', ui_pnl_opt, 'Style', 'checkbox', ...
+ 'String', 'Recal. fft', 'Value', 1, 'Position', [pnl_x(4) pnl_y(4) pnl_w(4) pnl_h]);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Exp. FFT', 'Position', [pnl_x(5) pnl_y(4) pnl_w(5) pnl_h]);
+
+ ui_pu_exp = uicontrol('Parent', ui_pnl_opt, 'Style', 'popup', ...
+ 'String', {'0.100', '0.125', '0.20', '0.25', '0.5', '0.75'}, 'Value', 3, ...
+ 'Position', [pnl_x(6) pnl_y(4) pnl_w(6) pnl_h], 'Callback', @(src, ev)fcn_show_ax_f_1(false));
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', 'Time(s.)', 'Position', [pnl_x(7) pnl_y(4) pnl_w(7) pnl_h]);
+
+ ui_edt_time = uicontrol('Parent', ui_pnl_opt, 'Style', 'edit', ...
+ 'String', '0.05', 'Position', [pnl_x(8) pnl_y(4) pnl_w(8) pnl_h]);
+
+ ui_txt_msg = uicontrol('Parent', ui_pnl_opt, 'Style', 'text', ...
+ 'String', '00.0%', 'Position', [pnl_x(9) pnl_y(4) pnl_w(9) pnl_h], 'FontSize', 13, 'FontWeight', 'bold');
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'stop', 'Position', [pnl_x(10) pnl_y(4) pnl_w(10) pnl_h], 'Callback', @cb_stop);
+
+ uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'String', 'close', 'Position', [pnl_x(11) pnl_y(4) pnl_w(11) pnl_h], 'Callback', @cb_close);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ pnl_w = [850];
+ pnl_n = length(pnl_w);
+ pnl_x = pnl_x_0*ones(1, pnl_n);
+
+ for it=2:pnl_n
+ pnl_x(it) = pnl_x(it-1) + pnl_d + pnl_w(it-1);
+ end
+
+ ui_pb_data_info = uicontrol('Parent', ui_pnl_opt, 'Style', 'pushbutton', ...
+ 'Enable', 'inactive', 'String', ' ', 'Position', [pnl_x(1) pnl_y(5) pnl_w(1) pnl_h]);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ d_f = 0.010;
+ h_f = 0.55;
+ w_1 = 0.16;
+ w_2 = h_f*h/w;
+ w_3 = w_2;
+ w_4 = w_3;
+
+ x_1 = (1-(w_1+w_2+w_3+w_4+3*d_f))/2;
+ x_2 = x_1+w_1+d_f;
+ x_3 = x_2+w_2+d_f;
+ x_4 = x_3+w_3+d_f;
+ y_0 = 0.10;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ ui_lb_data = uicontrol('Style', 'listbox', 'Units', 'normalized', ...
+ 'Position', [x_1 y_0 w_1 h_f], 'Callback', @cb_show_sel_ui_lb_data);
+
+ ax_f(1) = axes('Position', [x_2 y_0 w_2 h_f], 'Visible', 'off');
+ ax_f(2) = axes('Position', [x_3 y_0 w_3 h_f], 'Visible', 'off');
+ ax_f(3) = axes('Position', [x_4 y_0 w_4 h_f], 'Visible', 'off');
+
+ fcn_init(system_config, data_i, at_p0);
+
+ fh.WindowButtonMotionFcn = @cb_mouse_move;
+ fh.WindowButtonDownFcn = @cb_mouse_click;
+ fh.WindowScrollWheelFcn = @cb_zoom;
+ fh.WindowKeyPressFcn = @cb_press_key;
+ fh.WindowKeyReleaseFcn = @cb_release_key;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ uiwait(fh)
+
+ function [typ] = fcn_get_activate_typ()
+ typ = ilm_ifelse(ui_rb_add_bd.Value, 1, 0);
+ typ = ilm_ifelse(ui_rb_resize.Value, 2, typ);
+ typ = ilm_ifelse(ui_rb_crop.Value, 3, typ);
+ end
+
+ function fcn_activate_opt(typ)
+ if(typ==0) % select
+ ui_edt_sampling_x.Enable = 'off';
+ ui_edt_sampling_y.Enable = 'off';
+
+ ui_pb_execute.Enable = 'off';
+ elseif(typ==1) % add bd
+ ui_edt_sampling_x.String = num2str(0);
+ ui_edt_sampling_x.Enable = 'on';
+
+ ui_edt_sampling_y.String = num2str(0);
+ ui_edt_sampling_y.Enable = 'on';
+
+ ui_pb_execute.Enable = 'on';
+ ui_pb_execute.Enable = 'on';
+ elseif(typ==2) % resize
+ if(str2double(ui_edt_sampling_x.String)<64)
+ ui_edt_sampling_x.String = num2str(nx);
+ end
+ ui_edt_sampling_x.Enable = 'on';
+
+ if(str2double(ui_edt_sampling_y.String)<64)
+ ui_edt_sampling_y.String = num2str(ny);
+ end
+ ui_edt_sampling_y.Enable = 'off';
+
+ ui_pb_execute.Enable = 'on';
+ elseif(typ==3) % crop
+ ui_edt_sampling_x.Enable = 'off';
+ ui_edt_sampling_y.Enable = 'off';
+
+ ui_pb_execute.Enable = 'on';
+ end
+ end
+
+ function cb_execute_selection(source, event)
+ typ = fcn_get_activate_typ();
+ fcn_activate_opt(typ)
+ end
+
+ function cb_execute(source, event)
+ fcn_msn_start();
+
+ typ = fcn_get_activate_typ();
+
+ if(typ==1) % add bd
+ bd_x = round(str2double(ui_edt_sampling_x.String));
+ bd_x = ilm_pn_border(nx, bd_x, 1);
+ nx_r = nx+2*bd_x;
+ ix_0 = bd_x + 1;
+ ix_e = ix_0 + nx-1;
+ ax = ix_0:ix_e;
+
+ bd_y = round(str2double(ui_edt_sampling_y.String));
+ bd_y = ilm_pn_border(ny, bd_y, 1);
+ ny_r = ny + 2*bd_y;
+ iy_0 = bd_y + 1;
+ iy_e = iy_0 + ny-1;
+ ay = iy_0:iy_e;
+
+ data_t = zeros(ny_r, nx_r, n_data);
+ % data_t(ay, ax, :) = data;
+ for ik=1:n_data
+ im_ik = double(data(:, :, ik));
+ data_t(:, :, ik) = mean(im_ik(:));
+ data_t(ay, ax, ik) = im_ik;
+
+ ui_txt_msg.String = [num2str(100*ik/n_data, '%4.1f'), ' %'];
+ pause(0.001);
+ end
+
+ p_rect_sel_0 = p_rect_sel + [bd_x, bd_y];
+
+ fcn_init(system_config, data_t, at_p, p_rect_sel_0);
+
+ ui_edt_sampling_x.String = num2str(0);
+ ui_edt_sampling_y.String = num2str(0);
+
+ elseif(typ==2) % resize
+ nx_r = round(str2double(ui_edt_sampling_x.String));
+
+ if(nx_r==0)
+ return;
+ end
+ ny_r = round(nx_r*ny/nx);
+ nx_r = ilm_pn_fact(nx_r);
+
+ data_t = zeros(ny_r, nx_r, n_data);
+ for ik=1:n_data
+ im_ik = double(data(:, :, ik));
+ data_t(:, :, ik) = max(0, imresize(im_ik, [ny_r, nx_r], 'bicubic'));
+
+ ui_txt_msg.String = [num2str(100*ik/n_data, '%4.1f'), ' %'];
+ pause(0.001);
+ end
+
+ at_p(:, 5:6) = at_p(:, 5:6).*[nx_r/nx, ny_r/ny];
+ if(mod(ny_r, 2)==1)
+ data_t = data_t(1:(end-1), :, :);
+ end
+
+ fcn_init(system_config, data_t, at_p);
+
+ ui_edt_sampling_x.String = num2str(0);
+ ui_edt_sampling_y.String = num2str(0);
+ elseif(typ==3) % crop
+ ax = p_rect_sel(1, 1):p_rect_sel(2, 1);
+ ay = p_rect_sel(1, 2):p_rect_sel(2, 2);
+
+ for ik=1:n_data
+ [A, txy] = ilm_cvt_at_v_2_A_txy(at_p(ik, :));
+ im_ik = double(data(:, :, ik));
+ data(:, :, ik) = ilc_tr_at_2d(system_config, im_ik, dx, dy, A, txy, 3, 0);
+ ui_txt_msg.String = [num2str(100*ik/n_data, '%4.1f'), ' %'];
+ pause(0.001);
+ end
+
+ at_p = ilm_dflt_at_p(n_data);
+
+ fcn_init(system_config, data(ay, ax, :), at_p);
+ end
+
+ fcn_msn_end();
+ end
+
+ function s = fcn_str_data_info(p_rect_sel)
+ s = ['[nx, ny] = [', num2str(nx), ', ', num2str(ny), ']'];
+ s = [s, ' - [ix_0, ix_e] = [', num2str(p_rect_sel(1, 1)), ', ', num2str(p_rect_sel(2, 1)), ']'];
+ s = [s, ' - [iy_0, iy_e] = [', num2str(p_rect_sel(1, 2)), ', ', num2str(p_rect_sel(2, 2)), ']'];
+ s = [s, ' - [nx_s, ny_s] = [', num2str(abs(p_rect_sel(2, 1)-p_rect_sel(1, 1))+1), ', ', num2str(abs(p_rect_sel(2, 2)-p_rect_sel(1, 2))+1), ']'];
+ end
+
+ function fcn_init(system_config, data_i, at_p_0, p_rect_sel_0)
+ fcn_msn_start();
+
+ bb_nr = false;
+
+ data = data_i;
+ [ny, nx, n_data] = ilm_size_data(data);
+
+ if(nx>ny)
+ f_xy = [1, nx/ny];
+ else
+ f_xy = [ny/nx, 1];
+ end
+
+ fs_ax = (1:nx)*f_xy(1);
+ fs_ay = (1:ny)*f_xy(2);
+ fs_x_c = nx*f_xy(1)/2 + 1;
+ fs_y_c = ny*f_xy(2)/2 + 1;
+
+ dx = 1;
+ dy = 1;
+
+ x_c = nx/2 + 1;
+ y_c = ny/2 + 1;
+
+ if(nargin<4)
+ p_rect_sel_0 = [1, 1; nx, ny];
+ end
+
+ p_rect_sel = p_rect_sel_0;
+
+ at_p = at_p_0;
+
+ % set sigma max
+ sigma_g_max = min(nx/2, ny/2)-1;
+
+ % set initial sigma
+ fim = fcn_mean_abs_fdata_at(system_config, data, at_p);
+ sigma_gt = ilc_info_lim_2d(fim);
+
+ ui_edt_sampling_x.String = num2str(nx);
+ ui_edt_sampling_y.String = num2str(ny);
+ ui_edt_sigma.String = num2str(sigma_gt, '%5.2f');
+ ui_pb_data_info.String = fcn_str_data_info(p_rect_sel);
+
+ % set initial zoom
+ fz_t(1) = sigma_g_max/(2*sigma_gt);
+ fz_t(2) = 1;
+ fz_t(3) = sigma_g_max/min(sigma_g_max/2, max(sigma_g_max/5, 6*ilm_sigma_g_2_sigma_r(nx, ny, sigma_gt)));
+
+ % plot fim
+ fcn_show_ax_f_1(false);
+
+ axes(ax_f(1));
+ ax = gca;
+ ax.Toolbar.Visible = 'off';
+
+ % set initial lb_data values
+ fcn_set_at_p_2_ui_lb_data(at_p);
+
+ axes(ax_f(2));
+ ax = gca;
+ ax.Toolbar.Visible = 'off';
+
+ axes(ax_f(3));
+ ax = gca;
+ ax.Toolbar.Visible = 'off';
+
+ ui_lb_data.Value = 1;
+ cb_show_sel_ui_lb_data();
+
+ fcn_msn_end();
+ end
+
+ function [image_av] = fcn_mean_abs_fdata_at(system_config, data, at_p)
+ [ny, nx, n_data] = ilm_size_data(data);
+
+ n_idx = max(2, round(n_data/2));
+ a_idx = randperm(n_data, n_idx);
+
+ image_av = zeros(ny, nx);
+ radius = 0.85*min(nx, ny)/2;
+ fbw = ilc_wd_butwth([nx, 1], [1, 1], 8, radius);
+ fbw = fbw.*ilc_wd_butwth([1, ny], [1, 1], 8, radius);
+
+ for ik = a_idx
+ [A, txy] = ilm_cvt_at_v_2_A_txy(at_p(ik, :));
+ image_ik = double(data(:, :, ik));
+ [image_ik, bg_ik] = ilc_tr_at_2d(system_config, image_ik, dx, dy, A, txy, 3, 0);
+ image_ik = (image_ik-0.999*bg_ik).*fbw;
+
+ image_av = image_av + abs(fft2(image_ik));
+ end
+
+ image_av = ifftshift(image_av/n_idx);
+ end
+
+ function fcn_msn_start()
+ ui_txt_msg.String = 'Processing';
+ drawnow;
+ end
+
+ function fcn_msn_end()
+ ui_txt_msg.String = 'Done';
+ drawnow;
+ end
+
+ function fcn_set_at_p_2_ui_lb_data(at_p)
+ n_at_p = size(at_p, 1);
+ items{1, n_at_p} = [];
+ UserData{1, n_at_p} = [];
+ for ik=1:n_at_p
+ s_at_p_ik = ['[', num2str(at_p(ik, 3), '%4.3f'), ', ', num2str(at_p(ik, 4), '%4.3f'), ...
+ ', ', num2str(at_p(ik, 5), '%5.2f'), ', ', num2str(at_p(ik, 6), '%5.2f'), ']'];
+
+ items{ik} = ['ik = ', num2str(ik, '%.3d'), ', at_p = ' s_at_p_ik];
+ UserData{ik} = ik;
+ end
+ ui_lb_data.String = items;
+ ui_lb_data.UserData = UserData;
+ end
+
+ function[im] = fcn_rescale_img(im_i)
+ alpha = str2double(ui_pu_exp.String{ui_pu_exp.Value});
+ if(~isnumeric(alpha))
+ alpha = 0.20;
+ end
+
+ alpha = max(0.01, abs(alpha));
+
+ im = abs(im_i).^alpha;
+ end
+
+ function fcn_set_nr_grid_0(n_data, nx, ny)
+ nr_grid.x = zeros(ny, nx, n_data, 'single');
+ nr_grid.y = zeros(ny, nx, n_data, 'single');
+ end
+
+ function st_opt = fcn_st_preproc_st_opt()
+ sigma = str2double(ui_edt_preproc_sigma.String);
+ if(~isnumeric(sigma))
+ sigma = 4.0;
+ end
+ st_opt.preproc_opt = ui_pu_preproc.Value;
+ st_opt.preproc_sigma = max(1.0, abs(sigma));
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ function fcn_show_ax_f_1(b_fimage_rc)
+ if(nargin==0)
+ b_fimage_rc = true;
+ end
+
+ if(b_fimage_rc)
+ fim = fcn_mean_abs_fdata_at(system_config, data, at_p);
+ end
+
+ % set axes
+ axes(ax_f(1));
+
+ % plot fimage
+ imagesc(fs_ax, fs_ay, fcn_rescale_img(fim));
+ axis image off;
+ colormap bone;
+
+ % plot circle
+ sigma_gt = str2double(ui_edt_sigma.String);
+ ilm_plot_circle(fs_x_c, fs_y_c, sigma_gt, 'red', 'f');
+
+ zoom(fz_t(1));
+ end
+
+ function fcn_show_ax_f_2(im, title_str)
+ % set axes
+ axes(ax_f(2));
+ imagesc(im);
+ axis image off;
+ colormap bone;
+ title(title_str);
+
+ bd = ilm_calc_borders_using_at_v(at_p);
+ p_rect_sel_atp = fcn_bd_2_p_rect_sel(bd);
+ ilm_plot_rectangle(p_rect_sel_atp, 'blue', 'f');
+
+ ilm_plot_rectangle(p_rect_sel, 'red', 'f');
+
+ zoom(fz_t(2));
+ end
+
+ function fcn_show_ax_f_3(im, title_str)
+ % set axes
+ axes(ax_f(3));
+ imagesc(im);
+ axis image off;
+ colormap bone;
+ title(title_str);
+
+ zoom(fz_t(3));
+ end
+
+ function fcn_plot_data_rg(im_r, A_r, txy_r, im_s, A_s, txy_s, p, sigma_gt, bd, title_ax_2, title_ax_3)
+ st_opt = fcn_st_preproc_st_opt();
+
+ [im_rp, im_sp] = ilm_pcf_data_tf(im_r, im_s, st_opt.preproc_opt, st_opt.preproc_sigma);
+
+ im_rp = ilc_tr_at_2d(system_config, im_rp, dx, dy, A_r, txy_r, 3, 0);
+
+ pcf = ilc_pcf_2d(system_config, im_rp, im_sp, dx, dy, A_s, txy_s, p, sigma_gt, bd, 3, 0);
+
+ im_r_plot = ilc_tr_at_2d(system_config, im_r, dx, dy, A_r, txy_r, 3, 0);
+ fcn_show_ax_f_2(im_r_plot, title_ax_2);
+
+ fcn_show_ax_f_3(pcf, title_ax_3);
+ end
+
+ function fcn_plot_data_nrg(im_r, im_s, p, sigma_gt, bd, title_ax_2, title_ax_3)
+
+ A = [1 0; 0 1];
+ txy = [0; 0];
+
+ st_opt = fcn_st_preproc_st_opt();
+ [im_rp, im_sp] = ilm_pcf_data_tf(im_r, im_s, st_opt.preproc_opt, st_opt.preproc_sigma);
+
+ pcf = ilc_pcf_2d(system_config, im_rp, im_sp, dx, dy, A, txy, p, sigma_gt, bd, 3, 0);
+
+ fcn_show_ax_f_2(im_r, title_ax_2);
+
+ fcn_show_ax_f_3(pcf, title_ax_3);
+ end
+
+ function cb_show_sel_ui_lb_data(source, event)
+ sigma_gt = str2double(ui_edt_sigma.String);
+
+ if(sigma_gt>sigma_g_max)
+ return
+ end
+
+ p = 0.05;
+ bd = fcn_p_rect_sel_2_bd(p_rect_sel);
+
+ fcn_msn_start();
+
+ ik_r = ui_lb_data.UserData{ui_lb_data.Value};
+ ik_s = ilm_ifelse(ik_r==n_data, ik_r-1, ik_r+1);
+
+ title_ax_2 = ['Image # ', num2str(ik_r)];
+ title_ax_3 = ['Pcf #= ', num2str(ik_r), ' - ', num2str(ik_s)];
+
+ if ui_cb_reg_typ.Value
+ im_r = double(data(:, :, ik_r));
+ [A_r, txy_r] = ilm_cvt_at_v_2_A_txy(at_p(ik_r, :));
+
+ im_s = double(data(:, :, ik_s));
+ [A_s, txy_s] = ilm_cvt_at_v_2_A_txy(at_p(ik_s, :));
+
+ fcn_plot_data_rg(im_r, A_r, txy_r, im_s, A_s, txy_s, p, sigma_gt, bd, title_ax_2, title_ax_3);
+ else
+ [Rx_i, Ry_i] = meshgrid(0:(nx-1), 0:(ny-1));
+
+ Rx = Rx_i + double(nr_grid.x(:, :, ik_r));
+ Ry = Ry_i + double(nr_grid.y(:, :, ik_r));
+ im_r = ilc_interp_rn_2d(system_config, double(data(:, :, ik_r)), Rx, Ry);
+
+ Rx = Rx_i + double(nr_grid.x(:, :, ik_s));
+ Ry = Ry_i + double(nr_grid.y(:, :, ik_s));
+ im_s = ilc_interp_rn_2d(system_config, double(data(:, :, ik_s)), Rx, Ry);
+
+ fcn_plot_data_nrg(im_r, im_s, p, sigma_gt, bd, title_ax_2, title_ax_3)
+ end
+
+ fcn_msn_end();
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ function fcn_show_rg_data(sigma_gt)
+ p = 0.05;
+ bd = fcn_p_rect_sel_2_bd(p_rect_sel);
+ for ik=2:n_data
+ if(b_stop)
+ break;
+ end
+
+ title_ax_2 = ['Image # ', num2str(ik-1)];
+ title_ax_3 = ['Pcf #= ', num2str(ilm_set_bound(ik-1, 1, n_data+1)), ' - ', num2str(ik)];
+
+ im_r = double(data(:, :, ik-1));
+ [A_r, txy_r] = ilm_cvt_at_v_2_A_txy(at_p(ik-1, :));
+
+ im_s = double(data(:, :, ik));
+ [A_s, txy_s] = ilm_cvt_at_v_2_A_txy(at_p(ik, :));
+
+ fcn_plot_data_rg(im_r, A_r, txy_r, im_s, A_s, txy_s, p, sigma_gt, bd, title_ax_2, title_ax_3)
+
+ ui_txt_msg.String = [num2str(100*ik/n_data, '%4.1f'), ' %'];
+
+ tm = str2double(ui_edt_time.String);
+ tm = ilm_ifelse(isnan(tm), 0.075, tm);
+ pause(tm);
+ end
+ b_stop = false;
+ end
+
+ function fcn_show_nr_data(sigma_gt)
+ if(~bb_nr)
+ nr_grid = ilm_at_p_2_nr_grid(at_p, nx, ny);
+ end
+
+ p = 0.05;
+ bd = fcn_p_rect_sel_2_bd(p_rect_sel);
+
+ [Rx_i, Ry_i] = meshgrid(0:(nx-1), 0:(ny-1));
+
+ for ik=2:n_data
+ if(b_stop)
+ break;
+ end
+
+ title_ax_2 = ['Image # ', num2str(ik-1)];
+ title_ax_3 = ['Pcf #= ', num2str(ilm_set_bound(ik-1, 1, n_data+1)), ' - ', num2str(ik)];
+
+ Rx = Rx_i + double(nr_grid.x(:, :, ik-1));
+ Ry = Ry_i + double(nr_grid.y(:, :, ik-1));
+ im_r = ilc_interp_rn_2d(system_config, double(data(:, :, ik-1)), Rx, Ry);
+
+ Rx = Rx_i + double(nr_grid.x(:, :, ik));
+ Ry = Ry_i + double(nr_grid.y(:, :, ik));
+ im_s = ilc_interp_rn_2d(system_config, double(data(:, :, ik)), Rx, Ry);
+
+ fcn_plot_data_nrg(im_r, im_s, p, sigma_gt, bd, title_ax_2, title_ax_3)
+
+ ui_txt_msg.String = [num2str(100*ik/n_data, '%4.1f'), ' %'];
+
+ tm = str2double(ui_edt_time.String);
+ tm = ilm_ifelse(isnan(tm), 0.075, tm);
+ pause(tm);
+ end
+ b_stop = false;
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ function cb_reset_txy(source, event)
+ at_p(:, 5:6) = at_p0(:, 5:6);
+
+ % fill in ui_lb_data
+ fcn_set_at_p_2_ui_lb_data(at_p);
+
+ % select item in ui_lb_data
+ cb_show_sel_ui_lb_data();
+
+ % plot fimage
+ fcn_show_ax_f_1(true);
+ end
+
+ function cb_reset_A(source, event)
+ at_p(:, 1) = 1;
+ at_p(:, 2:3) = 0;
+ at_p(:, 4) = 1;
+
+ % fill in ui_lb_data
+ fcn_set_at_p_2_ui_lb_data(at_p);
+
+ % select item in ui_lb_data
+ cb_show_sel_ui_lb_data();
+
+ % plot fimage
+ fcn_show_ax_f_1(true);
+ end
+
+ function cb_assign_A_txy(source, event)
+ fcn_msn_start();
+
+ nr_grid = ilm_at_p_2_nr_grid(at_p, nx, ny);
+ cb_show_sel_ui_lb_data();
+
+ fcn_msn_end();
+
+ bb_nr = true;
+ end
+
+ function cb_reset_data(source, event)
+ data = data_i;
+ n_data = ilm_nz_data(data);
+ [ny, nx, n_data] = ilm_size_data(data);
+ at_p = at_p0;
+
+ % reset nr_grid
+ fcn_set_nr_grid_0(n_data, nx, ny);
+
+ % fill in ui_lb_data
+ fcn_set_at_p_2_ui_lb_data(at_p);
+
+ % plot fimage
+ fcn_show_ax_f_1(true);
+
+ % select item in ui_lb_data
+ cb_show_sel_ui_lb_data();
+
+ p_rect_sel = [1, 1; nx, ny];
+
+ bb_nr = false;
+ end
+
+ function cb_stop(source, event)
+ b_stop = true;
+ end
+
+ function cb_preproc(source, event)
+ ui_edt_preproc_sigma.Enable = ilm_ifelse(ui_pu_preproc.Value==3, 'on', 'off');
+ cb_show_sel_ui_lb_data(source, event);
+ end
+
+ function cb_idx_ref(source, event)
+ idx_ref = ui_pu_idx_ref.Value;
+ at_p(:, 5:6) = at_p(:, 5:6) - at_p(idx_ref, 5:6);
+ cb_show_sel_ui_lb_data(source, event);
+ end
+
+ function cb_reg_typ(source, event)
+ if source.Value
+ ui_pb_show_data.String = 'Show rg data';
+ ui_pb_show_avg_data.String = 'Show avg rg data';
+ else
+ ui_pb_show_data.String = 'Show nrg data';
+ ui_pb_show_avg_data.String = 'Show avg nrg data';
+ end
+
+ cb_show_sel_ui_lb_data();
+ end
+
+ function cb_show_data(source, event)
+ sigma_gt = str2double(ui_edt_sigma.String);
+
+ if(sigma_gt>sigma_g_max)
+ return
+ end
+
+ fcn_msn_start();
+
+ if ui_cb_reg_typ.Value
+ fcn_show_rg_data(sigma_gt);
+ else
+ fcn_show_nr_data(sigma_gt);
+ end
+
+ cb_show_sel_ui_lb_data();
+
+ fcn_msn_end();
+ end
+
+ function cb_show_avg_data(source, event)
+ fcn_msn_start();
+
+ if ui_cb_reg_typ.Value
+ image_avg = ilm_mean_data_at(system_config, data, at_p, 3);
+ fig_n = 2;
+ title_str = 'Average image rigid registration';
+ else
+ image_avg = ilm_mean_data_nr_grid(system_config, data, nr_grid, 3);
+ fig_n = 3;
+ title_str = 'Average image non-rigid registration';
+ end
+
+ % set constant borders
+
+ bd = ilm_calc_borders_using_at_v(at_p);
+ image_avg = ilc_repl_bdr(image_avg, bd, 3);
+
+ figure(fig_n);
+ imagesc(image_avg);
+ axis image off;
+ colormap bone;
+ title(title_str);
+
+ fcn_msn_end();
+
+ figure(fig_n);
+ end
+
+ function bd = fcn_p_rect_sel_2_bd(p_rect_sel)
+ bd = [p_rect_sel(1, 1)-1, nx-p_rect_sel(2, 1), p_rect_sel(1, 2)-1, ny-p_rect_sel(2, 2)];
+ bd(1) = max(0, bd(1));
+ bd(2) = min(nx, bd(2));
+ bd(3) = max(0, bd(3));
+ bd(4) = min(ny, bd(4));
+ end
+
+ function p_rect = fcn_bd_2_p_rect_sel(bd)
+ p_rect = [bd(1)+1, nx-bd(2); bd(3)+1, ny-bd(4)].';
+ p_rect(1, 1) = max(1, p_rect(1, 1));
+ p_rect(2, 1) = min(nx, p_rect(2, 1));
+ p_rect(1, 2) = max(1, p_rect(1, 2));
+ p_rect(2, 2) = min(ny, p_rect(2, 2));
+ end
+
+ function bd = fcn_atp_p_rect_sel_2_bd(at_p, p_rect_sel)
+ bd = ilm_calc_borders_using_at_v(at_p);
+ bd_user = [p_rect_sel(1, 1)-1, nx-p_rect_sel(2, 1), p_rect_sel(1, 2)-1, ny-p_rect_sel(2, 2)];
+ bd = max(bd, bd_user);
+ end
+
+ function cb_crt_txy(opt)
+ sigma_gt = str2double(ui_edt_sigma.String);
+
+ if(sigma_gt>sigma_g_max)
+ return
+ end
+
+ fcn_msn_start();
+
+ idx_ref = ui_pu_idx_ref.Value;
+ at_p(:, 5:6) = at_p(:, 5:6) - at_p(idx_ref, 5:6);
+
+ rg_n_it = str2num(ui_edt_rg_n_it.String); %#ok
+ b_fit = true;
+ sigma_rt = ilm_sigma_g_2_sigma_r(nx, ny, sigma_gt);
+ radius = sigma_rt;
+ p = 0.05;
+
+ % calculate shifting between images
+ st_opt = fcn_st_preproc_st_opt();
+ bd = fcn_atp_p_rect_sel_2_bd(at_p, p_rect_sel);
+ at_p_r = ilm_fd_tr_2d_bi(system_config, data, p, sigma_gt, radius, bd, at_p, rg_n_it, b_fit, st_opt);
+
+ % center shifts
+ if idx_ref>0
+ if(opt==1)
+ at_p(:, 5) = at_p_r(:, 5) - at_p_r(idx_ref, 5);
+ elseif(opt==2)
+ at_p(:, 6) = at_p_r(:, 6) - at_p_r(idx_ref, 6);
+ else
+ at_p(:, 5:6) = at_p_r(:, 5:6) - at_p_r(idx_ref, 5:6);
+ end
+ else
+ at_p = ilm_center_tr_2d_using_at_v(at_p);
+ end
+
+ % fill in ui_lb_data
+ fcn_set_at_p_2_ui_lb_data(at_p);
+
+ % plot fimage
+ fcn_show_ax_f_1(ui_cb_rcfft.Value);
+
+ % select item in ui_lb_data
+ cb_show_sel_ui_lb_data();
+
+ fcn_msn_end();
+ end
+
+ function cb_crt_A_txy(source, event)
+ sigma_gt = str2double(ui_edt_sigma.String);
+
+ if(sigma_gt>sigma_g_max)
+ return
+ end
+
+ fcn_msn_start();
+
+ rg_n_it = str2num(ui_edt_rg_n_it.String); %#ok
+
+ % find affine transformation
+ at_p = ilm_run_rg_stem(system_config, data, p, sigma_gt, at_p, rg_n_it);
+
+ % fill in ui_lb_data
+ fcn_set_at_p_2_ui_lb_data(at_p);
+
+ % plot fimage
+ fcn_show_ax_f_1(ui_cb_rcfft.Value);
+
+ % show pcf
+ %fcn_show_rg_data(sigma_gt);
+
+ % select item in ui_lb_data
+ cb_show_sel_ui_lb_data();
+
+ fcn_msn_end();
+ end
+
+ function cb_crt_nr_grid(source, event)
+ fcn_msn_start();
+
+ sigma_gt = str2double(ui_edt_sigma.String);
+ sigma_r = 1/(2*pi*sigma_gt*min(1/nx, 1/ny));
+ alpha = str2double(ui_edt_alpha.String);
+
+ nrg_n_it_i = str2num(ui_edt_nrg_n_it_i.String); %#ok
+ nrg_n_it_o = str2num(ui_edt_nrg_n_it_o.String); %#ok
+
+ opt = ui_pu_opt.Value;
+
+ bd = fcn_atp_p_rect_sel_2_bd(at_p, p_rect_sel);
+ nr_grid = ilm_run_nr_stem(system_config, data, bd, alpha, sigma_r, nr_grid, nrg_n_it_i, nrg_n_it_o, opt);
+
+ fcn_msn_end();
+ end
+
+ function fcn_draw_circle_ax_f_1(bb_mouse_click)
+ C = get(ax_f(1), 'CurrentPoint');
+ sigma_gt = sqrt((C(1, 1)-fs_x_c)^2+(C(1, 2)-fs_y_c)^2);
+ sigma_rt = ilm_sigma_g_2_sigma_r(nx, ny, sigma_gt);
+
+ children = get(ax_f(1), 'Children');
+ if bb_mouse_click
+ delete(findobj(children, 'Type', 'Line'));
+
+ if(sigma_gt>sigma_g_max)
+ return
+ end
+ else
+ delete(findobj(children, 'Type', 'Line', '-and', 'Tag', 'm'));
+ end
+
+ axes(ax_f(1));
+ title(ax_f(1), ['sigma_g = ', num2str(sigma_gt, '%6.2f'), ' px. , sigma_r = ', num2str(sigma_rt, '%6.2f'), ' px.']);
+
+ if bb_mouse_click
+ ui_edt_sigma.String = num2str(sigma_gt, '%5.2f');
+
+ ilm_plot_circle(fs_x_c, fs_y_c, sigma_gt, 'red', 'f');
+
+ cb_show_sel_ui_lb_data();
+ else
+ ilm_plot_circle(fs_x_c, fs_y_c, sigma_gt, 'green', 'm');
+ end
+ end
+
+ function fcn_draw_rectangle_ax_f_2(bb_mouse_click)
+ C = get(ax_f(2), 'CurrentPoint');
+ C = [max(1, min(nx, round(C(1, 1)))), max(1, min(ny, round(C(1, 2))))];
+
+ d = abs(p_rect_sel-C);
+ [~, ii] = min(d(:));
+
+ if(bb_ctrl_kpf)
+ if(ii<=2)
+ bx = ilm_ifelse(ii==1, C(1), nx-C(1));
+ bx = round((nx-ilm_pn_fact(nx-2*bx, 4))/2);
+ ix_0 = bx+1;
+ ix_e = nx-bx;
+ p_rect_sel(:, 1) = [ix_0;ix_e];
+ else
+ by = ilm_ifelse(ii==3, C(2), ny-C(2));
+ by = round((ny-ilm_pn_fact(ny-2*by, 4))/2);
+ iy_0 = by+1;
+ iy_e = ny-by;
+ p_rect_sel(:, 2) = [iy_0;iy_e];
+ end
+ elseif(bb_shift_kpf)
+ if(ii==1)
+ ix_e = p_rect_sel(2, 1);
+ ix_0 = round(ix_e - ilm_pn_fact(round(ix_e-C(1)+1))+1);
+ p_rect_sel(1, 1) = ilm_set_bound(ix_0, 1, nx);
+ elseif(ii==2)
+ ix_0 = p_rect_sel(1, 1);
+ ix_e = round(ilm_pn_fact(round(C(1)-ix_0+1))+ ix_0-1);
+ p_rect_sel(2, 1) = ilm_set_bound(ix_e, 1, nx);
+ elseif(ii==3)
+ iy_e = p_rect_sel(2, 2);
+ iy_0 = round(iy_e - ilm_pn_fact(round(iy_e-C(2)+1))+1);
+ p_rect_sel(1, 2) = ilm_set_bound(iy_0, 1, ny);
+ else
+ iy_0 = p_rect_sel(1, 2);
+ iy_e = round(ilm_pn_fact(round(C(2)-iy_0+1))+ iy_0-1);
+ p_rect_sel(2, 2) = ilm_set_bound(iy_e, 1, ny);
+ end
+ end
+
+ children = get(ax_f(2), 'Children');
+ if bb_mouse_click
+ delete(findobj(children, 'Type', 'Line'));
+ else
+ delete(findobj(children, 'Type', 'Line', '-and', 'Tag', 'm'));
+ end
+
+ axes(ax_f(2));
+ if bb_mouse_click
+ cb_show_sel_ui_lb_data();
+ else
+ ilm_plot_rectangle(p_rect_sel, 'green', 'm');
+ end
+
+ ui_pb_data_info.String = fcn_str_data_info(p_rect_sel);
+ end
+
+ function cb_mouse_move(source, event)
+ if (bb_shift_kpf || bb_ctrl_kpf)
+ b_ax_f = ilm_gui_is_over_object(source, ax_f);
+
+ if(b_ax_f(1))
+ if(bb_shift_kpf)
+ fcn_draw_circle_ax_f_1(false);
+ children = get(ax_f(2), 'Children');
+ delete(findobj(children, 'Type', 'Line', '-and', 'Tag', 'm'));
+ end
+ elseif(b_ax_f(2))
+ if((bb_shift_kpf || bb_ctrl_kpf)&& ui_rb_select.Value)
+ fcn_draw_rectangle_ax_f_2(false);
+ children = get(ax_f(1), 'Children');
+ delete(findobj(children, 'Type', 'Line', '-and', 'Tag', 'm'));
+ end
+ end
+ end
+ end
+
+ function cb_mouse_click(source, event)
+ if (bb_shift_kpf || bb_ctrl_kpf)
+ b_ax_f = ilm_gui_is_over_object(source, ax_f);
+
+ if(b_ax_f(1))
+ if(bb_shift_kpf)
+ fcn_draw_circle_ax_f_1(true);
+ end
+ elseif((bb_shift_kpf || bb_ctrl_kpf)&& ui_rb_select.Value)
+ fcn_draw_rectangle_ax_f_2(true);
+ end
+ end
+ end
+
+ function cb_press_key(obj, event)
+ if(strcmpi(event.Key, 'delete'))
+ b_ui_lb_data = ilm_gui_is_over_object(obj, ui_lb_data);
+ if(~b_ui_lb_data)
+ return
+ end
+
+ fcn_msn_start();
+
+ ik_del = ui_lb_data.UserData{ui_lb_data.Value};
+ data(:, :, ik_del) = [];
+ n_data = ilm_nz_data(data);
+
+ at_p(ik_del, :) = [];
+ nr_grid.x(:, :, ik_del) = [];
+ nr_grid.y(:, :, ik_del) = [];
+
+ % fill in ui_lb_data
+ fcn_set_at_p_2_ui_lb_data(at_p);
+ ui_lb_data.Value = min(max(1, ik_del), n_data);
+
+ % select item in ui_lb_data
+ cb_show_sel_ui_lb_data();
+
+ % plot fimage
+ fcn_show_ax_f_1(ui_cb_rcfft.Value);
+
+ fcn_msn_end();
+ end
+
+ bb_shift_kpf = strcmpi(event.Modifier, 'shift');
+ bb_shift_kpf = ilm_ifelse(isempty(bb_shift_kpf), 0, bb_shift_kpf);
+
+ bb_ctrl_kpf = strcmpi(event.Modifier, 'control');
+ bb_ctrl_kpf = ilm_ifelse(isempty(bb_ctrl_kpf), 0, bb_ctrl_kpf);
+ end
+
+ function cb_release_key(source, event)
+ bb_shift_kpf = 0;
+ bb_ctrl_kpf = 0;
+ end
+
+ function cb_zoom(source, event)
+ fz = 1;
+ if(event.VerticalScrollCount<0)
+ fz = 1.5;
+ elseif(event.VerticalScrollCount>0)
+ fz = 1/1.5;
+ end
+
+ b_ax_f = ilm_gui_is_over_object(source, ax_f);
+
+ if(b_ax_f(1))
+ fz_t(1) = fz_t(1)*fz;
+ axes(ax_f(1));
+ zoom(fz);
+ elseif(b_ax_f(2))
+ fz_t(2) = fz_t(2)*fz;
+ axes(ax_f(2));
+ zoom(fz);
+ elseif(b_ax_f(3))
+ fz_t(3) = fz_t(3)*fz;
+ axes(ax_f(3));
+ zoom(fz);
+ end
+ end
+
+ function cb_close(source, event)
+ b_stop = true;
+
+ if(~bb_nr)
+ nr_grid = ilm_at_p_2_nr_grid(at_p, nx, ny);
+ end
+
+ delete(fh);
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_hist.m b/matlab_functions/ilm_hist.m
new file mode 100755
index 00000000..de6ed76a
--- /dev/null
+++ b/matlab_functions/ilm_hist.m
@@ -0,0 +1,25 @@
+function[h, h_min, h_max, dh] = ilm_hist(x, n_bin, n_left_space, n_right_space)
+ if nargin<4
+ n_right_space = 0;
+ end
+
+ if nargin<3
+ n_left_space = 0;
+ end
+
+ n_bin_r = n_bin - n_left_space - n_right_space;
+
+ x = double(x);
+ h_min = min(x);
+ h_max = max(x);
+ dh = (h_max - h_min)/n_bin_r;
+ idx = floor((x - h_min)/dh)+1;
+ idx = n_left_space + min(n_bin_r, max(1, idx));
+
+ h = zeros(n_bin, 1, 'double');
+ n_idx = numel(idx);
+ for ix=1:n_idx
+ ik_s = idx(ix);
+ h(ik_s) = h(ik_s) + 1;
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_ifelse.m b/matlab_functions/ilm_ifelse.m
old mode 100644
new mode 100755
index e815d61d..672a9759
--- a/matlab_functions/ilm_ifelse.m
+++ b/matlab_functions/ilm_ifelse.m
@@ -1,7 +1,7 @@
-function [c] = ilm_ifelse(bb, a, b)
- if(bb)
- c = a;
- else
- c = b;
- end
+function [c] = ilm_ifelse(bb, a, b)
+ if(bb) %#ok
+ c = a;
+ else
+ c = b;
+ end
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_lambda.m b/matlab_functions/ilm_lambda.m
new file mode 100755
index 00000000..0475b1a3
--- /dev/null
+++ b/matlab_functions/ilm_lambda.m
@@ -0,0 +1,6 @@
+% Input: E_0(keV), Output:lambda Angstrom
+function [lambda] = ilm_lambda(E_0)
+ emass = 510.99906; % electron rest mass in keV
+ hc = 12.3984244; % Planck's const x speed of light
+ lambda = hc/sqrt(E_0*(2.0*emass + E_0));
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_lcwt.m b/matlab_functions/ilm_lcwt.m
new file mode 100755
index 00000000..f6a75404
--- /dev/null
+++ b/matlab_functions/ilm_lcwt.m
@@ -0,0 +1,38 @@
+function [im_o]= ilm_lcwt(im_i, sigma)
+ n = 2*ceil(sigma)+1;
+ kn = ones(n,n);
+ kn = kn/sum(kn(:));
+
+ im_o = (im_i - mean(im_i, 'all'))/std(im_i, 0, 'all');
+
+ im_mean_0 = conv2(im_o, kn,'same');
+ im_mean = imgaussfilt(im_mean_0, sigma, 'FilterSize', 2*ceil(2.5*sigma)+1, 'Padding', 'symmetric');
+
+ im_std_0 = (im_o - im_mean).^2;
+ im_std_0 = conv2(im_std_0, kn, 'same');
+ im_std_0 = max(0.01, im_std_0);
+ im_std = imgaussfilt(im_std_0, sigma, 'FilterSize', 2*ceil(2.5*sigma)+1, 'Padding', 'symmetric');
+
+ if 0
+ figure(1);clf;
+ subplot(2, 2, 1);
+ imagesc(im_mean_0);
+ axis image off;
+ colorbar;
+ subplot(2, 2, 2);
+ imagesc(im_mean);
+ axis image off;
+ colorbar;
+ subplot(2, 2, 3);
+ imagesc(im_std_0);
+ axis image off;
+ colorbar;
+ subplot(2, 2, 4);
+ imagesc(im_std);
+ axis image off;
+ colorbar;
+ end
+
+ im_o = (im_o - im_mean)./im_std;
+ im_o = (im_o - mean(im_o, 'all'))/std(im_o, 0, 'all');
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_mex.m b/matlab_functions/ilm_mex.m
old mode 100644
new mode 100755
index 62c11c9a..07f13f30
--- a/matlab_functions/ilm_mex.m
+++ b/matlab_functions/ilm_mex.m
@@ -1,222 +1,221 @@
-function [] = ilm_mex(option, m_file, src, varargin)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%% Format input data %%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if(strcmp('../', src(1:3)))
- [pathstr, ~, ~] = fileparts(pwd);
- src = [pathstr, filesep, src(4:end)];
- else
- [pathstr, ~, ~] = fileparts(src);
- end
-
- nVarargs = length(varargin);
- for k = 1:nVarargs
- varargin{k} = strcat(src, filesep, char(varargin{k}));
- end
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%% set cuda path %%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- CUDA_PATH = getenv('CUDA_PATH');
-
-% CUDA_PATH = '';
-
- if(isempty(CUDA_PATH))
- if(ispc)
- CUDA_PATH = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0';
- elseif(ismac)
- CUDA_PATH = '/Developer/NVIDIA/CUDA-10.0';
- else
- CUDA_PATH = '/usr/local/cuda-10.0';
- end
- end
-
- CUDA_PATH = ilm_replace_filesep(CUDA_PATH);
-
- %%%%%%%%%%%%%%%%%%%% get cuda version %%%%%%%%%%%%%%%%%%%%%%%
- idx = strfind(CUDA_PATH, filesep);
- CUDA_VERSION = CUDA_PATH((idx(end)+1):end);
- CUDA_VERSION = CUDA_VERSION(~isletter(CUDA_VERSION));
- CUDA_VERSION = erase(CUDA_VERSION, {'-', '_'});
-
- if isempty(CUDA_VERSION)
- CUDA_VERSION_PATH = [CUDA_PATH, filesep,'version.txt'];
- FID = fopen(CUDA_VERSION_PATH);
- data = textscan(FID,'%s');
- fclose(FID);
- stringData = string(data{:});
- stringData = strsplit(stringData{3}, '.');
- CUDA_VERSION = [stringData{1}, '.', stringData{2}];
- end
-
- if(~exist(CUDA_PATH, 'dir'))
- disp('Error - Cuda path not found')
- end
-
- CUDA_BIN_PATH = [CUDA_PATH, filesep, 'bin'];
- CUDA_INC_PATH = [CUDA_PATH, filesep, 'include'];
- if(ispc)
- CUDA_LIB_PATH = [CUDA_PATH, filesep, 'lib', filesep, 'x64'];
- elseif(ismac)
- CUDA_LIB_PATH = [CUDA_PATH, filesep, 'lib64'];
- else
- CUDA_LIB_PATH = [CUDA_PATH, filesep, 'lib64'];
- end
- CUDA_LIBS = '-lcudart -lcufft -lcublas';
-
- %%%%%%%%%%%%%%% set NVCC compiler location %%%%%%%%%%%%%%%%%%
- setenv('CUDA_PATH', CUDA_PATH);
- setenv('CUDA_BIN_PATH', CUDA_BIN_PATH);
- setenv('CUDA_LIB_PATH', CUDA_LIB_PATH);
- setenv('CUDA_NVVM_PATH', [CUDA_PATH, filesep, 'nvvm']);
- setenv('MW_NVCC_PATH', CUDA_BIN_PATH);
-
- %%%%%%%%%%%%%%%%%%% set card architecture %%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%% https://developer.nvidia.com/cuda-gpus %%%%%%%%%%
- % https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- CUDA_VERSION_D = str2double(CUDA_VERSION);
- CARD_30="-gencode=arch=compute_30,code=sm_30";
- CARD_35="-gencode=arch=compute_35,code=\"sm_35,compute_35\"";
- CARD_50="-gencode=arch=compute_50,code=\"sm_50,compute_50\"";
- CARD_60="-gencode=arch=compute_60,code=\"sm_60,compute_60\"";
- CARD_70="-gencode=arch=compute_70,code=\"sm_70,compute_70\"";
- CARD_75="-gencode=arch=compute_75,code=\"sm_75,compute_75\"";
- CARD_86="-gencode=arch=compute_86,code=\"sm_86,compute_86\"";
- CARD_87="-gencode=arch=compute_87,code=\"sm_87,compute_87\"";
- CARD_MULT = join([CARD_30, CARD_35, CARD_50, CARD_60, CARD_70, CARD_75], ' ');
-
- if CUDA_VERSION_D >= 11.0
- CARD_MULT = join([CARD_MULT CARD_86, CARD_87], ' ');
- end
-
- if 1
- % Get compute capabilities of all available devices
- gpu_comp_cap = zeros(1,gpuDeviceCount);
- ARCH_FLAGS = "";
- for i_dev = 1:gpuDeviceCount
- gpu_comp_cap(i_dev) = str2double(replace(gpuDevice(i_dev).ComputeCapability,'.',''));
- end
- % avoid duplicate compiler settings
- [~, id] = unique(gpu_comp_cap,'stable');
-
- % Add architecture flags for all necessary compute capabilities
- for i_dev = 1:numel(id)
- gpu_comp_cap_str = num2str(gpu_comp_cap(id(i_dev)));
- if gpu_comp_cap(id(i_dev)) < 35
- ARCH_FLAGS = join([ARCH_FLAGS, ['-gencode=arch=compute_' gpu_comp_cap_str ',code=sm_' gpu_comp_cap_str]]);
- else
- if gpu_comp_cap(id(i_dev)) > 75 && CUDA_VERSION_D < 11.0
- warning([gpuDevice(id(i_dev)).Name ' has compute capability ' gpuDevice(id(i_dev)).ComputeCapability ' but the Cuda version ' CUDA_VERSION ' does not support it. Attempting to compile for compute capability 7.5.']);
- gpu_comp_cap_str = '75';
- end
- ARCH_FLAGS = join([ARCH_FLAGS, ['-gencode=arch=compute_' gpu_comp_cap_str ',code=\"sm_' gpu_comp_cap_str ',compute_' gpu_comp_cap_str '\"']]);
- end
- end
- else
- ARCH_FLAGS = CARD_MULT;
- end
-
- %%%%%%%%%%%%%%% read template mex_cuda file %%%%%%%%%%%%%%%%%
- if(ispc)
- mex_cuda_filename = 'mex_CUDA_win64.xml';
- elseif(ismac)
- mex_cuda_filename = 'mex_CUDA_maci64.xml';
- else
- mex_cuda_filename = 'mex_CUDA_glnxa64.xml';
- end
-
- %%%%%%%%%%%%%%%%%% read mex_cuda template %%%%%%%%%%%%%%%%%%%%
- mex_cuda_file_in = [pathstr, filesep, 'matlab_functions', filesep, mex_cuda_filename];
- mex_cuda = fileread(mex_cuda_file_in);
-
- %%%%%%%%%%%%% replace string in mex_cuda file %%%%%%%%%%%%%%%%
- mex_cuda = strrep(mex_cuda, 'XXX_CUDA_VER', CUDA_VERSION);
- mex_cuda = strrep(mex_cuda, 'XXX_ARCH_FLAGS', ARCH_FLAGS);
-
- %%%%%%%%%%%%%%%%%%% save mex_cuda file %%%%%%%%%%%%%%%%%%%%%%
- mex_cuda_file_out = [pwd, filesep, mex_cuda_filename];
- fid = fopen(mex_cuda_file_out, 'w+');
- fwrite(fid, mex_cuda);
- fclose(fid);
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%% set library path %%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if(ispc)
- % OS = Windows 10
- FFTW_LIB_PATH = src;
- FFTW_LIBS = '-lfftw3f-3 -lfftw3-3';
-
- BLAS_LIB_PATH = src;
- BLAS_LIBS = '-lblas';
-
- LAPACK_LIB_PATH = src;
- LAPACK_LIBS = '-llapack';
-
- elseif(ismac)
- % OS = /usr/bin/ld:
- FFTW_LIB_PATH = [];
- FFTW_LIBS = '-lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads';
- BLAS_LIB_PATH = [];
- BLAS_LIBS = '-lblas';
-
- LAPACK_LIB_PATH = [];
- LAPACK_LIBS = '-llapack';
- else
- % OS = scientific linux
- %FFTW_LIB = '-/opt/local/lib';
- %FFTW_LIBS = '-lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads';
- %LAPACK_LIB = '/opt/local/lib';
- %BLAS_LAPACK_LIBS = '-lblas -llapack';
-
- % OS = ubuntu
- FFTW_LIB_PATH = '/usr/lib/x86_64-linux-gnu';
- FFTW_LIBS = '-lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads';
-
- BLAS_LIB_PATH = '/usr/lib/x86_64-linux-gnu/blas';
- BLAS_LIBS = '-lblas';
-
- LAPACK_LIB_PATH = '/usr/lib/x86_64-linux-gnu/lapack';
- LAPACK_LIBS = '-llapack';
- end
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- BLAS_LIBS = '-lmwblas';
- LAPACK_LIBS = '-lmwlapack ';
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- if(~exist(FFTW_LIB_PATH, 'dir'))
- disp('FFTW path not found')
- end
-
- if(~exist(BLAS_LIB_PATH, 'dir'))
- disp('Blas path not found')
- end
-
- if(~exist(LAPACK_LIB_PATH, 'dir'))
- disp('Lapack path not found')
- end
-
-% if(~ispc && ~ismac)
-% mex_cuda_filename = 'nvcc_g++.xml';
-% end
-
- INCLUDE = ['-I"', CUDA_INC_PATH, '" -I"', src, '"'];
- LIBRARY = ['-L"', CUDA_LIB_PATH, '" ', CUDA_LIBS, ' -L"', FFTW_LIB_PATH, '" ', FFTW_LIBS, ' -L"', BLAS_LIB_PATH, '" ', BLAS_LIBS, ' -L"', LAPACK_LIB_PATH, '" ', LAPACK_LIBS];
- mex_comand = ['mex -R2017b -f ', mex_cuda_filename, ' -v'];
-
- if (strcmpi(option, 'debug'))
- mex_comand = [mex_comand, ' -g'];
- end
-
- OUTDIR = ['-outdir ..', filesep, 'mex_bin'];
-
- textcommands = strjoin({mex_comand, OUTDIR, INCLUDE, LIBRARY, m_file, strjoin(varargin)});
- disp(textcommands);
- eval(textcommands);
-
- delete(mex_cuda_file_out);
-end
+function [] = ilm_mex(option, m_file, src, varargin)
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%% Format input data %%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ if(strcmp('../', src(1:3)))
+ [pathstr, ~, ~] = fileparts(pwd);
+ src = [pathstr, filesep, src(4:end)];
+ else
+ [pathstr, ~, ~] = fileparts(src);
+ end
+
+ nVarargs = length(varargin);
+ for k = 1:nVarargs
+ varargin{k} = strcat(src, filesep, char(varargin{k}));
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%% set cuda path %%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ CUDA_PATH = getenv('CUDA_PATH');
+
+% CUDA_PATH = '';
+
+ if(isempty(CUDA_PATH))
+ if(ispc)
+ CUDA_PATH = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0';
+ elseif(ismac)
+ CUDA_PATH = '/Developer/NVIDIA/CUDA-10.0';
+ else
+ CUDA_PATH = '/usr/local/cuda-10.0';
+ end
+ end
+
+ CUDA_PATH = ilm_replace_filesep(CUDA_PATH);
+
+ %%%%%%%%%%%%%%%%%%%% get cuda version %%%%%%%%%%%%%%%%%%%%%%%
+ idx = strfind(CUDA_PATH, filesep);
+ CUDA_VERSION = CUDA_PATH((idx(end)+1):end);
+ CUDA_VERSION = CUDA_VERSION(~isletter(CUDA_VERSION));
+ CUDA_VERSION = erase(CUDA_VERSION, {'-', '_'});
+
+ if isempty(CUDA_VERSION)
+ CUDA_VERSION_PATH = [CUDA_PATH, filesep,'version.txt'];
+ FID = fopen(CUDA_VERSION_PATH);
+ data = textscan(FID,'%s');
+ fclose(FID);
+ stringData = string(data{:});
+ stringData = strsplit(stringData{3}, '.');
+ CUDA_VERSION = [stringData{1}, '.', stringData{2}];
+ end
+
+ if(~exist(CUDA_PATH, 'dir'))
+ disp('Error - Cuda path not found')
+ end
+
+ CUDA_BIN_PATH = [CUDA_PATH, filesep, 'bin'];
+ CUDA_INC_PATH = [CUDA_PATH, filesep, 'include'];
+ if(ispc)
+ CUDA_LIB_PATH = [CUDA_PATH, filesep, 'lib', filesep, 'x64'];
+ elseif(ismac)
+ CUDA_LIB_PATH = [CUDA_PATH, filesep, 'lib64'];
+ else
+ CUDA_LIB_PATH = [CUDA_PATH, filesep, 'lib64'];
+ end
+ CUDA_LIBS = '-lcudart -lcufft -lcublas';
+
+ %%%%%%%%%%%%%%% set NVCC compiler location %%%%%%%%%%%%%%%%%%
+ setenv('CUDA_PATH', CUDA_PATH);
+ setenv('CUDA_BIN_PATH', CUDA_BIN_PATH);
+ setenv('CUDA_LIB_PATH', CUDA_LIB_PATH);
+ setenv('CUDA_NVVM_PATH', [CUDA_PATH, filesep, 'nvvm']);
+ setenv('MW_NVCC_PATH', CUDA_BIN_PATH);
+
+ %%%%%%%%%%%%%%%%%%% set card architecture %%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%% https://developer.nvidia.com/cuda-gpus %%%%%%%%%%
+ % https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ CUDA_VERSION_D = str2double(CUDA_VERSION);
+ CARD_30="-gencode=arch=compute_30,code=sm_30";
+ CARD_35="-gencode=arch=compute_35,code=\"sm_35,compute_35\"";
+ CARD_50="-gencode=arch=compute_50,code=\"sm_50,compute_50\"";
+ CARD_60="-gencode=arch=compute_60,code=\"sm_60,compute_60\"";
+ CARD_70="-gencode=arch=compute_70,code=\"sm_70,compute_70\"";
+ CARD_75="-gencode=arch=compute_75,code=\"sm_75,compute_75\"";
+ CARD_86="-gencode=arch=compute_86,code=\"sm_86,compute_86\"";
+ CARD_87="-gencode=arch=compute_87,code=\"sm_87,compute_87\"";
+ CARD_MULT = join([CARD_30, CARD_35, CARD_50, CARD_60, CARD_70, CARD_75], ' ');
+
+ if CUDA_VERSION_D >= 11.0
+ CARD_MULT = join([CARD_MULT CARD_86, CARD_87], ' ');
+ end
+
+ if 1
+ % Get compute capabilities of all available devices
+ gpu_comp_cap = zeros(1,gpuDeviceCount);
+ ARCH_FLAGS = "";
+ for i_dev = 1:gpuDeviceCount
+ gpu_comp_cap(i_dev) = str2double(replace(gpuDevice(i_dev).ComputeCapability,'.',''));
+ end
+ % avoid duplicate compiler settings
+ [~, id] = unique(gpu_comp_cap,'stable');
+
+ % Add architecture flags for all necessary compute capabilities
+ for i_dev = 1:numel(id)
+ gpu_comp_cap_str = num2str(gpu_comp_cap(id(i_dev)));
+ if gpu_comp_cap(id(i_dev)) < 35
+ ARCH_FLAGS = join([ARCH_FLAGS, ['-gencode=arch=compute_' gpu_comp_cap_str ',code=sm_' gpu_comp_cap_str]]);
+ else
+ if gpu_comp_cap(id(i_dev)) > 75 && CUDA_VERSION_D < 11.0
+ warning([gpuDevice(id(i_dev)).Name ' has compute capability ' gpuDevice(id(i_dev)).ComputeCapability ' but the Cuda version ' CUDA_VERSION ' does not support it. Attempting to compile for compute capability 7.5.']);
+ gpu_comp_cap_str = '75';
+ end
+ ARCH_FLAGS = join([ARCH_FLAGS, ['-gencode=arch=compute_' gpu_comp_cap_str ',code=\"sm_' gpu_comp_cap_str ',compute_' gpu_comp_cap_str '\"']]);
+ end
+ end
+ else
+ ARCH_FLAGS = CARD_MULT;
+ end
+
+ %%%%%%%%%%%%%%% read template mex_cuda file %%%%%%%%%%%%%%%%%
+ if(ispc)
+ mex_cuda_filename = 'mex_CUDA_win64.xml';
+ elseif(ismac)
+ mex_cuda_filename = 'mex_CUDA_maci64.xml';
+ else
+ mex_cuda_filename = 'mex_CUDA_glnxa64.xml';
+ end
+
+ %%%%%%%%%%%%%%%%%% read mex_cuda template %%%%%%%%%%%%%%%%%%%%
+ mex_cuda_file_in = [pathstr, filesep, 'matlab_functions', filesep, mex_cuda_filename];
+ mex_cuda = fileread(mex_cuda_file_in);
+
+ %%%%%%%%%%%%% replace string in mex_cuda file %%%%%%%%%%%%%%%%
+ mex_cuda = strrep(mex_cuda, 'XXX_CUDA_VER', CUDA_VERSION);
+ mex_cuda = strrep(mex_cuda, 'XXX_ARCH_FLAGS', ARCH_FLAGS);
+
+ %%%%%%%%%%%%%%%%%%% save mex_cuda file %%%%%%%%%%%%%%%%%%%%%%
+ mex_cuda_file_out = [pwd, filesep, mex_cuda_filename];
+ fid = fopen(mex_cuda_file_out, 'w+');
+ fwrite(fid, mex_cuda);
+ fclose(fid);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%% set library path %%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ if(ispc)
+ % OS = Windows 10
+ FFTW_LIB_PATH = src;
+ FFTW_LIBS = '-lfftw3f-3 -lfftw3-3';
+
+ BLAS_LIB_PATH = src;
+ BLAS_LIBS = '-lblas';
+
+ LAPACK_LIB_PATH = src;
+ LAPACK_LIBS = '-llapack';
+
+ elseif(ismac)
+ % OS = Windows 10
+ FFTW_LIB_PATH = [];
+ FFTW_LIBS = '-lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads';
+ BLAS_LIB_PATH = [];
+ BLAS_LIBS = '-lblas';
+
+ LAPACK_LIB_PATH = [];
+ LAPACK_LIBS = '-llapack';
+ else
+ % OS = scientific linux
+ %FFTW_LIB = '-/opt/local/lib';
+ %FFTW_LIBS = '-lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads';
+ %LAPACK_LIB = '/opt/local/lib';
+ %BLAS_LAPACK_LIBS = '-lblas -llapack';
+
+ % OS = ubuntu
+ FFTW_LIB_PATH = '/usr/lib/x86_64-linux-gnu';
+ FFTW_LIBS = '-lfftw3f -lfftw3 -lfftw3f_threads -lfftw3_threads';
+
+ BLAS_LIB_PATH = '/usr/lib/x86_64-linux-gnu';
+ BLAS_LIBS = '-lblas';
+
+ LAPACK_LIB_PATH = '/usr/lib/x86_64-linux-gnu';
+ LAPACK_LIBS = '-llapack';
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ BLAS_LIBS = '-lmwblas';
+ LAPACK_LIBS = '-lmwlapack ';
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ if(~exist(FFTW_LIB_PATH, 'dir'))
+ disp('FFTW path not found')
+ end
+
+ if(~exist(BLAS_LIB_PATH, 'dir'))
+ disp('Blas path not found')
+ end
+
+ if(~exist(LAPACK_LIB_PATH, 'dir'))
+ disp('Lapack path not found')
+ end
+
+% if(~ispc && ~ismac)
+% mex_cuda_filename = 'nvcc_g++.xml';
+% end
+
+ INCLUDE = ['-I"', CUDA_INC_PATH, '" -I"', src, '"'];
+ LIBRARY = ['-L"', CUDA_LIB_PATH, '" ', CUDA_LIBS, ' -L"', FFTW_LIB_PATH, '" ', FFTW_LIBS, ' -L"', BLAS_LIB_PATH, '" ', BLAS_LIBS, ' -L"', LAPACK_LIB_PATH, '" ', LAPACK_LIBS];
+ mex_comand = ['mex -R2018a -f ', mex_cuda_filename, ' -v'];
+ if (strcmpi(option, 'debug'))
+ mex_comand = [mex_comand, ' -g'];
+ end
+
+ OUTDIR = ['-outdir ..', filesep, 'mex_bin'];
+
+ textcommands = strjoin({mex_comand, OUTDIR, INCLUDE, LIBRARY, m_file, strjoin(varargin)});
+ disp(textcommands);
+ eval(textcommands);
+
+ delete(mex_cuda_file_out);
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_mrad_2_rAng.m b/matlab_functions/ilm_mrad_2_rAng.m
old mode 100644
new mode 100755
index 31f236eb..0ce18750
--- a/matlab_functions/ilm_mrad_2_rAng.m
+++ b/matlab_functions/ilm_mrad_2_rAng.m
@@ -2,6 +2,6 @@
function [rAng] = ilm_mrad_2_rAng(E_0, theta)
emass = 510.99906; % electron rest mass in keV
hc = 12.3984244; % Planck's const x speed of light
- lambda = hc./sqrt(E_0.*(2.0*emass + E_0));
- rAng = theta*1e-03./lambda;
-end
+ lambda = hc/sqrt(E_0*(2.0*emass + E_0));
+ rAng = theta*1e-03/lambda;
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_pcf_2d.m b/matlab_functions/ilm_pcf_2d.m
new file mode 100755
index 00000000..58709203
--- /dev/null
+++ b/matlab_functions/ilm_pcf_2d.m
@@ -0,0 +1,33 @@
+function[pcf] = ilm_pcf_2d(system_config, im_r, im_s, dx, dy, sigma_g_px)
+ [ny, nx] = size(im_r, [1, 2]);
+ bsx = nx*dx;
+ bsy = ny*dy;
+ sigma_g = sigma_g_px*min(1/bsx, 1/bsy);
+
+ [~, ~, g2] = ilm_fs_grid_2d(nx, ny, bsx, bsy, 1);
+ M = exp(-0.5*g2/sigma_g^2);
+
+ fpcf = conj(fft2(fftshift(im_r))).*fft2(fftshift(im_s));
+ fpcf = M.*exp(1i*angle(fpcf));
+ pcf = ifftshift(real(ifft2(fpcf)));
+
+ if 0
+ figure(2);clf;
+ subplot(2, 2, 1);
+ imagesc(im_r);
+ axis image;
+ colormap jet;
+ subplot(2, 2, 2);
+ imagesc(im_s);
+ axis image;
+ colormap jet;
+ subplot(2, 2, 3);
+ imagesc(M);
+ axis image;
+ colormap jet;
+ subplot(2, 2, 4);
+ imagesc(pcf);
+ axis image;
+ colormap jet;
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_pcf_2d_wd_bd_tf.m b/matlab_functions/ilm_pcf_2d_wd_bd_tf.m
new file mode 100755
index 00000000..17bacbdc
--- /dev/null
+++ b/matlab_functions/ilm_pcf_2d_wd_bd_tf.m
@@ -0,0 +1,40 @@
+function [im_o] = ilm_pcf_2d_wd_bd_tf(system_config, im_i, dx, dy, A, txy, p, bd_px)
+ [ny, nx] = size(im_i, [1, 2]);
+
+ im_o = ilm_apply_af_tf_2d(system_config, im_i, dx, dy, A, txy, 0);
+
+ rect = ilm_bd_2_rect(nx, ny, bd_px);
+ rect = max(1, round(rect));
+ p_c = mean(rect, 1);
+
+ radius_x = 0.5*(nx-bd_px(1)-bd_px(2))*(1-p);
+ radius_y = 0.5*(ny-bd_px(3)-bd_px(4))*(1-p);
+ rx = (0:1:(nx-1)) - p_c(1);
+ ry = (0:1:(ny-1)).' - p_c(2);
+ n = 8;
+
+ fx = 1./(1 + (rx/radius_x).^(2*n));
+ fx_sft = max(fx(1), fx(end));
+ fx = (fx - fx_sft)/(0.5-fx_sft);
+ fx = max(0, min(1.0, fx));
+ fy = 1./(1 + (ry/radius_y).^(2*n));
+ fy_sft = max(fy(1), fy(end));
+ fy = (fy - fy_sft)/(0.5-fy_sft);
+ fy = max(0, min(1.0, fy));
+
+ im_o = fx.*fy.*im_o;
+
+ if 0
+
+ figure(1);clf;
+ subplot(1, 2, 1);
+ imagesc(im_i);
+ axis image;
+ colormap jet;
+ subplot(1, 2, 2);
+ imagesc(im_o);
+ axis image;
+ colormap bone;
+ end
+end
+
diff --git a/matlab_functions/ilm_pcf_data_tf.m b/matlab_functions/ilm_pcf_data_tf.m
new file mode 100755
index 00000000..4c32d253
--- /dev/null
+++ b/matlab_functions/ilm_pcf_data_tf.m
@@ -0,0 +1,24 @@
+function [im_rp, im_sp] = ilm_pcf_data_tf(im_r, im_s, opt, sigma_f)
+ if nargin<3
+ opt=1;
+ end
+
+ if nargin<4
+ sigma_f = 4;
+ end
+
+ im_rp = double(im_r);
+ im_sp = double(im_s);
+
+ if opt==2
+ im_rp = del2(im_rp);
+ im_sp = del2(im_sp);
+ elseif opt==3
+ im_rp = ilm_lcwt(im_rp, sigma_f);
+ im_sp = ilm_lcwt(im_sp, sigma_f);
+ else
+ im_rp = im_rp - mean(im_rp, 'all');
+ im_sp = im_sp - mean(im_sp, 'all');
+ end
+
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_rAng_2_mrad.m b/matlab_functions/ilm_rAng_2_mrad.m
old mode 100644
new mode 100755
diff --git a/matlab_functions/ilm_read_2x_y_hdf5.m b/matlab_functions/ilm_read_2x_y_hdf5.m
new file mode 100755
index 00000000..3c705440
--- /dev/null
+++ b/matlab_functions/ilm_read_2x_y_hdf5.m
@@ -0,0 +1,5 @@
+function [x, x_1, y] = ilm_read_2x_y_hdf5(fn)
+ x = h5read(fn, '/x');
+ x_1 = h5read(fn, '/x_1');
+ y = h5read(fn, '/y');
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_angles_cif.m b/matlab_functions/ilm_read_angles_cif.m
old mode 100644
new mode 100755
index 7b60871d..f46f7047
--- a/matlab_functions/ilm_read_angles_cif.m
+++ b/matlab_functions/ilm_read_angles_cif.m
@@ -1,25 +1,25 @@
-% Read lattice parameter from cif file
-function [alpha, beta, gamma] = ilm_read_angles_cif(path)
- str_file = fileread(path);
- str_file = strtrim(strsplit(str_file, '\n'));
-
- alpha = fn_extract_pattern(str_file, '_cell_angle_alpha', '%s%f%s', 2);
- beta = fn_extract_pattern(str_file, '_cell_angle_beta', '%s%f%s', 2);
- gamma = fn_extract_pattern(str_file, '_cell_angle_gamma', '%s%f%s', 2);
-end
-
-function[str_out] =fn_extract_pattern(str_file, str_ss, patt, idx)
- if(nargin<3)
- idx = 0;
- end
-
- str_iy = str_file{contains(str_file, str_ss)};
- ix = strfind(str_iy, str_ss);
- str_iy = str_iy(ix:end);
- C = textscan(str_iy, patt);
- if(idx==0)
- str_out = C;
- else
- str_out = C{idx};
- end
+% Read lattice parameter from cif file
+function [alpha, beta, gamma] = ilm_read_angles_cif(path)
+ str_file = fileread(path);
+ str_file = strtrim(strsplit(str_file, '\n'));
+
+ alpha = fn_extract_pattern(str_file, '_cell_angle_alpha', '%s%f%s', 2);
+ beta = fn_extract_pattern(str_file, '_cell_angle_beta', '%s%f%s', 2);
+ gamma = fn_extract_pattern(str_file, '_cell_angle_gamma', '%s%f%s', 2);
+end
+
+function[str_out] =fn_extract_pattern(str_file, str_ss, patt, idx)
+ if(nargin<3)
+ idx = 0;
+ end
+
+ str_iy = str_file{contains(str_file, str_ss)};
+ ix = strfind(str_iy, str_ss);
+ str_iy = str_iy(ix:end);
+ C = textscan(str_iy, patt);
+ if(idx==0)
+ str_out = C;
+ else
+ str_out = C{idx};
+ end
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_ap_cif.m b/matlab_functions/ilm_read_ap_cif.m
old mode 100644
new mode 100755
index c569bf5a..0e0efeab
--- a/matlab_functions/ilm_read_ap_cif.m
+++ b/matlab_functions/ilm_read_ap_cif.m
@@ -1,185 +1,189 @@
-% Read atomic positions from cif file
-% Copyright 2023 Ivan Lobato
-function [atoms, lx, ly, lz] = ilm_read_ap_cif(path, rmsd_3d_0, pbc, na, nb, nc)
- if(nargin<6)
- nc = 1;
- end
-
- if(nargin<5)
- nb = 1;
- end
-
- if(nargin<4)
- na = 1;
- end
-
- % for anisotropic atomic displacement check out the following website
- % https://www.iucr.org/__data/iucr/cif/software/oostar/oostar_ddl1/bin/data/cifdic.c91.list.html
- if(nargin<3)
- pbc = true;
- end
-
- if(nargin<2)
- rmsd_3d_0 = 0.085;
- end
-
- occ_0 = 1;
-
- str_file = fileread(path);
- str_file = strtrim(strsplit(str_file, '\n'));
-
- xtl_parm.na = na;
- xtl_parm.nb = nb;
- xtl_parm.nc = nc;
-
- xtl_parm.a = fn_extract_pattern(str_file, '_cell_length_a', '%s%f%s', 2);
- xtl_parm.b = fn_extract_pattern(str_file, '_cell_length_b', '%s%f%s', 2);
- xtl_parm.c = fn_extract_pattern(str_file, '_cell_length_c', '%s%f%s', 2);
-
- xtl_parm.alpha = fn_extract_pattern(str_file, '_cell_angle_alpha', '%s%f%s', 2);
- xtl_parm.beta = fn_extract_pattern(str_file, '_cell_angle_beta', '%s%f%s', 2);
- xtl_parm.gamma = fn_extract_pattern(str_file, '_cell_angle_gamma', '%s%f%s', 2);
-
- % https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_IT_number.html
- if(fn_get_idx(str_file, '_space_group_IT_number')>0)
- xtl_parm.sgn = fn_extract_pattern(str_file, '_space_group_IT_number', '%s%d%s', 2);
- else
- xtl_parm.sgn = fn_extract_pattern(str_file, '_symmetry_Int_Tables_number', '%s%d%s', 2);
- end
-
- xtl_parm.pbc = pbc;
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- iy_0 = find(contains(str_file, '_atom_site_fract_x'), 1, 'first');
- iy_0 = iy_0-1;
- while ~contains(str_file{iy_0}, 'loop_')
- iy_0 = iy_0-1;
- end
- iy_0 = iy_0 + 1;
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- iy_e = iy_0+1;
- while contains(str_file{iy_e}, '_atom_site_')
- iy_e = iy_e+1;
- end
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- n_col = (iy_e-iy_0);
- map = containers.Map(iy_0:(iy_e-1), 1:n_col);
-
- iy_Z = fn_get_idx(str_file, '_atom_site_type_symbol');
- iy_x = fn_get_idx(str_file, '_atom_site_fract_x');
- iy_y = fn_get_idx(str_file, '_atom_site_fract_y');
- iy_z = fn_get_idx(str_file, '_atom_site_fract_z');
-
- iy_rmsd_3d = fn_get_idx(str_file, '_atom_site_B_iso_or_equiv');
- iy_occ = fn_get_idx(str_file, '_atom_site_occupancy');
- str_patt = repmat('%s', 1, n_col);
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- asym_uc = [];
- n_rows = length(str_file);
- iy = iy_e;
- while true
- if((iy>n_rows) || strcmp(str_file{iy}, ''))
- break;
- end
-
- str_text = textscan(str_file{iy}, str_patt);
- if(fn_break(str_text{map(iy_Z)}))
- break;
- end
-
- Z = fn_read_Z(str_text{map(iy_Z)}{1});
- x = fn_read_number(str_text{map(iy_x)}{1});
- y = fn_read_number(str_text{map(iy_y)}{1});
- z = fn_read_number(str_text{map(iy_z)}{1});
-
- % https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_B_iso_or_equiv.html
- if(ilm_chk_bound(iy_rmsd_3d, iy_0, iy_e))
- rmsd_3d = fn_read_rmsd_3d(str_text{map(iy_rmsd_3d)}{1}, rmsd_3d_0);
- else
- rmsd_3d = rmsd_3d_0;
- end
-
- % https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_occupancy.html
- if(ilm_chk_bound(iy_occ, iy_0, iy_e))
- occ = fn_read_rmsd_3d(str_text{map(iy_occ)}{1}, occ_0);
- else
- occ = occ_0;
- end
-
- asym_uc = [asym_uc;Z, x, y, z, rmsd_3d, occ];
- iy = iy + 1;
- end
-
- xtl_parm.asym_uc = asym_uc;
- xtl_parm.base = [];
-
- atoms = ilc_xtl_build(xtl_parm);
-
- xyz = atoms(:, 2:4);
- xyz = xyz - min(xyz);
- [lx, ly, lz] = ilm_vect_assign(max(xyz));
- atoms(:, 2:4) = xyz;
-
- [lx, ly, lz] = ilm_vect_assign([max(lx, xtl_parm.a), max(ly, xtl_parm.b), max(lz, xtl_parm.c)]);
-end
-
-function[bb] =fn_break(str_ss)
- if(size(str_ss, 1)>0)
- str_ss = str_ss{1};
- bb = ilm_Z(str_ss(isletter(str_ss)))<1;
- else
- bb = true;
- end
-end
-
-function[Z] =fn_read_Z(str_ss)
- Z = ilm_Z(str_ss(isletter(str_ss)));
-end
-
-function[n] =fn_read_number(str_ss, n_0)
- if(nargin<2)
- n_0 = 0;
- end
-
- str_ss = eraseBetween(str_ss, '(', ')', 'Boundaries', 'inclusive');
- n = str2double(strtrim(str_ss));
-
- if(isnan(n))
- n = n_0;
- end
-end
-
-function[rmsd_3d] =fn_read_rmsd_3d(str_ss, rmsd_3d_0)
- B = fn_read_number(str_ss);
- if(B==0)
- rmsd_3d = rmsd_3d_0;
- else
- rmsd_3d = sqrt(B/(8*pi^2));
- end
-end
-
-function[idx] =fn_get_idx(str_file, str_ss)
- idx = find(contains(str_file, str_ss), 1, 'first');
- if(numel(idx)==0)
- idx = -1;
- end
-end
-
-function[str_out] =fn_extract_pattern(str_file, str_ss, patt, idx)
- if(nargin<3)
- idx = 0;
- end
-
- str_iy = str_file{contains(str_file, str_ss)};
- ix = strfind(str_iy, str_ss);
- str_iy = str_iy(ix:end);
- C = textscan(str_iy, patt);
- if(idx==0)
- str_out = C;
- else
- str_out = C{idx};
- end
+% Read atomic positions from cif file
+% Copyright 2020 Ivan Lobato
+function [atoms, lx, ly, lz] = ilm_read_ap_cif(path, rmsd_3d_0, pbc, na, nb, nc)
+ if(nargin<6)
+ nc = 1;
+ end
+
+ if(nargin<5)
+ nb = 1;
+ end
+
+ if(nargin<4)
+ na = 1;
+ end
+
+ % for anisotropic atomic displacement check out the following website
+ % https://www.iucr.org/__data/iucr/cif/software/oostar/oostar_ddl1/bin/data/cifdic.c91.list.html
+ if(nargin<3)
+ pbc = true;
+ end
+
+ if(nargin<2)
+ rmsd_3d_0 = 0.085;
+ end
+
+ occ_0 = 1;
+
+ str_file = fileread(path);
+ str_file = strtrim(strsplit(str_file, '\n'));
+
+ xtl_parm.na = na;
+ xtl_parm.nb = nb;
+ xtl_parm.nc = nc;
+
+ xtl_parm.a = fn_extract_pattern(str_file, '_cell_length_a', '%s%f%s', 2);
+ xtl_parm.b = fn_extract_pattern(str_file, '_cell_length_b', '%s%f%s', 2);
+ xtl_parm.c = fn_extract_pattern(str_file, '_cell_length_c', '%s%f%s', 2);
+
+ xtl_parm.alpha = fn_extract_pattern(str_file, '_cell_angle_alpha', '%s%f%s', 2);
+ xtl_parm.beta = fn_extract_pattern(str_file, '_cell_angle_beta', '%s%f%s', 2);
+ xtl_parm.gamma = fn_extract_pattern(str_file, '_cell_angle_gamma', '%s%f%s', 2);
+
+ % https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Ispace_group_IT_number.html
+ if(fn_get_idx(str_file, '_space_group_IT_number')>0)
+ xtl_parm.sgn = fn_extract_pattern(str_file, '_space_group_IT_number', '%s%d%s', 2);
+ else
+ xtl_parm.sgn = fn_extract_pattern(str_file, '_symmetry_Int_Tables_number', '%s%d%s', 2);
+ end
+
+ xtl_parm.pbc = pbc;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ iy_0 = find(contains(str_file, '_atom_site_fract_x'), 1, 'first');
+ iy_0 = iy_0-1;
+ while ~contains(str_file{iy_0}, 'loop_')
+ iy_0 = iy_0-1;
+ end
+ iy_0 = iy_0 + 1;
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ iy_e = iy_0+1;
+ while contains(str_file{iy_e}, '_atom_site_')
+ iy_e = iy_e+1;
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ n_col = (iy_e-iy_0);
+ map = containers.Map(iy_0:(iy_e-1), 1:n_col);
+
+ iy_Z = fn_get_idx(str_file, '_atom_site_type_symbol');
+ iy_x = fn_get_idx(str_file, '_atom_site_fract_x');
+ iy_y = fn_get_idx(str_file, '_atom_site_fract_y');
+ iy_z = fn_get_idx(str_file, '_atom_site_fract_z');
+
+ iy_rmsd_3d = fn_get_idx(str_file, '_atom_site_B_iso_or_equiv');
+ iy_occ = fn_get_idx(str_file, '_atom_site_occupancy');
+ str_patt = repmat('%s', 1, n_col);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ asym_uc = [];
+ n_rows = length(str_file);
+ iy = iy_e;
+ while true
+ if((iy>n_rows) || strcmp(str_file{iy}, ''))
+ break;
+ end
+
+ str_text = textscan(str_file{iy}, str_patt);
+ if(fn_break(str_text{map(iy_Z)}))
+ break;
+ end
+
+ Z = fn_read_Z(str_text{map(iy_Z)}{1});
+ x = fn_read_number(str_text{map(iy_x)}{1});
+ y = fn_read_number(str_text{map(iy_y)}{1});
+ z = fn_read_number(str_text{map(iy_z)}{1});
+
+ % https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_B_iso_or_equiv.html
+ if(ilm_chk_bound(iy_rmsd_3d, iy_0, iy_e))
+ rmsd_3d = fn_read_rmsd_3d(str_text{map(iy_rmsd_3d)}{1}, rmsd_3d_0);
+ else
+ rmsd_3d = rmsd_3d_0;
+ end
+
+ % https://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Iatom_site_occupancy.html
+ if(ilm_chk_bound(iy_occ, iy_0, iy_e))
+ occ = fn_read_rmsd_3d(str_text{map(iy_occ)}{1}, occ_0);
+ else
+ occ = occ_0;
+ end
+
+ asym_uc = [asym_uc;Z, x, y, z, rmsd_3d, occ];
+ iy = iy + 1;
+ end
+
+ xtl_parm.asym_uc = asym_uc;
+
+% xtl_parm.base = ilm_xtl_build_base(xtl_parm);
+% atoms = ilc_xtl_build(xtl_parm);
+
+ xtl_parm.base = [];
+ atoms = ilc_xtl_build(xtl_parm);
+% ilc_xtl_build
+
+ xyz = atoms(:, 2:4);
+ xyz = xyz - min(xyz);
+ [lx, ly, lz] = ilm_vect_assign(max(xyz));
+ atoms(:, 2:4) = xyz;
+
+ [lx, ly, lz] = ilm_vect_assign([max(lx, xtl_parm.a), max(ly, xtl_parm.b), max(lz, xtl_parm.c)]);
+end
+
+function[bb] = fn_break(str_ss)
+ if(size(str_ss, 1)>0)
+ str_ss = str_ss{1};
+ bb = ilm_Z(str_ss(isletter(str_ss)))<1;
+ else
+ bb = true;
+ end
+end
+
+function[Z] =fn_read_Z(str_ss)
+ Z = ilm_Z(str_ss(isletter(str_ss)));
+end
+
+function[n] =fn_read_number(str_ss, n_0)
+ if(nargin<2)
+ n_0 = 0;
+ end
+
+ str_ss = eraseBetween(str_ss, '(', ')', 'Boundaries', 'inclusive');
+ n = str2double(strtrim(str_ss));
+
+ if(isnan(n))
+ n = n_0;
+ end
+end
+
+function[rmsd_3d] =fn_read_rmsd_3d(str_ss, rmsd_3d_0)
+ B = fn_read_number(str_ss);
+ if(B==0)
+ rmsd_3d = rmsd_3d_0;
+ else
+ rmsd_3d = sqrt(B/(8*pi^2));
+ end
+end
+
+function[idx] =fn_get_idx(str_file, str_ss)
+ idx = find(contains(str_file, str_ss), 1, 'first');
+ if(numel(idx)==0)
+ idx = -1;
+ end
+end
+
+function[str_out] =fn_extract_pattern(str_file, str_ss, patt, idx)
+ if(nargin<3)
+ idx = 0;
+ end
+
+ str_iy = str_file{contains(str_file, str_ss)};
+ ix = strfind(str_iy, str_ss);
+ str_iy = str_iy(ix:end);
+ C = textscan(str_iy, patt);
+ if(idx==0)
+ str_out = C;
+ else
+ str_out = C{idx};
+ end
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_ap_xyz.m b/matlab_functions/ilm_read_ap_xyz.m
old mode 100644
new mode 100755
index 07a81857..b3b67120
--- a/matlab_functions/ilm_read_ap_xyz.m
+++ b/matlab_functions/ilm_read_ap_xyz.m
@@ -1,26 +1,24 @@
-% Read atomic positions from xyz file
-function [atoms, lx, ly, lz] = ilm_read_ap_xyz(path, rmsd_3d)
- ces = {'H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca', ...
- 'Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn', 'Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr', ...
- 'Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn', 'Sb','Te','I','Xe','Cs','Ba','La','Ce','Pr','Nd',...
- 'Pm','Sm','Eu','Gd','Tb','Dy','Ho','Er','Tm','Yb','Lu','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg',...
- 'Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Th','Pa','U','Np','Pu','Am','Cm','Bk','Cf'};
-
- fid = fopen(path,'r');
- fgetl(fid);
- fgetl(fid);
- atoms = [];
- while feof(fid) == 0
- text = strtrim(upper(sscanf(fgetl(fid),'%c')));
- if (~isempty(text))
- C = textscan(text, '%s %f %f %f');
- atoms = [atoms; [find(strcmpi(ces, strtrim(C{1}))), C{2}, C{3}, C{4}, rmsd_3d, 1.0]];
- end
- end
- fclose(fid);
-
- atoms(:,2:4) = bsxfun(@minus, atoms(:,2:4), min(atoms(:,2:4)));
- lx = max(atoms(:,2));
- ly = max(atoms(:,3));
- lz = max(atoms(:,4));
+% Read atomic positions from xyz file
+function [atoms, lx, ly, lz] = ilm_read_ap_xyz(path, rmsd_3d)
+ if(nargin<2)
+ rmsd_3d = 0.085;
+ end
+
+ fid = fopen(path, 'r');
+ fgetl(fid);
+ fgetl(fid);
+ atoms = [];
+ while feof(fid) == 0
+ text = strtrim(upper(sscanf(fgetl(fid), '%c')));
+ if (~isempty(text))
+ C = textscan(text, '%s %f %f %f');
+ atoms = [atoms;[ilm_Z(C{1}), C{2}, C{3}, C{4}, rmsd_3d, 1.0]];
+ end
+ end
+ fclose(fid);
+
+ xyz = atoms(:, 2:4);
+ xyz = xyz - min(xyz);
+ [lx, ly, lz] = ilm_vect_assign(max(xyz));
+ atoms(:, 2:4) = xyz;
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_lat_parm_cif.m b/matlab_functions/ilm_read_lat_parm_cif.m
old mode 100644
new mode 100755
index 147a839d..8dc3a489
--- a/matlab_functions/ilm_read_lat_parm_cif.m
+++ b/matlab_functions/ilm_read_lat_parm_cif.m
@@ -1,26 +1,26 @@
-% Read lattice parameter from cif file
-% Copyright 2023 Ivan Lobato
-function [a, b, c] = ilm_read_lat_parm_cif(path)
- str_file = fileread(path);
- str_file = strtrim(strsplit(str_file, '\n'));
-
- a = fn_extract_pattern(str_file, '_cell_length_a', '%s%f%s', 2);
- b = fn_extract_pattern(str_file, '_cell_length_b', '%s%f%s', 2);
- c = fn_extract_pattern(str_file, '_cell_length_c', '%s%f%s', 2);
-end
-
-function[str_out] =fn_extract_pattern(str_file, str_ss, patt, idx)
- if(nargin<3)
- idx = 0;
- end
-
- str_iy = str_file{contains(str_file, str_ss)};
- ix = strfind(str_iy, str_ss);
- str_iy = str_iy(ix:end);
- C = textscan(str_iy, patt);
- if(idx==0)
- str_out = C;
- else
- str_out = C{idx};
- end
+% Read lattice parameter from cif file
+% Copyright 2020 Ivan Lobato
+function [a, b, c] = ilm_read_lat_parm_cif(path)
+ str_file = fileread(path);
+ str_file = strtrim(strsplit(str_file, '\n'));
+
+ a = fn_extract_pattern(str_file, '_cell_length_a', '%s%f%s', 2);
+ b = fn_extract_pattern(str_file, '_cell_length_b', '%s%f%s', 2);
+ c = fn_extract_pattern(str_file, '_cell_length_c', '%s%f%s', 2);
+end
+
+function[str_out] =fn_extract_pattern(str_file, str_ss, patt, idx)
+ if(nargin<3)
+ idx = 0;
+ end
+
+ str_iy = str_file{contains(str_file, str_ss)};
+ ix = strfind(str_iy, str_ss);
+ str_iy = str_iy(ix:end);
+ C = textscan(str_iy, patt);
+ if(idx==0)
+ str_out = C;
+ else
+ str_out = C{idx};
+ end
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_len_hdf5.m b/matlab_functions/ilm_read_len_hdf5.m
new file mode 100755
index 00000000..a3e8a3e3
--- /dev/null
+++ b/matlab_functions/ilm_read_len_hdf5.m
@@ -0,0 +1,13 @@
+function [sz] = ilm_read_len_hdf5(fn, str_var, dim)
+ if exist(fn, 'file')
+ try
+ info = h5info(fn, ['/', str_var]);
+ sz = info.Dataspace.Size(dim);
+ catch
+ sz = 0;
+ end
+ else
+ sz = 0;
+ end
+
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_x_y_sft_sc_hdf5.m b/matlab_functions/ilm_read_x_y_sft_sc_hdf5.m
new file mode 100755
index 00000000..35a5f940
--- /dev/null
+++ b/matlab_functions/ilm_read_x_y_sft_sc_hdf5.m
@@ -0,0 +1,28 @@
+function [x, y, x_sft, x_sc, y_sft, y_sc] = ilm_read_x_y_sft_sc_hdf5(fn)
+ x = h5read(fn, '/x');
+ y = h5read(fn, '/y');
+
+ try
+ x_sft = h5read(fn, '/x_sft');
+ catch
+ x_sft = 0.0;
+ end
+
+ try
+ x_sc = h5read(fn, '/x_sc');
+ catch
+ x_sc = 1.0;
+ end
+
+ try
+ y_sft = h5read(fn, '/y_sft');
+ catch
+ y_sft = 0.0;
+ end
+
+ try
+ y_sc = h5read(fn, '/y_sc');
+ catch
+ y_sc = 1.0;
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_read_x_y_sft_sc_y_dr_hdf5.m b/matlab_functions/ilm_read_x_y_sft_sc_y_dr_hdf5.m
new file mode 100755
index 00000000..b5e08473
--- /dev/null
+++ b/matlab_functions/ilm_read_x_y_sft_sc_y_dr_hdf5.m
@@ -0,0 +1,34 @@
+function [x, y, x_sft, x_sc, y_sft, y_sc, y_dr] = ilm_read_x_y_sft_sc_y_dr_hdf5(fn)
+ x = h5read(fn, '/x');
+ y = h5read(fn, '/y');
+
+ try
+ x_sft = h5read(fn, '/x_sft');
+ catch
+ x_sft = 0.0;
+ end
+
+ try
+ x_sc = h5read(fn, '/x_sc');
+ catch
+ x_sc = 1.0;
+ end
+
+ try
+ y_sft = h5read(fn, '/y_sft');
+ catch
+ y_sft = 0.0;
+ end
+
+ try
+ y_sc = h5read(fn, '/y_sc');
+ catch
+ y_sc = 1.0;
+ end
+
+ try
+ y_dr = h5read(fn, '/y_dr');
+ catch
+ y_dr = 1.0;
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_replace_filesep.m b/matlab_functions/ilm_replace_filesep.m
index 7f53079f..c874c951 100755
--- a/matlab_functions/ilm_replace_filesep.m
+++ b/matlab_functions/ilm_replace_filesep.m
@@ -1,4 +1,4 @@
-function[str]=ilm_replace_filesep(str, ss_rep)
+function[str] = ilm_replace_filesep(str, ss_rep)
if nargin < 2
ss_rep = filesep;
end
diff --git a/matlab_functions/ilm_show_crystal.m b/matlab_functions/ilm_show_crystal.m
deleted file mode 100644
index 334cae86..00000000
--- a/matlab_functions/ilm_show_crystal.m
+++ /dev/null
@@ -1,47 +0,0 @@
-function[]=ilm_show_crystal(fig, atoms, bb_clf, bb_rz)
- if(nargin<4)
- bb_rz = true;
- end
-
- if(nargin<3)
- bb_clf = true;
- end
-
- aZ = unique(atoms(:, 1));
-
- if(fig>0)
- figure(fig);
- end
-
- if(bb_clf)
- clf;
- else
- hold on;
- end
-
- str = {};
- for iZ=1:length(aZ)
- hold all;
- ii = find(atoms(:, 1)==aZ(iZ));
- plot3(atoms(ii, 2), atoms(ii, 3), atoms(ii, 4), 'o', 'MarkerSize', 3, 'MarkerFaceColor', 'auto');
- str{iZ} = num2str(aZ(iZ));
- end
-% legend(str);
- axis equal;
- r_min = min(atoms(:, 2:4), [], 1);
- r_max = max(atoms(:, 2:4), [], 1);
-
- x_min = r_min(1)-1;
- x_max = r_max(1)+1;
- y_min = r_min(2)-1;
- y_max = r_max(2)+1;
- z_min = r_min(3)-1;
- z_max = r_max(3)+1;
-
- axis([x_min, x_max, y_min, y_max, z_min, z_max]);
- view([0 0 1]);
-
- if(bb_rz)
- set(gca, 'zdir', 'reverse');
- end
-end
\ No newline at end of file
diff --git a/matlab_functions/ilm_show_slicing.m b/matlab_functions/ilm_show_slicing.m
old mode 100644
new mode 100755
index 88560dd3..1fee017f
--- a/matlab_functions/ilm_show_slicing.m
+++ b/matlab_functions/ilm_show_slicing.m
@@ -1,35 +1,35 @@
-function []=ilm_show_slicing(input_multem, inFP, nf)
- [Atoms, Slice] = getSliceSpecimen(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, input_multem.spec_dz, inFP, input_multem.DimFP, input_multem.SeedFP);
- S = getAtomTypes(input_multem.PotPar);
- z0 = min(Atoms(:, 3))-S(Atoms(1,4)).Rmax;
- ze = max(Atoms(:, 3))+S(Atoms(end,4)).Rmax;
- [nAtoms,~] = size(Atoms);
- [nslice, ~] = size(Slice);
-
- xy = zeros(nAtoms, 2);
- xy(:, 2) = Atoms(:, 3);
- figure(nf); clf;
- plot(xy(:, 1), xy(:, 2), '*k');
- for i = 1:nslice
- hold on;
- plot([-1 1], [Slice(i, 1) Slice(i, 1)], '-r','LineWidth',1);
- set(gca,'FontSize',10,'LineWidth',2,'PlotBoxAspectRatio',[0.75 1 1]);
- end
- hold on;
- plot([-1 1], [Slice(i, 2) Slice(i, 2)], '-r','LineWidth',1);
- hold on;
- ee = 0.25e-01;
- plot([-1 1], [z0-ee z0-ee], '-k');
- hold on;
- plot([-1 1], [ze+ee ze+ee], '-k');
-
- Planes = getPlanes(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, inFP, input_multem.DimFP, input_multem.SeedFP);
- [nPlanes, ~] = size(Planes);
- for i = 1:nPlanes
- hold on;
- plot([-1 1], [Planes(i) Planes(i)], '-b');
- set(gca,'FontSize',10,'LineWidth',1,'PlotBoxAspectRatio',[0.75 1 1]);
- end
- [nAtoms, nslice, nPlanes]
-end
-
+function [] = ilm_show_slicing(input_multem, inFP, nf)
+ [Atoms, Slice] = getSliceSpecimen(input_multem.spec_atoms, input_multem.spec_bs_x, input_multem.spec_bs_y, input_multem.spec_slic(1).sli_thick, inFP, input_multem.DimFP, input_multem.SeedFP);
+ S = getAtomTypes(input_multem.pot_parm_typ);
+ z0 = min(Atoms(:, 3))-S(Atoms(1, 4)).Rmax;
+ ze = max(Atoms(:, 3))+S(Atoms(end, 4)).Rmax;
+ [nAtoms, ~] = size(Atoms);
+ [nslice, ~] = size(Slice);
+
+ xy = zeros(nAtoms, 2);
+ xy(:, 2) = Atoms(:, 3);
+ figure(nf);clf;
+ plot(xy(:, 1), xy(:, 2), '*k');
+ for i = 1:nslice
+ hold on;
+ plot([-1 1], [Slice(i, 1) Slice(i, 1)], '-r', 'LineWidth', 1);
+ set(gca, 'FontSize', 10, 'LineWidth', 2, 'PlotBoxAspectRatio', [0.75 1 1]);
+ end
+ hold on;
+ plot([-1 1], [Slice(i, 2) Slice(i, 2)], '-r', 'LineWidth', 1);
+ hold on;
+ ee = 0.25e-01;
+ plot([-1 1], [z0-ee z0-ee], '-k');
+ hold on;
+ plot([-1 1], [ze+ee ze+ee], '-k');
+
+ Planes = getPlanes(input_multem.spec_atoms, input_multem.spec_bs_x, input_multem.spec_bs_y, inFP, input_multem.DimFP, input_multem.SeedFP);
+ [nPlanes, ~] = size(Planes);
+ for i = 1:nPlanes
+ hold on;
+ plot([-1 1], [Planes(i) Planes(i)], '-b');
+ set(gca, 'FontSize', 10, 'LineWidth', 1, 'PlotBoxAspectRatio', [0.75 1 1]);
+ end
+ [nAtoms, nslice, nPlanes]
+end
+
diff --git a/matlab_functions/ilm_vect_assign.m b/matlab_functions/ilm_vect_assign.m
old mode 100644
new mode 100755
index d83106ba..d4757d97
--- a/matlab_functions/ilm_vect_assign.m
+++ b/matlab_functions/ilm_vect_assign.m
@@ -1,3 +1,3 @@
-function[varargout] = ilm_vect_assign(v)
- varargout = num2cell(v);
+function[varargout] = ilm_vect_assign(v)
+ varargout = num2cell(v);
end
\ No newline at end of file
diff --git a/matlab_functions/ilm_wd_butwth.m b/matlab_functions/ilm_wd_butwth.m
new file mode 100755
index 00000000..ec89aba8
--- /dev/null
+++ b/matlab_functions/ilm_wd_butwth.m
@@ -0,0 +1,42 @@
+function[fbw] = ilm_wd_butwth(bs, dr, n, r_wd, sft, r_max, p_c)
+ if length(p_c) == 1
+ p_c = [p_c, p_c];
+ end
+
+ if length(r_max) == 1
+ r_max = [r_max, r_max];
+ end
+
+ if length(r_wd) == 1
+ r_wd = [r_wd, r_wd];
+ end
+
+ radius_x = r_wd(1);
+ radius_y = r_wd(2);
+ rx = (0:1:(bs(1)-1))*dr(1) - p_c(1);
+ ry = ((0:1:(bs(2)-1))*dr(2)).' - p_c(2);
+
+ if bs(1)>1
+ fx = 1./(1 + (rx/radius_x).^(2*n));
+ fx_sft = max(fx(1), fx(end));
+ fx = (fx - fx_sft)/(0.5-fx_sft);
+ fx = max(0, min(1.0, fx));
+ else
+ fx = 1;
+ end
+
+ if bs(2)>1
+ fy = 1./(1 + (ry/radius_y).^(2*n));
+ fy_sft = max(fy(1), fy(end));
+ fy = (fy - fy_sft)/(0.5-fy_sft);
+ fy = max(0, min(1.0, fy));
+ else
+ fy = 1;
+ end
+
+ fbw = fx.*fy;
+
+ if sft
+ fbw = ifftshift(fbw);
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_write_2x_y_hdf5.m b/matlab_functions/ilm_write_2x_y_hdf5.m
new file mode 100755
index 00000000..19e58fa4
--- /dev/null
+++ b/matlab_functions/ilm_write_2x_y_hdf5.m
@@ -0,0 +1,37 @@
+function ilm_write_2x_y_hdf5(fn, x, x_1, y)
+ x_shape = size(x);
+ x_1_shape = size(x_1);
+ y_shape = size(y);
+
+ if exist(fn, 'file')
+ try
+ info = h5info(fn, '/x');
+ bb = isequal(info.Dataspace.Size, x_shape);
+ info = h5info(fn, '/x_1');
+ bb = bb && isequal(info.Dataspace.Size, x_1_shape);
+ info = h5info(fn, '/y');
+ bb = bb && isequal(info.Dataspace.Size, y_shape);
+ if ~bb
+ delete(fn)
+
+ h5create(fn, '/x', x_shape, 'Datatype', class(x))
+ h5create(fn, '/x_1', x_1_shape, 'Datatype', class(x_1))
+ h5create(fn, '/y', y_shape, 'Datatype', class(y))
+ end
+ catch
+ delete(fn)
+
+ h5create(fn, '/x', x_shape, 'Datatype', class(x))
+ h5create(fn, '/x_1', x_1_shape, 'Datatype', class(x_1))
+ h5create(fn, '/y', y_shape, 'Datatype', class(y))
+ end
+ else
+ h5create(fn, '/x', x_shape, 'Datatype', class(x))
+ h5create(fn, '/x_1', x_1_shape, 'Datatype', class(x_1))
+ h5create(fn, '/y', y_shape, 'Datatype', class(y))
+ end
+
+ h5write(fn, '/x', x)
+ h5write(fn, '/x_1', x_1)
+ h5write(fn, '/y', y)
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_write_x_y_sft_sc_hdf5.m b/matlab_functions/ilm_write_x_y_sft_sc_hdf5.m
new file mode 100755
index 00000000..49a444df
--- /dev/null
+++ b/matlab_functions/ilm_write_x_y_sft_sc_hdf5.m
@@ -0,0 +1,86 @@
+function ilm_write_x_y_sft_sc_hdf5(fn, x, y, x_sft, x_sc, y_sft, y_sc)
+ x_shape = size(x);
+ y_shape = size(y);
+
+ bb_y_sc = ~(nargin<7);
+ bb_y_sft = ~(nargin<6);
+ bb_x_sc = ~(nargin<5);
+ bb_x_sft = ~(nargin<4);
+
+ if bb_x_sft
+ x_sft_shape = size(x_sft);
+ end
+
+ if bb_x_sc
+ x_sc_shape = size(x_sc);
+ end
+
+ if bb_y_sft
+ y_sft_shape = size(y_sft);
+ end
+
+ if bb_y_sc
+ y_sc_shape = size(y_sc);
+ end
+
+ bb = false;
+ for ik=1:4
+ try
+ if exist(fn, 'file')
+ delete(fn);
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ h5create(fn, '/x', x_shape, 'Datatype', class(x));
+ h5create(fn, '/y', y_shape, 'Datatype', class(y));
+
+ if bb_x_sft
+ h5create(fn, '/x_sft', x_sft_shape, 'Datatype', class(x_sft));
+ end
+
+ if bb_x_sc
+ h5create(fn, '/x_sc', x_sc_shape, 'Datatype', class(x_sc));
+ end
+
+ if bb_y_sft
+ h5create(fn, '/y_sft', y_sft_shape, 'Datatype', class(y_sft));
+ end
+
+ if bb_y_sc
+ h5create(fn, '/y_sc', y_sc_shape, 'Datatype', class(y_sc));
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ h5write(fn, '/x', x);
+ h5write(fn, '/y', y);
+
+ if bb_x_sft
+ h5write(fn, '/x_sft', x_sft);
+ end
+
+ if bb_x_sc
+ h5write(fn, '/x_sc', x_sc);
+ end
+
+ if bb_y_sft
+ h5write(fn, '/y_sft', y_sft);
+ end
+
+ if bb_y_sc
+ h5write(fn, '/y_sc', y_sc);
+ end
+
+ bb = true;
+ break;
+ catch
+ pause(1);
+ end
+ end
+
+ if ~bb
+ disp(['data will not be saved: ', fn]);
+ if exist(fn, 'file')
+ delete(fn);
+ end
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/ilm_write_x_y_sft_sc_y_dr_hdf5.m b/matlab_functions/ilm_write_x_y_sft_sc_y_dr_hdf5.m
new file mode 100755
index 00000000..7f365ced
--- /dev/null
+++ b/matlab_functions/ilm_write_x_y_sft_sc_y_dr_hdf5.m
@@ -0,0 +1,99 @@
+function ilm_write_x_y_sft_sc_y_dr_hdf5(fn, x, y, x_sft, x_sc, y_sft, y_sc, y_dr)
+ x_shape = size(x);
+ y_shape = size(y);
+
+ bb_y_dr = ~(nargin<8);
+ bb_y_sc = ~(nargin<7);
+ bb_y_sft = ~(nargin<6);
+ bb_x_sc = ~(nargin<5);
+ bb_x_sft = ~(nargin<4);
+
+ if bb_x_sft
+ x_sft_shape = size(x_sft);
+ end
+
+ if bb_x_sc
+ x_sc_shape = size(x_sc);
+ end
+
+ if bb_y_sft
+ y_sft_shape = size(y_sft);
+ end
+
+ if bb_y_sc
+ y_sc_shape = size(y_sc);
+ end
+
+ if bb_y_dr
+ y_dr_shape = size(y_dr);
+ end
+
+ bb = false;
+ for ik=1:4
+ try
+ if exist(fn, 'file')
+ delete(fn);
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ h5create(fn, '/x', x_shape, 'Datatype', class(x));
+ h5create(fn, '/y', y_shape, 'Datatype', class(y));
+
+ if bb_x_sft
+ h5create(fn, '/x_sft', x_sft_shape, 'Datatype', class(x_sft));
+ end
+
+ if bb_x_sc
+ h5create(fn, '/x_sc', x_sc_shape, 'Datatype', class(x_sc));
+ end
+
+ if bb_y_sft
+ h5create(fn, '/y_sft', y_sft_shape, 'Datatype', class(y_sft));
+ end
+
+ if bb_y_sc
+ h5create(fn, '/y_sc', y_sc_shape, 'Datatype', class(y_sc));
+ end
+
+ if bb_y_dr
+ h5create(fn, '/y_dr', y_dr_shape, 'Datatype', class(y_dr));
+ end
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ h5write(fn, '/x', x);
+ h5write(fn, '/y', y);
+
+ if bb_x_sft
+ h5write(fn, '/x_sft', x_sft);
+ end
+
+ if bb_x_sc
+ h5write(fn, '/x_sc', x_sc);
+ end
+
+ if bb_y_sft
+ h5write(fn, '/y_sft', y_sft);
+ end
+
+ if bb_y_sc
+ h5write(fn, '/y_sc', y_sc);
+ end
+
+ if bb_y_dr
+ h5write(fn, '/y_dr', y_dr);
+ end
+
+ bb = true;
+ break;
+ catch
+ pause(1);
+ end
+ end
+
+ if ~bb
+ disp(['data will not be saved: ', fn]);
+ if exist(fn, 'file')
+ delete(fn);
+ end
+ end
+end
\ No newline at end of file
diff --git a/matlab_functions/m2psi_tot_0.mat b/matlab_functions/m2psi_tot_0.mat
old mode 100644
new mode 100755
diff --git a/matlab_functions/mex_CUDA_glnxa64.xml b/matlab_functions/mex_CUDA_glnxa64.xml
old mode 100644
new mode 100755
diff --git a/matlab_functions/mex_CUDA_maci64.xml b/matlab_functions/mex_CUDA_maci64.xml
old mode 100644
new mode 100755
diff --git a/matlab_functions/mex_CUDA_win64.xml b/matlab_functions/mex_CUDA_win64.xml
old mode 100644
new mode 100755
index 674df2a3..d592d1e4
--- a/matlab_functions/mex_CUDA_win64.xml
+++ b/matlab_functions/mex_CUDA_win64.xml
@@ -1,227 +1,275 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/matlab_functions/read_psi_0_multem.m b/matlab_functions/read_psi_0_multem.m
old mode 100644
new mode 100755
index eaaf2c45..3e3ee649
--- a/matlab_functions/read_psi_0_multem.m
+++ b/matlab_functions/read_psi_0_multem.m
@@ -1,7 +1,7 @@
-function [psi] = read_psi_0_multem(nx, ny)
-psi_0 = importdata('m2psi_tot_0.mat');
-[ny0, nx0] = size(psi_0);
-[Rx, Ry] = meshgrid(1+(0:(nx-1))*(nx0-1)/(nx-1), 1+(0:(ny-1))*(ny0-1)/(ny-1));
-A = interp2(psi_0, Rx, Ry);
-P = exp(1i*0.5*pi*A);
+function [psi] = read_psi_0_multem(nx, ny)
+psi_0 = importdata('m2psi_tot_0.mat');
+[ny0, nx0] = size(psi_0);
+[Rx, Ry] = meshgrid(1+(0:(nx-1))*(nx0-1)/(nx-1), 1+(0:(ny-1))*(ny0-1)/(ny-1));
+A = interp2(psi_0, Rx, Ry);
+P = exp(1i*0.5*pi*A);
psi = A.*P;
\ No newline at end of file
diff --git a/matlab_functions/reg_polyh.mat b/matlab_functions/reg_polyh.mat
new file mode 100755
index 00000000..92b11836
Binary files /dev/null and b/matlab_functions/reg_polyh.mat differ
diff --git a/matlab_functions/tfm_check_stem_setup.m b/matlab_functions/tfm_check_stem_setup.m
old mode 100644
new mode 100755
index b82f6575..87f70f1f
--- a/matlab_functions/tfm_check_stem_setup.m
+++ b/matlab_functions/tfm_check_stem_setup.m
@@ -1,22 +1,20 @@
function tfm_check_stem_setup(input_multem, n_detector)
-
+
fcn_check_probe(input_multem);
fcn_check_slicing(input_multem);
- if nargin > 1
- fcn_check_detector_coverage(input_multem, n_detector);
- end
+ fcn_check_detector_coverage(input_multem, n_detector);
function fcn_check_probe(input_multem)
- input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
- input_multem.system_conf.device = 1; % eD_CPU = 1, eD_GPU = 2
- input_multem.system_conf.cpu_nthread = 1;
- input_multem.system_conf.gpu_device = 0;
+ system_config.precision = 1; % eP_Float = 1, eP_double = 2
+ system_config.device = 1; % eD_CPU = 1, eD_GPU = 2
+ system_config.cpu_nthread = 1;
+ system_config.gpu_device = 0;
- input_multem.iw_type = 2; % 2 = convergent beam
+ input_multem.incdt_wav_typ = 2; % 2 = convergent beam
input_multem.iw_x = 0.5*input_multem.spec_lx;
input_multem.iw_y = 0.5*input_multem.spec_ly;
- output_incident_wave = input_multem.ilc_incident_wave;
+ output_incident_wave = ilc_incident_wave(system_config, input_multem);
psi_0 = output_incident_wave.psi_0;
figure(1); clf
@@ -40,57 +38,43 @@ function fcn_check_probe(input_multem)
end
function fcn_check_slicing(input_multem)
-
- if ~isempty(input_multem.spec_atoms)
- % Slicing
- [~, Slice] = ilc_spec_slicing(input_multem.toStruct);
- [nslice, ~] = size(Slice);
- figure(2); clf;
- subplot(1,2,1);
- plot(input_multem.spec_atoms(:, 2), input_multem.spec_atoms(:, 4), 'ok');
- hold on;
- for i = 1:nslice
- plot([min(input_multem.spec_atoms(:, 2)) max(input_multem.spec_atoms(:, 2))], [Slice(i, 1) Slice(i, 1)], '-b', [min(input_multem.spec_atoms(:, 2)) max(input_multem.spec_atoms(:, 2))], [Slice(i, 2) Slice(i, 2)], '-b');
- end
- hold off;
- title('Slice positions');
- ylabel('z');
- xlabel('x');
- axis equal;
- axis([min(input_multem.spec_atoms(:, 2))-3 max(input_multem.spec_atoms(:, 2))+3 Slice(1, 1)-3 Slice(end, 1)+3]);
+ % Slicing
+ [atoms, Slice] = ilc_spec_slicing(input_multem);
+ [nslice, ~] = size(Slice);
- legend({'Atom positions','Slice boundaries'},'Location','southoutside')
- set(gca,'YDir','reverse')
-
- subplot(1,2,2);
- plot3(input_multem.spec_atoms(:,2), input_multem.spec_atoms(:,3), input_multem.spec_atoms(:,4),'or');
- hold on;
- if input_multem.simulation_type <= 12
- plot3([input_multem.scanning_x0; input_multem.scanning_xe; input_multem.scanning_xe; input_multem.scanning_x0;input_multem.scanning_x0],...
- [input_multem.scanning_y0; input_multem.scanning_y0; input_multem.scanning_ye; input_multem.scanning_ye;input_multem.scanning_y0],...
- [0; 0; 0; 0; 0],'-k');
- legend({'Atom positions','STEM Scan Field'},'Location','southoutside')
- else
- z0 = get_defocus_ref(input_multem);
- [xp, yp, zp] = cylinder([0 2], 64);
- surf(input_multem.iw_x+xp, input_multem.iw_y+yp, z0+(10*zp),'FaceAlpha',0.5,'EdgeColor','none','FaceColor','g')
- surf(input_multem.iw_x+xp, input_multem.iw_y+yp, z0+(-10*zp),'FaceAlpha',0.5, 'EdgeColor','none','FaceColor','g')
- plot3(input_multem.iw_x, input_multem.iw_y, z0,'xk');
- legend({'Atom positions','Probe'},'Location','southoutside')
- end
-
- hold off;
- axis equal;
- title('Atom positions and Scan Field')
- zlabel('z');
- xlabel('x');
- ylabel('y');
- set(gca,'ZDir','reverse')
- else
- fprintf(2,['No atoms are specified. Check your input structure! \n']);
+ figure(2); clf;
+ subplot(1,2,1);
+ plot(atoms(:, 3), atoms(:, 4), 'ok');
+ hold on;
+ for i = 1:nslice
+ plot([min(atoms(:, 3)) max(atoms(:, 3))], [Slice(i, 1) Slice(i, 1)], '-b', [min(atoms(:, 3)) max(atoms(:, 3))], [Slice(i, 2) Slice(i, 2)], '-b');
end
-
+ hold off;
+ title('Slice positions');
+ ylabel('z');
+ xlabel('x');
+ axis equal;
+ axis([min(atoms(:, 3)) max(atoms(:, 3)) -5 input_multem.spec_lz + 5]);
+ legend({'Atom positions','Slice boundaries'},'Location','southoutside')
+ set(gca,'YDir','reverse')
+
+ subplot(1,2,2);
+ plot3(input_multem.spec_atoms(:,2), input_multem.spec_atoms(:,3), input_multem.spec_atoms(:,4),'or');
+ hold on;
+ plot3([input_multem.scanning_x0; input_multem.scanning_xe; input_multem.scanning_xe; input_multem.scanning_x0;input_multem.scanning_x0],...
+ [input_multem.scanning_y0; input_multem.scanning_y0; input_multem.scanning_ye; input_multem.scanning_ye;input_multem.scanning_y0],...
+ [0; 0; 0; 0; 0],'-k');
+ hold off;
+ axis equal;
+ title('Atom positions and Scan Field')
+ zlabel('z');
+ xlabel('x');
+ ylabel('y');
+ axis equal;
+ legend({'Atom positions','STEM Scan Field'},'Location','southoutside')
+ set(gca,'ZDir','reverse')
+ view([0 0 1])
end
function fcn_check_detector_coverage(input_multem, detector)
@@ -102,7 +86,8 @@ function fcn_check_detector_coverage(input_multem, detector)
ly = input_multem.spec_ly;
ri_detector = input_multem.detector.cir(detector).inner_ang;
ro_detector = input_multem.detector.cir(detector).outer_ang;
-
+
+ clc;
gmax(1)=nx/(2*lx); gmax(2) = ny/(2*ly);
gmax_abs=min(gmax(:));
ri_detector = ilm_mrad_2_rAng(E_0,ri_detector);
@@ -115,6 +100,7 @@ function fcn_check_detector_coverage(input_multem, detector)
bwx = 2/3*(gmax_abs*cos(t));
bwy = 2/3*(gmax_abs*sin(t));
+
gspace=polyshape([-gmax(1) gmax(1) gmax(1) -gmax(1)],[-gmax(2) -gmax(2) gmax(2) gmax(2)]);
d=polyshape({xi,xo},{yi,yo},'Simplify',false);
figure(3); clf
@@ -134,23 +120,8 @@ function fcn_check_detector_coverage(input_multem, detector)
if tfm_pn_fact(nx,1)~=nx && tfm_pn_fact(nx,2)~=nx && tfm_pn_fact(nx,3)~=nx
fprintf(2,['Using ' num2str(nx) ' pixels in x is computationally unefficient. Consider using ' num2str(tfm_pn_fact(nx,1)) ' or ' num2str(tfm_pn_fact(nx,3)) ' instead.' '\n'])
end
- if tfm_pn_fact(ny,1)~=ny && tfm_pn_fact(ny,2)~=ny && tfm_pn_fact(ny,3)~=ny
+ if tfm_pn_fact(ny,1)~=nx && tfm_pn_fact(ny,2)~=ny && tfm_pn_fact(ny,3)~=ny
fprintf(2,['Using ' num2str(ny) ' pixels in y is computationally unefficient. Consider using ' num2str(tfm_pn_fact(ny,1)) ' or ' num2str(tfm_pn_fact(ny,3)) ' instead.' '\n'])
end
end
-end
-
-function z0 = get_defocus_ref(input_multem)
- at_min = min(input_multem.spec_atoms(:,4));
- at_max = max(input_multem.spec_atoms(:,4));
- switch input_multem.cond_lens_zero_defocus_type
- case 1
- z0 = at_min;
- case 2
- z0 = (at_max -at_min)/2+at_min;
- case 3
- z0 = at_max;
- case 4
- z0 = input_multem.cond_lens_zero_defocus_plane;
- end
end
\ No newline at end of file
diff --git a/matlab_functions/tfm_pn_fact.m b/matlab_functions/tfm_pn_fact.m
deleted file mode 100644
index d1c4d490..00000000
--- a/matlab_functions/tfm_pn_fact.m
+++ /dev/null
@@ -1,59 +0,0 @@
-function xo = tfm_pn_fact(x, b_min)
- % Returns an integer corresponding to the closest prime number
- % factorisation for computational efficiency (mainly relevant for CUDA)
- % Inputs:
- % x Input number
- % b_min (optional) either:
- % 1 (nearest solution) (default)
- % 2 (next smaller solution)
- % 3 (next larger solution)
-
- x = int64(x);
- x = min(max(2,x),2^16);
- p_min = 64;
-
- if nargin < 2
- b_min = 1;
- end
-
- switch b_min
- case 1
- x_t(1) = fcn_pn_down(x);
- x_t(2) = fcn_pn_up(x);
- [~,id] = sort(abs(x-x_t));
- xo = x_t(id(1));
- case 2
- x = max(3,x);
- xo = fcn_pn_down(x-1);
- case 3
- xo = fcn_pn_up(x+1);
- end
- xo = double(xo);
- function x = fcn_pn_up(x)
- pn = factor(x);
- b_pn = fcn_b_pn(x,pn);
- while b_pn
- x = x + 1;
- pn = factor(x);
- b_pn = fcn_b_pn(x,pn);
- end
- end
-
- function x = fcn_pn_down(x)
- pn = factor(x);
- b_pn = fcn_b_pn(x,pn);
- while b_pn
- x = x - 1;
- pn = factor(x);
- b_pn = fcn_b_pn(x,pn);
- end
- end
-
- function b_pn = fcn_b_pn(x,pn)
- if x > p_min
- b_pn = any(pn>7) || ~any(pn==2);
- else
- b_pn = ~all(pn==2);
- end
- end
-end
\ No newline at end of file
diff --git a/matlab_functions/xy_projected.mat b/matlab_functions/xy_projected.mat
old mode 100644
new mode 100755
diff --git a/mex_bin/mex_binary_files.txt b/mex_bin/mex_binary_files.txt
new file mode 100755
index 00000000..e69de29b
diff --git a/mex_examples_multem/Pt_twin.xyz b/mex_examples_multem/Pt_twin.xyz
old mode 100644
new mode 100755
diff --git a/mex_examples_multem/SrTiO3_mp-4651_conventional_standard.cif b/mex_examples_multem/SrTiO3_mp-4651_conventional_standard.cif
new file mode 100755
index 00000000..10659f5e
--- /dev/null
+++ b/mex_examples_multem/SrTiO3_mp-4651_conventional_standard.cif
@@ -0,0 +1,46 @@
+# generated using pymatgen
+data_SrTiO3
+_symmetry_space_group_name_H-M 'P 1'
+_cell_length_a 5.56772800
+_cell_length_b 5.56772800
+_cell_length_c 7.90710600
+_cell_angle_alpha 90.00000000
+_cell_angle_beta 90.00000000
+_cell_angle_gamma 90.00000000
+_symmetry_Int_Tables_number 1
+_chemical_formula_structural SrTiO3
+_chemical_formula_sum 'Sr4 Ti4 O12'
+_cell_volume 245.11708427
+_cell_formula_units_Z 4
+loop_
+ _symmetry_equiv_pos_site_id
+ _symmetry_equiv_pos_as_xyz
+ 1 'x, y, z'
+loop_
+ _atom_site_type_symbol
+ _atom_site_label
+ _atom_site_symmetry_multiplicity
+ _atom_site_fract_x
+ _atom_site_fract_y
+ _atom_site_fract_z
+ _atom_site_occupancy
+ Sr Sr0 1 0.00000000 0.50000000 0.25000000 1
+ Sr Sr1 1 0.50000000 0.00000000 0.25000000 1
+ Sr Sr2 1 0.50000000 0.00000000 0.75000000 1
+ Sr Sr3 1 0.00000000 0.50000000 0.75000000 1
+ Ti Ti4 1 0.00000000 0.00000000 0.00000000 1
+ Ti Ti5 1 0.50000000 0.50000000 0.00000000 1
+ Ti Ti6 1 0.50000000 0.50000000 0.50000000 1
+ Ti Ti7 1 0.00000000 0.00000000 0.50000000 1
+ O O8 1 0.77093350 0.27093350 0.50000000 1
+ O O9 1 0.22906650 0.27093350 0.00000000 1
+ O O10 1 0.77093350 0.72906650 0.00000000 1
+ O O11 1 0.72906650 0.22906650 0.00000000 1
+ O O12 1 0.50000000 0.50000000 0.25000000 1
+ O O13 1 0.00000000 0.00000000 0.25000000 1
+ O O14 1 0.27093350 0.77093350 0.00000000 1
+ O O15 1 0.72906650 0.77093350 0.50000000 1
+ O O16 1 0.27093350 0.22906650 0.50000000 1
+ O O17 1 0.22906650 0.72906650 0.50000000 1
+ O O18 1 0.00000000 0.00000000 0.75000000 1
+ O O19 1 0.50000000 0.50000000 0.75000000 1
diff --git a/mex_examples_multem/example_MULTEM_CBED.m b/mex_examples_multem/example_MULTEM_CBED.m
old mode 100644
new mode 100755
index cf4e8c15..e2af6174
--- a/mex_examples_multem/example_MULTEM_CBED.m
+++ b/mex_examples_multem/example_MULTEM_CBED.m
@@ -1,121 +1,120 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Convergent beam electron diffraction (CBED) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 21;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 40; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Si001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = 0; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 100; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 4; % 1: coherente mode, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 1110; % Defocus (�)
-input_multem.cond_lens_c_30 = 3.3; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 7.50; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_a = 1.0; % Height proportion of a normalized Gaussian [0, 1]
-input_multem.cond_lens_ti_sigma = dsf_sigma; % Standard deviation of the defocus spread for the Gaussian component (�)
-input_multem.cond_lens_ti_beta = 0.0; % Standard deviation of the defocus spread for the Exponential component (�)
-input_multem.cond_lens_ti_npts = 4; % Number of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_a = 1.0; % Height proportion of a normalized Gaussian [0, 1]
-input_multem.cond_lens_si_sigma = ssf_sigma; % Standard deviation of the source spread function for the Gaussian component: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_beta = 0.0; % Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % Number of radial integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_azm_npts = 4; % Number of radial integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 4; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-c = 1e5;
-figure(1); clf;
-for i=1:length(output_multislice.data)
- m2psi_tot = output_multislice.data(i).m2psi_tot;
- m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
-
- I_min = min(m2psi_tot(:));
- I_max = max(m2psi_tot(:));
-
- imagesc(output_multislice.x, output_multislice.y, m2psi_tot, [I_min I_max]);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
- axis image;
- colormap hot;
- pause(0.5);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Convergent beam electron diffraction (CBED) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 21;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 40;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Si001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 100; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 1110; % Defocus (Å)
+input_multem.cond_lens_c_30 = 3.3; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 7; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+c = 1e5;
+figure(1); clf;
+for i=1:length(output_multem.data)
+ m2psi_tot = output_multem.data(i).m2psi_tot;
+ m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
+
+ I_min = min(m2psi_tot(:));
+ I_max = max(m2psi_tot(:));
+
+ imagesc(output_multem.x, output_multem.y, m2psi_tot, [I_min I_max]);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap hot;
+ pause(0.5);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_CBEI.m b/mex_examples_multem/example_MULTEM_CBEI.m
old mode 100644
new mode 100755
index 1b828fae..80231f5a
--- a/mex_examples_multem/example_MULTEM_CBEI.m
+++ b/mex_examples_multem/example_MULTEM_CBEI.m
@@ -1,127 +1,131 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Convergent beam electron Imaging (CBEI) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 22;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 40; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Si001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = 0; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 100; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 140.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 0; % Defocus (�)
-input_multem.obj_lens_c_30 = 0.00; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-input_multem.obj_lens_ti_sigma = 0; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0;
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-figure(1);
-for i=1:length(output_multislice.data)
- imagesc(output_multislice.data(i).m2psi_tot);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
- axis image;
- colormap hot;
- pause(0.25);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Convergent beam electron image (CBEI) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 22;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 40;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Si001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 100; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 140.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 0; % Defocus (Å)
+input_multem.obj_lens_c_30 = 0.00; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+input_multem.obj_lens_tp_inc_sigma = 0; % standard deviation (Å)
+input_multem.obj_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0;
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).m2psi_tot);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap hot;
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_ED.m b/mex_examples_multem/example_MULTEM_ED.m
old mode 100644
new mode 100755
index 2168eb1d..2e31a36f
--- a/mex_examples_multem/example_MULTEM_ED.m
+++ b/mex_examples_multem/example_MULTEM_ED.m
@@ -1,80 +1,83 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Electron diffraction (ED) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 31;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 40; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-c = 1e6;
-figure(1);
-for i=1:length(output_multislice.data)
- m2psi_tot = output_multislice.data(i).m2psi_tot;
- m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
-
- I_min = min(m2psi_tot(:));
- I_max = max(m2psi_tot(:));
-
- imagesc(m2psi_tot, [I_min I_max]);
- title(strcat('Total intensity - Thick = ', num2str(i)));
- axis image;
- colormap gray;
- pause(0.25);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Convergent beam electron diffraction (CBED) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 31;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 40;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+c = 1e6;
+figure(1);
+for i=1:length(output_multem.data)
+ m2psi_tot = output_multem.data(i).m2psi_tot;
+ m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
+
+ I_min = min(m2psi_tot(:));
+ I_max = max(m2psi_tot(:));
+
+ imagesc(m2psi_tot, [I_min I_max]);
+ title(strcat('Total intensity - Thick = ', num2str(i)));
+ axis image;
+ colormap gray;
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_EELS.m b/mex_examples_multem/example_MULTEM_EELS.m
old mode 100644
new mode 100755
index a602e52a..b85e68bf
--- a/mex_examples_multem/example_MULTEM_EELS.m
+++ b/mex_examples_multem/example_MULTEM_EELS.m
@@ -1,120 +1,114 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% STEM electron energy loss spectroscopy (EELS) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-% eST_STEM=11, eST_ISTEM=12, eST_CBED=21, eST_CBEI=22, eST_ED=31, eST_HRTEM=32, eST_PED=41, eST_HCI=42, eST_EWFS=51, eST_EWRS=52,
-% eST_EELS=61, eST_EFTEM=62, eST_ProbeFS=71, eST_ProbeRS=72, eST_PPFS=81, eST_PPRS=82,eST_TFFS=91, eST_TFRS=92
-input_multem.simulation_type = 61;
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 5; % true: phonon configuration, false: number of frozen phonon configurations
-
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-na = 4; nb = 4; nc = 10; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.nx = 512;
-input_multem.ny = 512;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 88.7414; % Defocus (�)
-input_multem.cond_lens_c_30 = 0.04; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.scanning_type = 1; % eST_Line = 1, eST_Area = 2
-input_multem.scanning_periodic = 1; % 1: true, 0:false (periodic boundary conditions)
-input_multem.scanning_ns = 10; % number of sampling points
-input_multem.scanning_x0 = 2*a; % x-starting point (�)
-input_multem.scanning_y0 = 2.5*b; % y-starting point (�)
-input_multem.scanning_xe = 3*a; % x-final point (�)
-input_multem.scanning_ye = 2.5*b; % y-final point (�)
-
-input_multem.eels_E_loss = 532; % Energy loss (eV)
-input_multem.eels_m_selection = 3; % selection rule
-input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
-input_multem.eels_Z = 8; % atomic type
-
-input_multem.eels_E_loss = 456; % Energy loss (eV)
-input_multem.eels_m_selection = 3; % selection rule
-input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
-input_multem.eels_Z = 22; % atomic type
-
-input_multem.eels_E_loss = 1940; % Energy loss (eV)
-input_multem.eels_m_selection = 3; % selection rule
-input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
-input_multem.eels_Z = 38; % atomic type
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-clear ilc_multem;
-
-figure(1);
-for i=1:length(output_multislice.data)
- imagesc(output_multislice.data(i).image_tot(1).image);
- title(strcat('Thk = ', num2str(i), ', det = ', num2str(j)));
- axis image;
- colormap gray;
- pause(0.25);
-end
-
-% cc = [1 0 1; 1 0 0; 0 0 1; 0 0 0];
-% for i=1:4
-% input_multem.eels_channelling_type = i;
-% clear ilc_multem;
-% tic;
-% [eels] = input_multem.ilc_multem;
-% toc;
-% figure(1);
-% hold on;
-% plot(eels, 'color', cc(i, :));
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+% eST_STEM=11, eST_ISTEM=12, eST_CBED=21, eST_CBEI=22, eST_ED=31, eST_HRTEM=32, eST_PED=41, eST_HCI=42, eST_EWFS=51, eST_EWRS=52,
+% eST_EELS=61, eST_EFTEM=62, eST_ProbeFS=71, eST_ProbeRS=72, eST_PPFS=81, eST_PPRS=82, eST_TFFS=91, eST_TFRS=92
+input_multem.em_sim_typ = 61;
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 5; % true: phonon configuration, false: number of frozen phonon configurations
+
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+na = 4;nb = 4;nc = 10;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.nx = 512;
+input_multem.ny = 512;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 88.7414; % Defocus (Å)
+input_multem.cond_lens_c_30 = 0.04; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.scan_pat_typ = 1; % eST_Line = 1, eST_Area = 2
+input_multem.scan_pat_pbc = 1; % 1: true, 0:false (periodic boundary conditions)
+input_multem.scan_pat_nsp = 10; % number of sampling points
+input_multem.scan_pat_r_0 = [2*a;2.5*b]; % starting point (Å)
+input_multem.scan_pat_r_e = [3*a;2.5*b]; % final point (Å)
+
+input_multem.eels_E_loss = 532; % Energy loss (eV)
+input_multem.eels_m_selection = 3; % selection rule
+input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+input_multem.eels_Z = 8; % atomic type
+
+input_multem.eels_E_loss = 456; % Energy loss (eV)
+input_multem.eels_m_selection = 3; % selection rule
+input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+input_multem.eels_Z = 22; % atomic type
+
+input_multem.eels_E_loss = 1940; % Energy loss (eV)
+input_multem.eels_m_selection = 3; % selection rule
+input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+input_multem.eels_Z = 38; % atomic type
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+clear ilc_multem;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).image_tot(1).image);
+ title(strcat('Thk = ', num2str(i), ', det = ', num2str(j)));
+ axis image;
+ colormap gray;
+ pause(0.25);
+end
+
+% cc = [1 0 1;1 0 0; 0 0 1; 0 0 0];
+% for i=1:4
+% input_multem.eels_channelling_type = i;
+% clear ilc_multem;
+% tic;
+% [eels] = ilc_multem(system_config, input_multem);
+% toc;
+% figure(1);
+% hold on;
+% plot(eels, 'color', cc(i, :));
% end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_EFTEM.m b/mex_examples_multem/example_MULTEM_EFTEM.m
old mode 100644
new mode 100755
index 4ea01057..c33677ee
--- a/mex_examples_multem/example_MULTEM_EFTEM.m
+++ b/mex_examples_multem/example_MULTEM_EFTEM.m
@@ -1,7 +1,10 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
+% output_multislice = ilc_multem(system_config, input_multem) perform TEM simulation
+%
% Energy filtered transmission electron microscopy (EFTEM) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
+%
+% All parameters of the input_multem structure are explained in multem_default_values()
+%
+% Copyright 2020 Ivan Lobato
clear; clc;
addpath([fileparts(pwd) filesep 'mex_bin'])
@@ -9,106 +12,106 @@
addpath([fileparts(pwd) filesep 'matlab_functions'])
%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
+input_multem = multem_default_values(); % Load default values;
%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_nthread = 1;
+system_config.gpu_device = 0;
%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 62;
+input_multem.em_sim_typ = 62;
%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 5; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 5; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
na = 8; nb = 8; nc = 5; ncu = 2; rmsd_3d = 0.085;
[input_multem.spec_atoms, input_multem.spec_lx...
, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001Crystal(na, nb, nc, ncu, rmsd_3d);
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = 0; % Array of thickes (�)
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes (Å)
%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.nx = 1024;
input_multem.ny = 1024;
input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
input_multem.iw_x = input_multem.spec_lx/2; % x position
input_multem.iw_y = input_multem.spec_ly/2; % y position
%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 88.7414; % Defocus (�)
-input_multem.cond_lens_c_30 = 0.04; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 88.7414; % Defocus (Å)
+input_multem.cond_lens_c_30 = 0.04; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
-input_multem.obj_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.obj_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
+ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
+input_multem.obj_lens_ssf_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1); otherwise (Å)
+input_multem.obj_lens_ssf_npoints = 4; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 0; % Defocus (�)
-input_multem.obj_lens_c_30 = 0; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
+input_multem.obj_lens_c_10 = 0; % Defocus (Å)
+input_multem.obj_lens_c_30 = 0; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
-input_multem.obj_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 10; % # integration steps for the defocus Spread. It will be only used if illumination_model=4
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
+input_multem.obj_lens_ti_sigma = 32; % standard deviation (Å)
+input_multem.obj_lens_ti_npts = 10; % # integration steps for the defocus Spread. It will be only used if illum_mod=4
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
input_multem.eftem_E_loss = 532; % Energy loss (eV)
input_multem.eftem_m_selection = 3; % selection rule
@@ -130,7 +133,7 @@
clear ilc_multem;
tic;
-output_multislice = input_multem.ilc_multem;
+output_multislice = ilc_multem(system_config, input_multem);
toc;
figure(1);
diff --git a/mex_examples_multem/example_MULTEM_EFTEMFS.m b/mex_examples_multem/example_MULTEM_EFTEMFS.m
new file mode 100755
index 00000000..6813325a
--- /dev/null
+++ b/mex_examples_multem/example_MULTEM_EFTEMFS.m
@@ -0,0 +1,145 @@
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Energy filtered transmission electron microscopy (EFTEM) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 71;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 5; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 4;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes (?)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (?)
+input_multem.phi = 0.0; % Till ilumination (?)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 4; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 15.0; % Defocus (A)
+input_multem.cond_lens_c_30 = 0.001; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (?)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (?)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (?)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (?)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (?)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(?^-1);otherwise (?)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 0; % Defocus (A)
+input_multem.obj_lens_c_30 = 0; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (?)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (?)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (?)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (?)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
+
+input_multem.eftem_E_loss = 532; % Energy loss (eV)
+input_multem.eftem_m_selection = 3; % selection rule
+input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eftem_collection_angle = 25; % Collection half angle (mrad)
+input_multem.eftem_Z = 8; % atomic type
+
+% input_multem.eftem_E_loss = 456; % Energy loss (eV)
+% input_multem.eftem_m_selection = 3; % selection rule
+% input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+% input_multem.eftem_collection_angle = 25; % Collection half angle (mrad)
+% input_multem.eftem_Z = 22; % atomic type
+%
+% input_multem.eftem_E_loss = 1940; % Energy loss (eV)
+% input_multem.eftem_m_selection = 3; % selection rule
+% input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+% input_multem.eftem_collection_angle = 25; % Collection half angle (mrad)
+% input_multem.eftem_Z = 38; % atomic type
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).m2psi_tot);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap gray;
+ pause(0.25);
+end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_EFTEMRS.m b/mex_examples_multem/example_MULTEM_EFTEMRS.m
new file mode 100755
index 00000000..b50cb682
--- /dev/null
+++ b/mex_examples_multem/example_MULTEM_EFTEMRS.m
@@ -0,0 +1,145 @@
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Energy filtered transmission electron microscopy (EFTEM) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 72;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 5; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 4;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes (?)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (?)
+input_multem.phi = 0.0; % Till ilumination (?)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 15.0; % Defocus (A)
+input_multem.cond_lens_c_30 = 0.001; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (?)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (?)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (?)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (?)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (?)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(?^-1);otherwise (?)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 0; % Defocus (A)
+input_multem.obj_lens_c_30 = 0; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (?)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (?)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (?)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (?)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
+
+input_multem.eftem_E_loss = 532; % Energy loss (eV)
+input_multem.eftem_m_selection = 3; % selection rule
+input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eftem_collection_angle = 25; % Collection half angle (mrad)
+input_multem.eftem_Z = 8; % atomic type
+
+% input_multem.eftem_E_loss = 456; % Energy loss (eV)
+% input_multem.eftem_m_selection = 3; % selection rule
+% input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+% input_multem.eftem_collection_angle = 25; % Collection half angle (mrad)
+% input_multem.eftem_Z = 22; % atomic type
+%
+% input_multem.eftem_E_loss = 1940; % Energy loss (eV)
+% input_multem.eftem_m_selection = 3; % selection rule
+% input_multem.eftem_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+% input_multem.eftem_collection_angle = 25; % Collection half angle (mrad)
+% input_multem.eftem_Z = 38; % atomic type
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).m2psi_tot);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap gray;
+ pause(0.25);
+end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_EWFS.m b/mex_examples_multem/example_MULTEM_EWFS.m
old mode 100644
new mode 100755
index 9aead610..cd20548c
--- a/mex_examples_multem/example_MULTEM_EWFS.m
+++ b/mex_examples_multem/example_MULTEM_EWFS.m
@@ -1,118 +1,122 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
% Exit wave real space (EWRS) simulation
+%
% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
+%
+% Copyright 2021 Ivan Lobato
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
+input_multem = ilm_dflt_input_multem(); % Load default values;
%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 51;
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 51;
%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 40; ncu = 2; rmsd_3d = 0.085;
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 40;ncu = 2;rmsd_3d = 0.085;
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.nx = 1024;
input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 140.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 140.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
%%%%%%%%% defocus spread function %%%%%%%%%%%%
dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%%% source spread function %%%%%%%%%%%%
ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
clear ilc_multem;
tic;
-output_multislice = input_multem.ilc_multem;
+output_multem = ilc_multem(system_config, input_multem);
toc;
c = 1e6;
figure(1);
-for i=1:length(output_multislice.data)
- m2psi_coh = abs(output_multislice.data(i).psi_coh).^2;
- if(isfield(output_multislice.data, 'm2psi_tot'))
- m2psi_tot = output_multislice.data(i).m2psi_tot;
+for i=1:length(output_multem.data)
+ m2psi_coh = abs(output_multem.data(i).psi_coh).^2;
+ if(isfield(output_multem.data, 'm2psi_tot'))
+ m2psi_tot = output_multem.data(i).m2psi_tot;
else
m2psi_tot = m2psi_coh;
- end
+ end
m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
m2psi_coh = log(1+c*m2psi_coh/max(m2psi_coh(:)));
@@ -122,14 +126,14 @@
subplot(1, 2, 1);
imagesc(m2psi_tot, [I_min I_max]);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
axis image;
colormap gray;
colorbar
subplot(1, 2, 2);
imagesc(m2psi_coh, [I_min I_max]);
- title(strcat('Coherent intensity - Thick = ', num2str(output_multislice.thick(i))));
+ title(strcat('Coherent intensity - Thick = ', num2str(output_multem.thick(i))));
axis image;
colormap gray;
colorbar
diff --git a/mex_examples_multem/example_MULTEM_EWFS_till_illumination.m b/mex_examples_multem/example_MULTEM_EWFS_till_illumination.m
old mode 100644
new mode 100755
index b2bc795f..2715b28c
--- a/mex_examples_multem/example_MULTEM_EWFS_till_illumination.m
+++ b/mex_examples_multem/example_MULTEM_EWFS_till_illumination.m
@@ -1,118 +1,122 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
% Exit wave real space (EWRS) simulation
+%
% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
+%
+% Copyright 2021 Ivan Lobato
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
+input_multem = ilm_dflt_input_multem(); % Load default values;
%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 51;
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 51;
%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 40; ncu = 2; rmsd_3d = 0.085;
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 40;ncu = 2;rmsd_3d = 0.085;
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.nx = 1024;
input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 3.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 3.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 140.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 140.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
%%%%%%%%% defocus spread function %%%%%%%%%%%%
dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%%% source spread function %%%%%%%%%%%%
ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
clear ilc_multem;
tic;
-output_multislice = input_multem.ilc_multem;
+output_multem = ilc_multem(system_config, input_multem);
toc;
c = 1e6;
figure(1);
-for i=1:length(output_multislice.data)
- m2psi_coh = abs(output_multislice.data(i).psi_coh).^2;
- if(isfield(output_multislice.data, 'm2psi_tot'))
- m2psi_tot = output_multislice.data(i).m2psi_tot;
+for i=1:length(output_multem.data)
+ m2psi_coh = abs(output_multem.data(i).psi_coh).^2;
+ if(isfield(output_multem.data, 'm2psi_tot'))
+ m2psi_tot = output_multem.data(i).m2psi_tot;
else
m2psi_tot = m2psi_coh;
- end
+ end
m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
m2psi_coh = log(1+c*m2psi_coh/max(m2psi_coh(:)));
@@ -122,14 +126,14 @@
subplot(1, 2, 1);
imagesc(m2psi_tot, [I_min I_max]);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
axis image;
colormap gray;
colorbar
subplot(1, 2, 2);
imagesc(m2psi_coh, [I_min I_max]);
- title(strcat('Coherent intensity - Thick = ', num2str(output_multislice.thick(i))));
+ title(strcat('Coherent intensity - Thick = ', num2str(output_multem.thick(i))));
axis image;
colormap gray;
colorbar
diff --git a/mex_examples_multem/example_MULTEM_EWRS.m b/mex_examples_multem/example_MULTEM_EWRS.m
old mode 100644
new mode 100755
index b181ef1a..5b4f65cd
--- a/mex_examples_multem/example_MULTEM_EWRS.m
+++ b/mex_examples_multem/example_MULTEM_EWRS.m
@@ -1,114 +1,127 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
% Exit wave real space (EWRS) simulation
+%
% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
+%
+% Copyright 2021 Ivan Lobato
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
+input_multem = ilm_dflt_input_multem(); % Load default values;
%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 52;
%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 10; ncu = 2; rmsd_3d = 0.085;
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 10;ncu = 2;rmsd_3d = 0.085;
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Si110_xtl(na, nb, nc, ncu, rmsd_3d);
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
+% [input_multem.spec_atoms, input_multem.spec_bs_x...
+% , input_multem.spec_bs_y, input_multem.spec_bs_z...
+% , a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+% [input_multem.spec_atoms, input_multem.spec_bs_x...
+% , input_multem.spec_bs_y, input_multem.spec_bs_z...
+% , a, b, c] = graphene(na, 1.42, rmsd_3d);
+% input_multem.spec_slic(1).sli_thick = 2.0;
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.nx = 1024;
input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 140.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 140.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
%%%%%%%%% defocus spread function %%%%%%%%%%%%
dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%%% source spread function %%%%%%%%%%%%
ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
clear ilc_multem;
tic;
-output_multislice = input_multem.ilc_multem;
+output_multem = ilc_multem(system_config, input_multem);
toc;
figure(1);
-for i=1:length(output_multislice.data)
- m2psi_coh = abs(output_multislice.data(i).psi_coh).^2;
- if(isfield(output_multislice.data, 'm2psi_tot'))
- m2psi_tot = output_multislice.data(i).m2psi_tot;
+for i=1:length(output_multem.data)
+ m2psi_coh = abs(output_multem.data(i).psi_coh).^2;
+ if(isfield(output_multem.data, 'm2psi_tot'))
+ m2psi_tot = output_multem.data(i).m2psi_tot;
else
m2psi_tot = m2psi_coh;
end
diff --git a/mex_examples_multem/example_MULTEM_EWRS_till_illumination.m b/mex_examples_multem/example_MULTEM_EWRS_till_illumination.m
old mode 100644
new mode 100755
index 75c69624..16726cdd
--- a/mex_examples_multem/example_MULTEM_EWRS_till_illumination.m
+++ b/mex_examples_multem/example_MULTEM_EWRS_till_illumination.m
@@ -1,117 +1,121 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
% Exit wave real space (EWRS) simulation
+%
% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
+%
+% Copyright 2021 Ivan Lobato
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
+input_multem = ilm_dflt_input_multem(); % Load default values;
%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 52;
%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 10; ncu = 2; rmsd_3d = 0.085;
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 10;ncu = 2;rmsd_3d = 0.085;
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.nx = 1024;
input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 3.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 3.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 140.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 140.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
%%%%%%%%% defocus spread function %%%%%%%%%%%%
dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%%% source spread function %%%%%%%%%%%%
ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
clear ilc_multem;
tic;
-output_multislice = input_multem.ilc_multem;
+output_multem = ilc_multem(system_config, input_multem);
toc;
figure(1);
-for i=1:length(output_multislice.data)
- m2psi_coh = abs(output_multislice.data(i).psi_coh).^2;
- if(isfield(output_multislice.data, 'm2psi_tot'))
- m2psi_tot = output_multislice.data(i).m2psi_tot;
+for i=1:length(output_multem.data)
+ m2psi_coh = abs(output_multem.data(i).psi_coh).^2;
+ if(isfield(output_multem.data, 'm2psi_tot'))
+ m2psi_tot = output_multem.data(i).m2psi_tot;
else
m2psi_tot = m2psi_coh;
- end
+ end
subplot(1, 2, 1);
imagesc(m2psi_tot);
title(strcat('Total intensity - Thick = ', num2str(i)));
diff --git a/mex_examples_multem/example_MULTEM_HCTEM.m b/mex_examples_multem/example_MULTEM_HCTEM.m
old mode 100644
new mode 100755
index 042085fc..e5915a95
--- a/mex_examples_multem/example_MULTEM_HCTEM.m
+++ b/mex_examples_multem/example_MULTEM_HCTEM.m
@@ -1,104 +1,107 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Hollow cone transmission electron microscopy (HCTEM) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 42;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 16; nb = 16; nc = 20; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 20; % Defocus (�)
-input_multem.obj_lens_c_30 = 0.04; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 25.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.obj_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HCI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.hci_nrot = 30; % number of orientations
-input_multem.hci_theta = 3.0; % Precession angle (degrees)
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-figure(1);
-for i=1:length(output_multislice.data)
- imagesc(output_multislice.data(i).m2psi_tot);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
- axis image;
- colormap gray;
- pause(0.25);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Hollow cone transmission electron microscopy (HCTEM) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 42;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 16;nb = 16;nc = 20;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
+input_multem.obj_lens_ssf_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.obj_lens_ssf_npoints = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 20; % Defocus (Å)
+input_multem.obj_lens_c_30 = 0.04; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 25.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.obj_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.obj_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HCI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.hci_nrot = 30; % number of orientations
+input_multem.hci_theta = 3.0; % Precession angle (degrees)
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).m2psi_tot);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap gray;
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_HRTEM.m b/mex_examples_multem/example_MULTEM_HRTEM.m
old mode 100644
new mode 100755
index 4bd7a5c5..ccfd8098
--- a/mex_examples_multem/example_MULTEM_HRTEM.m
+++ b/mex_examples_multem/example_MULTEM_HRTEM.m
@@ -1,104 +1,108 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% High resolution transmission electron microscopy (HRTEM) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 32;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 16; nb = 16; nc = 20; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 20; % Defocus (�)
-input_multem.obj_lens_c_30 = 0.04; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.obj_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
-input_multem.obj_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.obj_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0;
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-figure(1);
-for i=1:length(output_multislice.data)
- imagesc(output_multislice.data(i).m2psi_tot);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
- axis image;
- colormap gray;
- pause(0.25);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% High resolution transmission electron microscopy (HRTEM) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 32;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 16;nb = 16;nc = 20;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
+input_multem.obj_lens_ssf_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.obj_lens_ssf_npoints = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 20; % Defocus (Å)
+input_multem.obj_lens_c_30 = 0.04; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.obj_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.obj_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
+
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).m2psi_tot);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap gray;
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_ISTEM.m b/mex_examples_multem/example_MULTEM_ISTEM.m
old mode 100644
new mode 100755
index e2ea7b57..21b5d7cc
--- a/mex_examples_multem/example_MULTEM_ISTEM.m
+++ b/mex_examples_multem/example_MULTEM_ISTEM.m
@@ -1,130 +1,131 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Imaging scanning transmission electron microscopy (ISTEM) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 12;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 5; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 200; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 15.836; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 0; % Defocus (�)
-input_multem.obj_lens_c_30 = 0; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-input_multem.obj_lens_ti_sigma = 0; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.scanning_type = 2; % eST_Line = 1, eST_Area = 2
-input_multem.scanning_periodic = 1; % 1: true, 0:false (periodic boundary conditions)
-input_multem.scanning_ns = 10;
-input_multem.scanning_x0 = 3*a;
-input_multem.scanning_y0 = 3*b;
-input_multem.scanning_xe = 4*a;
-input_multem.scanning_ye = 4*b;
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-figure(1);
-for i=1:length(output_multislice.data)
- imagesc(output_multislice.data(i).m2psi_tot);
- title(strcat('Total intensity - Thick = ', num2str(output_multislice.thick(i))));
- axis image;
- colormap gray;
- pause(0.25);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Imaging scanning transmission electron microscopy (ISTEM) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 12;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 5;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 200; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 15.836; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 0; % Defocus (Å)
+input_multem.obj_lens_c_30 = 0; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+input_multem.obj_lens_tp_inc_sigma = 0; % standard deviation (Å)
+input_multem.obj_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.scan_pat_typ = 2; % eST_Line = 1, eST_Area = 2
+input_multem.scan_pat_pbc = 1; % 1: true, 0:false (periodic boundary conditions)
+input_multem.scan_pat_nsp = 10;
+input_multem.scan_pat_r_0 = [3*a;3*b]; % starting point (Å)
+input_multem.scan_pat_r_e = [4*a;4*b]; % final point (Å)
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ imagesc(output_multem.data(i).m2psi_tot);
+ title(strcat('Total intensity - Thick = ', num2str(output_multem.thick(i))));
+ axis image;
+ colormap gray;
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_PED.m b/mex_examples_multem/example_MULTEM_PED.m
old mode 100644
new mode 100755
index b7e84968..96a706cf
--- a/mex_examples_multem/example_MULTEM_PED.m
+++ b/mex_examples_multem/example_MULTEM_PED.m
@@ -1,101 +1,102 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-%
-% Precession electron diffraction (PED) simulation
-%
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-%
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 41;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 16; nb = 16; nc = 30; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
-input_multem.obj_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.obj_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%%%% aperture radius %%%%%%%%%%%%%%%%%
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PED %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.ped_nrot = 30; % number of orientations
-input_multem.ped_theta = 3.0; % Precession angle (degrees)
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-c = 1e7;
-figure(1);
-for i=1:length(output_multislice.data)
- m2psi_tot = output_multislice.data(i).m2psi_tot;
- m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
-
- I_min = min(m2psi_tot(:));
- I_max = max(m2psi_tot(:));
-
- imagesc(output_multislice.x, output_multislice.y, m2psi_tot, [I_min I_max]);
- title(strcat('Total intensity - Thick = ', num2str(i)));
- axis image;
- colormap gray;
- pause(0.5);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Precession electron diffraction (PED) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 41;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 16;nb = 16;nc = 30;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c:c:1000; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_mrad_2_sigma(input_multem.E_0, 0.02); % mrad to standard deviation
+input_multem.obj_lens_ssf_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.obj_lens_ssf_npoints = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+ %%%%%%%%%%%% aperture radius %%%%%%%%%%%%%%%%%
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 0.0; % Outer aperture (mrad)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PED %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.ped_nrot = 30; % number of orientations
+input_multem.ped_theta = 3.0; % Precession angle (degrees)
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+c = 1e7;
+figure(1);
+for i=1:length(output_multem.data)
+ m2psi_tot = output_multem.data(i).m2psi_tot;
+ m2psi_tot = log(1+c*m2psi_tot/max(m2psi_tot(:)));
+
+ I_min = min(m2psi_tot(:));
+ I_max = max(m2psi_tot(:));
+
+ imagesc(output_multem.x, output_multem.y, m2psi_tot, [I_min I_max]);
+ title(strcat('Total intensity - Thick = ', num2str(i)));
+ axis image;
+ colormap gray;
+ pause(0.5);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_STEM.m b/mex_examples_multem/example_MULTEM_STEM.m
old mode 100644
new mode 100755
index 484899c0..65433dc0
--- a/mex_examples_multem/example_MULTEM_STEM.m
+++ b/mex_examples_multem/example_MULTEM_STEM.m
@@ -1,127 +1,124 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Scanning transmission electron microscopy (STEM) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 11;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 5; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au110_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c/2:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 512;
-input_multem.ny = 512;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 14.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (Ã…)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Ã…^-1); otherwise (Ã…)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_azm_npts = 12; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.scanning_type = 2; % eST_Line = 1, eST_Area = 2
-input_multem.scanning_periodic = 1; % 1: true, 0:false (periodic boundary conditions)
-input_multem.scanning_square_pxs = 0; % 0: false, 1: true
-input_multem.scanning_ns = 20;
-input_multem.scanning_x0 = 3*a;
-input_multem.scanning_y0 = 3*b;
-input_multem.scanning_xe = 4*a;
-input_multem.scanning_ye = 4*b;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Detector %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.detector.type = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
-input_multem.detector.cir(1).inner_ang = 40; % Inner angle(mrad)
-input_multem.detector.cir(1).outer_ang = 160; % Outer angle(mrad)
-input_multem.detector.cir(2).inner_ang = 80; % Inner angle(mrad)
-input_multem.detector.cir(2).outer_ang = 160; % Outer angle(mrad)
-
-%%%%%%%%%%%%%%%%%%%%%%%%%% run multem %%%%%%%%%%%%%%%%%%%%%%%%%%
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-output_multislice
-
-figure(1);
-for i=1:length(output_multislice.data)
- ndet = length(input_multem.detector.cir);
- for j=1:ndet
- subplot(1, ndet, j);
- imagesc(output_multislice.data(i).image_tot(j).image);
- title(strcat('Thk = ', num2str(i), ', det = ', num2str(output_multislice.thick(j))));
- axis image;
- colormap jet;
- end
- pause(0.5);
-end
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% Scanning transmission electron microscopy (STEM) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = [0, 0];
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 11;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 5;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = c/2:c:1000; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 14.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
+input_multem.cond_lens_spt_inc_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.scan_pat_typ = 2; % eST_Line = 1, eST_Area = 2
+input_multem.scan_pat_pbc = 1; % 1: true, 0:false (periodic boundary conditions)
+input_multem.scan_pat_nsp = 20;
+input_multem.scan_pat_r_0 = [3*a;3*b]; % starting point (Å)
+input_multem.scan_pat_r_e = [4*a;4*b]; % final point (Å)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Detector %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.detector.typ = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
+input_multem.detector.cir(1).inner_ang = 40; % Inner angle(mrad)
+input_multem.detector.cir(1).outer_ang = 160; % Outer angle(mrad)
+input_multem.detector.cir(2).inner_ang = 80; % Inner angle(mrad)
+input_multem.detector.cir(2).outer_ang = 160; % Outer angle(mrad)
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1);
+for i=1:length(output_multem.data)
+ ndet = length(input_multem.detector.cir);
+ for j=1:ndet
+ subplot(1, ndet, j);
+ imagesc(output_multem.data(i).image_tot(j).image);
+ title(strcat('Thk = ', num2str(i), ', det = ', num2str(output_multem.thick(j))));
+ axis image;
+ colormap jet;
+ end
+ pause(0.25);
+end
diff --git a/mex_examples_multem/example_MULTEM_STEM_EELS.m b/mex_examples_multem/example_MULTEM_STEM_EELS.m
old mode 100644
new mode 100755
index 5f042c2b..695e03f9
--- a/mex_examples_multem/example_MULTEM_STEM_EELS.m
+++ b/mex_examples_multem/example_MULTEM_STEM_EELS.m
@@ -1,143 +1,136 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% STEM electron energy loss spectroscopy (EELS) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 1;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 61;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 5; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 5; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = 0; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = -14.03; % Defocus (�)
-input_multem.cond_lens_c_30 = 0.01; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.obj_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.obj_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%% scanning area %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.scanning_type = 1; % eST_Line = 1, eST_Area = 2
-input_multem.scanning_periodic = 1; % 1: true, 0:false (periodic boundary conditions)
-input_multem.scanning_ns = 10; % number of sampling points
-input_multem.scanning_x0 = 2*a; % x-starting point (�)
-input_multem.scanning_y0 = 2.5*b; % y-starting point (�)
-input_multem.scanning_xe = 3*a; % x-final point (�)
-input_multem.scanning_ye = 2.5*b; % y-final point (�)
-
-input_multem.eels_E_loss = 532; % Energy loss (eV)
-input_multem.eels_m_selection = 3; % selection rule
-input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
-input_multem.eels_Z = 8; % atomic type
-
-input_multem.eels_E_loss = 456; % Energy loss (eV)
-input_multem.eels_m_selection = 3; % selection rule
-input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
-input_multem.eels_Z = 22; % atomic type
-
-% input_multem.eels_E_loss = 1940; % Energy loss (eV)
-% input_multem.eels_m_selection = 3; % selection rule
-% input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
-% input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
-% input_multem.eels_Z = 38; % atomic type
-
-% ilm_ilm_show_crystal(1, input_multem.spec_atoms);
-
-%%%%%%%%% find all atoms with Z = 22 %%%%%%%%%%
-ii = find(input_multem.spec_atoms(:, 1)==22);
-n_ii = length(ii);
-%%%%%% do not include some Z(22) atoms %%%%%%%%
-ii_s = ii(randperm(n_ii, round(0.1*n_ii)));
-input_multem.spec_atoms(ii_s, 1) = 1000+ input_multem.spec_atoms(ii_s, 1);
-
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-figure(1); clf;
-for i=1:length(output_multislice.data)
- plot(output_multislice.data(i).image_tot(1).image);
- title(strcat('Thk = ', num2str(output_multislice.thick(i))));
- pause(0.25);
+% output_multem = ilc_multem(system_config, input_multem) perform TEM simulation
+%
+% STEM electron energy loss spectroscopy (EELS) simulation
+%
+% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 61;
+
+%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 5; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
+na = 8;nb = 8;nc = 5;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+%%%%%%%%%%%%%%%%%%%%%% specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes (Å)
+
+%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
+
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.illum_mod = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 88.7414; % Defocus (Å)
+input_multem.cond_lens_c_30 = 0.04; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+
+%%%%%%%%% defocus spread function %%%%%%%%%%%%
+dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
+input_multem.cond_lens_tp_inc_sigma = dsf_sigma; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 5; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%%% source spread function %%%%%%%%%%%%
+ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
+input_multem.obj_lens_ssf_sigma = ssf_sigma; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.obj_lens_ssf_npoints = 4; % # of integration points. It will be only used if illum_mod=4
+
+%%%%%%%%% zero defocus reference %%%%%%%%%%%%
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%% scanning area %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.scan_pat_typ = 1; % eST_Line = 1, eST_Area = 2
+input_multem.scan_pat_pbc = 1; % 1: true, 0:false (periodic boundary conditions)
+input_multem.scan_pat_nsp = 10; % number of sampling points
+input_multem.scan_pat_r_0 = [2*a;2.5*b]; % starting point (Å)
+input_multem.scan_pat_r_e = [3*a;2.5*b]; % final point (Å)
+
+input_multem.eels_E_loss = 532; % Energy loss (eV)
+input_multem.eels_m_selection = 3; % selection rule
+input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+input_multem.eels_Z = 8; % atomic type
+
+input_multem.eels_E_loss = 456; % Energy loss (eV)
+input_multem.eels_m_selection = 3; % selection rule
+input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+input_multem.eels_Z = 22; % atomic type
+
+input_multem.eels_E_loss = 1940; % Energy loss (eV)
+input_multem.eels_m_selection = 3; % selection rule
+input_multem.eels_channelling_type = 1; % eCT_Single_Channelling = 1, eCT_Mixed_Channelling = 2, eCT_Double_Channelling = 3
+input_multem.eels_collection_angle = 100; % Collection half angle (mrad)
+input_multem.eels_Z = 38; % atomic type
+
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+figure(1); clf;
+for i=1:length(output_multem.data)
+ plot(output_multem.data(i).image_tot(1).image);
+ title(strcat('Thk = ', num2str(output_multem.thick(i))));
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_add_amorphous_layer.m b/mex_examples_multem/example_add_amorphous_layer.m
deleted file mode 100644
index 51a65565..00000000
--- a/mex_examples_multem/example_add_amorphous_layer.m
+++ /dev/null
@@ -1,40 +0,0 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-na = 20; nb = 20; nc = 30; ncu = 2; rmsd_3d = 0.085;
-
-[atoms, lx, ly, ~, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-lz = 20;
-Z = 6;
-rms_3d = 0.09;
-d_min = 1.4;
-seed = 1983;
-rho = 2.2;
-lay_pos = 1; %1: top, 2: bottom
-
-tic;
-atoms = ilc_add_amorp_lay(atoms, lx, ly, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
-toc;
-
-ilm_show_crystal(1, atoms)
-view([1 0 0])
-zlim([min(atoms(:, 4)), max(atoms(:, 4))])
-
-disp([lx, ly])
-disp([min(atoms(:, 2)), max(atoms(:, 2))])
-disp([min(atoms(:, 3)), max(atoms(:, 3))])
-disp([min(atoms(:, 4)), max(atoms(:,4))])
-
-% atoms(:, 4) = atoms(:, 4)-min(atoms(:, 4));
-% save_atomic_position_pdb('amorphous.pdb', atoms, a, b, c, 90, 90, 90);
-
-figure(2); clf;
-tic;
-[r, rdf] = ilc_rdf_3d(atoms, 8, 200);
-toc;
-plot(r, rdf,'-+r');
\ No newline at end of file
diff --git a/mex_examples_multem/example_amorp_build.m b/mex_examples_multem/example_amorp_build.m
new file mode 100755
index 00000000..49bcec3b
--- /dev/null
+++ b/mex_examples_multem/example_amorp_build.m
@@ -0,0 +1,43 @@
+clear; clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bs = [50, 50, 50];
+
+Z = 6;
+rms_3d = 0.09;
+occ = 1.0;
+tag = 0;
+d_min = 1.4;
+rho = 2.2;
+seed = 1983;
+
+tic;
+atoms = ilc_amorp_build(Z, rms_3d, occ, tag, bs, d_min, rho, seed);
+toc;
+
+disp(size(atoms))
+figure(1); clf;
+plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4), '.r');
+axis equal;
+
+NA = 6.022140857e+23;
+
+d = 0;
+lx0 = bs(1)-d;
+ly0 = bs(2)-d;
+lz0 = bs(3);
+ii = find((0.5*d<=atoms(:, 2)) & (atoms(:, 2)<=bs(1)-0.5*d) & (0.5*d<=atoms(:, 3)) & (atoms(:, 3)<=bs(2)-0.5*d));
+% atoms = atoms(ii, :);
+density = length(atoms)*12.011/(lx0*ly0*lz0*NA*(1e-8)^3);
+
+disp([rho, density])
+tic;
+[r, rdf] = ilc_rdf(atoms(:, 2:4), 8, 200);
+toc;
+
+
+figure(2);clf;
+plot(r, rdf, '-+r');
\ No newline at end of file
diff --git a/mex_examples_multem/example_amorp_lay_add.m b/mex_examples_multem/example_amorp_lay_add.m
new file mode 100755
index 00000000..6a702548
--- /dev/null
+++ b/mex_examples_multem/example_amorp_lay_add.m
@@ -0,0 +1,51 @@
+clear; clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+na = 10; nb = 10; nc = 20; ncu = 2;rmsd_3d = 0.085;
+
+[atoms, lx, ly, lz, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+% ilm_show_xtl(1, atoms)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bs = [lx, ly, 30];
+
+Z = 6;
+rms_3d = 0.09;
+occ = 1.0;
+tag = 0;
+d_min = 1.4;
+rho = 2.2;
+lay_pos = 21; %1: top, 2: bottom
+seed = 1983;
+
+tic;
+atoms = ilc_amorp_lay_add(atoms(:, 1:5), Z, rms_3d, occ, tag, bs, d_min, rho, lay_pos, seed);
+toc;
+
+ilm_show_xtl(1, atoms)
+view([1 0 0])
+zlim([min(atoms(:, 4)), max(atoms(:, 4))])
+
+disp([lx, ly])
+disp([min(atoms(:, 2)), max(atoms(:, 2))])
+disp([min(atoms(:, 3)), max(atoms(:, 3))])
+disp([min(atoms(:, 4)), max(atoms(:, 4))])
+
+nbins = round((max(atoms(:, 4))-min(atoms(:, 4)))/0.1);
+tic;
+[x, y] = ilc_hist(atoms(:, 4), nbins);
+toc;
+
+atoms(:, 4) = atoms(:, 4)-min(atoms(:, 4));
+% ilm_write_ap_pdb('amorphous.pdb', atoms, a, b, c, 90, 90, 90);
+
+figure(2); clf;
+subplot(1, 2, 1);
+plot(x, y, '-r');
+tic;
+[r, rdf] = ilc_rdf(atoms(:, 2:4), 8, 200);
+toc;
+subplot(1, 2, 2);
+plot(r, rdf, '-+r');
\ No newline at end of file
diff --git a/mex_examples_multem/example_amorphous_specimen.m b/mex_examples_multem/example_amorphous_specimen.m
deleted file mode 100644
index 8c8c1962..00000000
--- a/mex_examples_multem/example_amorphous_specimen.m
+++ /dev/null
@@ -1,44 +0,0 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-
-lx = 50;
-ly = 50;
-lz = 20;
-Z = 6;
-rms_3d = 0.09;
-d_min = 1.4;
-seed = 1983;
-rho = 2.2;
-
-tic;
-atoms = ilc_amorp_spec(lx, ly, lz, d_min, Z, rms_3d, rho, seed);
-toc;
-
-% path = strcat('input_spec\Si_',num2str(lx), 'x', num2str(ly), 'x', num2str(lz), '_', num2str(seed), '.mat');
-% save(path, 'atoms');
-% disp([iseed, lz]);
-figure(1); clf;
-plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4),'.r');
-axis equal;
-
-NA = 6.022140857e+23;
-
-d = 0;
-lx0 = lx-d;
-ly0 = ly-d;
-lz0 = lz;
-ii = find((0.5*d<=atoms(:,2))&(atoms(:,2)<=lx-0.5*d)&(0.5*d<=atoms(:,3))&(atoms(:,3)<=ly-0.5*d));
-% atoms = atoms(ii, :);
-density = length(atoms)*12.011/(lx0*ly0*lz0*NA*(1e-8)^3)
-
-tic;
-[r, rdf] = ilc_rdf_3d(atoms, 8, 200);
-toc;
-
-figure(2); clf;
-plot(r, rdf,'-+r');
\ No newline at end of file
diff --git a/mex_examples_multem/example_apply_ctf.m b/mex_examples_multem/example_apply_ctf.m
deleted file mode 100644
index 9fb33712..00000000
--- a/mex_examples_multem/example_apply_ctf.m
+++ /dev/null
@@ -1,115 +0,0 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% inclusion of TEM aberrerations into a exitwve simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 110;
-input_multem.pn_seed = 300183;
-input_multem.pn_single_conf = 0; % 1: true, 0:false
-input_multem.pn_nconf = 5;
-
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-input_multem.bwl = 0;
-
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-na = 4; nb = 4; nc = 10; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 15.836; % Defocus (�)
-input_multem.obj_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
-input_multem.obj_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 10; % # integration steps for the defocus Spread. It will be only used if illumination_model=4
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
-clear ilc_multem;
-tic;
-output_multislice_0 = input_multem.ilc_multem;
-toc;
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 32;
-clear ilc_multem;
-tic;
-output_multislice_1 = input_multem.ilc_multem;
-toc;
-
-%%%%%%%%%%%%%%%%%%%%% apply contrast transfer function %%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = output_multislice_0.data.psi_coh; % user define incident wave
-clear ilc_multem;
-tic;
-output_multislice_2 = input_multem.ilc_apply_ctf;
-toc;
-
-figure(1);
-subplot(1, 3, 1);
-imagesc(abs(output_multislice_0.data.psi_coh).^2);
-title('Total intensity');
-axis image;
-colormap gray;
-
-subplot(1, 3, 2);
-imagesc(abs(output_multislice_1.data.m2psi_tot));
-title('Total intensity');
-axis image;
-colormap gray;
-
-subplot(1, 3, 3);
-imagesc(abs(output_multislice_2.psi).^2);
-title('Total intensity');
-axis image;
-colormap gray;
\ No newline at end of file
diff --git a/mex_examples_multem/example_atomic_info.m b/mex_examples_multem/example_atomic_info.m
new file mode 100755
index 00000000..99b19a07
--- /dev/null
+++ b/mex_examples_multem/example_atomic_info.m
@@ -0,0 +1,67 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+% S = ilc_atomic_info(pot_parm_typ) get atomic properties
+%
+% Pot_Par is an integer number which is link to the atomic potential parameterization
+
+% 1: Doyle_0_4
+% 2: Peng_0_4
+% 3: Peng_0_12
+% 4: Kirkland_0_12
+% 5: Weickenmeier_0_12
+% 6: Lobato_0_12
+%
+% outputs:
+% name % atom name
+% Z % atomic number
+% A % mass number
+% m % atomic mass
+% rn % experimental nuclear radius (Angs.)
+% ra % experimental atomic radius (Angs.)
+% eels_maj_edg % major eels edges
+% eels_min_edg % minor eels edges
+% feg % electron scattering factor coefficients
+% fxg % x-ray scattering factor coefficients
+% pr % electron density coefficients
+% vr % potential coefficients
+% vzp % projected potential coefficients
+%
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+pot_parm_typ = 6;
+tic;
+S = ilc_atomic_info(pot_parm_typ);
+toc;
+
+k = 79;cc = '-+r';
+S(k).coef(1).feg
+S(k).coef(1).fxg
+S(k).coef(1).pr
+S(k).coef(1).vr
+S(k).coef(1).vzp
+
+S
+
+figure(1); clf;
+Z = (1:103)';
+y = zeros(size(Z));
+for i = 1:5
+ hold on;
+ subplot(2, 3, i);
+ for j = 1:103
+ y(j) = S(j).coef(1).feg.cnl(i);
+ end
+ plot(Z, y, '-*r');
+ set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+ title('Non-Lineal coeeficients');
+ ylabel(strcat('cnl[', num2str(i), ']'), 'FontSize', 14);
+ xlabel('Z', 'FontSize', 12);
+ xlim([1 103]);
+ legend(strcat('cnl[', num2str(i), ']'));
+ set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
+end
\ No newline at end of file
diff --git a/mex_examples_multem/example_atomic_radius.m b/mex_examples_multem/example_atomic_radius.m
new file mode 100755
index 00000000..34386603
--- /dev/null
+++ b/mex_examples_multem/example_atomic_radius.m
@@ -0,0 +1,47 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+% r = ilc_atomic_radius(Pot_Par, dim, Vrl) calculates the atomic radius
+%
+% Pot_Par is an integer number which is link to the atomic potential parameterization
+%
+% 1: Doyle_0_4
+% 2: Peng_0_4
+% 3: Peng_0_12
+% 4: Kirkland_0_12
+% 5: Weickenmeier_0_12
+% 6: Lobato_0_12
+%
+% dim is the dimension with possible values 2 and 3
+%
+% Vrl is the atomic potential threshold in eV
+%
+% r(:, 1) = integral {r^2 V(r)dr} / integral{V(r)dr}
+% r(:, 2) are calculated by solving the equation V(r) = Vrl
+% r(:, 3) are the experimental values
+%
+% Copyright 2021 Ivan Lobato
+
+clear; clc;
+dim = 3;
+Vrl = 0.01;
+pot_parm_typ = 6;
+z = 1:103;
+tic;
+r = ilc_atomic_radius(pot_parm_typ, dim, Vrl);
+toc;
+
+figure(1); clf;
+
+plot(z, r(:, 1), '-*r', z, r(:, 2), '-*b', z, r(:, 3), '-*k');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic radius');
+ylabel('$\mathrm{radius}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+axis([1 103 0 1.1*max(r(:))]);
+legend('rms', 'Cut-off', 'Experimental');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_beam_self_interaction.m b/mex_examples_multem/example_beam_self_interaction.m
old mode 100644
new mode 100755
index e7f81853..5f2ceada
--- a/mex_examples_multem/example_beam_self_interaction.m
+++ b/mex_examples_multem/example_beam_self_interaction.m
@@ -1,129 +1,125 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-input_multem.E_0 = 200; % Acceleration Voltage (keV)
-input_multem.theta = 0.00;
-input_multem.phi = 0.0;
-
-input_multem.spec_lx = 20;
-input_multem.spec_ly = 20;
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = 0.0; % x position
-input_multem.iw_y = 0.0; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 0; % Defocus (�)
-input_multem.cond_lens_c_30 = 0.002; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-
-input_multem.iw_x = 0.5*input_multem.spec_lx;
-input_multem.iw_y = 0.5*input_multem.spec_ly;
-
-ax = 0:input_multem.spec_lx/input_multem.nx:input_multem.spec_lx;
-ay = 0:input_multem.spec_ly/input_multem.ny:input_multem.spec_ly;
-
-df0 = ilc_scherzer_defocus(input_multem.E_0, input_multem.cond_lens_c_30);
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%% simulation box size %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.spec_lx = 20;
-input_multem.spec_ly = 20;
-input_multem.iw_x = 0.5*input_multem.spec_lx;
-input_multem.iw_y = 0.5*input_multem.spec_ly;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%The incoming beam at Scherzer defocus at z=0 %%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_c_10 = df0;
-output_incident_wave = input_multem.ilc_incident_wave;
-psi_i = output_incident_wave.psi_0;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% The incoming beam at Scherzer defocus after traveling a thickness(z=thk) %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-thk = 250;
-input_multem.cond_lens_c_10 = (df0+thk);
-output_incident_wave = input_multem.ilc_incident_wave;
-psi_o = output_incident_wave.psi_0;
-
-
-figure(1);
-subplot(1, 2, 1);
-imagesc(ax, ay, abs(psi_i).^2);
-title(['intensity - df = ', num2str(df0)]);
-axis image;
-colormap gray;
-subplot(1, 2, 2);
-imagesc(ax, ay, abs(psi_o).^2);
-title(['intensity - df = ', num2str(df0+thk)]);
-axis image;
-colormap gray;
-pause(0.5);
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%% simulation box size %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.spec_lx = 50;
-input_multem.spec_ly = 50;
-input_multem.iw_x = 0.5*input_multem.spec_lx;
-input_multem.iw_y = 0.5*input_multem.spec_ly;
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%The incoming beam at Scherzer defocus at z=0 %%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_c_10 = df0;
-output_incident_wave = input_multem.ilc_incident_wave;
-psi_i = output_incident_wave.psi_0;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% The incoming beam at Scherzer defocus after traveling a thickness(z=thk) %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-thk = 250;
-input_multem.cond_lens_c_10 = (df0+thk);
-output_incident_wave = input_multem.ilc_incident_wave;
-psi_o = output_incident_wave.psi_0;
-
-
-figure(2);
-subplot(1, 2, 1);
-imagesc(ax, ay, abs(psi_i).^2);
-title(['intensity - df = ', num2str(df0)]);
-axis image;
-colormap gray;
-subplot(1, 2, 2);
-imagesc(ax, ay, abs(psi_o).^2);
-title(['intensity - df = ', num2str(df0+thk)]);
-axis image;
-colormap gray;
+clear; clc;
+addpath([fileparts(pwd) filesep 'mex_bin'])
+addpath([fileparts(pwd) filesep 'crystalline_materials'])
+addpath([fileparts(pwd) filesep 'matlab_functions'])
+
+
+input_multem = multem_default_values(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_nthread = 4;
+system_config.gpu_device = 0;
+
+input_multem.E_0 = 200; % Acceleration Voltage (keV)
+input_multem.theta = 0.00;
+input_multem.phi = 0.0;
+
+input_multem.spec_lx = 20;
+input_multem.spec_ly = 20;
+
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+input_multem.iw_x = 0.0; % x position
+input_multem.iw_y = 0.0; % y position
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 0; % Defocus (Å)
+input_multem.cond_lens_c_30 = 0.002; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_ti_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1); otherwise (Å)
+input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+
+input_multem.iw_x = 0.5*input_multem.spec_lx;
+input_multem.iw_y = 0.5*input_multem.spec_ly;
+
+ax = 0:input_multem.spec_lx/input_multem.nx:input_multem.spec_lx;
+ay = 0:input_multem.spec_ly/input_multem.ny:input_multem.spec_ly;
+
+df0 = ilc_scherzer_defocus(input_multem.E_0, input_multem.cond_lens_c_30);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%% simulation box size %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_lx = 20;
+input_multem.spec_ly = 20;
+input_multem.iw_x = 0.5*input_multem.spec_lx;
+input_multem.iw_y = 0.5*input_multem.spec_ly;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%The incoming beam at Scherzer defocus at z=0 %%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_c_10 = df0;
+output_incident_wave = ilc_incident_wave(system_config, input_multem);
+psi_i = output_incident_wave.psi_0;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% The incoming beam at Scherzer defocus after traveling a thickness(z=thk) %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+thk = 250;
+input_multem.cond_lens_c_10 = (df0+thk);
+output_incident_wave = ilc_incident_wave(system_config, input_multem);
+psi_o = output_incident_wave.psi_0;
+
+
+figure(1);
+subplot(1, 2, 1);
+imagesc(ax, ay, abs(psi_i).^2);
+title(['intensity - df = ', num2str(df0)]);
+axis image;
+colormap gray;
+subplot(1, 2, 2);
+imagesc(ax, ay, abs(psi_o).^2);
+title(['intensity - df = ', num2str(df0+thk)]);
+axis image;
+colormap gray;
+pause(0.5);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%% simulation box size %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_lx = 50;
+input_multem.spec_ly = 50;
+input_multem.iw_x = 0.5*input_multem.spec_lx;
+input_multem.iw_y = 0.5*input_multem.spec_ly;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%The incoming beam at Scherzer defocus at z=0 %%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_c_10 = df0;
+output_incident_wave = ilc_incident_wave(system_config, input_multem);
+psi_i = output_incident_wave.psi_0;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% The incoming beam at Scherzer defocus after traveling a thickness(z=thk) %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+thk = 250;
+input_multem.cond_lens_c_10 = (df0+thk);
+output_incident_wave = ilc_incident_wave(system_config, input_multem);
+psi_o = output_incident_wave.psi_0;
+
+
+figure(2);
+subplot(1, 2, 1);
+imagesc(ax, ay, abs(psi_i).^2);
+title(['intensity - df = ', num2str(df0)]);
+axis image;
+colormap gray;
+subplot(1, 2, 2);
+imagesc(ax, ay, abs(psi_o).^2);
+title(['intensity - df = ', num2str(df0+thk)]);
+axis image;
+colormap gray;
pause(0.5);
\ No newline at end of file
diff --git a/mex_examples_multem/example_check_STEM_input.m b/mex_examples_multem/example_check_STEM_input.m
old mode 100644
new mode 100755
index 21d2afb6..f90ce1a1
--- a/mex_examples_multem/example_check_STEM_input.m
+++ b/mex_examples_multem/example_check_STEM_input.m
@@ -8,40 +8,40 @@
probe_size = 10;
%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%%%%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
+input_multem = multem_default_values(); % Load default values;
%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 12;
-input_multem.system_conf.gpu_device = 0;
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_nthread = 12;
+system_config.gpu_device = 0;
%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 11;
+input_multem.em_sim_typ = 11;
%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
+%%%%%%%%%%%%%%%%%%%%%%% specimen slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 3; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 100183; % Random seed(frozen phonon)
+%%%%%%%%%%%%%%% atomic vibrations model %%%%%%%%%%%%%%%%%%
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_coh_contrib = 0;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 3; % true: specific phonon configuration, false: number of frozen phonon configurations
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 100183; % Random seed(frozen phonon)
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%% specimen information %%%%%%%%%%%%%%%%%%%%%%%
rmsd_3d = 0.0697;
[atoms, lx, ly, lz] = ilm_read_ap_xyz('Pt_twin.xyz', rmsd_3d);
-atoms = ilm_center_spec(atoms, lx, ly, lz);
+atoms = center_spec(atoms, lx, ly, lz);
% centre point
p0 = [lx/2 ly/2 0];
@@ -50,7 +50,7 @@
b_crop = atoms(:,2) < (p0(1)-(lx_c/2)) | atoms(:,2) > (p0(1)+(lx_c/2)) | atoms(:,3) < (p0(2)-(lx_c/2)) | atoms(:,3) > (p0(2)+(lx_c/2));
atoms(b_crop,:) = [];
-atoms = ilm_center_spec(atoms, lx_c, lx_c, lz);
+atoms = center_spec(atoms, lx_c, lx_c, lz);
lx = lx_c;
ly = lx_c;
@@ -68,14 +68,14 @@
input_multem.ny = ny;
input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%% microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
input_multem.E_0 = 300; % Acceleration Voltage (keV)
input_multem.theta = 0.0; % Till ilumination (�)
input_multem.phi = 0.0; % Till ilumination (�)
%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+input_multem.illum_mod = 1; % 1: coherente mode, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
input_multem.cond_lens_m = 0; % Vortex momentum
@@ -90,21 +90,21 @@
input_multem.cond_lens_outer_aper_ang = 21.1; % Outer aperture (mrad)
%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.scanning_type = 2; % eST_Line = 1, eST_Area = 2
-input_multem.scanning_periodic = 0; % 1: true, 0:false (periodic boundary conditions)
-input_multem.scanning_ns = ceil(scan_field/dx);
+input_multem.scan_pat_typ = 2; % eST_Line = 1, eST_Area = 2
+input_multem.scan_pat_pbc = 0; % 1: true, 0:false (periodic boundary conditions)
+input_multem.scan_pat_nsp = ceil(scan_field/dx);
input_multem.scanning_x0 = (lx-scan_field)/2;
input_multem.scanning_y0 = (ly-scan_field)/2;
input_multem.scanning_xe = (lx+scan_field)/2;
input_multem.scanning_ye = (ly+scan_field)/2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Detector %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.detector.type = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
+input_multem.detector.typ = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
input_multem.detector.cir(1).inner_ang = 60; % Inner angle(mrad)
input_multem.detector.cir(1).outer_ang = 190; % Outer angle(mrad)
@@ -115,7 +115,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Run %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% clear ilc_multem;
% tic;
-% output_multislice = input_multem.ilc_multem;
+% output_multislice = ilc_multem(system_config, input_multem);
% toc;
diff --git a/mex_examples_multem/example_crystal_by_layers.m b/mex_examples_multem/example_crystal_by_layers.m
deleted file mode 100644
index 94fe76c1..00000000
--- a/mex_examples_multem/example_crystal_by_layers.m
+++ /dev/null
@@ -1,35 +0,0 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-xtl_parm.na = 10;
-xtl_parm.nb = 10;
-xtl_parm.nc = 10;
-xtl_parm.a = 4.0780;
-xtl_parm.b = 4.0780;
-xtl_parm.c = 4.0780;
-xtl_parm.nuLayer = 2;
-occ = 1;
-region = 0;
-charge = 0;
-% Au = 79
-%Z x y z sigma occupancy
-rmsd_3d = 0.085;
-xtl_parm.uLayer(1).atoms = [79, 0.0, 0.0, 0.0, rmsd_3d, occ, region, charge; 79, 0.5, 0.5, 0.0, rmsd_3d, occ, region, charge];
-xtl_parm.uLayer(2).atoms = [79, 0.0, 0.5, 0.5, rmsd_3d, occ, region, charge; 79, 0.5, 0.0, 0.5, rmsd_3d, occ, region, charge];
-
-tic;
-Crys3D = ilc_crystal_by_lays(xtl_parm);
-toc;
-
-na = 1;
-nb = 1;
-nc = 1;
-[Crys3D, lx, ly, lz, a, b, c, dz] = SrTiO3001_xtl(na, nb, nc, 2, 0.085);
-[lx, ly]
-% show crystal
-clf;
-ilm_show_crystal(1, Crys3D);
\ No newline at end of file
diff --git a/mex_examples_multem/example_det_min_sampling.m b/mex_examples_multem/example_det_min_sampling.m
new file mode 100755
index 00000000..9f2ba64e
--- /dev/null
+++ b/mex_examples_multem/example_det_min_sampling.m
@@ -0,0 +1,14 @@
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+E_0 = 300;
+bs = [50, 35]; % simulations box size
+theta = [80, 100, 120, 200, 215, 250]; % mrad
+
+% minimun number of pixels to cover the detector
+np = ilc_det_min_spl(E_0, bs, theta);
+disp(np)
\ No newline at end of file
diff --git a/mex_examples_multem/example_feg.m b/mex_examples_multem/example_feg.m
old mode 100644
new mode 100755
index 8d263ebe..dde3d3b4
--- a/mex_examples_multem/example_feg.m
+++ b/mex_examples_multem/example_feg.m
@@ -1,43 +1,43 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-Z = 50;
-occ = 1;
-region = 0;
-charge = 0;
-
-gmin = 0; gmax = 12; ng = 512;
-dg = (gmax-gmin)/(ng-1);
-g = gmin:dg:gmax;
-
-[f1, df1] = ilc_feg(1, Z, charge, g);
-[f2, df2] = ilc_feg(2, Z, charge, g);
-[f3, df3] = ilc_feg(3, Z, charge, g);
-[f4, df4] = ilc_feg(4, Z, charge, g);
-[f5, df5] = ilc_feg(5, Z, charge, g);
-[f6, df6] = ilc_feg(6, Z, charge, g);
-figure(1); clf;
-
-subplot(1, 2, 1);
-plot(g, f1, '-k', g, f2, '-b', g, f3, '-c', g, f4, '-m', g, f5, '-r', g, f6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Electron Scattering factor');
-ylabel('$\displaystyle f_e(g)$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{g}$','interpreter','latex','FontSize',12);
-xlim([0 gmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-subplot(1, 2, 2);
-plot(g, df1, '-k', g, df2, '-b', g, df3, '-c', g, df4, '-m', g, df5, '-r', g, df6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Derivative of the electron Scattering factor');
-ylabel('$\displaystyle \frac{d f_e(g)}{dg}$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{g}$','interpreter','latex','FontSize',12);
-xlim([0 gmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-set(gcf,'units','normalized','outerposition',[0 0 1 1]);
\ No newline at end of file
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath([ fileparts(pwd), filesep, 'mex_bin'])
+
+Z = 79;
+occ = 1;
+tag = 0;
+charge = 0;
+
+gmin = 0;gmax = 20;ng = 512;
+dg = (gmax-gmin)/(ng-1);
+g = gmin:dg:gmax;
+
+tic;
+[f1, df1] = ilc_feg(1, Z, charge, g);
+[f2, df2] = ilc_feg(2, Z, charge, g);
+[f3, df3] = ilc_feg(3, Z, charge, g);
+[f4, df4] = ilc_feg(4, Z, charge, g);
+[f5, df5] = ilc_feg(5, Z, charge, g);
+[f6, df6] = ilc_feg(6, Z, charge, g);
+toc;
+
+figure(1); clf;
+
+subplot(1, 2, 1);
+plot(g, f1, '-k', g, f2, '-b', g, f3, '-c', g, f4, '-m', g, f5, '-r', g, f6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Electron Scattering factor');
+ylabel('$\displaystyle f_e(g)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{g}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 gmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+subplot(1, 2, 2);
+plot(g, df1, '-k', g, df2, '-b', g, df3, '-c', g, df4, '-m', g, df5, '-r', g, df6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Derivative of the electron Scattering factor');
+ylabel('$\displaystyle \frac{d f_e(g)}{dg}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{g}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 gmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_fxeg_data.m b/mex_examples_multem/example_fxeg_data.m
new file mode 100755
index 00000000..a1d7cad7
--- /dev/null
+++ b/mex_examples_multem/example_fxeg_data.m
@@ -0,0 +1,27 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath([ fileparts(pwd), filesep, 'mex_bin'])
+
+Z = 24; dg = 1;
+% Load Kirkland X-ray and electron scattering tabulated data
+tic;
+[g, fxg, feg] = ilc_fxeg_data(Z, dg);
+toc;
+
+a = [3.028317848436913e+00 -9.553939330814323e+01 9.617615623521981e+01 3.597773159579877e-02 3.914928907184223e-04];
+b = [8.359115043146318e+00 1.802637902641032e+00 1.775094889570472e+00 5.481444121431137e-02 3.998289689160348e-03];
+a_0 = 0.52917721077817892;
+
+feg_p = sum(a.*(2+b.*g.^2)./(1+b.*g.^2).^2, 2);
+% feg = (Z-fxg)./(2*pi^2*a_0*g.^2);
+
+figure(1); clf;
+plot(g, feg, '-+r', g, feg_p, '-+b');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Tabulated electron Scattering factor');
+ylabel('$\displaystyle f_e(g)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{g}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 g(end)]);
+legend('Kirkland [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_fxg.m b/mex_examples_multem/example_fxg.m
old mode 100644
new mode 100755
index 4baaf8d5..e1e38bff
--- a/mex_examples_multem/example_fxg.m
+++ b/mex_examples_multem/example_fxg.m
@@ -1,44 +1,43 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-Z = 49;
-occ = 1;
-region = 0;
-charge = 0;
-
-gmin = 0; gmax = 20; ng = 512;
-dg = (gmax-gmin)/(ng-1);
-g = gmin:dg:gmax;
-
-[f1, df1] = ilc_fxg(1, Z, charge, g);
-[f2, df2] = ilc_fxg(2, Z, charge, g);
-[f3, df3] = ilc_fxg(3, Z, charge, g);
-[f4, df4] = ilc_fxg(4, Z, charge, g);
-[f5, df5] = ilc_fxg(5, Z, charge, g);
-[f6, df6] = ilc_fxg(6, Z, charge, g);
-
-figure(1); clf;
-
-subplot(1, 2, 1);
-plot(g, f1, '-k', g, f2, '-b', g, f3, '-c', g, f4, '-m', g, f5, '-r', g, f6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('X-ray Scattering factor');
-ylabel('$\displaystyle f_x(g)$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{g}$','interpreter','latex','FontSize',12);
-xlim([0 gmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-subplot(1, 2, 2);
-plot(g, df1, '-k', g, df2, '-b', g, df3, '-c', g, df4, '-m', g, df5, '-r', g, df6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Derivative of the X-ray Scattering factor');
-ylabel('$\displaystyle \frac{d f_x(g)}{dg}$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{g}$','interpreter','latex','FontSize',12);
-xlim([0 gmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-set(gcf,'units','normalized','outerposition',[0 0 1 1]);
\ No newline at end of file
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath([ fileparts(pwd), filesep, 'mex_bin'])
+
+Z = 35;
+occ = 1;
+tag = 0;
+charge = 0;
+
+gmin = 0;gmax = 10;ng = 512;
+dg = (gmax-gmin)/(ng-1);
+g = gmin:dg:gmax;
+
+tic;
+[f1, df1] = ilc_fxg(1, Z, charge, g);
+[f2, df2] = ilc_fxg(2, Z, charge, g);
+[f3, df3] = ilc_fxg(3, Z, charge, g);
+[f4, df4] = ilc_fxg(4, Z, charge, g);
+[f5, df5] = ilc_fxg(5, Z, charge, g);
+[f6, df6] = ilc_fxg(6, Z, charge, g);
+toc;
+
+figure(1); clf;
+
+subplot(1, 2, 1);
+plot(g, f1, '-k', g, f2, '-b', g, f3, '-c', g, f4, '-m', g, f5, '-r', g, f6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('X-ray Scattering factor');
+ylabel('$\displaystyle f_x(g)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{g}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 gmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+subplot(1, 2, 2);
+plot(g, df1, '-k', g, df2, '-b', g, df3, '-c', g, df4, '-m', g, df5, '-r', g, df6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Derivative of the X-ray Scattering factor');
+ylabel('$\displaystyle \frac{d f_x(g)}{dg}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{g}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 gmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_incident_wave_1.m b/mex_examples_multem/example_incident_wave_1.m
old mode 100644
new mode 100755
index dcd9bc4f..988d7f17
--- a/mex_examples_multem/example_incident_wave_1.m
+++ b/mex_examples_multem/example_incident_wave_1.m
@@ -1,76 +1,73 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Incident wave simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0;
-input_multem.phi = 0.0;
-
-input_multem.spec_lx = 20;
-input_multem.spec_ly = 20;
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-input_multem.iw_x = 0.5*input_multem.spec_lx; % x position
-input_multem.iw_y = 0.5*input_multem.spec_ly; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = -150.00; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-for x = (0.4:0.025:0.6)*input_multem.spec_lx
- for y = (0.4:0.025:0.6)*input_multem.spec_ly
- input_multem.iw_x = x;
- input_multem.iw_y = y;
-
- tic;
- output_incident_wave = input_multem.ilc_incident_wave;
- toc;
- psi_0 = output_incident_wave.psi_0;
- sum(abs(output_incident_wave.psi_0(:)).^2)
- figure(2);
- subplot(1, 2, 1);
- imagesc(abs(psi_0).^2);
- title('intensity');
- axis image;
- colormap gray;
-
- subplot(1, 2, 2);
- imagesc(angle(psi_0));
- title('phase');
- axis image;
- colormap gray;
- pause(0.01);
- end
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+input_multem.E_0 = 60; % Acceleration Voltage (keV)
+input_multem.theta = 0.0;
+input_multem.phi = 0.0;
+
+input_multem.spec_bs_x = 20;
+input_multem.spec_bs_y = 20;
+
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 111.50; % Defocus (Å)
+input_multem.cond_lens_c_30 = -0.0007; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.6634; % Outer aperture (mrad)
+input_multem.cond_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+% for x = (0.5:0.1:0.6)*input_multem.spec_bs_x
+% for y = (0.6:0.1:0.8)*input_multem.spec_bs_y
+for x = 0.5*input_multem.spec_bs_x
+ for y = 0.5*input_multem.spec_bs_y
+ input_multem.beam_pos = [x;y];
+
+ tic;
+ output_incident_wave = ilc_incident_wave(system_config, input_multem);
+ toc;
+ psi_0 = output_incident_wave.psi_0;
+ sum(abs(output_incident_wave.psi_0(:)).^2)
+ figure(2);
+ subplot(1, 2, 1);
+ imagesc(abs(psi_0).^2);
+ title('intensity');
+ axis image;
+ colormap gray;
+
+ subplot(1, 2, 2);
+ imagesc(angle(psi_0));
+ title('phase');
+ axis image;
+ colormap gray;
+ pause(0.01);
+ end
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_incident_wave_2.m b/mex_examples_multem/example_incident_wave_2.m
old mode 100644
new mode 100755
index a49272eb..013bdab9
--- a/mex_examples_multem/example_incident_wave_2.m
+++ b/mex_examples_multem/example_incident_wave_2.m
@@ -1,76 +1,69 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Incident wave simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-input_multem.E_0 = 200; % Acceleration Voltage (keV)
-input_multem.theta = 0.0;
-input_multem.phi = 0.0;
-
-input_multem.spec_lx = 50;
-input_multem.spec_ly = 50;
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-input_multem.iw_x = 0.0; % x position
-input_multem.iw_y = 0.0; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = -15.836; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-
-for x = (0.4:0.025:0.6)*input_multem.spec_lx
- for y = (0.4:0.025:0.6)*input_multem.spec_ly
-
- input_multem.iw_x = x;
- input_multem.iw_y = y;
-% input_multem.iw_x = input_multem.spec_lx/2;
-% input_multem.iw_y = input_multem.spec_ly/2;
-
- tic;
- output_incident_wave = input_multem.ilc_incident_wave;
- toc;
- psi_0 = flipud(output_incident_wave.psi_0);
- figure(2);
- subplot(1, 2, 1);
- imagesc(abs(psi_0).^2);
- title('intensity');
- axis image;
- colormap gray;
-
- subplot(1, 2, 2);
- imagesc(angle(psi_0));
- title('phase');
- axis image;
- colormap gray;
- pause(0.1);
- end
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+input_multem.E_0 = 200; % Acceleration Voltage (keV)
+input_multem.theta = 0.0;
+input_multem.phi = 0.0;
+
+input_multem.spec_bs_x = 50;
+input_multem.spec_bs_y = 50;
+
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [0; 0];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = -15.836; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+
+for x = (0.4:0.025:0.6)*input_multem.spec_bs_x
+ for y = (0.4:0.025:0.6)*input_multem.spec_bs_y
+
+ input_multem.beam_pos = [x;y];
+
+ tic;
+ output_incident_wave = ilc_incident_wave(system_config, input_multem);
+ toc;
+ psi_0 = flipud(output_incident_wave.psi_0);
+ figure(2);
+ subplot(1, 2, 1);
+ imagesc(abs(psi_0).^2);
+ title('intensity');
+ axis image;
+ colormap gray;
+
+ subplot(1, 2, 2);
+ imagesc(angle(psi_0));
+ title('phase');
+ axis image;
+ colormap gray;
+ pause(0.1);
+ end
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_incident_wave_3.m b/mex_examples_multem/example_incident_wave_3.m
old mode 100644
new mode 100755
index 0f7bfdc9..1daccac6
--- a/mex_examples_multem/example_incident_wave_3.m
+++ b/mex_examples_multem/example_incident_wave_3.m
@@ -1,82 +1,77 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Incident wave simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-input_multem.E_0 = 120; % Acceleration Voltage (keV)
-input_multem.theta = 0.00;
-input_multem.phi = 0.0;
-
-input_multem.spec_lx = 200;
-input_multem.spec_ly = 200;
-
-input_multem.nx = 1120;
-input_multem.ny = 1120;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-sum(abs(input_multem.iw_psi(:)).^2)
-input_multem.iw_x = 0.0; % x position
-input_multem.iw_y = 0.0; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = -100; % Defocus (�)
-input_multem.cond_lens_c_30 = 0.00; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 20; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-
-input_multem.iw_x = 0.5*input_multem.spec_lx;
-input_multem.iw_y = 0.5*input_multem.spec_ly;
-
-df0 = -15.836;
-ax = 0:input_multem.spec_lx/input_multem.nx:input_multem.spec_lx;
-ay = 0:input_multem.spec_ly/input_multem.ny:input_multem.spec_ly;
-
-thick = 300;
-for df = (df0+thick)
-% input_multem.cond_lens_c_10 = df; %Angs
-
- tic;
- output_incident_wave = input_multem.ilc_incident_wave;
- toc;
- psi_0 = output_incident_wave.psi_0;
- sum(abs(psi_0(:)).^2)
-
- figure(2);
- subplot(1, 2, 1);
-
- imagesc(ax, ay, abs(psi_0).^2);
- title(strcat('intensity - df = ', num2str(df)));
- axis image;
- colormap gray;
-
- subplot(1, 2, 2);
- imagesc(ax, ay, angle(psi_0));
- title(strcat('phase - df = ', num2str(df)));
- axis image;
- colormap gray;
- pause(0.5);
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 1; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 1;
+system_config.gpu_device = 0;
+
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.00;
+input_multem.phi = 0.0;
+
+input_multem.spec_bs_x = 7*4.078;
+input_multem.spec_bs_y = 7*4.078;
+
+input_multem.nx = 1792;
+input_multem.ny = 1792;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+sum(abs(input_multem.incdt_wav_psi(:)).^2)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [0; 0];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 0; % Defocus (Å)
+input_multem.cond_lens_c_30 = 0.001; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+df0 = -15.836;
+ax = 0:input_multem.spec_bs_x/input_multem.nx:input_multem.spec_bs_x;
+ay = 0:input_multem.spec_bs_y/input_multem.ny:input_multem.spec_bs_y;
+for df = 20
+ input_multem.cond_lens_c_10 = df; %Angs
+
+ tic;
+ output_incident_wave = ilc_incident_wave(system_config, input_multem);
+ toc;
+ psi_0 = output_incident_wave.psi_0;
+ sum(abs(psi_0(:)).^2)
+
+ figure(2);
+ subplot(1, 2, 1);
+
+ imagesc(ax, ay, abs(psi_0).^2);
+ title(strcat('intensity - df = ', num2str(df)));
+ axis image;
+ colormap gray;
+
+ subplot(1, 2, 2);
+ imagesc(ax, ay, angle(psi_0));
+ title(strcat('phase - df = ', num2str(df)));
+ axis image;
+ colormap gray;
+ pause(0.5);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_incident_wave_4.m b/mex_examples_multem/example_incident_wave_4.m
old mode 100644
new mode 100755
index 694f8e3a..3c41a453
--- a/mex_examples_multem/example_incident_wave_4.m
+++ b/mex_examples_multem/example_incident_wave_4.m
@@ -1,75 +1,69 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Incident wave simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) '/mex_bin'])
-addpath([fileparts(pwd) '/crystalline_materials'])
-addpath([fileparts(pwd) '/matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4; % Number of CPU threads
-input_multem.system_conf.gpu_device = 0; % GPU device (i.e. 0, 1, 2, ... )
-
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0;
-input_multem.phi = 0.0;
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-input_multem.spec_lx = 50;
-input_multem.spec_ly = 50;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-input_multem.iw_x = 0.5*input_multem.spec_lx; % x position
-input_multem.iw_y = 0.5*input_multem.spec_ly; % y position
-input_multem.iw_x = 10+[0, 25, 0, 25]; % x position
-input_multem.iw_y = 10+[5, 5, 25, 25]; % y position
-% input_multem.iw_x = 10+[0, 25]; % x position
-% input_multem.iw_y = 10+[5, 25]; % y position
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = -14.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-input_multem.cond_lens_c_10 = ilc_scherzer_defocus(input_multem.E_0, input_multem.cond_lens_c_30);
-
-input_multem.cond_lens_c_10 = input_multem.cond_lens_c_10;
-
-tic;
-output_incident_wave = input_multem.ilc_incident_wave;
-toc;
-
-psi_0 = flipud(output_incident_wave.psi_0);
-figure(1); clf;
-subplot(1, 2, 1);
-imagesc(output_incident_wave.x, output_incident_wave.y, abs(psi_0).^2);
-title('intensity');
-axis image;
-colormap gray;
-
-subplot(1, 2, 2);
-imagesc(output_incident_wave.x, output_incident_wave.y, angle(psi_0));
-title('phase');
-axis image;
-colormap gray;
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_ncores = 1; % Number of Cores CPU (It will be used in the future)
+system_config.cpu_n_thread = 4; % Number of CPU threads
+system_config.gpu_device = 0; % GPU device (i.e. 0, 1, 2, ... )
+
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0;
+input_multem.phi = 0.0;
+
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+
+input_multem.spec_bs_x = 50;
+input_multem.spec_bs_y = 50;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 2; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = -14.0312; % Defocus (Å)
+input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
+input_multem.cond_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+input_multem.cond_lens_c_10 = ilc_scherzer_defocus(input_multem.E_0, input_multem.cond_lens_c_30);
+
+input_multem.cond_lens_c_10 = input_multem.cond_lens_c_10;
+
+tic;
+output_incident_wave = ilc_incident_wave(system_config, input_multem);
+toc;
+
+psi_0 = flipud(output_incident_wave.psi_0);
+figure(1); clf;
+subplot(1, 2, 1);
+imagesc(output_incident_wave.x, output_incident_wave.y, abs(psi_0).^2);
+title('intensity');
+axis image;
+colormap gray;
+
+subplot(1, 2, 2);
+imagesc(output_incident_wave.x, output_incident_wave.y, angle(psi_0));
+title('phase');
+axis image;
+colormap gray;
pause(0.2);
\ No newline at end of file
diff --git a/mex_examples_multem/example_MULTEM_STEM_matrix_detector.m b/mex_examples_multem/example_matrix_detector.m
old mode 100644
new mode 100755
similarity index 62%
rename from mex_examples_multem/example_MULTEM_STEM_matrix_detector.m
rename to mex_examples_multem/example_matrix_detector.m
index b8346378..3bf74188
--- a/mex_examples_multem/example_MULTEM_STEM_matrix_detector.m
+++ b/mex_examples_multem/example_matrix_detector.m
@@ -1,167 +1,162 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% Scanning transmission electron microscopy (STEM) simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-%%%%%%%%%%%%%%%%%% Load multem default parameter %%%%%%%%$$%%%%%%%%%
-input_multem = multem_input.parameters; % Load default values;
-
-%%%%%%%%%%%%%%%%%%%%% Set system configuration %%%%%%%%%%%%%%%%%%%%%
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 6;
-input_multem.system_conf.gpu_device = 0;
-
-%%%%%%%%%%%%%%%%%%%% Set simulation experiment %%%%%%%%%%%%%%%%%%%%%
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 11;
-
-%%%%%%%%%%%%%% Electron-Specimen interaction model %%%%%%%%%%%%%%%%%
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-%%%%%%%%%%%%%%%%%%%%%%% Potential slicing %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-%%%%%%%%%%%%%%% Electron-Phonon interaction model %%%%%%%%%%%%%%%%%%
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_coh_contrib = 0;
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 10; % true: specific phonon configuration, false: number of frozen phonon configurations
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-
-%%%%%%%%%%%%%%%%%%%%%%% Specimen information %%%%%%%%%%%%%%%%%%%%%%%
-na = 8; nb = 8; nc = 5; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-%%%%%%%%%%%%%%%%%%%%%% Specimen thickness %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.thick_type = 2; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = c/2:c:1000; % Array of thickes (�)
-
-%%%%%%%%%%%%%%%%%%%%%% x-y sampling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.nx = 512;
-input_multem.ny = 512;
-input_multem.bwl = 0; % Band-width limit, 1: true, 0:false
-
-%%%%%%%%%%%%%%%%%%%% Microscope parameters %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-%%%%%%%%%%%%%%%%%%%%%% Illumination model %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.illumination_model = 1; % 1: coherente mode, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 14.0312; % Defocus (�)
-input_multem.cond_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 21.0; % Outer aperture (mrad)
-
-%%%%%%%%% defocus spread function %%%%%%%%%%%%
-dsf_sigma = ilc_iehwgd_2_sigma(32); % from defocus spread to standard deviation
-input_multem.cond_lens_ti_sigma = dsf_sigma; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 5; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%%% source spread function %%%%%%%%%%%%
-ssf_sigma = ilc_hwhm_2_sigma(0.45); % half width at half maximum to standard deviation
-input_multem.cond_lens_si_sigma = ssf_sigma; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 4; % # of integration points. It will be only used if illumination_model=4
-
-%%%%%%%%% zero defocus reference %%%%%%%%%%%%
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%STEM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.scanning_type = 2; % eST_Line = 1, eST_Area = 2
-input_multem.scanning_periodic = 1; % 1: true, 0:false (periodic boundary conditions)
-input_multem.scanning_ns = 16;
-input_multem.scanning_x0 = 3*a;
-input_multem.scanning_y0 = 3*b;
-input_multem.scanning_xe = 4*a;
-input_multem.scanning_ye = 4*b;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Circular Detector %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.detector.type = 1; % eDT_Circular = 1, eDT_Radial = 2, eDT_Matrix = 3
-input_multem.detector.cir(1).inner_ang = 40; % Inner angle(mrad)
-input_multem.detector.cir(1).outer_ang = 160; % Outer angle(mrad)
-
-clear ilc_multem;
-tic;
-output_radial_detector = input_multem.ilc_multem;
-toc;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Matrix Detector %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% This yields the same detector as the radial detector above, to check
-% the consistency of the results
-
-nxh = input_multem.nx/2;
-nyh = input_multem.ny/2;
-dgx = 1/input_multem.spec_lx;
-dgy = 1/input_multem.spec_ly;
-
-detector = zeros(input_multem.ny, input_multem.nx);
-[gx, gy] = meshgrid((-nxh:1:(nxh-1))*dgx, (-nyh:1:(nyh-1))*dgy);
-g = sqrt(gx.^2+gy.^2);
-
-g_min = ilm_mrad_2_rAng(input_multem.E_0, input_multem.detector.cir(1).inner_ang);
-g_max = ilm_mrad_2_rAng(input_multem.E_0, input_multem.detector.cir(1).outer_ang);
-detector((g_min<=g)&(g
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 110;
-input_multem.pn_seed = 300183;
-input_multem.pn_single_conf = 0; % 1: true, 0:false
-input_multem.pn_nconf = 5;
-
-input_multem.illumination_model = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-input_multem.bwl = 0;
-
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (�)
-input_multem.phi = 0.0; % Till ilumination (�)
-
-na = 4; nb = 4; nc = 10; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 15.836; % Defocus (�)
-input_multem.obj_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
-input_multem.obj_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 10; % # integration steps for the defocus Spread. It will be only used if illumination_model=4
-input_multem.obj_lens_zero_defocus_type = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 0; % It will be only used if obj_lens_zero_defocus_type = eZDT_User_Define
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
-clear ilc_multem;
-tic;
-output_multislice_0 = input_multem.ilc_multem;
-toc;
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 32;
-clear ilc_multem;
-tic;
-output_multislice_1 = input_multem.ilc_multem;
-toc;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = output_multislice_0.data.psi_coh; % user define incident wave
-clear ilc_multem;
-tic;
-output_multislice_2 = input_multem.ilc_microscope_aberrations;
-toc;
-
-figure(1);
-subplot(1, 3, 1);
-imagesc(abs(output_multislice_0.data.psi_coh).^2);
-title('Total intensity');
-axis image;
-colormap gray;
-
-subplot(1, 3, 2);
-imagesc(abs(output_multislice_1.data.m2psi_tot));
-title('Total intensity');
-axis image;
-colormap gray;
-
-subplot(1, 3, 3);
-imagesc(abs(output_multislice_2.m2psi));
-title('Total intensity');
-axis image;
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 52;
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_dim = [true, true, false];
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false
+input_multem.atomic_vib_nconf = 5;
+
+input_multem.illum_mod = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+input_multem.bwl = 0;
+
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+na = 4;nb = 4;nc = 10;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 15.836; % Defocus (Å)
+input_multem.obj_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
+input_multem.obj_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.obj_lens_tp_inc_npts = 10; % # integration steps for the defocus Spread. It will be only used if illum_mod=4
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0; % It will be only used if obj_lens_zero_def_typ = eZDT_User_Define
+
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 52;
+clear ilc_multem;
+tic;
+output_multem_0 = ilc_multem(system_config, input_multem);
+toc;
+
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 32;
+clear ilc_multem;
+tic;
+output_multem_1 = ilc_multem(system_config, input_multem);
+toc;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = output_multem_0.data.psi_coh; % user define incident wave
+clear ilc_multem;
+tic;
+output_multem_2 = ilc_microscope_aberrations(system_config, input_multem);
+toc;
+
+figure(1);
+subplot(1, 3, 1);
+imagesc(abs(output_multem_0.data.psi_coh).^2);
+title('Total intensity');
+axis image;
+colormap gray;
+
+subplot(1, 3, 2);
+imagesc(output_multem_1.data.m2psi_tot);
+title('Total intensity');
+axis image;
+colormap gray;
+
+subplot(1, 3, 3);
+imagesc(output_multem_2.m2psi);
+title('Total intensity');
+axis image;
colormap gray;
\ No newline at end of file
diff --git a/mex_examples_multem/example_min_max_dist.m b/mex_examples_multem/example_min_max_dist.m
new file mode 100755
index 00000000..2e49dc57
--- /dev/null
+++ b/mex_examples_multem/example_min_max_dist.m
@@ -0,0 +1,24 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+[x, y, z] = meshgrid(0:2:50);
+r_3d = [x(:), y(:), z(:)];
+r_3d = r_3d + 0.1*rand(size(r_3d));
+r_3d = double(r_3d);
+
+tic;
+[r, rdf] = ilc_rdf(r_3d, 5, 400);
+toc;
+
+r_min = ilc_min_dist(r_3d);
+r_max = ilc_max_dist(r_3d);
+
+figure(1); clf;
+plot(r, rdf, '-k');
+hold on;
+plot(r_min, 0.5*max(rdf), 'or')
+hold on;
+plot(r_max, 0.5*max(rdf), 'or')
\ No newline at end of file
diff --git a/mex_examples_multem/example_pr.m b/mex_examples_multem/example_pr.m
old mode 100644
new mode 100755
index f3bc2f78..09f4ce40
--- a/mex_examples_multem/example_pr.m
+++ b/mex_examples_multem/example_pr.m
@@ -1,43 +1,42 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-Z = 79;
-occ = 1;
-region = 0;
-charge = 0;
-
-rmin = 1e-05; rmax = 0.1; nr = 512;
-dlnr = log(rmax/rmin)/(nr-1); r = rmin*exp((0:1:(nr-1))*dlnr);
-
-[f1, df1] = ilc_pr(1, Z, charge, r);
-[f2, df2] = ilc_pr(2, Z, charge, r);
-[f3, df3] = ilc_pr(3, Z, charge, r);
-[f4, df4] = ilc_pr(4, Z, charge, r);
-[f5, df5] = ilc_pr(5, Z, charge, r);
-[f6, df6] = ilc_pr(6, Z, charge, r);
-
-figure(1); clf;
-
-subplot(1, 2, 1);
-plot(r, f1, '-k', r, f2, '-b', r, f3, '-c', r, f4, '-m', r, f5, '-r', r, f6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Electron density');
-ylabel('$\displaystyle \rho(r)$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{r}$','interpreter','latex','FontSize',12);
-xlim([0 rmax]); ylim([0 max(f6)]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-subplot(1, 2, 2);
-plot(r, df1, '-k', r, df2, '-b', r, df3, '-c', r, df4, '-m', r, df5, '-r', r, df6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Derivative of the Electron density');
-ylabel('$\displaystyle \frac{d \rho(r)}{d r}$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{r}$','interpreter','latex','FontSize',12);
-xlim([0 rmax]); ylim([min(df6) max(df6)]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-set(gcf,'units','normalized','outerposition',[0 0 1 1]);
\ No newline at end of file
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath([ fileparts(pwd), filesep, 'mex_bin'])
+
+Z = 79;
+occ = 1;
+tag = 0;
+charge = 0;
+
+rmin = 1e-05;rmax = 0.1;nr = 512;
+dlnr = log(rmax/rmin)/(nr-1);r = rmin*exp((0:1:(nr-1))*dlnr);
+
+tic;
+[f1, df1] = ilc_pr(1, Z, charge, r);
+[f2, df2] = ilc_pr(2, Z, charge, r);
+[f3, df3] = ilc_pr(3, Z, charge, r);
+[f4, df4] = ilc_pr(4, Z, charge, r);
+[f5, df5] = ilc_pr(5, Z, charge, r);
+[f6, df6] = ilc_pr(6, Z, charge, r);
+toc;
+
+figure(1); clf;
+
+subplot(1, 2, 1);
+plot(r, f1, '-k', r, f2, '-b', r, f3, '-c', r, f4, '-m', r, f5, '-r', r, f6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Electron density');
+ylabel('$\displaystyle \rho(r)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 rmax]);ylim([0 max(f6)]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+subplot(1, 2, 2);
+plot(r, df1, '-k', r, df2, '-b', r, df3, '-c', r, df4, '-m', r, df5, '-r', r, df6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Derivative of the Electron density');
+ylabel('$\displaystyle \frac{d \rho(r)}{d r}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 rmax]);ylim([min(df6) max(df6)]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_projected_potential.m b/mex_examples_multem/example_projected_potential.m
old mode 100644
new mode 100755
index f2ec68a2..ae7559ef
--- a/mex_examples_multem/example_projected_potential.m
+++ b/mex_examples_multem/example_projected_potential.m
@@ -1,69 +1,64 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 2; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 111; % phonon dimensions
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-input_multem.pn_single_conf = 1; % 1: true, 0:false
-input_multem.pn_nconf = 1; % true: phonon configuration, false: number of frozen phonon configurations
-
-na = 4; nb = 4; nc = 4; ncu = 2; rmsd_3d = 0.25;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.nx = 2048;
-input_multem.ny = 2048;
-
-clear ilc_spec_slicing;
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-
-[natoms,~] = size(atoms); [nslice, ~] = size(Slice);
-for islice = 1:nslice
- input_multem.islice = islice;
-
- input_multem.system_conf.device = 1; % eD_CPU = 1, eD_GPU = 2
- input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
- tic;
- clear ilc_projected_potential;
- ouput_multislice_1 = input_multem.ilc_projected_potential;
- toc;
-
- input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
- input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
- tic;
- clear ilc_projected_potential;
- ouput_multislice_2 = input_multem.ilc_projected_potential;
- toc;
- mean(abs(ouput_multislice_1.V(:)-ouput_multislice_2.V(:)))
-
- figure(1);
- subplot(1, 2, 1);
- imagesc(ouput_multislice_1.V);
- colormap gray;
- axis image;
- subplot(1, 2, 2);
- imagesc(ouput_multislice_2.V);
- colormap gray;
- axis image;
- disp([min(ouput_multislice_1.V(:)), min(ouput_multislice_2.V(:))])
- disp([max(ouput_multislice_1.V(:)), max(ouput_multislice_2.V(:))])
- pause(0.10);
-
-end
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 2; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_dim = 111; % phonon dimensions
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+input_multem.atomic_vib_sgl_conf = 1; % 1: true, 0:false
+input_multem.atomic_vib_nconf = 1; % true: phonon configuration, false: number of frozen phonon configurations
+
+na = 4;nb = 4;nc = 4;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.nx = 2048;
+input_multem.ny = 2048;
+
+clear ilc_spec_slicing;
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+
+[natoms, ~] = size(atoms);[nslice, ~] = size(Slice);
+for islice = 1:nslice
+ input_multem.islice = islice;
+
+ system_config.device = 1; % eD_CPU = 1, eD_GPU = 2
+ system_config.precision = 1; % eP_Float = 1, eP_double = 2
+ tic;
+ clear ilc_projected_potential;
+ output_multislice_1 = ilc_projected_potential(system_config, input_multem);
+ toc;
+
+ system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+ system_config.precision = 1; % eP_Float = 1, eP_double = 2
+ tic;
+ clear ilc_projected_potential;
+ output_multislice_2 = ilc_projected_potential(system_config, input_multem);
+ toc;
+ mean(abs(output_multislice_1.V(:)-output_multislice_2.V(:)))
+
+ figure(1);
+ subplot(1, 2, 1);
+ imagesc(output_multislice_1.V);
+ colormap gray;
+ axis image;
+ subplot(1, 2, 2);
+ imagesc(output_multislice_2.V);
+ colormap gray;
+ axis image;
+ disp([min(output_multislice_1.V(:)), min(output_multislice_2.V(:))])
+ disp([max(output_multislice_1.V(:)), max(output_multislice_2.V(:))])
+ pause(0.10);
+
+end
diff --git a/mex_examples_multem/example_propagate.m b/mex_examples_multem/example_propagate.m
old mode 100644
new mode 100755
index 09ec82ab..260eb2ba
--- a/mex_examples_multem/example_propagate.m
+++ b/mex_examples_multem/example_propagate.m
@@ -1,95 +1,89 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 110;
-input_multem.pn_seed = 300183;
-input_multem.pn_single_conf = 0; % 1: true, 0:false
-input_multem.pn_nconf = 5;
-
-input_multem.illumination_model = 1; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
-input_multem.temporal_spatial_incoh = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
-
-input_multem.bwl = 0;
-
-input_multem.E_0 = 300; % Acceleration Voltage (keV)
-input_multem.theta = 0.0; % Till ilumination (º)
-input_multem.phi = 0.0; % Till ilumination (º)
-
-na = 4; nb = 4; nc = 10; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.nx = 1024;
-input_multem.ny = 1024;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = 0; % user define incident wave
-input_multem.iw_x = input_multem.spec_lx/2; % x position
-input_multem.iw_y = input_multem.spec_ly/2; % y position
-
-input_multem.simulation_type = 52; % eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52, eTEMST_EELS=61, eTEMST_EFTEM=62
-clear ilc_multem;
-tic;
-output_multislice = input_multem.ilc_multem;
-toc;
-
-input_multem.obj_lens_c_10 = 10; %Angs
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = output_multislice.data.psi_coh; % user define incident wave
-
-input_multem.system_conf.precision = 2; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 1; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 2;
-input_multem.system_conf.gpu_device = 0;
-tic;
-output_propagate = input_multem.ilc_propagate;
-toc;
-
-figure(1);
-subplot(2, 2, 1);
-imagesc(abs(output_multislice.data.psi_coh).^2);
-title('wave intensity');
-axis image;
-colormap gray;
-
-subplot(2, 2, 2);
-imagesc(angle(output_multislice.data.psi_coh));
-title('phase');
-axis image;
-colormap gray;
-
-subplot(2, 2, 3);
-imagesc(abs(output_propagate.psi).^2);
-title('wave intensity');
-axis image;
-colormap gray;
-
-subplot(2, 2, 4);
-imagesc(angle(output_propagate.psi));
-title('angle');
-axis image;
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 52;
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_dim = [true, true, false];
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false
+input_multem.atomic_vib_nconf = 5;
+
+input_multem.illum_mod = 2; % 1: coherente mode, 2: Partial coherente mode, 3: transmission cross coefficient, 4: Numerical integration
+input_multem.illum_inc = 1; % 1: Temporal and Spatial, 2: Temporal, 3: Spatial
+
+input_multem.bwl = 0;
+
+input_multem.E_0 = 300; % Acceleration Voltage (keV)
+input_multem.theta = 0.0; % Till ilumination (º)
+input_multem.phi = 0.0; % Till ilumination (º)
+
+na = 4;nb = 4;nc = 10;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Cu001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.nx = 1024;
+input_multem.ny = 1024;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 4; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = 0; % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+input_multem.em_sim_typ = 52; % eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52, eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72
+clear ilc_multem;
+tic;
+output_multem = ilc_multem(system_config, input_multem);
+toc;
+
+input_multem.obj_lens_c_10 = 10; %Angs
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 3; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = output_multem.data.psi_coh; % user define incident wave
+
+tic;
+output_propagate = ilc_propagate(system_config, input_multem);
+toc;
+
+figure(1);
+subplot(2, 2, 1);
+imagesc(abs(output_multem.data.psi_coh).^2);
+title('wave intensity');
+axis image;
+colormap gray;
+
+subplot(2, 2, 2);
+imagesc(angle(output_multem.data.psi_coh));
+title('Total intensity');
+axis image;
+colormap gray;
+
+subplot(2, 2, 3);
+imagesc(abs(output_propagate.psi).^2);
+title('wave intensity');
+axis image;
+colormap gray;
+
+subplot(2, 2, 4);
+imagesc(angle(output_propagate.psi));
+title('Total intensity');
+axis image;
colormap gray;
\ No newline at end of file
diff --git a/mex_examples_multem/example_rdf_2d.m b/mex_examples_multem/example_rdf_2d.m
new file mode 100755
index 00000000..9881d075
--- /dev/null
+++ b/mex_examples_multem/example_rdf_2d.m
@@ -0,0 +1,15 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'mex_bin'])
+
+[x, y] = meshgrid(0:2:50);
+r_2d = [x(:), y(:)];
+r_2d = r_2d + 0.1*rand(size(r_2d));
+r_2d = double(r_2d);
+
+tic;
+[r, rdf] = ilc_rdf(r_2d, 8, 200);
+toc;
+
+figure(1); clf;
+plot(r, rdf, '-+r');
\ No newline at end of file
diff --git a/mex_examples_multem/example_rdf_3d.m b/mex_examples_multem/example_rdf_3d.m
new file mode 100755
index 00000000..cbc5fc83
--- /dev/null
+++ b/mex_examples_multem/example_rdf_3d.m
@@ -0,0 +1,15 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'mex_bin'])
+
+[x, y, z] = meshgrid(0:2:50);
+r_3d = [x(:), y(:), z(:)];
+r_3d = r_3d + 0.1*rand(size(r_3d));
+r_3d = double(r_3d);
+
+tic;
+[r, rdf] = ilc_rdf(r_3d, 8, 200);
+toc;
+
+figure(1); clf;
+plot(r, rdf, '-+r');
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_creation_from_cif_file.m b/mex_examples_multem/example_specimen_creation_from_cif_file.m
old mode 100644
new mode 100755
index 94712be3..ed9664bb
--- a/mex_examples_multem/example_specimen_creation_from_cif_file.m
+++ b/mex_examples_multem/example_specimen_creation_from_cif_file.m
@@ -1,30 +1,30 @@
-% Specimen creation
-% Copyright 2023 Ivan Lobato
-
-clear all;clc;
-
-ncu = 2;
-rmsd_3d = 0.085;
-fn = 'SrTiO3_mp-4651_conventional_standard.cif';
-
-[a, b, c] = ilm_read_lat_parm_cif(fn);
-na = 2;
-nb = 2;
-nc = 2;
-rmsd_3d_0 = 0.085;
-pbc = false;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-[atoms_0, lx, ly, lz] = ilm_read_ap_cif(fn, rmsd_3d_0, pbc, na, nb, nc);
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-pbc = true;
-[atoms_1, lx, ly, lz] = ilm_read_ap_cif(fn, rmsd_3d_0, pbc, na, nb, nc);
-
-figure(1); clf;
-subplot(1, 2, 1);
-ilm_show_crystal(0, atoms_0, false);
-title('pbc=false');
-subplot(1, 2, 2);
-ilm_show_crystal(0, atoms_1, false);
-title('pbc=true');
+% specimen creation
+% Copyright 2020 Ivan Lobato
+
+clear;clc;
+
+ncu = 2;
+rmsd_3d = 0.085;
+fn = 'SrTiO3_mp-4651_conventional_standard.cif';
+
+[a, b, c] = ilm_read_lat_parm_cif(fn);
+na = 2;
+nb = 2;
+nc = 2;
+rmsd_3d_0 = 0.085;
+pbc = false;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+[atoms_0, lx, ly, lz] = ilm_read_ap_cif(fn, rmsd_3d_0, pbc, na, nb, nc);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+pbc = true;
+[atoms_1, lx, ly, lz] = ilm_read_ap_cif(fn, rmsd_3d_0, pbc, na, nb, nc);
+
+figure(1); clf;
+subplot(1, 2, 1);
+ilm_show_xtl(0, atoms_0, false);
+title('pbc=false');
+subplot(1, 2, 2);
+ilm_show_xtl(0, atoms_1, false);
+title('pbc=true');
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_planes.m b/mex_examples_multem/example_specimen_planes.m
old mode 100644
new mode 100755
index 214ecbe4..2511f6c8
--- a/mex_examples_multem/example_specimen_planes.m
+++ b/mex_examples_multem/example_specimen_planes.m
@@ -1,127 +1,124 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.pn_dim = 110;
-input_multem.pn_seed = 300183;
-input_multem.pn_nconf = 1;
-
-input_multem.spec_rot_theta = 0; % final angle
-input_multem.spec_rot_u0 = [1 0 0]; % unitary vector
-input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
-input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
-na = 6; nb = 6; nc = 10; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au110_xtl(na, nb, nc, ncu, rmsd_3d);
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz] = graphene(10, 2.46, 0.085);
-
-ilm_write_ap_pdb('graphene.pdb', input_multem.spec_atoms);
-
-% occ = 1;
-% region = 0;
-% charge = 0;
-% [input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, lz] = graphene(1, 1.42, sqrt(0.5/(8*pi^2)));
-% input_multem.spec_dz = 0.5;
-
-input_multem.spec_dz = 2;
-
-disp([min(input_multem.spec_atoms(:, 4)), max(input_multem.spec_atoms(:,4))])
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-lz = 20;
-Z = 6;
-rms_3d = 0.09;
-d_min = 1.4;
-seed = 1983;
-rho = 2.2;
-lay_pos = 2; %1: top, 2: bottom
-
-z_min = min(input_multem.spec_atoms(:, 4));
-z_max = max(input_multem.spec_atoms(:, 4));
-tic;
-input_multem.spec_atoms = ilc_add_amorp_lay(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
-toc;
-
-if(lay_pos==1)
- input_multem.spec_amorp(1).z_0 = z_min-lz; % Starting z position of the amorphous layer (�)
- input_multem.spec_amorp(1).z_e = z_min; % Ending z position of the amorphous layer (�)
-else
- input_multem.spec_amorp(1).z_0 = z_max; % Starting z position of the amorphous layer (�)
- input_multem.spec_amorp(1).z_e = z_max+lz; % Ending z position of the amorphous layer (�)
-end
-input_multem.spec_amorp(1).dz = 2.0; % slice thick of the amorphous layer (�)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-lz = 10;
-Z = 6;
-rms_3d = 0.09;
-d_min = 1.4;
-seed = 1983;
-rho = 2.2;
-lay_pos = 1; %1: top, 2: bottom
-
-z_min = min(input_multem.spec_atoms(:, 4));
-z_max = max(input_multem.spec_atoms(:, 4));
-
-tic;
-input_multem.spec_atoms = ilc_add_amorp_lay(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
-toc;
-
-if(lay_pos==1)
-
- input_multem.spec_amorp(2).z_0 = z_min-lz; % Starting z position of the amorphous layer (�)
- input_multem.spec_amorp(2).z_e = z_min; % Ending z position of the amorphous layer (�)
-else
- input_multem.spec_amorp(2).z_0 = z_max; % Starting z position of the amorphous layer (�)
- input_multem.spec_amorp(2).z_e = z_max+lz; % Ending z position of the amorphous layer (�)
-end
-input_multem.spec_amorp(2).dz = 2.0; % slice thick of the amorphous layer (�)
-
-ilm_show_crystal(1, input_multem.spec_atoms)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-clc;
-tic;
-[z_planes] = ilc_spec_planes(input_multem.toStruct);
-toc;
-diff(z_planes)
-[nplanes, ~] = size(z_planes);
-disp(['Number of slices = ', num2str(nplanes)])
-
-figure(1); clf;
-plot(input_multem.spec_atoms(:, 3), input_multem.spec_atoms(:, 4), 'ok');
-set(gca,'ydir','reverse');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Atomic positions');
-ylabel('y','FontSize',14);
-xlabel('x','FontSize',12);
-axis equal;
-
-for i = 1:nplanes
- hold on;
- plot([-2 input_multem.spec_lx], [z_planes(i) z_planes(i)], '-r');
- axis equal;
-end
-axis([-2, 18, min(input_multem.spec_atoms(:, 4))-5, max(input_multem.spec_atoms(:, 4))+5]);
-
-% nbins = floor((max(input_multem.spec_atoms(:, 4))-min(input_multem.spec_atoms(:, 4)))/0.10001);
-% tic;
-% [x, y] = ilc_hist(input_multem.spec_atoms(:, 4), nbins-1);
-% toc;
-%
-% figure(2); clf;
-% plot(x, y, '-+r');
-% hold on;
-% ii = find(y<0.5);
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_vib_dim = [true, true, false];
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_nconf = 1;
+
+input_multem.spec_rot_theta = 0; % final angle
+input_multem.spec_rot_u_0 = [1 0 0]; % unitary vector
+input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+na = 6; nb = 6;nc = 10; ncu = 2; rmsd_3d = 0.15;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.spec_slic(1).sli_thick = 2;
+
+disp([min(input_multem.spec_atoms(:, 4)), max(input_multem.spec_atoms(:, 4))])
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+lz = 20;
+Z = 6;
+rms_3d = 0.09;
+occ = 1;
+tag = 1;
+bs = [input_multem.spec_bs_x, input_multem.spec_bs_y, lz];
+d_min = 1.4;
+rho = 2.2;
+lay_pos = 2; %1: top, 2: bottom
+seed = 1983;
+
+z_min = min(input_multem.spec_atoms(:, 4));
+z_max = max(input_multem.spec_atoms(:, 4));
+tic;
+
+input_multem.spec_atoms = ilc_amorp_lay_add(input_multem.spec_atoms, Z, rms_3d, occ, tag, bs, d_min, rho, lay_pos, seed);
+toc;
+
+if(lay_pos==1)
+ input_multem.spec_slic(1).z_0 = z_min-lz; % Starting z position of the amorphous layer (Å)
+ input_multem.spec_slic(1).z_e = z_min; % Ending z position of the amorphous layer (Å)
+else
+ input_multem.spec_slic(1).z_0 = z_max; % Starting z position of the amorphous layer (Å)
+ input_multem.spec_slic(1).z_e = z_max+lz; % Ending z position of the amorphous layer (Å)
+end
+input_multem.spec_slic(1).sli_thick = 2.0; % slice thick of the amorphous layer (Å)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+lz = 10;
+Z = 6;
+rms_3d = 0.09;
+occ = 1;
+tag = 1;
+bs = [input_multem.spec_bs_x, input_multem.spec_bs_y, lz];
+d_min = 1.4;
+rho = 2.2;
+lay_pos = 1; %1: top, 2: bottom
+seed = 1983;
+
+z_min = min(input_multem.spec_atoms(:, 4));
+z_max = max(input_multem.spec_atoms(:, 4));
+
+tic;
+input_multem.spec_atoms = ilc_amorp_lay_add(input_multem.spec_atoms, Z, rms_3d, occ, tag, bs, d_min, rho, lay_pos, seed);
+toc;
+
+if(lay_pos==1)
+ input_multem.spec_slic(2).z_0 = z_min-lz; % Starting z position of the amorphous layer (Å)
+ input_multem.spec_slic(2).z_e = z_min; % Ending z position of the amorphous layer (Å)
+else
+ input_multem.spec_slic(2).z_0 = z_max; % Starting z position of the amorphous layer (Å)
+ input_multem.spec_slic(2).z_e = z_max+lz; % Ending z position of the amorphous layer (Å)
+end
+input_multem.spec_slic(2).dz = 2.0; % slice thick of the amorphous layer (Å)
+
+ilm_show_xtl(1, input_multem.spec_atoms)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clc;
+tic;
+[z_planes] = ilc_spec_planes(input_multem);
+toc;
+diff(z_planes)
+[nplanes, ~] = size(z_planes);
+disp(['Number of slices = ', num2str(nplanes)])
+
+figure(1); clf;
+plot(input_multem.spec_atoms(:, 3), input_multem.spec_atoms(:, 4), 'ok');
+set(gca, 'ydir', 'reverse');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic positions');
+ylabel('y', 'FontSize', 14);
+xlabel('x', 'FontSize', 12);
+axis equal;
+
+for i = 1:nplanes
+ hold on;
+ plot([-2 input_multem.spec_bs_x], [z_planes(i) z_planes(i)], '-r');
+ axis equal;
+end
+axis([-2, 18, min(input_multem.spec_atoms(:, 4))-5, max(input_multem.spec_atoms(:, 4))+5]);
+
+% nbins = floor((max(input_multem.spec_atoms(:, 4))-min(input_multem.spec_atoms(:, 4)))/0.10001);
+% tic;
+% [x, y] = ilc_hist(input_multem.spec_atoms(:, 4), nbins-1);
+% toc;
+%
+% figure(2);clf;
+% plot(x, y, '-+r');
+% hold on;
+% ii = find(y<0.5);
% plot(x(ii), y(ii), '.b');
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_rotation.m b/mex_examples_multem/example_specimen_rotation.m
old mode 100644
new mode 100755
index 637f5179..401df935
--- a/mex_examples_multem/example_specimen_rotation.m
+++ b/mex_examples_multem/example_specimen_rotation.m
@@ -1,43 +1,38 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-%
-% Exit wave real space (EWRS) simulation
-%
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-%
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-% create specimen
-lx = 100;
-ly = 100;
-lz = 100;
-
-na = 8; nb = 8; nc = 8; ncu = 2; rmsd_3d = 0.085;
-
-[atoms, ~] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-atoms = ilm_center_spec(atoms, lx, ly, lz);
-
-theta = 45; % angle (�)
-u0 = [1 1 0]; % unitary vector
-rot_point_type = 1; % 1: geometric center, 2: User define
-p0 = [0 0 0]; % rotation point
-
-% rotate specimen
-atoms_r = ilc_spec_rot(atoms, theta, u0, rot_point_type, p0);
-figure(1); clf;
-
-subplot(1, 2, 1);
-plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4), 'o', 'MarkerSize', 2, 'MarkerFaceColor', 'auto');
-axis equal;
-axis([0 lx 0 ly 0 lz]);
-view([1 0 1]);
-
-subplot(1, 2, 2);
-plot3(atoms_r(:, 2), atoms_r(:, 3), atoms_r(:, 4), 'o', 'MarkerSize', 2, 'MarkerFaceColor', 'auto');
-axis equal;
-axis([0 lx 0 ly 0 lz]);
-view([0 0 1]);
\ No newline at end of file
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+% create specimen
+lx = 100;
+ly = 100;
+lz = 100;
+
+na = 8; nb = 8; nc = 8; ncu = 2; rmsd_3d = 0.085;
+[atoms, ~] = SrTiO3001_xtl(na, nb, nc, ncu, rmsd_3d);
+atoms = ilm_spec_recenter(atoms, lx, ly, lz);
+atoms = atoms(:, 1:5);
+
+ilm_show_xtl(1, atoms);
+
+theta = 45; % angle (º)
+u_0 = [1 0 0]; % unitary vector
+rot_point_type = 1; % 1: geometric center, 2: User define
+p_0 = [0 0 0]; % rotation point
+
+% rotate specimen
+tic;
+atoms_r = ilc_spec_rot(atoms, theta, u_0, rot_point_type, p_0);
+toc;
+
+figure(1); clf;
+subplot(1, 2, 1);
+ilm_show_xtl(1, atoms, false);
+view([1 0 1]);
+title('Raw')
+
+subplot(1, 2, 2);
+ilm_show_xtl(1, atoms_r, false);
+view([0 0 1]);
+title('Rotated')
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_slicing_rotation.m b/mex_examples_multem/example_specimen_slicing_rotation.m
old mode 100644
new mode 100755
index 7af1e87d..4990abc7
--- a/mex_examples_multem/example_specimen_slicing_rotation.m
+++ b/mex_examples_multem/example_specimen_slicing_rotation.m
@@ -1,86 +1,89 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
-% eTEMST_EELS=61, eTEMST_EFTEM=62, eTEMST_ProbeFS=71, eTEMST_ProbeRS=72, eTEMST_PPFS=81, eTEMST_PPRS=82,eTEMST_TFFS=91, eTEMST_TFRS=92
-input_multem.simulation_type = 52;
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 110; % phonon dimensions (xyz)
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-input_multem.pn_single_conf = 0; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 100; % true: phonon configuration, false: number of frozen phonon configurations
-
-input_multem.spec_rot_theta = 45; % angle (�)
-input_multem.spec_rot_u0 = [1 0 0]; % unitary vector
-input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
-input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
-na = 8; nb = 8; nc = 8; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.spec_lx = 100;
-input_multem.spec_ly = 100;
-input_multem.spec_lz = 100;
-
-[input_multem.spec_atoms] = ilm_center_spec(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, input_multem.spec_lz);
-
-% get spec slicing
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-
-ilm_show_crystal(1, atoms);
-
-[natoms,~] = size(atoms);
-[nslice, ~] = size(Slice);
-
-for i = 1:nslice
- figure(1); clf;
- i1 = Slice(i, 5); i2 = Slice(i, 6); ii = i1:1:i2;
- plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4), '.k', atoms(ii, 2), atoms(ii, 3), atoms(ii, 4), 'or');
- set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
- title('Atomic positions');
- ylabel('y','FontSize',14);
- xlabel('x','FontSize',12);
- axis equal;
- i2-i1+1
- view([1 0 0]);
- pause(0.1);
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-natoms = size(atoms, 1);
-bb = zeros(natoms, 1);
-d = 0.1;
-ic = 0;
-xy = [];
-for ia=1:natoms
- if(bb(ia)<0.1)
- x = atoms(ia, 2);
- y = atoms(ia, 3);
- ii = find(sqrt((atoms(:, 2)-x).^2+(atoms(:, 3)-y).^2)
+
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+% eTEMST_STEM=11, eTEMST_ISTEM=12, eTEMST_CBED=21, eTEMST_CBEI=22, eTEMST_ED=31, eTEMST_HRTEM=32, eTEMST_PED=41, eTEMST_HCTEM=42, eTEMST_EWFS=51, eTEMST_EWRS=52,
+% eTEMST_STEM_EELS=61, eTEMST_ISTEM_EELS=62, eTEMST_EFTEMFS=71, eTEMST_EFTEMRS=72, eTEMST_ProbeFS=81, eTEMST_ProbeRS=82, eTEMST_PPFS=91, eTEMST_PPRS=92, eTEMST_TFFS=101, eTEMST_TFRS=102
+input_multem.em_sim_typ = 52;
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions (xyz)
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 100; % true: phonon configuration, false: number of frozen phonon configurations
+
+input_multem.spec_rot_theta = 45; % angle (º)
+input_multem.spec_rot_u_0 = [1 0 0]; % unitary vector
+input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+na = 8;nb = 8;nc = 8;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.spec_bs_x = 100;
+input_multem.spec_bs_y = 100;
+input_multem.spec_bs_z = 100;
+
+[input_multem.spec_atoms] = ilm_spec_recenter(input_multem.spec_atoms, input_multem.spec_bs_x, input_multem.spec_bs_y, input_multem.spec_bs_z);
+
+% get spec slicing
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+
+ilm_show_xtl(1, atoms);
+
+[natoms, ~] = size(atoms);
+[nslice, ~] = size(Slice);
+
+for i = 1:nslice
+ figure(1); clf;
+ i1 = Slice(i, 5);i2 = Slice(i, 6);ii = i1:1:i2;
+ plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4), '.k', atoms(ii, 2), atoms(ii, 3), atoms(ii, 4), 'or');
+ set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+ title('Atomic positions');
+ ylabel('y', 'FontSize', 14);
+ xlabel('x', 'FontSize', 12);
+ axis equal;
+ i2-i1+1
+ view([1 0 0]);
+ pause(0.1);
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+natoms = size(atoms, 1);
+bb = zeros(natoms, 1);
+d = 0.1;
+ic = 0;
+xy = [];
+for ia=1:natoms
+ if(bb(ia)<0.1)
+ x = atoms(ia, 2);
+ y = atoms(ia, 3);
+ ii = find(sqrt((atoms(:, 2)-x).^2+(atoms(:, 3)-y).^2)
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.pn_dim = 111;
-input_multem.pn_seed = 300183;
-input_multem.pn_nconf = 1;
-
-input_multem.spec_rot_theta = 0; % final angle
-input_multem.spec_rot_u0 = [1 0 0]; % unitary vector
-input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
-input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
-na = 4; nb = 4; nc = 10; ncu = 4; rmsd_3d = 0.08;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = GaAs001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.spec_dz = 5;
-% get spec slicing
-tic;
-input_multem.pn_model = 1;
-[atoms0, Slice0] = ilc_spec_slicing(input_multem.toStruct);
-toc;
-
-[nslice0, ~] = size(Slice0);
-
-tic;
-input_multem.pn_model = 3;
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-toc;
-
-[nslice, ~] = size(Slice);
-
-figure(1); clf;
-plot(atoms(:, 3), atoms(:, 4), 'ok');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Atomic positions');
-ylabel('y','FontSize',14);
-xlabel('x','FontSize',12);
-axis equal;
-axis([-2 18 -5 input_multem.spec_lz + 5]);
-
-for i = 1:nslice
- hold on;
- plot([-2 18], [Slice(i, 1) Slice(i, 1)], '-b', [-2 18], [Slice(i, 2) Slice(i, 2)], '-b');
- axis equal;
- axis([-2 18 -5 input_multem.spec_lz + 5]);
-end
-
-for i = 1:nslice0
- hold on;
- plot([-2 18], [Slice0(i, 1) Slice0(i, 1)], '-r', [-2 18], [Slice0(i, 2) Slice0(i, 2)], '-r');
- axis equal;
- axis([-2 18 -5 input_multem.spec_lz + 5]);
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_vib_dim = 111;
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_nconf = 1;
+
+input_multem.spec_rot_theta = 0; % final angle
+input_multem.spec_rot_u_0 = [1 0 0]; % unitary vector
+input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+na = 4;nb = 4;nc = 10;ncu = 4;rmsd_3d = 0.08;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = GaAs001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.spec_slic(1).sli_thick = 5;
+% get spec slicing
+tic;
+input_multem.atomic_vib_mod = 1;
+[atoms0, Slice0] = ilc_spec_slicing(input_multem);
+toc;
+
+[nslice0, ~] = size(Slice0);
+
+tic;
+input_multem.atomic_vib_mod = 3;
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+toc;
+
+[nslice, ~] = size(Slice);
+x_min = min(atoms(:, 2))-2;
+x_max = max(atoms(:, 2))+2;
+z_min = min(atoms(:, 4))-5;
+z_max = max(atoms(:, 4))+5;
+
+figure(1); clf;
+plot(atoms(:, 3), atoms(:, 4), 'ok');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic positions');
+ylabel('y', 'FontSize', 14);
+xlabel('x', 'FontSize', 12);
+axis equal;
+axis([x_min x_max z_min z_max]);
+
+for i = 1:nslice
+ hold on;
+ plot([x_min x_max], [Slice(i, 1) Slice(i, 1)], '-b', [x_min x_max], [Slice(i, 2) Slice(i, 2)], '-b');
+ axis equal;
+ axis([x_min x_max z_min z_max]);
+end
+
+for i = 1:nslice0
+ hold on;
+ plot([x_min x_max], [Slice0(i, 1) Slice0(i, 1)], '-r', [x_min x_max], [Slice0(i, 2) Slice0(i, 2)], '-r');
+ axis equal;
+ axis([x_min x_max z_min z_max]);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_slicing_with_amorphous_layer.m b/mex_examples_multem/example_specimen_slicing_with_amorphous_layer.m
old mode 100644
new mode 100755
index d693ee24..9fed6e73
--- a/mex_examples_multem/example_specimen_slicing_with_amorphous_layer.m
+++ b/mex_examples_multem/example_specimen_slicing_with_amorphous_layer.m
@@ -1,122 +1,123 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.pn_dim = 110;
-input_multem.pn_seed = 300183;
-input_multem.pn_nconf = 1;
-
-input_multem.spec_rot_theta = 0; % final angle
-input_multem.spec_rot_u0 = [1 0 0]; % unitary vector
-input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
-input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
-na = 6; nb = 6; nc = 10; ncu = 4; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.spec_dz=a/2;
-
-disp([min(input_multem.spec_atoms(:, 4)), max(input_multem.spec_atoms(:,4))])
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-lz = 20;
-Z = 6;
-rms_3d = 0.09;
-d_min = 1.4;
-seed = 1983;
-rho = 2.2;
-lay_pos = 2; %1: top, 2: bottom
-
-z_min = min(input_multem.spec_atoms(:, 4));
-z_max = max(input_multem.spec_atoms(:, 4));
-tic;
-input_multem.spec_atoms = ilc_add_amorp_lay(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
-toc;
-
-if(lay_pos==1)
- input_multem.spec_amorp(1).z_0 = z_min-lz; % Starting z position of the amorphous layer (�)
- input_multem.spec_amorp(1).z_e = z_min; % Ending z position of the amorphous layer (�)
-else
- input_multem.spec_amorp(1).z_0 = z_max; % Starting z position of the amorphous layer (�)
- input_multem.spec_amorp(1).z_e = z_max+lz; % Ending z position of the amorphous layer (�)
-end
-<<<<<<< HEAD
-input_multem.spec_amorp(1).dz = 4.0; % slice thick of the amorphous layer (Å)
-
-=======
-input_multem.spec_amorp(1).dz = 2.0; % slice thick of the amorphous layer (�)
->>>>>>> 94cc921ae7d3a0df6312674918b3608ae0ceb3a6
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% lz = 10;
-% Z = 6;
-% rms_3d = 0.09;
-% d_min = 1.4;
-% seed = 1983;
-% rho = 2.2;
-% lay_pos = 1; %1: top, 2: bottom
-%
-% z_min = min(input_multem.spec_atoms(:, 4));
-% z_max = max(input_multem.spec_atoms(:, 4));
-%
-% tic;
-% input_multem.spec_atoms = ilc_add_amorp_lay(input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
-% toc;
-%
-% if(lay_pos==1)
-% input_multem.spec_amorp(2).z_0 = z_min-lz; % Starting z position of the amorphous layer (�)
-% input_multem.spec_amorp(2).z_e = z_min; % Ending z position of the amorphous layer (�)
-% else
-% input_multem.spec_amorp(2).z_0 = z_max; % Starting z position of the amorphous layer (�)
-% input_multem.spec_amorp(2).z_e = z_max+lz; % Ending z position of the amorphous layer (�)
-% end
-% input_multem.spec_amorp(2).dz = 2.0; % slice thick of the amorphous layer (�)
-
-% ilm_show_crystal(1, input_multem.spec_atoms)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-clc;
-tic;
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-toc;
-disp([min(atoms(:, 4)), max(atoms(:,4))])
-
-[nslice, ~] = size(Slice);
-disp(['Number of slices = ', num2str(nslice)])
-
-figure(1); clf;
-plot(atoms(:, 3), atoms(:, 4), 'ok');
-set(gca,'ydir','reverse');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Atomic positions');
-ylabel('y','FontSize',14);
-xlabel('x','FontSize',12);
-axis equal;
-
-for i = 1:nslice
- hold on;
- plot([-2 input_multem.spec_lx], [Slice(i, 1) Slice(i, 1)], '-r', [-2 input_multem.spec_lx], [Slice(i, 2) Slice(i, 2)], '-r');
- axis equal;
-
-end
-axis([-2, 18, min(input_multem.spec_atoms(:, 4))-5, max(input_multem.spec_atoms(:, 4))+5]);
-
-tic;
-[z_planes] = ilc_spec_planes(input_multem.toStruct);
-toc;
-nplanes = length(z_planes);
-for i = 1:nplanes
- hold on;
- plot([-2 input_multem.spec_lx], [z_planes(i) z_planes(i)], '-b');
- axis equal;
-end
-diff(z_planes)
\ No newline at end of file
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_vib_dim = [true, true, false];
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_nconf = 1;
+
+input_multem.spec_rot_theta = 0; % final angle
+input_multem.spec_rot_u_0 = [1 0 0]; % unitary vector
+input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+na = 6;nb = 6;nc = 10;ncu = 4;rmsd_3d = 0.15;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.spec_slic(1).sli_thick=a/2;
+
+disp([min(input_multem.spec_atoms(:, 4)), max(input_multem.spec_atoms(:, 4))])
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+lz = 20;
+Z = 6;
+rms_3d = 0.09;
+d_min = 1.4;
+seed = 1983;
+rho = 2.2;
+lay_pos = 2; %1: top, 2: bottom
+
+z_min = min(input_multem.spec_atoms(:, 4));
+z_max = max(input_multem.spec_atoms(:, 4));
+tic;
+input_multem.spec_atoms = ilc_amorp_lay_add(input_multem.spec_atoms, input_multem.spec_bs_x, input_multem.spec_bs_y, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
+toc;
+
+if(lay_pos==1)
+ input_multem.spec_slic(1).z_0 = z_min-lz; % Starting z position of the amorphous layer (Å)
+ input_multem.spec_slic(1).z_e = z_min; % Ending z position of the amorphous layer (Å)
+else
+ input_multem.spec_slic(1).z_0 = z_max; % Starting z position of the amorphous layer (Å)
+ input_multem.spec_slic(1).z_e = z_max+lz; % Ending z position of the amorphous layer (Å)
+end
+input_multem.spec_slic(1).sli_thick = 2.0; % slice thick of the amorphous layer (Å)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% lz = 10;
+% Z = 6;
+% rms_3d = 0.09;
+% d_min = 1.4;
+% seed = 1983;
+% rho = 2.2;
+% lay_pos = 1; %1: top, 2: bottom
+%
+% z_min = min(input_multem.spec_atoms(:, 4));
+% z_max = max(input_multem.spec_atoms(:, 4));
+%
+% tic;
+% input_multem.spec_atoms = ilc_amorp_lay_add(input_multem.spec_atoms, input_multem.spec_bs_x, input_multem.spec_bs_y, lz, d_min, Z, rms_3d, rho, lay_pos, seed);
+% toc;
+%
+% if(lay_pos==1)
+% input_multem.spec_slic(2).z_0 = z_min-lz; % Starting z position of the amorphous layer (Å)
+% input_multem.spec_slic(2).z_e = z_min; % Ending z position of the amorphous layer (Å)
+% else
+% input_multem.spec_slic(2).z_0 = z_max; % Starting z position of the amorphous layer (Å)
+% input_multem.spec_slic(2).z_e = z_max+lz; % Ending z position of the amorphous layer (Å)
+% end
+% input_multem.spec_slic(2).dz = 2.0; % slice thick of the amorphous layer (Å)
+
+% ilm_show_xtl(1, input_multem.spec_atoms)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+clc;
+tic;
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+toc;
+disp([min(atoms(:, 4)), max(atoms(:, 4))])
+
+[nslice, ~] = size(Slice);
+disp(['Number of slices = ', num2str(nslice)])
+
+figure(1); clf;
+plot(atoms(:, 3), atoms(:, 4), 'ok');
+set(gca, 'ydir', 'reverse');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic positions');
+ylabel('y', 'FontSize', 14);
+xlabel('x', 'FontSize', 12);
+axis equal;
+
+for i = 1:nslice
+ hold on;
+ plot([-2 input_multem.spec_bs_x], [Slice(i, 1) Slice(i, 1)], '-r', [-2 input_multem.spec_bs_x], [Slice(i, 2) Slice(i, 2)], '-r');
+ axis equal;
+
+end
+axis([-2, 18, min(input_multem.spec_atoms(:, 4))-5, max(input_multem.spec_atoms(:, 4))+5]);
+
+tic;
+[z_planes] = ilc_spec_planes(input_multem);
+toc;
+nplanes = length(z_planes);
+for i = 1:nplanes
+ hold on;
+ plot([-2 input_multem.spec_bs_x], [z_planes(i) z_planes(i)], '-b');
+ axis equal;
+end
+diff(z_planes)
+
+nbins = floor((max(atoms(:, 4))-min(atoms(:, 4)))/0.10001);
+tic;
+[x, y] = ilc_hist(input_multem.spec_atoms(:, 4), nbins-1);
+toc;
+
+% figure(2);clf;
+% plot(x, y, '-+r');
+% hold on;
+% ii = find(y<0.5);
+% plot(x(ii), y(ii), '.b');
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_slicing_zone_axis.m b/mex_examples_multem/example_specimen_slicing_zone_axis.m
old mode 100644
new mode 100755
index e5c6b3f1..d817758a
--- a/mex_examples_multem/example_specimen_slicing_zone_axis.m
+++ b/mex_examples_multem/example_specimen_slicing_zone_axis.m
@@ -1,54 +1,49 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.pn_dim = 111;
-input_multem.pn_seed = 300183;
-input_multem.pn_nconf = 3;
-
-input_multem.spec_rot_theta = 0; % final angle
-input_multem.spec_rot_u0 = [1 0 0]; % unitary vector
-input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
-input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
-na = 4; nb = 4; nc = 20; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-% ilm_show_crystal(1, input_multem.spec_atoms);
-
-input_multem.spec_dz = 5.0;
-
-view
-% get spec slicing
-tic;
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-toc;
-[natoms,~] = size(atoms); [nslice, ~] = size(Slice);
-
-for i = 1:nslice
- figure(1); clf;
- i1 = Slice(i, 5); i2 = Slice(i, 6); ii = i1:1:i2;
- plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4), '.k', atoms(ii, 2), atoms(ii, 3), atoms(ii, 4), 'or');
- set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
- title('Atomic positions');
- ylabel('y','FontSize',14);
- xlabel('x','FontSize',12);
- axis equal;
- i2-i1+1
- view([1 0 0]);
- pause(0.1);
-end
-
-[size(input_multem.spec_atoms, 1), natoms, nslice]
-[input_multem.spec_lx, input_multem.spec_ly, input_multem.spec_lz]
\ No newline at end of file
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+input_multem.atomic_vib_mod = 3; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_vib_dim = 111;
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_nconf = 3;
+
+input_multem.spec_rot_theta = 0; % final angle
+input_multem.spec_rot_u_0 = [1 0 0]; % unitary vector
+input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+na = 4;nb = 4;nc = 20;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+% ilm_show_xtl(1, input_multem.spec_atoms);
+
+input_multem.spec_slic(1).sli_thick = 5.0;
+
+view
+% get spec slicing
+tic;
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+toc;
+[natoms, ~] = size(atoms);[nslice, ~] = size(Slice);
+
+for i = 1:nslice
+ figure(1); clf;
+ i1 = Slice(i, 5);i2 = Slice(i, 6);ii = i1:1:i2;
+ plot3(atoms(:, 2), atoms(:, 3), atoms(:, 4), '.k', atoms(ii, 2), atoms(ii, 3), atoms(ii, 4), 'or');
+ set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+ title('Atomic positions');
+ ylabel('y', 'FontSize', 14);
+ xlabel('x', 'FontSize', 12);
+ axis equal;
+ i2-i1+1
+ view([1 0 0]);
+ pause(0.1);
+end
+
+[size(input_multem.spec_atoms, 1), natoms, nslice]
+[input_multem.spec_bs_x, input_multem.spec_bs_y, input_multem.spec_bs_z]
\ No newline at end of file
diff --git a/mex_examples_multem/example_specimen_subslicing.m b/mex_examples_multem/example_specimen_subslicing.m
old mode 100644
new mode 100755
index 57256e2c..a21f7e21
--- a/mex_examples_multem/example_specimen_subslicing.m
+++ b/mex_examples_multem/example_specimen_subslicing.m
@@ -1,71 +1,66 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 3; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.pn_dim = 110;
-input_multem.pn_seed = 300183;
-input_multem.pn_nconf = 1;
-
-input_multem.spec_rot_theta = 0; % final angle
-input_multem.spec_rot_u0 = [0 1 1]; % unitary vector
-input_multem.spec_rot_center_type = 1; % 1: geometric center, 2: User define
-input_multem.spec_rot_center_p = [0 0 0]; % rotation point
-
-input_multem.spec_lx = 10;
-input_multem.spec_ly = 10;
-input_multem.spec_lz = 10;
-input_multem.spec_dz = 0.5;
-
-occ = 1;
-region = 0;
-charge = 0;
-input_multem.spec_atoms = [29, 2, 2, 0.0, 0.8, 1.0, charge; 29, 6, 2, 0.0, 0.8, 1.0, charge];
-[input_multem.spec_atoms, input_multem.spec_lx, input_multem.spec_ly, lz] = graphene(1, 1.42, sqrt(0.5/(8*pi^2)));
-input_multem.spec_dz = 0.5;
-
-% get spec slicing
-tic;
-input_multem.pn_model = 1;
-[atoms0, Slice0] = ilc_spec_slicing(input_multem.toStruct);
-toc;
-
-[nslice0, ~] = size(Slice0);
-
-tic;
-input_multem.pn_model = 3;
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-toc;
-
-[nslice, ~] = size(Slice);
-
-figure(1); clf;
-plot(atoms(:, 2), atoms(:, 4), '*k');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Atomic positions');
-ylabel('y','FontSize',14);
-xlabel('x','FontSize',12);
-axis equal;
-axis([-2 input_multem.spec_lx+2 -5 input_multem.spec_lz + 5]);
-
-
-for i = 1:nslice
- hold on;
- plot([-2 18], [Slice(i, 1) Slice(i, 1)], '-b', [-2 18], [Slice(i, 2) Slice(i, 2)], '-b');
- axis equal;
- axis([-2 input_multem.spec_lx+2 -5 input_multem.spec_lz + 5]);
-end
-
-for i = 1:nslice0
- hold on;
- plot([-2 input_multem.spec_lx+2], [Slice0(i, 1) Slice0(i, 1)], '-r', [-2 input_multem.spec_lx+2], [Slice0(i, 2) Slice0(i, 2)], '-r');
- axis equal;
- axis([-2 input_multem.spec_lx+2 -5 input_multem.spec_lz + 5]);
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 3; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_vib_dim = [true, true, false];
+input_multem.atomic_vib_seed = 300183;
+input_multem.atomic_vib_nconf = 1;
+
+input_multem.spec_rot_theta = 0; % final angle
+input_multem.spec_rot_u_0 = [0 1 1]; % unitary vector
+input_multem.spec_rot_ctr_typ = 1; % 1: geometric center, 2: User define
+input_multem.spec_rot_ctr_p = [0 0 0]; % rotation point
+
+input_multem.spec_bs_x = 10;
+input_multem.spec_bs_y = 10;
+input_multem.spec_bs_z = 10;
+input_multem.spec_slic(1).sli_thick = 0.5;
+
+occ = 1;
+tag = 0;
+charge = 0;
+input_multem.spec_atoms = [29, 2, 2, 0.0, 0.8, 1.0, charge;29, 6, 2, 0.0, 0.8, 1.0, charge];
+[input_multem.spec_atoms, input_multem.spec_bs_x, input_multem.spec_bs_y, lz] = graphene(1, 1.42, sqrt(0.5/(8*pi^2)));
+input_multem.spec_slic(1).sli_thick = 0.5;
+
+% get spec slicing
+tic;
+input_multem.atomic_vib_mod = 1;
+[atoms0, Slice0] = ilc_spec_slicing(input_multem);
+toc;
+
+[nslice0, ~] = size(Slice0);
+
+tic;
+input_multem.atomic_vib_mod = 3;
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+toc;
+
+[nslice, ~] = size(Slice);
+
+figure(1); clf;
+plot(atoms(:, 2), atoms(:, 4), '*k');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic positions');
+ylabel('y', 'FontSize', 14);
+xlabel('x', 'FontSize', 12);
+axis equal;
+axis([-2 input_multem.spec_bs_x+2 -5 input_multem.spec_bs_z + 5]);
+
+
+for i = 1:nslice
+ hold on;
+ plot([-2 18], [Slice(i, 1) Slice(i, 1)], '-b', [-2 18], [Slice(i, 2) Slice(i, 2)], '-b');
+ axis equal;
+ axis([-2 input_multem.spec_bs_x+2 -5 input_multem.spec_bs_z + 5]);
+end
+
+for i = 1:nslice0
+ hold on;
+ plot([-2 input_multem.spec_bs_x+2], [Slice0(i, 1) Slice0(i, 1)], '-r', [-2 input_multem.spec_bs_x+2], [Slice0(i, 2) Slice0(i, 2)], '-r');
+ axis equal;
+ axis([-2 input_multem.spec_bs_x+2 -5 input_multem.spec_bs_z + 5]);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_transf_exp_factor.m b/mex_examples_multem/example_transf_exp_factor.m
new file mode 100755
index 00000000..b072b851
--- /dev/null
+++ b/mex_examples_multem/example_transf_exp_factor.m
@@ -0,0 +1,20 @@
+% Copyright 2021 Ivan Lobato
+
+clear;clc;
+
+E_0 = [60, 80, 100, 120, 200, 300];
+sigma = ilc_elec_interact_parm_kva(E_0); % radians/(kV - Angs)
+tf_exp_factor = ilc_transf_exp_factor(E_0); % radians/(V - Angs)
+
+f = 1e-3
+
+figure(1); clf;
+plot(E_0, tf_exp_factor, '-*r', E_0, sigma*f, '-*b');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+% title('Atomic radius');
+% ylabel('$\mathrm{radius}$', 'interpreter', 'latex', 'FontSize', 14);
+% xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+% axis([1 103 0 1.1*max(r(:))]);
+% legend('rms', 'Cut-off', 'Experimental');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_transmission_function.m b/mex_examples_multem/example_transmission_function.m
old mode 100644
new mode 100755
index f6065a05..d8430165
--- a/mex_examples_multem/example_transmission_function.m
+++ b/mex_examples_multem/example_transmission_function.m
@@ -1,83 +1,78 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_ncores = 1; % Number of Cores CPU (It will be used in the future)
-input_multem.system_conf.cpu_nthread = 4; % Number of CPU threads
-input_multem.system_conf.gpu_device = 0; % GPU device (i.e. 0, 1, 2, ... )
-
-input_multem.pn_model = 1; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_dim = 110; % phonon dimensions
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-input_multem.pn_single_conf = 1; % 1: true, 0:false
-input_multem.pn_nconf = 1; % true: phonon configuration, false: number of frozen phonon configurations
-
-input_multem.bwl = 0;
-
-input_multem.E_0 = 300;
-input_multem.theta = 0.0;
-input_multem.phi = 0.0;
-
-na = 4; nb = 4; nc =2; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-% input_multem.spec_atoms = [79 4.0 4.0 0 rmsd_3d 1.0];
-% input_multem.spec_lx = 8.0;
-% input_multem.spec_ly = 8.0;
-% input_multem.spec_dz = 0.5;
-
-input_multem.nx = 2048;
-input_multem.ny = 2048;
-
-clear ilc_spec_slicing;
-[atoms, Slice] = ilc_spec_slicing(input_multem.toStruct);
-
-[natoms,~] = size(atoms); [nslice, ~] = size(Slice);
-for islice = 1:nslice
- input_multem.islice = islice;
-
- input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
- input_multem.system_conf.precision = 2; % eP_Float = 1, eP_double = 2
- tic;
-% clear ilc_transmission_function;
- ouput_multislice_1 = input_multem.ilc_transmission_function;
- toc;
-
- input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
- input_multem.system_conf.precision = 2; % eP_Float = 1, eP_double = 2
- tic;
-% clear ilc_transmission_function;
- ouput_multislice_2 = input_multem.ilc_transmission_function;
- toc;
- sum(abs(ouput_multislice_1.trans(:)-ouput_multislice_2.trans(:))/(input_multem.nx*input_multem.ny))
-
- figure(1);
- subplot(1, 3, 1);
- imagesc(real(ouput_multislice_1.trans));
- colormap gray;
- axis image;
- subplot(1, 3, 2);
- imagesc(imag(ouput_multislice_1.trans));
- colormap gray;
- axis image;
- subplot(1, 3, 3);
- imagesc(abs(ouput_multislice_1.trans));
- colormap gray;
- axis image;
- num2str([islice, min(abs(ouput_multislice_1.trans(:))), max(abs(ouput_multislice_1.trans(:))), sum(abs(ouput_multislice_1.trans(:)))/(input_multem.nx*input_multem.ny)], 10)
- pause(0.10);
+clear;clc;
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_ncores = 1; % Number of Cores CPU (It will be used in the future)
+system_config.cpu_n_thread = 4; % Number of CPU threads
+system_config.gpu_device = 0; % GPU device (i.e. 0, 1, 2, ... )
+
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+input_multem.atomic_vib_sgl_conf = 1; % 1: true, 0:false
+input_multem.atomic_vib_nconf = 1; % true: phonon configuration, false: number of frozen phonon configurations
+
+input_multem.bwl = 0;
+
+input_multem.E_0 = 300;
+input_multem.theta = 0.0;
+input_multem.phi = 0.0;
+
+na = 4;nb = 4;nc =2;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+% input_multem.spec_atoms = [79 4.0 4.0 0 rmsd_3d 1.0];
+% input_multem.spec_bs_x = 8.0;
+% input_multem.spec_bs_y = 8.0;
+% input_multem.spec_slic(1).sli_thick = 0.5;
+
+input_multem.nx = 2048;
+input_multem.ny = 2048;
+
+clear ilc_spec_slicing;
+[atoms, Slice] = ilc_spec_slicing(input_multem);
+
+[natoms, ~] = size(atoms);[nslice, ~] = size(Slice);
+for islice = 1:nslice
+ input_multem.islice = islice;
+
+ system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+ system_config.precision = 2; % eP_Float = 1, eP_double = 2
+ tic;
+% clear ilc_transmission_function;
+ output_multislice_1 = ilc_transmission_function(system_config, input_multem);
+ toc;
+
+ system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+ system_config.precision = 2; % eP_Float = 1, eP_double = 2
+ tic;
+% clear ilc_transmission_function;
+ output_multislice_2 = ilc_transmission_function(system_config, input_multem);
+ toc;
+ sum(abs(output_multislice_1.trans(:)-output_multislice_2.trans(:))/(input_multem.nx*input_multem.ny))
+
+ figure(1);
+ subplot(1, 3, 1);
+ imagesc(real(output_multislice_1.trans));
+ colormap gray;
+ axis image;
+ subplot(1, 3, 2);
+ imagesc(imag(output_multislice_1.trans));
+ colormap gray;
+ axis image;
+ subplot(1, 3, 3);
+ imagesc(abs(output_multislice_1.trans));
+ colormap gray;
+ axis image;
+ num2str([islice, min(abs(output_multislice_1.trans(:))), max(abs(output_multislice_1.trans(:))), sum(abs(output_multislice_1.trans(:)))/(input_multem.nx*input_multem.ny)], 10)
+ pause(0.10);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_vp.m b/mex_examples_multem/example_vp.m
old mode 100644
new mode 100755
index 1568aeb6..a2aa6cd0
--- a/mex_examples_multem/example_vp.m
+++ b/mex_examples_multem/example_vp.m
@@ -1,11 +1,9 @@
-% Copyright 2023 Ivan Lobato
-
clear; clc;
addpath([fileparts(pwd) filesep 'mex_bin'])
addpath([fileparts(pwd) filesep 'crystalline_materials'])
addpath([fileparts(pwd) filesep 'matlab_functions'])
-Z = 49;
+Z = 78;
charge = 0;
Rmin = 1e-02; Rmax = 5.0; nR = 512;
diff --git a/mex_examples_multem/example_vr.m b/mex_examples_multem/example_vr.m
old mode 100644
new mode 100755
index 61ea89e5..54149f1a
--- a/mex_examples_multem/example_vr.m
+++ b/mex_examples_multem/example_vr.m
@@ -1,47 +1,46 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-Z = 79;
-occ = 1;
-region = 0;
-charge = 0;
-
-rmin = 1e-02; rmax = 5.0; nr = 512;
-dlnr = log(rmax/rmin)/(nr-1); r = rmin*exp((0:1:(nr-1))*dlnr);
-
-tic;
-[f1, df1] = ilc_vr(1, Z, charge, r);
-[f2, df2] = ilc_vr(2, Z, charge, r);
-[f3, df3] = ilc_vr(3, Z, charge, r);
-[f4, df4] = ilc_vr(4, Z, charge, r);
-[f5, df5] = ilc_vr(5, Z, charge, r);
-[f6, df6] = ilc_vr(6, Z, charge, r);
-toc;
-
-figure(1); clf;
-
-subplot(1, 2, 1);
-hold on;
-plot(r, f1, '-k', r, f2, '-b', r, f3, '-c', r, f4, '-m', r, f5, '-r', r, f6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Atomic potential');
-ylabel('$\displaystyle V(r)$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{r}$','interpreter','latex','FontSize',12);
-xlim([0 rmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-subplot(1, 2, 2);
-hold on;
-plot(r, df1, '-k', r, df2, '-b', r, df3, '-c', r, df4, '-m', r, df5, '-r', r, df6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Derivative of the Atomic potential');
-ylabel('$\displaystyle \frac{d V(r)}{dr}$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{r}$','interpreter','latex','FontSize',12);
-xlim([0 rmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-set(gcf,'units','normalized','outerposition',[0 0 1 1]);
\ No newline at end of file
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+Z = 79;
+occ = 1;
+tag = 0;
+charge = 0;
+
+rmin = 1e-02;rmax = 5.0;nr = 512;
+dlnr = log(rmax/rmin)/(nr-1);r = rmin*exp((0:1:(nr-1))*dlnr);
+
+tic;
+[f1, df1] = ilc_vr(1, Z, charge, r);
+[f2, df2] = ilc_vr(2, Z, charge, r);
+[f3, df3] = ilc_vr(3, Z, charge, r);
+[f4, df4] = ilc_vr(4, Z, charge, r);
+[f5, df5] = ilc_vr(5, Z, charge, r);
+[f6, df6] = ilc_vr(6, Z, charge, r);
+toc;
+
+figure(1); clf;
+
+subplot(1, 2, 1);
+hold on;
+plot(r, f1, '-k', r, f2, '-b', r, f3, '-c', r, f4, '-m', r, f5, '-r', r, f6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic potential');
+ylabel('$\displaystyle V(r)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 rmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+subplot(1, 2, 2);
+hold on;
+plot(r, df1, '-k', r, df2, '-b', r, df3, '-c', r, df4, '-m', r, df5, '-r', r, df6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Derivative of the Atomic potential');
+ylabel('$\displaystyle \frac{d V(r)}{dr}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 rmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_vz.m b/mex_examples_multem/example_vz.m
old mode 100644
new mode 100755
index 8f466bf1..2660fcae
--- a/mex_examples_multem/example_vz.m
+++ b/mex_examples_multem/example_vz.m
@@ -1,46 +1,46 @@
-% Copyright 2023 Ivan Lobato
-
-clear; clc;
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-Z = 51;
-charge = 1;
-
-rmin = 1e-02; rmax = 5.0; nr = 512;
-dlnr = log(rmax/rmin)/(nr-1); r = rmin*exp((0:1:(nr-1))*dlnr);
-z0 = -8.0; ze = 8.0;
-
-tic;
-[f1, df1] = ilc_vz(1, Z, charge, z0, ze, r);
-[f2, df2] = ilc_vz(2, Z, charge, z0, ze, r);
-[f3, df3] = ilc_vz(3, Z, charge, z0, ze, r);
-[f4, df4] = ilc_vz(4, Z, charge, z0, ze, r);
-[f5, df5] = ilc_vz(5, Z, charge, z0, ze, r);
-[f6, df6] = ilc_vz(6, Z, charge, z0, ze, r);
-toc;
-
-figure(1); clf;
-
-subplot(1, 2, 1);
-hold on;
-plot(r, f1, '-k', r, f2, '-b', r, f3, '-c', r, f4, '-m', r, f5, '-r', r, f6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Atomic potential');
-ylabel('$\displaystyle V(r)$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{r}$','interpreter','latex','FontSize',12);
-xlim([0 rmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-subplot(1, 2, 2);
-hold on;
-plot(r, df1, '-k', r, df2, '-b', r, df3, '-c', r, df4, '-m', r, df5, '-r', r, df6, '-g');
-set(gca,'FontSize',12,'LineWidth',1,'PlotBoxAspectRatio',[1.25 1 1]);
-title('Derivative of the Atomic potential');
-ylabel('$\displaystyle \frac{d V(r)}{dr}$','interpreter','latex','FontSize',14);
-xlabel('$\mathbf{r}$','interpreter','latex','FontSize',12);
-xlim([0 rmax]);
-legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
-
-set(gcf,'units','normalized','outerposition',[0 0 1 1]);
\ No newline at end of file
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+
+Z = 79;
+charge = 0;
+
+rmin = 1e-02;rmax = 5.0;nr = 512;
+dlnr = log(rmax/rmin)/(nr-1);r = rmin*exp((0:1:(nr-1))*dlnr);
+z0 = -2.0;ze = 2.0;
+
+tic;
+[f1, df1] = ilc_vz(1, Z, charge, z0, ze, r);
+[f2, df2] = ilc_vz(2, Z, charge, z0, ze, r);
+[f3, df3] = ilc_vz(3, Z, charge, z0, ze, r);
+[f4, df4] = ilc_vz(4, Z, charge, z0, ze, r);
+[f5, df5] = ilc_vz(5, Z, charge, z0, ze, r);
+[f6, df6] = ilc_vz(6, Z, charge, z0, ze, r);
+toc;
+
+figure(1); clf;
+
+subplot(1, 2, 1);
+hold on;
+plot(r, f1, '-k', r, f2, '-b', r, f3, '-c', r, f4, '-m', r, f5, '-r', r, f6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Atomic potential');
+ylabel('$\displaystyle V(r)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 rmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+subplot(1, 2, 2);
+hold on;
+plot(r, df1, '-k', r, df2, '-b', r, df3, '-c', r, df4, '-m', r, df5, '-r', r, df6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Derivative of the Atomic potential');
+ylabel('$\displaystyle \frac{d V(r)}{dr}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{r}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 rmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_vzp.m b/mex_examples_multem/example_vzp.m
new file mode 100755
index 00000000..44b401cd
--- /dev/null
+++ b/mex_examples_multem/example_vzp.m
@@ -0,0 +1,45 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+
+Z = 79;
+charge = 4;
+
+Rmin = 1e-03;Rmax = 5.0;nR = 512;
+dlnR = log(Rmax/Rmin)/(nR-1);R = Rmin*exp((0:1:(nR-1))*dlnR);
+
+tic;
+[f1, df1] = ilc_vzp(1, Z, charge, R);
+[f2, df2] = ilc_vzp(2, Z, charge, R);
+[f3, df3] = ilc_vzp(3, Z, charge, R);
+[f4, df4] = ilc_vzp(4, Z, charge, R);
+[f5, df5] = ilc_vzp(5, Z, charge, R);
+[f6, df6] = ilc_vzp(6, Z, charge, R);
+toc;
+
+figure(1); clf;
+
+subplot(1, 2, 1);
+hold on;
+plot(R, f1, '-k', R, f2, '-b', R, f3, '-c', R, f4, '-m', R, f5, '-r', R, f6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Projected Atomic potential');
+ylabel('$\displaystyle V(R)$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{R}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 Rmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+subplot(1, 2, 2);
+hold on;
+plot(R, df1, '-k', R, df2, '-b', R, df3, '-c', R, df4, '-m', R, df5, '-r', R, df6, '-g');
+set(gca, 'FontSize', 12, 'LineWidth', 1, 'PlotBoxAspectRatio', [1.25 1 1]);
+title('Derivative of the Atomic potential');
+ylabel('$\displaystyle \frac{d V(R)}{dr}$', 'interpreter', 'latex', 'FontSize', 14);
+xlabel('$\mathbf{R}$', 'interpreter', 'latex', 'FontSize', 12);
+xlim([0 Rmax]);
+legend('Doyle [0-4]', 'Peng [0-4]', 'Peng [0-12]', 'Kirkland [0-12]', 'Weickenmeier [0-12]', 'Lobato [0-12]');
+
+set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
\ No newline at end of file
diff --git a/mex_examples_multem/example_wave_function.m b/mex_examples_multem/example_wave_function.m
old mode 100644
new mode 100755
index 3354031e..9308d47a
--- a/mex_examples_multem/example_wave_function.m
+++ b/mex_examples_multem/example_wave_function.m
@@ -1,115 +1,112 @@
-% output_multislice = input_multem.ilc_multem perform TEM simulation
-% All parameters of the input_multem structure are explained in ilm_dflt_input_multem()
-% Copyright 2023 Ivan Lobato clear; clc;
-
-addpath([fileparts(pwd) filesep 'mex_bin'])
-addpath([fileparts(pwd) filesep 'crystalline_materials'])
-addpath([fileparts(pwd) filesep 'matlab_functions'])
-
-input_multem = multem_input.parameters; % Load default values;
-
-input_multem.system_conf.precision = 1; % eP_Float = 1, eP_double = 2
-input_multem.system_conf.device = 2; % eD_CPU = 1, eD_GPU = 2
-input_multem.system_conf.cpu_nthread = 4;
-input_multem.system_conf.gpu_device = 0;
-
-% eTEMST_EWFS=51, eTEMST_EWRS=52
-input_multem.simulation_type = 52;
-input_multem.interaction_model = 1; % eESIM_Multislice = 1, eESIM_Phase_Object = 2, eESIM_Weak_Phase_Object = 3
-input_multem.potential_slicing = 1; % ePS_Planes = 1, ePS_dz_Proj = 2, ePS_dz_Sub = 3, ePS_Auto = 4
-
-input_multem.potential_type = 6; % ePT_Doyle_0_4 = 1, ePT_Peng_0_4 = 2, ePT_Peng_0_12 = 3, ePT_Kirkland_0_12 = 4, ePT_Weickenmeier_0_12 = 5, ePT_Lobato_0_12 = 6
-
-input_multem.pn_model = 3; % ePM_Still_Atom = 1, ePM_Absorptive = 2, ePM_Frozen_Phonon = 3
-input_multem.pn_dim = 110; % phonon dimensions
-input_multem.pn_seed = 300183; % Random seed(frozen phonon)
-input_multem.pn_single_conf = 1; % 1: true, 0:false (extract single configuration)
-input_multem.pn_nconf = 3; % true: phonon configuration, false: number of frozen phonon configurations
-
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = 0; % Array of thickes
-
-input_multem.bwl = 0;
-
-input_multem.E_0 = 100;
-input_multem.theta = 0.01;
-input_multem.phi = 0.0;
-
-na = 8; nb = 8; nc = 3; ncu = 2; rmsd_3d = 0.085;
-
-[input_multem.spec_atoms, input_multem.spec_lx...
-, input_multem.spec_ly, input_multem.spec_lz...
-, a, b, c, input_multem.spec_dz] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
-
-input_multem.thick_type = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
-input_multem.thick = 0:2*c:1000; % Array of thickes
-
-input_multem.nx = 2048;
-input_multem.ny = 2048;
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.iw_type = 1; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
-input_multem.iw_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
-input_multem.iw_x = 0.5*input_multem.spec_lx; % x position
-input_multem.iw_y = 0.5*input_multem.spec_ly; % y position
-
-%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.cond_lens_m = 0; % Vortex momentum
-input_multem.cond_lens_c_10 = 1110; % Defocus (�)
-input_multem.cond_lens_c_30 = 3.3; % Third order spherical aberration (mm)
-input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.cond_lens_outer_aper_ang = 7.50; % Outer aperture (mrad)
-input_multem.cond_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.cond_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_si_sigma = 0.2; % standard deviation: For parallel ilumination(�^-1); otherwise (�)
-input_multem.cond_lens_si_rad_npts = 8; % # of integration points. It will be only used if illumination_model=4
-input_multem.cond_lens_zero_defocus_type = 1; % eZDT_First = 1, eZDT_User_Define = 4
-input_multem.cond_lens_zero_defocus_plane = 0;
-
-%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
-input_multem.obj_lens_m = 0; % Vortex momentum
-input_multem.obj_lens_c_10 = 15.836; % Defocus (�)
-input_multem.obj_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
-input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
-input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (�)
-input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (�)
-input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (�)
-input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (�)
-input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
-input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
-input_multem.obj_lens_ti_sigma = 32; % standard deviation (�)
-input_multem.obj_lens_ti_npts = 10; % # of integration points. It will be only used if illumination_model=4
-input_multem.obj_lens_zero_defocus_type = 4; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
-input_multem.obj_lens_zero_defocus_plane = 5;
-
-input_multem.output_area_ix_0 = 1; % x-starting pixel
-input_multem.output_area_iy_0 = 1; % y-starting pixel
-input_multem.output_area_ix_e = 1; % x-final pixel
-input_multem.output_area_iy_e = 1; % y-final pixel
-
-clear ilc_wave_function;
-tic;
-ouput_multislice = input_multem.ilc_wave_function;
-toc;
-
-figure(1);
-for ithk=1:length(ouput_multislice.thick)
- psi_coh = flipud(ouput_multislice.data(ithk).psi_coh);
-
- subplot(1, 2, 1);
- imagesc(abs(psi_coh).^2);
- colormap gray;
- axis image;
- title(strcat('Intensity, thick = ', num2str(ithk)));
- subplot(1, 2, 2);
- imagesc(angle(psi_coh));
- colormap gray;
- axis image;
- title(strcat('Phase, thick = ', num2str(ithk)));
- pause(0.25);
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+
+input_multem = ilm_dflt_input_multem(); % Load default values;
+
+system_config.precision = 1; % eP_Float = 1, eP_double = 2
+system_config.device = 2; % eD_CPU = 1, eD_GPU = 2
+system_config.cpu_n_thread = 4;
+system_config.gpu_device = 0;
+
+% eTEMST_EWFS=51, eTEMST_EWRS=52
+input_multem.em_sim_typ = 52;
+input_multem.elec_spec_interact_mod = 1; % eesim_multislice = 1, eesim_phase_object = 2, eesim_weak_phase_object = 3
+input_multem.spec_slic(1).typ = 1; % esst_plns_proj = 1, esst_dz_proj = 2, esst_plns_sub = 3, esst_dz_sub = 4, esst_user_def = 5, esst_auto = 6
+
+input_multem.atomic_pot_parm_typ = 6; % eappt_doyle_0_4 = 1, eappt_peng_0_4 = 2, eappt_peng_0_12 = 3, eappt_kirkland_0_12 = 4, eappt_weickenmeier_0_12 = 5, eappt_lobato_0_12 = 6
+
+input_multem.atomic_vib_mod = 1; % eavm_still_atom = 1, eavm_absorptive_pot = 2, eavm_frozen_phonon = 3, eavm_user_def = 4
+input_multem.atomic_vib_dim = [true, true, false]; % phonon dimensions
+input_multem.atomic_vib_seed = 300183; % Random seed(frozen phonon)
+input_multem.atomic_vib_sgl_conf = 0; % 1: true, 0:false (extract single configuration)
+input_multem.atomic_vib_nconf = 5; % true: phonon configuration, false: number of frozen phonon configurations
+
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0; % Array of thickes
+
+input_multem.bwl = 0;
+
+input_multem.E_0 = 100;
+input_multem.theta = 0.01;
+input_multem.phi = 0.0;
+
+na = 8;nb = 8;nc = 3;ncu = 2;rmsd_3d = 0.085;
+
+[input_multem.spec_atoms, input_multem.spec_bs_x...
+, input_multem.spec_bs_y, input_multem.spec_bs_z...
+, a, b, c, input_multem.spec_slic(1).sli_thick] = Au001_xtl(na, nb, nc, ncu, rmsd_3d);
+
+input_multem.thick_typ = 1; % eTT_Whole_Spec = 1, eTT_Through_Thick = 2, eTT_Through_Slices = 3
+input_multem.thick = 0:2*c:1000; % Array of thickes
+
+input_multem.nx = 2048;
+input_multem.ny = 2048;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% Incident wave %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.incdt_wav_typ = 1; % 1: Plane_Wave, 2: Convergent_wave, 3:User_Define, 4: auto
+input_multem.incdt_wav_psi = read_psi_0_multem(input_multem.nx, input_multem.ny); % user define incident wave
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%% beam position %%%%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.beam_pos = [input_multem.spec_bs_x/2;input_multem.spec_bs_y/2];
+
+%%%%%%%%%%%%%%%%%%%%%%%% condenser lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.cond_lens_m = 0; % Vortex momentum
+input_multem.cond_lens_c_10 = 1110; % Defocus (Å)
+input_multem.cond_lens_c_30 = 3.3; % Third order spherical aberration (mm)
+input_multem.cond_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.cond_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.cond_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.cond_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.cond_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.cond_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.cond_lens_outer_aper_ang = 7.50; % Outer aperture (mrad)
+input_multem.cond_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.cond_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_spt_inc_sigma = 0.2; % standard deviation: For parallel ilumination(Å^-1);otherwise (Å)
+input_multem.cond_lens_spt_inc_rad_npts = 8; % # of integration points. It will be only used if illum_mod=4
+input_multem.cond_lens_zero_def_typ = 1; % eZDT_First = 1, eZDT_User_Define = 2
+input_multem.cond_lens_zero_def_plane = 0;
+
+%%%%%%%%%%%%%%%%%%%%%%%% Objective lens %%%%%%%%%%%%%%%%%%%%%%%%
+input_multem.obj_lens_m = 0; % Vortex momentum
+input_multem.obj_lens_c_10 = 15.836; % Defocus (Å)
+input_multem.obj_lens_c_30 = 1e-03; % Third order spherical aberration (mm)
+input_multem.obj_lens_c_50 = 0.00; % Fifth order spherical aberration (mm)
+input_multem.obj_lens_c_12 = 0.0; % Twofold astigmatism (Å)
+input_multem.obj_lens_phi_12 = 0.0; % Azimuthal angle of the twofold astigmatism (º)
+input_multem.obj_lens_c_23 = 0.0; % Threefold astigmatism (Å)
+input_multem.obj_lens_phi_23 = 0.0; % Azimuthal angle of the threefold astigmatism (º)
+input_multem.obj_lens_inner_aper_ang = 0.0; % Inner aperture (mrad)
+input_multem.obj_lens_outer_aper_ang = 24.0; % Outer aperture (mrad)
+input_multem.obj_lens_tp_inc_sigma = 32; % standard deviation (Å)
+input_multem.obj_lens_tp_inc_npts = 10; % # of integration points. It will be only used if illum_mod=4
+input_multem.obj_lens_zero_def_typ = 3; % eZDT_First = 1, eZDT_Middle = 2, eZDT_Last = 3, eZDT_User_Define = 4
+input_multem.obj_lens_zero_def_plane = 0;
+
+input_multem.output_area_ip_0 = [1;1]; % Starting position in pixels
+input_multem.output_area_ip_e = [1;1]; % End position in pixels
+
+clear ilc_wave_function;
+tic;
+output_multislice = ilc_wave_function(system_config, input_multem);
+toc;
+
+figure(1);
+for ithk=1:length(output_multislice.thick)
+ psi_coh = flipud(output_multislice.data(ithk).psi_coh);
+
+ subplot(1, 2, 1);
+ imagesc(abs(psi_coh).^2);
+ colormap gray;
+ axis image;
+ title(strcat('Intensity, thick = ', num2str(ithk)));
+ subplot(1, 2, 2);
+ imagesc(angle(psi_coh));
+ colormap gray;
+ axis image;
+ title(strcat('Phase, thick = ', num2str(ithk)));
+ pause(0.25);
end
\ No newline at end of file
diff --git a/mex_examples_multem/example_xtl_build.m b/mex_examples_multem/example_xtl_build.m
new file mode 100755
index 00000000..0dc9df85
--- /dev/null
+++ b/mex_examples_multem/example_xtl_build.m
@@ -0,0 +1,44 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+xtl_parm.na = 1;
+xtl_parm.nb = 1;
+xtl_parm.nc = 1;
+
+xtl_parm.a = 4.0780;
+xtl_parm.b = 4.0780;
+xtl_parm.c = 4.0780;
+
+xtl_parm.alpha = 90;
+xtl_parm.beta = 90;
+xtl_parm.gamma = 90;
+
+xtl_parm.sgn = 1;
+xtl_parm.pbc = false;
+
+occ = 1;
+tag = 0;
+charge = 0;
+% Au = 79
+%Z x y z sigma occupancy tag charge
+rmsd_3d = 0.085;
+
+xtl_parm.asym_uc = [];
+
+xtl_parm.base = [79, 0.0, 0.0, 0.0, rmsd_3d, occ, tag, charge;...
+ 79, 0.5, 0.5, 0.0, rmsd_3d, occ, tag, charge;...
+ 79, 0.0, 0.5, 0.5, rmsd_3d, occ, tag, charge;...
+ 79, 0.5, 0.0, 0.5, rmsd_3d, occ, tag, charge];
+
+tic;
+if 1
+ atoms = ilc_xtl_build(xtl_parm);
+else
+ atoms = ilm_xtl_build(xtl_parm);
+end
+toc;
+
+ilm_show_xtl(1, atoms);
diff --git a/mex_examples_multem/example_xtl_build_base.m b/mex_examples_multem/example_xtl_build_base.m
new file mode 100755
index 00000000..60c40347
--- /dev/null
+++ b/mex_examples_multem/example_xtl_build_base.m
@@ -0,0 +1,28 @@
+% Copyright 2021 Ivan Lobato
+clear;clc;
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+xtl_parm.a = 5;
+xtl_parm.b = 5;
+xtl_parm.c = 5;
+xtl_parm.alpha = 90;
+xtl_parm.beta = 90;
+xtl_parm.gamma = 90;
+xtl_parm.na = 1;
+xtl_parm.nb = 1;
+xtl_parm.nc = 1;
+xtl_parm.sgn = 120;
+xtl_parm.pbc = false;
+xtl_parm.asym_uc = [6, 0, 0, 0; 6, 1/4, 1/4, 1/4];
+if 1
+ xtl_parm.base = ilc_xtl_build_base(xtl_parm.asym_uc, xtl_parm.sgn);
+else
+ xtl_parm.base = ilm_xtl_build_base(xtl_parm);
+end
+
+base = xtl_parm.base;
+
+ilm_show_xtl(1, base);
+view([0 0 1])
\ No newline at end of file
diff --git a/mex_examples_multem/example_xtl_system_space_group.m b/mex_examples_multem/example_xtl_system_space_group.m
new file mode 100755
index 00000000..aff38a58
--- /dev/null
+++ b/mex_examples_multem/example_xtl_system_space_group.m
@@ -0,0 +1,52 @@
+clear; clc;
+
+addpath(['..', filesep, 'matlab_functions'])
+addpath(['..', filesep, 'crystalline_materials'])
+addpath(['..', filesep, 'mex_bin'])
+
+% triclinic or anorthic: a
+% monoclinic" m
+% orthorhombic: o
+% tetragonal: t
+% rhombohedral or trigonal: r
+% hexagonal: h
+% cubic: c
+
+css = 'triclinic';
+% css = 'cubic';
+css = 'h';
+% css = 'o';
+
+% from xtl system string to xtl system number
+csn_c = ilc_xtl_css_2_csn(css);
+csn_m = ilm_xtl_css_2_csn(css);
+
+disp('from xtl system string to xtl system number')
+disp(' C++ Matlab')
+disp([csn_c, csn_m])
+
+% from xtl system string to space group range
+[sgr_0c, sgr_ec] = ilc_xtl_css_2_sgr(css);
+[sgr_0m, sgr_em] = ilm_xtl_css_2_sgr(css);
+
+disp('from xtl system string to space group range')
+disp(' C++ Matlab')
+disp([sgr_0c, sgr_ec, sgr_0m, sgr_em])
+csn = csn_c;
+
+% from xtl system number to space group range
+[sgr_0c, sgr_ec] = ilc_xtl_csn_2_sgr(csn);
+[sgr_0m, sgr_em] = ilm_xtl_csn_2_sgr(csn);
+
+disp('from xtl system number to space group range')
+disp(' C++ Matlab')
+disp([sgr_0c, sgr_ec, sgr_0m, sgr_em])
+
+sgn = 125;
+% from space group number to xtl system number
+csn_c = ilc_xtl_sgn_2_csn(sgn);
+csn_m = ilm_xtl_sgn_2_csn(sgn);
+
+disp('from space group number to xtl system number')
+disp(' C++ Matlab')
+disp([csn_c, csn_m])
\ No newline at end of file
diff --git a/mex_examples_multem/stem_sim_Au_def_0.00_nconf_2.mat b/mex_examples_multem/stem_sim_Au_def_0.00_nconf_2.mat
deleted file mode 100644
index c7528303..00000000
Binary files a/mex_examples_multem/stem_sim_Au_def_0.00_nconf_2.mat and /dev/null differ
diff --git a/mex_files_multem/ilc_add_amorp_lay.cpp b/mex_files_multem/ilc_add_amorp_lay.cpp
deleted file mode 100644
index d6b0c2a9..00000000
--- a/mex_files_multem/ilc_add_amorp_lay.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * This file is part of MULTEM.
- * Copyright 2015 Ivan Lobato
- *
- * MULTEM is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MULTEM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MULTEM. If not, see .
- */
-
-#include "types.cuh"
-#include "matlab_types.cuh"
-#include "atomic_data_mt.hpp"
-#include "amorp_spec.hpp"
-
-#include
-#include "matlab_mex.cuh"
-
-void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[ ])
-{
- auto ratoms = mx_get_matrix(prhs[0]);
- auto l_x = mx_get_scalar(prhs[1]);
- auto l_y = mx_get_scalar(prhs[2]);
- auto l_z = mx_get_scalar(prhs[3]);
- auto r_min = mx_get_scalar(prhs[4]);
- auto Z = mx_get_scalar(prhs[5]);
- auto rms_3d = mx_get_scalar(prhs[6]);
- auto rho = mx_get_scalar(prhs[7]);
- auto lay_pos = (nrhs>8)?mx_get_scalar(prhs[8]):mt::eALT_Top;
- int seed = (nrhs>9)?mx_get_scalar(prhs[9]):300183;
-
- /*******************************************************************/
- mt::Atom_Data atoms;
- atoms.set_atoms(ratoms.rows, ratoms.cols, ratoms.real, l_x, l_y);
-
- int region = (ratoms.rows==0)?0:atoms.region_max+1;
-
- atoms.amorp_lay_info.resize(1);
- if(lay_pos==mt::eALT_Top)
- {
- atoms.amorp_lay_info[0].z_0 = atoms.z_min-l_z;
- atoms.amorp_lay_info[0].z_e = atoms.z_min;
- atoms.amorp_lay_info[0].dz = 2.0;
- atoms.amorp_lay_info[0].type = mt::eALT_Top;
- atoms.amorp_lay_info[0].region = region;
- }
- else
- {
- atoms.amorp_lay_info[0].z_0 = atoms.z_max;
- atoms.amorp_lay_info[0].z_e = atoms.z_max+l_z;
- atoms.amorp_lay_info[0].dz = 2.0;
- atoms.amorp_lay_info[0].type = mt::eALT_Bottom;
- atoms.amorp_lay_info[0].region = region;
- }
-
- mt::Amorp_Spec spec;
- spec.create(atoms, r_min, Z, rms_3d, rho, seed);
-
- auto atomsM = mx_create_matrix(atoms.size(), 8, plhs[0]);
- for(auto idx = 0; idx
+ *
+ * Multem is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version of the License, or
+ * (at your option) any later version.
+ *
+ * Multem is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Multem. If not, see .
+ */
+
+#define MATLAB_BLAS_LAPACK
+
+#include "types_mt.cuh"
+#include "particles.cuh"
+#include "amorp_build.hpp"
+
+#include
+#include "matlab_mex.h"
+
+void mexFunction(dt_int32 nlhs, mxArray* plhs[], dt_int32 nrhs, const mxArray* prhs[])
+{
+ using T = dt_float32;
+
+ const auto Z = mex_get_num(prhs[0]);
+ const auto rms_3d = mex_get_num(prhs[1]);
+ const auto occ = mex_get_num(prhs[2]);
+ const auto tag = mex_get_num(prhs[3]);
+ const auto bs = mex_get_r_3d(prhs[4]);
+ const auto d_min = mex_get_num(prhs[5]);
+ const auto rho = mex_get_num(prhs[6]);
+ const dt_int32 seed = (nrhs>7)?mex_get_num(prhs[7]):300183;
+
+ /***************************************************************************************/
+ mt::R_3d r_0(0, 0, 0);
+ mt::Spec_Lay_Info spec_lay_info(bs, r_0, tag);
+
+ mt::Amorp_Build amorp_build;
+ auto atoms = amorp_build(Z, rms_3d, occ, d_min, rho, seed, spec_lay_info);
+
+ auto patoms = mex_create_pVctr({atoms.size(), atoms.cols_used}, plhs[0]);
+ atoms.cpy_to_ptr(patoms.data(), atoms.size(), 0, atoms.cols_used);
+}
\ No newline at end of file
diff --git a/mex_files_multem/ilc_amorp_lay_add.cpp b/mex_files_multem/ilc_amorp_lay_add.cpp
new file mode 100755
index 00000000..3c09c64c
--- /dev/null
+++ b/mex_files_multem/ilc_amorp_lay_add.cpp
@@ -0,0 +1,58 @@
+/*
+ * This file is part of Multem.
+ * Copyright 2022 Ivan Lobato
+ *
+ * Multem is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version of the License, or
+ * (at your option) any later version.
+ *
+ * Multem is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Multem. If not, see .
+ */
+
+#define MATLAB_BLAS_LAPACK
+
+#include "types_mt.cuh"
+#include "particles.cuh"
+#include "amorp_build.hpp"
+
+#include
+#include "matlab_mex.h"
+
+template
+void mex_run(dt_int32 nlhs, mxArray* plhs[], dt_int32 nrhs, const mxArray* prhs[])
+{
+ const auto patoms_i = mex_get_pvctr(prhs[0]);
+ const auto Z = mex_get_num(prhs[1]);
+ const auto rms_3d = mex_get_num(prhs[2]);
+ const auto occ = mex_get_num(prhs[3]);
+ const auto tag = mex_get_num(prhs[4]);
+ const auto bs = mex_get_r_3d(prhs[5]);
+ const auto d_min = mex_get_num(prhs[6]);
+ const auto rho = mex_get_num(prhs[7]);
+ const auto spec_lay_typ = (nrhs>8)?mex_get_enum(prhs[8]):mt::eslp_top;
+ const dt_int32 seed = (nrhs>9)?mex_get_num(prhs[9]):300183;
+
+ /***************************************************************************************/
+ mt::Ptc_Atom atoms(patoms_i, {0, 0, 0}, false, true);
+
+ mt::R_3d r_0 = (mt::is_spec_lay_top(spec_lay_typ))?mt::R_3d(0, 0, atoms.z_lim.x-bs.z):mt::R_3d(0, 0, atoms.z_lim.y);
+ mt::Spec_Lay_Info spec_lay_info(bs, r_0, tag, spec_lay_typ);
+
+ mt::Amorp_Build amorp_build;
+ amorp_build(atoms, Z, rms_3d, occ, d_min, rho, seed, spec_lay_info);
+
+ auto patoms_o = mex_create_pVctr({atoms.size(), atoms.cols_used}, plhs[0]);
+ atoms.cpy_to_ptr(patoms_o.data(), atoms.size(), 0, atoms.cols_used);
+}
+
+void mexFunction(dt_int32 nlhs, mxArray* plhs[], dt_int32 nrhs, const mxArray* prhs[])
+{
+ MEX_RUN_FCN_FLOAT_OUT(mex_run, 0);
+}
\ No newline at end of file
diff --git a/mex_files_multem/ilc_amorp_spec.cpp b/mex_files_multem/ilc_amorp_spec.cpp
deleted file mode 100644
index 36bfc3c1..00000000
--- a/mex_files_multem/ilc_amorp_spec.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * This file is part of MULTEM.
- * Copyright 2015 Ivan Lobato
- *
- * MULTEM is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MULTEM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MULTEM. If not, see .
- */
-
-#include "types.cuh"
-#include "matlab_types.cuh"
-#include "atomic_data_mt.hpp"
-#include "amorp_spec.hpp"
-
-#include
-#include "matlab_mex.cuh"
-
-void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[ ])
-{
- auto l_x = mx_get_scalar(prhs[0]);
- auto l_y = mx_get_scalar(prhs[1]);
- auto l_z = mx_get_scalar(prhs[2]);
- auto r_min = mx_get_scalar(prhs[3]);
- auto Z = mx_get_scalar(prhs[4]);
- auto rms_3d = mx_get_scalar(prhs[5]);
- auto rho = mx_get_scalar(prhs[6]);
- int seed = (nrhs>7)?mx_get_scalar(prhs[7]):300183;
-
- /*******************************************************************/
- mt::Atom_Data atoms;
- atoms.l_x = l_x;
- atoms.l_y = l_y;
-
- atoms.amorp_lay_info.resize(1);
- atoms.amorp_lay_info[0].z_0 = 0;
- atoms.amorp_lay_info[0].z_e = l_z;
- atoms.amorp_lay_info[0].dz = 2.0;
- atoms.amorp_lay_info[0].type = mt::eALT_Bottom;
- atoms.amorp_lay_info[0].region = 0;
-
- mt::Amorp_Spec spec;
- spec.create(atoms, r_min, Z, rms_3d, rho, seed);
-
- auto atomsM = mx_create_matrix(spec.m_atoms.size(), 8, plhs[0]);
- for(auto idx = 0; idx
- *
- * MULTEM is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MULTEM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MULTEM. If not, see .
- */
-
-#include "types.cuh"
-#include "matlab_types.cuh"
-#include "traits.cuh"
-#include "stream.cuh"
-#include "fft.cuh"
-#include "input_multislice.cuh"
-#include "output_multislice.hpp"
-
-#include "microscope_effects.cuh"
-
-#include
-#include "matlab_mex.cuh"
-
-using mt::rmatrix_r;
-using mt::rmatrix_c;
-
-template
-void read_input_multislice(const mxArray *mx_input_multislice, TInput_Multislice &input_multislice, bool full = true)
-{
- using T_r = mt::Value_type;
-
- /************************ simulation type **************************/
- input_multislice.simulation_type = mt::eTEMST_PropRS;
-
- /**************************** Specimen *****************************/
- auto lx = mx_get_scalar_field(mx_input_multislice, "spec_lx");
- auto ly = mx_get_scalar_field(mx_input_multislice, "spec_ly");
- T_r lz = 0;
- T_r dz = 0.25;
- bool pbc_xy = true;
-
- /************************** xy sampling ****************************/
- auto nx = mx_get_scalar_field(mx_input_multislice, "nx");
- auto ny = mx_get_scalar_field(mx_input_multislice, "ny");
- bool bwl = false;
-
- input_multislice.grid_2d.set_input_data(nx, ny, lx, ly, dz, bwl, pbc_xy);
-
- /************************ Incident wave ****************************/
- auto iw_type = mx_get_scalar_field(mx_input_multislice, "iw_type");
- input_multislice.set_incident_wave_type(iw_type);
-
- if (input_multislice.is_user_define_wave() && full)
- {
- auto iw_psi = mx_get_matrix_field(mx_input_multislice, "iw_psi");
- mt::assign(iw_psi, input_multislice.iw_psi);
- }
-
- // read iw_x and iw_y
- auto iw_x = mx_get_matrix_field(mx_input_multislice, "iw_x");
- auto iw_y = mx_get_matrix_field(mx_input_multislice, "iw_y");
-
- int n_iw_xy = min(iw_x.size(), iw_y.size());
- input_multislice.iw_x.assign(iw_x.begin(), iw_x.begin() + n_iw_xy);
- input_multislice.iw_y.assign(iw_y.begin(), iw_y.begin() + n_iw_xy);
-
- /********************* Microscope parameter ***********************/
- input_multislice.E_0 = mx_get_scalar_field(mx_input_multislice, "E_0");
- input_multislice.theta = mx_get_scalar_field(mx_input_multislice, "theta")*mt::c_deg_2_rad;
- input_multislice.phi = mx_get_scalar_field(mx_input_multislice, "phi")*mt::c_deg_2_rad;
-
- /********************* Illumination model *************************/
- input_multislice.illumination_model = mx_get_scalar_field(mx_input_multislice, "illumination_model");
- input_multislice.temporal_spatial_incoh = mx_get_scalar_field(mx_input_multislice, "temporal_spatial_incoh");
-
- /********************* source spread function *********************/
- // input_multislice.cond_lens.si_sigma = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_sigma"); // standard deviation: For parallel ilumination(�^-1); otherwise (�)
- // input_multislice.cond_lens.si_rad_npts = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_rad_npts"); // # of integration points
- /********************* defocus spread function ********************/
- input_multislice.cond_lens.ti_a = mx_get_scalar_field(mx_input_multislice, "cond_lens_ti_a"); // Height proportion of a normalized Gaussian [0, 1]
- input_multislice.cond_lens.ti_sigma = mx_get_scalar_field(mx_input_multislice, "cond_lens_ti_sigma"); // Standard deviation of the source spread function for the Gaussian component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.cond_lens.ti_beta = mx_get_scalar_field(mx_input_multislice, "cond_lens_ti_beta"); // Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.cond_lens.ti_npts = mx_get_scalar_field(mx_input_multislice, "cond_lens_ti_npts"); // Number of integration points
-
- /********************* source spread function *********************/
- input_multislice.cond_lens.si_a = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_a"); // Height proportion of a normalized Gaussian [0, 1]
- input_multislice.cond_lens.si_sigma = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_sigma"); // Standard deviation of the source spread function for the Gaussian component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.cond_lens.si_beta = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_beta"); // Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.cond_lens.si_rad_npts = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_rad_npts"); // Number of radial integration points
- input_multislice.cond_lens.si_azm_npts = mx_get_scalar_field(mx_input_multislice, "cond_lens_si_azm_npts");
-
- input_multislice.cond_lens.set_input_data(input_multislice.E_0, input_multislice.grid_2d);
-
- /*********************** Objective lens ***************************/
- input_multislice.obj_lens.m = mx_get_scalar_field(mx_input_multislice, "obj_lens_m"); // momentum of the vortex
- input_multislice.obj_lens.c_10 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_10"); // defocus (Angstrom)
- input_multislice.obj_lens.c_12 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_12"); // 2-fold astigmatism (Angstrom)
- input_multislice.obj_lens.phi_12 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_12")*mt::c_deg_2_rad; // Azimuthal angle of 2-fold astigmatism (degrees-->rad)
-
- input_multislice.obj_lens.c_21 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_21"); // Axial coma (Angstrom)
- input_multislice.obj_lens.phi_21 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_21")*mt::c_deg_2_rad; // Azimuthal angle of axial coma (degrees-->rad)
- input_multislice.obj_lens.c_23 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_23"); // 3-fold astigmatism (Angstrom)
- input_multislice.obj_lens.phi_23 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_23")*mt::c_deg_2_rad; // Azimuthal angle of 3-fold astigmatism (degrees-->rad)
-
- input_multislice.obj_lens.c_30 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_30")*mt::c_mm_2_Angs; // 3rd order spherical aberration (mm-->Angstrom)
- input_multislice.obj_lens.c_32 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_32"); // Axial star aberration (Angstrom)
- input_multislice.obj_lens.phi_32 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_32")*mt::c_deg_2_rad; // Azimuthal angle of axial star aberration (degrees-->rad)
- input_multislice.obj_lens.c_34 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_34"); // 4-fold astigmatism (Angstrom)
- input_multislice.obj_lens.phi_34 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_34")*mt::c_deg_2_rad; // Azimuthal angle of 4-fold astigmatism (degrees-->rad)
-
- input_multislice.obj_lens.c_41 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_41"); // 4th order axial coma (Angstrom)
- input_multislice.obj_lens.phi_41 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_41")*mt::c_deg_2_rad; // Azimuthal angle of 4th order axial coma (degrees-->rad)
- input_multislice.obj_lens.c_43 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_43"); // 3-lobe aberration (Angstrom)
- input_multislice.obj_lens.phi_43 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_43")*mt::c_deg_2_rad; // Azimuthal angle of 3-lobe aberration (degrees-->rad)
- input_multislice.obj_lens.c_45 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_45"); // 5-fold astigmatism (Angstrom)
- input_multislice.obj_lens.phi_45 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_45")*mt::c_deg_2_rad; // Azimuthal angle of 5-fold astigmatism (degrees-->rad)
-
- input_multislice.obj_lens.c_50 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_50")*mt::c_mm_2_Angs; // 5th order spherical aberration (mm-->Angstrom)
- input_multislice.obj_lens.c_52 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_52"); // 5th order axial star aberration (Angstrom)
- input_multislice.obj_lens.phi_52 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_52")*mt::c_deg_2_rad; // Azimuthal angle of 5th order axial star aberration (degrees-->rad)
- input_multislice.obj_lens.c_54 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_54"); // 5th order rosette aberration (Angstrom)
- input_multislice.obj_lens.phi_54 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_54")*mt::c_deg_2_rad; // Azimuthal angle of 5th order rosette aberration(degrees-->rad)
- input_multislice.obj_lens.c_56 = mx_get_scalar_field(mx_input_multislice, "obj_lens_c_56"); // 6-fold astigmatism (Angstrom)
- input_multislice.obj_lens.phi_56 = mx_get_scalar_field(mx_input_multislice, "obj_lens_phi_56")*mt::c_deg_2_rad; // Azimuthal angle of 6-fold astigmatism (degrees-->rad)
-
- input_multislice.obj_lens.inner_aper_ang = mx_get_scalar_field(mx_input_multislice, "obj_lens_inner_aper_ang")*mt::c_mrad_2_rad; // inner aperture (mrad-->rad)
- input_multislice.obj_lens.outer_aper_ang = mx_get_scalar_field(mx_input_multislice, "obj_lens_outer_aper_ang")*mt::c_mrad_2_rad; // outer aperture (mrad-->rad)
-
- /********************* defocus spread function ********************/
- input_multislice.obj_lens.ti_a = mx_get_scalar_field(mx_input_multislice, "obj_lens_ti_a"); // Height proportion of a normalized Gaussian [0, 1]
- input_multislice.obj_lens.ti_sigma = mx_get_scalar_field(mx_input_multislice, "obj_lens_ti_sigma"); // Standard deviation of the source spread function for the Gaussian component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.obj_lens.ti_beta = mx_get_scalar_field(mx_input_multislice, "obj_lens_ti_beta"); // Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.obj_lens.ti_npts = mx_get_scalar_field(mx_input_multislice, "obj_lens_ti_npts"); // Number of integration points
-
- /********************* source spread function *********************/
- input_multislice.obj_lens.si_a = mx_get_scalar_field(mx_input_multislice, "obj_lens_si_a"); // Height proportion of a normalized Gaussian [0, 1]
- input_multislice.obj_lens.si_sigma = mx_get_scalar_field(mx_input_multislice, "obj_lens_si_sigma"); // Standard deviation of the source spread function for the Gaussian component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.obj_lens.si_beta = mx_get_scalar_field(mx_input_multislice, "obj_lens_si_beta"); // Standard deviation of the source spread function for the Exponential component: For parallel ilumination(�^-1); otherwise (�)
- input_multislice.obj_lens.si_rad_npts = mx_get_scalar_field(mx_input_multislice, "obj_lens_si_rad_npts"); // Number of radial integration points
- input_multislice.obj_lens.si_azm_npts = mx_get_scalar_field(mx_input_multislice, "obj_lens_si_azm_npts"); // Number of azimuth integration points
-
- /********************* zero defocus reference ********************/
- input_multislice.obj_lens.zero_defocus_type = mx_get_scalar_field(mx_input_multislice, "obj_lens_zero_defocus_type"); // Zero defocus type
- input_multislice.obj_lens.zero_defocus_plane = mx_get_scalar_field(mx_input_multislice, "obj_lens_zero_defocus_plane"); // Zero defocus position
-
- input_multislice.obj_lens.set_input_data(input_multislice.E_0, input_multislice.grid_2d);
-
- /********************* select output region *************************/
- input_multislice.output_area.ix_0 = mx_get_scalar_field(mx_input_multislice, "output_area_ix_0")-1;
- input_multislice.output_area.iy_0 = mx_get_scalar_field(mx_input_multislice, "output_area_iy_0")-1;
- input_multislice.output_area.ix_e = mx_get_scalar_field(mx_input_multislice, "output_area_ix_e")-1;
- input_multislice.output_area.iy_e = mx_get_scalar_field(mx_input_multislice, "output_area_iy_e")-1;
-
- /********************* validate parameters *************************/
- input_multislice.validate_parameters();
-}
-
-template