Open a new terminal and move to the folder you want to download this code, conducting:
git clone https://github.com/zhenyuwei99/Lammps_Toolbox.git
sudo matlab
git clone https://github.com/zhenyuwei99/Lammps_Toolbox.git
In Matlab:
pathtool
Using Adding Folder to add 'Data_Analysis' and 'Str_Generation' folders.
Now you can use all of functions.
Matlab functions which can analysis LAMMPS data and generate LAMMPS data file.
LammpsStrCellCoord function is used to generate coordinates of cells. This function should be used before any other manipulations about modeling.
- cell_vec is a 3-D vector represents the # of cells in each direction
Example
cell_vec = [10 10 10];
data_cell = LammpsStrCellCoord(cell_vec);
LammpsStrSelectCell function is used to choose a specific range of cells and generate a structure containing all the information of those cells for further manipulations;
- data_cell is a structure generated by function LammpsStrCellCoord
- select_mode is a string determining which kind of region will be selected. Currently supported mode: 'cylinder'.
- select_arg is a string containing all args that needed to determining the region chosen before.
- cylinder: # of args: 2. (1) radius of cylinder; (2) direction of axis of cylinder.
Example
% Assuming data_cell has been generated before
select_mode = 'cylinder';
select_arg = '2 z'
data_cell_selected = LammpsStrSelectCell(data_cell,select_mode,select_arg);
LammpsStrDeleteCell function is used to deleted cell points in 'data_cell' determining by 'data_cell_selected' and will return a structure which have exactly the same formation as 'data_cell'.
- data_cell: structure generated by function LammpsStrCellCoord
- data_cell_selected: structure generated by function LammpsStrSelectCell
LammpsStrGenerate(data_cell,structure,lattice_const,atom_type,atom_charge) or LammpsStrGenerate(data_cell,structure,pbc)
LammpsStrGenerate is used to generate a structure variable containing all information needed to write a .data file. Two types of command are supported, one for models with specific structure but no specific elements BCC FCC etc, another for models with both specific elements and structure like Si3N4.
- data_cell is a structure which contains information of cells and creates by function LammpsStrCellCoord.
- structure is a char (case insensitive) of which structure will be used. Supporting list:
- Type 1: SC BCC FCC DC
- Type 2: Si3N4 TIP3P SPC SPCE
- Type1:
- lattice_const is lattice constance of structure.
- atom_type could be in three types:
- Case 1 : atom_type = 1, all atom will be set to type 1;
- Case 2 : atom_type = 2, each atom in cell will get an unique type
- Case 3 : atom_type is matrix. each of atom will be set to type correspond number in matrix. Matrix length should be equal to # of atoms in cell strictly.
- atom_charge is the charge of atoms, also obey the rules of atom_type.
- Case 1 : atom_charge = 0; All atom charge will be set to 0.
- Case 2 : atom_charge single number. All atom will be set to the same charge.
- Case 3 : atom_charge is a matrix. Each atom will be set to a charge correspond number in matrix. Same as Case 3 of atom_type, length of matrix should be equal to # of atoms in cell
- Type2
- pbc: determining which boundary will be applied with PBC condition for bonds definitions.
Example(1)
structure = 'bcc';
cell_vec = [8,10,5];
data_cell = LammpsStrCellCoord(cell_vec);
lattice_const = 1;
atom_type = 1;
atom_charge = 0;
data = LammpsStrGenerate(data_cell,structure,lattice_const,atom_type,atom_charge);
Example(2)
structure = 'si3n4';
cell_vec = [4 4 3];
data_cell = LammpsStrCellCoord(structure,cell_vec);
data = LammpsStrGenerate(data_cell,structure,['x y']);
LammpsStrSC, LammpsStrBCC, LammpsStrFCC, LammpsStrDC,LammpsStrSI3N4,LammpsStrSI3N4_ORT,LammpsStrTIP3P,LammpsStrTIP3P_HEX_SI3N4,LammpsStrSPC,LammpsStrSPCE
All above functions will be called by LammpsStrGenerate function to create structure 'data' corresponding to variable 'struture' in LammpsStrGenerate.
LammpsStrSelectAtom function is used choose a specific range of atoms and generate a structure containing all the information of those atoms for further manipulations;
- data: structure generated by function LammpsStrGenerate
- select_mode is a string determining which kind of region will be selected. Currently supported mode: 'cylinder'.
- select_arg is a string containing all args that needed to determining the region chosen before.
- cylinder: # of args: 2. (1) radius of cylinder; (2) direction of axis of cylinder.
Example
% Assuming data has been generated before
select_mode = 'cylinder';
select_arg = '2 z'
data_atom_selected = LammpsStrSelectAtom(data,select_mode,select_arg);
LammpsStrDeleteCell function is used to deleted atom points in 'data' determining by 'data_atom_selected' and will return a structure which have exactly the same formation as 'data', could be used in LammpsStrWrite.
- data: structure generated by function LammpsStrGenerate
- data_atom_selected: structure generated by function LammpsStrSelectAtom
LammpsStrMove function is used to move both the box and atoms uniformly with a 3-d vector.
- data: structure generated by function LammpsStrGenerate
- move_vec: a 3-d vector determing a uniform movements of box and atoms coordinates.
Example
% Assuming data has been generated before
move_vec = [3 3 3];
data = LammpsStrMove(data,move_vec);
- data: structure generated by function LammpsStrGenerate
- conc: concentration of solution, Unit: mol/L
- ion_type: string of type of co- and counter- ion.
Example
% Assuming data has been generated before
conc = 0.5;
ion_type = 'k cl'; % Space is needed for identification
data = LammpsStrAddIons(data,conc,ion_type);
LammpsStrCat function is used to concatenate different 'data' structure generated by LammpsStrGenerate and a structure containing all information needed to write '.data' file will be returned.
Example
% A Silicon-Nitride plane with a 5 Angstrom nanopore and TIP3P water molecules will be generated with this file
data_cell_si3n4 = LammpsStrCellCoord([6 5 3]);
data_cell_wat = LammpsStrCellCoord([10 9 10]);
data_si3n4 = LammpsStrGenerate(data_cell_si3n4,'si3n4','x y');
data_si3n4_selected = LammpsStrSelectAtom(data_si3n4,'cylinder','5 z');
data_si3n4 = LammpsStrDeleteAtom(data_si3n4,data_si3n4_selected);
data_wat_up = LammpsStrGenerate(data_cell_wat,'tip3p');
data_wat_up = LammpsStrMove(data_wat_up,[15 4 9]);
data_wat_low = LammpsStrGenerate(data_cell_wat,'tip3p');
data_wat_low = LammpsStrMove(data_wat_low,[15 4 -2]);
data_sum = LammpsStrCat(data_wat_up,data_wat_low,data_si3n4);
LammpsStrWrite(data_sum,'test.data');
- data is the structure generated by LammpsStrGenerate.
- name_output is the name of .data file that you will write. Example
% Assuming data has been generated before
name_output = 'test.dump';
LammpsStrWrite(data,name_output);
LammpsDataReadDump function is the core function in Data_Analysis module. A structure contaning all information in dump file will be generated and used in the other function for further analysis. In other words, this function should be runned before any other utilization of other functions.
Example
dump_name = 'example.dump';
dump_prop = ['id type coord vel'];
dump_col = [1 2 3 6];
t_sim = 5; % Unit: time unit;
data = LammpsDataReadDump(dump_name,dump_prop,dump_col,t_sim);
Notice: martix 'coord' should be contained in output structure variable. Or the name of coordinate data in dump_prop should be 'coord' (saying annotation in LammpsDataReadDump.m for further information)
LammpsDataReadLog function is used to read the data in log function.
Example
log_name = 'log.lammps';
log_prop = ['step temp press etotal vol'];
data_log = LammpsDataReadLog(log_name,log_prop);
Notice: Squeeze of log_prop should be follow the order in log file strictly.
LammpsDataConstans function is used to generate a structure which contains many useful constants and unit converters in data anlysis of MD simulation.
LammpsDataPBC function is used to handle Periodic Boundary Condition (PBC) issues. Coordinate file will be unwarpped if PBC is used in MD simulation;
LammpsDataMSD function is used to calculate Mean Square Displacement (MSD).
LammpsDataDiffusion function is used to calculate diffusion coefficients
- alpha is ratio of simulation time to maximum MSD interval.
LammpsDataRDF function is used to calculate Radial Distribution Function (RDF).
- data_01 and data_02 are structure of atom_01, atom_02 generated by LammpsDataReadDump, respectively.
- r_cut is the cut off radius in RDF calculation
- num_bins is the number of bins between 0 to r_cut.
- mass is the mass of atom in data structure
LammpsDataPhysicalProp function is used to calculate physical properties in MD simulation.
Current supported properties:
- Momentum
- E_kine
- Temp
- Density
LammpsDataCoord2Scl function is used to calculate scaled coordinates from raw coordinates.
LammpsDataScl2Coord function is used to calculate coordinates from scaled coordinates.
LammpsDataNeighborList function is used to construct Neighbor List of each atoms in each dump steps.
- r_cut is the cut off radius for Neighbor List construction.