# -*- coding: iso-8859-1 -*-
# Maintainer: joaander

from hoomd import *
from hoomd import md
context.initialize()
import unittest
import os
import numpy

# tests md.dihedral.harmonic
class dihedral_harmonic_tests (unittest.TestCase):
    def setUp(self):
        print
        snap = data.make_snapshot(N=40,
                                  box=data.boxdim(L=100),
                                  particle_types = ['A'],
                                  bond_types = [],
                                  angle_types = [],
                                  dihedral_types = ['dihedralA'],
                                  improper_types = [])

        if comm.get_rank() == 0:
            snap.dihedrals.resize(10);
            for i in range(10):
                x = numpy.array([i, 0, 0], dtype=numpy.float32)
                snap.particles.position[4*i+0,:] = x;
                x += numpy.random.random(3)
                snap.particles.position[4*i+1,:] = x;
                x += numpy.random.random(3)
                snap.particles.position[4*i+2,:] = x;
                x += numpy.random.random(3)
                snap.particles.position[4*i+3,:] = x;

                snap.dihedrals.group[i,:] = [4*i+0, 4*i+1, 4*i+2, 4*i+3];

        init.read_snapshot(snap)

        context.current.sorter.set_params(grid=8)

    # test to see that se can create an angle.harmonic
    def test_create(self):
        md.dihedral.harmonic();

    # test setting coefficients
    def test_set_coeff(self):
        harmonic = md.dihedral.harmonic();
        harmonic.dihedral_coeff.set('dihedralA', k=1.0, d=1, n=4, p0=0)
        all = group.all();
        md.integrate.mode_standard(dt=0.005);
        md.integrate.nve(all);
        run(100);

    # test coefficient not set checking
    def test_set_coeff_fail(self):
        harmonic = md.dihedral.harmonic();
        all = group.all();
        md.integrate.mode_standard(dt=0.005);
        md.integrate.nve(all);
        self.assertRaises(RuntimeError, run, 100);

    def tearDown(self):
        context.initialize();



if __name__ == '__main__':
    unittest.main(argv = ['test.py', '-v'])

@@ -1612,11 +1612,343 @@
 4, p
-0=0
+hi_0=0)%0A        all = group.all();%0A        md.integrate.mode_standard(dt=0.005);%0A        md.integrate.nve(all);%0A        run(100);%0A        %0A    # test setting coefficients with default phi_0%0A    def test_set_coeff_default(self):%0A        harmonic = md.dihedral.harmonic();%0A        harmonic.dihedral_coeff.set('dihedralA', k=1.0, d=1, n=4
 )%0A  

Test for default kwargs, rename p0 to phi_0