Ejemplo n.º 1
0
def test_constrain_on_polymer_end():    
    end = Point(index=19,position=[0.2,0.2,0.2])
    #end = Point(index=199,position=[0.2,0.2,0.2])
    box = Box([0,0,0],[20,20,20])
    coords,bonds,type_beads,ids = one_polymer(N=20,type_bead=1,ptolerance=0,type_polymer="linear",start_id=0,lconstrain=[end],gconstrain=[box],max_trial=1000)   
    print norm(coords[-2]-np.array([0.2,0.2,0.2]))
    assert(norm(coords[-2]-np.array([0.2,0.2,0.2])) < 3)
Ejemplo n.º 2
0
def test_create_mixture_angle_start_angle_start_id():
    coords,bonds,type_beads,ids = one_polymer(N=3,type_bead=[0,1,0],
                                               liaison={"0-0":[1.0,0],"0-1":[2.0,1]},
                                              angle_bond=True,start_angle=10,
                                             angle_def={"0-0-0":[1.,0],"0-0-1":[1.,1],"0-1-1":[1.,2],"1-1-1":[1.,3]},
                                        ptolerance=0,type_polymer="linear",start_id=20)
    assert (bonds[0] == [[0,1,20,21],[1,1,21,22]])
    assert (bonds[1] == [[10,1,20,21,22]])
Ejemplo n.º 3
0
def test_startid():
    coords, bonds, type_beads, ids = one_polymer(N=2,
                                                 type_bead=0,
                                                 liaison={"0-0": [1.0, 0]},
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=1)
    assert (bonds[0] == [[0, 0, 1, 2]])
Ejemplo n.º 4
0
def test_one_particule():
    coords, bonds, type_beads, ids = one_polymer(N=1,
                                                 type_bead=0,
                                                 liaison={"0-0": [1.0, 0]},
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=1)
    assert (bonds[0] == [])
Ejemplo n.º 5
0
def test_bond_size_angle():
    box = Box([-100,-100,-100],[400,400,400])
    
    coords,bonds,type_beads,ids = one_polymer(N=400,type_bead=1,liaison={"1-1":[1.5,1]},ptolerance=0,
                                       type_polymer="linear",start_id=0,lconstrain=[],
                                       gconstrain=[box],max_trial=500000,rc=1,virtual_lp=4,rigid_constrain=False,flexible_lp=True)  
                                       
    bonds = np.mean(np.sqrt(np.sum((coords[1:]-coords[:-1])**2,axis=1)))
    assert(abs(bonds-1.5)< 0.1)                                       
Ejemplo n.º 6
0
 def testerror1(self):
     self.assertRaises(
         SomeCoolException,
         one_polymer(N=3,
                     type_bead=[0, 1],
                     liaison={"0-0": [1.0, 0]},
                     ptolerance=0,
                     type_polymer="linear",
                     start_id=0))
Ejemplo n.º 7
0
def test_constrain_box_on_polymer():
    box = Box([0, 0, 0], [10, 10, 10])
    coords, bonds, type_beads, ids = one_polymer(N=200,
                                                 type_bead=1,
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0,
                                                 gconstrain=[box])
    for p in coords:
        assert (box.is_inside(p))
Ejemplo n.º 8
0
def test_angle():
    coords, bonds, type_beads, ids = one_polymer(N=2,
                                                 type_bead=0,
                                                 liaison={"0-0": [1.0, 0]},
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=1,
                                                 start_bond=1,
                                                 angle_bond=True)
    assert (bonds[1] == [])
Ejemplo n.º 9
0
def test_create():

    coords, bonds, type_beads, ids = one_polymer(N=2,
                                                 type_bead=0,
                                                 liaison={"0-0": [1.0, 0]},
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0)
    assert (bonds[0] == [[0, 0, 0, 1]])
    assert (round(norm(coords[0] - coords[1]), 3) == 1.00)
    assert (type_beads == [0, 0])
Ejemplo n.º 10
0
def test_constrain_on_polymer_start():
    start = Point(index=0, position=[0.2, 0.2, 0.2])
    #end = Point(index=199,position=[0.2,0.2,0.2])
    box = Box([0, 0, 0], [10, 10, 10])
    coords, bonds, type_beads, ids = one_polymer(N=20,
                                                 type_bead=1,
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0,
                                                 lconstrain=[start],
                                                 gconstrain=[box])
    assert (norm(coords[0] - np.array([0.2, 0.2, 0.2])) < 0.01)
Ejemplo n.º 11
0
def test_crash():
    PS = [0.2,0.2,0.2]
    PM = [10,10.2,0.2]
    PE = [0.2,199,19]
    start = Point(index=0,position=PS)  
    middle = Point(index=39,position=PM)
    
    end = Point(index=399,position=PE)
    #end = Point(index=199,position=[0.2,0.2,0.2])
    box = Box([-10,-10,-10],[400,400,400])
    coords_lp,bonds,type_beads,ids = one_polymer(N=400,type_bead=1,liaison={"1-1":[1.0,1]},ptolerance=0,
                                           type_polymer="linear",start_id=0,lconstrain=[start,middle,end],
                                           gconstrain=[box],max_trial=500000,rc=0.5,virtual_lp=3,rigid_constrain=True)
Ejemplo n.º 12
0
def test_create_mixture():
    coords, bonds, type_beads, ids = one_polymer(N=3,
                                                 type_bead=[0, 1, 0],
                                                 liaison={
                                                     "0-0": [1.0, 0],
                                                     "0-1": [2.0, 1]
                                                 },
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0)
    assert (bonds[0] == [[0, 1, 0, 1], [1, 1, 1, 2]])
    assert (round(norm(coords[0] - coords[1]), 3) == 2.00)
    assert (round(norm(coords[1] - coords[2]), 3) == 2.00)
Ejemplo n.º 13
0
def test_constrain_on_polymer_end():
    end = Point(index=19, position=[0.2, 0.2, 0.2])
    #end = Point(index=199,position=[0.2,0.2,0.2])
    box = Box([0, 0, 0], [20, 20, 20])
    coords, bonds, type_beads, ids = one_polymer(N=20,
                                                 type_bead=1,
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0,
                                                 lconstrain=[end],
                                                 gconstrain=[box],
                                                 max_trial=1000)
    print norm(coords[-2] - np.array([0.2, 0.2, 0.2]))
    assert (norm(coords[-2] - np.array([0.2, 0.2, 0.2])) < 3)
Ejemplo n.º 14
0
def test_bond_size():
    box = Box([-100, -100, -100], [400, 400, 400])

    coords, bonds, type_beads, ids = one_polymer(N=400,
                                                 type_bead=1,
                                                 liaison={"1-1": [2.0, 1]},
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0,
                                                 lconstrain=[],
                                                 gconstrain=[box],
                                                 max_trial=300000,
                                                 rc=0.5,
                                                 virtual_lp=None,
                                                 rigid_constrain=True)

    bonds = np.mean(np.sqrt(np.sum((coords[1:] - coords[:-1])**2, axis=1)))
    assert (abs(bonds - 2) < 0.1)
Ejemplo n.º 15
0
def test_create_mixture_angle():
    coords, bonds, type_beads, ids = one_polymer(N=3,
                                                 type_bead=[0, 1, 0],
                                                 liaison={
                                                     "0-0": [1.0, 0],
                                                     "0-1": [2.0, 1]
                                                 },
                                                 angle_bond=True,
                                                 angle_def={
                                                     "0-0-0": [1., 0],
                                                     "0-0-1": [1., 1],
                                                     "0-1-1": [1., 2],
                                                     "1-1-1": [1., 3]
                                                 },
                                                 ptolerance=0,
                                                 type_polymer="linear",
                                                 start_id=0)
    assert (bonds[0] == [[0, 1, 0, 1], [1, 1, 1, 2]])
    assert (bonds[1] == [[0, 1, 0, 1, 2]])
Ejemplo n.º 16
0
    def __init__(self, **kwargs):
        coords, bonds, type_beads, ids = one_polymer(**kwargs)

        #Getting liaison and angle information
        self.liaison = kwargs.get("liaison", None)
        self.angle_def = kwargs.get("angle_def", None)

        a = inspect.getargspec(one_polymer)
        for arg, value in zip(a.args[-len(a.defaults):], a.defaults):
            #print arg
            if self.liaison is None and arg == "liaison":
                self.liaison = value
            if self.angle_def is None and arg == "angle_def":
                self.angle_def = value

        self.coords = coords
        self.bond = bonds[0]
        self.angle = bonds[1]
        self.types_beads = type_beads
        self.ids = ids
        self.extrabond = []
