def test_gaff(self, smiles):
        import foyer
        import mbuild as mb
        # These tests are smiles strings
        cmpd = mb.load(smiles, smiles=True)
        ff = commpare.identify_forcefields()['GAFF']
        structure = ff.apply(cmpd)
        # Enlarge box to avoid cutoff issues
        bbox = cmpd.boundingbox
        bbox.lengths *= 10
        if any(bbox.lengths < 10):
            bbox.lengths = [100, 100, 100]

        structure.box = [
            bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
        ]
        energies = commpare.spawn_engine_simulations(structure,
                                                     hoomd_kwargs={
                                                         'ref_distance': 10,
                                                         'ref_energy':
                                                         1 / 4.184
                                                     })
        print(smiles)
        print(energies)
        print('=' * 20)
 def test_small_systems(self):
     import foyer
     # These tests are gro/top files
     path_to_foyer_unit_tests = os.path.join(foyer.__path__[0],
                                             'opls_validation/')
     # Walk through each unit test folder, loading energy and print out
     unit_dirs = [
         folder for folder in os.listdir(path_to_foyer_unit_tests)
         if (os.path.isdir(os.path.join(path_to_foyer_unit_tests, folder))
             and 'oplsaa.ff' not in folder)
     ]
     for unit_test_dir in unit_dirs:
         os.chdir(os.path.join(path_to_foyer_unit_tests, unit_test_dir))
         top_file = glob.glob("*.top")[0]
         gro_file = glob.glob("*.gro")[0]
         structure = pmd.load_file(top_file, xyz=gro_file)
         energies = commpare.spawn_engine_simulations(structure,
                                                      hoomd_kwargs={
                                                          'ref_distance':
                                                          10,
                                                          'ref_energy':
                                                          1 / 4.184
                                                      })
         print(unit_test_dir)
         print(energies)
         print('=' * 20)
 def test_small_systems(self):
     import validate
     path_to_amb_unit_tests = os.path.join(validate.__path__[0],
                                           'tests/amber/unit_tests')
     # Walk through each unit test folder, loading energy and print out
     unit_dirs = [
         folder for folder in os.listdir(path_to_amb_unit_tests)
         if os.path.isdir(os.path.join(path_to_amb_unit_tests, folder))
     ]
     for unit_test_dir in unit_dirs:
         print(unit_test_dir)
         os.chdir(os.path.join(path_to_amb_unit_tests, unit_test_dir))
         # Maybe there's a better way to validate the contents of each
         # unit test directory?
         prmtop_files = glob.glob("*.prmtop")
         crd_files = []
         crd_files.extend(glob.glob("*.crd"))
         crd_files.extend(glob.glob("*.inpcrd"))
         if len(prmtop_files) > 0 and len(crd_files) > 0:
             structure = pmd.load_file(prmtop_files[0], xyz=crd_files[0])
             energies = commpare.spawn_engine_simulations(
                 structure,
                 engines=['openmm', 'gromacs'],
                 hoomd_kwargs={
                     'ref_distance': 10,
                     'ref_energy': 1 / 4.184
                 })
             print(energies)
         print('=' * 20)
示例#4
0
    def test_conversions(self):
        # Check to see if we can correctly spawn engine simulations
        eth = Alkane(n=10)
        cmpd = mb.fill_box(eth, n_compounds=10, box=[10, 10, 10])
        ff = foyer.Forcefield(name='oplsaa')
        structure = ff.apply(cmpd)

        df = commpare.spawn_engine_simulations(structure,
                                               hoomd_kwargs={
                                                   'ref_distance': 10,
                                                   'ref_energy': 1 / 4.184
                                               })
        assert df is not None
 def test_small_systems(self):
     import validate
     path_to_gmx_unit_tests = os.path.join(validate.__path__[0],
                                           'tests/gromacs/unit_tests')
     # Walk through each unit test folder, loading energy and print out
     unit_dirs = [
         folder for folder in os.listdir(path_to_gmx_unit_tests)
         if os.path.isdir(os.path.join(path_to_gmx_unit_tests, folder))
     ]
     for unit_test_dir in unit_dirs:
         print(unit_test_dir)
         os.chdir(os.path.join(path_to_gmx_unit_tests, unit_test_dir))
         top_file = glob.glob("*.top")[0]
         gro_file = glob.glob("*.gro")[0]
         structure = pmd.load_file(top_file, xyz=gro_file)
         energies = commpare.spawn_engine_simulations(structure,
                                                      hoomd_kwargs={
                                                          'ref_distance':
                                                          10,
                                                          'ref_energy':
                                                          1 / 4.184
                                                      })
         print(energies)
         print('=' * 20)
    def test_mbuild_examples(self):
        import mbuild as mb
        from mbuild.examples import (Alkane, Methane, Ethane, PMPCLayer,
                                     AlkaneMonolayer)
        import foyer
        for i in range(4, 20):
            my_alkane = Alkane(n=i)
            ff = foyer.Forcefield(name='oplsaa')
            structure = ff.apply(my_alkane)
            bbox = my_alkane.boundingbox
            bbox.lengths *= 10
            if any(bbox.lengths < 10):
                bbox.lengths = [100, 100, 100]

            structure.box = [
                bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
            ]
            structure.combining_rule = 'lorentz'
            energies = commpare.spawn_engine_simulations(structure,
                                                         hoomd_kwargs={
                                                             'ref_distance':
                                                             10,
                                                             'ref_energy':
                                                             1 / 4.184
                                                         })
            print('Alkane, n={}'.format(i))
            print(energies)
            print('=' * 20)

        eth = Ethane()
        structure = ff.apply(eth)
        bbox = eth.boundingbox
        bbox.lengths *= 10
        if any(bbox.lengths < 10):
            bbox.lengths = [100, 100, 100]

        structure.box = [
            bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
        ]

        structure.combining_rule = 'lorentz'
        energies = commpare.spawn_engine_simulations(structure,
                                                     hoomd_kwargs={
                                                         'ref_distance': 10,
                                                         'ref_energy':
                                                         1 / 4.184
                                                     })
        print("Ethane")
        print(energies)
        print('=' * 20)

        methan = Methane()
        structure = ff.apply(methan)
        bbox = methan.boundingbox
        bbox.lengths *= 10
        if any(bbox.lengths < 10):
            bbox.lengths = [100, 100, 100]

        structure.box = [
            bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
        ]

        structure.combining_rule = 'lorentz'
        energies = commpare.spawn_engine_simulations(structure,
                                                     hoomd_kwargs={
                                                         'ref_distance': 10,
                                                         'ref_energy':
                                                         1 / 4.184
                                                     })
        print("Methane")
        print(energies)
        print('=' * 20)