#!/bin/sh
# autopkgtest check
# (C) 2014 Anton Gladky

set -e

export OMPI_MCA_plm_rsh_agent=/bin/false

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
mkdir post

cat <<EOF > in.ellispe
# GayBerne ellipsoids in LJ background fluid

units	     lj
atom_style   ellipsoid
dimension    2

lattice	     sq 0.02
region	     box block 0 20 0 20 -0.5 0.5
create_box   2 box
create_atoms 1 box

set	     group all type/fraction 2 0.1 95392
set 	     type 1 mass 1.0
set 	     type 2 mass 1.5
set 	     type 1 shape 1 1 1
set 	     type 2 shape 3 1 1
set	     group all quat/random 18238

compute	     rot all temp/asphere
group	     spheroid type 1
variable     dof equal count(spheroid)+2
compute_modify rot extra \${dof}

velocity     all create 2.4 87287 loop geom

pair_style   gayberne 1.0 3.0 1.0 4.0
pair_coeff   1 1 3.0 1.0 1 1 1 1 1 1 2.5
pair_coeff   1 2 3.0 1.0 1 1 1 0 0 0
pair_coeff   2 2 1.0 1.0 1 1 0.2 0 0 0

neighbor     0.8 bin

thermo_style custom step c_rot epair etotal press vol
thermo	     100

timestep     0.002

compute	     q all property/atom quatw quati quatj quatk

#dump	     1 all custom 100 dump.ellipse.gayberne &
#	     id type x y z c_q[1] c_q[2] c_q[3] c_q[4]

#dump	     2 all image 100 image.*.jpg type type &
#	     zoom 1.6 center d 0.5 0.5 0.5
#dump_modify  2 pad 4 adiam 1 1.0 adiam 2 2.0

#dump	     3 all movie 100 movie.mpg type type &
#	     zoom 1.6 center d 0.5 0.5 0.5
#dump_modify  3 pad 4 adiam 1 1.0 adiam 2 2.0

fix	     1 all npt/asphere temp 2.0 2.0 0.1 iso 0.0 1.0 1.0 &
	       mtk no pchain 0 tchain 1
fix	     2 all enforce2d

compute_modify 1_temp extra \${dof}

# equilibrate to shrink box around dilute system

run	     2000

# run dynamics on dense system

unfix	     1
fix	     1 all nve/asphere

run	     2000

EOF

mpirun -np 2 --oversubscribe lammps < in.ellispe
lammps < in.ellispe
echo "run: OK"
