diff --git a/examples/README b/examples/README index ccd2325736..3743a864aa 100644 --- a/examples/README +++ b/examples/README @@ -83,6 +83,7 @@ shear: sideways shear applied to 2d solid, with and without a void srd: stochastic rotation dynamics (SRD) particles as solvent tad: temperature-accelerated dynamics of vacancy diffusion in bulk Si tri: triangular particles in rigid bodies +voronoi: test of Voronoi tesselation in compute voronoi/atom Here is how you might run and visualize one of the sample problems: diff --git a/examples/voronoi/in.voronoi b/examples/voronoi/in.voronoi new file mode 100644 index 0000000000..671a7c9b54 --- /dev/null +++ b/examples/voronoi/in.voronoi @@ -0,0 +1,155 @@ +# Test of Kawasaki Dynamics on LJ test system + +units metal +#newton off +boundary p p p + +lattice fcc 1 origin 0.25 0.25 0.25 +atom_style atomic + +atom_modify sort 0 0.0 + +region box block 0 10 0 10 0 10 +create_box 2 box +create_atoms 1 box basis 1 2 + +mass 1 50 +mass 2 50 + +pair_style lj/cut 2.0 +pair_coeff 1 1 0.0 1.0 +pair_coeff 1 2 0.0 1.0 +pair_coeff 2 2 0.0 1.0 + +neighbor 0.3 bin +neigh_modify delay 10 + +# set the cut-off to 2.5x the cutoff from the potential +communicate single cutoff 5.0 + +# atom radii per type +variable r atom (type==1)*0.1+(type==2)*0.3 + +# groups +group type1 type 1 +group type2 type 2 + +thermo 1 +# reduce computes +#compute r1 type1 reduce sum c_v1[1] +#compute r2 type2 reduce sum c_v1[1] + +#compute v1 all voronoi/atom radius v_r + + +# +# TEST 1: Sum of all voronoi cells is the simulation cell volume +# +compute v1 all voronoi/atom +dump d1 all custom 1 dump.voro id type x y z c_v1[1] c_v1[2] +compute r0 all reduce sum c_v1[1] +thermo_style custom c_r0 +variable t1 equal c_r0 +run 0 +print "TEST_1 $(round(abs(v_t1-1000)/10))% Error. Sum of all voronoi cells is the simulation cell volume" +uncompute v1 +uncompute r0 +undump d1 + +# +# TEST 2: Sum of all only_group voronoi cells is the simulation cell volume +# +compute v1 type2 voronoi/atom only_group +dump d1 all custom 1 dump.voro id type x y z c_v1[1] c_v1[2] +compute r0 type2 reduce sum c_v1[1] +compute r1 type1 reduce sum c_v1[1] +thermo_style custom c_r0 c_r1 +variable t2a equal c_r0 +variable t2b equal c_r1 +run 0 +print "TEST_2a $(round(abs(v_t2a-1000)/10))% Error. Sum of all only_group voronoi cells is the simulation cell volume" +print "TEST_2b $(round(v_t2b/10))% Error. Sum of all only_group not included voronoi cells is zero" +uncompute v1 +uncompute r0 +uncompute r1 +undump d1 + +# +# TEST 3: Sum of all radius voronoi cells is the simulation cell volume +# +compute v1 all voronoi/atom radius v_r +dump d1 all custom 1 dump.voro id type x y z c_v1[1] c_v1[2] +compute r0 all reduce sum c_v1[1] +thermo_style custom c_r0 +variable t3 equal c_r0 +run 0 +print "TEST_3 $(round(abs(v_t3-1000)/10))% Error. Sum of all radius voronoi cells is the simulation cell volume" +uncompute v1 +uncompute r0 +undump d1 + + +# +# TEST 4: Edge histogram tests +# +compute v1 type2 voronoi/atom edge_histo 6 +thermo_style custom c_v1[1] c_v1[2] c_v1[3] c_v1[4] c_v1[5] c_v1[6] c_v1[7] +run 1 +variable t4a equal (abs(c_v1[4]-12000)+c_v1[1]+c_v1[2]+c_v1[3]+c_v1[5]+c_v1[6]+c_v1[7])/120 +print "TEST_4a $(round(v_t4a))% Error. Edge histogram of a simple cubic lattice (6 sides. 4 edges per side)" +uncompute v1 +compute v1 all voronoi/atom edge_histo 8 +thermo_style custom c_v1[1] c_v1[2] c_v1[3] c_v1[4] c_v1[5] c_v1[6] c_v1[7] +run 1 +variable t4b equal (abs(c_v1[4]-48000)+c_v1[1]+c_v1[2]+c_v1[3]+c_v1[5]+c_v1[6]+c_v1[7])/480 +print "TEST_4b $(round(v_t4b))% Error. Edge histogram of a face centered cubic lattice (12 sides. 4 edges per side)" +uncompute v1 + +# perturbed fcc lattice +displace_atoms all random 0.01 0.01 0.01 31423 +compute v1 all voronoi/atom edge_histo 8 edge_threshold 0.1 +thermo_style custom c_v1[1] c_v1[2] c_v1[3] c_v1[4] c_v1[5] c_v1[6] c_v1[7] +run 1 +variable t4c equal (abs(c_v1[4]-48000)+c_v1[1]+c_v1[2]+c_v1[3]+c_v1[5]+c_v1[6]+c_v1[7])/480 +print "TEST_4c $(round(v_t4c))% Error. Edge histogram of a perturbed face centered cubic lattice with edge_threshold" +uncompute v1 + +# bcc lattice +delete_atoms group all +lattice bcc 1 origin 0.25 0.25 0.25 +create_atoms 1 box +compute v1 all voronoi/atom edge_histo 8 +thermo_style custom c_v1[1] c_v1[2] c_v1[3] c_v1[4] c_v1[5] c_v1[6] c_v1[7] +run 1 +variable t4d equal (abs(c_v1[4]-12000)+abs(c_v1[6]-16000)+c_v1[1]+c_v1[2]+c_v1[3]+c_v1[5]+c_v1[7])/280 +print "TEST_4d $(round(v_t4d))% Error. Edge histogram of a body centered cubic lattice (truncated octahedron, 6 sides with 4 edges, 8 sides with 6 edges)" +uncompute v1 + +# restore fcc lattice +delete_atoms group all +lattice fcc 1 origin 0.25 0.25 0.25 +create_atoms 1 box basis 1 2 + + +# +# TEST 5: Sum of all voronoi cells is the triclinic simulation cell volume +# + +# switch to triclinic box +change_box all triclinic +change_box all xy final 5.0 remap units box + +compute v1 all voronoi/atom +dump d1 all custom 1 dump.voro id type x y z c_v1[1] c_v1[2] +compute r0 all reduce sum c_v1[1] +thermo_style custom c_r0 +variable t5 equal c_r0 +run 0 +print "TEST_5 $(round((v_t5-1000)/10))% Error. Sum of all voronoi cells is the triclinic simulation cell volume" +uncompute v1 +uncompute r0 +undump d1 + + +# All tests done +print TEST_DONE