[Numpy-discussion] The mu.py script will keep running and never end.

Andrea Gavana andrea.gavana at gmail.com
Sun Oct 11 01:32:29 EDT 2020


On Sun, 11 Oct 2020 at 07.14, Andrea Gavana <andrea.gavana at gmail.com> wrote:

> Hi,
>
> On Sun, 11 Oct 2020 at 00.27, Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
>
>> On Sun, Oct 11, 2020 at 1:48 AM Robert Kern <robert.kern at gmail.com>
>> wrote:
>> >
>> > You don't need to use vectorize() on fermi(). fermi() will work just
>> fine on arrays and should be much faster.
>>
>> Yes, it really does the trick. See the following for the benchmark
>> based on your suggestion:
>>
>> $ time python mu.py
>> [-10.999 -10.999 -10.999 ...  20.     20.     20.   ] [4.973e-84
>> 4.973e-84 4.973e-84 ... 4.973e-84 4.973e-84 4.973e-84]
>>
>> real    0m41.056s
>> user    0m43.970s
>> sys    0m3.813s
>>
>>
>> But are there any ways to further improve/increase efficiency?
>
>
>
> I believe it will get a bit better if you don’t column_stack an array 6000
> times - maybe pre-allocate your output first?
>
> Andrea.
>


I’m sorry, scratch that: I’ve seen a ghost white space in front of your
column_stack call and made me think you were stacking your results very
many times, which is not the case.


>
>
>>
>> Regards,
>> HY
>>
>> >
>> > On Sat, Oct 10, 2020, 8:23 AM Hongyi Zhao <hongyi.zhao at gmail.com>
>> wrote:
>> >>
>> >> Hi,
>> >>
>> >> My environment is Ubuntu 20.04 and python 3.8.3 managed by pyenv. I
>> >> try to run the script
>> >> <
>> https://notebook.rcc.uchicago.edu/files/acs.chemmater.9b05047/Data/bulk/dft/mu.py
>> >,
>> >> but it will keep running and never end. When I use 'Ctrl + c' to
>> >> terminate it, it will give the following output:
>> >>
>> >> $ python mu.py
>> >> [-10.999 -10.999 -10.999 ...  20.     20.     20.   ] [4.973e-84
>> >> 4.973e-84 4.973e-84 ... 4.973e-84 4.973e-84 4.973e-84]
>> >>
>> >> I have to terminate it and obtained the following information:
>> >>
>> >> ^CTraceback (most recent call last):
>> >>   File "mu.py", line 38, in <module>
>> >>     integrand=DOS*fermi_array(energy,mu,kT)
>> >>   File
>> "/home/werner/.pyenv/versions/datasci/lib/python3.8/site-packages/numpy/lib/function_base.py",
>> >> line 2108, in __call__
>> >>     return self._vectorize_call(func=func, args=vargs)
>> >>   File
>> "/home/werner/.pyenv/versions/datasci/lib/python3.8/site-packages/numpy/lib/function_base.py",
>> >> line 2192, in _vectorize_call
>> >>     outputs = ufunc(*inputs)
>> >>   File "mu.py", line 8, in fermi
>> >>     return 1./(exp((E-mu)/kT)+1)
>> >> KeyboardInterrupt
>> >>
>> >>
>> >> Any helps and hints for this problem will be highly appreciated?
>> >>
>> >> Regards,
>> >> --
>> >> Hongyi Zhao <hongyi.zhao at gmail.com>
>> >> _______________________________________________
>> >> NumPy-Discussion mailing list
>> >> NumPy-Discussion at python.org
>> >> https://mail.python.org/mailman/listinfo/numpy-discussion
>> >
>> > _______________________________________________
>> > NumPy-Discussion mailing list
>> > NumPy-Discussion at python.org
>> > https://mail.python.org/mailman/listinfo/numpy-discussion
>>
>>
>>
>> --
>> Hongyi Zhao <hongyi.zhao at gmail.com>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
>> https://mail.python.org/mailman/listinfo/numpy-discussion
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20201011/1ba34017/attachment.html>


More information about the NumPy-Discussion mailing list