コード例 #1
0
ファイル: test_core.py プロジェクト: cordor/chemlab
 def test_subsystem_from_atoms(self):
     mols = self._make_molecules()
     system = System(mols)
     sub = subsystem_from_atoms(system, np.array([True, True, False,
                                                  False, False, False,
                                                  False, False, False]))
     assert_equals(sub.n_mol, 1)
コード例 #2
0
 def test_subsystem_from_atoms(self):
     mols = self._make_molecules()
     system = System(mols)
     sub = subsystem_from_atoms(
         system,
         np.array(
             [True, True, False, False, False, False, False, False, False]))
     assert_equals(sub.n_mol, 1)
コード例 #3
0
ファイル: select_.py プロジェクト: ajjackson/chemlab
def delete():
    s = current_system()
    s = subsystem_from_atoms(s, ~current_selection().atom_selection_mask)
    
    # Fix also trajectory
    coords = current_trajectory()
    for i, c in enumerate(coords):
        coords[i] = c[~current_selection().atom_selection_mask]
    
    display(s)
コード例 #4
0
def delete():
    s = current_system()
    s = subsystem_from_atoms(s, ~current_selection().atom_selection_mask)

    # Fix also trajectory
    coords = current_trajectory()
    for i, c in enumerate(coords):
        coords[i] = c[~current_selection().atom_selection_mask]

    display(s)
コード例 #5
0
def test_system():
    wat = Molecule([Atom("O", [-4.99, 2.49, 0.0]),
                    Atom("H", [-4.02, 2.49, 0.0]),
                    Atom("H", [-5.32, 1.98, 1.0])], export={'hello': 1.0})

    wat.r_array *= 0.1
    # Initialization from empty
    s = System.empty(4, 4*3)
    
    mols = []
    for i in xrange(s.n_mol):
        wat.r_array += 0.1
        s.add(wat)
        m  = wat.copy()
        mols.append(wat.copy())
        
    # Printing just to test if there aren't any exception    
    print "Init from Empty"
    print "*" * 72
    _print_sysinfo(s)
    
    print "Init Normal"
    print "*" * 72
    s = System(mols)
    _print_sysinfo(s)
    
    # 3 water molecules
    r_array = np.random.random((9, 3))
    type_array = ['O', 'H', 'H', 'O', 'H', 'H', 'O', 'H', 'H']
    mol_indices = [0, 3, 6]
    mol_n_atoms = [3, 3, 3]
    s2 = System.from_arrays(r_array=r_array, type_array=type_array,
                       mol_indices=mol_indices, mol_n_atoms=mol_n_atoms)
    

    print 'bonds', s2._mol_bonds
    sub2 = subsystem_from_molecules(s2, np.array([0, 2]))
    assert sub2.n_mol == 2
    
    
    sub = subsystem_from_atoms(s2, np.array([True, True, False,
                                             False, False, False,
                                             False, False, False]))
    assert sub.n_mol == 1