def get_next(self): """ Iterate the parameters and return them as a dictionary """ O = AbstractParticle.get_next(self) O["particle_model"] = "atoms" O["atomic_numbers"] = self.get_atomic_numbers() O["atomic_positions"] = self.get_atomic_positions() return O
def get_conf(self): """ Get configuration in form of a dictionary. Another identically configured ParticleAtoms instance can be initialised by: .. code-block:: python conf = P0.get_conf() # P0: already existing ParticleAtoms instance P1 = condor.ParticleAtoms(**conf) # P1: new ParticleMolcule instance with the same configuration as P0 """ conf = {} conf.update(AbstractParticle.get_conf()) conf["atomic_numbers"] = self.get_atomic_numbers() conf["atomic_positions"] = self.get_atomic_positions() return conf
class ParticleAtoms(AbstractParticle): """ Class for a particle model *Model:* Discrete atomic positions Kwargs: :pdb_filename (str): See :meth:`set_atoms_from_pdb_file` (default ``None``) :pdb_id (str): See :meth:`set_atoms_from_pdb_id` (default ``None``) :atomic_numbers (array): See :meth:`set_atoms_from_arrays` (default ``None``) :atomic_positions (array): See :meth:`set_atoms_from_arrays` (default ``None``) .. note:: The atomic positions have to be specified either by a ``pdb_filename`` or by ``atomic_numbers`` and ``atomic_positions``. :rotation_values (array): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_alignment` (default ``None``) :rotation_formalism (str): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_alignment` (default ``None``) :rotation_mode (str): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_alignment` (default ``None``) :number (float): Expectation value for the number of particles in the interaction volume. (defaukt ``1.``) :arrival (str): Arrival of particles at the interaction volume can be either ``'random'`` or ``'synchronised'``. If ``sync`` at every event the number of particles in the interaction volume equals the rounded value of ``number``. If ``'random'`` the number of particles is Poissonian and ``number`` is the expectation value. (default ``'synchronised'``) :position (array): See :class:`condor.particle.particle_abstract.AbstractParticle` (default ``None``) :position_variation (str): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_position_variation` (default ``None``) :position_spread (float): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_position_variation` (default ``None``) :position_variation_n (int): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_position_variation` (default ``None``) """ def __init__(self, pdb_filename=None, pdb_id=None, atomic_numbers=None, atomic_positions=None, rotation_values=None, rotation_formalism=None, rotation_mode="extrinsic", number=1., arrival="synchronised", position=None, position_variation=None, position_spread=None, position_variation_n=None): try: import spsim except Exception, e: print str(e) log_and_raise_error( logger, "Cannot import spsim module. This module is necessary to simulate diffraction for particle model of discrete atoms. Please install spsim from https://github.com/FilipeMaia/spsim and try again." ) return # Initialise base class AbstractParticle.__init__(self, rotation_values=rotation_values, rotation_formalism=rotation_formalism, rotation_mode=rotation_mode, number=number, arrival=arrival, position=position, position_variation=position_variation, position_spread=position_spread, position_variation_n=position_variation_n) self._atomic_positions = None self._atomic_numbers = None self._pdb_filename = None self._diameter_mean = None if pdb_filename is not None: log_debug(logger, "Attempt reading atoms from PDB file %s." % pdb_filename) if (pdb_id is not None or atomic_numbers is not None or atomic_positions is not None): log_and_raise_error( logger, "Atom configuration is ambiguous. pdb_filename is specified but also at least one of the following arguments: atomic_numbers, atomic_positions, pdb_id." ) sys.exit(1) elif not os.path.isfile(pdb_filename): log_and_raise_error( logger, "Cannot initialize particle model. PDB file %s does not exist." % pdb_filename) sys.exit(1) else: self.set_atoms_from_pdb_file(pdb_filename) elif pdb_id is not None: log_debug(logger, "Attempt fetching PDB entry of ID=%s" % pdb_id) if (atomic_numbers is not None or atomic_positions is not None): log_and_raise_error( logger, "Atom configuration is ambiguous. pdb_id is specified but also at least one of the following arguments: atomic_numbers, atomic_positions." ) sys.exit(1) else: self.set_atoms_from_pdb_id(pdb_id) elif atomic_numbers is not None and atomic_positions is not None: log_debug(logger, "Attempt reading atoms from lists/attays.") self.set_atoms_from_arrays(atomic_numbers, atomic_positions) else: log_and_raise_error( logger, "Cannot initialise particle model. The atomic positions have to be specified either by a pdb_filename, pdb_id or by atomic_numbers and atomic_positions." )