def update_total_energy(line): if line.startswith("!"): total_energy = float(line.split()[4]) cuds_entity = sim.get(oclass=QE.TotalEnergy) if cuds_entity: cuds_entity[0].value = total_energy cuds_entity[0].unit = "Ry" else: sim.add(QE.TotalEnergy(value=total_energy, unit="Ry"))
def _update_cuds(self, sim): """Based off of the structure Args: sim (QE.Simulation or list of QE.Simulations): the simulation for which cuds should be updated. For calculations that require multiple simulations and aggregate the data (such as ev.x), please provide a list of strings. """ # Adds the output file that comes standard with most commands to the structure. sim.add( QE.Outfile(path=self._file_path_root + self._session._output_file))
def update_volume(line): if line.startswith(" unit-cell volume"): volume = float(line.split()[3]) cuds_entity = sim.get(oclass=QE.Cell)[0].get(oclass=QE.Volume) if cuds_entity: cuds_entity[0].value = volume cuds_entity[0].unit = "au^3" else: sim.get(oclass=QE.Cell)[0].add( QE.Volume(value=volume, unit="au^3"))
def update_force(line): if line.startswith(" atom "): atom = self.atomlist[int(line.split()[1]) - 1] force = [float(line.split()[j]) for j in range(6, 9)] cuds_entity = atom.get(oclass=QE.Force) if cuds_entity: cuds_entity[0].vector = force cuds_entity[0].unit = "N" else: atom.add(QE.Force(vector=force, unit="N"))
def update_pressure(line): if line.startswith(" Computing"): try: pressure = float(lines[i + 2].split()[5]) except: pressure = float(lines[i + 4].split()[5]) cuds_entity = sim.get(oclass=QE.Pressure) if cuds_entity: cuds_entity[0].value = pressure cuds_entity[0].unit = "kbar" else: sim.add(QE.Pressure(value=pressure, unit="kbar"))
def _update_cuds(self, sims): # Updates equilibrium volume and bulk modulus. with open(self._file_path_root + self._session._output_file, 'r') as file: lines = file.readlines() v0 = lines[1].split()[3] b0 = lines[1].split()[6][1:] for s in sims: volume_entity = s.get(oclass=QE.Cell)[0].get( oclass=QE.EquilibriumVolume) modulus_entity = s.get(oclass=QE.BulkModulus) if volume_entity: volume_entity[0].value = float(v0) volume_entity[0].unit = "au^3" else: s.get(oclass=QE.Cell)[0].add( QE.EquilibriumVolume(value=v0, unit="au^3")) if modulus_entity: modulus_entity[0].value = float(b0) volume_entity[0].unit = "kbar" else: s.add(QE.BulkModulus(value=b0, unit="kbar"))
def _update_cuds(self, sim): sim.add( QE.PhOut(path=self._file_path_root + self._session._output_file)) with open(self._file_path_root + self._session._output_file, 'r') as file: lines = file.readlines() beginend = [] for i, line in enumerate(lines): if line.startswith(" ****"): beginend.append(i) q_point = self.qpoints[0] for i in range(beginend[0] + 1, beginend[1]): freq = float(lines[i].split()[4]) modenum = int(lines[i].split()[2][:-1]) unit = lines[i].split()[5][1:-1] for mode in q_point.get(oclass=QE.Mode): if mode.number == modenum: if mode.get(oclass=QE.Frequency): mode.get(oclass=QE.Frequency)[0].value = freq mode.get(oclass=QE.Frequency)[0].unit = unit else: mode.add(QE.Frequency(value=freq, unit=unit)) super()._update_cuds(sim)
def update_stress_tensor(i, line): if line.startswith(" Computing"): try: stresslines = [lines[i + j] for j in range(3, 6)] raw_stress_tensor = [ float(j) for j in "".join(stresslines).split() ] except: stresslines = [lines[i + j] for j in range(5, 8)] raw_stress_tensor = [ float(j) for j in "".join(stresslines).split() ] stress_tensor_kbar = np.array(raw_stress_tensor).reshape( (3, 6))[:, 3:6] cuds_entity = sim.get(oclass=QE.StressTensor) if cuds_entity: cuds_entity[0].tensor2 = stress_tensor_kbar cuds_entity[0].unit = "kbar" else: sim.add( QE.StressTensor(tensor2=stress_tensor_kbar, unit="kbar"))
import numpy as np from osp.core.namespaces import QE from osp.core.utils import pretty_print from osp.wrappers.quantumespresso.qe_session import qeSession # Creates simulation sim = QE.Simulation() k = QE.K_POINTS(vector6 = (7, 7, 7, 0, 0, 0), unit = "") # Creates a cell, the element Silicon, a pseudopotential, two atoms and cell parameters SiCell = QE.Cell() Si = QE.Element(name = "Si") SiPseudo = QE.PSEUDOPOTENTIAL(path = "Si.pbe-n-kjpaw_psl.1.0.0.UPF") Si1 = QE.Atom() celldm1 = QE.Celldm1(value = 5.43070, unit = "au") # Adds pseudopotential and atoms to the element # Describes element's mass # Adds atoms and cell parameters to the cell # Positions the atoms Si.add(SiPseudo, Si1) Si.add(QE.Mass(value = 28.085, unit = "amu")) SiParams = QE.CellParams(tensor2 = [[0.5, 0.5, 0.], [0.5, 0., 0.5], [0., 0.5, 0.5]], unit = "") SiCell.add(Si1, SiParams) Si1.add(QE.Position(vector = (0, 0, 0), unit = "")) SiCell.add(celldm1) # Specifies the values of the cell parameters
import numpy as np from osp.core.namespaces import QE from osp.wrappers.quantumespresso.qe_session import qeSession from osp.core.utils import pretty_print sim = QE.Simulation() root = "" session = qeSession(root) quantum_espresso_wrapper = QE.QEWrapper(session = session) quantum_espresso_wrapper.add(sim) cell = QE.Cell() alat = 4. cellParams = cell.add(QE.CellParams(tensor2 = [[1., 0., 0.,], [0., 1., 0.,], [0., 0., 1.,]], unit = "alat")) cell.add(QE.Celldm1(value = alat, unit = "")) O = QE.Element(name = "O") Ba = QE.Element(name = "Ba") Ti = QE.Element(name = "Ti") O.add(QE.Mass(value = 15.999, unit = "amu")) Ba.add(QE.Mass(value = 137.327, unit = "amu")) Ti.add(QE.Mass(value = 47.867, unit = "amu")) O.add(QE.PSEUDOPOTENTIAL(path = "O.pbe-n-kjpaw_psl.1.0.0.UPF")) Ba.add(QE.PSEUDOPOTENTIAL(path = "Ba.pbe-spn-kjpaw_psl.1.0.0.UPF")) Ti.add(QE.PSEUDOPOTENTIAL(path = "Ti.pbe-spn-kjpaw_psl.1.0.0.UPF"))
def _update_cuds(self, sim): sim.add( QE.XSF(path=self._file_path_root + self._session._prefix + ".pp.xsf")) super()._update_cuds(sim)
def _update_cuds(self, sim): sim.add( QE.DosDat(path=self._file_path_root + self._session._prefix + ".dos.dat")) super()._update_cuds(sim)