ectoolkits.analysis.atom_density module#

class ectoolkits.analysis.atom_density.AtomDensity(atomgroup, verbose=True, **kwargs)[source]#

Bases: AnalysisBase

Class for analyzing atom density profiles along the z-axis for interface systems.

This class extends the MDAnalysis AnalysisBase class and provides methods to compute and analyze atom density distributions along the z-axis, which is useful for studying interfaces and layered materials.

twoD#

Whether the system is a 2D material (surface 1 and 2 are the same).

Type:

bool

surf1#

Indices of atoms defining surface 1 (left interface).

Type:

np.ndarray

surf2#

Indices of atoms defining surface 2 (right interface).

Type:

np.ndarray

density_type#

Parameters specifying which atom types to analyze.

Type:

Any

ag#

AtomGroup of all atoms to be analyzed.

Type:

AtomGroup

u#

The MDAnalysis Universe object containing the atomgroup and trajectory.

Type:

Universe

cellpar#

Unit cell parameters of the system.

Type:

np.ndarray

n_atoms#

Number of atoms in the selected atom group.

Type:

int

volume#

Volume of the simulation cell.

Type:

float

xy_area#

Area of the xy-plane of the simulation cell.

Type:

float

n_results#

Number of results to store for each frame.

Type:

int

all_z#

Array to store z-coordinates of all atoms for each frame.

Type:

np.ndarray

surf1_z_list#

Average z positions of surface 1 atoms for each frame.

Type:

np.ndarray

surf2_z_list#

Average z positions of surface 2 atoms for each frame.

Type:

np.ndarray

surf1_z#

Mean z position of surface 1.

Type:

float

surf2_z#

Mean z position of surface 2.

Type:

float

water_cent_list#

List of water center positions along the trajectory.

Type:

np.ndarray

atom_density#

Dictionary to store computed atom density profiles.

Type:

dict

atom_density_z#

Dictionary to store z-coordinates corresponding to density profiles.

Type:

dict

_prepare()[source]#

Prepares data structures before trajectory iteration.

_single_frame()[source]#

Processes a single frame to extract z-coordinates.

_conclude()[source]#

Finalizes the analysis and computes density profiles.

get_surf_z_list(idxs_surf)[source]#

Calculates average z positions for a given surface.

get_water_cent_list()[source]#

Computes the water center positions along the trajectory.

get_idx_list(param)[source]#

Determines atom indices to analyze based on input parameters.

get_idx_list_manual(param)[source]#

Returns manually specified atom indices.

get_idx_list_all(param)[source]#

Returns all atom indices of a specified element.

get_atom_density(param, idx_list)[source]#

Calculates and saves the atom density profile.

get_unit_conversion(density_unit, dz, xy_area)[source]#

Computes the unit conversion factor for density.

get_atom_density(param, idx_list)[source]#

Calculate and save the atom density profile.

Computes the histogram of atom z-coordinates, normalizes the density, and saves the profile to a file.

Parameters:
  • param (dict) – Parameters for density calculation (e.g., bin width, unit).

  • idx_list (list or np.array) – Indices of atoms to include in the density profile.

get_ave_density(width_list)[source]#
get_idx_list(param)[source]#

Determine atom indices to analyze based on input parameters.

Selects indices either manually or by element type as specified in the parameter dictionary.

Parameters:

param (dict) – Dictionary specifying selection method and parameters.

Returns:

List of atom indices to analyze.

Return type:

list or np.array

get_idx_list_all(param)[source]#

Return all atom indices of a specified element.

Parameters:

param (dict) – Dictionary containing ‘element’.

Returns:

Array of atom indices for the specified element.

Return type:

np.array

get_idx_list_manual(param)[source]#

Return manually specified atom indices.

Parameters:

param (dict) – Dictionary containing ‘idx_list’.

Returns:

List of atom indices.

Return type:

list

get_surf_z_list(idxs_surf: array) array[source]#

Calculate the average z positions for a given surface.

Wraps the z-coordinates of surface atoms to handle periodic boundaries and computes the mean z position for each frame.

Parameters:

idxs_surf (np.array) – Indices of surface atoms.

Returns:

Average z positions for each frame.

Return type:

np.array

static get_unit_conversion(density_unit, dz, xy_area)[source]#

Compute the unit conversion factor for density.

Parameters:
  • density_unit (str) – Desired density unit (‘water’ or ‘number’).

  • dz (float) – Bin width along z-axis.

  • xy_area (float) – Area of the xy-plane.

Returns:

Conversion factor for density normalization.

Return type:

float

get_water_cent_list() array[source]#

Compute the water center positions along the trajectory.

Calculates the midpoint between the two surfaces for each frame.

Returns:

Water center positions for each frame.

Return type:

np.array

plot_density(sym=False)[source]#
class ectoolkits.analysis.atom_density.Density(inp)[source]#

Bases: object

get_all_z() array[source]#

get the z coordinates of atoms along trajectory

_extended_summary_

Returns:

the z coordinates of atoms

Return type:

np.array

get_atom_density(param, idx_list)[source]#
get_ave_density(width_list)[source]#
get_idx_list(param)[source]#
get_idx_list_all(param)[source]#
get_idx_list_manual(param)[source]#
get_surf1_z_list() array[source]#

calculate the surface 1 average position

_extended_summary_

Returns:

axis 0: traj

Return type:

np.array

get_surf2_z_list() array[source]#

calculate the surface 2 average position

_extended_summary_

Returns:

axis 0: traj

Return type:

np.array

get_unit_conversion(param, dz)[source]#
get_water_cent_list() array[source]#
plot_density(sym=False)[source]#
run()[source]#
water_O_idx()[source]#
ectoolkits.analysis.atom_density.analysis_run(args)[source]#
ectoolkits.analysis.atom_density.run_atom_density_analysis(inp)[source]#