Atomic Structure Generation

[1]:
import mdapy as mp
import numpy as np
mp.__version__
[1]:
'1.0.5a2'

Build FCC Cu

[2]:
fcc = mp.build_crystal('Cu', 'fcc', 3.615, nx=3, ny=3, nz=3)

Build BCC Fe

[3]:
bcc = mp.build_crystal('Fe', 'bcc', 2.8, nx=3, ny=3, nz=3)

Build HCP Ti

[4]:
hcp = mp.build_crystal('Ti', 'hcp', 3.0, nx=2, ny=2, nz=2)
[5]:
hcp
[5]:
Atom Number: 16
Box information:
[[ 6.          0.          0.        ]
 [-3.          5.19615242  0.        ]
 [ 0.          0.          9.79795897]]
Origin: [0. 0. 0.]
Triclinic: True
Boundary: [1 1 1]
Particle Information:
shape: (16, 4)
┌────────────┬──────────┬──────────┬─────────┐
│ x          ┆ y        ┆ z        ┆ element │
│ ---        ┆ ---      ┆ ---      ┆ ---     │
│ f64        ┆ f64      ┆ f64      ┆ str     │
╞════════════╪══════════╪══════════╪═════════╡
│ 0.0        ┆ 0.0      ┆ 0.0      ┆ Ti      │
│ 5.5511e-17 ┆ 1.732051 ┆ 2.44949  ┆ Ti      │
│ 0.0        ┆ 0.0      ┆ 4.898979 ┆ Ti      │
│ 5.5511e-17 ┆ 1.732051 ┆ 7.348469 ┆ Ti      │
│ -1.5       ┆ 2.598076 ┆ 0.0      ┆ Ti      │
│ …          ┆ …        ┆ …        ┆ …       │
│ 3.0        ┆ 1.732051 ┆ 7.348469 ┆ Ti      │
│ 1.5        ┆ 2.598076 ┆ 0.0      ┆ Ti      │
│ 1.5        ┆ 4.330127 ┆ 2.44949  ┆ Ti      │
│ 1.5        ┆ 2.598076 ┆ 4.898979 ┆ Ti      │
│ 1.5        ┆ 4.330127 ┆ 7.348469 ┆ Ti      │
└────────────┴──────────┴──────────┴─────────┘
[6]:
hcp_ortho = mp.orthogonal_cell(hcp)
[7]:
hcp_ortho
[7]:
Atom Number: 32
Box information:
[[ 6.          0.          0.        ]
 [ 0.         10.39230485  0.        ]
 [ 0.          0.          9.79795897]]
Origin: [0. 0. 0.]
Triclinic: False
Boundary: [1 1 1]
Particle Information:
shape: (32, 4)
┌─────┬──────────┬──────────┬─────────┐
│ x   ┆ y        ┆ z        ┆ element │
│ --- ┆ ---      ┆ ---      ┆ ---     │
│ f64 ┆ f64      ┆ f64      ┆ str     │
╞═════╪══════════╪══════════╪═════════╡
│ 0.0 ┆ 0.0      ┆ 0.0      ┆ Ti      │
│ 0.0 ┆ 1.732051 ┆ 2.44949  ┆ Ti      │
│ 0.0 ┆ 0.0      ┆ 4.898979 ┆ Ti      │
│ 0.0 ┆ 1.732051 ┆ 7.348469 ┆ Ti      │
│ 3.0 ┆ 0.0      ┆ 0.0      ┆ Ti      │
│ …   ┆ …        ┆ …        ┆ …       │
│ 1.5 ┆ 9.526279 ┆ 7.348469 ┆ Ti      │
│ 4.5 ┆ 7.794229 ┆ 0.0      ┆ Ti      │
│ 4.5 ┆ 9.526279 ┆ 2.44949  ┆ Ti      │
│ 4.5 ┆ 7.794229 ┆ 4.898979 ┆ Ti      │
│ 4.5 ┆ 9.526279 ┆ 7.348469 ┆ Ti      │
└─────┴──────────┴──────────┴─────────┘

Build Cubic Diamond

[8]:
dia = mp.build_crystal('C', 'diamond', 3.0, nx=2, ny=2, nz=2)

Build Graphene layer

[9]:
gra = mp.build_crystal('C', 'graphene', 2.46, c=10, nx=2, ny=4, nz=1)
gra
[9]:
Atom Number: 16
Box information:
[[ 4.92        0.          0.        ]
 [-4.92        8.52168997  0.        ]
 [ 0.          0.         10.        ]]
