instantiation.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. .. _api-instantiation:
  2. *************
  3. Instantiation
  4. *************
  5. InitialSurfaceRelease
  6. =====================
  7. Defines molecules to be released onto a SurfaceRegion right when simulation starts
  8. Attributes:
  9. ***********
  10. .. _InitialSurfaceRelease__complex:
  11. complex: Complex
  12. ----------------
  13. | Defines the species of the molecule that will be released.
  14. .. _InitialSurfaceRelease__number_to_release:
  15. number_to_release: int
  16. ----------------------
  17. | Number of molecules to be released onto a region,
  18. | only one of number_to_release and density can be set.
  19. | - default argument value in constructor: None
  20. .. _InitialSurfaceRelease__density:
  21. density: float
  22. --------------
  23. | Density of molecules to be released onto a region,
  24. | only one of number_to_release and density can be set.
  25. | - default argument value in constructor: None
  26. Instantiation
  27. =============
  28. Container used to hold instantiation-related model data.
  29. Instantiation is usually specific for each model, defines
  30. the geometry and initial setup of molecule releases.
  31. Example: `pymcell4/1250_organelle_move <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4/1250_organelle_move>`_
  32. Attributes:
  33. ***********
  34. .. _Instantiation__release_sites:
  35. release_sites: List[ReleaseSite]
  36. --------------------------------
  37. | List of release sites to be included in the model.
  38. | - default argument value in constructor: None
  39. .. _Instantiation__geometry_objects:
  40. geometry_objects: List[GeometryObject]
  41. --------------------------------------
  42. | List of geometry objects to be included in the model.
  43. | - default argument value in constructor: None
  44. .. _Instantiation__checkpointed_molecules:
  45. checkpointed_molecules: List[BaseChkptMol]
  46. ------------------------------------------
  47. | Used when resuming simulation from a checkpoint.
  48. | - default argument value in constructor: None
  49. Methods:
  50. *********
  51. .. _Instantiation__add_release_site:
  52. add_release_site (s: ReleaseSite)
  53. ---------------------------------
  54. | Adds a reference to the release site s to the list of release sites.
  55. * | s: ReleaseSite
  56. .. _Instantiation__find_release_site:
  57. find_release_site (name: str) -> ReleaseSite
  58. --------------------------------------------
  59. | Finds a release site by its name, returns None if no such release site is present.
  60. * | name: str
  61. .. _Instantiation__add_geometry_object:
  62. add_geometry_object (o: GeometryObject)
  63. ---------------------------------------
  64. | Adds a reference to the geometry object o to the list of geometry objects.
  65. * | o: GeometryObject
  66. .. _Instantiation__find_geometry_object:
  67. find_geometry_object (name: str) -> GeometryObject
  68. --------------------------------------------------
  69. | Finds a geometry object by its name, returns None if no such geometry object is present.
  70. * | name: str
  71. .. _Instantiation__find_volume_compartment_object:
  72. find_volume_compartment_object (name: str) -> GeometryObject
  73. ------------------------------------------------------------
  74. | Finds a geometry object by its name, the geometry object must be a BNGL compartment.
  75. | Returns None if no such geometry object is present.
  76. * | name: str
  77. .. _Instantiation__find_surface_compartment_object:
  78. find_surface_compartment_object (name: str) -> GeometryObject
  79. -------------------------------------------------------------
  80. | Finds a geometry object that is a BNGL compartment and its surface name is name.
  81. | Returns None if no such geometry object is present.
  82. * | name: str
  83. .. _Instantiation__load_bngl_compartments_and_seed_species:
  84. load_bngl_compartments_and_seed_species (file_name: str, default_release_region: Region=None, parameter_overrides: Dict[str, float]=None)
  85. -----------------------------------------------------------------------------------------------------------------------------------------
  86. | First loads section compartments and for each 3D compartment that does not
  87. | already exist as a geometry object in this Instantiation object, creates a
  88. | box with compartment's volume and also sets its 2D (membrane) compartment name.
  89. | When multiple identical geometry objects are added to the final Model object,
  90. | only one copy is left so one can merge multiple Instantiation objects that created
  91. | compartments assuming that their volume is the same.
  92. | Then loads section seed species from a BNGL file and creates release sites according to it.
  93. | All elementary molecule types used in the seed species section must be already defined in subsystem.
  94. | If an item in the BNGL seed species section does not have its compartment set,
  95. | the argument default_region must be set and the molecules are then released into or onto the
  96. | default_region.
  97. * | file_name: str
  98. | Path to the BNGL file.
  99. * | default_release_region: Region = None
  100. | Used as region for releases for seed species that have no compartments specified.
  101. * | parameter_overrides: Dict[str, float] = None
  102. | For each key k in the parameter_overrides, if it is defined in the BNGL's parameters section,
  103. | its value is ignored and instead value parameter_overrides[k] is used.
  104. | Example: `2100_gradual_bngl_load/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4/2100_gradual_bngl_load/model.py>`_
  105. MoleculeReleaseInfo
  106. ===================
  107. Defines a pair (molecule, location). Used in ReleaseSite when its shape is Shape.LIST.
  108. Attributes:
  109. ***********
  110. .. _MoleculeReleaseInfo__complex:
  111. complex: Complex
  112. ----------------
  113. | Complex instance defining the molecule that will be released.
  114. | Orientation of the complex instance is used to define orientation of the released molecule,
  115. | when Orientation.DEFAULT is set, volume molecules are released with Orientation.NONE and
  116. | surface molecules are released with Orientation.UP.
  117. | Compartment must not be set because this specific release definition states the location.
  118. .. _MoleculeReleaseInfo__location:
  119. location: List[float]
  120. ---------------------
  121. | 3D position where the molecule will be released.
  122. | If a molecule has a 2D diffusion constant, it will be
  123. | placed on the surface closest to the coordinate given.
  124. | Argument must have exactly three floating point values [x, y, z].
  125. ReleasePattern
  126. ==============
  127. Defines a release pattern that specifies repeating molecule releases.
  128. Can be used by a ReleaseSite.
  129. Attributes:
  130. ***********
  131. .. _ReleasePattern__name:
  132. name: str
  133. ---------
  134. | Name of the release pattern.
  135. | - default argument value in constructor: None
  136. .. _ReleasePattern__release_interval:
  137. release_interval: float
  138. -----------------------
  139. | During a train of releases, release molecules after every t seconds.
  140. | Default is to release only once.
  141. | - default argument value in constructor: TIME_INFINITY
  142. .. _ReleasePattern__train_duration:
  143. train_duration: float
  144. ---------------------
  145. | The train of releases lasts for t seconds before turning off.
  146. | Default is to never turn off.
  147. | - default argument value in constructor: TIME_INFINITY
  148. .. _ReleasePattern__train_interval:
  149. train_interval: float
  150. ---------------------
  151. | A new train of releases happens every t seconds.
  152. | Default is to never have a new train.
  153. | The train interval must not be shorter than the train duration.
  154. | - default argument value in constructor: TIME_INFINITY
  155. .. _ReleasePattern__number_of_trains:
  156. number_of_trains: int
  157. ---------------------
  158. | Repeat the release process for n trains of releases. Default is one train.
  159. | For unlimited number of trains use a constant NUMBER_OF_TRAINS_UNLIMITED.
  160. | - default argument value in constructor: 1
  161. ReleaseSite
  162. ===========
  163. Defines a release site that specifies where, when and how should molecules be released.
  164. Example: `1100_point_release/model.py <https://github.com/mcellteam/mcell_tests/blob/master/tests/pymcell4/1100_point_release/model.py>`_
  165. Attributes:
  166. ***********
  167. .. _ReleaseSite__name:
  168. name: str
  169. ---------
  170. | Name of the release site
  171. .. _ReleaseSite__complex:
  172. complex: Complex
  173. ----------------
  174. | Defines the species of the molecule that will be released. Not used for the LIST shape.
  175. | Must be set when molecule_list is empty and unset when molecule_list is not empty.
  176. | Orientation of the complex instance is used to define orientation of the released molecule,
  177. | when Orientation.DEFAULT is set, volume molecules are released with Orientation.NONE and
  178. | surface molecules are released with Orientation.UP.
  179. | When compartment is specified and region is not set, this sets shape to Shape.COMPARTMENT and
  180. | the molecules are released into the compartment.
  181. | When this is a release of volume molecules, and both compartment and region are set,
  182. | this sets shape to Shape.REGION_EXPR and the target region is the intersection
  183. | of the region and the compartment.
  184. | - default argument value in constructor: None
  185. .. _ReleaseSite__molecule_list:
  186. molecule_list: List[MoleculeReleaseInfo]
  187. ----------------------------------------
  188. | Used for LIST shape release mode.
  189. | Only one of number_to_release, density, concentration or molecule_list can be set.
  190. | - default argument value in constructor: None
  191. .. _ReleaseSite__release_time:
  192. release_time: float
  193. -------------------
  194. | Specifies time in seconds when the release event is executed.
  195. | In case when a release pattern is used, this is the time of the first release.
  196. | Equivalent to MDL's RELEASE_PATTERN command DELAY.
  197. | - default argument value in constructor: 0
  198. .. _ReleaseSite__release_pattern:
  199. release_pattern: ReleasePattern
  200. -------------------------------
  201. | Use the release pattern to define schedule of releases.
  202. | The default is to release the specified number of molecules at the set release_time.
  203. | - default argument value in constructor: None
  204. .. _ReleaseSite__shape:
  205. shape: Shape
  206. ------------
  207. | Defines how the molecules shoudl be released.
  208. | Set automatically for these cases to the following values\:
  209. | region is set - Shape.REGION_EXPR,
  210. | region is not set and complex uses a compartment - Shape.COMPARTMENT,
  211. | molecule_list is set - Shape.LIST,
  212. | location is set - Shape.SPHERICAL.
  213. | - default argument value in constructor: Shape.UNSET
  214. .. _ReleaseSite__region:
  215. region: Region
  216. --------------
  217. | Defines a volume or surface region where to release molecules.
  218. | Setting it sets shape to Shape.REGION_EXPR.
  219. | When this is a release of volume molecules, and both compartment and region are set,
  220. | this sets shape to Shape.REGION_EXPR and the target region is the intersection
  221. | of the region and the compartment.
  222. | - default argument value in constructor: None
  223. .. _ReleaseSite__location:
  224. location: List[float]
  225. ---------------------
  226. | Defines center of a sphere where to release molecules.
  227. | Setting it sets shape to Shape.SPHERICAL.
  228. | - default argument value in constructor: None
  229. .. _ReleaseSite__site_diameter:
  230. site_diameter: float
  231. --------------------
  232. | For a geometrical release site, this releases molecules uniformly within
  233. | a radius r computed as site_diameter/2.
  234. | Used only when shape is Shape.SPHERICAL.
  235. | Maximum one of site_diameter or site_radius may be set.
  236. | - default argument value in constructor: 0
  237. .. _ReleaseSite__site_radius:
  238. site_radius: float
  239. ------------------
  240. | For a geometrical release site, this releases molecules uniformly within
  241. | a radius site_radius.
  242. | Used only when shape is Shape.SPHERICAL.
  243. | Maximum one of site_diameter or site_radius may be set.
  244. | - default argument value in constructor: None
  245. .. _ReleaseSite__number_to_release:
  246. number_to_release: float
  247. ------------------------
  248. | Sets number of molecules to release. Cannot be set when shape is Shape.LIST.
  249. | Only one of number_to_release, density, concentration or molecule_list can be set.
  250. | Value is truncated (floored) to an integer.
  251. | - default argument value in constructor: None
  252. .. _ReleaseSite__density:
  253. density: float
  254. --------------
  255. | Unit is molecules per square micron (for surfaces).
  256. | Only one of number_to_release, density, concentration or molecule_list can be set.
  257. | Cannot be set when shape is Shape.LIST.
  258. | - default argument value in constructor: None
  259. .. _ReleaseSite__concentration:
  260. concentration: float
  261. --------------------
  262. | Unit is molar (moles per liter) for volumes.
  263. | Only one of number_to_release, density, concentration or molecule_list can be set.
  264. | Cannot be set when shape is Shape.LIST.
  265. | - default argument value in constructor: None
  266. .. _ReleaseSite__release_probability:
  267. release_probability: float
  268. --------------------------
  269. | This release does not occur every time, but rather with probability p.
  270. | Either the whole release occurs or none of it does; the probability does not
  271. | apply molecule-by-molecule. release_probability must be in the interval [0, 1].
  272. | - default argument value in constructor: 1