Skip to content

Commit

Permalink
update 17/10/2023 morning
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivanlh20 committed Oct 17, 2023
1 parent 18ae0bf commit 537ff34
Show file tree
Hide file tree
Showing 621 changed files with 218,132 additions and 67,432 deletions.
471 changes: 435 additions & 36 deletions .gitignore
100644 → 100755

Large diffs are not rendered by default.

1,346 changes: 673 additions & 673 deletions LICENSE.txt
100644 → 100755

Large diffs are not rendered by default.

215 changes: 108 additions & 107 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 ([email protected]), 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 ([email protected]).

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}
}
```
108 changes: 65 additions & 43 deletions compile_mex_multem.m
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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
Empty file modified crystalline_materials/Ag001_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Ag110_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Al001_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Al110_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Au001_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Au110_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Cu001_xtl.m
100644 → 100755
Empty file.
Empty file modified crystalline_materials/Cu110_xtl.m
100644 → 100755
Empty file.
38 changes: 26 additions & 12 deletions crystalline_materials/Diamond110_xtl.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 537ff34

Please sign in to comment.