Пример #1
0
    def run_task(self, fw_spec):

        molecules = self["constituent_molecules"]
        mols_number = self["mols_number"]
        input_filename = self["input_filename"]
        forcefield = self["forcefield"]
        topologies = self["topologies"]

        user_settings = self.get("user_settings", {})
        data_filename = user_settings.get("data_file", "lammps.data")
        final_molecule = self["final_molecule"]
        if isinstance(final_molecule, six.string_types):
            final_molecule = Molecule.from_file(final_molecule)

        lammps_ff_data = LammpsForceFieldData.from_forcefield_and_topology(
            molecules, mols_number, self["box_size"], final_molecule,
            forcefield, topologies)

        lammps_input_set = LammpsInputSet.from_file(
            "forcefield",
            self["input_file"],
            user_settings=user_settings,
            lammps_data=lammps_ff_data,
            data_filename=data_filename,
            is_forcefield=True)

        lammps_input_set.write_input(input_filename, data_filename)
 def setUpClass(cls):
     atoms = OrderedDict([('hw', 'h'), ('ow', 'o')])
     bonds = OrderedDict([((u'hw', u'ow'), [553.0, 0.957]),
                          ((u'hw', u'hw'), [553.0, 1.513])])
     angles = OrderedDict([((u'hw', u'ow', u'hw'), [0.0, 104.52])])
     vdws = OrderedDict([(u'hw', [0.0, 0.0]), (u'ow', [1.7683, 0.1520])])
     forcefield = ForceField(atoms, bonds, angles, pairs=vdws)
     h2o_coords = [[9.626, 6.787, 12.673],
                   [9.626, 8.420, 12.673],
                   [10.203, 7.604, 12.673]]
     h2o = Molecule(["H", "H", "O"], h2o_coords)
     # h2o, h-o, h-o, h=1, h=2, o=3
     top_atoms = [['h', 'hw'], ['o', 'ow']]
     top_bonds = [[1, 3, ('hw', 'ow')], [2, 3, ('hw', 'ow')]]
     top_angles = [[1, 3, 2, ('hw', 'ow', 'hw')]]
     topology = Topology(top_atoms, top_bonds, top_angles)
     mols = [h2o]
     mols_number = [1]
     box_size = [[0.0, 10.0], [0.0, 10.0], [0.0, 10.0]]
     molecule = h2o
     topologies = [topology]
     cls.lammps_ff_data = LammpsForceFieldData.from_forcefield_and_topology(
         mols, mols_number,
         box_size, molecule,
         forcefield,
         topologies)
    def setUp(self):
        self.polymer_linear = Molecule.from_file(
            os.path.join(test_dir, "polymer_linear.xyz"))

        charges = [-0.1187, 0.0861, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.1187, 0.0861,
                   0.0861, 0.0861]
        ff_map = ["C3", "H3", "H3", "H3", "O", "C2", "H2",
                   "H2", "C2", "H2", "H2", "O", "C2", "H2",
                   "H2", "C2", "H2", "H2", "O", "C2", "H2",
                   "H2", "C2", "H2", "H2", "O", "C2", "H2",
                   "H2", "C2", "H2", "H2", "O", "C2", "H2",
                   "H2", "C2", "H2", "H2", "O", "C2", "H2",
                   "H2", "C2", "H2", "H2", "O", "C3", "H3", "H3", "H3"]
        self.polymer_linear.add_site_property("charge", charges)
        self.polymer_linear.add_site_property("ff_map", ff_map)
        self.topology = Topology.from_molecule(self.polymer_linear)
        self.forcefield = ForceField.from_file(
            os.path.join(test_dir, "ffmap_data.yaml"))

        box_size = [[0.0, 50],
                    [0.0, 50],
                    [0.0, 50]]
        self.lammps_ff_data = LammpsForceFieldData.from_forcefield_and_topology(
            [self.polymer_linear], [1], box_size, self.polymer_linear,
            self.forcefield, [self.topology])
