def __init__(self, restart=None, ignore_bad_restart_file=False, label='abinit', atoms=None, scratch=None, **kwargs): """Construct ABINIT-calculator object. Parameters ========== label: str Prefix to use for filenames (label.in, label.txt, ...). Default is 'abinit'. Examples ======== Use default values: >>> h = Atoms('H', calculator=Abinit(ecut=200, toldfe=0.001)) >>> h.center(vacuum=3.0) >>> e = h.get_potential_energy() """ self.scratch = scratch self.species = None self.ppp_list = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, atoms=None, restart=None, directory='', label='vasp', ignore_bad_restart_file=False, command=None, txt=None, **kwargs): # Initialize parameter dictionaries GenerateVaspInput.__init__(self) self._store_param_state() # Initialize an empty parameter state # Store atoms objects from vasprun.xml here, when an index is read # Format: self.xml_data[index] = atoms_object self.xml_data = {} label = os.path.join(directory, label) if restart is True: # We restart in the label directory restart = label FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command, **kwargs) # Overwrite the command from the FileIOCalculator init # as we might have other options than ASE_VASP_COMMAND # Also forces the user to have VASP installed first, # avoids issues with trying to e.g. get POTCAR's if not installed # XXX: Do we want to initialize this later? self.command = self.make_command(command) self.set_txt(txt) # Set the output txt stream
def __init__(self, restart=None, label=None, atoms=None, command=None, ignore_troublesome_keywords=None, check_keywords=True, _autofix_outputformats=False, **kwargs): """Create Octopus calculator. Label is always taken as a subdirectory. Restart is taken to be a label.""" # XXX support the specially defined ASE parameters, # "smear" etc. # We run oct-help to get a list of all keywords. # This makes us able to robustly construct the input file # in the face of changing octopus versions, and also of # early partial verification of user input. if check_keywords: try: octopus_keywords = get_octopus_keywords() except OSError as err: msg = ('Could not obtain Octopus keyword list from ' 'command oct-help: %s. Octopus not installed in ' 'accordance with expectations. ' 'Use check_octopus_keywords=False to override.' % err) raise OSError(msg) else: octopus_keywords = None self.octopus_keywords = octopus_keywords self._autofix_outputformats = _autofix_outputformats if restart is not None: if label is not None and restart != label: raise ValueError('restart and label are mutually exclusive ' 'or must at the very least coincide.') label = restart if label is None: label = 'ink-pool' if ignore_troublesome_keywords: trouble = set(self.troublesome_keywords) for keyword in ignore_troublesome_keywords: trouble.remove(keyword) self.troublesome_keywords = trouble self.kwargs = {} FileIOCalculator.__init__(self, restart=restart, ignore_bad_restart_file=False, label=label, atoms=atoms, command=command, **kwargs)
def __init__( self, label='ase_dftd3', # Label for dftd3 output files command=None, # Command for running dftd3 dft=None, # DFT calculator atoms=None, **kwargs): self.dft = None FileIOCalculator.__init__(self, restart=None, ignore_bad_restart_file=False, label=label, atoms=atoms, command=command, dft=dft, **kwargs) # If the user is running DFTD3 with another DFT calculator, such as # GPAW, the DFT portion of the calculation should take much longer. # If we only checked for a valid command in self.calculate, the DFT # calculation would run before we realize that we don't know how # to run dftd3. So, we check here at initialization time, to avoid # wasting the user's time. if self.command is None: raise RuntimeError("Don't know how to run DFTD3! Please " 'set the ASE_DFTD3_COMMAND environment ' 'variable, or explicitly pass the path ' 'to the dftd3 executable to the D3 calculator!') if isinstance(self.command, str): self.command = self.command.split()
def __init__(self, restart=None, ignore_bad_restart_file=False, label='dDMC', atoms=None, kpts=None, **kwargs): """Construct a dDMC calculator. """ self.default_parameters = dict(tag=label + '.tag', debugflag='down', geometry=label + '_ddmc.xyz', atomdata='notImportant', tagtype='dftbp', gradient='UP') FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if kpts != None: raise NotImplemented('dDMC cannot execute k-points computations') if restart != None: raise NotImplemented('No meaning to restart a dDMC computation') #indexes for the result file self.first_time = True self.index_energy = None
def __init__(self, restart=None, ignore_bad_restart_file=False, label='orca', atoms=None, **kwargs): """ ASE interface to ORCA 4 by Ragnar Bjornsson, Based on NWchem interface but simplified. Only supports energies and gradients (no dipole moments, orbital energies etc.) for now. For more ORCA-keyword flexibility, method/xc/basis etc. keywords are not used. Instead, two keywords: orcasimpleinput: str What you'd put after the "!" in an orca input file. orcablock: str What you'd put in the "% ... end"-blocks. are used to define the ORCA simple-inputline and the ORCA-block input. This allows for more flexible use of any ORCA method or keyword available in ORCA instead of hardcoding stuff. Point Charge IO functionality added by A. Dohn. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.pcpot = None
def __init__(self, label='mopac', restart=None, atoms=None, ignore_bad_restart_file=None,**kwargs): # set initial values self.default_parameters = dict( restart = 0, spin = 1, opt = False, functional = 'PM6', job_type = ['NOANCI','GRADIENTS', '1SCF'], relscf = 0.1, charge = 0 ) # save label and atoms self.label = label self.atoms = atoms FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) #the input file written only once # self.write_mopac_in(self.atoms) # initialize the results self.version = None self.energy_zero = None self.energy_free = None self.forces = None self.charges = None self.stress = None # initialize the results self.occupations = None
def __init__(self, restart=None, ignore_bad_restart_file=False, label='mopac', atoms=None, **kwargs): """Construct MOPAC-calculator object. Parameters: label: str Prefix for filenames (label.mop, label.out, ...) Examples: Use default values to do a single SCF calculation and print the forces (task='1SCF GRADIENTS') >>> from ase.build import molecule >>> from ase.calculators.mopac import MOPAC >>> atoms = molecule('O2') >>> atoms.calc = MOPAC(label='O2') >>> atoms.get_potential_energy() >>> eigs = atoms.calc.get_eigenvalues() >>> somos = atoms.calc.get_somo_levels() >>> h**o, lumo = atoms.calc.get_homo_lumo_levels() Use the internal geometry optimization of Mopac >>> atoms = molecule('H2') >>> atoms.calc = MOPAC(label='H2', task='GRADIENTS') >>> atoms.get_potential_energy() Read in and start from output file >>> atoms = MOPAC.read_atoms('H2') >>> atoms.calc.get_homo_lumo_levels() """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, label='ase_dftd3', # Label for dftd3 output files command=None, # Command for running dftd3 dft=None, # DFT calculator atoms=None, **kwargs): self.dft = None FileIOCalculator.__init__(self, restart=None, ignore_bad_restart_file=False, label=label, atoms=atoms, command=command, dft=dft, **kwargs) # If the user is running DFTD3 with another DFT calculator, such as # GPAW, the DFT portion of the calculation should take much longer. # If we only checked for a valid command in self.calculate, the DFT # calculation would run before we realize that we don't know how # to run dftd3. So, we check here at initialization time, to avoid # wasting the user's time. if self.command is None: raise RuntimeError("Don't know how to run DFTD3! Please " 'set the ASE_DFTD3_COMMAND environment ' 'variable, or explicitly pass the path ' 'to the dftd3 executable to the D3 calculator!') if isinstance(self.command, str): self.command = self.command.split()
def __init__(self, label='mopacddmc', atoms=None, mopacdict={}, ddmcdict={}, **kwargs): """Construct a MOPAC and a dDMC calculator. """ os.environ['ASE_MOPACDDMC_COMMAND'] = '' self.label = label self.mopacdict = mopacdict self.ddmcdict = ddmcdict ddmc_default_parameters = {} ddmc_default_parameters['param_a'] = 1.53014262236515 ddmc_default_parameters['param_b'] = 1.04216259309481 ddmc_default_parameters['param_c'] = 23.0 ddmc_default_parameters['param_d'] = 1.84166256639050 ddmc_default_parameters['dftype'] = 4 ddmc_default_parameters['tagtype'] = 'column' for param in ddmc_default_parameters.keys(): if not param in self.ddmcdict.keys(): self.ddmcdict[param] = ddmc_default_parameters[param] restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, label='gausddmc', atoms=None, gausdict={}, ddmcdict={}, **kwargs): """Construct a Gaussian and a dDMC calculator. """ os.environ['ASE_GAUSDDMC_COMMAND'] = '' self.label = label self.gausdict = gausdict self.ddmcdict = ddmcdict self.ddmcdict['param_a'] = 1.5880952 self.ddmcdict['param_b'] = 0.2533719 self.ddmcdict['param_c'] = 23.0 self.ddmcdict['dftype'] = 3 self.ddmcdict['tagtype'] = 'column' restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label=os.curdir, atoms=None, cubes=None, radmul=None, tier=None, **kwargs): """Construct FHI-aims calculator. The keyword arguments (kwargs) can be one of the ASE standard keywords: 'xc', 'kpts' and 'smearing' or any of FHI-aims' native keywords. Additional arguments: cubes: AimsCube object Cube file specification. radmul: int Set radial multiplier for the basis set of all atomic species. tier: int or array of ints Set basis set tier for all atomic species. """ try: self.outfilename = kwargs.get('run_command').split()[-1] except: self.outfilename = 'aims.out' FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command = kwargs.get('run_command'), **kwargs) self.cubes = cubes self.radmul = radmul self.tier = tier
def __init__(self, restart=None, ignore_bad_restart_file=False, label='cry', atoms=None, **kwargs): """Construct a crystal calculator. """ # default parameters self.default_parameters = dict(xc='HF', spinpol=False, guess=True, kpts=None, isp=1, basis='custom', smearing=None, otherkeys=[]) self.pcpot = None self.lines = None self.atoms = None self.atoms_input = None self.outfilename = 'cry.out' FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='orca', atoms=None, scratch=None, basisfile=None, extra=None, **kwargs): """Constructs a orca-calculator object. extra: any extra text to be included in the input card """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if restart is not None: try: self.read(restart) except ReadError: if ignore_bad_restart_file: self.reset() else: raise self.scratch = scratch self.basisfile = basisfile # store extra parameters self.extra = extra
def __init__( self, restart=None, ignore_bad_restart_file=FileIOCalculator._deprecated, label='ace', atoms=None, command=None, basisfile=None, **kwargs): FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command=command, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='dftb', atoms=None, kpts=None, **kwargs): """Construct a DFTB+ calculator. """ from ase.dft.kpoints import monkhorst_pack if 'DFTB_PREFIX' in os.environ: slako_dir = os.environ['DFTB_PREFIX'] else: slako_dir = './' self.default_parameters = dict( Hamiltonian_='DFTB', Driver_='ConjugateGradient', Driver_MaxForceComponent='1E-4', Driver_ConvergentForcesOnly='No', Driver_MaxSteps=0, Hamiltonian_SlaterKosterFiles_='Type2FileNames', Hamiltonian_SlaterKosterFiles_Prefix=slako_dir, Hamiltonian_SlaterKosterFiles_Separator='"-"', Hamiltonian_SlaterKosterFiles_Suffix='".skf"', Hamiltonian_SCC='No', Hamiltonian_Eigensolver='RelativelyRobust{}') FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.kpts = kpts # kpoint stuff by ase if self.kpts != None: mpgrid = kpts2mp(atoms, self.kpts) mp = monkhorst_pack(mpgrid) initkey = 'Hamiltonian_KPointsAndWeights' self.parameters[initkey + '_'] = '' for i, imp in enumerate(mp): key = initkey + '_empty' + str(i) self.parameters[key] = str(mp[i]).strip('[]') + ' 1.0' #the input file written only once if restart == None: self.write_dftb_in() else: if os.path.exists(restart): os.system('cp ' + restart + ' dftb_in.hsd') if not os.path.exists('dftb_in.hsd'): raise IOError('No file "dftb_in.hsd", use restart=None') #indexes for the result file self.first_time = True self.index_energy = None self.index_force_begin = None self.index_force_end = None self.index_charge_begin = None self.index_charge_end = None
def __init__(self, label='dftbddmc', atoms=None, dftbdict={}, ddmcdict={}, **kwargs): """Construct a DFTB+ and a dDMC calculator. """ os.environ['ASE_DFTBDDMC_COMMAND'] = '' self.label = label self.dftbdict = dftbdict self.ddmcdict = ddmcdict ddmc_default_parameters = {} ddmc_default_parameters['param_a'] = 1.85705835084132 ddmc_default_parameters['param_b'] = 1.01824853175310 ddmc_default_parameters['param_c'] = 23.0 ddmc_default_parameters['dftype'] = 3 ddmc_default_parameters['tagtype'] = 'dftbp' for param in ddmc_default_parameters.keys(): if not param in self.ddmcdict.keys(): self.ddmcdict[param] = ddmc_default_parameters[param] restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.dftb_calc = Dftb(label=self.label) self.ddmc_calc = dDMC(label=self.label)
def __init__(self, restart=None, ignore_bad_restart_file=FileIOCalculator._deprecated, label='cry', atoms=None, crys_pcc=False, **kwargs): """Construct a crystal calculator. """ # default parameters self.default_parameters = dict( xc='HF', spinpol=False, oldgrid=False, neigh=False, coarsegrid=False, guess=True, kpts=None, isp=1, basis='custom', smearing=None, otherkeys=[]) self.pcpot = None self.lines = None self.atoms = None self.crys_pcc = crys_pcc # True: Reads Coulomb Correction from file. self.atoms_input = None self.outfilename = 'cry.out' FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='g09', atoms=None, scratch=None, ioplist=list(), basisfile=None, **kwargs): """Constructs a Gaussian-calculator object. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if restart is not None: try: self.read(restart) except ReadError: if ignore_bad_restart_file: self.reset() else: raise self.ioplist = ioplist self.scratch = scratch self.basisfile = basisfile
def __init__(self, restart=None, ignore_bad_restart_file=False, label='g09', atoms=None, scratch=None, ioplist=list(), basisfile=None, extra=None, addsec=None, **kwargs): """Constructs a Gaussian-calculator object. extra: any extra text to be included in the input card addsec: a list of strings to be included as "additional sections" """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if restart is not None: try: self.read(restart) except ReadError: if ignore_bad_restart_file: self.reset() else: raise self.ioplist = ioplist self.scratch = scratch self.basisfile = basisfile # store extra parameters self.extra = extra self.addsec = addsec
def __init__(self, restart=None, ignore_bad_restart_file=False, label='abinit', atoms=None, scratch=None, **kwargs): """Construct ABINIT-calculator object. Parameters ========== label: str Prefix to use for filenames (label.in, label.txt, ...). Default is 'abinit'. Examples ======== Use default values: >>> h = Atoms('H', calculator=Abinit(ecut=200, toldfe=0.001)) >>> h.center(vacuum=3.0) >>> e = h.get_potential_energy() """ self.scratch = scratch self.species = [] self.ppp_list = [] FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='mopac', atoms=None, **kwargs): """Construct MOPAC-calculator object. Parameters ========== label: str Prefix for filenames (label.mop, label.out, ...) Examples ======== Use default values to do a single SCF calculation and print the forces (task='1SCF GRADIENTS') >>> from ase.build import molecule >>> from ase.calculators.mopac import MOPAC >>> atoms = molecule('O2') >>> atoms.calc = MOPAC(label='O2') >>> atoms.get_potential_energy() >>> eigs = atoms.calc.get_eigenvalues() >>> somos = atoms.calc.get_somo_levels() >>> h**o, lumo = atoms.calc.get_homo_lumo_levels() Use the internal geometry optimization of Mopac >>> atoms = molecule('H2') >>> atoms.calc = MOPAC(label='H2', task='GRADIENTS') >>> atoms.get_potential_energy() Read in and start from output file >>> atoms = MOPAC.read_atoms('H2') >>> atoms.calc.get_homo_lumo_levels() """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, label=None, directory=None, atoms=None, command=None, **kwargs): """Create Octopus calculator. Label is always taken as a subdirectory. Restart is taken to be a label.""" kwargs.pop('check_keywords', None) # Ignore old keywords kwargs.pop('troublesome_keywords', None) if label is not None: # restart mechanism in Calculator tends to set the label. #import warnings #warnings.warn('Please use directory=... instead of label') directory = label.rstrip('/') if directory is None: directory = 'ink-pool' self.kwargs = {} FileIOCalculator.__init__(self, restart=restart, directory=directory, atoms=atoms, command=command, **kwargs)
def __init__(self, label='mopacddmc', atoms=None, mopacdict={}, ddmcdict={}, **kwargs): """Construct a MOPAC and a dDMC calculator. """ os.environ['ASE_MOPACDDMC_COMMAND'] = '' self.label = label self.mopacdict = mopacdict self.ddmcdict = ddmcdict ddmc_default_parameters = {} ddmc_default_parameters['param_a'] = 1.53014262236515 ddmc_default_parameters['param_b'] = 1.04216259309481 ddmc_default_parameters['param_c'] = 23.0 ddmc_default_parameters['param_d'] = 1.84166256639050 ddmc_default_parameters['dftype'] = 4 ddmc_default_parameters['tagtype'] = 'column' for param in ddmc_default_parameters.keys(): if not param in self.ddmcdict.keys(): self.ddmcdict[param] = ddmc_default_parameters[param] restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=FileIOCalculator._deprecated, label='abinit', atoms=None, pp_paths=None, v8_legacy_format=None, **kwargs): """Construct ABINIT-calculator object. Parameters ========== label: str Prefix to use for filenames (label.in, label.txt, ...). Default is 'abinit'. Examples ======== Use default values: >>> h = Atoms('H', calculator=Abinit(ecut=200, toldfe=0.001)) >>> h.center(vacuum=3.0) >>> e = h.get_potential_energy() """ self.v8_legacy_format = v8_legacy_format self.pp_paths = pp_paths FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, label='dftbddmc', atoms=None, dftbdict={}, ddmcdict={}, **kwargs): """Construct a DFTB+ and a dDMC calculator. """ os.environ['ASE_DFTBDDMC_COMMAND'] = '' self.label = label self.dftbdict = dftbdict self.ddmcdict = ddmcdict ddmc_default_parameters = {} ddmc_default_parameters['param_a'] = 1.85705835084132 ddmc_default_parameters['param_b'] = 1.01824853175310 ddmc_default_parameters['param_c'] = 23.0 ddmc_default_parameters['dftype'] = 3 ddmc_default_parameters['tagtype'] = 'dftbp' for param in ddmc_default_parameters.keys(): if not param in self.ddmcdict.keys(): self.ddmcdict[param] = ddmc_default_parameters[param] restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.dftb_calc = Dftb(label=self.label) self.ddmc_calc = dDMC(label=self.label)
def __init__(self, atoms=None, restart=None, directory='', label='vasp', ignore_bad_restart_file=False, command=None, txt=None, **kwargs): # Initialize parameter dictionaries GenerateVaspInput.__init__(self) self._store_param_state() # Initialize an empty parameter state # Store atoms objects from vasprun.xml here - None => uninitialized self._xml_data = None label = os.path.join(directory, label) if restart is True: # We restart in the label directory restart = label FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command, **kwargs) self.command = command self.set_txt(txt) # Set the output txt stream
def __init__(self, restart=None, ignore_bad_restart_file=False, label='gamess_us', atoms=None, delold=False, **kwargs): """Construct GAMESS-US-calculator object.""" FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.delold = delold
def __init__(self, restart=None, label=None, directory=None, atoms=None, command=None, ignore_troublesome_keywords=None, check_keywords=True, **kwargs): """Create Octopus calculator. Label is always taken as a subdirectory. Restart is taken to be a label.""" # XXX support the specially defined ASE parameters, # "smear" etc. # We run oct-help to get a list of all keywords. # This makes us able to robustly construct the input file # in the face of changing octopus versions, and also of # early partial verification of user input. if check_keywords: try: octopus_keywords = get_octopus_keywords() except OSError as err: msg = ('Could not obtain Octopus keyword list from ' 'command oct-help: %s. Octopus not installed in ' 'accordance with expectations. ' 'Use check_octopus_keywords=False to override.' % err) raise OSError(msg) else: octopus_keywords = None self.octopus_keywords = octopus_keywords if label is not None: # restart mechanism in Calculator tends to set the label. #import warnings #warnings.warn('Please use directory=... instead of label') directory = label.rstrip('/') if directory is None: directory = 'ink-pool' if ignore_troublesome_keywords: trouble = set(self.troublesome_keywords) for keyword in ignore_troublesome_keywords: trouble.remove(keyword) self.troublesome_keywords = trouble self.kwargs = {} FileIOCalculator.__init__(self, restart=restart, ignore_bad_restart_file=False, directory=directory, atoms=atoms, command=command, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='dmol_calc/tmp', atoms=None, **kwargs): """ Construct DMol3 calculator. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) # tracks if DMol transformed coordinate system self.internal_transformation = False
def __init__(self, restart=None, label=None, atoms=None, command='octopus', ignore_troublesome_keywords=None, check_keywords=True, _autofix_outputformats=False, **kwargs): """Create Octopus calculator. Label is always taken as a subdirectory. Restart is taken to be a label.""" # XXX support the specially defined ASE parameters, # "smear" etc. # We run oct-help to get a list of all keywords. # This makes us able to robustly construct the input file # in the face of changing octopus versions, and also of # early partial verification of user input. if check_keywords: try: octopus_keywords = get_octopus_keywords() except OSError as err: msg = ('Could not obtain Octopus keyword list from ' 'command oct-help: %s. Octopus not installed in ' 'accordance with expectations. ' 'Use check_octopus_keywords=False to override.' % err) raise OSError(msg) else: octopus_keywords = None self.octopus_keywords = octopus_keywords self._autofix_outputformats = _autofix_outputformats if restart is not None: if label is not None and restart != label: raise ValueError('restart and label are mutually exclusive ' 'or must at the very least coincide.') label = restart if label is None: label = 'ink-pool' if ignore_troublesome_keywords: trouble = set(self.troublesome_keywords) for keyword in ignore_troublesome_keywords: trouble.remove(keyword) self.troublesome_keywords = trouble self.kwargs = {} FileIOCalculator.__init__(self, restart=restart, ignore_bad_restart_file=False, label=label, atoms=atoms, command=command, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label=None, atoms=None, **kwargs): FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='nwchem', atoms=None, **kwargs): """Construct NWchem-calculator object.""" FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='dftb', atoms=None, kpts=None, **kwargs): """Construct a DFTB+ calculator. """ from ase.dft.kpoints import monkhorst_pack if 'DFTB_PREFIX' in os.environ: slako_dir = os.environ['DFTB_PREFIX'] else: slako_dir = './' self.default_parameters = dict( Hamiltonian_='DFTB', Driver_='ConjugateGradient', Driver_MaxForceComponent='1E-4', Driver_ConvergentForcesOnly = 'No', Driver_MaxSteps=0, Hamiltonian_SlaterKosterFiles_='Type2FileNames', Hamiltonian_SlaterKosterFiles_Prefix=slako_dir, Hamiltonian_SlaterKosterFiles_Separator='"-"', Hamiltonian_SlaterKosterFiles_Suffix='".skf"', Hamiltonian_SCC = 'No', Hamiltonian_Eigensolver = 'RelativelyRobust{}' ) FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.kpts = kpts # kpoint stuff by ase if self.kpts != None: mpgrid = kpts2mp(atoms, self.kpts) mp = monkhorst_pack(mpgrid) initkey = 'Hamiltonian_KPointsAndWeights' self.parameters[initkey + '_'] = '' for i, imp in enumerate(mp): key = initkey + '_empty' + str(i) self.parameters[key] = str(mp[i]).strip('[]') + ' 1.0' #the input file written only once if restart == None: self.write_dftb_in() else: if os.path.exists(restart): os.system('cp ' + restart + ' dftb_in.hsd') if not os.path.exists('dftb_in.hsd'): raise IOError('No file "dftb_in.hsd", use restart=None') #indexes for the result file self.first_time = True self.index_energy = None self.index_force_begin = None self.index_force_end = None self.index_charge_begin = None self.index_charge_end = None
def __init__(self, **kwargs): parameters = self.get_default_parameters() functional, authors = parameters['xc'].split('.') parameters['xc'] = XC(functional=functional, authors=authors) parameters.update(kwargs) FileIOCalculator.__init__( self, **parameters )
def __init__(self, restart=None, ignore_bad_restart_file=False, label='abinit', atoms=None, scratch=None, **kwargs): """Construct ABINIT-calculator object. Parameters ========== label: str Prefix to use for filenames (label.in, label.txt, ...). Default is 'abinit'. xc: str Exchange-correlation functional. Must be one of LDA, PBE, revPBE, RPBE. kpts: list of three int Monkhost-Pack sampling. nbands: int Number of bands. For the values of occopt not equal to 0 or 2, nbands can be omitted. nstep: int Number of self-consistent field STEPS. width: float Fermi-distribution width in eV. Default is 0.04 Hartree. ecut: float Planewave cutoff energy in eV. No default. charge: float Total charge of the system. Default is 0. npulayit: int Number of old densities to use for Pulay mixing. diemix: float Mixing parameter between zero and one for density mixing. diemac: float Model DIElectric MACroscopic constant. The value of diemac should usually be bigger than 1.0d0, on physical grounds. If you let diemac to its default value, you might even never obtain the self-consistent convergence! Examples ======== Use default values: >>> h = Atoms('H', calculator=Abinit(ecut=200, toldfe=0.001)) >>> h.center(vacuum=3.0) >>> e = h.get_potential_energy() """ self.scratch = scratch self.species = None self.ppp_list = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, **kwds): """ Parameters ---------- All parameters: ``self.parameters.keys()`` label : str Basename of input and output files (e.g. 'pw') or a path to the calculation dir *including* the basename ('/path/to/pw', where directory='/path/to' and prefix='pw'). In ``self.command``, '<prefix>.in' and '<prefix>.out' are used. kpts : ASE k-points description Examples: ``3.5``, ``[6,6,4]``. If a float ``x`` is used, then it is the inverse of the k-grid spacing `h` per reciprocal axis as in ``kpts=pwtools.crys.kgrid(struct.cell, h=1/x)`` calc_name : str 'prefix' in PWscf pp : str or sequence Definition of the pseudopotential file and thus `xc`. If `pp` is a string (e.g. 'pbe-n-kjpaw_psl.0.1.UPF'), then the atom symbols are used to build the PP file name ``'<atom_symbol>.pbe-n-kjpaw_psl.0.1.UPF'`` for each atom type. Needs a file of that name in `pseudo_dir`. If `pp` is a list, e.g. ``['Al.pbe-n-kjpaw_psl.0.1.UPF', 'N.pbe-n-kjpaw_psl.0.1.UPF']``, then this is used for each atom type. outdir, pseudo_dir, ecutwfc, ecutrho, diagonalization, mixing_mode, mixing_beta, electron_maxstep, conv_thr : as in PWscf, see http://www.quantum-espresso.org/wp-content/uploads/Doc/INPUT_PW.html backup : bool make backup of old pw.in and pw.out if found, uses :func:`~pwtools.common.backup` """ self.init_params_from_input(kwds) FileIOCalculator.__init__(self, **kwds) # ASE keywords if self.smearing is not None: raise NotImplementedError("smearing not implemented") if self.xc is not None: raise Exception("please use the `pp` keyword instead of `xc`") self.ecutrho = 4.0 * self.ecutwfc if self.ecutrho is None else self.ecutrho # hard-coded <label>.(in|out) == <directory>/<prefix>.(in|out) self.infile = os.path.join(self.directory, self.prefix + '.in') self.outfile = os.path.join(self.directory, self.prefix + '.out') self.infile_templ_keys = list(self.parameters.keys()) + [ 'natoms', 'ntyp', 'atpos', 'atspec', 'cell', 'kpoints' ] assert self.pp is not None, "set pp" assert self.pseudo_dir is not None, "set pseudo_dir" assert self.outdir is not None, "set outdir" assert self.kpts is not None, "set kpts"
def __init__(self, restart=None, ignore_bad_restart_file=False, label='qchem', scratch=None, np=1, nt=1, pbs=False, basisfile=None, ecpfile=None, atoms=None, **kwargs): """ The scratch directory, number of processor and threads as well as a few other command line options can be set using the arguments explained below. The remaining kwargs are copied as options to the input file. The calculator will convert these options to lower case for storage and convert back to upper case (Q-Chem standard) when writting the input file. scratch: str path of the scratch directory np: int number of processors for the -np command line flag nt: int number of threads for the -nt command line flag pbs: boolean command line flag for pbs scheduler (see Q-Chem manual) basisfile: str path to file containing the basis. Use in combination with basis='gen' keyword argument. ecpfile: str path to file containing the effective core potential. Use in combination with ecp='gen' keyword argument. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) # Augment the command by various flags if pbs: self.command = 'qchem -pbs ' else: self.command = 'qchem ' if np != 1: self.command += '-np %d ' % np if nt != 1: self.command += '-nt %d ' % nt self.command += 'PREFIX.inp PREFIX.out' if scratch is not None: self.command += ' %s' % scratch self.basisfile = basisfile self.ecpfile = ecpfile
def __init__(self, restart=None, ignore_bad_restart_file=False, label='espresso', atoms=None, **kwargs): FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if atoms is not None: self.atoms = atoms self.atoms.calc = self self.calc = None
def __init__(self, restart=None, ignore_bad_restart_file=False, label=os.curdir, atoms=None, **kwargs): """Construct ELK calculator. The keyword arguments (kwargs) can be one of the ASE standard keywords: 'xc', 'kpts' and 'smearing' or any of ELK' native keywords. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label=None, command=None, atoms=None, **kwargs): FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command, **kwargs) self.species = [] self.species_cond = [] self.pseudos = [] self.restart = False self.prefix = label self.directory = '.'
def __init__(self, **kwds): """ Parameters ---------- All parameters: ``self.parameters.keys()`` label : str Basename of input and output files (e.g. 'pw') or a path to the calculation dir *including* the basename ('/path/to/pw', where directory='/path/to' and prefix='pw'). In ``self.command``, '<prefix>.in' and '<prefix>.out' are used. kpts : ASE k-points description Examples: ``3.5``, ``[6,6,4]``. If a float ``x`` is used, then it is the inverse of the k-grid spacing `h` per reciprocal axis as in ``kpts=pwtools.crys.kgrid(struct.cell, h=1/x)`` calc_name : str 'prefix' in PWscf pp : str or sequence Definition of the pseudopotential file and thus `xc`. If `pp` is a string (e.g. 'pbe-n-kjpaw_psl.0.1.UPF'), then the atom symbols are used to build the PP file name ``'<atom_symbol>.pbe-n-kjpaw_psl.0.1.UPF'`` for each atom type. Needs a file of that name in `pseudo_dir`. If `pp` is a list, e.g. ``['Al.pbe-n-kjpaw_psl.0.1.UPF', 'N.pbe-n-kjpaw_psl.0.1.UPF']``, then this is used for each atom type. outdir, pseudo_dir, ecutwfc, ecutrho, diagonalization, mixing_mode, mixing_beta, electron_maxstep, conv_thr : as in PWscf, see http://www.quantum-espresso.org/wp-content/uploads/Doc/INPUT_PW.html backup : bool make backup of old pw.in and pw.out if found, uses :func:`~pwtools.common.backup` """ self.init_params_from_input(kwds) FileIOCalculator.__init__(self, **kwds) # ASE keywords if self.smearing is not None: raise NotImplementedError("smearing not implemented") if self.xc is not None: raise StandardError("please use the `pp` keyword instead of `xc`") self.ecutrho = 4.0*self.ecutwfc if self.ecutrho is None else self.ecutrho # hard-coded <label>.(in|out) == <directory>/<prefix>.(in|out) self.infile = os.path.join(self.directory, self.prefix + '.in') self.outfile = os.path.join(self.directory, self.prefix + '.out') self.infile_templ_keys = self.parameters.keys() + ['natoms', 'ntyp', 'atpos', 'atspec', 'cell', 'kpoints'] assert self.pp is not None, "set pp" assert self.pseudo_dir is not None, "set pseudo_dir" assert self.outdir is not None, "set outdir" assert self.kpts is not None, "set kpts"
def __init__(self, restart=None, ignore_bad_restart_file=False, label='./openmx', atoms=None, command=None, mpi=None, pbs=None, **kwargs): # Initialize and put the default parameters. self.initialize_pbs(pbs) self.initialize_mpi(mpi) self.initialize_output_setting(**kwargs) FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='gulp', atoms=None, optimized=None, Gnorm=1000.0, steps=1000, conditions=None, **kwargs): """Construct GULP-calculator object.""" FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.optimized = optimized self.Gnorm = Gnorm self.steps = steps self.conditions = conditions self.library_check() self.atom_types = []
def __init__(self, label=None, atoms=None, wdir='./', restart=None, **kwargs): FileIOCalculator.__init__(self,label=label,atoms=atoms,command=None,**kwargs) self.label=label self.prefix=label self.wdir=wdir if restart : # Restart mode - prevent any write operations self.directory=restart self.restart=True else : self.directory=make_calc_dir(self.prefix,wdir) self.restart=False self.submited=False
def __init__(self, restart=None, ignore_bad_restart_file=False, label='g09', atoms=None, scratch=None, ioplist=list(), basisfile=None, **kwargs): """Constructs a Gaussian-calculator object. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.ioplist = ioplist self.scratch = scratch self.basisfile = basisfile
def __init__(self, **kwargs): """ASE interface to the deMon code. Parameters: label : str. relative path to the run directory atoms : The Atoms onject command : str. Command to run deMon. If not present the environment varable DEMON_COMMAND will be used restart : str. Relative path to ASE restart directory for parameters and atoms object and results basis_path : str. Relative path to the directory containing BASIS, AUXIS, ECPS, MCPS and AUGMENT ignore_bad_restart_file : bool. Ignore broken or missing ASE restart files By default, it is an error if the restart file is missing or broken. deMon_restart_path : str. Relative path to the deMon restart dir title : str. Title in the deMon input file. scftype : str. Type of scf forces : bool. If True a force calculation will be enforced. dipole : bool. If True a dipole calculation will be enforced xc : str. xc-functional guess : str. guess for initial density and wave functions print_out : str|list. Options for the printing in deMon basis : dict. Definition of basis sets. ecps : dict. Definition of ECPs. mcps : dict. Definition of MCPs. auxis : dict. Definition of AUXIS, augment : dict. Definition of AUGMENT. input_arguments: dict. Explicitly given input arguments. The key is the input keyword and the value is either a str, a list of str (will be written on the same line as the keyword), or a list of lists of str (first list is written on the first line, the others on following lines.) """ parameters = Parameters_deMon(**kwargs) # Setup the run command command = parameters['command'] if command is None: command = os.environ.get('DEMON_COMMAND') if command is None: mess = 'The "DEMON_COMMAND" environment is not defined.' raise ValueError(mess) else: parameters['command'] = command # Call the base class. FileIOCalculator.__init__( self, **parameters)
def __init__(self, label='mopacddmc', atoms=None, mopacdict={}, d3h4dict={}, **kwargs): """Construct a MOPAC and a dDMC calculator. """ os.environ['ASE_MOPACD3H4_COMMAND'] = '' self.label = label self.mopacdict = mopacdict self.d3h4dict = d3h4dict restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.mopac_calc = Mopac(label=self.label) self.d3h4_calc = D3H4(label=self.label)
def __init__(self, restart=None, ignore_bad_restart_file=False, label=os.curdir, atoms=None, cubes=None, **kwargs): """Construct FHI-aims calculator. The keyword arguments (kwargs) can be one of the ASE standard keywords: 'xc', 'kpts' and 'smearing' or any of FHI-aims' native keywords. Additional arguments: cubes: AimsCube object Cube file specification. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.cubes = cubes
def __init__(self, **kwds): """ Parameters ---------- All parameters: ``self.parameters.keys()`` """ self.init_params_from_input(kwds) FileIOCalculator.__init__(self, **kwds) self.infile_templ_keys = self.parameters.keys() + \ ['prefix', 'dumpfile', 'structfile'] self.infile = os.path.join(self.directory, self.prefix + '.in') self.outfile = os.path.join(self.directory, self.prefix + '.out') self.dumpfile = os.path.join(self.directory, self.prefix + '.out.dump') self.structfile = os.path.join(self.directory, self.prefix + '.struct') self.logfile = os.path.join(self.directory, 'log.lammps')
def __init__(self, label='dftbddmc', atoms=None, dftbdict={}, d3h4dict={}, **kwargs): """Construct a DFTB+ and a D3H4 calculator. """ os.environ['ASE_DFTBD3H4_COMMAND'] = '' self.label = label self.dftbdict = dftbdict self.d3h4dict = d3h4dict restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) self.dftb_calc = Dftb(label=self.label) self.d3h4_calc = D3H4(label=self.label)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='D3H4', atoms=None, kpts=None, **kwargs): """Construct a D3H4 calculator. """ self.default_parameters = dict( noH4 = False ) FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if kpts != None: raise NotImplemented ('D3H4 cannot execute k-points computations') if restart != None: raise NotImplemented ('No meaning to restart a D3H4 computation') #indexes for the result file self.first_time = True self.index_energy = None
def __init__(self, label=None, atoms=None, wdir='./', restart=None, **kwargs): FileIOCalculator.__init__(self,label=label,atoms=atoms,command=None,**kwargs) self.label=label self.prefix=label self.wdir=wdir if restart : # Restart mode - prevent any write operations self.directory=restart self.restart=True else : self.directory=make_calc_dir(self.prefix,wdir) self.restart=False self.submited=False # override parameters with environment variables if 'ESPRESSO_PP_PATH' in os.environ: self.parameters['pseudo_dir'] = os.environ['ESPRESSO_PP_PATH'] elif 'ESPRESSO_PSEUDO' in os.environ: self.parameters['pseudo_dir'] = os.environ['ESPRESSO_PSEUDO'] if 'ASE_ESPRESSO_COMMAND' in os.environ: pw_cmd=os.environ['ASE_ESPRESSO_COMMAND']
def __init__(self, label='gausddmc', atoms=None, gausdict={}, ddmcdict={}, **kwargs): """Construct a Gaussian and a dDMC calculator. """ os.environ['ASE_GAUSDDMC_COMMAND'] = '' self.label = label self.gausdict = gausdict self.ddmcdict = ddmcdict self.ddmcdict['param_a'] = 1.5880952 self.ddmcdict['param_b'] = 0.2533719 self.ddmcdict['param_c'] = 23.0 self.ddmcdict['dftype'] = 3 self.ddmcdict['tagtype'] = 'column' restart = None ignore_bad_restart_file = None FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs)
def __init__(self, restart=None, ignore_bad_restart_file=False, label='mymd', atoms=None, **kwargs): """Construct MyMD-calculator object. Parameters restart STRING Restart file providing atomic positions and velocities label STRING Label for files to be written by calculator. All files will be named <label>.<ext> where <ext> can be '.inp', '.rest', 'traj' atoms ase.atoms.Atoms Atoms on which to perform the calculation. """ # If restart is set, this method will call self.read(restart) # and take care of stuffing **kwarks into self.parameters FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if restart: self.parameters.restart = restart else: self.parameters.restart = self.label + '.rest'
def __init__(self, restart=None, ignore_bad_restart_file=False, label='g09', atoms=None, scratch=None, ioplist=list(), basisfile=None, **kwargs): """Constructs a Gaussian-calculator object. """ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, **kwargs) if restart is not None: try: self.read(restart) except ReadError: if ignore_bad_restart_file: self.reset() else: raise self.ioplist = ioplist self.scratch = scratch self.basisfile = basisfile