-
Notifications
You must be signed in to change notification settings - Fork 12
/
cellblender_initialization.py
746 lines (653 loc) · 38.7 KB
/
cellblender_initialization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
"""
This file contains the classes for CellBlender's Reactions.
"""
import cellblender
# blender imports
import bpy
from bpy.props import BoolProperty, CollectionProperty, EnumProperty, \
FloatProperty, FloatVectorProperty, IntProperty, \
IntVectorProperty, PointerProperty, StringProperty
#from bpy.app.handlers import persistent
#import math
#import mathutils
# python imports
import re
# CellBlender imports
import cellblender
from . import parameter_system
from . import cellblender_utils
class MCellInitializationPropertyGroup(bpy.types.PropertyGroup):
def __init__(self):
print ( "\n\nMCellInitializationPropertyGroup.__init__() called\n\n" )
iterations: PointerProperty ( name="iterations", type=parameter_system.Parameter_Reference )
time_step: PointerProperty ( name="Time Step", type=parameter_system.Parameter_Reference )
status: StringProperty(name="Status")
advanced: BoolProperty(default=False)
warnings: BoolProperty(default=False)
notifications: BoolProperty(default=False)
# Advanced/Optional Commands
time_step_max: PointerProperty ( name="Time Step Max", type=parameter_system.Parameter_Reference )
space_step: PointerProperty ( name="Space Step", type=parameter_system.Parameter_Reference )
interaction_radius: PointerProperty ( name="Interaction Radius", type=parameter_system.Parameter_Reference )
radial_directions: PointerProperty ( name="Radial Directions", type=parameter_system.Parameter_Reference )
radial_subdivisions: PointerProperty ( name="Radial Subdivisions", type=parameter_system.Parameter_Reference )
vacancy_search_distance: PointerProperty ( name="Radial Subdivisions", type=parameter_system.Parameter_Reference )
surface_grid_density: PointerProperty ( name="Surface Grid Density", type=parameter_system.Parameter_Reference )
command_options: StringProperty(name="Command Options", default="")
def init_properties ( self, parameter_system ):
helptext = "Number of iterations to run"
self.iterations.init_ref ( parameter_system,
user_name="Iterations",
user_expr="1000",
user_units="",
user_descr=helptext,
user_int=True )
helptext = "Simulation Time Step\n1e-6 is a common value."
self.time_step.init_ref ( parameter_system,
user_name="Time Step",
user_expr="1e-6",
user_units="seconds",
user_descr=helptext )
helptext = """The longest possible time step. MCell3 will move longer
than the specified simulation time step if it seems safe. This command makes
sure that the longest possible time step is no longer than this value (in
seconds), even if MCell3 thinks a longer step would be safe. The default is no
limit."""
self.time_step_max.init_ref ( parameter_system,
user_name="Maximum Time Step",
user_expr="",
user_units="seconds",
user_descr=helptext )
helptext = """Have molecules take the same mean diffusion distance.
Have all diffusing molecules take time steps of different duration, chosen so
that the mean diffusion distance is N microns for each molecule. By default,
all molecules move the same time step."""
self.space_step.init_ref ( parameter_system,
user_name="Space Step",
user_expr="",
user_units="microns",
user_descr=helptext )
helptext = """Diffusing Volume Molecules will interact when they get
within N microns of each other. The default is: 1 / sqrt(Pi *
SurfaceGridDensity)"""
self.interaction_radius.init_ref ( parameter_system,
user_name="Interaction Radius",
user_expr="", user_units="microns",
user_descr=helptext )
helptext = """Specifies how many different directions to put in the
lookup table. The default is sensible. Don’t use this unless you know what
you’re doing. Instead of a number, you can specify FULLY_RANDOM in MDL to
generate the directions directly from double precision numbers (but this is
slower)."""
self.radial_directions.init_ref ( parameter_system,
user_name="Radial Directions",
user_expr="", user_units="microns",
user_descr=helptext )
helptext = """Specifies how many distances to put in the diffusion
look-up table. The default is sensible. FULLY_RANDOM is not implemented."""
self.radial_subdivisions.init_ref ( parameter_system,
user_name="Radial Subdivisions",
user_expr="",
user_descr=helptext )
helptext = """Surface molecule products can be created at r distance.
Normally, a reaction will not proceed on a surface unless there is room to
place all products on the single grid element where the reaction is initiated.
By increasing r from its default value of 0, one can specify how far from the
reaction’s location, in microns, the reaction can place its products. To be
useful, r must be larger than the longest axis of the grid element on the
triangle in question. The reaction will then proceed if there is room to place
its products within a radius r, and will place those products as close as
possible to the place where the reaction occurs (deterministically, so
small-scale directional bias is possible)."""
self.vacancy_search_distance.init_ref ( parameter_system,
user_name="Vacancy Search Distance",
user_expr="",
user_units="microns",
user_descr=helptext )
helptext = """Number of molecules that can be stored per square micron.
Tile all surfaces so that they can hold molecules at N different positions per
square micron. The default is 10000. For backwards compatibility,
EFFECTOR_GRID_DENSITY works also in MCell MDL."""
self.surface_grid_density.init_ref ( parameter_system,
user_name="Surface Grid Density",
user_expr="10000",
user_units="count / sq micron",
user_descr=helptext )
def remove_properties ( self, context ):
ps = context.scene.mcell.parameter_system
# It's not needed to remove these properties because there is only one copy? Mostly yes.
# It appears that removing some of the "original 16" panel parameters causes a problem.
# This was fixed by commenting out the removal code. However, that causes some of the
# other "original 16" to be recreated when reading from a data model (or using the
# "Clear Project" scripting button). These duplicate parameters appear to not be a
# problem because the RNA properties only store a reference to the most current one.
# However, they do leave a trail of ID property "ghosts" which show multiple versions
# of the same panel parameters.
# But if they were to be removed, here's what it would look like:
"""
self.iterations.clear_ref ( ps )
self.time_step.clear_ref ( ps )
self.time_step_max.clear_ref ( ps )
self.space_step.clear_ref ( ps )
self.interaction_radius.clear_ref ( ps )
self.radial_directions.clear_ref ( ps )
self.radial_subdivisions.clear_ref ( ps )
self.vacancy_search_distance.clear_ref ( ps )
self.surface_grid_density.clear_ref ( ps )
"""
def build_data_model_from_properties ( self, context ):
mcell4_mode = context.scene.mcell.cellblender_preferences.mcell4_mode
dm_dict = {}
dm_dict['data_model_version'] = "DM_2017_11_18_0130"
dm_dict['iterations'] = self.iterations.get_expr()
dm_dict['time_step'] = self.time_step.get_expr()
dm_dict['time_step_max'] = self.time_step_max.get_expr()
dm_dict['space_step'] = self.space_step.get_expr()
dm_dict['interaction_radius'] = self.interaction_radius.get_expr()
dm_dict['radial_directions'] = self.radial_directions.get_expr()
dm_dict['radial_subdivisions'] = self.radial_subdivisions.get_expr()
dm_dict['vacancy_search_distance'] = self.vacancy_search_distance.get_expr()
dm_dict['surface_grid_density'] = self.surface_grid_density.get_expr()
dm_dict['microscopic_reversibility'] = str(self.microscopic_reversibility)
dm_dict['accurate_3d_reactions'] = self.accurate_3d_reactions==True
dm_dict['center_molecules_on_grid'] = self.center_molecules_grid==True
dm_dict['export_all_ascii'] = self.export_all_ascii==True
dm_dict['command_options'] = self.command_options
notify_dict = {}
notify_dict['all_notifications'] = str(self.all_notifications)
notify_dict['species_reactions_report'] = self.species_reactions_report
notify_dict['diffusion_constant_report'] = str(self.diffusion_constant_report)
notify_dict['file_output_report'] = self.file_output_report==True
notify_dict['final_summary'] = self.final_summary==True
notify_dict['iteration_report'] = self.iteration_report==True
notify_dict['partition_location_report'] = self.partition_location_report==True
notify_dict['probability_report'] = str(self.probability_report)
notify_dict['probability_report_threshold'] = "%g" % (self.probability_report_threshold)
notify_dict['varying_probability_report'] = self.varying_probability_report==True
notify_dict['progress_report'] = self.progress_report==True
notify_dict['release_event_report'] = self.release_event_report==True
notify_dict['molecule_collision_report'] = self.molecule_collision_report==True
notify_dict['box_triangulation_report'] = False
dm_dict['notifications'] = notify_dict
warn_dict = {}
warn_dict['all_warnings'] = str(self.all_warnings)
warn_dict['large_molecular_displacement'] = str(self.large_molecular_displacement)
warn_dict['degenerate_polygons'] = str(self.degenerate_polygons)
if not mcell4_mode:
warn_dict['high_reaction_probability'] = str(self.high_reaction_probability)
else:
warn_dict['high_reaction_probability'] = str(self.high_reaction_probability_mcell4)
warn_dict['high_probability_threshold'] = "%g" % (self.high_probability_threshold)
warn_dict['lifetime_too_short'] = str(self.lifetime_too_short)
warn_dict['lifetime_threshold'] = str(self.lifetime_threshold)
warn_dict['missed_reactions'] = str(self.missed_reactions)
warn_dict['missed_reaction_threshold'] = "%g" % (self.missed_reaction_threshold)
warn_dict['negative_diffusion_constant'] = str(self.negative_diffusion_constant)
warn_dict['missing_surface_orientation'] = str(self.missing_surface_orientation)
warn_dict['negative_reaction_rate'] = str(self.negative_reaction_rate)
warn_dict['useless_volume_orientation'] = str(self.useless_volume_orientation)
dm_dict['warnings'] = warn_dict
return dm_dict
@staticmethod
def upgrade_data_model ( dm ):
# Upgrade the data model as needed. Return updated data model or None if it can't be upgraded.
print ( "------------------------->>> Upgrading MCellInitializationPropertyGroup Data Model" )
if not ('data_model_version' in dm):
# Make changes to move from unversioned to DM_2014_10_24_1638
dm['data_model_version'] = "DM_2014_10_24_1638"
if dm['data_model_version'] == "DM_2014_10_24_1638":
# Change on November 18, 2017: Add the large_molecular_displacement field with the current MCell default of warning:
dm['large_molecular_displacement'] = "WARNING"
dm['data_model_version'] = "DM_2017_11_18_0130"
if dm['data_model_version'] != "DM_2017_11_18_0130":
data_model.flag_incompatible_data_model ( "Error: Unable to upgrade MCellInitializationPropertyGroup data model to current version." )
return None
return dm
def build_properties_from_data_model ( self, context, dm_dict ):
mcell4_mode = context.scene.mcell.cellblender_preferences.mcell4_mode
print ( "Top of MCellInitializationPropertyGroup.build_properties_from_data_model" )
if dm_dict['data_model_version'] != "DM_2017_11_18_0130":
data_model.handle_incompatible_data_model ( "Error: Unable to upgrade MCellInitializationPropertyGroup data model to current version." )
#__import__('code').interact(local={k: v for ns in (globals(), locals()) for k, v in ns.items()})
if "iterations" in dm_dict: self.iterations.set_expr ( dm_dict["iterations"] )
if "time_step" in dm_dict: self.time_step.set_expr ( dm_dict["time_step"] )
if "time_step_max" in dm_dict: self.time_step_max.set_expr ( dm_dict["time_step_max"] )
if "space_step" in dm_dict: self.space_step.set_expr ( dm_dict["space_step"] )
if "interaction_radius" in dm_dict: self.interaction_radius.set_expr ( dm_dict["interaction_radius"] )
if "radial_directions" in dm_dict: self.radial_directions.set_expr ( dm_dict["radial_directions"] )
if "radial_subdivisions" in dm_dict: self.radial_subdivisions.set_expr ( dm_dict["radial_subdivisions"] )
if "vacancy_search_distance" in dm_dict: self.vacancy_search_distance.set_expr ( dm_dict["vacancy_search_distance"] )
if "surface_grid_density" in dm_dict: self.surface_grid_density.set_expr ( dm_dict["surface_grid_density"] )
if "microscopic_reversibility" in dm_dict: self.microscopic_reversibility = dm_dict["microscopic_reversibility"]
if "accurate_3d_reactions" in dm_dict: self.accurate_3d_reactions = dm_dict["accurate_3d_reactions"]
if "center_molecules_on_grid" in dm_dict: self.center_molecules_grid = dm_dict["center_molecules_on_grid"]
if "export_all_ascii" in dm_dict: self.export_all_ascii = dm_dict["export_all_ascii"]
if "command_options" in dm_dict: self.command_options = dm_dict["command_options"]
if "notifications" in dm_dict:
note_dict = dm_dict['notifications']
if "all_notifications" in note_dict: self.all_notifications = note_dict['all_notifications']
if "diffusion_constant_report" in note_dict: self.diffusion_constant_report = note_dict['diffusion_constant_report']
if "species_reactions_report" in note_dict: self.species_reactions_report = note_dict['species_reactions_report']
if "file_output_report" in note_dict: self.file_output_report = note_dict['file_output_report']
if "final_summary" in note_dict: self.final_summary = note_dict['final_summary']
if "iteration_report" in note_dict: self.iteration_report = note_dict['iteration_report']
if "partition_location_report" in note_dict: self.partition_location_report = note_dict['partition_location_report']
if "probability_report" in note_dict: self.probability_report = note_dict['probability_report']
if "probability_report_threshold" in note_dict: self.probability_report_threshold = float(note_dict['probability_report_threshold'])
if "varying_probability_report" in note_dict: self.varying_probability_report = note_dict['varying_probability_report']
if "progress_report" in note_dict: self.progress_report = note_dict['progress_report']
if "release_event_report" in note_dict: self.release_event_report = note_dict['release_event_report']
if "molecule_collision_report" in note_dict: self.molecule_collision_report = note_dict['molecule_collision_report']
##notify_dict[box_triangulation_report'] = False
if "warnings" in dm_dict:
warn_dict = dm_dict['warnings']
if "all_warnings" in warn_dict: self.all_warnings = warn_dict['all_warnings']
if "large_molecular_displacement" in warn_dict: self.large_molecular_displacement = warn_dict['large_molecular_displacement']
if "degenerate_polygons" in warn_dict: self.degenerate_polygons = warn_dict['degenerate_polygons']
if "high_reaction_probability" in warn_dict:
self.high_reaction_probability = warn_dict['high_reaction_probability']
self.high_reaction_probability_mcell4 = warn_dict['high_reaction_probability']
if "high_probability_threshold" in warn_dict: self.high_probability_threshold = float(warn_dict['high_probability_threshold'])
if "lifetime_too_short" in warn_dict: self.lifetime_too_short = warn_dict['lifetime_too_short']
if "lifetime_threshold" in warn_dict: self.lifetime_threshold = float(warn_dict['lifetime_threshold'])
if "missed_reactions" in warn_dict: self.missed_reactions = warn_dict['missed_reactions']
if "missed_reaction_threshold" in warn_dict: self.missed_reaction_threshold = float(warn_dict['missed_reaction_threshold'])
if "negative_diffusion_constant" in warn_dict: self.negative_diffusion_constant = warn_dict['negative_diffusion_constant']
if "missing_surface_orientation" in warn_dict: self.missing_surface_orientation = warn_dict['missing_surface_orientation']
if "negative_reaction_rate" in warn_dict: self.negative_reaction_rate = warn_dict['negative_reaction_rate']
if "useless_volume_orientation" in warn_dict: self.useless_volume_orientation = warn_dict['useless_volume_orientation']
print ( "Bottom of MCellInitializationPropertyGroup.build_properties_from_data_model" )
def check_properties_after_building ( self, context ):
print ( "check_properties_after_building not implemented for " + str(self) )
accurate_3d_reactions: BoolProperty(
name="Accurate 3D Reaction",
description="If selected, molecules will look through partitions to "
"react.",
default=True)
center_molecules_grid: BoolProperty(
name="Center Molecules on Grid",
description="If selected, surface molecules will be centered on the "
"grid.",
default=False)
microscopic_reversibility_enum = [
('ON', "On", ""),
('OFF', "Off", ""),
('SURFACE_ONLY', "Surface Only", ""),
('VOLUME_ONLY', "Volume Only", "")]
microscopic_reversibility: EnumProperty(
items=microscopic_reversibility_enum, name="Microscopic Reversibility",
description="If false, more efficient but less accurate reactions",
default='OFF')
# Export all ascii
export_all_ascii: BoolProperty(
name="ASCII Molecule Files",
description="Positions of all molecules are also exported in ASCII format",
default=False)
# Notifications
all_notifications_enum = [
('INDIVIDUAL', "Set Individually", ""),
('ON', "On", ""),
('OFF', "Off", "")]
all_notifications: EnumProperty(
items=all_notifications_enum, name="All Notifications",
description="If on/off, all notifications will be set to on/off "
"respectively.",
default='INDIVIDUAL')
diffusion_constant_report_enum = [
('BRIEF', "Brief", ""),
('ON', "On", ""),
('OFF', "Off", "")]
diffusion_constant_report: EnumProperty(
items=diffusion_constant_report_enum, name="Diffusion Constant Report",
description="If brief, Mcell will report average diffusion distance "
"per step for each molecule.")
species_reactions_report: BoolProperty( # MCell4-specific
name="Species and Reactions Report",
description="If enabled, MCell will generate report files containing information on species and reactions used during simulation.",
default=False)
file_output_report: BoolProperty(
name="File Output Report",
description="If selected, MCell will report every time that reaction "
"data is written.",
default=False)
final_summary: BoolProperty(
name="Final Summary",
description="If selected, MCell will report about the CPU time used",
default=True)
iteration_report: BoolProperty(
name="Iteration Report",
description="If selected, MCell will report how many iterations have "
"completed based on total.",
default=True)
partition_location_report: BoolProperty(
name="Partition Location Report",
description="If selected, the partition locations will be printed.",
default=False)
probability_report_enum = [
('ON', "On", ""),
('OFF', "Off", ""),
('THRESHOLD', "Threshold", "")]
probability_report: EnumProperty(
items=probability_report_enum, name="Probability Report", default='ON',
description="If on, MCell will report reaction probabilites for each "
"reaction.")
probability_report_threshold: FloatProperty(
name="Threshold", min=0.0, max=1.0, precision=2)
varying_probability_report: BoolProperty(
name="Varying Probability Report",
description="If selected, MCell will print out the reaction "
"probabilites for time-varying reaction.",
default=True)
progress_report: BoolProperty(
name="Progress Report",
description="If selected, MCell will print out messages indicating "
"which part of the simulation is underway.",
default=True)
release_event_report: BoolProperty(
name="Release Event Report",
description="If selected, MCell will print a message every time "
"molecules are released through a release site.",
default=True)
molecule_collision_report: BoolProperty(
name="Molecule Collision Report",
description="If selected, MCell will print the number of "
"bi/trimolecular collisions that occured.",
default=False)
# Warnings
all_warnings_enum = [
('INDIVIDUAL', "Set Individually", ""),
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
all_warnings: EnumProperty(
items=all_warnings_enum, name="All Warnings",
description="If not \"Set Individually\", all warnings will be set "
"the same.",
default='INDIVIDUAL')
large_molecular_displacement_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
large_molecular_displacement: EnumProperty(
items=large_molecular_displacement_enum, name="Large Molecular Displacement",
description="Generate warnings or errors for large molecular displacement.",
default='WARNING')
degenerate_polygons_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
degenerate_polygons: EnumProperty(
items=degenerate_polygons_enum, name="Degenerate Polygons",
description="Degenerate polygons have zero area and must be removed.",
default='WARNING')
high_reaction_probability_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
high_reaction_probability: EnumProperty(
items=high_reaction_probability_enum, name="High Reaction Probability",
description="Generate warnings or errors if probability reaches a "
"specified threshold.",
default='IGNORED')
high_reaction_probability_enum_mcell4 = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", "")]
high_reaction_probability_mcell4: EnumProperty(
items=high_reaction_probability_enum_mcell4, name="High Reaction Probability",
description="Generate warnings if bimolecular reaction probability reaches 50%, "
"warnings when reaction probability reaches 100% are always printed.",
default='IGNORED')
high_probability_threshold: FloatProperty(
name="High Probability Threshold", min=0.0, max=1.0, default=1.0,
precision=2)
lifetime_too_short_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", "")]
lifetime_too_short: EnumProperty(
items=lifetime_too_short_enum, name="Lifetime Too Short",
description="Generate warning if molecules have short lifetimes.",
default='WARNING')
lifetime_threshold: IntProperty(
name="Threshold", min=0, default=50)
missed_reactions_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", "")]
missed_reactions: EnumProperty(
items=missed_reactions_enum, name="Missed Reactions",
description="Generate warning if there are missed reactions.",
default='WARNING')
missed_reaction_threshold: FloatProperty(
name="Threshold", min=0.0, max=1.0, default=0.001,
precision=4)
negative_diffusion_constant_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
negative_diffusion_constant: EnumProperty(
items=negative_diffusion_constant_enum,
description="Diffusion constants cannot be negative and will be set "
"to zero.",
name="Negative Diffusion Constant", default='WARNING')
missing_surface_orientation_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
missing_surface_orientation: EnumProperty(
items=missing_surface_orientation_enum,
description="Generate errors/warnings if molecules are placed on "
"surfaces or reactions occur at surfaces without "
"specified orientation.",
name="Missing Surface Orientation",
default='ERROR')
negative_reaction_rate_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
negative_reaction_rate: EnumProperty(
items=negative_reaction_rate_enum, name="Negative Reaction Rate",
description="Reaction rates cannot be negative and will be set "
"to zero.",
default='WARNING')
useless_volume_orientation_enum = [
('IGNORED', "Ignored", ""),
('WARNING', "Warning", ""),
('ERROR', "Error", "")]
useless_volume_orientation: EnumProperty(
items=useless_volume_orientation_enum,
description="Generate errors/warnings if molecules are released in a "
"volume or reactions occur in a volume with specified "
"orientation.",
name="Useless Volume Orientation", default='WARNING')
acc3D_show_help: BoolProperty ( default=False, description="Toggle more information about this parameter" )
center_on_grid_show_help: BoolProperty ( default=False, description="Toggle more information about this parameter" )
micro_rev_show_help: BoolProperty ( default=False, description="Toggle more information about this parameter" )
export_ascii_show_help: BoolProperty ( default=False, description="Toggle more information about this parameter" )
command_options_show_help: BoolProperty ( default=False, description="Toggle more information about this parameter" )
def draw_layout(self, context, layout):
mcell = context.scene.mcell
mcell4_mode = mcell.cellblender_preferences.mcell4_mode
if not mcell.initialized:
mcell.draw_uninitialized ( layout )
else:
ps = mcell.parameter_system
self.iterations.draw(layout,ps)
self.time_step.draw(layout,ps)
# Note that the run_simulation panel is effectively being drawn in the middle of this model_initialization panel!!!
mcell.run_simulation.draw_layout_queue(context,layout)
# Advanced Options
box = layout.box()
row = box.row(align=True)
row.alignment = 'LEFT'
if self.advanced:
row.prop(mcell.initialization, "advanced", icon='TRIA_DOWN',
text="Advanced Options", emboss=False)
self.time_step_max.draw(box,ps)
self.space_step.draw(box,ps)
self.interaction_radius.draw(box,ps)
if not mcell4_mode:
self.radial_directions.draw(box,ps)
self.radial_subdivisions.draw(box,ps)
self.vacancy_search_distance.draw(box,ps)
self.surface_grid_density.draw(box,ps)
if not mcell4_mode:
helptext = """Specifies which method to use for computing 3D
molecule-molecule interactions. If value is TRUE, then molecules will look
through partition boundaries for potential interacting partners – this is
slower but more accurate. If boolean is FALSE, then molecule interaction disks
will be clipped at partition boundaries and probabilities adjusted to get the
correct rate – this is faster but can be less accurate. The default is TRUE."""
ps.draw_prop_with_help ( box, "Accurate 3D Reactions", mcell.initialization, "accurate_3d_reactions", "acc3D_show_help", self.acc3D_show_help, helptext )
helptext = """If boolean is set to TRUE, then all molecules on
a surface will be located exactly at the center of their grid element. If
FALSE, the molecules will be randomly located when placed, and reactions will
take place at the location of the target (or the site of impact in the case of
3D molecule/surface reactions). The default is FALSE."""
ps.draw_prop_with_help ( box, "Center Molecules on Grid", mcell.initialization, "center_molecules_grid", "center_on_grid_show_help", self.center_on_grid_show_help, helptext )
if not mcell4_mode:
helptext = """If value is set to OFF, then binding- unbinding
reactions between molecules will be somewhat more efficient but may not be
accurate if the probability of binding is high (close to 1). If ON, a more
computationally demanding routine will be used to make sure binding- unbinding
is more similar in both directions. If value is set to SURFACE_ONLY or
VOLUME_ONLY, the more accurate routines will be used only for reactions at
surfaces or only for those in the volume. OFF is the default."""
ps.draw_prop_with_help ( box, "Microscopic Reversibility", mcell.initialization, "microscopic_reversibility", "micro_rev_show_help", self.micro_rev_show_help, helptext )
helptext = """Generate visualization data in ASCII format. The default is OFF."""
ps.draw_prop_with_help ( box, "ASCII Molecule Files", mcell.initialization, "export_all_ascii", "export_ascii_show_help", self.export_ascii_show_help, helptext )
if not mcell4_mode:
helptext = "Command Line Parameters - \n" \
"These options are passed directly to the program.\n" \
"Use -h to print MCell's help to console or text overlay.\n" \
"Visualization options (-z) are defined in viz_output.c.\n" \
"\n" \
" 0x01=All_components_share_name\n" \
" 0x02=All_components_by_global_name\n" \
" 0x03=All_components_by_mol_comp_name\n" \
" 0x08=Force_output_of_proxy_molecules\n" \
" 0x10=Generate_Text_BNGL_Viz_Files\n" \
" 0x20=Generate_JSON_BNGL_Viz_Files\n" \
"\n" \
"Debug output with -d # (between 0 and 100)"
ps.draw_prop_with_help ( box, "Command Options", mcell.initialization, "command_options", "command_options_show_help", self.command_options_show_help, helptext )
else:
row.prop(mcell.initialization, "advanced", icon='TRIA_RIGHT',
text="Advanced Options", emboss=False)
# Notifications
box = layout.box()
row = box.row(align=True)
row.alignment = 'LEFT'
if self.notifications:
row.prop(mcell.initialization, "notifications", icon='TRIA_DOWN',
text="Notifications", emboss=False)
if not mcell4_mode:
row = box.row()
row.prop(mcell.initialization, "all_notifications")
if self.all_notifications == 'INDIVIDUAL':
if not mcell4_mode:
row = box.row(align=True)
row.prop(mcell.initialization, "probability_report")
if self.probability_report == 'THRESHOLD':
row.prop(
mcell.initialization, "probability_report_threshold",
slider=True)
row = box.row()
row.prop(mcell.initialization, "diffusion_constant_report")
if mcell4_mode:
row = box.row()
row.prop(mcell.initialization, "species_reactions_report")
if not mcell4_mode:
row = box.row()
row.prop(mcell.initialization, "file_output_report")
row = box.row()
row.prop(mcell.initialization, "final_summary")
row = box.row()
row.prop(mcell.initialization, "iteration_report")
row = box.row()
row.prop(mcell.initialization, "partition_location_report")
row = box.row()
row.prop(mcell.initialization, "varying_probability_report")
if not mcell4_mode:
row = box.row()
row.prop(mcell.initialization, "progress_report")
row = box.row()
row.prop(mcell.initialization, "release_event_report")
row = box.row()
row.prop(mcell.initialization, "molecule_collision_report")
else:
row.prop(mcell.initialization, "notifications", icon='TRIA_RIGHT',
text="Notifications", emboss=False)
# Warnings
box = layout.box()
row = box.row(align=True)
row.alignment = 'LEFT'
if self.warnings:
row.prop(mcell.initialization, "warnings", icon='TRIA_DOWN',
text="Warnings", emboss=False)
row = box.row()
if not mcell4_mode:
row.prop(mcell.initialization, "all_warnings")
if self.all_warnings == 'INDIVIDUAL':
row = box.row()
row.prop(mcell.initialization, "large_molecular_displacement")
row = box.row()
row.prop(mcell.initialization, "degenerate_polygons")
row = box.row()
row.prop(mcell.initialization, "missing_surface_orientation")
row = box.row()
row.prop(mcell.initialization, "negative_diffusion_constant")
row = box.row()
row.prop(mcell.initialization, "negative_reaction_rate")
row = box.row()
row.prop(mcell.initialization, "useless_volume_orientation")
row = box.row(align=True)
row.prop(mcell.initialization, "high_reaction_probability")
if self.high_reaction_probability != 'IGNORED':
row.prop(mcell.initialization,
"high_probability_threshold", slider=True)
row = box.row(align=True)
row.prop(mcell.initialization, "lifetime_too_short")
if self.lifetime_too_short == 'WARNING':
row.prop(mcell.initialization, "lifetime_threshold")
row = box.row(align=True)
row.prop(mcell.initialization, "missed_reactions")
if self.missed_reactions == 'WARNING':
row.prop(mcell.initialization, "missed_reaction_threshold")
else: # mcell4
row = box.row()
row.prop(mcell.initialization, "high_reaction_probability_mcell4")
else:
row.prop(mcell.initialization, "warnings", icon='TRIA_RIGHT',
text="Warnings", emboss=False)
if (self.status != ""):
row = layout.row()
row.label(text=self.status, icon='ERROR')
def draw_panel ( self, context, panel ):
""" Create a layout from the panel and draw into it """
layout = panel.layout
self.draw_layout ( context, layout )
classes = (
MCellInitializationPropertyGroup,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)