File: Be-solid.pl

package info (click to toggle)
lammps 20250204%2Bdfsg.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 474,368 kB
  • sloc: cpp: 1,060,070; python: 27,785; ansic: 8,956; f90: 7,254; sh: 6,044; perl: 4,171; fortran: 2,442; xml: 1,714; makefile: 1,352; objc: 238; lisp: 188; yacc: 58; csh: 16; awk: 14; tcl: 6; javascript: 2
file content (131 lines) | stat: -rwxr-xr-x 3,646 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/perl

# Usage: Be-solid.pl <nx> <ny> <nz> > data.Be
#
# Generates a beryllium solid LAMMPS data file.

$nx = shift(@ARGV);
$ny = shift(@ARGV);
$nz = shift(@ARGV);

$La = 4.592;  # eFF optimized (4.33 expt)
$Lc = 7.025;  # eFF optimized (6.78 expt)

# This part changes for different lattices
@xunit = (0, 0.5, 0, 0.5); 
@yunit = (0, 0.5, 0.5 * (4/3), (1/3) * 0.5);
@zunit = (0, 0, 0.5, 0.5);

$Lx = $La;
$Ly = $La * sqrt(3);
$Lz = $Lc;

$idx = 0;
for ($x = 0; $x < $nx; $x++)
{
  for ($y = 0; $y < $ny; $y++)
  {
    for ($z = 0; $z < $nz; $z++)
    {
      for ($i = 0; $i <= $#xunit; $i++)
      {
        $xnuc[$idx] = ($x + .25) * $Lx + $xunit[$i] * $Lx;
        $ynuc[$idx] = ($y + .25) * $Ly + $yunit[$i] * $Ly;
        $znuc[$idx] = ($z + .25) * $Lz + $zunit[$i] * $Lz;
        $idx++;
      } 
    }
  }
} 

$numnuc = $idx;

# Print length of supercell

printf("Created by Be-solid.pl\n\n");
printf("%d atoms\n",$numnuc+$numnuc*2+$numnuc*2);
printf("2 atom types\n\n");
printf("%f %f xlo xhi\n", 0, $Lx * $nx);
printf("%f %f ylo yhi\n", 0, $Ly * $ny);
printf("%f %f zlo zhi\n\n", 0, $Lz * $nz);
printf("Masses\n\n");
printf("1 9.012182\n");
printf("2 1.000000\n\n");
printf("Atoms\n\n");

$j=0;
# Print out the nuclei
for ($i = 0; $i < $numnuc; $i++)
{
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 1, 4.0, 0, 0.0, $xnuc[$i], $ynuc[$i], $znuc[$i]);
}

# Print out the core electrons
$r_core = 0.5;
for ($i = 0; $i < $numnuc; $i++)
{
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2,  0.0, 1, $r_core,$xnuc[$i], $ynuc[$i], $znuc[$i]);
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, -1, $r_core,$xnuc[$i], $ynuc[$i], $znuc[$i]);
}

# Print out the valence electrons
$r_valence = 2.5;
for ($i = 0; $i < $numnuc; $i += 4)
{
  $x = &BoundX($xnuc[$i] + $Lx / 2.0);
  $y = &BoundY($ynuc[$i] + $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, 1, $r_valence,$x, $y, $z);
  $x = &BoundX($xnuc[$i] + $Lx / 2.0);
  $y = &BoundY($ynuc[$i] + $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, -1, $r_valence,$x, $y, $z);

  $x = &BoundX($xnuc[$i+1] + $Lx / 2.0);
  $y = &BoundY($ynuc[$i+1] + $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i+1];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, 1, $r_valence, $x, $y, $z);
  $x = &BoundX($xnuc[$i+1] + $Lx / 2.0);
  $y = &BoundY($ynuc[$i+1] + $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i+1];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, -1, $r_valence,$x, $y, $z);

  $x = &BoundX($xnuc[$i+2] - $Lx / 2.0);
  $y = &BoundY($ynuc[$i+2] - $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i+2];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, 1, $r_valence,$x, $y, $z);
  $x = &BoundX($xnuc[$i+2] - $Lx / 2.0);
  $y = &BoundY($ynuc[$i+2] - $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i+2];
  printf("%i %i %f %f %f %f %f %f\n", $j+=1, 2, 0.0, -1, $r_valence,$x, $y, $z);

  $x = &BoundX($xnuc[$i+3] - $Lx / 2.0);
  $y = &BoundY($ynuc[$i+3] - $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i+3];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, 1, $r_valence, $x, $y, $z);
  $x = &BoundX($xnuc[$i+3] - $Lx / 2.0);
  $y = &BoundY($ynuc[$i+3] - $Lx / (2.0 * sqrt(3)));
  $z = $znuc[$i+3];
  printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, -1, $r_valence,$x, $y, $z);
}

sub BoundX {
  $x = $_[0];
  if ($x > $Lx * $nx) {$x -= $Lx * $nx;}
  if ($x < 0) {$x += $Lx * $nx;}
  return $x;
}

sub BoundY {
  $y = $_[0];
  if ($y > $Ly * $ny) {$y -= $Ly * $ny;}
  if ($y < 0) {$y += $Ly * $ny;}
  return $y;
}
  
sub BoundZ {
  $z = $_[0];
  if ($z > $Lz * $nz) {$z -= $Lz * $nz;}
  if ($z < 0) {$z += $Lz * $nz;}
  return $z;
}