Пример #4
0
    def setUpClass(cls):
        polymer_chain = Molecule.from_file(os.path.join(test_dir, "polymer_chain.xyz"))
        polymer_linear = Molecule.from_file(os.path.join(test_dir, "polymer_linear.xyz"))
        cls.polymer_matrix = Molecule.from_file(os.path.join(test_dir, "polymer_matrix.xyz"))

        charges = [-0.1187, 0.0861, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.0326, 0.0861,
                   0.0861, -0.0326, 0.0861, 0.0861, -0.2792, -0.1187, 0.0861,
                   0.0861, 0.0861]
        polymer_linear.add_site_property("charge", charges)
        topology = Topology.from_molecule(polymer_linear)

        cls.polymer_linear_ff_decorated = Molecule.from_file(
            os.path.join(test_dir,"polymer_linear.xyz"))
        ff_map = ['C2', 'H3', 'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'C2', 'H3',
                  'H2', 'O', 'C2', 'H3', 'H2', 'C3', 'H2', 'H3', 'O', 'C3',
                  'H2', 'H3', 'C2', 'H3', 'H2', 'O', 'C2', 'H3', 'H2', 'C3',
                  'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'C2', 'H3', 'H2', 'O',
                  'C2', 'H3', 'H2', 'C3', 'H2', 'H3', 'O', 'C3', 'H2', 'H3', 'H2']
        cls.polymer_linear_ff_decorated.add_site_property("ff_map", ff_map)

        atoms = OrderedDict([("C", "C"), ("H", "H"), ("O", "O")])
        bonds = OrderedDict([((u'C', u'O'), [1000, 1.4115]),
                             ((u'C', u'H'), [1000, 1.1041]),
                             ((u'C', u'C'), [1000, 1.5075])])
        pairs = OrderedDict([((u'O', u'O'), [75844.8, 0.2461, 396.9]),
                             ((u'H', u'H'), [2649.6, 0.2674, 27.22]),
                             ((u'C', u'C'), [14976.0, 0.3236, 637.6])])
        angles = OrderedDict([((u'C', u'C', u'H'), [42.9, 110.1]),
                              ((u'H', u'C', u'H'), [38.5, 109.47]),
                              ((u'H', u'C', u'O'), [56.0, 109.48]),
                              ((u'C', u'C', u'O'), [86.0, 108.54]),
                              ((u'C', u'O', u'C'), [74.5, 108.05])])
        dihedrals = OrderedDict([((u'H', u'C', u'O', u'C'), [0.0, 0.0, -0.73, 0.0]),
                                 ((u'H', u'C', u'C', u'H'), [0.0, 0.0, 0.28, 0.0]),
                                 ((u'C', u'C', u'O', u'C'), [1.76, 0.67, 0.04, 0.0]),
                                 ((u'H', u'C', u'C', u'O'), [0.0, 0.0, 0.28, 0.0]),
                                 ((u'O', u'C', u'C', u'O'), [0.41, -2.1, -0.6, -0.82])])
        forcefield = ForceField(atoms, bonds, angles, dihedrals=dihedrals, pairs=pairs)

        cls.molecules = [polymer_chain] * 3
        cls.mols_number = [7, 3, 1]
        box_size = [[0.0, 50], [0.0, 50], [0.0, 50]]
        cls.topologies = [topology] * len(cls.molecules)

        cls.lammps_ff_data_1 = LammpsForceFieldData.from_forcefield_and_topology(
            cls.molecules, cls.mols_number, box_size, cls.polymer_matrix,
            forcefield, cls.topologies)
 def setUp(self):
     # DMOE = Dimethoxyethane
     self.dmoe = Molecule.from_file(os.path.join(test_dir, "dmoe.xyz"))
     dmoe_charges = [-0.10, 0.09, 0.09, 0.09,
                     -0.34, -0.01, 0.09, 0.09,
                     -0.01, 0.09, 0.09, -0.34,
                     -0.10, 0.09, 0.09, 0.09]
     self.dmoe.add_site_property("charge", dmoe_charges)
     ff_map = ["C3", "H3", "H3", "H3",
               "O", "C2", "H2", "H2",
               "C2", "H2", "H2", "O",
               "C3", "H3", "H3", "H3"]
     self.dmoe.add_site_property("ff_map", ff_map)
     self.topology = Topology.from_molecule(self.dmoe, ff_map="ff_map")
     self.forcefield = ForceField.from_file(
         os.path.join(test_dir, "ffmap_data.yaml"))
     self.box_size = [[0.0, 10], [0.0, 10], [0.0, 10]]
     self.lammps_ff_data = \
         LammpsForceFieldData.from_forcefield_and_topology(
             [self.dmoe], [1], self.box_size, self.dmoe, self.forcefield, [self.topology])
 def setUpClass(cls):
     atoms = OrderedDict([('hw', 'h'), ('ow', 'o')])
     bonds = OrderedDict([((u'hw', u'ow'), [553.0, 0.957]),
                          ((u'hw', u'hw'), [553.0, 1.513])])
     angles = OrderedDict([((u'hw', u'ow', u'hw'), [0.0, 104.52])])
     vdws = OrderedDict([(u'hw', [0.0, 0.0]), (u'ow', [1.7683, 0.1520])])
     forcefield = ForceField(atoms, bonds, angles, vdws=vdws)
     h2o_coords = [[9.626, 6.787, 12.673], [9.626, 8.420, 12.673],
                   [10.203, 7.604, 12.673]]
     h2o = Molecule(["H", "H", "O"], h2o_coords)
     # h2o, h-o, h-o, h=1, h=2, o=3
     top_atoms = [['h', 'hw'], ['o', 'ow']]
     top_bonds = [[1, 3, ('hw', 'ow')], [2, 3, ('hw', 'ow')]]
     top_angles = [[1, 3, 2, ('hw', 'ow', 'hw')]]
     topology = Topology(top_atoms, top_bonds, top_angles)
     mols = [h2o]
     mols_number = [1]
     box_size = [[0.0, 10.0], [0.0, 10.0], [0.0, 10.0]]
     molecule = h2o
     topologies = [topology]
     cls.lammps_ff_data = LammpsForceFieldData.from_forcefield_and_topology(
         mols, mols_number, box_size, molecule, forcefield, topologies)