def read(self, filename = None): if filename != None: self._filename = filename self._data = pickle.load( open(self._filename, 'r') ) from qecalc.qetask.qeparser.qestructure import QEStructure self._structures = [] for config in self._data['config']: stru = QEStructure() stru.readStr(config) self._structures.append( stru )
def read(self, filename=None): if filename != None: self._filename = filename self._data = pickle.load(open(self._filename, 'r')) from qecalc.qetask.qeparser.qestructure import QEStructure self._structures = [] for config in self._data['config']: stru = QEStructure() stru.readStr(config) self._structures.append(stru)
def test_fileInit(self): from qecalc.qetask.qeparser.qestructure import QEStructure filename = os.path.join(testdata_dir, 'al_pw.in') stru = QEStructure(filename = filename) answer = """"Face Centered Cubic" cell: -3.85000000 0.00000000 3.85000000 0.00000000 3.85000000 3.85000000 -3.85000000 3.85000000 0.00000000 Atomic positions in units of lattice parametr "a": Al 0.00000000 0.00000000 0.00000000 Al 26.9800 Al.pz-vbc.UPF """ self.assertEqual(str(stru), answer) stru = QEStructure() filename = os.path.join(testdata_dir, 'PbTe.cif') stru.read(filename = filename, format = 'cif') answer ="""&SYSTEM ibrav = 0, celldm(1) = 1.889725989, ntyp = 2, nat = 8, / ATOMIC_SPECIES Pb2+ 0.0000 Te 0.0000 ATOMIC_POSITIONS (crystal) Pb2+ 0.50000000 0.50000000 0.50000000 Pb2+ 0.50000000 0.00000000 0.00000000 Pb2+ 0.00000000 0.50000000 0.00000000 Pb2+ 0.00000000 0.00000000 0.50000000 Te 0.00000000 0.00000000 0.00000000 Te 0.00000000 0.50000000 0.50000000 Te 0.50000000 0.00000000 0.50000000 Te 0.50000000 0.50000000 0.00000000 CELL_PARAMETERS (cubic) 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 """ #print stru.toString( stringConfig ) self.assertEqual(stru.toString( stringConfig ), answer )
def __init__(self, filename=None, config=None, type = 'pw', setting = None,\ parse = True): self._structure = QEStructure(self) self.kpoints = PWKpoints(self) # Boolean flag, if True, QEInput is updated on change of any property in # structure, lattice, or atom self.autoUpdate = True QESInput.__init__(self,filename, config, type = type, setting = setting,\ parse = parse)
def test_fileInit(self): from qecalc.qetask.qeparser.qestructure import QEStructure filename = os.path.join(testdata_dir, 'al_pw.in') stru = QEStructure(filename=filename) answer = """"Face Centered Cubic" cell: -3.85000000 0.00000000 3.85000000 0.00000000 3.85000000 3.85000000 -3.85000000 3.85000000 0.00000000 Atomic positions in units of lattice parametr "a": Al 0.00000000 0.00000000 0.00000000 Al 26.9800 Al.pz-vbc.UPF """ self.assertEqual(str(stru), answer) stru = QEStructure() filename = os.path.join(testdata_dir, 'PbTe.cif') stru.read(filename=filename, format='cif') answer = """&SYSTEM ibrav = 0, celldm(1) = 1.889725989, ntyp = 2, nat = 8, / ATOMIC_SPECIES Pb2+ 0.0000 Te 0.0000 ATOMIC_POSITIONS (crystal) Pb2+ 0.50000000 0.50000000 0.50000000 Pb2+ 0.50000000 0.00000000 0.00000000 Pb2+ 0.00000000 0.50000000 0.00000000 Pb2+ 0.00000000 0.00000000 0.50000000 Te 0.00000000 0.00000000 0.00000000 Te 0.00000000 0.50000000 0.50000000 Te 0.50000000 0.00000000 0.50000000 Te 0.50000000 0.50000000 0.00000000 CELL_PARAMETERS (cubic) 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 """ #print stru.toString( stringConfig ) self.assertEqual(stru.toString(stringConfig), answer)
def test_constructor(self): from qecalc.qetask.qeparser.qelattice import QELattice from qecalc.qetask.qeparser.qestructure import QEStructure from qecalc.qetask.qeparser.qeatom import QEAtom filename = os.path.join(testdata_dir, 'fev3_pwgeom.out') self.input.structure.read(filename, 'pwoutput') vmass = 50.94150 vpot = 'V_potential' femass = 55.84700 fepot = 'Fe_potential' at1 = QEAtom('V', [0., 0., 0.], vmass, vpot) at2 = QEAtom('V', [0.5, 0., 0.], vmass, vpot) at3 = QEAtom('V', [0., 0.5, 0.], vmass, vpot) at4 = QEAtom('V', [0., 0., 0.5], vmass, vpot) at5 = QEAtom('V', [0.5, 0.5, 0.], vmass, vpot) at6 = QEAtom('V', [0., 0.5, 0.5], vmass, vpot) at7 = QEAtom('V', [0.5, 0., 0.5], vmass, vpot) at8 = QEAtom('V', [0.5, 0.5, 0.5], vmass, vpot) at9 = QEAtom('V', [0.25, 0.25, 0.25], vmass, vpot) at10 = QEAtom('Fe', [0.75, 0.25, 0.25], femass, fepot) at11 = QEAtom('V', [0.75, 0.75, 0.25], vmass, vpot) at12 = QEAtom('Fe', [0.25, 0.75, 0.25], femass, fepot) at13 = QEAtom('Fe', [0.25, 0.25, 0.75], femass, fepot) at14 = QEAtom('V', [0.75, 0.25, 0.75], vmass, vpot) at15 = QEAtom('Fe', [0.75, 0.75, 0.75], femass, fepot) at16 = QEAtom('V', [0.25, 0.75, 0.75], vmass, vpot) lattice = QELattice(lattice=self.input.structure.lattice) #print lattice new_struct = QEStructure( [ at1, at2, at3, at4, at5, at6, at7, at8, at9, \ at10, at11, at12, at13, at14, at15, at16], \ lattice = lattice ) answer = """"Face Centered Cubic" cell: -5.50788176 0.00000000 5.50788176 0.00000000 5.50788176 5.50788176 -5.50788176 5.50788176 0.00000000 Atomic positions in crystal coordinates: V 0.00000000 0.00000000 0.00000000 V 0.50000000 0.00000000 0.00000000 V 0.00000000 0.50000000 0.00000000 V 0.00000000 0.00000000 0.50000000 V 0.50000000 0.50000000 0.00000000 V 0.00000000 0.50000000 0.50000000 V 0.50000000 0.00000000 0.50000000 V 0.50000000 0.50000000 0.50000000 V 0.25000000 0.25000000 0.25000000 Fe 0.75000000 0.25000000 0.25000000 V 0.75000000 0.75000000 0.25000000 Fe 0.25000000 0.75000000 0.25000000 Fe 0.25000000 0.25000000 0.75000000 V 0.75000000 0.25000000 0.75000000 Fe 0.75000000 0.75000000 0.75000000 V 0.25000000 0.75000000 0.75000000 V 50.9415 V_potential Fe 55.8470 Fe_potential """ self.assertEqual(str(new_struct), answer) new_struct = QEStructure(self.input.structure) # Check if the constructor messes _qeInput self.input.structure.lattice.a = 10 new_struct.lattice.a = 12 s1 = self.input.structure.toString() s2 = new_struct.toString() self.assertNotEqual(s1, s2)
def test_constructor(self): from qecalc.qetask.qeparser.qelattice import QELattice from qecalc.qetask.qeparser.qestructure import QEStructure from qecalc.qetask.qeparser.qeatom import QEAtom filename = os.path.join(testdata_dir, 'fev3_pwgeom.out') self.input.structure.read(filename, 'pwoutput') vmass = 50.94150 vpot = 'V_potential' femass = 55.84700 fepot = 'Fe_potential' at1 = QEAtom('V', [0., 0., 0.], vmass, vpot) at2 = QEAtom('V', [0.5, 0., 0.], vmass, vpot) at3 = QEAtom('V', [0., 0.5, 0.], vmass, vpot) at4 = QEAtom('V', [0., 0., 0.5], vmass, vpot) at5 = QEAtom('V', [0.5, 0.5, 0.], vmass, vpot) at6 = QEAtom('V', [0., 0.5, 0.5], vmass, vpot) at7 = QEAtom('V', [0.5, 0., 0.5], vmass, vpot) at8 = QEAtom('V', [0.5, 0.5, 0.5], vmass, vpot) at9 = QEAtom('V', [0.25, 0.25, 0.25], vmass, vpot) at10 = QEAtom('Fe', [0.75, 0.25, 0.25], femass, fepot) at11 = QEAtom('V', [0.75, 0.75, 0.25], vmass, vpot) at12 = QEAtom('Fe', [0.25, 0.75, 0.25], femass, fepot) at13 = QEAtom('Fe', [0.25, 0.25, 0.75], femass, fepot) at14 = QEAtom('V', [0.75, 0.25, 0.75], vmass, vpot) at15 = QEAtom('Fe', [0.75, 0.75, 0.75], femass, fepot) at16 = QEAtom('V', [0.25, 0.75, 0.75], vmass, vpot) lattice = QELattice(lattice = self.input.structure.lattice) #print lattice new_struct = QEStructure( [ at1, at2, at3, at4, at5, at6, at7, at8, at9, \ at10, at11, at12, at13, at14, at15, at16], \ lattice = lattice ) answer = """"Face Centered Cubic" cell: -5.50788176 0.00000000 5.50788176 0.00000000 5.50788176 5.50788176 -5.50788176 5.50788176 0.00000000 Atomic positions in crystal coordinates: V 0.00000000 0.00000000 0.00000000 V 0.50000000 0.00000000 0.00000000 V 0.00000000 0.50000000 0.00000000 V 0.00000000 0.00000000 0.50000000 V 0.50000000 0.50000000 0.00000000 V 0.00000000 0.50000000 0.50000000 V 0.50000000 0.00000000 0.50000000 V 0.50000000 0.50000000 0.50000000 V 0.25000000 0.25000000 0.25000000 Fe 0.75000000 0.25000000 0.25000000 V 0.75000000 0.75000000 0.25000000 Fe 0.25000000 0.75000000 0.25000000 Fe 0.25000000 0.25000000 0.75000000 V 0.75000000 0.25000000 0.75000000 Fe 0.75000000 0.75000000 0.75000000 V 0.25000000 0.75000000 0.75000000 V 50.9415 V_potential Fe 55.8470 Fe_potential """ self.assertEqual(str(new_struct), answer) new_struct = QEStructure(self.input.structure) # Check if the constructor messes _qeInput self.input.structure.lattice.a = 10 new_struct.lattice.a = 12 s1 = self.input.structure.toString() s2 = new_struct.toString() self.assertNotEqual(s1, s2)
def test_fileInit(self): from qecalc.qetask.qeparser.qestructure import QEStructure filename = os.path.join(testdata_dir, 'al_pw.in') stru = QEStructure(filename=filename) answer = """"Face Centered Cubic" cell: -3.85000000 0.00000000 3.85000000 0.00000000 3.85000000 3.85000000 -3.85000000 3.85000000 0.00000000 Atomic positions in units of lattice parametr "a": Al 0.00000000 0.00000000 0.00000000 Al 26.9800 Al.pz-vbc.UPF """ self.assertEqual(str(stru), answer) stru = QEStructure() filename = os.path.join(testdata_dir, 'PbTe.cif') stru.read(filename=filename, format='cif') answer = """&CONTROL calculation = 'scf', restart_mode = 'from_scratch', tstress = .true., tprnfor = .true., prefix = 'mgalb4', pseudo_dir = '/home/user/pslib', outdir = '/scratch/user', / &SYSTEM ibrav = 0, nbnd = 21, nspin = 1, occupations = 'smearing', degauss = 0.025, smearing = 'methfessel-paxton', ecutwfc = 64.0, ecutrho = 256.0, celldm(1) = 1.889725989, ntyp = 2, nat = 8, / &ELECTRONS conv_thr = 1.0d-10, mixing_beta = 0.4, / ATOMIC_SPECIES Pb2+ 0.0000 Te 0.0000 ATOMIC_POSITIONS (crystal) Pb2+ 0.50000000 0.50000000 0.50000000 Pb2+ 0.50000000 0.00000000 0.00000000 Pb2+ 0.00000000 0.50000000 0.00000000 Pb2+ 0.00000000 0.00000000 0.50000000 Te 0.00000000 0.00000000 0.00000000 Te 0.00000000 0.50000000 0.50000000 Te 0.50000000 0.00000000 0.50000000 Te 0.50000000 0.50000000 0.00000000 K_POINTS (automatic) 32 32 16 0 0 0 CELL_PARAMETERS (cubic) 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 """ #print stru.toString( stringConfig ) self.assertEqual(stru.toString(stringConfig), answer)
def test_fileInit(self): from qecalc.qetask.qeparser.qestructure import QEStructure filename = os.path.join(testdata_dir, 'al_pw.in') stru = QEStructure(filename = filename) answer = """"Face Centered Cubic" cell: -3.85000000 0.00000000 3.85000000 0.00000000 3.85000000 3.85000000 -3.85000000 3.85000000 0.00000000 Atomic positions in units of lattice parametr "a": Al 0.00000000 0.00000000 0.00000000 Al 26.9800 Al.pz-vbc.UPF """ self.assertEqual(str(stru), answer) stru = QEStructure() filename = os.path.join(testdata_dir, 'PbTe.cif') stru.read(filename = filename, format = 'cif') answer ="""&CONTROL calculation = 'scf', restart_mode = 'from_scratch', tstress = .true., tprnfor = .true., prefix = 'mgalb4', pseudo_dir = '/home/user/pslib', outdir = '/scratch/user', / &SYSTEM ibrav = 0, nbnd = 21, nspin = 1, occupations = 'smearing', degauss = 0.025, smearing = 'methfessel-paxton', ecutwfc = 64.0, ecutrho = 256.0, celldm(1) = 1.889725989, ntyp = 2, nat = 8, / &ELECTRONS conv_thr = 1.0d-10, mixing_beta = 0.4, / ATOMIC_SPECIES Pb2+ 0.0000 Te 0.0000 ATOMIC_POSITIONS (crystal) Pb2+ 0.50000000 0.50000000 0.50000000 Pb2+ 0.50000000 0.00000000 0.00000000 Pb2+ 0.00000000 0.50000000 0.00000000 Pb2+ 0.00000000 0.00000000 0.50000000 Te 0.00000000 0.00000000 0.00000000 Te 0.00000000 0.50000000 0.50000000 Te 0.50000000 0.00000000 0.50000000 Te 0.50000000 0.50000000 0.00000000 K_POINTS (automatic) 32 32 16 0 0 0 CELL_PARAMETERS (cubic) 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 0.00000000 0.00000000 0.00000000 6.46100000 """ #print stru.toString( stringConfig ) self.assertEqual(stru.toString( stringConfig ), answer )