.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/RydbergRb87_3d_groundstate.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_RydbergRb87_3d_groundstate.py: Ground state search for a Rydberg system (Rb87) =============================================== Rb87 with Rydberg state 70s1/2) in a 3d setup. .. GENERATED FROM PYTHON SOURCE LINES 17-98 .. code-block:: Python # pylint: disable=invalid-name import numpy as np import numpy.linalg as nla import qtealeaves as qtl from qtealeaves import modeling def main(tn_type=5, output_folder=None): """ Main method for the ground state search of the 3d Rydberg model. **Arguments** tn_type : int, optional Choose 5 for python-TTN, 6 for python-MPS. Default to 5. output_folder : str | None, optional Output folder. Default to None. """ model_name = lambda params: "Rydberg_L%d" % (params["L"]) if output_folder is None: output_folder = lambda params: "Rb87_L%d" % (params["L"]) model = modeling.QuantumModel(3, "L", name=model_name) model += modeling.LocalTerm("sx", strength="Jx") model += modeling.LocalTerm("n", strength="U") model += modeling.TwoBodyTerm3D(["n", "n"], [1, 0, 0], strength="V1") model += modeling.TwoBodyTerm3D(["n", "n"], [1, 1, 0], strength="V2") model += modeling.TwoBodyTerm3D(["n", "n"], [1, 1, 1], strength="V3") model += modeling.TwoBodyTerm3D(["n", "n"], [2, 0, 0], strength="V4") my_conv = qtl.convergence_parameters.TNConvergenceParameters( max_iter=3, max_bond_dimension=2 ) my_ops = qtl.operators.TNSpin12Operators() my_obs = qtl.observables.TNObservables() my_obs += qtl.observables.Local("", "sx") simulation = qtl.QuantumGreenTeaSimulation( model, my_ops, my_conv, my_obs, tn_type=tn_type, folder_name_output=output_folder, store_checkpoints=False, ) params = [ {"L": 4, "Jx": 2.0, "U": -15.0, "V1": 25.0, "V2": 3.12, "V3": 0.92, "V4": 0.39} ] simulation.run(params, delete_existing_folder=True) for elem in params: tn_energy_0 = simulation.get_static_obs(elem)["energy"] if elem["L"] == 2: ed_energy_0 = nla.eigh(model.build_ham(my_ops, elem))[0][0] print("TN vs ED ground state energy", tn_energy_0, ed_energy_0) assert np.abs(tn_energy_0 - ed_energy_0) < 1e-4 msg_check = "ground state energy at least correct up to 1e-4." else: print("TN ground state energy", tn_energy_0) msg_check = "no asserts implemented for this system size." print(f"\nExample `{__file__}` ran successfully; {msg_check}") return if __name__ == "__main__": main() .. _sphx_glr_download_auto_examples_RydbergRb87_3d_groundstate.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: RydbergRb87_3d_groundstate.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: RydbergRb87_3d_groundstate.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: RydbergRb87_3d_groundstate.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_