### Run example script Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/install.rst Execute a standard example script to verify the mumax+ installation. This helps confirm that the compilation was successful. ```bash python examples/standardproblem4.py ``` -------------------------------- ### Execute Python Example Script Source: https://github.com/mumax/plus/blob/master/README.md Executes a standard Python example script from the examples directory. ```bash python standardproblem4.py ``` -------------------------------- ### Install mumax+ with pre-built wheels Source: https://github.com/mumax/plus/blob/master/docs/_build/html/install.html Use this command to install mumax+ and its dependencies if your system meets the pre-built wheel requirements. Replace `mumaxplus` with `mumaxplus[all]` to install optional dependencies. ```bash pip install mumaxplus -f https://github.com/mumax/plus/releases/expanded_assets/v1.2.1 ``` ```bash pip install mumaxplus[all] -f https://github.com/mumax/plus/releases/expanded_assets/v1.2.1 ``` -------------------------------- ### Build and Install mumax+ Source: https://github.com/mumax/plus/blob/master/INSTALL.md Install mumax+ using pip after setting up the environment. This command builds and installs the package in the current environment. ```bash pip install . ``` -------------------------------- ### Check Git installation Source: https://github.com/mumax/plus/blob/master/docs/_build/html/install.html Verify that Git is installed correctly on your system. ```bash git --version ``` -------------------------------- ### Install all mumax+ dependencies Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/install.rst Installs mumax+ along with all optional dependencies, such as those for 3D plotting, to preserve disk space. Use this if you need full functionality. ```bash pip install mumaxplus[all] ``` -------------------------------- ### Install mumax+ from Source (PyPI) Source: https://github.com/mumax/plus/blob/master/INSTALL.md Installs the latest stable version of mumax+ from PyPI by building from source. This method is used when pre-built wheels are not available or when contributing to development. ```bash pip install mumaxplus ``` -------------------------------- ### Install mumax+ Pre-built Wheel Source: https://github.com/mumax/plus/blob/master/INSTALL.md Installs mumax+ and its dependencies using a pre-built wheel. This is the recommended method for systems with compatible NVIDIA GPUs and Python versions. ```bash pip install mumaxplus -f https://github.com/mumax/plus/releases/expanded_assets/v1.2.1 ``` -------------------------------- ### Check Python installation Source: https://github.com/mumax/plus/blob/master/docs/_build/html/install.html Verify the installation of Python, pip, and conda by checking their respective versions. ```bash python --version ``` ```bash pip --version ``` ```bash conda --version ``` -------------------------------- ### Check CUDA installation Source: https://github.com/mumax/plus/blob/master/docs/_build/html/install.html Verify that the CUDA Toolkit is installed and accessible by checking its version. ```bash nvcc --version ``` -------------------------------- ### Check GCC installation on Linux Source: https://github.com/mumax/plus/blob/master/docs/_build/html/install.html Verify the GCC C++ compiler installation and check its version. ```bash gcc --version ``` -------------------------------- ### Standard Problem 2 Simulation Setup Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/examples/stdp2.rst Initializes simulation parameters for Standard Problem 2, including dimensions, material properties, and simulation time. This snippet sets up the basic environment for the simulation. ```python import mumax3 as mu mu.set_seed(12345) mu.set_threads(4) # Define simulation parameters Lz = 10e-9 # Thickness in meters # Define material properties mu.set_material(A=1e-11, D=0.0, Ms=1.0, K1=0.0, phi=0.0, Demag=True) # Define simulation time mu.set_time(1e-9) ``` -------------------------------- ### Mumax+ Simulation Setup and Langevin Comparison Source: https://github.com/mumax/plus/blob/master/examples/langevin.ipynb Sets up a mumax+ simulation environment, defines magnetic parameters, and compares simulation results with the Langevin theory for varying temperatures. Requires mumaxplus, numpy, and matplotlib. ```python msat = 800e3 cellvolume = 100e-27 bext = 0.05 temperatures = np.linspace(1, 500, 25) N = 1024 relaxtime = 1e-9 sampletime = 1e-9 nsamples = 200 world = World(cellsize=3*[np.power(cellvolume, 1./3.)]) magnet = Ferromagnet(world, Grid((N, 1, 1))) magnet.enable_demag = False magnet.aex = 0.0 magnet.alpha = 0.1 magnet.msat = msat magnet.magnetization = (0,0,1) # groundstate solver = world.timesolver @np.vectorize def expectation_mz_simul(bext, temperature): world.bias_magnetic_field = (0, 0, bext) magnet.temperature = temperature solver.run(relaxtime) outputquantities = {"mz": lambda: magnet.magnetization.average()[2]} timepoints = solver.time + np.linspace(0, sampletime, nsamples) output = world.timesolver.solve(timepoints, outputquantities) return np.average(output['mz']) m_simul = expectation_mz_simul(bext, temperatures) m_langevin = expectation_mz_langevin(msat, bext, temperatures, cellvolume) plt.plot(temperatures, m_simul, 'o', label="Simulation") plt.plot(temperatures, m_langevin, 'k-', label="theory") plt.xlabel("Temperature (K)") plt.ylabel("<$m_z$>") plt.legend() plt.show() ``` -------------------------------- ### Standard Problem 2 Simulation Setup Source: https://github.com/mumax/plus/blob/master/docs/examples/stdp2.rst This Python snippet sets up the simulation for Standard Problem 2, defining material properties and simulation parameters. It is intended for use with mumax3. ```python from mumax import * # Set up simulation parameters SetTimeStep(1e-12) SetDemag(1) SetSpinTrans(1) # Material properties # Thickness t = 10 nm, Exchange length lambda = 10 nm # t/lambda = 1 # Msat = 1 MA/m, A = 1e-11 J/m, Ku = 1e5 J/m^3, alpha = 0.1, Hext = (0,0,0) # Define the material Mat(Msat=1e6, A=1e-11, Ku=1e5, alpha=0.1, Hext=(0,0,0)) # Define the geometry # Box(10e-9, 10e-9, 10e-9) # Set up the simulation # This part is typically defined in the main script and not included here # for brevity, but it would involve defining the simulation box and # potentially boundary conditions or initial states. ``` -------------------------------- ### Magnetoelastic Simulation Setup Source: https://github.com/mumax/plus/blob/master/docs/examples/magnetoelastics.rst Initializes a magnet, applies a sinusoidal external field, and sets elastic parameters for a simulation. This snippet requires the mumax3 environment. ```python from mumax3 import * # Initialize a magnet magnetized to the right SetSaturation(1.0, 1.0, 0.0) # Minimize the magnet Minimize() # Assign elastic parameters and apply a circular area with an external sinusoidal field in the y-direction # The simulation runs for 0.5 ns and returns an animation of the y-magnetization and the amplified displacement. SetElasticity(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) SetExternalField(lambda x,y,z: (0.0, 0.5 * sin(2*pi*1e9*t), 0.0)) # Run the simulation for 0.5 ns Simulate(0.5e-9) # Save the animation of y-magnetization and amplified displacement SaveAnimation("magnetoelastic.mp4", "my", "my") ``` -------------------------------- ### Magnetoelastics Simulation Setup Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/examples/magnetoelastics.rst Initializes a magnet, sets elastic parameters, and applies a sinusoidal external field. This snippet requires the mumax/plus library. ```python import mumax3_plus as mp # Initialize simulation mp.init() # Set simulation parameters mp.set_sim_params(dt=0.5e-9, max_step=1000000) # Initialize a magnet magnetized to the right mp.set_m(1, 0, 0) # Minimize the magnet mp.minimize() # Assign elastic parameters and apply a circular area with an external sinusoidal field in the y-direction mp.set_elastic_params(lambda x, y, z: 1.0, lambda x, y, z: 1.0, lambda x, y, z: 1.0, lambda x, y, z: 0.0, lambda x, y, z: 0.0, lambda x, y, z: 0.0) mp.set_external_field(lambda x, y, z: 0.0, lambda x, y, z: 1e5 * np.sin(2 * np.pi * 1e9 * mp.t), lambda x, y, z: 0.0) # Run the simulation and record animation of y-magnetization and amplified displacement mp.run_sim(animation=True, filename='magnetoelastic.mp4') ``` -------------------------------- ### Install PyVista with trame support Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/shapes.rst Installs PyVista with optional trame support for enhanced 3D plotting interactivity. ```console pip install ipywidgets 'pyvista[all,trame]' ``` -------------------------------- ### Install GCC on Linux Source: https://github.com/mumax/plus/blob/master/INSTALL.md Installs the GCC compiler on Linux systems. This is a prerequisite for compiling mumax+ from source, especially when C++17 support is required. ```bash sudo apt-get install gcc ``` -------------------------------- ### Install Mumax+ Python Package Source: https://github.com/mumax/plus/blob/master/examples/colab.ipynb Installs a specific version of the mumaxplus Python package from a GitHub release wheel. It checks for the correct wheel based on the Python version and installs it using pip. ```python MUMAXPLUS_VERSION = "1.2.1" try: import google.colab import requests except ImportError: pass else: # Determine which wheel to use from platform import python_version_tuple major, minor, patch = python_version_tuple() PYVERSION = major + minor # Download the mumax+ wheel URL = f"https://github.com/mumax/plus/releases/download/v{MUMAXPLUS_VERSION}/mumaxplus-{MUMAXPLUS_VERSION}-cp{PYVERSION}-cp{PYVERSION}-manylinux_2_34_x86_64.whl" if requests.head(URL).status_code not in [200, 302]: raise ValueError(f"No wheel found for mumax+ {MUMAXPLUS_VERSION} on Python {major}.{minor}. Try another mumax+ version.") else: cmd = f'pip install -v "{URL}"' !{cmd} ``` -------------------------------- ### Check MSVC installation on Windows Source: https://github.com/mumax/plus/blob/master/docs/_build/html/install.html Verify the Microsoft Visual C++ compiler installation on Windows by checking if 'cl.exe' is in your PATH. ```bash where.exe cl.exe ``` -------------------------------- ### Install mumax+ for Live Python Code Changes Source: https://github.com/mumax/plus/blob/master/INSTALL.md Install mumax+ in editable mode. This allows changes to Python code to take effect without needing to reinstall. ```bash pip install -ve . ``` -------------------------------- ### Get Help for Vortex Configuration Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/magnetization.rst Displays the help documentation for the 'vortex' magnetization configuration function, showing its parameters and usage. ```console Help on function vortex in module mumaxplus.util.config: vortex(position, diameter, circulation, polarization) Return a vortex magnetization configuration. Parameters ---------- position: tuple of three floats The position of the vortex center. diameter: float The diameter of the vortex center. circulation: 1 or -1 Circulation of the vortex. polarization: 1 or -1 The polarization of the vortex center. ``` -------------------------------- ### Install Executable Source: https://github.com/mumax/plus/blob/master/src/cmd/CMakeLists.txt Installs the 'cmd' executable to the bin directory within the Conda environment prefix. This ensures the executable is available in the activated environment. ```cmake install(TARGETS cmd DESTINATION "$ENV{CONDA_PREFIX}/bin") ``` -------------------------------- ### Get Help for Predefined Configuration Source: https://github.com/mumax/plus/blob/master/docs/_build/html/tutorial/magnetization.html Retrieves help information for a specific predefined magnetization configuration function, such as 'vortex'. ```python help(config.vortex) ``` -------------------------------- ### Simulation Setup and Plotting Configuration Source: https://github.com/mumax/plus/blob/master/docs/_build/html/tutorial/precision.html Initializes simulation parameters, defines time step arrays for different integration methods, and configures the plot axes for visualizing simulation errors against time steps. This prepares for running and plotting the results of various numerical integration methods. ```python method_names = ["Heun", "BogackiShampine", "CashKarp", "Fehlberg", "DormandPrince"] exact_names = ["Heun", "Bogacki-Shampine", "Cash-Karp", "Fehlberg", "Dormand-Prince"] RK_names = ["RK12", "RK32", "RKCK45", "RKF45", "RK45"] exact_order = [2, 3, 5, 5, 5] dts_lower = [2e-12, 4e-12, 8e-12, 8e-12, 8e-12] # Lower bounds for the time steps dts_upper = [3e-11, 5e-11, 8e-11, 5e-11, 5e-11] # Upper bounds for the time steps N_dens = 30 # Amount of datapoints between two powers of 10 dts = [np.logspace(np.log10(dts_lower[i]), np.log10(dts_upper[i]), int(N_dens*(np.log10(dts_upper[i]) - np.log10(dts_lower[i])))) for i, _ in enumerate(method_names)] # Time step arrays # --- Plotting --- plt.xscale('log') plt.yscale('log') plt.xlim((0.9e-12, 1e-10)) plt.ylim((1e-6, 1)) plt.xlabel("Time step (s)") plt.ylabel("Absolute error after 10 precessions") plt.plot([], [], color="black", label="Theory") # Labels for theoretical results plt.scatter([], [], marker="o", color="black", label="Simulation") # Labels for simulated results # --- Simulation Loops --- orders = {} for i, method in enumerate(method_names): error = np.zeros(shape=dts[i].shape) for j, dt in enumerate(dts[i]): ``` -------------------------------- ### Plot Initial Magnetization Source: https://github.com/mumax/plus/blob/master/docs/_build/html/tutorial/stdp4.html Visualizes the initial magnetization of the ferromagnet. This is useful for verifying the setup before relaxation. ```python plot_field(magnet.magnetization, enable_quiver=False) ``` -------------------------------- ### Console Output of Magnet Center Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/magnetization.rst Example console output showing the calculated center coordinates of the magnet. ```console (9.949999935088272e-08, 4.9499998766577846e-08, 0.0) ``` -------------------------------- ### Console Output of Average Magnetization Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/magnetization.rst Example console output showing the normalized average magnetization vector. ```console [0.7071072459220886, 0.0, 0.7071072459220886] ``` -------------------------------- ### Magnetoelastic Simulation Setup and Execution Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/magnetoelastics.html Sets up a circular magnetic field excitation, defines material properties like damping and elastic force damping, configures the time solver, and runs the simulation, saving magnetization and displacement data. ```python Bdiam = 200e-9 # excitation diameter # circular magnetic field excitation at the center Bshape = shapes.Circle(Bdiam).translate(*magnet.center) Bmask = magnet._get_mask_array(Bshape, grid, world, "mask") magnet.bias_magnetic_field.add_time_term( lambda t: (0, Bac * math.sin(2*math.pi*f_B * t), 0), mask=Bmask) magnet.alpha = 0.004 magnet.eta = 1e10 # elastic force damping # plotting fig, ax = plt.subplots() u_scale = 1e5 # amplification of displacement u_skip = 10 # don't show every displacement world.timesolver.adaptive_timestep = False world.timesolver.timestep = 1e-12 frames = 400 steps_per_frame = 2 # save magnetization and displacement m = np.zeros(shape=(frames, ny, nx)) u = np.zeros(shape=(frames, *magnet.elastic_displacement.shape)) t = np.zeros(shape=(frames)) # run a simulation print("Simulating...") for i in tqdm(range(frames)): world.timesolver.steps(steps_per_frame) m[i,...] = magnet.magnetization.eval()[1,0,:,:] u[i,...] = magnet.elastic_displacement.eval() t[i] = world.timesolver.time ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/mumax/plus/blob/master/INSTALL.md Create a new conda environment from the 'environment.yml' file and activate it. This ensures all necessary dependencies are installed. ```bash conda env create -f environment.yml conda activate mumaxplus ``` -------------------------------- ### Initialize and Configure Magnetic System Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/DW_SAW.html Sets up the magnetic system by defining interfacial DMI and creating a two-domain state. Minimizes the initial magnetization configuration. ```python magnet.dmi_tensor.set_interfacial_dmi(1e-3) # Create a DW magnet.magnetization = twodomain((0,0,1), (-1,0,0), (0,0,-1), nx*cx/3, 5*cx) print("minimizing...") magnet.minimize() # minimize ``` -------------------------------- ### Image and Colorbar Setup for Magnetization Plotting Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/magnetoelastics.html Configures the image display for magnetization data, including setting the extent, color limits, and colormap. A colorbar is added and labeled to indicate the magnetization component. ```python # imshow setup im_extent = (-0.5*cx, length - 0.5*cx, -0.5*cy, width - 0.5*cy) vmax, vmin = np.max(m), np.min(m) vmax = max(abs(vmax), abs(vmin)) vmin = -vmax m_im = ax.imshow(m[0,...], origin="lower", extent=im_extent, vmin=vmin, vmax=vmax, cmap="seismic") # colorbar setup cbar = plt.colorbar(m_im) cbar.ax.set_ylabel(r"$$", rotation=270) # final touches ax.set_xlabel("$x$ (m)") ax.set_ylabel("$y$ (m)") ax.set_xlim(im_extent[0], im_extent[1]) ax.set_ylim(im_extent[2], im_extent[3]) ``` -------------------------------- ### Import necessary libraries and define material properties Source: https://github.com/mumax/plus/blob/master/docs/_build/html/tutorial/plot_field.html Imports numpy, matplotlib, and mumaxplus modules. Defines saturation magnetization, exchange length, damping, and anisotropy constants. This setup is typical for micromagnetic simulations. ```python import numpy as np import matplotlib.pyplot as plt from mumaxplus import Ferromagnet, Grid, World from mumaxplus.util.config import vortex from mumaxplus.util.formulary import exchange_length, magnetostatic_energy_density msat = 800e3 aex = 13e-12 alpha = 0.02 ku1 = 0.1 * magnetostatic_energy_density(msat) anisU = (1, 0, 0) # close to cube size where vortex and flower states have equal energy length_in_lex = 8.46 # in unit of exchange length ``` -------------------------------- ### Compare simulation error floor with different precisions Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/precision.rst This example demonstrates how floating-point precision affects the error floor by comparing simulation results with the analytical solution for a magnetic moment's precession. It sets the precision to SINGLE and simulates a spin in an external magnetic field. ```python import os os.environ["MUMAXPLUS_FP_PRECISION"] = "SINGLE" import matplotlib.pyplot as plt import numpy as np from math import acos, atan, pi, exp, tan, sin, cos, sqrt from mumaxplus import * from mumaxplus.util import * def magnetic_moment_precession(time, initial_magnetization, hfield_z, damping): """Return the analytical solution of the LLG equation for a single magnetic moment and an applied field along the z direction. """ mx, my, mz = initial_magnetization theta0 = acos(mz) phi0 = atan(my / mx) freq = GAMMALL_DEFAULT * hfield_z / (1 + damping ** 2) phi = phi0 + freq * time theta = pi - 2 * atan(exp(damping * freq * time) * tan(pi / 2 - theta0 / 2)) return np.array([sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)]) def single_system(method, dt): """This function simulates a single spin in a magnetic field of 0.1 T without damping. Returns the absolute error between the simulation and the exact solution. Parameters: method -- The used simulation method dt -- The time step """ # --- Setup --- world = World(cellsize=(1e-9, 1e-9, 1e-9)) magnetization = (1/np.sqrt(2), 0, 1/np.sqrt(2)) damping = 0.001 hfield_z = 0.1 # External field strength duration = 2*np.pi/(GAMMALL_DEFAULT * hfield_z) * (1 + damping**2) * 10 # Time of 10 precessions magnet = Ferromagnet(world, grid=Grid((1, 1, 1))) magnet.enable_demag = False magnet.magnetization = magnetization magnet.alpha = damping magnet.aex = 10e-12 magnet.msat = 1/MU0 world.bias_magnetic_field = (0, 0, hfield_z) # --- Run the simulation --- world.timesolver.set_method(method) world.timesolver.adaptive_timestep = False world.timesolver.timestep = dt world.timesolver.run(duration) ``` -------------------------------- ### Initialize World and Ferromagnet Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/langevin.rst Sets up the simulation environment by creating a World object and a Ferromagnet instance with specified properties like cell volume, grid size, and magnetic parameters. ```python cellvolume = 100e-27 # volume of a cubic cell N = 1024 # number of cells world = World(cellsize=3*[np.power(cellvolume, 1./3.)]) magnet = Ferromagnet(world, Grid((N, 1, 1))) magnet.enable_demag = False magnet.aex = 0.0 magnet.alpha = 0.1 magnet.msat = 800e3 magnet.magnetization = (0,0,1) # groundstate ``` -------------------------------- ### Setting up Ferromagnet Simulation Source: https://github.com/mumax/plus/blob/master/examples/plot_field.ipynb Initializes a `Ferromagnet` object with specified material properties and grid size. This code sets up the simulation environment before magnetization is applied. ```python from mumaxplus import Ferromagnet, Grid, World from mumaxplus.util.config import vortex from mumaxplus.util.formulary import exchange_length, magnetostatic_energy_density msat = 800e3 aex = 13e-12 alpha = 0.02 ku1 = 0.1 * magnetostatic_energy_density(msat) anisU = (1, 0, 0) # close to cube size where vortex and flower states have equal energy length_in_lex = 8.46 # in unit of exchange length lex = exchange_length(aex, msat) length = length_in_lex * lex N = 32 world = World(cellsize=(length / N, length / N, length / N)) magnet = Ferromagnet(world, Grid((N, N, N))) magnet.msat = msat magnet.aex = aex magnet.ku1 = ku1 magnet.anisU = anisU ``` -------------------------------- ### Install Specific GCC Version on Linux Source: https://github.com/mumax/plus/blob/master/INSTALL.md Installs a specific version of the GCC compiler on Linux. This is useful when a particular CUDA version requires a specific GCC version to avoid conflicts. ```bash sudo apt-get install gcc- ``` -------------------------------- ### Initialize Ferromagnet and Plot Initial Magnetization Source: https://github.com/mumax/plus/blob/master/examples/magnetization_configurations.ipynb Initializes a World, Ferromagnet, and plots the initial random magnetization. Requires mumaxplus and mumaxplus.util imports. ```python from mumaxplus import Ferromagnet, Grid, World from mumaxplus.util import plot_field world = World(cellsize=(1e-9,1e-9,1e-9)) magnet = Ferromagnet(world, Grid((200,100,1))) plot_field(magnet.magnetization, enable_quiver=False); ``` -------------------------------- ### Initialize Ferromagnetic World and Magnet Source: https://github.com/mumax/plus/blob/master/docs/_build/html/tutorial/langevin.html Sets up the simulation environment, including the world dimensions, grid, and magnetic material properties. This is a prerequisite for running magnetic simulations. ```python cellvolume = 100e-27 # volume of a cubic cell N = 1024 # number of cells world = World(cellsize=3*["3*np.power(cellvolume, 1./3.)"]) magnet = Ferromagnet(world, Grid((N, 1, 1))) magnet.enable_demag = False magnet.aex = 0.0 magnet.alpha = 0.1 magnet.msat = 800e3 magnet.magnetization = (0,0,1) # groundstate ``` -------------------------------- ### Variable.get Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Variable.html Get the current value of the variable field. ```APIDOC get() Get the variable value. ``` -------------------------------- ### aex (Ferromagnet property) Source: https://github.com/mumax/plus/blob/master/docs/_build/html/genindex.html Gets the aex property of a Ferromagnet. ```APIDOC ## aex (Ferromagnet property) ### Description Gets the aex property of a Ferromagnet. ### Method N/A (Property) ### Endpoint N/A (Property) ### Parameters (Details not provided in source) ### Request Example (Not applicable for property) ### Response (Not applicable for property) ``` -------------------------------- ### Create Altermagnet and Set Parameters Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/Bloch_wall_altermagnet.html Initializes the mumax+ World, Grid, and Altermagnet objects, then sets material properties like saturation magnetization, damping, anisotropy, and exchange interactions. ```python # ----------- Create altermagnet ----------- Nx = int(length / cs) Ny = int(width / cs) world = World((cs, cs, cs)) grid = Grid((Nx, 1, 1)) magnet = Altermagnet(world, grid) # ----------- Set parameters ----------- magnet.msat = Ms magnet.alpha = 0.01 magnet.ku1 = K magnet.anisU = (0, 0, 1) magnet.afmex_nn = A12 magnet.afmex_cell = A0 magnet.latcon = a magnet.alterex_1 = A1 # first exchange matrix eigenvalue magnet.alterex_2 = A2 # second exchange matrix eigenvalue magnet.alterex_angle = 0 # exchange frame of reference aligns with the simulation grid ``` -------------------------------- ### Import mumaxplus Configuration Utilities Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/magnetization.rst Imports the configuration module from mumaxplus.util, which contains predefined magnetization configurations. ```python import mumaxplus.util.config as config ``` -------------------------------- ### afmex_nn (Altermagnet property) Source: https://github.com/mumax/plus/blob/master/docs/_build/html/genindex.html Gets the afmex_nn property of an Altermagnet or Antiferromagnet. ```APIDOC ## afmex_nn (Altermagnet property) ### Description Gets the afmex_nn property of an Altermagnet or Antiferromagnet. ### Method N/A (Property) ### Endpoint N/A (Property) ### Parameters (Details not provided in source) ### Request Example (Not applicable for property) ### Response (Not applicable for property) ``` -------------------------------- ### afmex_cell (Altermagnet property) Source: https://github.com/mumax/plus/blob/master/docs/_build/html/genindex.html Gets the afmex_cell property of an Altermagnet or Antiferromagnet. ```APIDOC ## afmex_cell (Altermagnet property) ### Description Gets the afmex_cell property of an Altermagnet or Antiferromagnet. ### Method N/A (Property) ### Endpoint N/A (Property) ### Parameters (Details not provided in source) ### Request Example (Not applicable for property) ### Response (Not applicable for property) ``` -------------------------------- ### Initialize Ferromagnet and Minimize Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/plot_field.rst Sets up a Ferromagnet object with specified material properties and minimizes its magnetization state. This is a prerequisite for plotting. ```python import numpy as np import matplotlib.pyplot as plt from mumaxplus import Ferromagnet, Grid, World from mumaxplus.util.config import vortex from mumaxplus.util.formulary import exchange_length, magnetostatic_energy_density msat = 800e3 aex = 13e-12 alpha = 0.02 ku1 = 0.1 * magnetostatic_energy_density(msat) anisU = (1, 0, 0) # close to cube size where vortex and flower states have equal energy length_in_lex = 8.46 # in unit of exchange length lex = exchange_length(aex, msat) length = length_in_lex * lex N = 32 world = World(cellsize=(length / N, length / N, length / N)) magnet = Ferromagnet(world, Grid((N, N, N))) magnet.msat = msat magnet.aex = aex magnet.ku1 = ku1 magnet.anisU = anisU magnet.magnetization = (1, 0, 0.01) # flower # magnet.magnetization = vortex(magnet.center, length / 12, -1, 1) # vortex magnet.minimize() # make magnetization a shorter variable mag = magnet.magnetization ``` -------------------------------- ### adaptive_timestep (TimeSolver property) Source: https://github.com/mumax/plus/blob/master/docs/_build/html/genindex.html Gets or sets the adaptive timestep property for TimeSolver. ```APIDOC ## adaptive_timestep (TimeSolver property) ### Description Gets or sets the adaptive timestep property for TimeSolver. ### Method N/A (Property) ### Endpoint N/A (Property) ### Parameters (Details not provided in source) ### Request Example (Not applicable for property) ### Response (Not applicable for property) ``` -------------------------------- ### Initialize and Configure Rescaled Magnet Source: https://github.com/mumax/plus/blob/master/examples/plot_field.ipynb Sets up a rescaled magnetic system with specific material properties and initializes the magnetization as a vortex. ```python cs = length_in_lex / N rescaled_world = World((cs, cs, cs)) rescaled_magnet = Ferromagnet(rescaled_world, Grid((N, N, N))) rescaled_magnet.msat = np.sqrt(2/MU0) # so Km = 1/2 µ0 Msat² = 1 rescaled_magnet.aex = 1.0 # so l_ex = sqrt(aex / Km) = 1 rescaled_magnet.ku1 = 0.1 # 0.1 * Km as specified rescaled_magnet.anisU = (1, 0, 0) rescaled_magnet.magnetization = vortex(rescaled_magnet.center, length_in_lex / 12, -1, 1) # vortex rescaled_magnet.minimize() ``` -------------------------------- ### Build Documentation HTML Source: https://github.com/mumax/plus/blob/master/README.md Builds the HTML documentation for mumax⁺. Requires Sphinx and optionally clang-uml for class diagrams on Linux. ```bash make html ``` -------------------------------- ### full_magnetization Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Get the full magnetization vector for the entire system. This includes contributions from all sublattices. ```APIDOC ## Property: full_magnetization ### Description Returns the total magnetization vector of the system. ### Type (Not specified in source) ``` -------------------------------- ### InterParameter Methods Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.InterParameter.html Methods for setting and getting specific inter-region parameter values, and evaluating the quantity. ```APIDOC ## InterParameter Methods ### Description Methods for setting and getting specific inter-region parameter values, and evaluating the quantity. ### Methods - **eval()** - Evaluates the quantity. Returns a numpy array containing a symmetric matrix where each region index corresponds to a row/column index. The elements of this matrix correspond to the values of self between the two regions. - **set(_value_)** - Sets the InterParameter value between every different region to the same value. - **set_between(_i_, _j_, _value_)** - Sets the InterParameter value between regions i and j. - **get_between(_i_, _j_)** - Gets the InterParameter value between regions i and j. ### Return Type for get_between float ``` -------------------------------- ### Initialize Magnetoelastic Simulation Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/magnetoelastics.html Sets up the simulation environment, defines grid and world parameters, initializes a ferromagnet with magnetic properties, and applies a uniform bias magnetic field. The magnet is then minimized. ```python import numpy as np import math from tqdm import tqdm import matplotlib.pyplot as plt import matplotlib.animation as animation from mumaxplus import World, Grid, Ferromagnet import mumaxplus.util.shape as shapes length, width, thickness = 1e-6, 1e-6, 20e-9 nx, ny, nz = 256, 256, 1 cx, cy, cz = length/nx, width/ny, thickness/nz cellsize = (cx, cy, cz) grid = Grid((nx, ny, nz)) world = World(cellsize, mastergrid=Grid((nx, ny, 0)), pbc_repetitions=(2, 2, 0)) magnet = Ferromagnet(world, grid) magnet.msat = 1.2e6 magnet.aex = 18e-12 magnet.alpha = 0.004 Bdc = 5e-3 magnet.bias_magnetic_field = (Bdc, 0, 0) # uniform term magnet.magnetization = (1, 0, 0) magnet.minimize() ``` -------------------------------- ### steps Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.TimeSolver.html Make n steps with the time solver. ```APIDOC ## steps ### Description Make n steps with the time solver. ### Method Not specified (likely internal to the solver) ### Parameters * **_nsteps_**: The number of steps to take. ``` -------------------------------- ### Initialize and Set Magnetization Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/Bloch_wall_altermagnet.html Initializes the magnetization for two sublattices to create a domain wall. The system is then minimized to find the ground state. ```python dw_idx = 10 # initial guess of DW width (in cells) m = np.zeros(magnet.sub1.magnetization.shape) m[2, :, :, 0:Nx//2 - dw_idx] = 1 # Left domain m[1, :, :, Nx//2 - dw_idx:Nx//2 + dw_idx] = -1 # Domain wall m[2, :, :, Nx//2 + dw_idx:] = -1 # Right domain magnet.sub1.magnetization = m magnet.sub2.magnetization = -m # minimize to ground state magnet.minimize() ``` -------------------------------- ### run Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.TimeSolver.html Run the solver for a given duration. ```APIDOC ## run ### Description Run the solver for a given duration. ### Method Not specified (likely internal to the solver) ### Parameters * **duration** (_float_) – Duration in seconds. ``` -------------------------------- ### dmi_vector Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the DMI vector. This is a simplified representation of the DMI, often used in specific contexts. ```APIDOC ## Property: dmi_vector ### Description Sets or gets the DMI vector. ### Type (Not specified in source) ``` -------------------------------- ### latcon Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the lattice constant of the material. This parameter defines the fundamental spacing of the crystal lattice. ```APIDOC ## Property: latcon ### Description Sets or gets the lattice constant of the material. ### Type (Not specified in source) ``` -------------------------------- ### inter_afmex_nn Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the inter-sublattice nearest-neighbor exchange interaction for AFmex. This is important for systems with multiple sublattices. ```APIDOC ## Property: inter_afmex_nn ### Description Sets or gets the inter-sublattice nearest-neighbor exchange interaction parameter for AFmex. ### Type (Not specified in source) ``` -------------------------------- ### Initialize Voronoi Tessellation and Generate Regions Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/voronoi.html Sets up the simulation world and grid, defines a circular geometry, and initializes the VoronoiTessellator with a specified grain size to generate regions. This is useful for creating granular magnetic materials. ```python import matplotlib.pyplot as plt import numpy as np from mumaxplus import Ferromagnet, Grid, World from mumaxplus.util import Circle, VoronoiTessellator, vortex, plot_field, show_regions # Set up simulation parameters N = 256 c = 4e-9 d = 40e-9 world = World(cellsize=(c, c, d)) grid = Grid((N, N, 1)) # Create a circle diam = N*c geo = Circle(diam).translate(diam/2, diam/2, 0) # Initialize a Voronoi Tesselator using a grainsize of 40e-9 m tessellator = VoronoiTessellator(40e-9) regions = tessellator.generate(world, grid) ``` -------------------------------- ### afmex_cell Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the cell for the AFmex calculation. AFmex is a method for calculating exchange interactions in antiferromagnets. ```APIDOC ## Property: afmex_cell ### Description Sets or gets the cell used for the AFmex calculation. ### Type (Not specified in source) ``` -------------------------------- ### Import Libraries and Define Parameters Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/Bloch_wall_altermagnet.html Imports necessary libraries (mumaxplus, matplotlib, numpy) and defines material and simulation parameters for the altermagnetic domain wall. ```python from mumaxplus import World, Grid, Altermagnet import matplotlib.pyplot as plt import numpy as np # ----------- Material and simulation parameters ----------- cs = 0.5e-9 a = 0.35e-9 Ms = 2.9e5 K = 2e5 A1 = 25e-12 A2 = 15e-12 A0 = -5e-13 A12 = A0/2 length = 256e-9 width = 64e-9 ``` -------------------------------- ### Get Magnetization Shape Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/magnetization.rst Prints the shape of the magnetization array. Useful for understanding the dimensions for direct array manipulation. ```python print(magnet.magnetization.shape) ``` -------------------------------- ### max_intracell_angle Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Get the maximum angle between spins within the same unit cell. This can indicate the degree of non-collinearity in the magnetic structure. ```APIDOC ## Property: max_intracell_angle ### Description Returns the maximum angle between spins within a unit cell. ### Type (Not specified in source) ``` -------------------------------- ### Check System Information and GPU Specs Source: https://github.com/mumax/plus/blob/master/examples/colab.ipynb This snippet checks the operating system, Python version, and displays GPU/CUDA specifications using `uname`, `python --version`, and `nvidia-smi`. ```bash ! echo "This machine runs" $(uname) "with" $(python --version) "and provides the following GPU/CUDA specs:" ! nvidia-smi ``` -------------------------------- ### steps() Method Source: https://github.com/mumax/plus/blob/master/docs/_build/html/genindex.html Executes a specified number of simulation steps using the TimeSolver. ```APIDOC ## steps() (TimeSolver method) ### Description Executes a specified number of simulation steps. ### Method Call ### Endpoint `mumaxplus.TimeSolver.steps()` ``` -------------------------------- ### Magnetization Shape Output Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_sources/tutorial/magnetization.rst Example output showing the four-dimensional shape of the magnetization array: (component, z-cell, y-cell, x-cell). ```console (3, 1, 100, 200) ``` -------------------------------- ### Initialize Ferromagnet and Calculate Remanence Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/stdp2.html This snippet sets up the simulation environment, defines a ferromagnet, and calculates its remanence magnetization. It's useful for studying magnetic properties under varying dimensions. ```python L = L_p_d * d # dimensionless length L = length/l_ex t = t_p_d * d # dimensionless thickness t = thickness/l_ex nx, ny, nz = get_gridsize(L, d, t, l_ex=l_ex) world = World(cellsize=(L*l_ex/nx, d*l_ex/ny, t*l_ex/nz)) magnet = Ferromagnet(world, Grid((nx, ny, nz))) magnet.msat = msat magnet.aex = aex magnet.magnetization = (1, 1, 1) # fully saturated in specified direction magnet.minimize() # TODO: try relax m = magnet.magnetization.average() # remnance magnetization mx_list.append(m[0]) my_list.append(m[1]) ``` -------------------------------- ### angle_field Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the angle field, which might relate to an external field or an internal anisotropy that depends on the angle of magnetization. ```APIDOC ## Property: angle_field ### Description Sets or gets the angle field. ### Type (Not specified in source) ``` -------------------------------- ### neel_vector Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Get the Neel vector, which represents the direction of the staggered magnetization in an antiferromagnet. This is a key property for characterizing antiferromagnetic order. ```APIDOC ## Property: neel_vector ### Description Returns the Neel vector, representing the staggered magnetization. ### Type (Not specified in source) ``` -------------------------------- ### Import Libraries and Set Simulation Parameters Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/DW_SAW.html Imports necessary libraries (numpy, matplotlib, mumaxplus) and defines simulation time parameters. This sets up the basic environment for the simulation. ```python import numpy as np import matplotlib.pyplot as plt from mumaxplus import World, Grid, Ferromagnet from mumaxplus.util import twodomain, plot_field # simulation time run = 10e-9 steps = 1000 dt = run/steps ``` -------------------------------- ### dmi_tensors Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get all DMI tensors in the system. This provides a comprehensive way to define or retrieve all antisymmetric exchange interactions. ```APIDOC ## Property: dmi_tensors ### Description Sets or gets all DMI tensors in the system. ### Type (Not specified in source) ``` -------------------------------- ### World Class Initialization Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.World.html Initializes a World object with specified cell size and periodic boundary conditions. It can also accept a master grid. ```APIDOC ## World Class ### Description Represents the simulation world with defined cell size and periodic boundary conditions. ### Method Signature `__init__(cellsize, pbc_repetitions=(0, 0, 0), mastergrid=Grid(size=(0, 0, 0), origin=(0, 0, 0))) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **cellsize** (tuple[float] of size 3) - Required - A tuple of three floating pointing numbers which represent the dimensions of the cells in the x, y, and z direction. * **pbc_repetitions** (tuple[int] of size 3) - Optional - Defines the periodic boundary conditions in x, y, and z directions. Defaults to (0, 0, 0). * **mastergrid** (Grid) - Optional - The master grid for the simulation. Defaults to a Grid with size (0, 0, 0) and origin (0, 0, 0). ### Request Example ```python # Example of initializing a World object world = mumaxplus.World(cellsize=(10e-9, 10e-9, 10e-9), pbc_repetitions=(1, 1, 0)) ``` ### Response #### Success Response (200) This method does not return a value; it initializes the World object. #### Response Example None ``` -------------------------------- ### afmex_nn Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the nearest-neighbor exchange interaction for AFmex. This parameter is crucial for defining the strength of interactions between adjacent spins. ```APIDOC ## Property: afmex_nn ### Description Sets or gets the nearest-neighbor exchange interaction parameter for AFmex. ### Type (Not specified in source) ``` -------------------------------- ### Initialize Ferromagnet and World Source: https://github.com/mumax/plus/blob/master/docs/_build/html/tutorial/magnetization.html Creates a Ferromagnet and World object for simulation. The initial magnetization is random. ```python from mumaxplus import Ferromagnet, Grid, World ``` -------------------------------- ### bias_magnetic_field Source: https://github.com/mumax/plus/blob/master/docs/_build/html/_api/mumaxplus/mumaxplus.Antiferromagnet.html Set or get the bias magnetic field applied to the antiferromagnetic system. This field can influence the magnetic ordering and dynamics. ```APIDOC ## Property: bias_magnetic_field ### Description Allows setting or getting the bias magnetic field applied to the antiferromagnetic system. ### Type (Not specified in source) ``` -------------------------------- ### Initialize Ferromagnet and Set Material Properties Source: https://github.com/mumax/plus/blob/master/docs/_build/html/examples/DW_SAW.html Creates a Ferromagnet object within the defined world and sets key magnetic material parameters such as saturation magnetization (msat), exchange stiffness (aex), damping (alpha), and uniaxial anisotropy (ku1) with its orientation (anisU). ```python magnet = Ferromagnet(world, Grid((nx, ny, nz))) # setting magnet parameters magnet.msat = 6e5 magnet.aex = 1e-11 magnet.alpha = 0.01 magnet.ku1 = 8e5 magnet.anisU = (0,0,1) # setting DMI to stabilize the DW ```