pressomancy.object_classes package

Submodules

pressomancy.object_classes.crowder_class module

class pressomancy.object_classes.crowder_class.Crowder(*args, **kwargs)[source]

Bases: object

Class that contains quadriplex relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Quadriplex. Therefore many relevant parameters are class specific, not instance specific.

config = {'associated_objects': None, 'espresso_handle': None, 'n_parts': 1, 'sigma': 1, 'size': 1}
numInstances = 0
part_types = {'crowder': 5}
required_features = []
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'crowder': 5}

pressomancy.object_classes.filament_class module

class pressomancy.object_classes.filament_class.Filament(*args, **kwargs)[source]

Bases: object

Class that contains filament relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Filament. Therefore many relevant parameters are class specific, not instance specific.

add_anchors(type_key)[source]

Adds virtual particles at top and bottom of a particle with size sigma, as determined by the orientation vector calculated by the get_orientation_vec(). Logic firstly adds front anchors and then back anchors, so there is a consistent logic to track ids. Indices of particles added here are stored in self.fronts_indices/self.backs_indices attributes respectively.

None:

add_bending_potential(type_key, bond_handle)[source]
add_dipole_to_embedded_virt(type_name, dip_magnitude=1.0)[source]

Adds virtual particles to the center of each particle whose index is stored in self.realz_indices. It is critical that said virtuals do not have a director and have disabled rotation!

Parameters:

dip_magnitude – float | magnitude of the dipole moment to be asigned using the self.orientor unit vector. Default=1.

Returns:

None

add_dipole_to_type(type_name, dip_magnitude=1.0)[source]

Adds dipoles to real particles.

Parameters:

dip_magnitude – float | magnitude of the dipole moment to be asigned using the self.orientor unit vector. Default=1.

Returns:

None

bond_center_to_center(type_key)[source]
bond_nearest_part(type_key)[source]

Docstring for bond_nearest_part

Parameters:
  • self – Description

  • bond_handle – Description

  • type_key – Description

bond_overlapping_virtualz(crit=0.0)[source]

Adds FENE bonds between virtuals that fulfill the crit distance criterion. In general, it is assumed that there are virtual anchors placed using the add_anchors() method, and that between two real parts one can always found a pair of either overlapping virts or at a distance corresponding to the FENE_r0 parameter (crit param can be arbitrary but should be realated to the aforementioned params). Relies on np.isclose().

Returns:

None

bond_quadriplexes(mode='hinge')[source]

associated_objects contains monomer objects (assume quadriplex). We add cormer particles in each quadriplex pair to a pool of candidate corners: candidate1 and candidate2. Finaly checks which corner pairs have a distance self.params[‘sigma’]-2*fene_r0. Relies on np.isclose(). :return: None

center_filament()[source]
config = {'associated_objects': None, 'bond_handle': BondWrapper(<FeneBond({'r_0': 0, 'k': 0, 'd_r_max': 0})>), 'espresso_handle': None, 'n_parts': 1, 'sigma': 1, 'size': 1, 'spacing': None}
numInstances = 0
part_types = {'real': 1, 'to_be_magnetized': 3, 'virt': 2}
required_features = []
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'filament': 54}

pressomancy.object_classes.object_class module

class pressomancy.object_classes.object_class.ObjectConfigParams(**kwargs)[source]

Bases: dict

Configuration parameters for simulation objects.

The ObjectConfigParams class extends the dictionary to provide a structured way to manage configuration parameters for simulation objects. It includes validation and merging with class-level configurations.

common_keys

Common configuration keys with default values.

Type:

dict

validate_and_join(class_config):

Validates the current configuration against the class-level configuration and updates the instance with missing values from the class configuration.

common_keys = {'associated_objects': None, 'espresso_handle': None, 'n_parts': 1, 'sigma': 1, 'size': 1}
specify(**overrides)[source]

Create a new instance configuration based on the class-level configuration, with specified overrides applied.

Parameters:

overrides (dict) – Key-value pairs to override in the configuration.

Returns:

A new ObjectConfigParams instance with the specified overrides.

Return type:

ObjectConfigParams

class pressomancy.object_classes.object_class.Simulation_Object(name, bases, class_dict)[source]

Bases: type

Metaclass for simulation objects, providing attribute enforcement and shared methods.

The Simulation_Object metaclass ensures that all simulation object subclasses adhere to a defined structure by enforcing required attributes at both the class and instance levels. It also provides common methods for particle management and system interaction.

Key Features

  • Attribute enforcement: Ensures subclasses define required attributes with the correct types.

  • Default behavior: Assigns shared methods and default behaviors to instances.

  • Polymorphism: Facilitates seamless integration of different object classes into the simulation framework.

  • Object identification: Implements equality and hashing based on unique instance attributes.

Class-Level Required Attributes

  • required_featureslist

    List of required features for the simulation object.

  • numInstancesint

    Tracks the number of instances of the class.

  • part_typesPartDictSafe

    Dictionary-like object mapping particle types to their identifiers.

  • simulation_typeSinglePairDict

    A single key-value pair representing the type of simulation object.

