def __init__(self, filename=None, create_indices=True, use_lock_file=False): self.filename = filename self.create_indices = create_indices if use_lock_file and isinstance(filename, str): self.lock = Lock(filename + '.lock', world=DummyMPI()) else: self.lock = None
def __init__(self, filename=None, create_indices=True, use_lock_file=False): self.filename = filename self.create_indices = create_indices if use_lock_file: self.lock = Lock(filename + '.lock', world=DummyMPI()) else: self.lock = None self.timestamp = None # timestamp form last write
def __init__(self, filename=None, create_indices=True, use_lock_file=False, serial=False): """Database object. serial: bool Let someone else handle parallelization. Default behavior is to interact with the database on the master only and then distribute results to all slaves. """ if isinstance(filename, basestring): filename = os.path.expanduser(filename) self.filename = filename self.create_indices = create_indices if use_lock_file and isinstance(filename, basestring): self.lock = Lock(filename + '.lock', world=DummyMPI()) else: self.lock = None self.serial = serial self._metadata = None # decription of columns and other stuff
def rank(): import sys # Check for special MPI-enabled Python interpreters: if '_gpaw' in sys.builtin_module_names: import _gpaw # http://wiki.fysik.dtu.dk/gpaw world = _gpaw.Communicator() elif '_asap' in sys.builtin_module_names: import _asap # http://wiki.fysik.dtu.dk/asap, can't import asap3.mpi here (import deadlock) world = _asap.Communicator() elif 'asapparallel3' in sys.modules: # Older version of Asap import asapparallel3 world = asapparallel3.Communicator() elif 'Scientific_mpi' in sys.modules: from Scientific.MPI import world elif 'mpi4py' in sys.modules: world = MPI4PY() else: from ase.parallel import DummyMPI world = DummyMPI() # This is a standard Python interpreter: rank = world.rank size = world.size return rank
om = 5 pz = Placzek( H2, KSSingles, gsname=gsname, exname=exname, verbose=True, ) ai = pz.absolute_intensity(omega=om)[-1] equal(ai, 301.659994669, 1e-3) # earlier obtained value i = pz.intensity(omega=om)[-1] equal(i, 7.87430831452e-05, 1e-11) # earlier obtained value pz.summary(omega=5, method='frederiksen') # parallel ------------------------ if world.size > 1 and world.rank == 0: # single core comm = DummyMPI() pzsi = Placzek( H2, KSSingles, gsname=gsname, exname=exname, comm=comm, verbose=True, ) isi = pzsi.intensity(omega=om)[-1] equal(isi, i, 1e-11)
def __init__(self, atoms, timestep, temperature_K, andersen_prob, fixcm=True, trajectory=None, logfile=None, loginterval=1, communicator=world, rng=random, append_trajectory=False): """" Parameters: atoms: Atoms object The list of atoms. timestep: float The time step in ASE time units. temperature_K: float The desired temperature, in Kelvin. andersen_prob: float A random collision probability, typically 1e-4 to 1e-1. With this probability atoms get assigned random velocity components. fixcm: bool (optional) If True, the position and momentum of the center of mass is kept unperturbed. Default: True. rng: RNG object (optional) Random number generator, by default numpy.random. Must have a random_sample method matching the signature of numpy.random.random_sample. logfile: file object or str (optional) If *logfile* is a string, a file with that name will be opened. Use '-' for stdout. trajectory: Trajectory object or str (optional) Attach trajectory object. If *trajectory* is a string a Trajectory will be constructed. Use *None* (the default) for no trajectory. communicator: MPI communicator (optional) Communicator used to distribute random numbers to all tasks. Default: ase.parallel.world. Set to None to disable communication. append_trajectory: bool (optional) Defaults to False, which causes the trajectory file to be overwritten each time the dynamics is restarted from scratch. If True, the new structures are appended to the trajectory file instead. The temperature is imposed by stochastic collisions with a heat bath that acts on velocity components of randomly chosen particles. The algorithm randomly decorrelates velocities, so dynamical properties like diffusion or viscosity cannot be properly measured. H. C. Andersen, J. Chem. Phys. 72 (4), 2384–2393 (1980) """ self.temp = units.kB * temperature_K self.andersen_prob = andersen_prob self.fix_com = fixcm self.rng = rng if communicator is None: communicator = DummyMPI() self.communicator = communicator MolecularDynamics.__init__(self, atoms, timestep, trajectory, logfile, loginterval, append_trajectory=append_trajectory)
def __init__(self, atoms, timestep, temperature=None, friction=None, fixcm=True, *, temperature_K=None, trajectory=None, logfile=None, loginterval=1, communicator=world, rng=None, append_trajectory=False): """ Parameters: atoms: Atoms object The list of atoms. timestep: float The time step in ASE time units. temperature: float (deprecated) The desired temperature, in electron volt. temperature_K: float The desired temperature, in Kelvin. friction: float A friction coefficient, typically 1e-4 to 1e-2. fixcm: bool (optional) If True, the position and momentum of the center of mass is kept unperturbed. Default: True. rng: RNG object (optional) Random number generator, by default numpy.random. Must have a standard_normal method matching the signature of numpy.random.standard_normal. logfile: file object or str (optional) If *logfile* is a string, a file with that name will be opened. Use '-' for stdout. trajectory: Trajectory object or str (optional) Attach trajectory object. If *trajectory* is a string a Trajectory will be constructed. Use *None* (the default) for no trajectory. communicator: MPI communicator (optional) Communicator used to distribute random numbers to all tasks. Default: ase.parallel.world. Set to None to disable communication. append_trajectory: bool (optional) Defaults to False, which causes the trajectory file to be overwritten each time the dynamics is restarted from scratch. If True, the new structures are appended to the trajectory file instead. The temperature and friction are normally scalars, but in principle one quantity per atom could be specified by giving an array. RATTLE constraints can be used with these propagators, see: E. V.-Eijnden, and G. Ciccotti, Chem. Phys. Lett. 429, 310 (2006) The propagator is Equation 23 (Eq. 39 if RATTLE constraints are used) of the above reference. That reference also contains another propagator in Eq. 21/34; but that propagator is not quasi-symplectic and gives a systematic offset in the temperature at large time steps. """ if friction is None: raise TypeError("Missing 'friction' argument.") self.fr = friction self.temp = units.kB * self._process_temperature(temperature, temperature_K, 'eV') self.fix_com = fixcm if communicator is None: communicator = DummyMPI() self.communicator = communicator if rng is None: self.rng = np.random else: self.rng = rng MolecularDynamics.__init__(self, atoms, timestep, trajectory, logfile, loginterval, append_trajectory=append_trajectory) self.updatevars()