.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "school-tutorials/trilmax-2025/2_black-box/plot_1_optimize-sd.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_school-tutorials_trilmax-2025_2_black-box_plot_1_optimize-sd.py: Optimization of spin directions ******************************* .. admonition:: Tutorial tasks * Display list of all available parameters for the script. * Optimize the Hamiltonian and inspect the output files. * Optimize the Hamiltonian on several super-cells. Are there any changes of the ground state? * Optimize with different directions and values of the external magnetic field. How does the result change? For the guide on the script read |magnopy-optimize-sd|_. Below we give two examples that were run on the reference files from |GROGU|_. Two reference files can be found in the ``Tutorial_2/magnopy-as-a-black-box`` folder. Here are the reference input files * :download:`CrI3/reference-GROGU.txt <../../resources/trilmax-2025/CrI3/reference-GROGU.txt>` * :download:`CrI3_U/reference-GROGU.txt <../../resources/trilmax-2025/CrI3_U/reference-GROGU.txt>` Links for downloading reference output files can be found at the end of each section. Optimization on the unit cell ============================= First, let us optimize the spin directions on the given unit cell of the spin Hamiltonian. To do so run the commands .. code-block:: bash magnopy-optimize-sd -ss GROGU -sf CrI3/reference-GROGU.txt -of CrI3/optimize-sd-output -hpd > console-output.txt and .. code-block:: bash magnopy-optimize-sd -ss GROGU -sf CrI3_U/reference-GROGU.txt -of CrI3_U/optimize-sd-output -hpd > console-output.txt in the terminal. Input parameters ---------------- Let us go through the parameters * ``-ss GROGU`` Tells magnopy that the Hamiltonian is coming from |GROGU|_. * ``-sf CrI3/reference-GROGU.txt`` Tells magnopy where the file with the Hamiltonian is located. The path, that is given for the ``-sf`` argument have to be either absolute or relative to the folder from which you execute the script. * ``-of CrI3/optimize-sd-output`` Tells magnopy to save all output files inside the "CrI3/optimize-sd-output" folder. * ``-of -hpd`` Tells magnopy to hide some of the user's private data in the output. Do not affect the calculation of magnopy, simply a decoration for the output. * ``> console-output.txt`` Redirects text output of magnopy and saves it to the file "console-output.txt", that will be created in the folder from which you executed the script. To display the text in the terminal and to save it to the file simultaneously use ``| tee console-output.txt`` instead. Output files ------------ After the successful completion of the script you can find several files in the output folder. Below we list all those files and give links where you can download examples of those files. * "console-output.txt" This is the main output file of magnopy that lists the steps of the calculations, gives comments, warnings and details of the files with data that were produced and where they have been saved. .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd/console-output.txt :caption: Content of "console-output.txt" for CrI3 * "INITIAL_GUESS.txt" This file describes the initial guess for spin directions that was used by the optimization routine. The initial guess is random, meaning that it is going to be different every time you run the program. In the file you will find one direction per line - initial guesses for each magnetic center. In the same order as they appear in the input file from |GROGU|_. .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd/INITIAL_GUESS.txt :caption: Content of "INITIAL_GUESS.txt" for CrI3 * "SPIN_POSITIONS.txt" This file gives Cartesian (absolute) coordinates of every magnetic center in the unit cell. One magnetic center per line, order is the same as in the input file from |GROGU|_. .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd/SPIN_POSITIONS.txt :caption: Content of "SPIN_POSITIONS.txt" for CrI3 * "SPIN_DIRECTIONS.txt" This file gives final, optimized spin directions for each spin in the unit cell. One spin per line, order is the same as in the input file from |GROGU|_. .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd/SPIN_DIRECTIONS.txt :caption: Content of "SPIN_DIRECTIONS.txt" for CrI3 * "SPIN_DIRECTIONS.html" This file visualizes the results of calculation in the interactive 3D picture. Unit cell, supercell (if any), initial guess and optimize spin directions are plotted. Download the files for "CrI3/reference-GROGU.txt" ------------------------------------------------- * :download:`console-output.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd/console-output.txt>` * :download:`INITIAL_GUESS.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd/INITIAL_GUESS.txt>` * :download:`SPIN_POSITIONS.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd/SPIN_POSITIONS.txt>` * :download:`SPIN_DIRECTIONS.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd/SPIN_DIRECTIONS.txt>` * :download:`SPIN_DIRECTIONS.html (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd/SPIN_DIRECTIONS.html>` Download the files for "CrI3_U/reference-GROGU.txt" --------------------------------------------------- * :download:`console-output.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd/console-output.txt>` * :download:`INITIAL_GUESS.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd/INITIAL_GUESS.txt>` * :download:`SPIN_POSITIONS.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd/SPIN_POSITIONS.txt>` * :download:`SPIN_DIRECTIONS.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd/SPIN_DIRECTIONS.txt>` * :download:`SPIN_DIRECTIONS.html (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd/SPIN_DIRECTIONS.html>` Optimization on the supercell ============================= For some systems the true ground state may not have the same periodicity as the unit cell of the underlying crystal. In that case one shall try to optimize the spin directions on the supercell and check if any new local minima can be found. To do so run the commands .. code-block:: bash magnopy-optimize-sd -s 5 5 1 -ss GROGU -sf CrI3/reference-GROGU.txt -of CrI3/optimize-sd-output-5-5-1 -hpd > console-output.txt and .. code-block:: bash magnopy-optimize-sd -s 5 5 1 -ss GROGU -sf CrI3_U/reference-GROGU.txt -of CrI3_U/optimize-sd-output-5-5-1 -hpd > console-output.txt in the terminal. Input parameters ---------------- There is one extra parameter in the input * ``-s 5 5 1`` Tells magnopy to construct a :math:`(5,5,1)` supercell and minimize spin directions by varying all spins in the supercell independently. Output files ------------ The set of output files is the same * "console-output.txt" .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/console-output.txt :caption: Content of "console-output.txt" for CrI3 * "INITIAL_GUESS.txt" .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/INITIAL_GUESS.txt :caption: Content of "INITIAL_GUESS.txt" for CrI3 * "SPIN_POSITIONS.txt" .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/SPIN_POSITIONS.txt :caption: Content of "SPIN_POSITIONS.txt" for CrI3 * "SPIN_DIRECTIONS.txt" .. literalinclude:: ../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/SPIN_DIRECTIONS.txt :caption: Content of "SPIN_DIRECTIONS.txt" for CrI3 * "SPIN_DIRECTIONS.html" Download the files for "CrI3/reference-GROGU.txt" ------------------------------------------------- * :download:`console-output.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/console-output.txt>` * :download:`INITIAL_GUESS.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/INITIAL_GUESS.txt>` * :download:`SPIN_POSITIONS.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/SPIN_POSITIONS.txt>` * :download:`SPIN_DIRECTIONS.txt (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/SPIN_DIRECTIONS.txt>` * :download:`SPIN_DIRECTIONS.html (for CrI3.txt) <../../resources/trilmax-2025/CrI3/optimize-sd-5-5-1/SPIN_DIRECTIONS.html>` Download the files for "CrI3_U/reference-GROGU.txt" --------------------------------------------------- * :download:`console-output.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd-5-5-1/console-output.txt>` * :download:`INITIAL_GUESS.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd-5-5-1/INITIAL_GUESS.txt>` * :download:`SPIN_POSITIONS.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd-5-5-1/SPIN_POSITIONS.txt>` * :download:`SPIN_DIRECTIONS.txt (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd-5-5-1/SPIN_DIRECTIONS.txt>` * :download:`SPIN_DIRECTIONS.html (for CrI3_U.txt) <../../resources/trilmax-2025/CrI3_U/optimize-sd-5-5-1/SPIN_DIRECTIONS.html>` .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.005 seconds) .. _sphx_glr_download_school-tutorials_trilmax-2025_2_black-box_plot_1_optimize-sd.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_1_optimize-sd.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_1_optimize-sd.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_1_optimize-sd.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_