Instance-Level Required Attributes

  • who_am_iint

    Unique identifier for the instance.

  • type_part_dictPartDictSafe

    Tracks particle handles grouped by type.

  • associated_objectslist

    List of related simulation objects, if any.

__init__(cls, name, bases, class_dict):

Enforces required class-level attributes during class creation.

__call__(cls, \*args, \*\*kwargs):

Creates a new instance and assigns default methods and attributes.

set_object(self, \*args, \*\*kwargs):

Abstract method for setting up simulation objects. Must be implemented by subclasses.

delete_owned_parts(self):

Deletes all particles owned by the object, including those in associated objects.

add_particle(self, type_name, pos, \*\*kwargs):

Adds a particle to the simulation box, ensuring it adheres to the object’s declared particle types.

change_part_type(self, particle, new_type_name):

Changes the type of an existing particle, updating all relevant tracking structures.

_eq(self, other):

Compares two instances for equality based on their who_am_i attribute.

_hash(self):

Generates a unique hash for the instance based on its class and who_am_i attribute.

_cusiter(self):

Returns an iterator for the object, enabling it to be used in loops.

Notes

  • This metaclass assumes a manager class (sys) is available for interacting with the simulation.

  • Subclasses must implement the set_object method to define their specific setup behavior.

add_particle(type_name, pos, **kwargs)[source]

Adds a particle to the simulation box.

Ensures the particle type is declared in part_types and updates tracking structures.

Parameters:
  • type_name (str) – Name of the particle type.

  • pos (iterable of shape (3,)) – Position of the particle in the simulation box.

  • **kwargs (dict) – Additional properties for the particle.

Returns:

Handle to the added particle.

Return type:

ParticleHandle

Raises:

AssertionError – If the particle type is not declared in part_types.

bond_owned_part_pair(p1, p2, bond_handle=None)[source]

Bonds the particle pair (p1,p2).

Adds the bond to the system if not already present.

Parameters:
  • p1 (espressomd.particle.ParticleHandle) – The partner particle to bond with.

  • p2 (espressomd.particle.ParticleHandle) – The partner particle to bond with.

change_part_type(particle, new_type_name)[source]

Changes the type of an existing particle.

Updates type_part_dict and modifies the particle’s type in the simulation.

Parameters:
  • particle (ParticleHandle) – Handle to the particle being modified.

  • new_type_name (str) – Name of the new particle type.

Raises:

AssertionError – If the new type is not declared in part_types.

delete_owned_parts()[source]

Deletes all particles owned by the object and any associated objects.

Iterates through type_part_dict to remove particles from the simulation. If associated_objects is defined, recursively deletes their owned particles.

get_owned_part()[source]

Returns a tuple: - tot_part: a flat list of all particle handles. - particle_chains: a list (same length as tot_part) where each element

is a list of (class_name, who_am_i) tuples representing the chain of objects from ‘self’ to the object that directly holds the particle.

set_object(*args, **kwargs)[source]

Abstract method for setting up simulation objects. Must be implemented by subclasses.

Raises:

NotImplementedError – If the method is not overridden by a subclass.

pressomancy.object_classes.object_class.generic_modify_system_attribute(self, clas_self, attribute_name, action)[source]
pressomancy.object_classes.object_class.generic_type_exception(name, attribute_name, expected_type)
pressomancy.object_classes.object_class.generic_type_exception_inst(name, attribute_name, expected_type)
pressomancy.object_classes.object_class.helper_set_attribute(instance, attr_name, target)[source]

pressomancy.object_classes.otp_molecule_class module

class pressomancy.object_classes.otp_molecule_class.OTP(*args, **kwargs)[source]

Bases: object

Class that contains OTP relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a OTP. Therefore many relevant parameters are class specific, not instance specific.

config = {'associated_objects': None, 'espresso_handle': None, 'long_side': 0.7191944807239401, 'n_parts': 3, 'rig_bond_long': BondWrapper(<RigidBond({'ptol': 1e-12, 'vtol': 1e-12, 'r': 0.7191944807239401})>), 'rig_bond_short': BondWrapper(<RigidBond({'ptol': 1e-12, 'vtol': 1e-12, 'r': 0.483})>), 'sigma': 0.483, 'size': 1}
numInstances = 0
part_types = {'otp': 6}
required_features = []
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. When the StopIteration except is caught Filament.last_index_used += Filament.n_parts . Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'otp': 6}

pressomancy.object_classes.quadriplex_class module

class pressomancy.object_classes.quadriplex_class.Quadriplex(*args, **kwargs)[source]

Bases: object

Class that contains quadriplex relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Quadriplex. Therefore many relevant parameters are class specific, not instance specific.

