An often thrown exception in obe.py line 1008

41 views
Skip to first unread message

M.E. Vos

unread,
May 2, 2024, 4:22:22 AM5/2/24
to pylcp
Hello,

First of all, thank you for this amazing package. It really helps my research.

I am simulating a BaF molecule in 1D optical molasses. Very similar to the PyLCP CaF MOT example.

Often the simulation runs just fine, but sometimes the following error is thrown:
numpy.core._exceptions.UFuncTypeError: Cannot cast ufunc 'add' output from dtype('complex128') to dtype('float64') with casting rule 'same_kind'

It is thrown at obe.py line 1008.

As a solution i am tempted to edit line 1008 to:
f += f_mag.real

Have you even seen this exception and would you think this is a wise solution?

With kind regards,

Max Vos,

RUG, Netherlands

Eckel, Stephen P. (Fed)

unread,
May 6, 2024, 10:07:57 AM5/6/24
to M.E. Vos, pylcp
Hi Max,

I’ve indeed come across this exception before. As I recall, it typically happens because some numerical error has crept into the integrator, usually a failure to maintain normalization.  As a result, I have been hesitant to employ your suggested fix.

What I can recommend is trying different integrators.  There is a rather lengthy discussion on this topic on the GitHub issues page, namely issue #44.

Best regards,

-Steve

--
Dr. Stephen Eckel
Physicist
Sensor Sciences Division
Fundamental Thermodynamics Group
100 Bureau Drive, Stop 8364
Gaithersburg, MD 20899-8364
(301) 975-8571

--
You received this message because you are subscribed to the Google Groups "pylcp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylcp+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylcp/d2e2bfec-607e-4375-a3f3-b3d6750deae9n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages