Skip to content

Commit

Permalink
fixed misleading warning (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Dec 15, 2022
1 parent d7807cf commit d702e09
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bsb/placement/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _fill_system(self, chunk, indicators):
for name, indicator in indicators.items()
]
# Create and fill the particle system.
system = ParticleSystem(track_displaced=True, scaffold=self.scaffold)
system = ParticleSystem(track_displaced=True, scaffold=self.scaffold, strat=self)
system.fill(voxels, particles)
return system

Expand Down Expand Up @@ -189,11 +189,12 @@ def __init__(self, origin, dimensions):


class ParticleSystem:
def __init__(self, track_displaced=False, scaffold=None):
def __init__(self, track_displaced=False, scaffold=None, strat=None):
self.particle_types = []
self.voxels = []
self.track_displaced = track_displaced
self.scaffold = scaffold
self.strat = strat

def fill(self, voxels, particles):
# Amount of spatial dimensions
Expand All @@ -213,12 +214,16 @@ def fill(self, voxels, particles):
)
)
pf = self.get_packing_factor()
if self.strat is not None:
strat_name = type(self.strat).__name__
else:
strat_name = "particle system"
msg = f"Packing factor {round(pf, 2)}"
if pf > 0.4:
if pf > 0.64:
msg += " exceeds geometrical maximum packing for spheres (0.64)"
elif pf > 0.4:
msg += " too high to resolve with ParticlePlacement"
msg += f" too high to resolve with {strat_name}"

count, pvol, vol = self._get_packing_factors()
raise PackingError(
Expand All @@ -227,7 +232,7 @@ def fill(self, voxels, particles):
)
elif pf > 0.2:
warn(
f"{msg} is too high for good ParticlePlacement performance.",
f"{msg} is too high for good {strat_name} performance.",
PackingWarning,
)
# Reset particles
Expand Down

0 comments on commit d702e09

Please sign in to comment.