{ "cells": [ { "cell_type": "markdown", "id": "e115187a", "metadata": {}, "source": [ "# Spatially dependent uniaxial anisotropy\n", "\n", "In this notebook, an example is given for a spatially varying uniaxial anisotropy. To demonstrate it, we will use a nanotube (with R=30 nm and r=20 nm outer and inner radii) and set a radial uniaxial anisotropy with constant magnitude. Any other material parametes can be made spatially dependent, it isn't restricted to the uniaxial anisotropy." ] }, { "cell_type": "code", "execution_count": 1, "id": "a0ea9478", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " " ] } ], "source": [ "import tetrax as tx\n", "\n", "sample = tx.Sample(\n", " tx.geometries.waveguide.tube(20, 30, 3),\n", " name='tube_radial_uanis'\n", " )" ] }, { "cell_type": "markdown", "id": "bd7bbdd8", "metadata": {}, "source": [ "In the following we set a radial uniaxial anisotropy using the ```tx.vectorfields.radial(sample.xyz,1)``` function:" ] }, { "cell_type": "code", "execution_count": 2, "id": "53b30d39", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/attilak/micromag/tetrax-tests/fresh_environement_test/venv/lib/python3.13/site-packages/traittypes/traittypes.py:97: UserWarning: Given trait value dtype \"float32\" does not match required type \"float32\". A coerced copy has been created.\n", " warnings.warn(\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4409d9ac6baf4d62bb583acb41ee6ef8", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Plot(antialias=3, axes=['x', 'y', 'z'], axes_helper=1.0, axes_helper_colors=[16711680, 65280, 255], background…" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample.material[\"Ku1\"] = 1e6 #J/m^3\n", "sample.material[\"e_u\"] = tx.vectorfields.radial(sample.xyz,1)\n", "\n", "sample.show(sample.material[\"e_u\"].value)" ] }, { "cell_type": "markdown", "id": "fb1a08a1", "metadata": {}, "source": [ "![spatially dependent anisotropy](uanis_sp_dep.png)" ] }, { "cell_type": "markdown", "id": "124484f3-f8e7-43a5-b7ff-6644ac64348e", "metadata": {}, "source": [ "By initializing the tube in a transversally magnetized state, one will observe the stabilization of a two-domain state, by the radial anisotropy, with radial domains and Néel walls between them.\n", "This example is a perfect example for the usage of the LLG based dynamic relaxation, which will follow the preliminary nergy minimization." ] }, { "cell_type": "code", "execution_count": 3, "id": "c14f7e63", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Minimizing energy in using 'L-BFGS-B' (tolerance 1e-11) ...\n", "energy length density: -8.604699660646469e-10 J/m, = 0.15, = 0.77, = -0.00\n", "Failure. Returning last iteration step.\n", "Minimizing torque with over-damped LLG (alpha=1, tolerance=1e-10) ...\n", "t = 4.0205874505712437e-10 (s), dm/dt = 1330852.6056958192 [Hz], = 0.16, = 0.77, = 0.000\n", "Success!\n", "\n" ] } ], "source": [ "sample.mag = (0, 1, .1)\n", "\n", "relaxation = tx.experiments.relax(sample, \n", " set_initial_on_failure=False,\n", " tolerance=1e-11)\n", "\n", "if relaxation.was_success is False:\n", " relax_dyn = tx.experiments.relax_dynamic(sample, tolerance=1e-10)" ] }, { "cell_type": "code", "execution_count": 4, "id": "72b573d5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/attilak/micromag/tetrax-tests/fresh_environement_test/venv/lib/python3.13/site-packages/traittypes/traittypes.py:97: UserWarning: Given trait value dtype \"float32\" does not match required type \"float32\". A coerced copy has been created.\n", " warnings.warn(\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9573390ad0264d94b38e61b05ca954ec", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Plot(antialias=3, axes=['x', 'y', 'z'], axes_helper=1.0, axes_helper_colors=[16711680, 65280, 255], background…" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample.show()" ] }, { "cell_type": "markdown", "id": "56a1a596", "metadata": {}, "source": [ "![Magnetic state sp_dep_anis](mag_uanis_sp_dep.png)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.1" } }, "nbformat": 4, "nbformat_minor": 5 }