keflavich / imf

Simple tools to work with the Initial Mass Function
MIT License
44 stars 17 forks source link

imf.make_cluster seems to ignore mmax #4

Closed wbuthod closed 5 years ago

wbuthod commented 5 years ago

Cluster minimum value corresponds to mmin kwarg, but mmax seems fixed at 120:

>>> c = imf.make_cluster(1000000,mmax=1,mmin=0.01);print(min(c),max(c))
Total cluster mass is 1e+06 (limit was 1e+06)
0.01004723201122255 119.41505448137
>>> c = imf.make_cluster(1000000,mmax=10,mmin=0.05);print(min(c),max(c))
Total cluster mass is 1e+06 (limit was 1e+06)
0.0501955360990432 119.50937842295497
>>> c = imf.make_cluster(1000000,mmax=100,mmin=1.);print(min(c),max(c))
Total cluster mass is 1e+06 (limit was 1e+06)
1.002401892692579 119.37502733413447
>>> c = imf.make_cluster(1000000,mmax=1000,mmin=1.);print(min(c),max(c))
Total cluster mass is 999999 (limit was 1e+06)
1.002401892692579 119.67021822529088
wbuthod commented 5 years ago

I should mention that imf.inverse_imf does not ignore the mmax kwarg:

>>> max([imf.inverse_imf(imf.np.random.uniform(),mmin=90.01, mmax=200.0) for _ in range(1000)])
199.6108355378401
>>> max([imf.inverse_imf(imf.np.random.uniform(),mmin=90.01, mmax=300.0) for _ in range(1000)])
299.6146391509267
keflavich commented 5 years ago

Good catch, this was because of a failure to pass the mmax kwarg correctly. A fix is forthcoming.

keflavich commented 5 years ago

Fixed in 48d15a050717a840961c37167924f9017daf7b7d