Ivanlh20 / multem

MULTEM is a powerful and advanced collection of C++ routines with CUDA support, designed to perform efficient and accurate multislice simulations for various TEM experiments such as HRTEM, STEM, ISTEM, ED, PED, CBED, ADF-TEM, ABF-HC, EFTEM, and EELS.
GNU General Public License v3.0
65 stars 26 forks source link

Change input structure to class #43

Closed ThFriedrich closed 3 years ago

ThFriedrich commented 4 years ago

Changing the multem_input structure from a struct to a class object allows for validation of input parameters for type, value, and size. The class will only accept predefined properties and will throw errors when using wrong/deprecated parameters (e.g. from legacy scripts). All examples were updated accordingly.

Using

% The object is intialized by calling:
input_multem = multem_input.parameters;

% The former system_conf struct is now also a class objected, nested in the multem_input class:
input_multem.system_conf.precision = 1;                           
input_multem.system_conf.device = 2;
input_multem.system_conf.cpu_nthread = 1;
input_multem.system_conf.gpu_device = 0;
% All other assignments remain as they were

Documentation

The class implementation further provides a convenient way for minimalistic documentation of the input structure and its properties.

doc multem_input.parameters

image

Nested Classes & Functions

Classes are defined also for the detector and system_conf structures. The class multem_input has a function toStruct which returns a struct-representation of the class. ilc_multem and other functions have been added to the class, so these functions can just be executed on the input object. e.g:

output_multislice = input_multem.ilc_multem;