rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
slab = hcp0001(surf, (n, m, opt.layers), a, a * opt.c_over_a, opt.vacuum) | if opt.c_over_a is None: c = np.sqrt(8 / 3.0) * a else: c = opt.c_over_a * a slab = hcp0001(surf, (n, m, opt.layers), a, c, opt.vacuum) | def build(): p = OptionParser(usage='%prog [options] [ads@]surf [output file]', version='%prog 0.1', description='Example ads/surf: CO@2x2Ru0001') p.add_option('-l', '--layers', type='int', default=4, help='Number of layers.') p.add_option('-v', '--vacuum', type='float', default=5.0, help='Vacuum.') p.add_option('-x',... |
self.packtext(vbox, "XXXX Bla bla bla.") | self.packtext(vbox, scaling_txt) | def __init__(self, gui): Simulation.__init__(self, gui) self.set_title("Homogeneous scaling") vbox = gtk.VBox() self.packtext(vbox, "XXXX Bla bla bla.") self.packimageselection(vbox, txt1="", txt2="") self.start_radio_nth.set_active(True) pack(vbox, gtk.Label("")) |
None, "Load optimal configuration (XXX broken!)") | None, "Load optimal configuration") | framedef = gtk.Frame("Deformation:") |
self.pars = Jacapo.default_input | self.pars = Jacapo.default_input.copy() | def __init__(self, nc='out.nc', outnc=None, debug=logging.WARN, stay_alive=False, **kwargs): ''' Initialize the Jacapo calculator |
if not os.path.isdir(base): | if not os.path.isdir(base) and base is not '': | def set_nc(self, nc='out.nc'): ''' set filename for the netcdf and text output for this calculation |
method, diagsperband=None): | method='eigsolve', diagsperband=2): | def set_electronic_minimization(self, method, diagsperband=None): '''set the eigensolver method |
def get_dipole_moment(self): | def get_dipole_moment(self,atoms=None): | def get_dipole_moment(self): ''' return dipole moment of unit cell |
atoms = self.get_atoms() | if atoms is None: atoms = self.get_atoms() | def get_dipole_moment(self): ''' return dipole moment of unit cell |
energies = np.arange(start, end+ediff, ediff) | energies = np.arange(start, end+ediff/2, ediff) | def get_spectrum(self, start=800, end=4000, npts=None, width=4, type='Gaussian', method='standard', direction='central'): """Get infrared spectrum. |
number_ionic_steps = nc.dimensions['number_ionic_steps'] frame = number_ionic_steps -1 | number_ionic_steps = nc.variables['TotalEnergy'].shape[0] frame = number_ionic_steps - 1 | def _set_frame_number(self, frame=None): '''set framenumber in the netcdf file |
if (np.array(listofkpts) == np.array(grid)).all(): | if grid.shape != listofkpts.shape: return True if (abs(listofkpts - grid) < 1e-6).all(): | def kpts_changed(calc, x): ''' check if kpt grid has changed. we have to take care to generate teh right k-points from x if needed. if a user provides (4,4,4) we need to generate the MP grid, etc... Since i changed the MP code in set_kpts, there is some incompatibility with old jacapo calculations and their MP grids.... |
newcell = np.dot(cell, np.array([a, b, c])) | newcell = np.dot(np.array([a, b, c]), cell) | def cut(atoms, a=(1,0,0), b=(0,1,0), c=(0,0,1), origo=(0,0,0), nlayers=None, extend=1.0, tolerance=0.001): """Cuts out a cell defined by *a*, *b*, *c* and *origo* from a sufficiently repeated copy of *atoms*. Typically, this function is used to create slabs of different sizes and orientations. The vectors *a*, *b* and... |
print 'UnitCell not found, there are probably no atoms in ',ncfile | def read_only_atoms(self,ncfile): '''read only the atoms from an existing netcdf file. Used to initialize a calculator from a ncfilename. | |
if "Atomic structure:" in line: | if "Atomic structure:" in line and not molecular_dynamics: | def read_aims_output(filename, index = -1): """ Import FHI-aims output files with all data available, i.e. relaxations, MD information, force information etc etc etc. """ from ase import Atoms, Atom from ase.calculators.singlepoint import SinglePointCalculator from ase.units import Ang, fs molecular_dynamics = False f... |
def __init__(self, stpmin=1e-8, xtol=1e-14): | def __init__(self, xtol=1e-14): | def __init__(self, stpmin=1e-8, xtol=1e-14): |
self.stpmin = stpmin | def __init__(self, stpmin=1e-8, xtol=1e-14): | |
maxstep=.2, c1=.23, c2=0.46, xtrapl=1.1, xtrapu=4., stpmax=50., args=()): | maxstep=.2, c1=.23, c2=0.46, xtrapl=1.1, xtrapu=4., stpmax=50., stpmin=1e-8, args=()): self.stpmin = stpmin | def _line_search(self, func, myfprime, xk, pk, gfk, old_fval, old_old_fval, maxstep=.2, c1=.23, c2=0.46, xtrapl=1.1, xtrapu=4., stpmax=50., args=()): |
stp,fval,derphi = self.step(alpha1, phi0, derphi0, c1, c2, | stp = self.step(alpha1, phi0, derphi0, c1, c2, | def _line_search(self, func, myfprime, xk, pk, gfk, old_fval, old_old_fval, maxstep=.2, c1=.23, c2=0.46, xtrapl=1.1, xtrapu=4., stpmax=50., args=()): |
return stp, self.fc, self.gc, fval, old_fval, gval | return stp, self.fc, self.gc, fval, old_fval, gval, self.no_update | def _line_search(self, func, myfprime, xk, pk, gfk, old_fval, old_old_fval, maxstep=.2, c1=.23, c2=0.46, xtrapl=1.1, xtrapu=4., stpmax=50., args=()): |
return stp, f, g | return stp | def step(self, stp, f, g, c1, c2, xtol, isave, dsave): if self.task[:5] == 'START': |
if stage == 1 and f <= fx and f > ftest: fm =f - stp * gtest fxm = fx - stx * gtest fym = fy - sty * gtest gm = g - gtest gxm = gx - gtest gym = gy - gtest | def step(self, stp, f, g, c1, c2, xtol, isave, dsave): if self.task[:5] == 'START': | |
stx, sty, stp, gx, fx, gy, fy= self.update (stx, fxm, gxm, sty, fym, gym, stp, fm, gm, self.bracket, stmin, stmax) fx = fxm + stx * gtest fy = fym + sty * gtest gx = gxm + gtest gy = gym + gtest else: stx, sty, stp, gx, fx, gy, fy= self.update(stx, fx, gx, sty, fy, gy, stp, f, g, self.bracket, stmin, stmax) | stx, sty, stp, gx, fx, gy, fy= self.update(stx, fx, gx, sty, fy, gy, stp, f, g, stmin, stmax) | def step(self, stp, f, g, c1, c2, xtol, isave, dsave): if self.task[:5] == 'START': |
return stp, f, g def update(self, stx, fx, gx, sty, fy, gy, stp, fp, gp, bracket, | return stp def update(self, stx, fx, gx, sty, fy, gy, stp, fp, gp, | def step(self, stp, f, g, c1, c2, xtol, isave, dsave): if self.task[:5] == 'START': |
def __init__(self, atoms, restart=None, logfile='-', maxstep=.2, | def __init__(self, atoms, restart='restart.pickle', logfile='-', maxstep=.2, | def __init__(self, atoms, restart=None, logfile='-', maxstep=.2, trajectory=None, c1=.23, c2=0.46, alpha=10., stpmax=50.): """Minimize a function using the BFGS algorithm. |
print p_size | def step(self, f): atoms = self.atoms r = atoms.get_positions() r = r.reshape(-1) g = -f.reshape(-1) / self.alpha #g = -f.reshape(-1) p0 = self.p self.update(r, g, self.r0, self.g0, p0) e = atoms.get_potential_energy() / self.alpha #e = self.func(r) | |
if not (self.alpha_k > 0 and abs(np.dot(g,p0))-abs(np.dot(g0,p0)) < 0): | if not ((self.alpha_k > 0 and abs(np.dot(g,p0))-abs(np.dot(g0,p0)) < 0) \ or self.replay): | def update(self, r, g, r0, g0, p0): self.I = eye(len(self.atoms) * 3, dtype=int) if self.H is None: self.H = eye(3 * len(self.atoms)) #self.H = eye(3 * len(self.atoms)) / self.alpha return else: dr = r - r0 dg = g - g0 if not (self.alpha_k > 0 and abs(np.dot(g,p0))-abs(np.dot(g0,p0)) < 0): return if self.no_update == T... |
self.H = None | def replay_trajectory(self, traj): """Initialize hessian from old trajectory.""" if isinstance(traj, str): from ase.io.trajectory import PickleTrajectory traj = PickleTrajectory(traj, 'r') self.H = None atoms = traj[0] r0 = atoms.get_positions().ravel() f0 = atoms.get_forces().ravel() for atoms in traj: r = atoms.get_p... | |
r0 = atoms.get_positions().ravel() f0 = atoms.get_forces().ravel() for atoms in traj: r = atoms.get_positions().ravel() f = atoms.get_forces().ravel() self.update(r, f, r0, f0) r0 = r f0 = f | r0 = None g0 = None for i in range(0, len(traj) - 1): r = traj[i].get_positions().ravel() g = - traj[i].get_forces().ravel() / self.alpha self.update(r, g, r0, g0, self.p) self.p = -np.dot(self.H,g) r0 = r.copy() g0 = g.copy() | def replay_trajectory(self, traj): """Initialize hessian from old trajectory.""" if isinstance(traj, str): from ase.io.trajectory import PickleTrajectory traj = PickleTrajectory(traj, 'r') self.H = None atoms = traj[0] r0 = atoms.get_positions().ravel() f0 = atoms.get_forces().ravel() for atoms in traj: r = atoms.get_p... |
self.f0 = f0 | self.g0 = g0 | def replay_trajectory(self, traj): """Initialize hessian from old trajectory.""" if isinstance(traj, str): from ase.io.trajectory import PickleTrajectory traj = PickleTrajectory(traj, 'r') self.H = None atoms = traj[0] r0 = atoms.get_positions().ravel() f0 = atoms.get_forces().ravel() for atoms in traj: r = atoms.get_p... |
self.pars[key] = kwargs[key] | if key == 'psp': self.psp[kwargs[key]['sym']] = kwargs[key]['psp'] else: self.pars[key] = kwargs[key] | def set(self, **kwargs): '''set a parameter |
key = option[0].get_text().strip() | key = option[0].get_text().split()[0].strip() | def set_attributes(self, *args): self.param = {} self.param["xc"] = self.xc.get_active_text() self.param["prec"] = self.prec.get_active_text() self.param["kpts"] = (int(self.kpts[0].value), int(self.kpts[1].value), int(self.kpts[2].value)) self.param["encut"] = self.encut.value self.param["ediff"] = self.ediff.value se... |
we have to take care to generate teh right k-points from x if | we have to take care to generate the right k-points from x if | def kpts_changed(calc, x): ''' check if kpt grid has changed. we have to take care to generate teh right k-points from x if needed. if a user provides (4,4,4) we need to generate the MP grid, etc... Since i changed the MP code in set_kpts, there is some incompatibility with old jacapo calculations and their MP grids.... |
return self.no == other.no and self.setting == other.setting | if isinstance(other, int): return self.no == other elif isinstance(other, str): return self.symbol == other else: return self.no == other.no and self.setting == other.setting | def __eq__(self, other): """Chech whether *self* and *other* refer to the same spacegroup number and setting.""" return self.no == other.no and self.setting == other.setting |
spg._centrosymmetric = bool(f.readline().split()[1]) | spg._centrosymmetric = bool(int(f.readline().split()[1])) | def _read_datafile_entry(spg, no, symbol, setting, f): """Read space group data from f to spg.""" spg._no = no spg._symbol = symbol.strip() spg._setting = setting spg._centrosymmetric = bool(f.readline().split()[1]) # primitive vectors f.readline() spg._scaled_primitive_cell = np.array([map(float, f.readline().split())... |
'keep' - ignore additional symmetry-equivalent positions 'replace' - reolace 'warn' - like 'keep', but issue an UserWarning 'error' - raises a SpacegroupValueError symprec : float | 'keep' ignore additional symmetry-equivalent positions 'replace' replace 'warn' like 'keep', but issue an UserWarning 'error' raises a SpacegroupValueError symprec: float | def equivalent_sites(self, scaled_positions, ondublicates='error', symprec=1e-3): """Returns the scaled positions and all their equivalent sites. |
suffix = os.path.splitext(filename)[1] | suffix = os.path.splitext(filename)[1][1:] | def save(self, action): chooser = gtk.FileChooserDialog( _('Save ...'), None, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) |
nc = netCDF(self.nc, 'r') sym = nc.variables['DynamicAtomSpecies'][:] symbols = [x.tostring().strip() for x in sym] for sym in symbols: vn = 'AtomProperty_%s' % sym if vn in nc.variables: var = nc.variables[vn] pspfile = var.PspotFile self.psp[sym] = pspfile nc.close() | try: nc = netCDF(self.nc, 'r') sym = nc.variables['DynamicAtomSpecies'][:] symbols = [x.tostring().strip() for x in sym] for sym in symbols: vn = 'AtomProperty_%s' % sym if vn in nc.variables: var = nc.variables[vn] pspfile = var.PspotFile self.psp[sym] = pspfile finally: nc.close() | def set_psp_database(self, xc=None): ''' get the xc-dependent psp database |
if nbands = None tje function returns with nothing done. At | if nbands = None the function returns with nothing done. At | def set_nbands(self, nbands=None): '''Set the number of bands. a few unoccupied bands are recommended. |
'number_IBZ_kpoints']) | 'number_IBZ_kpoints'], ncvars=[]) | def set_kpts(self, kpts): ''' set the kpt grid. |
print 'posmatch = ',posmatch print 'cellmatch = ',cellmatch,self.atoms.get_cell(),atoms.get_cell() print 'lenmatch = ',lenmatch | if self.debug > 1: print 'posmatch = ',posmatch,abs(a['positions'] - b['positions']) print 'cellmatch = ',cellmatch,self.atoms.get_cell(),atoms.get_cell() print 'lenmatch = ',lenmatch | def atoms_are_equal(self,atoms): ''' comparison of atoms to self.atoms using tolerances to account for float/double differences and float math. ''' TOL = 1.0e-6 #angstroms |
os.system('cp %s %s' % (self.nc,nc)) | base,f = os.path.split(nc) if not os.path.isdir(base): os.makedirs(base) status = os.system('cp %s %s' % (self.nc,nc)) if status != 0: raise Exception, 'Copying ncfile failed.' | def set_nc(self,nc='out.nc'): ''' set filename for the netcdf and text output for this calculation |
return sym | if sym == 'Off': return False elif sym == 'Maximum': return True else: raise Exception, 'Type of symmetry not recognized' | def get_symmetry(self): '''return the type of symmetry used''' nc = netCDF(self.nc,'r') if 'UseSymmetry' in nc.variables: sym = string.join(nc.variables['UseSymmetry'][:],'').strip() else: sym = None nc.close() return sym |
]) | ], ncvars=[]) | def set_fftgrid(self,soft=None,hard=None): ''' sets the dimensions of the FFT grid to be used |
else: value,position = None,None nc.close() return {'value':value,'position':position} | ed = {'value':value,'position':position} else: ed = None nc.close() return ed | def get_external_dipole(self): var = 'ExternalDipolePotential' nc = netCDF(self.get_nc(),'r') if var in nc.variables: v = nc.variables[var] value = v.getValue() if hasattr(v,'DipoleLayerPosition'): position = v.DipoleLayerPosition else: position = None else: value,position = None,None nc.close() return {'value':value,'... |
if self.debug > 0: print 'EXCEPTION HAPPENED in delete_NCATTR' | if self.debug > 0: print 'TypeError EXCEPTION HAPPENED in delete_NCATTR, you can ignore this message.' print 'variable name: %s' % v | def delete_ncattdimvar(self,ncf,ncattrs=[],ncdims=[],ncvars=[]): ''' helper function to delete attributes, dimensions and variables in a netcdffile |
elif x.shape[1] == 3 and (x.dtype[0:5] == 'float64'): | elif x.shape[1] == 3 and (str(x.dtype))[0:7] == 'float64': | def valid_kpts(self, x): if isinstance(x,str): return x in ['cc-6-1x1', 'cc-12-2x3', 'cc-18-sq3xsq3', 'cc-18-1x1', 'cc-54-sq3xsq3', 'cc-54-1x1', 'cc-162-1x1'] x = np.array(x) #empty arg is no good if x.shape == (): return False #monkhorst-pack elif x.shape == (3,) and ((x.dtype == 'int32') or (x.dtype == 'int64')): ret... |
print 'checking if em changed' | def electronic_minimization_changed(self, x): print 'checking if em changed' myx = self.get_electronic_minimization() print myx print x return False | |
print myx print x | for key in myx: if myx[key] != x[key]: print key, myx[key],' changed to ',x[key] return True | def electronic_minimization_changed(self, x): print 'checking if em changed' myx = self.get_electronic_minimization() print myx print x return False |
if x != self.get_symmetry: | if x != self.get_symmetry(): | def symmetry_changed(self,x): if x != self.get_symmetry: return True else: return False |
pos = np.dot(cell,spos.T).T | pos = np.dot(spos,cell) | def read_only_atoms(self,ncfile): '''read only the atoms from an existing netcdf file. Used to initialize a calculator from a ncfilename. |
ii = index_startswith(lines, 'Fermi Level') | ii = index_startswith(lines, 'Fermi Level:') | def index_startswith(lines, string): for i, line in enumerate(lines): if line.startswith(string): return i raise ValueError |
Parameters ---------- | Parameters: | def rotate_vectors(v1i, v2i, angle): """Rotate vectors *v1i* and *v2i* by *angle*""" cAng = cos(angle) sAng = sin(angle) v1o = v1i * cAng + v2i * sAng v2o = v2i * cAng - v1i * sAng # Ensure the length of the input and output vectors is equal return normalize(v1o) * norm(v1i), normalize(v2o) * norm(v2i) |
Notes ----- | Notes: | def rotate_vectors(v1i, v2i, angle): """Rotate vectors *v1i* and *v2i* by *angle*""" cAng = cos(angle) sAng = sin(angle) v1o = v1i * cAng + v2i * sAng v2o = v2i * cAng - v1i * sAng # Ensure the length of the input and output vectors is equal return normalize(v1o) * norm(v1i), normalize(v2o) * norm(v2i) |
References ---------- | References: | def rotate_vectors(v1i, v2i, angle): """Rotate vectors *v1i* and *v2i* by *angle*""" cAng = cos(angle) sAng = sin(angle) v1o = v1i * cAng + v2i * sAng v2o = v2i * cAng - v1i * sAng # Ensure the length of the input and output vectors is equal return normalize(v1o) * norm(v1i), normalize(v2o) * norm(v2i) |
*parameters* ------------ eigenmode_method: The name of the eigenmode search method. (string) f_rot_min: Size of the rotational force under which no rotation will be performed. (float) f_rot_max: Size of the rotational force under which only one rotation will be performed. (float) max_num_rot: Maximum number of rotatio... | Parameters: eigenmode_method: str The name of the eigenmode search method. f_rot_min: float Size of the rotational force under which no rotation will be performed. f_rot_max: float Size of the rotational force under which only one rotation will be performed. max_num_rot: int Maximum number of rotations per optimizer s... | def reset_all_counters(self): """Reset all counters.""" for key in self.counters.keys(): self.counters[key] = 0 |
'cg_rotation': True, | def reset_all_counters(self): """Reset all counters.""" for key in self.counters.keys(): self.counters[key] = 0 | |
Parameters ---------- | Parameters: | def log(self, parameter=None): """Log the parameters of the eigenmode search.""" if self.logfile is not None: if parameter is not None: l = 'DIM:CONTROL: Updated Parameter: %s = %s\n' % (parameter, str(self.get_parameter(parameter))) else: l = 'MINMODE:METHOD: Dimer\n' l += 'DIM:CONTROL: Search Parameters:\n' l += 'DIM... |
mask: A list of booleans as long as the number of atoms | mask: list of bool | def log(self, parameter=None): """Log the parameters of the eigenmode search.""" if self.logfile is not None: if parameter is not None: l = 'DIM:CONTROL: Updated Parameter: %s = %s\n' % (parameter, str(self.get_parameter(parameter))) else: l = 'MINMODE:METHOD: Dimer\n' l += 'DIM:CONTROL: Search Parameters:\n' l += 'DIM... |
References ---------- | References: | def log(self, parameter=None): """Log the parameters of the eigenmode search.""" if self.logfile is not None: if parameter is not None: l = 'DIM:CONTROL: Updated Parameter: %s = %s\n' % (parameter, str(self.get_parameter(parameter))) else: l = 'MINMODE:METHOD: Dimer\n' l += 'DIM:CONTROL: Search Parameters:\n' l += 'DIM... |
if self.frame is None or filename != filenames[self.frame]: | if self.frame is None or filename != filenames[self.frame] or filename is None: | def set_frame(self, frame=None, focus=False, init=False): if frame is None: frame = self.frame |
raise RuntimeError( "The combination %s for lorbit with %s for rwigs not supported to calculate magnetic moments" % (p['lorbit'], p['rwigs'])) | return None | def get_magnetic_moments(self, atoms): if self.int_params['lorbit']>=10 or self.list_params['rwigs']: self.update(atoms) return self.magnetic_moments else: raise RuntimeError( "The combination %s for lorbit with %s for rwigs not supported to calculate magnetic moments" % (p['lorbit'], p['rwigs'])) |
return isinstance(x, int) | if (isinstance(x, int) or isinstance(x,np.int32)): return True | def valid_int(x): return isinstance(x, int) |
return (isinstance(x, int) or isinstance(x, float)) | return ((isinstance(x, int) or isinstance(x,np.int32)) or isinstance(x, float)) | def valid_int_or_float(x): return (isinstance(x, int) or isinstance(x, float)) |
return x in ['cc-6-1x1', 'cc-12-2x3', 'cc-18-sq3xsq3', 'cc-18-1x1', 'cc-54-sq3xsq3', 'cc-54-1x1', 'cc-162-1x1'] | return x in ['cc6_1x1', 'cc12_2x3', 'cc18_sq3xsq3', 'cc18_1x1', 'cc54_sq3xsq3', 'cc54_1x1', 'cc162_sq3xsq3', 'cc162_1x1'] | def valid_kpts(x): if isinstance(x, str): return x in ['cc-6-1x1', 'cc-12-2x3', 'cc-18-sq3xsq3', 'cc-18-1x1', 'cc-54-sq3xsq3', 'cc-54-1x1', 'cc-162-1x1'] x = np.array(x) #empty arg is no good if x.shape == (): return False #monkhorst-pack elif x.shape == (3,) and ((x.dtype == 'int32') or (x.dtype == 'int64')): return T... |
return ldau, ldau_print, ldautype, ldau_luj | return ldau, ldauprint, ldautype, ldau_luj | def read_ldau(self): ldau_luj = None ldauprint = None ldau = None ldautype = None atomtypes = [] # read ldau parameters from outcar for line in open('OUTCAR'): if line.find('TITEL') != -1: # What atoms are present atomtypes.append(line.split()[3].split('_')[0].split('.')[0]) if line.find('LDAUTYPE') != -1: # Is this... |
except Exception, e: print e | except Exception: traceback.print_exc() | def run_test(get_atoms, get_calculator, name, fmax=0.05, steps=100, plot=True): plotter = Plotter(name, fmax) csvwriter = CSVWriter(name) for optimizer in optimizers: note = '' logname = name + '-' + optimizer atoms = get_atoms() atoms.set_calculator(get_calculator()) opt = get_optimizer(optimizer) relax = opt(atoms,... |
ok = chooser.run() if ok == gtk.RESPONSE_OK: | ok = chooser.run() == gtk.RESPONSE_OK if ok: | def open(self, button=None, filenames=None): if filenames == None: chooser = gtk.FileChooserDialog( _('Open ...'), None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) ok = chooser.run() if ok == gtk.RESPONSE_OK: filenames = [chooser.get_filename()] chooser.destr... |
self.read_outcar() | def restart_load(self): """Method which is called upon restart.""" # Try to read sorting file if os.path.isfile('ase-sort.dat'): self.sort = [] self.resort = [] file = open('ase-sort.dat', 'r') lines = file.readlines() file.close() for line in lines: data = line.split() self.sort.append(int(data[0])) self.resort.appen... | |
def get_number_of_bands(self): return self.nbands | def get_dipole_moment(self, atoms): """Returns total dipole moment of the system.""" self.update(atoms) return self.dipole | |
exec('from ase.dft.kpoints import %s' % kpts) listofkpts = eval(kpts) | exec('from ase.dft.kpoints import %s' % x) listofkpts = eval(x) | def kpts_changed(calc, x): ''' check if kpt grid has changed. we have to take care to generate teh right k-points from x if needed. if a user provides (4,4,4) we need to generate the MP grid, etc... Since i changed the MP code in set_kpts, there is some incompatibility with old jacapo calculations and their MP grids.... |
>>> | def cut(atoms, a=(1,0,0), b=(0,1,0), c=(0,0,1), origo=(0,0,0), nlayers=None, extend=1.0, tolerance=0.001): """Cuts out a cell defined by *a*, *b*, *c* and *origo* from a sufficiently repeated copy of *atoms*. Typically, this function is used to create slabs of different sizes and orientations. The vectors *a*, *b* and... | |
>>> | def stack(atoms1, atoms2, axis=2, cell=None, fix=0.5, maxstrain=0.5, distance=None): """Return a new Atoms instance with *atoms2* added to atoms1 along the given axis. Periodicity in all directions is ensured. The size of the final cell is determined by *cell*, except that the length alongh *axis* will be the sum of *... | |
return (x in ['Off', 'MediumLevel', 'HighLevel']) | return (x.strip() in ['Off', 'MediumLevel', 'HighLevel']) | def valid_ascii_debug(x): return (x in ['Off', 'MediumLevel', 'HighLevel']) |
if not valid_int(x[key]): | if not (valid_int(x[key]) or x[key] is None): | def valid_electronic_minimization(x): valid_keys = ['method', 'diagsperband'] for key in x: if key not in valid_keys: return False elif key == 'method': if x[key] not in ['resmin', 'eigsolve', 'rmm-diis']: return False elif key == 'diagsperband': if not valid_int(x[key]): return False return True |
""" % (str(effpid), str(effpid))) | """ % {'effpid':str(effpid)}) | def execute_external_dynamics(self, nc=None, txt=None, stoppfile='stop', stopprogram=None): ''' Implementation of the stay alive functionality with socket communication between dacapo and python. Known limitations: It is not possible to start 2 independent Dacapo calculators from the same python process, since the pyt... |
self.notify_vulnerable() | def new_atoms(self, atoms, init_magmom=False): "Set a new atoms object." self.notify_vulnerable() self.reset_tools_modes() rpt = getattr(self.images, 'repeat', None) self.images.repeat_images(np.ones(3, int)) self.images.initialize([atoms], init_magmom=init_magmom) self.frame = 0 # Prevent crashes self.images.repeat... | |
if len(symbols) == 1: | nads = len(symbols) if nads == 1: | def build(): p = OptionParser(usage='%prog [options] [ads@]surf [output file]', version='%prog 0.1', description='Example ads/surf: CO@2x2Ru0001') p.add_option('-l', '--layers', type='int', default=4, help='Number of layers.') p.add_option('-v', '--vacuum', type='float', default=5.0, help='Vacuum.') p.add_option('-x',... |
ads = molecules(ads) | ads = molecule(ads) | def build(): p = OptionParser(usage='%prog [options] [ads@]surf [output file]', version='%prog 0.1', description='Example ads/surf: CO@2x2Ru0001') p.add_option('-l', '--layers', type='int', default=4, help='Number of layers.') p.add_option('-v', '--vacuum', type='float', default=5.0, help='Vacuum.') p.add_option('-x',... |
y = ((R[:-1] - R[-1])**2).sum(1).min()**0.5 | y = ((R[:-nads] - R[-nads])**2).sum(1).min()**0.5 | def build(): p = OptionParser(usage='%prog [options] [ads@]surf [output file]', version='%prog 0.1', description='Example ads/surf: CO@2x2Ru0001') p.add_option('-l', '--layers', type='int', default=4, help='Number of layers.') p.add_option('-v', '--vacuum', type='float', default=5.0, help='Vacuum.') p.add_option('-x',... |
slab[-1].z += h | slab.positions[-nads:, 2] += h | def build(): p = OptionParser(usage='%prog [options] [ads@]surf [output file]', version='%prog 0.1', description='Example ads/surf: CO@2x2Ru0001') p.add_option('-l', '--layers', type='int', default=4, help='Number of layers.') p.add_option('-v', '--vacuum', type='float', default=5.0, help='Vacuum.') p.add_option('-x',... |
print >>sys.stderr, "AG INTERNAL ERROR: strange response in Save,", response | def save(self, action): chooser = gtk.FileChooserDialog( _('Save ...'), None, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) | |
self.forces = np.array(forces, float) self.stress = np.array(stress, float) self.magmoms = np.array(magmoms, float) | if forces is not None: forces = np.array(forces, float) self.forces = forces if stress is not None: stress = np.array(stress, float) self.stress = stress if magmoms is not None: magmoms = np.array(magmoms, float) self.magmoms = magmoms | def __init__(self, energy, forces, stress, magmoms, atoms): """Save energy, forces and stresses for the current configuration.""" self.energy = energy self.forces = np.array(forces, float) self.stress = np.array(stress, float) self.magmoms = np.array(magmoms, float) self.atoms = atoms.copy() |
"""MPI save print - prints only from master. | """MPI-safe print - prints only from master. | def parprint(*args, **kwargs): """MPI save print - prints only from master. Tries to adopt python 3 behaviour. """ if rank > 0: return defaults = { 'end' : '\n', 'file' : sys.stdout } for key in defaults: if not key in kwargs: kwargs[key] = defaults[key] for arg in args[:-1]: print >> kwargs['file'], arg, if len(args... |
:Valid kwargs: | Valid kwargs: | def __init__(self, nc='out.nc', outnc=None, debug=0, stay_alive=False, **kwargs): ''' Initialize the Jacapo calculator |
:Parameters: kpts : (n1,n2,n3) or [k1,k2,k3,...] or one of these | Parameters: kpts: (n1,n2,n3) or [k1,k2,k3,...] or one of these | def set_kpts(self, kpts): ''' set the kpt grid. |
cc6_1x1 cc12_2x3 cc18_sq3xsq3 cc18_1x1 cc54_sq3xsq3 cc54_1x1 cc162_sq3xsq3 cc162_1x1 | * cc6_1x1 * cc12_2x3 * cc18_sq3xsq3 * cc18_1x1 * cc54_sq3xsq3 * cc54_1x1 * cc162_sq3xsq3 * cc162_1x1 | def set_kpts(self, kpts): ''' set the kpt grid. |
n.append(nodes.inline(text=t)) | n.append(nodes.Text(t)) | def mol_role(role, rawtext, text, lineno, inliner, options={}, content=[]): n = [] t = '' while text: if text[0] == '_': n.append(nodes.inline(text=t)) t = '' n.append(nodes.subscript(text=text[1])) text = text[2:] else: t += text[0] text = text[1:] n.append(nodes.inline(text=t)) return n, [] |
This will calculate the forces for 6 displacements per atom ±x, ±y, ±z. Only those calculations that are not already done will be started. Be aware that an interrupted calculation may produce an empty file (ending with .pckl), which must be deleted before restarting the job. Otherwise the forces will not be calculated... | This will calculate the forces for 6 displacements per atom ±x, ±y, ±z. Only those calculations that are not already done will be started. Be aware that an interrupted calculation may produce an empty file (ending with .pckl), which must be deleted before restarting the job. Otherwise the forces will not be calculated ... | def run(self): """Run the vibration calculations. |
fd = open(filename, 'w') | def run(self): """Run the vibration calculations. | |
if "Updated atomic structure:" in line: | if "Updated atomic structure:" in line and not molecular_dynamics: | def read_aims_output(filename, index = -1): """ Import FHI-aims output files with all data available, i.e. relaxations, MD information, force information etc etc etc. """ from ase import Atoms, Atom from ase.calculators.singlepoint import SinglePointCalculator molecular_dynamics = False fd = open(filename, 'r') cell =... |
velocities += [[float(inp[1]),float(inp[2]),float(inp[3])]] if molecular_dynamics: atoms.set_velocities(velocities) | if "Atomic structure (and velocities)" in line: fd.readline() atoms = Atoms() velocities = [] for i in range(n_atoms): inp = fd.readline().split() atoms.append(Atom(inp[4],(inp[1],inp[2],inp[3]))) inp = fd.readline().split() velocities += [[float(inp[1])*v_unit,float(inp[2])*v_unit,float(inp[3])*v_unit]] atoms.set_velo... | def read_aims_output(filename, index = -1): """ Import FHI-aims output files with all data available, i.e. relaxations, MD information, force information etc etc etc. """ from ase import Atoms, Atom from ase.calculators.singlepoint import SinglePointCalculator molecular_dynamics = False fd = open(filename, 'r') cell =... |
print 1 | def read_aims(filename): """Import FHI-aims geometry type files. Reads unitcell, atom positions and constraints from a geometry.in file. """ from ase import Atoms from ase.constraints import FixAtoms, FixCartesian import numpy as np atoms = Atoms() fd = open(filename, 'r') lines = fd.readlines() fd.close() positions... | |
print self.resort | def restart_load(self): """Method which is called upon restart.""" # Try to read sorting file if os.path.isfile('ase-sort.dat'): self.sort = [] self.resort = [] file = open('ase-sort.dat', 'r') lines = file.readlines() file.close() for line in lines: data = line.split() self.sort.append(int(data[0])) self.resort.appen... | |
del(lines[0:6]) | if len(lines[5].split())==0: del(lines[0:6]) elif len(lines[4].split())==0: del(lines[0:5]) | def convert(self): lines = open(self.xdatcar).readlines() |
rc = beta * s0 * 0.5 * (sqrt(3) + sqrt(4)) | def initialize(self, atoms): self.par = {} self.rc = 0.0 self.numbers = atoms.get_atomic_numbers() for Z in self.numbers: if Z not in self.par: p = parameters[chemical_symbols[Z]] s0 = p[1] * Bohr eta2 = p[3] / Bohr kappa = p[4] / Bohr rc = beta * s0 * 0.5 * (sqrt(3) + sqrt(4)) x = eta2 * beta * s0 gamma1 = 0.0 gamma2 ... | |
x = n / (12 * (1.0 + exp(acut * (r - rc)))) | x = n / (12 * (1.0 + exp(self.acut * (r - rc)))) | def initialize(self, atoms): self.par = {} self.rc = 0.0 self.numbers = atoms.get_atomic_numbers() for Z in self.numbers: if Z not in self.par: p = parameters[chemical_symbols[Z]] s0 = p[1] * Bohr eta2 = p[3] / Bohr kappa = p[4] / Bohr rc = beta * s0 * 0.5 * (sqrt(3) + sqrt(4)) x = eta2 * beta * s0 gamma1 = 0.0 gamma2 ... |
if rc + 0.5 > self.rc: self.rc = rc + 0.5 | def initialize(self, atoms): self.par = {} self.rc = 0.0 self.numbers = atoms.get_atomic_numbers() for Z in self.numbers: if Z not in self.par: p = parameters[chemical_symbols[Z]] s0 = p[1] * Bohr eta2 = p[3] / Bohr kappa = p[4] / Bohr rc = beta * s0 * 0.5 * (sqrt(3) + sqrt(4)) x = eta2 * beta * s0 gamma1 = 0.0 gamma2 ... | |
self.ksi[s1][s2] = (p2['n0'] / p1['n0'] * exp(eta1 * (p1['s0'] - p2['s0']))) | self.ksi[s1][s2] = p2['n0'] / p1['n0'] | def initialize(self, atoms): self.par = {} self.rc = 0.0 self.numbers = atoms.get_atomic_numbers() for Z in self.numbers: if Z not in self.par: p = parameters[chemical_symbols[Z]] s0 = p[1] * Bohr eta2 = p[3] / Bohr kappa = p[4] / Bohr rc = beta * s0 * 0.5 * (sqrt(3) + sqrt(4)) x = eta2 * beta * s0 gamma1 = 0.0 gamma2 ... |
if r < p1['rc'] + 0.5: | if r < self.rc + 0.5: | def calculate(self, atoms): self.positions = atoms.get_positions().copy() self.cell = atoms.get_cell().copy() self.pbc = atoms.get_pbc().copy() icell = np.linalg.inv(self.cell) scaled = np.dot(self.positions, icell) N = [] for i in range(3): if self.pbc[i]: scaled[:, i] %= 1.0 v = icell[:, i] h = 1 / sqrt(np.dot(v, v)... |
self.interact1(a1, a2, d, r, p1, ksi[Z2]) | if self.fix_alloys: p2 = self.par[Z2] else: p2 = p1 self.interact1(a1, a2, d, r, p1, p2, ksi[Z2]) | def calculate(self, atoms): self.positions = atoms.get_positions().copy() self.cell = atoms.get_cell().copy() self.pbc = atoms.get_pbc().copy() icell = np.linalg.inv(self.cell) scaled = np.dot(self.positions, icell) N = [] for i in range(3): if self.pbc[i]: scaled[:, i] %= 1.0 v = icell[:, i] h = 1 / sqrt(np.dot(v, v)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.