Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions docs/analysis/atom_density.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ Next, we move to the analysis of water density at interfaces.
To perform the water density analysis, the indices of oxygen atoms between two interfaces are need to be specified, as shown in the `O_idx` of the above figure. Again, you can find the indices using the method `find_idx_from_range`, and put these indices (`List`) in the `inp_dict["density_type"]["idx_list"]`. Here, the `density_unit` should be set to `"water"` because the coordinates of oxygen atoms are treated as the positions of water molecules and are converted to water density through unit conversion.

## Usage
Now, we import the analysis class `AtomDensity` and gather the following mentioned parameters.
Now, we import the analysis class `AtomDensity` and gather the above mentioned parameters into a dictionary `inp`. Because the `AtomDensity` class is based on the `AnalysisBase` class from the MDAnalysis package, an `Universe` object is necessary to use the class.
We recommend that users instantiate an `Universe` object by themselves as follows. The dictionary `inp` is not required.
```python
from ectoolkits.analysis.atom_density import AtomDensity

# from
inp_dict={
# The following input
inp={
"xyz_file": "./Hematite-pos-1.xyz", # the path to the xyz trajecotry.
"format": "XYZ", # could be other formats for trajectories. Please refer to MDAnalysis
# https://userguide.mdanalysis.org/stable/formats/index.html#id1
"cell": [10.0564, 8.7091, 38.506, 90, 90, 90], # the cell parameters
"surf2": [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43], # the interface on the right
"surf1": [112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 12], # the interface on the left
Expand All @@ -74,9 +77,22 @@ inp_dict={
]
}

ad = AtomDensity(inp_dict)
xyz_file = inp.get("xyz_file")
fmt = inp.get("format", "XYZ")
cell = inp.get("cell")
cell = Cell.new(cell)
u = Universe(xyz_file, format=fmt)
u.atoms.dimensions = cell.cellpar()
surf1 = inp.get("surf1")
surf2 = inp.get("surf2")
density_type = inp.get("density_type")
ad = AtomDensity(atomgroup=u.atoms,
surf1=surf1,
surf2=surf2,
density_type=density_type)
ad.run()


# detail information is accessible in
ad.atom_density
ad.atom_density_z
Expand All @@ -90,4 +106,40 @@ all_cent_density = ad.get_ave_density(width_list)
ad.plot_density(sym=False)

```
![density](./figures/density.png)
![density](./figures/density.png)




## Old inputs
For users using the following old input. We recommend use the function `run_atom_density_analysis` to parse the input. The usage is present as follows:
```python
from ectoolkits.analysis.atom_density import run_atom_density_analysis

# from
inp_dict={
"xyz_file": "./Hematite-pos-1.xyz", # the path to the xyz trajecotry.
"cell": [10.0564, 8.7091, 38.506, 90, 90, 90], # the cell parameters
"surf2": [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43], # the interface on the right
"surf1": [112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 12], # the interface on the left
"density_type":[
{
"element": "O",
"idx_method": "manual",
"idx_list": O_idx,
"density_unit": "water",
"dz": 0.05,
"name": "O_density"
},
{
"element": "H",
"idx_method": "manual",
"idx_list": H_idx,
"density_unit": "water",
"dz": 0.05,
"name": "H_density"
}
]
}

ad = run_atom_density_analysis(input_dict)
Loading