Origin: [0. 0. 0.]
Triclinic: True
Boundary: [1 1 1]
Particle Information:
shape: (16, 4)
┌────────────┬──────────┬─────┬─────────┐
│ x          ┆ y        ┆ z   ┆ element │
│ ---        ┆ ---      ┆ --- ┆ ---     │
│ f64        ┆ f64      ┆ f64 ┆ str     │
╞════════════╪══════════╪═════╪═════════╡
│ 0.0        ┆ 0.0      ┆ 0.0 ┆ C       │
│ 8.5117e-18 ┆ 1.420282 ┆ 0.0 ┆ C       │
│ -1.23      ┆ 2.130422 ┆ 0.0 ┆ C       │
│ -1.23      ┆ 3.550704 ┆ 0.0 ┆ C       │
│ -2.46      ┆ 4.260845 ┆ 0.0 ┆ C       │
│ …          ┆ …        ┆ …   ┆ …       │
│ 1.23       ┆ 3.550704 ┆ 0.0 ┆ C       │
│ 0.0        ┆ 4.260845 ┆ 0.0 ┆ C       │
│ 8.5117e-18 ┆ 5.681127 ┆ 0.0 ┆ C       │
│ -1.23      ┆ 6.391267 ┆ 0.0 ┆ C       │
│ -1.23      ┆ 7.811549 ┆ 0.0 ┆ C       │
└────────────┴──────────┴─────┴─────────┘

Build structure with specific orientations

[10]:
aluminum = mp.build_crystal('Al', 'fcc', 3.615, nx=3, ny=3, nz=3, miller1=[1, 1, 2], miller2=[1, -1, 0], miller3=[1, 1, -1])
[11]:
aluminum
[11]:
Atom Number: 162
Box information:
[[13.28235813  0.          0.        ]
 [ 0.          7.66857304  0.        ]
 [ 0.          0.         18.78409101]]
Origin: [0. 0. 0.]
Triclinic: False
Boundary: [1 1 1]
Particle Information:
shape: (162, 4)
┌───────────┬──────────┬───────────┬─────────┐
│ x         ┆ y        ┆ z         ┆ element │
│ ---       ┆ ---      ┆ ---       ┆ ---     │
│ f64       ┆ f64      ┆ f64       ┆ str     │
╞═══════════╪══════════╪═══════════╪═════════╡
│ 0.0       ┆ 0.0      ┆ 0.0       ┆ Al      │
│ 1.475818  ┆ 0.0      ┆ 2.087121  ┆ Al      │
│ 2.213726  ┆ 1.278096 ┆ 0.0       ┆ Al      │
│ 2.951635  ┆ 0.0      ┆ 4.174242  ┆ Al      │
│ 3.689544  ┆ 1.278096 ┆ 2.087121  ┆ Al      │
│ …         ┆ …        ┆ …         ┆ …       │
│ 10.330723 ┆ 5.112382 ┆ 14.609849 ┆ Al      │
│ 11.068632 ┆ 6.390478 ┆ 12.522727 ┆ Al      │
│ 11.806541 ┆ 5.112382 ┆ 16.69697  ┆ Al      │
│ 12.544449 ┆ 6.390478 ┆ 14.609849 ┆ Al      │
│ 9.592814  ┆ 6.390478 ┆ 16.69697  ┆ Al      │
└───────────┴──────────┴───────────┴─────────┘

Build high-entropy alloy

[12]:
hea = mp.build_hea(['Cr', 'Co', 'Ni'], [0.5, 0.3, 0.2], 'fcc', 3.6, nx=10, ny=10, nz=10, random_seed=1)
[13]:
hea
[13]:
Atom Number: 4000
Box information:
[[36.  0.  0.]
 [ 0. 36.  0.]
 [ 0.  0. 36.]]
Origin: [0. 0. 0.]
Triclinic: False
Boundary: [1 1 1]
Particle Information:
shape: (4_000, 4)
┌──────┬──────┬──────┬─────────┐
│ x    ┆ y    ┆ z    ┆ element │
│ ---  ┆ ---  ┆ ---  ┆ ---     │
│ f64  ┆ f64  ┆ f64  ┆ str     │
╞══════╪══════╪══════╪═════════╡
│ 0.0  ┆ 0.0  ┆ 0.0  ┆ Cr      │
│ 1.8  ┆ 1.8  ┆ 0.0  ┆ Cr      │
│ 0.0  ┆ 1.8  ┆ 1.8  ┆ Cr      │
│ 1.8  ┆ 0.0  ┆ 1.8  ┆ Co      │
│ 0.0  ┆ 0.0  ┆ 3.6  ┆ Cr      │
│ …    ┆ …    ┆ …    ┆ …       │
│ 34.2 ┆ 32.4 ┆ 30.6 ┆ Ni      │
│ 32.4 ┆ 32.4 ┆ 32.4 ┆ Cr      │
│ 34.2 ┆ 34.2 ┆ 32.4 ┆ Ni      │
│ 32.4 ┆ 34.2 ┆ 34.2 ┆ Cr      │
│ 34.2 ┆ 32.4 ┆ 34.2 ┆ Cr      │
└──────┴──────┴──────┴─────────┘

Build polyscrystal

[14]:
unit = mp.build_crystal("Al", "fcc", 4.05)
poly = mp.CreatePolycrystal(unit, box=100, seed_number=5, randomseed=1, metal_overlap_dis=2.0)
system = poly.compute()
======================================================================
                    POLYCRYSTAL GENERATION
======================================================================
[1/5] Generating Voronoi tessellation...
  Number of grains: 5
  Average volume:    200000.00 A^3
  Volume range:      180820.01 - 251770.56  A^3
  Random seed:      1
