Exemple #1
0
 def _lammps_input_get_non_mast_keywords(self):
     """Get the non-LAMMPS keywords and make a dictionary."""
     input_dict = dict()
     allowedpath = os.path.join(dirutil.get_mast_install_path(), 'MAST',
                                'ingredients', 'programkeys',
                                'lammps_allowed_keywords.py')
     allowed_list = self._lammps_input_get_allowed_keywords(allowedpath)
     for key, value in self.keywords['program_keys'].iteritems():
         if not key[0:5] == "mast_":
             keytry = key.upper()
             if not (keytry in allowed_list):
                 self.logger.warning(
                     "Ignoring program key %s for INPUT. To allow this keyword, add it to %s"
                     % (keytry, allowedpath))
             else:
                 if type(value) == str and value.isalpha():
                     input_dict[keytry.lower()] = value
                 else:
                     input_dict[keytry.lower()] = value
     if 'autocorrect' in input_dict:
         input_dict['autocorrect'] = bool(input_dict['autocorrect'])
     else:
         input_dict['autocorrect'] = True
     if input_dict['autocorrect']:
         input_dict = readable_lammps_parameters(input_dict,
                                                 self.keywords['structure'])
     return input_dict
Exemple #2
0
def get_citations(recipedir):
    """Use mast_exec lines from the recipe directory in order
        to assign a CITATIONS section to the SUMMARY.txt file.
        Args:
            recipedir <str>: Recipe directory
        Returns:
            linelist <list of str>: Lines to add to SUMMARY.txt
    """
    mylist = list()
    mylist = ['mast', 'pymatgen',
              'spglib']  #need to use; removed python as standard
    myinput = os.path.join(recipedir, "input.inp")
    mastexecs = fileutil.grepme(myinput, "mast_exec")
    for mastexec in mastexecs:
        if 'vasp' in mastexec.lower():
            mylist.append('vasp')
            mastxcs = fileutil.grepme(myinput, "mast_xc")
            if len(mastxcs) >= 1:
                mylist.append('vasp_pps')
                for mastxc in mastxcs:
                    if ("pw" in mastxc.lower()) or ("paw" in mastxc.lower()):
                        mylist.append('vasp_paw')
            mastprogs = fileutil.grepme(myinput, "mast_program")
            if len(mastprogs) >= 1:
                for mastprog in mastprogs:
                    if ("vasp_neb" in mastprog.lower()):
                        mylist.append('vaspneb')
            if "tst" in mastexec.lower():
                mylist.append('vaspneb')
        #if 'phon' in mastexec.lower():
        #    mylist.append('phon')
        if 'structopt' in mastexec.lower():
            mylist.append('structopt')
    mastwrites = fileutil.grepme(myinput, "mast_write_method")
    for mastwrite in mastwrites:
        if 'pathfinder' in mastexec.lower():
            mylist.append('pathfinder')
    citationpath = os.path.join(dirutil.get_mast_install_path(), "summary",
                                "citation_files")
    citationfiles = os.listdir(citationpath)
    linelist = list()
    uniquelist = list()
    for mylistitem in mylist:
        if not mylistitem in uniquelist:
            uniquelist.append(mylistitem)
    #print "UNIQUELIST: ", uniquelist
    for listitem in uniquelist:
        for citationfile in citationfiles:
            if citationfile[:-3] == listitem:  #all except number
                cfpath = os.path.join(citationpath, citationfile)
                cffile = MASTFile(cfpath)
                linelist.extend(cffile.data)
    return linelist
Exemple #3
0
def get_citations(recipedir):
    """Use mast_exec lines from the recipe directory in order
        to assign a CITATIONS section to the SUMMARY.txt file.
        Args:
            recipedir <str>: Recipe directory
        Returns:
            linelist <list of str>: Lines to add to SUMMARY.txt
    """
    mylist=list()
    mylist=['mast','pymatgen','spglib'] #need to use; removed python as standard
    myinput = os.path.join(recipedir, "input.inp")
    mastexecs = fileutil.grepme(myinput, "mast_exec")
    for mastexec in mastexecs:
        if 'vasp' in mastexec.lower():
            mylist.append('vasp')
            mastxcs = fileutil.grepme(myinput, "mast_xc")
            if len(mastxcs) >= 1:
                mylist.append('vasp_pps')
                for mastxc in mastxcs:
                    if ("pw" in mastxc.lower()) or ("paw" in mastxc.lower()):
                        mylist.append('vasp_paw')
            mastprogs = fileutil.grepme(myinput, "mast_program")
            if len(mastprogs) >= 1:
                for mastprog in mastprogs:
                    if ("vasp_neb" in mastprog.lower()):
                        mylist.append('vaspneb')
            if "tst" in mastexec.lower():
                mylist.append('vaspneb')
        #if 'phon' in mastexec.lower():
        #    mylist.append('phon')
        if 'structopt' in mastexec.lower():
            mylist.append('structopt')
    mastwrites = fileutil.grepme(myinput, "mast_write_method")
    for mastwrite in mastwrites:
        if 'pathfinder' in mastexec.lower():
            mylist.append('pathfinder')
    citationpath = os.path.join(dirutil.get_mast_install_path(),
                    "summary","citation_files")
    citationfiles = os.listdir(citationpath)
    linelist = list()
    uniquelist=list()
    for mylistitem in mylist:
        if not mylistitem in uniquelist:
            uniquelist.append(mylistitem)
    #print "UNIQUELIST: ", uniquelist
    for listitem in uniquelist:
        for citationfile in citationfiles:
            if citationfile[:-3] == listitem: #all except number
                cfpath = os.path.join(citationpath, citationfile)
                cffile = MASTFile(cfpath)
                linelist.extend(cffile.data)
    return linelist
Exemple #4
0
 def _phon_inphon_get_non_mast_keywords(self):
     """Sort out the non-PHON keywords and make a dictionary."""
     inphon_dict=dict()
     allowedpath = os.path.join(dirutil.get_mast_install_path(),
                     'ingredients','programkeys','phon_allowed_keywords.py')
     allowed_list = self._phon_inphon_get_allowed_keywords(allowedpath)
     for key, value in self.keywords['program_keys'].iteritems():
         if not key[0:5] == "mast_":
             keytry = key.upper()
             if not (keytry in allowed_list):
                 self.logger.warning("Ignoring program key %s for INPHON. To allow this keyword, add it to %s" % (keytry, allowedpath))
             else:
                 if type(value)==str and value.isalpha():
                     inphon_dict[keytry]=value.capitalize() #First letter cap
                 else:
                     inphon_dict[keytry]=value
     return inphon_dict
Exemple #5
0
 def _lammps_input_get_non_mast_keywords(self):
     """Get the non-LAMMPS keywords and make a dictionary."""
     input_dict=dict()
     allowedpath = os.path.join(dirutil.get_mast_install_path(),
                     'ingredients','programkeys','lammps_allowed_keywords.py')
     allowed_list = self._lammps_input_get_allowed_keywords(allowedpath)
     for key, value in self.keywords['program_keys'].iteritems():
         if not key[0:5] == "mast_":
             keytry = key.upper()
             if not (keytry in allowed_list):
                 self.logger.warning("Ignoring program key %s for INPUT. To allow this keyword, add it to %s" % (keytry, allowedpath))
             else:
                 if type(value)==str and value.isalpha():
                     input_dict[keytry.lower()]=value
                 else:
                     input_dict[keytry.lower()]=value
     return input_dict
Exemple #6
0
 def _phon_inphon_get_non_mast_keywords(self):
     """Sort out the non-PHON keywords and make a dictionary."""
     inphon_dict = dict()
     allowedpath = os.path.join(dirutil.get_mast_install_path(),
                                'ingredients', 'programkeys',
                                'phon_allowed_keywords.py')
     allowed_list = self._phon_inphon_get_allowed_keywords(allowedpath)
     for key, value in self.keywords['program_keys'].iteritems():
         if not key[0:5] == "mast_":
             keytry = key.upper()
             if not (keytry in allowed_list):
                 self.logger.warning(
                     "Ignoring program key %s for INPHON. To allow this keyword, add it to %s"
                     % (keytry, allowedpath))
             else:
                 if type(value) == str and value.isalpha():
                     inphon_dict[keytry] = value.capitalize(
                     )  #First letter cap
                 else:
                     inphon_dict[keytry] = value
     return inphon_dict
