introspection.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. .. _api-introspection:
  2. *************
  3. Introspection
  4. *************
  5. Introspection
  6. =============
  7. Only internal. This class is used only as a base class to Model, it is not provided through API. Defines interface to introspect simulation state.
  8. Methods:
  9. *********
  10. .. _Introspection__get_molecule_ids:
  11. get_molecule_ids (pattern: Complex=None) -> List[int]
  12. -----------------------------------------------------
  13. | Returns a list of ids of molecules.
  14. | If the arguments pattern is not set, the list of all molecule ids is returned.
  15. | If the argument pattern is set, the list of all molecule ids whose species match
  16. | the pattern is returned.
  17. * | pattern: Complex = None
  18. | BNGL pattern to select molecules based on their species, might use compartments.
  19. | Example: `1910_get_molecule_ids_w_pattern/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1910_get_molecule_ids_w_pattern/model.py>`_
  20. .. _Introspection__get_molecule:
  21. get_molecule (id: int) -> Molecule
  22. ----------------------------------
  23. | Returns a information on a molecule from the simulated environment,
  24. | None if the molecule does not exist.
  25. * | id: int
  26. | Unique id of the molecule to be retrieved.
  27. | Example: `1900_molecule_introspection/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1900_molecule_introspection/model.py>`_
  28. .. _Introspection__get_species_name:
  29. get_species_name (species_id: int) -> str
  30. -----------------------------------------
  31. | Returns a string representing canonical species name in the BNGL format.
  32. * | species_id: int
  33. | Id of the species.
  34. | Example: `1850_run_unimol_rxn_in_callback/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1850_run_unimol_rxn_in_callback/model.py>`_
  35. .. _Introspection__get_vertex:
  36. get_vertex (object: GeometryObject, vertex_index: int) -> List[float]
  37. ---------------------------------------------------------------------
  38. | Returns coordinates of a vertex.
  39. * | object: GeometryObject
  40. * | vertex_index: int
  41. | This is the index of the vertex in the geometry object's walls (wall_list).
  42. | Example: `1340_get_vertex/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1340_get_vertex/model.py>`_
  43. .. _Introspection__get_wall:
  44. get_wall (object: GeometryObject, wall_index: int) -> Wall
  45. ----------------------------------------------------------
  46. | Returns information about a wall belonging to a given object.
  47. * | object: GeometryObject
  48. | Geometry object whose wall to retrieve.
  49. * | wall_index: int
  50. | This is the index of the wall in the geometry object's walls (wall_list).
  51. | Example: `1330_get_wall/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1330_get_wall/model.py>`_
  52. .. _Introspection__get_vertex_unit_normal:
  53. get_vertex_unit_normal (object: GeometryObject, vertex_index: int) -> List[float]
  54. ---------------------------------------------------------------------------------
  55. | Returns sum of all wall normals that use this vertex converted to a unit vector of
  56. | length 1 um (micrometer).
  57. | This represents the unit vector pointing outwards from the vertex.
  58. * | object: GeometryObject
  59. | Geometry object whose vertex to retrieve.
  60. * | vertex_index: int
  61. | This is the index of the vertex in the geometry object's vertex_list.
  62. | Example: `1320_get_vertex_unit_normal/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1320_get_vertex_unit_normal/model.py>`_
  63. .. _Introspection__get_wall_unit_normal:
  64. get_wall_unit_normal (object: GeometryObject, wall_index: int) -> List[float]
  65. -----------------------------------------------------------------------------
  66. | Returns wall normal converted to a unit vector of length 1um.
  67. * | object: GeometryObject
  68. | Geometry object whose wall's normal to retrieve.
  69. * | wall_index: int
  70. | This is the index of the vertex in the geometry object's walls (wall_list).
  71. | Example: `1310_get_wall_unit_normal/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1310_get_wall_unit_normal/model.py>`_
  72. .. _Introspection__get_wall_color:
  73. get_wall_color (object: GeometryObject, wall_index: int) -> Color
  74. -----------------------------------------------------------------
  75. | Returns color of a wall.
  76. * | object: GeometryObject
  77. | Geometry object whose wall's color to retrieve.
  78. * | wall_index: int
  79. | This is the index of the vertex in the geometry object's walls (wall_list).
  80. .. _Introspection__set_wall_color:
  81. set_wall_color (object: GeometryObject, wall_index: int, color: Color)
  82. ----------------------------------------------------------------------
  83. | Sets color of a wall.
  84. * | object: GeometryObject
  85. | Geometry object whose wall's color to retrieve.
  86. * | wall_index: int
  87. | This is the index of the vertex in the geometry object's walls (wall_list).
  88. * | color: Color
  89. | Color to be set.
  90. Molecule
  91. ========
  92. Representation of a molecule obtained from Model
  93. during simulation obtained through Model.get_molecule.
  94. Changes through changing attributes of this object are not allowed except
  95. for complete removal of this molecule.
  96. Example: `1900_molecule_introspection/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1900_molecule_introspection/model.py>`_
  97. Attributes:
  98. ***********
  99. .. _Molecule__id:
  100. id: int
  101. -------
  102. | Unique id of this molecule. MCell assigns this unique id to each created
  103. | molecule. All reactions change ID of molecules even in reactions such as
  104. | A\@CP -> A\@EC.
  105. | - default argument value in constructor: ID_INVALID
  106. .. _Molecule__type:
  107. type: MoleculeType
  108. ------------------
  109. | Type of this molecule, either volume or surface.
  110. | - default argument value in constructor: MoleculeType.UNSET
  111. .. _Molecule__species_id:
  112. species_id: int
  113. ---------------
  114. | Species id of this molecule.
  115. | The species_id value is only temporary. Species ids are created and removed as needed
  116. | automatically and if this species is removed, this particular species_id value
  117. | won't be valid. This can happen when a following iteration is simulated.
  118. | - default argument value in constructor: ID_INVALID
  119. .. _Molecule__pos3d:
  120. pos3d: List[float]
  121. ------------------
  122. | Contains position of a molecule in 3D space.
  123. | - default argument value in constructor: None
  124. .. _Molecule__orientation:
  125. orientation: Orientation
  126. ------------------------
  127. | Contains orientation for surface molecule. Volume molecules
  128. | have always orientation set to Orientation.NONE.
  129. | - default argument value in constructor: Orientation.NOT_SET
  130. .. _Molecule__pos2d:
  131. pos2d: List[float]
  132. ------------------
  133. | Set only for surface molecules. Position on a wall in UV coordinates
  134. | relative to the triangle of the wall.
  135. | - default argument value in constructor: None
  136. .. _Molecule__geometry_object:
  137. geometry_object: GeometryObject
  138. -------------------------------
  139. | Set only for surface molecules.
  140. | Is set to a reference to the geometry object on whose surface is the molecule located.
  141. | - default argument value in constructor: None
  142. .. _Molecule__wall_index:
  143. wall_index: int
  144. ---------------
  145. | Set only for surface molecules.
  146. | Index of wall belonging to the geometry_object where is the
  147. | molecule located.
  148. | - default argument value in constructor: -1
  149. Methods:
  150. *********
  151. .. _Molecule__remove:
  152. remove ()
  153. ---------
  154. | Removes this molecule from simulation. Any subsequent modifications
  155. | of this molecule won't have any effect.
  156. | Example: `1920_molecule_remove/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1920_molecule_remove/model.py>`_
  157. Wall
  158. ====
  159. Constant representation of wall of a geometry object.
  160. Changes through changing attributes of this object are not allowed
  161. except for the attribute is_movable.
  162. Example: `1330_get_wall/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1330_get_wall/model.py>`_
  163. Attributes:
  164. ***********
  165. .. _Wall__geometry_object:
  166. geometry_object: GeometryObject
  167. -------------------------------
  168. | Object to which this wall belongs.
  169. .. _Wall__wall_index:
  170. wall_index: int
  171. ---------------
  172. | Index of this wall in the object to which this wall belongs.
  173. .. _Wall__vertices:
  174. vertices: List[List[float]]
  175. ---------------------------
  176. | Vertices of the triangle that represents this wall.
  177. .. _Wall__area:
  178. area: float
  179. -----------
  180. | Area of the wall in um^2.
  181. .. _Wall__unit_normal:
  182. unit_normal: List[float]
  183. ------------------------
  184. | Normal of this wall with unit length of 1 um.
  185. | There is also a method Model.get_wall_unit_normal that allows to
  186. | retrieve just the normal value without the need to prepare this
  187. | whole Wall object.
  188. .. _Wall__is_movable:
  189. is_movable: bool
  190. ----------------
  191. | If True, whis wall can be moved through Model.apply_vertex_moves,
  192. | if False, wall moves are ignored.
  193. | Can be set during simulation.
  194. | - default argument value in constructor: True
  195. WallWallHitInfo
  196. ===============
  197. This class is used in the return type of Model.apply_vertex_moves.
  198. Contains pair of walls that collided.
  199. Example: `1515_tetrahedron_box_collision_moving_3_w_wall_wall_hit/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4_positive/1515_tetrahedron_box_collision_moving_3_w_wall_wall_hit/model.py>`_
  200. Attributes:
  201. ***********
  202. .. _WallWallHitInfo__wall1:
  203. wall1: Wall
  204. -----------
  205. | First colliding wall.
  206. .. _WallWallHitInfo__wall2:
  207. wall2: Wall
  208. -----------
  209. | Second colliding wall.