Skip to content

Commit 4e0a4a0

Browse files
committed
non-orthogonal PBC
1 parent 15cd7ce commit 4e0a4a0

66 files changed

Lines changed: 187598 additions & 43 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libefp_pbc.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/cubegen.pl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#! /usr/bin/perl
2+
3+
# This script generates a rectangular box of fragments for EFPMD input
4+
5+
use 5.008;
6+
use strict;
7+
use warnings;
8+
9+
use Math::Trig;
10+
11+
if (scalar(@ARGV) != 6) {
12+
die <<EOF;
13+
usage: cubegen.pl <n1:n2:...> <r1:r2:...> <space> <nx> <ny> <nz>
14+
15+
<n1:n2:...> a colon separated list of fragment names
16+
<r1:r2:...> a colon separated list of fragment ratios
17+
<space> distance between the fragments
18+
<nx> number of fragments in x direction
19+
<ny> number of fragments in y direction
20+
<nz> number of fragments in z direction
21+
22+
example: cubegen.pl c2h5oh_l:h2o_l 40:60 4.0 20 20 20 > vodka.in
23+
EOF
24+
}
25+
26+
my @name = split ':', $ARGV[0];
27+
my @ratio = split ':', $ARGV[1];
28+
my $space = $ARGV[2];
29+
my $nx = $ARGV[3];
30+
my $ny = $ARGV[4];
31+
my $nz = $ARGV[5];
32+
33+
die "ratios do not match names" unless scalar(@name) == scalar(@ratio);
34+
die "positive number expected" unless $space > 0.0 && $nx > 0 && $ny > 0 && $nz > 0;
35+
36+
foreach my $i (1 .. scalar(@ratio) - 1) {
37+
$ratio[$i] += $ratio[$i - 1];
38+
}
39+
40+
foreach my $x (0 .. $nx - 1) {
41+
foreach my $y (0 .. $ny - 1) {
42+
foreach my $z (0 .. $nz - 1) {
43+
print_fragment($x, $y, $z);
44+
}
45+
}
46+
}
47+
48+
sub select_fragment {
49+
my $n = int(rand($ratio[-1]));
50+
51+
foreach my $i (0 .. scalar(@ratio) - 1) {
52+
if ($ratio[$i] > $n) {
53+
return $i;
54+
}
55+
}
56+
57+
die;
58+
}
59+
60+
sub print_fragment {
61+
my ($x, $y, $z) = @_;
62+
my $idx = select_fragment();
63+
my @xyzabc = ($space * $x,
64+
$space * $y,
65+
$space * $z,
66+
2.0 * pi * rand,
67+
pi * rand,
68+
2.0 * pi * rand);
69+
70+
print "\n", "fragment ", $name[$idx], "\n";
71+
72+
foreach (@xyzabc) {
73+
printf " %8.3f", $_;
74+
}
75+
76+
print "\n";
77+
}

bin/efpmd

396 KB
Binary file not shown.

bin/trajectory.pl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#! /usr/bin/perl
2+
3+
# This script extracts trajectory data from EFPMD output
4+
5+
use 5.008;
6+
use strict;
7+
use warnings;
8+
9+
die "usage: trajectory.pl <input>\n" if scalar(@ARGV) != 1;
10+
11+
open(FH, "<", $ARGV[0]) || die "$!";
12+
13+
while (<FH>) {
14+
next unless /GEOMETRY/;
15+
<FH>;
16+
17+
my @lines;
18+
19+
while (<FH>) {
20+
last if /^$/;
21+
push @lines, $_;
22+
}
23+
24+
print scalar(@lines), "\n";
25+
print "xyz", "\n";
26+
27+
foreach (@lines) {
28+
$_ =~ s/A[0-9]+([a-zA-Z]+)[0-9]*/$1/;
29+
print $_;
30+
}
31+
}

efpmd/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ Setting `enable_pbc` to `true` also sets `enable_cutoff` to `true`.
227227

228228
##### Periodic Box Size
229229

230-
`periodic_box <x> <y> <z>`
230+
`periodic_box <x> <y> <z> <alpha> <beta> <gamma>`
231231

232-
Default value: `30.0 30.0 30.0`
232+
Default value: `30.0 30.0 30.0 90.0 90.0 90.0`
233233

234-
Unit: Angstrom
234+
Unit: Angstroms, degrees
235235

236236
The smallest box dimension must be greater than `2 * swf_cutoff`.
237237

efpmd/src/common.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,16 @@ void print_matrix(size_t rows, size_t cols, const double *mat)
270270
}
271271
}
272272

273-
vec_t box_from_str(const char *str)
273+
six_t box_from_str(const char *str)
274274
{
275-
vec_t box;
275+
six_t box;
276276

277-
if (sscanf(str, "%lf %lf %lf", &box.x, &box.y, &box.z) < 3)
277+
if (sscanf(str, "%lf %lf %lf %lf %lf %lf ", &box.x, &box.y, &box.z, &box.a, &box.b, &box.c) < 3)
278278
error("incorrect box format");
279279

280-
vec_scale(&box, 1.0 / BOHR_RADIUS);
280+
box.x *= 1.0 / BOHR_RADIUS;
281+
box.y *= 1.0 / BOHR_RADIUS;
282+
box.z *= 1.0 / BOHR_RADIUS;
283+
// vec_scale(&box, 1.0 / BOHR_RADIUS);
281284
return box;
282285
}

efpmd/src/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void print_matrix(size_t, size_t, const double *);
117117
void check_fail(enum efp_result);
118118
void compute_energy(struct state *, bool);
119119
struct sys *parse_input(struct cfg *, const char *);
120-
vec_t box_from_str(const char *);
120+
six_t box_from_str(const char *);
121121
int efp_strcasecmp(const char *, const char *);
122122
int efp_strncasecmp(const char *, const char *, size_t);
123123

0 commit comments

Comments
 (0)