def set(self, **kwargs): """ Function to set parameters. For now, this doesn't do anything as all parameters are within the model and descriptor. """ changed_parameters = Calculator.set(self, **kwargs) if len(changed_parameters) > 0: self.reset()
def set(self, **kwargs): """Function to set parameters. For now, this doesn't do anything as all parameters are within the model and descriptor. """ changed_parameters = Calculator.set(self, **kwargs) if len(changed_parameters) > 0: self.reset()
def set(self, **kwargs) -> dict: """Set new parameters to dftd4""" changed_parameters = Calculator.set(self, **kwargs) # Always reset the calculation if parameters change if changed_parameters: self.reset() return changed_parameters
def set(self, **kwargs): """Override the set function, to test for changes in the fingerprint Calculator. """ changed_parameters = {} if 'atoms' in kwargs: atoms = kwargs.pop('atoms') self.atoms = atoms # Resets results changed_parameters.update(Calculator.set(self, **kwargs))
def set(self, **kwargs): """Set parameters like set(key1=value1, key2=value2, ...).""" msg = '"%s" is not a known keyword for the CP2K calculator. ' \ 'To access all features of CP2K by means of an input ' \ 'template, consider using the "inp" keyword instead.' for key in kwargs: if key not in self.default_parameters: raise CalculatorSetupError(msg % key) changed_parameters = Calculator.set(self, **kwargs) if changed_parameters: self.reset()
def set(self, **kwargs): """Override the set function, to test for changes in the Vasp Calculator, then call the create_input.set() on remaining inputs for VASP specific keys. Allows for setting ``label``, ``directory`` and ``txt`` without resetting the results in the calculator. """ changed_parameters = {} if 'label' in kwargs: label = kwargs.pop('label') self.set_label(label) if 'directory' in kwargs: # If we explicitly set directory, overwrite the one in label. # XXX: Should we just raise an error here if clash? directory = kwargs.pop('directory') label = os.path.join(directory, self.prefix) self.set_label(label) if 'txt' in kwargs: txt = kwargs.pop('txt') self.set_txt(txt) if 'atoms' in kwargs: atoms = kwargs.pop('atoms') self.set_atoms(atoms) # Resets results if 'command' in kwargs: self.command = kwargs.pop('command') changed_parameters.update(Calculator.set(self, **kwargs)) # We might at some point add more to changed parameters, or use it if changed_parameters: self.results.clear() # We don't want to clear atoms if kwargs: # If we make any changes to Vasp input, we always reset GenerateVaspInput.set(self, **kwargs) self.results.clear()
def set(self, **kwargs): """Override the set function, to test for changes in the Vasp Calculator, then call the create_input.set() on remaining inputs for VASP specific keys. Allows for setting ``label``, ``directory`` and ``txt`` without resetting the results in the calculator. """ changed_parameters = {} if 'label' in kwargs: self.label = kwargs.pop('label') if 'directory' in kwargs: # str() call to deal with pathlib objects self.directory = str(kwargs.pop('directory')) if 'txt' in kwargs: self.txt = kwargs.pop('txt') if 'atoms' in kwargs: atoms = kwargs.pop('atoms') self.atoms = atoms # Resets results if 'command' in kwargs: self.command = kwargs.pop('command') changed_parameters.update(Calculator.set(self, **kwargs)) # We might at some point add more to changed parameters, or use it if changed_parameters: self.results.clear() # We don't want to clear atoms if kwargs: # If we make any changes to Vasp input, we always reset GenerateVaspInput.set(self, **kwargs) self.results.clear()
def set(self, **kwargs): """Set parameters like set(key1=value1, key2=value2, ...).""" changed_parameters = Calculator.set(self, **kwargs) if changed_parameters: self.reset()
def set(self, **kwargs): changed_parameters = Calculator.set(self, **kwargs) if changed_parameters: self.reset()
def set(self, **kwargs): """Change parameters for calculator. Examples:: calc.set(xc='PBE') calc.set(nbands=20, kpts=(4, 1, 1)) """ changed_parameters = Calculator.set(self, **kwargs) for key in ['setups', 'basis']: if key in changed_parameters: dct = changed_parameters[key] if isinstance(dct, dict) and None in dct: dct['default'] = dct.pop(None) warnings.warn('Please use {key}={dct}'.format(key=key, dct=dct)) # We need to handle txt early in order to get logging up and running: if 'txt' in changed_parameters: self.log.fd = changed_parameters.pop('txt') if not changed_parameters: return {} self.initialized = False self.scf = None self.results = {} self.log('Input parameters:') self.log.print_dict(changed_parameters) self.log() for key in changed_parameters: if key in ['eigensolver', 'convergence'] and self.wfs: self.wfs.set_eigensolver(None) if key in [ 'mixer', 'verbose', 'txt', 'hund', 'random', 'eigensolver', 'idiotproof' ]: continue if key in ['convergence', 'fixdensity', 'maxiter']: continue # More drastic changes: if self.wfs: self.wfs.set_orthonormalized(False) if key in ['external', 'xc', 'poissonsolver']: self.hamiltonian = None elif key in ['occupations', 'width']: pass elif key in ['charge', 'background_charge']: self.hamiltonian = None self.density = None self.wfs = None elif key in ['kpts', 'nbands', 'symmetry']: self.wfs = None elif key in ['h', 'gpts', 'setups', 'spinpol', 'dtype', 'mode']: self.density = None self.hamiltonian = None self.wfs = None elif key in ['basis']: self.wfs = None else: raise TypeError('Unknown keyword argument: "%s"' % key)
def set(self, **kwargs): """Change parameters for calculator. Examples:: calc.set(xc='PBE') calc.set(nbands=20, kpts=(4, 1, 1)) """ # Verify that keys are consistent with default ones. for key in kwargs: if key != 'txt' and key not in self.default_parameters: raise TypeError('Unknown GPAW parameter: {}'.format(key)) if key in ['convergence', 'symmetry', 'experimental' ] and isinstance(kwargs[key], dict): # For values that are dictionaries, verify subkeys, too. default_dict = self.default_parameters[key] for subkey in kwargs[key]: if subkey not in default_dict: allowed = ', '.join(list(default_dict.keys())) raise TypeError('Unknown subkeyword "{}" of keyword ' '"{}". Must be one of: {}'.format( subkey, key, allowed)) changed_parameters = Calculator.set(self, **kwargs) for key in ['setups', 'basis']: if key in changed_parameters: dct = changed_parameters[key] if isinstance(dct, dict) and None in dct: dct['default'] = dct.pop(None) warnings.warn('Please use {key}={dct}'.format(key=key, dct=dct)) # We need to handle txt early in order to get logging up and running: if 'txt' in changed_parameters: self.log.fd = changed_parameters.pop('txt') if not changed_parameters: return {} self.initialized = False self.scf = None self.results = {} self.log('Input parameters:') self.log.print_dict(changed_parameters) self.log() for key in changed_parameters: if key in ['eigensolver', 'convergence'] and self.wfs: self.wfs.set_eigensolver(None) if key in [ 'mixer', 'verbose', 'txt', 'hund', 'random', 'eigensolver', 'idiotproof' ]: continue if key in ['convergence', 'fixdensity', 'maxiter']: continue # Check nested arguments if key in ['experimental']: changed_parameters2 = changed_parameters[key] for key2 in changed_parameters2: if key2 in ['kpt_refine', 'magmoms', 'soc']: self.wfs = None elif key2 in ['reuse_wfs_method', 'niter_fixdensity']: continue else: raise TypeError('Unknown keyword argument:', key2) continue # More drastic changes: if self.wfs: self.wfs.set_orthonormalized(False) if key in ['external', 'xc', 'poissonsolver']: self.hamiltonian = None elif key in ['occupations', 'width']: pass elif key in ['charge', 'background_charge']: self.hamiltonian = None self.density = None self.wfs = None elif key in ['kpts', 'nbands', 'symmetry']: self.wfs = None elif key in ['h', 'gpts', 'setups', 'spinpol', 'dtype', 'mode']: self.density = None self.hamiltonian = None self.wfs = None elif key in ['basis']: self.wfs = None else: raise TypeError('Unknown keyword argument: "%s"' % key)
def set(self, **kwargs): '''Set parameters like set(key1=value1, key2=value2, ...).''' changed_parameters = Calculator.set(self, **kwargs) if(changed_parameters): self.reset()