Ejemplo n.º 17
0
 def __init__(self,**kwargs):
     coords,bonds,type_beads,ids = one_polymer(**kwargs)
     
     #Getting liaison and angle information
     self.liaison = kwargs.get("liaison",None)
     self.angle_def = kwargs.get("angle_def",None)
     
      
     a = inspect.getargspec(one_polymer)
     for arg,value in zip(a.args[-len(a.defaults):],a.defaults):
         #print arg
         if self.liaison is None and arg == "liaison":
              self.liaison =value
         if self.angle_def is None and arg == "angle_def":
              self.angle_def = value
         
     self.coords = coords
     self.bond = bonds[0]
     self.angle = bonds[1]
     self.types_beads = type_beads
     self.ids = ids
     self.extrabond = []
Ejemplo n.º 18
0
def test_crash():
    PS = [0.2, 0.2, 0.2]
    PM = [10, 10.2, 0.2]
    PE = [0.2, 199, 19]
    start = Point(index=0, position=PS)
    middle = Point(index=39, position=PM)

    end = Point(index=399, position=PE)
    #end = Point(index=199,position=[0.2,0.2,0.2])
    box = Box([-10, -10, -10], [400, 400, 400])
    coords_lp, bonds, type_beads, ids = one_polymer(
        N=400,
        type_bead=1,
        liaison={"1-1": [1.0, 1]},
        ptolerance=0,
        type_polymer="linear",
        start_id=0,
        lconstrain=[start, middle, end],
        gconstrain=[box],
        max_trial=500000,
        rc=0.5,
        virtual_lp=3,
        rigid_constrain=True)
Ejemplo n.º 19
0
def test_constrain_on_polymer_start():    
    start = Point(index=0,position=[0.2,0.2,0.2])
    #end = Point(index=199,position=[0.2,0.2,0.2])
    box = Box([0,0,0],[10,10,10])
    coords,bonds,type_beads,ids = one_polymer(N=20,type_bead=1,ptolerance=0,type_polymer="linear",start_id=0,lconstrain=[start],gconstrain=[box])   
    assert(norm(coords[0]-np.array([0.2,0.2,0.2])) < 0.01)
Ejemplo n.º 20
0
def test_create():
    
    coords,bonds,type_beads,ids = one_polymer(N=2,type_bead=0,liaison={"0-0":[1.0,0]},ptolerance=0,type_polymer="linear",start_id=0)
    assert (bonds[0] == [[0,0,0,1]])
    assert (round(norm(coords[0]-coords[1]),3) == 1.00)
    assert(type_beads == [0,0])
Ejemplo n.º 21
0
 def testerror1(self):
     self.assertRaises(SomeCoolException, one_polymer(N=3,type_bead=[0,1],liaison={"0-0":[1.0,0]},ptolerance=0,type_polymer="linear",start_id=0))
Ejemplo n.º 22
0
def test_create_mixture():
    coords,bonds,type_beads,ids = one_polymer(N=3,type_bead=[0,1,0],liaison={"0-0":[1.0,0],"0-1":[2.0,1]},ptolerance=0,type_polymer="linear",start_id=0)
    assert (bonds[0] == [[0,1,0,1],[1,1,1,2]])
    assert (round(norm(coords[0]-coords[1]),3) == 2.00)
    assert (round(norm(coords[1]-coords[2]),3)== 2.00)
Ejemplo n.º 23
0
def test_one_particule():   
    coords,bonds,type_beads,ids = one_polymer(N=1,type_bead=0,liaison={"0-0":[1.0,0]},ptolerance=0,type_polymer="linear",start_id=1)
    assert (bonds[0] == [])
Ejemplo n.º 24
0
def test_startbond():   
    coords,bonds,type_beads,ids = one_polymer(N=2,type_bead=0,liaison={"0-0":[1.0,0]},ptolerance=0,type_polymer="linear",start_id=1,start_bond=1)
    assert (bonds[0] == [[1,0,1,2]])
Ejemplo n.º 25
0
def test_angle():   
    coords,bonds,type_beads,ids = one_polymer(N=2,type_bead=0,liaison={"0-0":[1.0,0]},ptolerance=0,type_polymer="linear",start_id=1,start_bond=1,angle_bond=True)
    assert (bonds[1] == [])
Ejemplo n.º 26
0
def test_constrain_box_on_polymer():
    box = Box([0,0,0],[10,10,10])
    coords,bonds,type_beads,ids = one_polymer(N=200,type_bead=1,ptolerance=0,type_polymer="linear",start_id=0,gconstrain=[box])
    for p in coords:
        assert(box.is_inside(p))