add_bending_potential(bending_potential_handle)[source]
add_patches_triples()[source]
bond_quartets_center_to_center()[source]
bond_quartets_corner_to_corner()[source]
config = {'associated_objects': None, 'bond_handle': BondWrapper(<FeneBond({'r_0': 0, 'k': 0, 'd_r_max': 0})>), 'bonding_mode': 'ftf', 'espresso_handle': None, 'n_parts': 3, 'sigma': 1, 'size': 6.0}
mark_covalent_bonds(part_type=666)[source]
numInstances = 0
part_types = {}
required_features = []
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'quadriplex': 22}
class pressomancy.object_classes.quadriplex_class.Quartet(*args, **kwargs)[source]

Bases: object

Class that contains quartet relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Quartet. Therefore many relevant parameters are class specific, not instance specific.

config = {'associated_objects': None, 'bond_handle': BondWrapper(<FeneBond({'r_0': 0, 'k': 0, 'd_r_max': 0})>), 'espresso_handle': None, 'n_parts': 25, 'sigma': 1, 'size': 1, 'type': 'solid'}
mark_covalent_corner(part_type=666)[source]
numInstances = 0
part_types = {'real': 1, 'virt': 2}
required_features = []
set_object(pos, ori, triplet=None)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part. Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'quartet': 11}

pressomancy.object_classes.raspberry_sphere module

class pressomancy.object_classes.raspberry_sphere.RaspberrySphere(*args, **kwargs)[source]

Bases: object

Class that contains relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Quadriplex. Therefore many relevant parameters are class specific, not instance specific.

config = {'associated_objects': None, 'espresso_handle': None, 'n_parts': 154, 'sigma': 1, 'size': 1}
numInstances = 0
part_types = {'real': 1, 'virt': 2}
required_features = []
set_hydrod_props(rot_inertia, mass)[source]
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'raspberry': 69}

pressomancy.object_classes.stoner_wohlfarth_part module

class pressomancy.object_classes.stoner_wohlfarth_part.SWPart(*args, **kwargs)[source]

Bases: object

Class that contains quadriplex relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Quadriplex. Therefore many relevant parameters are class specific, not instance specific.

config = {'HK_inv': 0.175, 'associated_objects': None, 'dipm': 1.75, 'dt_incr': 1e-10, 'espresso_handle': None, 'kT_KVm_inv': 5.0, 'n_parts': 1, 'sigma': 1, 'size': 1, 'tau0_inv': 735000000.0, 'tau_trans_inv': 0}
numInstances = 0
part_types = {'sw_real': 9, 'sw_virt': 10}
required_features = []
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'sw_part': 13}

pressomancy.object_classes.egg_model_part module

class pressomancy.object_classes.egg_model_part.EGGPart(*args, **kwargs)[source]

Bases: object

Class that contains quadriplex relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a Quadriplex. Therefore many relevant parameters are class specific, not instance specific.

config = {'aniso_energy': 1.0, 'associated_objects': None, 'dipm': 1.0, 'egg_gamma': 2.0, 'espresso_handle': None, 'n_parts': 1, 'sigma': 1, 'size': 1}
numInstances = 0
part_types = {'real': 1, 'virt': 2}
required_features = ['MAGNETODYNAMICS_EGG_MODEL']
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of filament stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'egg_part': 74}

pressomancy.object_classes.tel_sequence module

class pressomancy.object_classes.tel_sequence.TelSeq(*args, **kwargs)[source]

Bases: object

Class that contains TelSeq relevant paramaters and methods. At construction one must pass an espresso handle becaouse the class manages parameters that are both internal and external to espresso. It is assumed that in any simulation instanse there will be only one type of a TelSeq. Therefore many relevant parameters are class specific, not instance specific.

config = {'associated_objects': None, 'bond_handle': BondWrapper(<FeneBond({'r_0': 0, 'k': 0, 'd_r_max': 0})>), 'diag_bond_handle': BondWrapper(<FeneBond({'r_0': 0, 'k': 0, 'd_r_max': 0})>), 'espresso_handle': None, 'n_parts': 1, 'sigma': 1, 'size': 1, 'spacing': None}
numInstances = 0
part_types = {'real': 1, 'to_be_magnetized': 3, 'virt': 2}
required_features = []
set_object(pos, ori)[source]

Sets a n_parts sequence of particles in espresso, asserting that the dimensionality of the pos paramater passed is commesurate with n_part.Using a generator object with the particle enumeration logic, and a try catch paradigm. Particles created here are treated as real, non_magnetic, with enabled rotations. Indices of added particles stored in self.realz_indices.append attribute. Orientation of TelSeq stored in self.orientor = self.get_orientation_vec()

Parameters:

pos – np.array() | float, list of positions

Returns:

None

simulation_type = {'tel_seq': 37}
wrap_into_Tel()[source]

associated_objects contains monomer objects (assume quadriplex). We add cormer particles in each quadriplex pair to a pool of candidate corners: candidate1 and candidate2. Finaly checks which corner pairs have a distance self.params[‘sigma’]-2*fene_r0. Relies on np.isclose(). :return: None

pressomancy.object_classes.tel_sequence.rule_maker(choice_id, offset, n=3)[source]

Module contents