gfrd / egfrd

enhanced Green's Function Reaction Dynamics
egfrd.org
GNU General Public License v2.0
9 stars 10 forks source link

Bug when running script w. direct binding #86

Closed Jintram closed 12 years ago

Jintram commented 12 years ago

Have a script with reaction network that allows for reactions between particles in membrane and in bulk. Get the following error message:

$export PYTHONPATH=~/...
$./test_directbinding.py 1 1
Traceback (most recent call last):
  File "./test_directbinding.py", line 329, in <module>
    s.step()                       
  File "/home/jintram/jintram_jul2012_egfrd/egfrd.py", line 445, in step
    f(self, domain, [domain.domain_id])         # fire the correct method for the class (e.g. process_single_event(self, Single))
  File "/home/jintram/jintram_jul2012_egfrd/egfrd.py", line 1760, in process_single_event
    domains = [self.make_new_domain(single)]
  File "/home/jintram/jintram_jul2012_egfrd/egfrd.py", line 1588, in make_new_domain
    domain = self.try_pair (single, obj)
  File "/home/jintram/jintram_jul2012_egfrd/egfrd.py", line 2296, in try_pair
    testShell = try_default_testpair(single1, single2, self.geometrycontainer, self.domains)
  File "/home/jintram/jintram_jul2012_egfrd/egfrd.py", line 148, in try_default_testpair
    return MixedPair2D3DtestShell(single2, single1, geometrycontainer, domains)
  File "/home/jintram/jintram_jul2012_egfrd/shells.py", line 2054, in __init__
    testMixedPair2D3D.__init__(self, single2D, single3D)
  File "/home/jintram/jintram_jul2012_egfrd/shells.py", line 317, in __init__
    testPair.__init__(self, single2D, single3D)
  File "/home/jintram/jintram_jul2012_egfrd/shells.py", line 229, in __init__
    self.com, self.iv = self.do_transform()         # NOTE The IV always points from particle1 to particle2
  File "/home/jintram/jintram_jul2012_egfrd/shells.py", line 348, in do_transform
    com = self.world.cyclic_transpose(com, self.structure2D.shape.position)
AttributeError: 'MixedPair2D3DtestShell' object has no attribute 'structure2D'

[Incorrect remark; but fixed bug, see below.]

YetAnotherTomek commented 12 years ago

This should be easily fixed by exchanging the order of defining self.structure2D and self.structure3D in testMixedPair2D3D and calling the initializer of testPair, i.e.:

 def __init__(self, single2D, single3D):

        if __debug__: 
                assert isinstance(single2D.structure, PlanarSurface) 
                assert isinstance(single3D.structure, CuboidalRegion)

        # for clarity:
        self.structure2D = single2D.structure   # equal to self.structure1
        self.structure3D = single3D.structure   # equal to self.structure2

        testPair.__init__(self, single2D, single3D)
          # note: this makes self.single1/self.pid_particle_pair1/self.structure1 for the 2D particle
          #              and self.single2/self.pid_particle_pair2/self.structure2 for the 3D particle
Jintram commented 12 years ago

Done


 310 class testMixedPair2D3D(testPair):
 311 
 312     def __init__(self, single2D, single3D):
 313 
 314         # First define 
 315         # for clarity:
 316         self.structure2D = single2D.structure   # equal to self.structure1
 317         self.structure3D = single3D.structure   # equal to self.structure2
 318 
 319         # These methods need above definitions.
 320         if __debug__:
 321                 assert isinstance(single2D.structure, PlanarSurface)
 322                 assert isinstance(single3D.structure, CuboidalRegion)
 323         testPair.__init__(self, single2D, single3D)
 324           # note: this makes self.single1/self.pid_particle_pair1/self.structure1 for the 2D particle
 325           #              and self.single2/self.pid_particle_pair2/self.structure2 for the 3D particle

Seems to work.