Visualize Atoms

This script will use mdapy (>=0.9.7) to visualize the 3D atoms model.

One should install k3d first. Try pip install k3d

[1]:
import mdapy as mp
import numpy as np
mp.init()
[Taichi] version 1.6.0, llvm 15.0.1, commit f1c6fbbd, win, python 3.8.0
[Taichi] Starting on arch=x64
[2]:
mp.__version__
[2]:
'0.9.9'

Build a polycrystalline as an example

[3]:
box = np.array([[0, 300.], [0, 100.], [0, 100]])
poly = mp.CreatePolycrystalline(box, 10, 3.615, 'FCC', randomseed=1, add_graphene=True)
poly.compute(save_dump=False)
Generating voronoi polygon...
Total grain number: 10
Generating grain 0..., volume is 359876.8004347251
Generating grain 1..., volume is 242724.44580869132
Generating grain 2..., volume is 249964.4459555453
Generating grain 3..., volume is 369284.89050798607
Generating grain 4..., volume is 223787.45956148254
Generating grain 5..., volume is 484387.8052467707
Generating grain 6..., volume is 145878.18345785938
Generating grain 7..., volume is 295809.66197816597
Generating grain 8..., volume is 445619.6401283492
Generating grain 9..., volume is 182666.6669204249
Wraping atoms into box...
Deleting overlap atoms...
Total atom numbers: 240353, average grain size: 300000.00000000006 A^3
Time costs: 3.4147725105285645 s.

Build a system

[4]:
system = mp.System(box = box, data=poly.data)
[5]:
system
[5]:
Filename: None
Atom Number: 240353
Simulation Box:
[[  0. 300.]
 [  0. 100.]
 [  0. 100.]]
TimeStep: 0
Boundary: [1, 1, 1]
Particle Information:
shape: (5, 6)
┌─────┬──────┬────────────┬───────────┬───────────┬─────────┐
│ id  ┆ type ┆ x          ┆ y         ┆ z         ┆ grainid │
│ --- ┆ ---  ┆ ---        ┆ ---       ┆ ---       ┆ ---     │
│ i32 ┆ i32  ┆ f32        ┆ f32       ┆ f32       ┆ i32     │
╞═════╪══════╪════════════╪═══════════╪═══════════╪═════════╡
│ 1   ┆ 1    ┆ 105.667709 ┆ 62.92952  ┆ 53.095554 ┆ 1       │
│ 2   ┆ 1    ┆ 103.898407 ┆ 66.064232 ┆ 53.429329 ┆ 1       │
│ 3   ┆ 1    ┆ 105.209488 ┆ 70.999443 ┆ 53.181995 ┆ 1       │
│ 4   ┆ 1    ┆ 104.553947 ┆ 68.531837 ┆ 53.30566  ┆ 1       │
│ 5   ┆ 1    ┆ 102.129112 ┆ 69.198936 ┆ 53.763103 ┆ 1       │
└─────┴──────┴────────────┴───────────┴───────────┴─────────┘

Display the configurations

[6]:
system.display()

Colored by the grain id

[7]:
system.atoms_colored_by('grainid')
[8]:
system.cal_polyhedral_template_matching(structure='fcc-hcp-bcc-graphene')

Colored by the structure type

[9]:
system.atoms_colored_by('structure_types')
[10]:
# Close the display
# system.view.close()