Exemple #1
0
 def setUp(self):
     super(TestLammpsDrone, self).setUp()
     self.drone = LammpsDrone()
     self.calc_dir = os.path.join(module_dir, "test_files")
     self.input_file = os.path.join(self.calc_dir, "lammps.in")
     self.data_file = os.path.join(self.calc_dir, "lammps.data")
     self.log_file = os.path.join(self.calc_dir, "lammps.log")
Exemple #2
0
 def setUp(self):
     super(TestLammpsDrone, self).setUp()
     self.drone = LammpsDrone()
     self.calc_dir = os.path.join(module_dir, "test_files")
     self.input_file = os.path.join(self.calc_dir, "lammps.in")
     self.data_file = os.path.join(self.calc_dir, "lammps.data")
     self.log_file = os.path.join(self.calc_dir, "lammps.log")
Exemple #3
0
class TestLammpsDrone(AtomateTest):

    def setUp(self):
        super(TestLammpsDrone, self).setUp()
        self.drone = LammpsDrone()
        self.calc_dir = os.path.join(module_dir, "test_files")
        self.input_file = os.path.join(self.calc_dir, "lammps.in")
        self.data_file = os.path.join(self.calc_dir, "lammps.data")
        self.log_file = os.path.join(self.calc_dir, "lammps.log")

    def test_assimilate(self):
        doc = self.drone.assimilate(self.calc_dir, input_filename="lammps.in",
                                    log_filename="lammps.log",
                                    data_filename="lammps.data")
        lmps_input_set = LammpsInputSet.from_file("lammps", self.input_file,
                                                  {}, lammps_data=self.data_file,
                                                  data_filename="lammps.data")
        # no dump file ==> output is just the log file
        lmps_output = LammpsLog(self.log_file)
        self.assertDictEqual(doc["input"], lmps_input_set.as_dict())
        self.assertDictEqual(doc["output"]["log"], lmps_output.as_dict())

        enthalpy = [1906.1958, 1220.2265, 596.51973, 465.01619, 148.91822, 26.160144,
                    319.27146, 141.35729, 299.04503, 271.19625, 145.4361]
        self.assertEqual(lmps_output.as_dict()['thermo_data']['enthalpy'], enthalpy)
Exemple #4
0
class TestLammpsDrone(AtomateTest):

    def setUp(self):
        super(TestLammpsDrone, self).setUp()
        self.drone = LammpsDrone()
        self.calc_dir = os.path.join(module_dir, "test_files")
        self.input_file = os.path.join(self.calc_dir, "lammps.in")
        self.data_file = os.path.join(self.calc_dir, "lammps.data")
        self.log_file = os.path.join(self.calc_dir, "lammps.log")

    def test_assimilate(self):
        doc = self.drone.assimilate(self.calc_dir, input_filename="lammps.in",
                                    log_filename="lammps.log",
                                    data_filename="lammps.data")
        lmps_input_set = LammpsInputSet.from_file("lammps", self.input_file,
                                                  {}, lammps_data=self.data_file,
                                                  data_filename="lammps.data")
        # no dump file ==> output is just the log file
        lmps_output = LammpsLog(self.log_file)
        self.assertDictEqual(doc["input"], lmps_input_set.as_dict())
        self.assertDictEqual(doc["output"]["log"], lmps_output.as_dict())

        enthalpy = [1906.1958, 1220.2265, 596.51973, 465.01619, 148.91822, 26.160144,
                    319.27146, 141.35729, 299.04503, 271.19625, 145.4361]
        self.assertEqual(lmps_output.as_dict()['thermo_data']['enthalpy'], enthalpy)
Exemple #5
0
    def run_task(self, fw_spec):

        # get the directory that contains the LAMMPS run parse.
        calc_dir = os.getcwd()
        if "calc_dir" in self:
            calc_dir = self["calc_dir"]
        elif self.get("calc_loc"):
            calc_dir = get_calc_loc(self["calc_loc"],
                                    fw_spec["calc_locs"])["path"]

        # parse the directory
        logger.info(f"PARSING DIRECTORY: {calc_dir}")

        drone = LammpsDrone(
            additional_fields=self.get("additional_fields"),
            diffusion_params=self.get("diffusion_params", None),
        )

        task_doc = drone.assimilate(
            calc_dir,
            input_filename=self["input_filename"],
            log_filename=self.get("log_filename", "log.lammps"),
            is_forcefield=self.get("is_forcefield", False),
            data_filename=self.get("data_filename", None),
            dump_files=self.get("dump_filenames", None),
        )

        # Check for additional keys to set based on the fw_spec
        if self.get("fw_spec_field"):
            task_doc.update(fw_spec[self.get("fw_spec_field")])

        db_file = env_chk(self.get("db_file"), fw_spec)

        # db insertion
        if not db_file:
            with open("task.json", "w") as f:
                f.write(json.dumps(task_doc, default=DATETIME_HANDLER))
        else:
            mmdb = LammpsCalcDb.from_db_file(db_file)
            # insert the task document
            t_id = mmdb.insert(task_doc)
            logger.info(f"Finished parsing with task_id: {t_id}")

        return FWAction(stored_data={"task_id": task_doc.get("task_id", None)})
Exemple #6
0
    def run_task(self, fw_spec):

        # get the directory that contains the LAMMPS run parse.
        calc_dir = os.getcwd()
        if "calc_dir" in self:
            calc_dir = self["calc_dir"]
        elif self.get("calc_loc"):
            calc_dir = get_calc_loc(self["calc_loc"], fw_spec["calc_locs"])["path"]

        # parse the directory
        logger.info("PARSING DIRECTORY: {}".format(calc_dir))

        drone = LammpsDrone(additional_fields=self.get("additional_fields"),
                            diffusion_params=self.get("diffusion_params", None))

        task_doc = drone.assimilate(calc_dir, input_filename=self["input_filename"],
                                    log_filename=self.get("log_filename", "log.lammps"),
                                    is_forcefield=self.get("is_forcefield", False),
                                    data_filename=self.get("data_filename", None),
                                    dump_files=self.get("dump_filenames", None))

        # Check for additional keys to set based on the fw_spec
        if self.get("fw_spec_field"):
            task_doc.update(fw_spec[self.get("fw_spec_field")])

        db_file = env_chk(self.get('db_file'), fw_spec)

        # db insertion
        if not db_file:
            with open("task.json", "w") as f:
                f.write(json.dumps(task_doc, default=DATETIME_HANDLER))
        else:
            mmdb = LammpsCalcDb.from_db_file(db_file)
            # insert the task document
            t_id = mmdb.insert(task_doc)
            logger.info("Finished parsing with task_id: {}".format(t_id))

        return FWAction(stored_data={"task_id": task_doc.get("task_id", None)})