Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F107419726
h2.pl
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Apr 8, 02:22
Size
1 KB
Mime Type
text/x-perl
Expires
Thu, Apr 10, 02:22 (23 h, 11 m)
Engine
blob
Format
Raw Data
Handle
25415557
Attached To
rLAMMPS lammps
h2.pl
View Options
#!/usr/bin/perl
# Usage: h2.pl <nx> <ny> <nz> <rs> > data.h2
#
# Generates rectangular lattice of hydrogen atoms, # in each direction = nx,
# with Wigner radius rs.
# ...
# Shifts H atoms in alternating directions so they form H2 molecule
# starting structures.
$nx = shift(@ARGV);
$ny = shift(@ARGV);
$nz = shift(@ARGV);
$rs = shift(@ARGV);
$L = 1.6119919540164693 * $rs; # length of unit cell ((4/3 pi)^(1/3)
$re = 1.823572; # electron radius
$dshift = 0.5;
$idx = 0;
for ($x = 0; $x < $nx; $x++)
{
for ($y = 0; $y < $ny; $y++)
{
$dsign = 1;
for ($z = 0; $z < $nz; $z++)
{
$xnuc[$idx] = $x * $L + 0.5 * $L;
$ynuc[$idx] = $y * $L + 0.5 * $L;
$znuc[$idx] = $z * $L + 0.5 * $L + $dshift * $dsign;
$dsign = -$dsign;
$idx++;
}
}
}
$numnuc = $idx;
# Print length of supercell
printf("Created with h2.pl\n\n");
printf("%d atoms\n",$numnuc*2);
printf("2 atom types\n\n");
printf("%f %f xlo xhi\n", 0, $L * $nx);
printf("%f %f ylo yhi\n", 0, $L * $ny);
printf("%f %f zlo zhi\n\n", 0, $L * $nz);
printf("Masses\n\n");
printf("1 1.007940\n");
printf("2 1.000000\n\n");
printf("Atoms\n\n");
$j=0;
# Print out the nuclei and the core electrons
for ($i = 0; $i < $numnuc; $i++)
{
printf("%i %i %f %i %f %f %f %f\n", $j+=1, 1, 1.0, 0, 0.0, $xnuc[$i], $ynuc[$i], $znuc[$i]);
}
$spin = 1;
for ($i = 0; $i < $numnuc; $i++)
{
if ($spin == 1) {$spin = -1;} else {$spin = 1;}
printf("%i %i %f %i %f %f %f %f\n", $j+=1, 2, 0.0, $spin, $re, $xnuc[$i], $ynuc[$i], $znuc[$i]);
}
Event Timeline
Log In to Comment