def test2_set_parameters(self): BB = BuildBulk(225, ['a'], ["Cu"]) atoms = BB.get_atoms(cell_parameters={'a': 5}) unit_cell_lengths = np.linalg.norm(atoms.cell, axis=1) assert np.all(np.isclose(unit_cell_lengths, 5 / np.sqrt(2))) atoms = BB.get_atoms(cell_parameters={'a': 5}, primitive_cell=False) unit_cell_lengths = np.linalg.norm(atoms.cell, axis=1) assert np.all(np.isclose(unit_cell_lengths, 5))
class TriSubmitTest(unittest.TestCase): def setUp(self): self.bb_iron = BuildBulk(225, ['a', 'c'], ['Mn', 'O']) atoms = self.bb_iron.get_atoms() self.submitter = TriSubmit(atoms, basepath_ext='tests', calc_parameters={'encut': 300, 'kspacing': 0.5}, ncpus=1, queue='small' ) self.pwd = os.getcwd() self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) def tearDown(self): os.chdir(self.pwd) shutil.rmtree(self.tempdir) def test_write_poscar(self): self.submitter.write_poscar('.') def test_write_model(self): self.submitter.write_model('.') with open('model.py') as f: model_text = f.readlines() def test_submit(self): self.submitter.submit_calculation()
def test6_all_spacegroups(self): images = [] spacegroups = range(195, 230) spacegroups, spacegroup_letters = get_wyckoff_letters(spacegroups) for sg in spacegroups: wyckoffs = spacegroup_letters[sg - 1][::-1][:5] species = metals[:len(wyckoffs)] print('----------', sg, '------------') BB = BuildBulk(sg, wyckoffs, species) atoms = BB.get_atoms(primitive_cell=False) PC = PrototypeClassification(atoms) prototype = PC.get_classification(include_parameters=False) if not prototype['spacegroup'] == sg: print(' change in spacegroup', sg, '----->', prototype['spacegroup']) print(' ', prototype['p_name']) else: assert prototype['wyckoffs'] == wyckoffs, \ '{} --->> {}'.format(prototype['wyckoffs'], wyckoffs)
def submit(self, prototype, ncpus=None, batch_no=None, calc_parameters=None, **kwargs): """Submit a calculation for a prototype, generating atoms with build_bulk and enumerator""" cell_parameters = prototype.get('parameters', None) BB = BuildBulk(prototype['spacegroup'], prototype['wyckoffs'], prototype['species'], ) atoms = BB.get_atoms(cell_parameters=cell_parameters) p_name = BB.get_prototype_name(prototype['species']) formula = atoms.get_chemical_formula() Sub = self.Submitter(atoms=atoms, ncpus=ncpus, calc_parameters=calc_parameters) Sub.submit_calculation() key_value_pairs = {'p_name': p_name, 'path': Sub.excpath, 'spacegroup': BB.spacegroup, 'wyckoffs': json.dumps(BB.wyckoffs), 'species': json.dumps(BB.species), 'ncpus': Sub.ncpus} key_value_pairs.update(kwargs) if batch_no: key_value_pairs.update({'batch': batch_no}) self.write_submission(key_value_pairs)
def test_write_model_nersc(self): bb_iron = BuildBulk(225, ['a', 'c'], ['Mn', 'O']) atoms = bb_iron.get_atoms() submitter = NerscSubmit(atoms, account='projectname', basepath='.') submitter.set_execution_path(strict_format=False) submitter.write_submission_files() submitter.write_submit_script()
def test_write_model(self): bb_iron = BuildBulk(225, ['a', 'c'], ['Mn', 'O']) atoms = bb_iron.get_atoms() self.submitter = TriSubmit(atoms, basepath_ext='tests') self.submitter.write_model('.')
def test1_no_parameters(self): BB = BuildBulk(225, ['a'], ["Cu"]) atoms = BB.get_atoms(proximity=1) unit_cell_lengths = np.linalg.norm(atoms.cell, axis=1) assert np.all(np.isclose(unit_cell_lengths, 2.629, rtol=0.01))
from protosearch.build_bulk.build_bulk import BuildBulk from ase.visualize import view BB = BuildBulk(47, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['Cu', 'Pd', 'Pt','Au', 'Cu', 'Pd', 'Pt','Au']) atoms = BB.get_atoms(proximity=1) view(atoms)