Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixed?] clear_volume doesn't work on empty simulation #15

Open
Jintram opened this issue May 18, 2011 · 2 comments
Open

[fixed?] clear_volume doesn't work on empty simulation #15

Jintram opened this issue May 18, 2011 · 2 comments

Comments

@Jintram
Copy link

Jintram commented May 18, 2011

Problem

You might think this is not such a big problem, as usually the simulation isn't empty.

But I'm working on the rebinding sample, which, depending on arguments from the user, contains or doesn't contain inert X particles.

At a certain moment particles A and B are added to certain location, and therefore the volume should be cleared.

Now, when the user has decided there shouldn't be any X-particles, the eGFRD simulation crashes.

I don't know if this is the only case in which clear_volume crashes, but it's certainly something we should look into IMO.

Crash report:

wehrens@amocf23:~/myfork_egfrd/samples/rebind$ LOGLEVEL=ERROR PYTHONPATH=../.. python -O run.py 1 0 [INF] 100

Traceback (most recent call last):
File "run.py", line 306, in
int(sys.argv[2]), T_list, int(sys.argv[4]))
File "run.py", line 74, in run
r_list, t_list = singlerun(T_list, N_B, N_X)
File "run.py", line 190, in singlerun
dd = s.clear_volume(A_pos, float(A['radius']))
File "/storage1/wehrens/myfork_egfrd/egfrd.py", line 544, in clear_volume
return self.burst_objs(neighbors)
File "/storage1/wehrens/myfork_egfrd/egfrd.py", line 521, in burst_objs
for obj in objs:
File "/storage1/wehrens/myfork_egfrd/egfrd.py", line 1484, in get_neighbors_within_radius_no_sort
for container in self.containers:
AttributeError: 'EGFRDSimulator' object has no attribute 'containers'

Proposed solution

Simply build in a check in clear_volume that checks if there are domains at all, if not, just pass and return emtpy output.

@Jintram Jintram closed this as completed May 18, 2011
@Jintram
Copy link
Author

Jintram commented May 18, 2011

Resolved

I've resolved the situation by updating egfrd.py as follows:

def get_neighbors_within_radius_no_sort(self, pos, radius, ignore=[]):
    # Get neighbor domains within given radius.
    #
    # ignore: domain ids.
    #
    # Only returns neighbors, not the distances towards their 
    # shells. Can for example be used to try to clear all objects 
    # from a certain volume.

    try:
        for container in self.containers:
            result = container.get_neighbors_within_radius(pos, radius)
            # result = [((shell_id_shell_pair), distance), ]
            # Since a domain can have more than 1 shell (multis for 
            # example), and for each shell there is an entry in the 
            # shell container, we make sure each domain occurs only once 
            # in the returned list here.
            for did in uniq(s[0][1].did for s in result):
                if did not in ignore:
                    yield self.domains[did]
    except AttributeError:
        pass

Everyone ok with this?

If this is ok someone can close the issue.

@Jintram Jintram reopened this May 18, 2011
@Jintram
Copy link
Author

Jintram commented May 18, 2011

Log?

Perhaps such an exception should be logged in case this masks some bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant