<jupyter_start><jupyter_text>Field-free Hamiltonian<jupyter_code>H.e0()
plt.spy(H.e0());
# diagonal elements
H.e0().diagonal()
# i.e.
H.eigenenergies(units='atomic_units')
# alt.
eigenenergies(H.e0())<jupyter_output><empty_output><jupyter_text>Stark matrix<jupyter_code>H.stark(Fz=500.1)
plt.spy(H._stark_z_matrix)<jupyter_output><empty_output><jupyter_text>`scipy.linalg.eigvalsh` only uses the lower elements to compute the eigenvalues of a Hermitian matrix.   However, the full matrix is required by the sparse solver, `scipy.sparse.linalg.eigsh`. To calculate the upper elements too, set the `Hamiltonian.upper` attribute to `True`.<jupyter_code>H.reset()
H.upper = True
H.stark(Fz=500.1)
plt.spy(H._stark_z_matrix)<jupyter_output>Stark: 100%|██████████████████████████████████| 16/16 [00:00<00:00, 3615.19it/s]<jupyter_text>Zeeman matrix<jupyter_code>H.zeeman(Bz=150.0)
plt.spy(H._zeeman_matrix)<jupyter_output><empty_output><jupyter_text>Total Hamiltonian The underlying Stark and Zeeman terms have been cached for rapid recalculation.<jupyter_code>H.total(Fz=10.9, Bz=0.1)
plt.spy(H.total(Fz=10.9, Bz=0.1));<jupyter_output><empty_output><jupyter_text>However, the cache can be cleared using the `reset` method.<jupyter_code>H.reset()<jupyter_output><empty_output><jupyter_text>... the terms are subsequently recalculated when needed.<jupyter_code>H.total(Fz=10, Bz=.1, numerov=True)<jupyter_output>Stark (numerov): 100%|████████████████████████| 16/16 [00:00<00:00, 3237.75it/s]
Zeeman: 100%|█████████████████████████████████| 16/16 [00:00<00:00, 3651.98it/s]<jupyter_text>Total Hamiltonian matrix converted to an array.<jupyter_code>plt.matshow(H.total(Fz=0.02, Bz=.1).toarray())<jupyter_output><empty_output><jupyter_text>Eigenvalues are computed from dense matrices (requires more memory but faster than sparse calc.)<jupyter_code># eigenvalues
electric_field = 582  # V/m
magnetic_field = 0.2  # T
H.eigenenergies(electric_field, magnetic_field, units="eV")
# alt.
Fz = electric_field * e * a0 / En_h
Bz = magnetic_field * mu_B / En_h
eigenenergies(H.e0() + H.stark(Fz) + H.zeeman(Bz), units="eV")
M = H.total(Bz=.1)
M
type(M)<jupyter_output><empty_output><jupyter_text>dense matrices<jupyter_code>H.reset()
H.sparse_format = "array"
M = H.total(Fz=10, Bz=0.1, numerov=True)
type(M)
M.shape<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1818961818961819, 'fraction_numerical': 0.04633204633204633, 'mean_word_length': 7.7669172932330826, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '389851', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1114, 'n_tokens_neox': 974, 'n_words': 159, 'path': 'notebooks/Matrices.ipynb', 'repo_name': 'ad3ller/positronium_FS', 'size': '2331'}