Open hcferguson opened 3 years ago
I think I see why the weirdness of the second error is happening. When the first attempt fails, make_cluster
never makes it down to the lines where it restores the original values of mmin
and mmax
:
if 'orig_mmin' in locals():
mfc.mmin = orig_mmin
if 'orig_mmax' in locals():
mfc.mmax = orig_mmax
Oof, that's an ugly error. Can I suggest, though, that in this case you just want a Salpeter (powerlaw) IMF instead of a Kroupa, since you're only using one powerlaw?
This error still occurs; if you want to use a Kroupa MF with a minimum mass above the first break, you have to define it custom following the example in the code:
class Kroupa(MassFunction):
# kroupa = BrokenPowerLaw(breaks={0.08: -0.3, 0.5: 1.3, 'last': 2.3}, mmin=0.03, mmax=120)
default_mmin = 0.03
default_mmax = 120
def __init__(self,
mmin=default_mmin,
mmax=default_mmax,
p1=0.3,
p2=1.3,
p3=2.3,
break1=0.08,
break2=0.5):
"""
The Kroupa IMF with two power-law breaks, p1 and p2. See __call__ for
details.
"""
super().__init__(mmin=mmin, mmax=mmax)
self.p1 = p1
self.p2 = p2
self.p3 = p3
self.break1 = break1
self.break2 = break2
self.distr = distributions.BrokenPowerLaw([-p1, -p2, -p3],
[self.mmin, break1, break2, self.mmax])
self.normfactor = 1
Thanks for this very useful package!
In simulating nearby dwarf galaxies, I'd like to save time in make_cluster by setting a lower-mass limit that's pretty high. This worked with an earlier version of this package (or at least didn't throw an error). Now I'm getting an error having to do with checking where the breaks in the power law distribution are.
It works if I do
cl = imf.make_cluster(1000,massfunc='kroupa')
but throws an error if I docl = imf.make_cluster(1000,massfunc='kroupa',mmin=1.0)
.The weird thing is that if I then try to repeat the first command again
cl = imf.make_cluster(1000,massfunc='kroupa')
, it now throws a different error.Traceback from the first error:
Traceback from the second time