mgrau / atomphys Goto Github PK
View Code? Open in Web Editor NEWA Python package to help with atomic physics calculations.
Home Page: https://atomphys.org
License: MIT License
A Python package to help with atomic physics calculations.
Home Page: https://atomphys.org
License: MIT License
atom.Atom('H',refresh_cache=True)
59 return [
60 {
61 **{
62 "energy": remove_annotations(state["Level (Ry)"]) + " Ry",
63 "term": print_term(state["Term"], J=state["J"]),
64 "configuration": state["Configuration"],
65 "g": None if state["g"] == "" else float(state["g"]),
66 },
67 **(
68 {"n": int(monovalent.match(state["Configuration"])["n"])}
69 if monovalent.match(state["Configuration"])
70 else {}
71 ),
72 }
73
74 for state in data
---> 75 if print_term(state["Term"], J=state["J"])
76 ]
KeyError: 'Term'
It seems that the parameter land_out=off results in invalid column settings for the nist website which breaks the fetching procedure.
Replacing land_out=on seems to fix it.
For a dipole-forbidden transition
in Atoms
), the matrix_element
attribute is unexpectedly nonzero:
>>> Ca_plus = Atom('Ca+')
>>> Ca_plus('4S1/2').to('3D5/2').matrix_element.to('e a0').m
0.0012221264747753456
I guess that the problem originates from the fact that the code doesn't try to distinguish between dipole-allowed and dipole-forbidden transitions. It and always calculates matrix element from lifetime using the dipole formula, whereas it is not valid for quadrupole and higher-order transitions.
print(Rb('S1/2').to('P1/2').λ.to('nm'))
returns 795 nm
and not 785 nm
as stated in the readme.
I found that some of the values from the NIST database are outdated. In particular, the A coefficient for the 40Ca+ ion D5/2 (729 nm) transition is pretty off. The value from NIST is a theoretical value of 1.3 s^-1 , whereas more recent measurements (i.e. https://journals.aps.org/pra/abstract/10.1103/PhysRevA.62.032503) give 0.86 s-1. Dipole transitions have less discrepancies, but are still outdated.
The polarizability for J = 0 states cannot be calculated due to a divide by zero in the calculation of the prefactor for the vector polarizability
atomphys/atomphys/calc/polarizability.py
Line 227 in d8b20d3
A J = 0 state does not have a vector polarizability since the Clebsch-Gordan coefficient <J=0, mj; 1, 0| J=0, mj> = 0 appearing in eq. (10) of http://dx.doi.org/10.1140/epjd/e2013-30729-x is zero.
Therefore,
if J == 0:
C1 = 0
else:
C1 = A * cos(θk) * mJ / J
solves the problem.
I installed atomphys
and failed to run the example from README.md
:
>>> from atomphys import Atom
>>> Rb = Atom('Rb')
This code resulted in an error:
Traceback (most recent call last):
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 40, in __init__
self.load(atom)
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 92, in load
with open(filename) as file:
FileNotFoundError: [Errno 2] No such file or directory: 'Rb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 4, in <module>
Rb = Atom('Rb', refresh_cache=True)
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 42, in __init__
self.load_nist(atom, refresh_cache)
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 114, in load_nist
self._load_states(nist.parse_states(nist.fetch_states(atom, refresh_cache)))
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/data/nist.py", line 55, in parse_states
return [
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/data/nist.py", line 70, in <listcomp>
if print_term(state["Term"], J=state["J"])
KeyError: 'Term'
In nist.py
, change the options in values
dictionary (line 27) to the following:
values = {
"spectrum": atom,
"units": 2, # energy units {0: cm^-1, 1: eV, 2: Ry}
"format": 3, # format {0: HTML, 1: ASCII, 2: CSV, 3: TSV}
"multiplet_ordered": 1, # energy ordred
"term_out": "on", # output the term symbol string
"conf_out": "on", # output the configutation string
"level_out": "on", # output the energy level
"unc_out": 1, # uncertainty on energy # --- changed 0 to 1
"j_out": "on", # output the J level
"g_out": "on", # output the g-factor
"lande_out": "on", # output experimentally measured g-factor # changed from "off" to "on"
}
I discovered that the error is caused by incorrect data retrieval from NIST. In fetch_states
in nist.py
, the URL request constructed from the values
dictionary is not correctly processed by https://physics.nist.gov. Instead of a .tsv
with the energy levels, https://physics.nist.gov returns the error page "Invalid Column Setting". The example URL request generated by current code version and causing error:
https://physics.nist.gov/cgi-bin/ASD/energy1.pl?spectrum=rb+i&units=2&format=3&multiplet_ordered=1&term_out=on&conf_out=on&level_out=on&unc_out=0&j_out=on&g_out=on&lande_out=off
Changing the options to lande_out=on
and unc_out=1
yields the correct result.
In transition.py and several tests, there are many expressions containing _ureg.h. It is obviously intended to be Planck constant but actually denotes an hour as a time unit.
At the moment data has to be always fetched from the NIST database when the Atom
class is initialized. There are functions for caching the data but loading is not possible (ValueError: could not convert string to float: '0 E_h'). As a result atomphys is not usable offline or when the NIST database is not accessible.
Proposed changes:
atom.load
to correctly load cached data.Atom
class.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.