Exemple #7
0
import MAST
from MAST.ingredients.pmgextend.structure_extensions import StructureExtensions
import shutil
import pymatgen
import numpy as np
from MAST.utility import dirutil

testname = "fss_structure_test"
#oldcontrol = os.getenv("MAST_CONTROL")
#oldrecipe = os.getenv("MAST_RECIPE_PATH")
#oldscratch = os.getenv("MAST_SCRATCH")
#print "Old directories:"
#print oldcontrol
#print oldrecipe
#print oldscratch
testdir = os.path.join(dirutil.get_mast_install_path(), 'test', testname)


class TestSE(unittest.TestCase):
    """Test StructureExtensions
    """
    def setUp(self):
        os.chdir(testdir)

    def tearDown(self):
        pass

    def test_scale_structure(self):
        size = '1 1 0,-1 1 0,0 0 1'
        perfect = pymatgen.io.vaspio.Poscar.from_file(
            "POSCAR_perfect").structure
Exemple #8
0
"""Tests for Recipe for FSS"""

import unittest
from unittest import SkipTest
import os
import time
import MAST
import pymatgen
from MAST.utility import dirutil
from MAST.recipe import recipeutility
from MAST.utility import MASTFile

testname = "fss_recipe_test"
testdir = os.path.join(dirutil.get_mast_install_path(), "test", testname)


class TestRecipeUtility(unittest.TestCase):
    def setUp(self):
        os.chdir(testdir)

    def tearDown(self):
        pass

    def test_read_recipe(self):
        fss_recipe = MASTFile(os.path.join(testdir, "fss_recipe.txt"))
        fss_recipe_lines = fss_recipe.data
        fss_recipe_lines.pop(0)  # remove recipe name
        [htu, ptc, htr] = recipeutility.read_recipe(fss_recipe_lines)
        self.assertEqual(htu["defect_2x2x3_int1_opt"]["neb_2x2x3_int1-int2_opt"], "relax_to_neb")
        self.assertItemsEqual(ptc["neb_1x2x4_int1-int2_opt"], ["defect_1x2x4_int1_opt", "defect_1x2x4_int2_opt"])
        self.assertEqual(htr["phonon_1x1x2_int1-int2_w0"], "phonon")
Exemple #9
0
# Maintainer: Tam Mayeshiba
# Last updated: 2014-04-25
##############################################################
# Purpose: Modify and get information out of submission scripts.
# 11/9/12 created

import os
import sys
import math  #TA to calc num_nodes
import importlib

from MAST.utility.mastfile import MASTFile
from MAST.utility import MASTError
from MAST.utility import dirutil
mast_control = dirutil.get_mast_control_path()
mast_install = dirutil.get_mast_install_path()
mast_platform = dirutil.get_mast_platform()

#mysc = "submit.platforms.script_commands_%s" % mast_platform
#my_script_commands = importlib.import_module(mysc)
"""
Script commands
"""


def write_submit_script(keywords):
    """This script example is built on the following ingredient keywords,
        and may require significant customization.
        mast_processors
        mast_ppn
        mast_queue
Exemple #10
0
# Maintainer: Tam Mayeshiba
# Last updated: 2014-04-25
##############################################################
# Purpose: Modify and get information out of submission scripts.
# 11/9/12 created

import os
import sys
import math #TA to calc num_nodes
import importlib

from MAST.utility.mastfile import MASTFile
from MAST.utility import MASTError
from MAST.utility import dirutil
mast_control = dirutil.get_mast_control_path()
mast_install = dirutil.get_mast_install_path() 
mast_platform = dirutil.get_mast_platform()

#mysc = "submit.platforms.script_commands_%s" % mast_platform
#my_script_commands = importlib.import_module(mysc)



"""
Script commands
"""

def write_submit_script(keywords):
    """This script example is built on the following ingredient keywords,
        and may require significant customization.
        mast_processors