def from_files(cls, disp_dir): """ Args: disp_dir: directory corresponding to this displacement (usually written by caesar as atomn.dispm) Returns: CaesarDisplacement object """ amplitude = float( np.genfromtxt(os.path.join(disp_dir, 'amplitude.dat'))) disp = np.genfromtxt(os.path.join(disp_dir, 'disp.dat')).tolist() #drone = VaspToComputedEntryDrone(inc_structure=True) #TODO: Possibly either find another drone or combine Vasprun and Outcar here # because this drone will return a dict, not an object. Don't forget to modify from_dict and the docstring if you make this change. drone = VaspToDbTaskDrone(simulate_mode=True) print 'assimilating vaspruns in ', disp_dir positive = drone.assimilate(os.path.join(disp_dir, 'positive')) #returned dict has last_updated as datetime.datetime object which jsanitize complains about if 'last_updated' in positive: positive['last_updated'] = str(positive['last_updated']) negative = drone.assimilate(os.path.join(disp_dir, 'negative')) if 'last_updated' in negative: negative['last_updated'] = str(negative['last_updated']) return cls(amplitude, disp, positive, negative)
def run_task(self, fw_spec): prev_dir = fw_spec['prev_vasp_dir'] # get the db credentials db_dir = os.environ['DB_LOC'] db_path = os.path.join(db_dir, 'tasks_db.json') # use MPDrone to put it in the database with open(db_path) as f: db_creds = json.load(f) drone = VaspToDbTaskDrone(host=db_creds['host'], port=db_creds['port'], database=db_creds['database'], user=db_creds['admin_user'], password=db_creds['admin_password'], collection=db_creds['collection']) t_id = drone.assimilate(prev_dir) if t_id: print 'ENTERED task id:', t_id stored_data = {'task_id': t_id} update_spec = { 'prev_vasp_dir': prev_dir, 'prev_task_type': fw_spec['prev_task_type'] } return FWAction(stored_data=stored_data, update_spec=update_spec) else: raise ValueError("Could not parse entry for database insertion!")
def run_task(self, fw_spec): prev_dir = fw_spec['prev_vasp_dir'] # get the db credentials db_dir = os.environ['DB_LOC'] db_path = os.path.join(db_dir, 'tasks_db.json') # use MPDrone to put it in the database with open(db_path) as f: db_creds = json.load(f) drone = VaspToDbTaskDrone( host=db_creds['host'], port=db_creds['port'], database=db_creds['database'], user=db_creds['admin_user'], password=db_creds['admin_password'], collection=db_creds['collection']) t_id = drone.assimilate(prev_dir) if t_id: print 'ENTERED task id:', t_id stored_data = {'task_id': t_id} update_spec = {'prev_vasp_dir': prev_dir, 'prev_task_type': fw_spec['prev_task_type']} return FWAction(stored_data=stored_data, update_spec=update_spec) else: raise ValueError("Could not parse entry for database insertion!")
import json from pynter.data.datasets import Dataset from pymatgen.io.vasp.inputs import VaspInput, Incar, Kpoints, Poscar, Potcar from pymatgen.core.structure import Structure ds = Dataset.from_directory( '/home/lorenzo/tests/project-test/tutorials/Si-BS-dataset') #%% from matgendb.creator import VaspToDbTaskDrone drone = VaspToDbTaskDrone(collection='test') for j in ds: drone.assimilate(j.path) #%% from matgendb.query_engine import QueryEngine qe = QueryEngine(collection='test') # entries = qe.get_entries({'dir_name':'localhost:/home/lorenzo/tests/project-test/tutorials/Si-BS-dataset/3-PBE-BS'}) entries = qe.get_entries({'chemsys': 'Si'}, optional_data=['calculations'], inc_structure=True) #%%
def run_task(self, fw_spec): """ Required Parameters: host (str): See SurfaceWorkflowManager in surface_wf.py port (int): See SurfaceWorkflowManager in surface_wf.py user (str): See SurfaceWorkflowManager in surface_wf.py password (str): See SurfaceWorkflowManager in surface_wf.py database (str): See SurfaceWorkflowManager in surface_wf.py collection (str): See SurfaceWorkflowManager in surface_wf.py struct_type (str): either oriented_unit_cell or slab_cell miller_index (list): Miller Index of the oriented unit cell or slab loc (str path): Location of the outputs of the vasp calculations Optional Parameters: surface_area (float): surface area of the slab, obtained from slab object before relaxation shift (float): A shift value in Angstrom that determines how much a slab should be shifted. For determining number of terminations, obtained from slab object before relaxation vsize (float): Size of vacuum layer of slab in Angstroms, obtained from slab object before relaxation ssize (float): Size of slab layer of slab in Angstroms, obtained from slab object before relaxation """ dec = MontyDecoder() struct_type = dec.process_decoded(self.get("struct_type")) loc = dec.process_decoded(self.get("loc")) cwd = dec.process_decoded(self.get("cwd")) surface_area = dec.process_decoded(self.get("surface_area", None)) shift = dec.process_decoded(self.get("shift", None)) vsize = dec.process_decoded(self.get("vsize", None)) ssize = dec.process_decoded(self.get("ssize", None)) miller_index = dec.process_decoded(self.get("miller_index")) # Sets default for DB parameters if not self["host"]: self["host"] = "127.0.0.1" if not self["port"]: self["port"] = 27017 if not self["database"]: self["database"] = "vasp" if not self["collection"]: self["collection"] = "tasks" # Addtional info relating to slabs additional_fields={"author": os.environ.get("USER"), "structure_type": struct_type, "miller_index": miller_index, "surface_area": surface_area, "shift": shift, "vac_size": vsize, "slab_size": ssize} drone = VaspToDbTaskDrone(host=self["host"], port=self["port"], user=self["user"], password=self["password"], database=self["database"], use_full_uri=False, additional_fields=additional_fields, collection=self["collection"]) drone.assimilate(cwd+loc)