[2/5] Generating atoms for 5 grains...
  Grain   1/5: Volume =  251770.56 A^3  Atoms =  15162
  Grain   2/5: Volume =  180820.01 A^3  Atoms =  10890
  Grain   3/5: Volume =  193528.01 A^3  Atoms =  11653
  Grain   4/5: Volume =  191668.31 A^3  Atoms =  11531
  Grain   5/5: Volume =  182213.11 A^3  Atoms =  10969
  Total atoms generated: 60,205
[3/5] Creating atomic structure...
[4/5] Removing overlapping atoms...
  Filtering: Metal-Metal overlaps
    Metal-Metal distance: 2.00 Å
  Atoms removed: 2,051 (3.41%)
  Atoms remaining: 58,154
[5/5] Finalizing structure...
======================================================================
 ✓ Polycrystal generation completed successfully!
 ✓ Execution time: 0.03 seconds
======================================================================

Build 2D polycrystal

[15]:
unit = mp.build_crystal("Al", "fcc", 4.05)
random_seed = 42
np.random.seed(random_seed)
box = np.array([[300, 0, 0], [0, 300, 0], [0, 0, unit.box.box[2, 2] * 12]])
seed_number = 10
box_lengths = np.diag(box)
seed_position = np.random.random((seed_number, 3)) * box_lengths
seed_position[:, 2] = box[2, 2] / 2
theta_list = np.random.uniform(-180, 180, (seed_number, 3))
theta_list[:, :2] = 0
poly = mp.CreatePolycrystal(
    unit,
    box=box,
    seed_number=seed_number,
    randomseed=random_seed,
    metal_overlap_dis=2.0,
    theta_list=theta_list,
    seed_position=seed_position,
)
system = poly.compute()
======================================================================
                    POLYCRYSTAL GENERATION
======================================================================
[1/5] Generating Voronoi tessellation...
  Number of grains: 10
  Average volume:    437400.00 A^3
  Volume range:      256714.65 - 797106.53  A^3
  Random seed:      42
[2/5] Generating atoms for 10 grains...
  Grain   1/10: Volume =  362972.67 A^3  Atoms =  21876
  Grain   2/10: Volume =  256714.65 A^3  Atoms =  15468
  Grain   3/10: Volume =  797106.53 A^3  Atoms =  47796
  Grain   4/10: Volume =  391536.22 A^3  Atoms =  23688
  Grain   5/10: Volume =  524456.68 A^3  Atoms =  31536
  Grain   6/10: Volume =  319233.38 A^3  Atoms =  19188
  Grain   7/10: Volume =  345779.30 A^3  Atoms =  20868
  Grain   8/10: Volume =  397379.07 A^3  Atoms =  23964
  Grain   9/10: Volume =  356555.71 A^3  Atoms =  21516
  Grain  10/10: Volume =  622265.80 A^3  Atoms =  37512
  Total atoms generated: 263,412
[3/5] Creating atomic structure...
[4/5] Removing overlapping atoms...
  Filtering: Metal-Metal overlaps
    Metal-Metal distance: 2.00 Å
  Atoms removed: 3,516 (1.33%)
  Atoms remaining: 259,896
[5/5] Finalizing structure...
======================================================================
 ✓ Polycrystal generation completed successfully!
 ✓ Execution time: 0.06 seconds
======================================================================

Build polycrystal with graphene grain boundary

[16]:
unit = mp.build_crystal("Al", "fcc", 4.05)
poly = mp.CreatePolycrystal(unit, box=100, seed_number=5, randomseed=1, metal_overlap_dis=2.0, add_graphene=True, metal_gra_overlap_dis=2.8)
system = poly.compute()
# system.write_xyz('gra_al.xyz')
======================================================================
                    POLYCRYSTAL GENERATION
======================================================================
[1/5] Generating Voronoi tessellation...
  Number of grains: 5
  Average volume:    200000.00 A^3
  Volume range:      180820.01 - 251770.56  A^3
  Graphene enabled: Yes (threshold = 0.0 A^2)
  Random seed:      1
[2/5] Generating atoms for 5 grains...
  Grain   1/5: Volume =  251770.56 A^3  Metal =  15162, Carbon =   8611
  Grain   2/5: Volume =  180820.01 A^3  Metal =  10890, Carbon =   7273
  Grain   3/5: Volume =  193528.01 A^3  Metal =  11653, Carbon =   7489
  Grain   4/5: Volume =  191668.31 A^3  Metal =  11531, Carbon =   7549
  Grain   5/5: Volume =  182213.11 A^3  Metal =  10969, Carbon =   7579
  Total atoms generated: 98,706
[3/5] Creating atomic structure...
[4/5] Removing overlapping atoms...
  Filtering: Metal-Metal, C-C, Metal-C overlaps
    Metal-Metal distance: 2.00 Å
    C-C distance:         1.40 Å
    Metal-C distance:     2.80 Å
  Atoms removed: 35,520 (35.99%)
  Atoms remaining: 63,186
[5/5] Finalizing structure...
======================================================================
 ✓ Polycrystal generation completed successfully!
 ✓ Execution time: 0.42 seconds
======================================================================