本文整理汇总了Python中MAST.utility.MASTFile.data方法的典型用法代码示例。如果您正苦于以下问题:Python MASTFile.data方法的具体用法?Python MASTFile.data怎么用?Python MASTFile.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MAST.utility.MASTFile
的用法示例。
在下文中一共展示了MASTFile.data方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_archive_files
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def create_archive_files(self):
"""Save off archive files.
Returns:
creates archive_input_options.txt
creates archive_recipe_plan.txt
"""
inputsave = MASTFile()
inputsave.data = repr(self.input_options)
inputsave.to_file(os.path.join(self.working_directory, 'archive_input_options.txt'))
recipesave = MASTFile()
recipesave.data = repr(self.recipe_plan)
recipesave.to_file(os.path.join(self.working_directory, 'archive_recipe_plan.txt'))
#pickle_plan = os.path.join(self.working_directory, 'archive_recipe_plan.pickle')
#pm = PickleManager(pickle_plan)
#pm.save_variable(self.recipe_plan)
#pickle_options = os.path.join(self.working_directory, 'archive_input_options.pickle')
#pm = PickleManager(pickle_options)
#pm.save_variable(self.input_options)
#create the *.py input script
#ipc_obj = InputPythonCreator(input_options=self.input_options)
#ipc_filename = ipc_obj.write_script(self.working_directory, 'archive_input_options.py')
return
示例2: create_archive_files
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def create_archive_files(self):
"""Save off archive files.
Returns:
creates archive_input_options.txt
creates archive_recipe_plan.txt
"""
inputsave = MASTFile()
inputsave.data = repr(self.input_options)
inputsave.to_file(os.path.join(self.recdir, 'archive_input_options_%s.txt' % self.timestamp))
recipesave = MASTFile()
recipesave.data = repr(self.recipe_plan)
recipesave.to_file(os.path.join(self.recdir, 'archive_recipe_plan_%s.txt' % self.timestamp))
return
示例3: evaluate_ga_vasp_and_update
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def evaluate_ga_vasp_and_update(self, childname=""):
"""Evaluate the Genetic Algorithm VASP ingredient.
"""
raise NotImplementedError
childpath = os.path.join(os.path.dirname(self.keywords['name']), childname)
from mastlib.amy_ga_code import fitness_evaluation
from MAST.ingredients.checker import VaspChecker
from MAST.utility import MASTFile
dircontents = os.listdir(self.keywords['name'])
subfolders = list()
for diritem in dircontents:
fulldir = os.path.join(self.keywords['name'],diritem)
if os.path.isdir(fulldir) and diritem.isdigit():
subfolders.append(fulldir)
energylist = list()
structurelist = list()
for subfolder in subfolders:
mychecker = VaspChecker(subfolder, self.keywords['program_keys'], self.keywords['structure'])
mystructure = mychecker.get_final_structure_from_directory()
structurelist.append(mystructure)
myenergy = mychecker.get_energy_from_energy_file()
energylist.append(myenergy)
[fitoutput, fitstructure] = fitness_evaluation.evaluate(structurelist, energylist)
#If output is a structure or xyz file, could just write it directly.
fitfile = MASTFile()
fitfile.data = fitoutput
import time
timestamp = time.strftime("%Y%m%d_%H%M%S")
outputname = "my_output_%s" % timestamp
outputstrname = "my_structure_%s" % timestamp
fitfile.to_file(os.path.join(childpath, outputname))
fitstructure.write_file(os.path.join(childpath, outputstrname))
return " %s and %s written in %s" % (outputname, outputstrname, childpath)
示例4: status_change_recommended
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def status_change_recommended(self, iname):
"""Check if a status change is recommended for the ingredient,
as listed in the ingredient folder/change_status.txt.
Args:
iname <str>: ingredient name
Returns:
True if a status change was recommended, and
changes the status of the ingredient in self.ingredients.
False otherwise
"""
statuspath = os.path.join(self.working_directory, iname, "change_status.txt")
if not os.path.isfile(statuspath):
return False
statusfile = MASTFile(statuspath)
newdata=list()
changed=False
for sline in statusfile.data: #status:recommend:timestamp
if not "status_changed" in sline:
newstatus = sline.split(":")[0]
self.ingredients[iname]=newstatus
newline = sline + ":status_changed:" + time.asctime() + "\n"
self.logger.info("Status of %s changed to %s" % (iname, newstatus))
changed=True
newdata.append(newline)
else:
newdata.append(sline)
statusfile.data=list(newdata)
statusfile.to_file(statuspath)
return changed
示例5: test_inputpythoncreator
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def test_inputpythoncreator(self):
raise SkipTest
myip = InputParser(inputfile='mast.inp')
myoptions=myip.parse()
myipc = InputPythonCreator(input_options=myoptions)
mylines=myipc.print_input_options()
myfile = MASTFile()
myfile.data = mylines
myfile.to_file("./input_python_created")
#print mylines
self.assertTrue(filecmp.cmp("input_python_created","test_input_python_created"))
示例6: test_set_up_program_input
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def test_set_up_program_input(self):
mystrs=list()
pos=dict()
for posstr in ['00','01','02','03','04']:
pos[posstr] = pymatgen.io.vaspio.Poscar.from_file("structures/POSCAR_%s" % posstr)
mystrs.append(pos[posstr].structure)
kdict=dict()
kdict['mast_kpoints']=[3,3,3,"G"]
kdict['mast_xc']="pw91"
kdict['mast_neb_settings']=dict()
kdict['mast_neb_settings']['images']=3
kdict['mast_neb_settings']['image_structures'] = mystrs
myvcneb=VaspNEBChecker(name="childdir",program_keys=kdict)
myvcneb.set_up_program_input()
submitscript = MASTFile()
submitscript.data="Submission script placeholder."
submitscript.to_file("childdir/submit.sh")
ozholder = MASTFile()
ozholder.data="OSZICAR placeholder."
submitscript.to_file("childdir/00/OSZICAR")
submitscript.to_file("childdir/04/OSZICAR")
self.assertTrue(myvcneb.is_ready_to_run())
示例7: main
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def main():
recipe_name, script_head_dir = parse_arguments()
mast_scratch = dirutil.get_mast_scratch_path()
mymon = MASTMon()
my_recipe_plan = mymon.set_up_recipe_plan(os.path.join(mast_scratch, recipe_name), 1)
my_dag_contents=list()
for iname in my_recipe_plan.ingredients: #all JOB lines need to be at top
my_dag_contents.append("JOB %s submit.sh DIR %s\n" % (iname, iname))
for iname in my_recipe_plan.ingredients:
my_dag_contents.append("SCRIPT PRE %s %s/mast_do_setup.sh %s %s\n" % (iname, script_head_dir, recipe_name, iname))
my_dag_contents.append("SCRIPT POST %s %s/mast_check_is_complete.sh %s %s\n" % (iname, script_head_dir, recipe_name, iname))
my_dag_contents.append("RETRY %s 5\n" % iname)
ptc = list(my_recipe_plan.parents_to_check[iname])
for pname in ptc:
my_dag_contents.append("PARENT %s CHILD %s\n" % (pname, iname))
my_dag_file = MASTFile()
my_dag_file.data = my_dag_contents
my_dag_file.to_file(os.path.join(mast_scratch, recipe_name, "recipe.dag"))
#print_to_file(recipe_name, ing_name, "MAIN: is complete: %s" % is_complete)
return 0
示例8: test_parse
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def test_parse(self):
#ipfile='small_workflow_with_scaling.inp'
ipfile='phonon_with_neb.inp'
workdir = os.path.join(testdir,'workdir')
shutil.copy(os.path.join(testdir,ipfile),workdir)
input_file = os.path.join(workdir,ipfile)
parser_obj = InputParser(inputfile=input_file)
input_options = parser_obj.parse()
recipe_file_contents = input_options.get_item('recipe','recipe_file')
myrtp = RecipeTemplateParser(inputOptions=input_options,
working_directory=workdir,
templateFile=recipe_file_contents,
personalRecipe=input_file)
parsed_lines = myrtp.parse()
output_parsed = MASTFile()
output_parsed.data = list(parsed_lines)
output_parsed.to_file('workdir/personal_recipe_test_output.txt')
self.assertEquals(len(myrtp.chunks),5)
#mypr = MASTFile(pr)
#for line in mypr.data:
# print line.rstrip()
compare_pr = MASTFile(os.path.join(testdir,'compare','personal_recipe_test_output.txt'))
self.assertEquals(parsed_lines, compare_pr.data)
示例9: test___repr__
# 需要导入模块: from MAST.utility import MASTFile [as 别名]
# 或者: from MAST.utility.MASTFile import data [as 别名]
def test___repr__(self):
topmetad = MASTFile("files/top_metadata_single")
topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
topmetad.to_file("recipedir/metadata.txt")
metad = MASTFile("files/metadata_single")
metad.to_file("recipedir/ing1/metadata.txt")
metad = MASTFile("files/metadata_single")
metad.data.append("defect_label = labela\n")
metad.to_file("recipedir/ing2a/metadata.txt")
metad = MASTFile("files/metadata_single")
metad.data.append("defect_label = labelb\n")
metad.to_file("recipedir/ing2b/metadata.txt")
metad = MASTFile("files/metadata_single")
metad.to_file("recipedir/ing3/metadata.txt")
rp = RecipePlan("recipedir")
rp.ingredients['ing1'] = "I"
rp.ingredients['ing2a'] = "I"
rp.ingredients['ing2b'] = "I"
rp.ingredients['ing3'] = "I"
kdict=dict()
kdict['mast_program']='vasp'
kdict['mast_xc']='pw91'
kdict['mast_kpoints']=[1,2,3,"G"]
my_struc = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
rp.ingred_input_options['ing1']=dict()
rp.ingred_input_options['ing1']['name']="recipedir/ing1"
rp.ingred_input_options['ing1']['program_keys']=kdict
rp.ingred_input_options['ing1']['structure']=my_struc
rp.complete_methods['ing1']=[['complete_singlerun']]
rp.run_methods['ing1']=[['run_singlerun']]
rp.ready_methods['ing1']=[['ready_singlerun']]
rp.write_methods['ing1']=[['write_singlerun']]
rp.update_methods['ing1']=dict()
rp.update_methods['ing1']['ing2a']=[['give_structure']]
rp.update_methods['ing1']['ing2b']=[['give_structure']]
rp.ingred_input_options['ing2a']=dict()
rp.ingred_input_options['ing2a']['name']="recipedir/ing2a"
rp.ingred_input_options['ing2a']['program_keys']=kdict
rp.ingred_input_options['ing2a']['structure']=my_struc
rp.complete_methods['ing2a']=[['complete_singlerun']]
rp.ready_methods['ing2a']=[['ready_structure']]
rp.run_methods['ing2a']=[['run_singlerun']]
rp.write_methods['ing2a']=[['write_singlerun']]
rp.update_methods['ing2a']=dict()
rp.update_methods['ing2a']['ing3']=[['give_structure_and_restart_files']]
rp.ingred_input_options['ing2b']=dict()
rp.ingred_input_options['ing2b']['name']="recipedir/ing2b"
rp.ingred_input_options['ing2b']['program_keys']=kdict
rp.ingred_input_options['ing2b']['structure']=my_struc
rp.complete_methods['ing2b']=[['complete_singlerun']]
rp.ready_methods['ing2b']=[['ready_structure']]
rp.run_methods['ing2b']=[['run_singlerun']]
rp.write_methods['ing2b']=[['write_singlerun']]
rp.update_methods['ing2b']=dict()
rp.update_methods['ing2b']['ing3']=[['give_structure_and_restart_files']]
rp.ingred_input_options['ing3']=dict()
rp.ingred_input_options['ing3']['name']="recipedir/ing3"
rp.ingred_input_options['ing3']['program_keys']=kdict
rp.ingred_input_options['ing3']['structure']=my_struc
rp.complete_methods['ing3']=[['complete_singlerun']]
rp.ready_methods['ing3']=[['ready_structure']]
rp.run_methods['ing3']=[['run_singlerun']]
rp.write_methods['ing3']=[['write_singlerun']]
rp.update_methods['ing3']=dict()
rp.parents_to_check['ing3']=['ing2a','ing2b']
rp.parents_to_check['ing2a']=['ing1']
rp.parents_to_check['ing2b']=[]
rp.parents_to_check['ing1']=[]
mylines=rp.__repr__()
printed =MASTFile()
printed.data = mylines
printed.to_file("recipedir/printed.txt")
compare_print=MASTFile("files/printout.txt")
printedread = MASTFile("recipedir/printed.txt")
self.assertEqual(printedread.data, compare_print.data)