Installation#
All packages in Ubermag are available on both conda forge and PyPI. All packages can
be installed independently using conda
or pip
. To simplify the
installation for users doing micromagnetic simulations we provide a meta-package
called ubermag
. During installation of this packages all individual
subpackages and additionally OOMMF are
installed.
If you want to run simulations using mumax3 you have to install it manually and make sure that it can be found on the command line (i.e. adding it to the PATH variable).
To install any of the packages please follow the guidelines below and replace
PACKAGE
with one of the actual package names:
ubermag
(includes all packages listed below + OOMMF)discretisedfield
micromagneticmodel
micromagneticdata
micromagnetictests
oommfc
ubermagtable
ubermagdata
ubermagutil
Standard installation – recommended#
Installation environment#
We recommend installation using conda
package manager. If you do not
already have it installed, download Anaconda Python 3.8+ for your operating
system and follow the instructions to install it. After the installation
is complete, in Terminal (Linux and MacOS) or in Anaconda Prompt
(Windows), create a new environment and activate it.
Here, we show how to create and activate a new conda environment called
ubermag_env
. To use a different name, replace ubermag_env
with
your desired name.
$ conda create -n ubermag_env python=3.10
$ conda activate ubermag_env
If you do not want to use or cannot use conda
you can also install
ubermag
via pip
. You have to manually install Python and pip for
your operating system.
First, we create a new virtual environment, here called ubermag_venv
.
To use a different name, replace ubermag_venv
with your desired name. A
new folder with the given environment name will be created in the current
directory.
$ python3 -m venv ubermag_venv
To activate the environment on Windows, run:
$ ubermag_venv\Scripts\activate.bat
On Linux or MacOS, run:
$ source ubermag_venv/bin/activate
Installation#
Now, you can install any PACKAGE
by running the following command. We
show the installation of the ubermag
meta-package. To install individual
packages, replace ubermag
with the name of the package that you want to
install.
$ conda install --channel conda-forge ubermag
$ pip install ubermag
If you want to use ubermag
in a Jupyter notebook we provide a short summary
of how to run Jupyter lab.
Installing a calculator#
Ubermag can use different existing micromagnetic calculators (currently OOMMF and mumax3).
When you install ubermag
using conda
OOMMF will be automatically
installed and ubermag
(more precisely oommfc
) knows how to find it. If
you install ubermag
using pip
you have to install OOMMF manually and
make sure that ubermag
can find it. This also allows you to use a custom
version of OOMMF. If you have no OOMMF installed but Docker is available
ubermag
will automatically attempt to download and use a Docker image
that contains OOMMF.
For detailed instructions how to use a non-default OOMMF installation please refer to Controlling the default runner.
Mumax3 does not directly come with ubermag
and you have to
install it manually (following the instructions on the mumax3
website). There are two different options how ubermag
(more precisely
mumax3c
) can use your custom mumax3 installation.
You can add the directory containing the mumax3 executable to your PATH variable.
ubermag
by default looks for an executable calledmumax3
on PATH.
or
You can change the name of the default executable in
mumax3c
when you import it as follows:import mumax3c mumax3c.runner.mumax3_exe = '/full/path/to/mumax/executable'
import mumax3c mumax3c.runner.mumax3_exe = r'C:\full\path\to\mumax\executable.exe'
A raw string is required to avoid that backslash + next character are interpreted as escape sequences in the Python string.
Testing#
You can test the installation by running:
$ python -c "import ubermag; ubermag.test()"
Again, replace ubermag
with the name of your package if you do not install
the meta-package. If no errors are reported, the installation was successful.
Update#
Every PACKAGE
can be updated by running (if necessary replace ubermag
with the name of your package):
$ conda update ubermag
$ pip install --upgrade ubermag
Advanced installation#
To use ubermag
for micromagnetic computations, you need to:
Install Ubermag.
Install a computational backend (such as OOMMF or mumax3).
Ensure Ubermag knows where to find the computational backend.
By installing Ubermag using conda
, all three steps would be carried out
automatically (for OOMMF). However, if for some reason you need more freedom in
choosing the computational backend, please follow the steps explained
subsequently for your operating system.
Before we install
ubermag
, we need to installPython3
Anaconda package manager. If you do not already have it installed, download Anaconda Python 3.8+ for your operating system and follow the instructions to install it.Now we have everything required to install
ubermag
. Run in Command Prompt:$ pip install ubermag
To install OOMMF as a computational backend, first, you need to install
tcl
on your machine. To do this, download the.exe
file from this link, appropriate for your operating system (32-bit or 64-bit). After the download is complete, run the downloaded file and follow the instructions to complete the installation.Download the
.zip
file for the latest OOMMF version which is appropriate for your Windows OS (32-bit or 64-bit) from this link. After the download is complete, unzip (extract) it. Locate among the the unzipped filesoommf.tcl
and remember its location - we are going to need it in step 3.Note: Some OOMMF extensions are only available in the conda package, not the official release from the NIST website.
In order to help Ubermag find where
oommf.tcl
is, we need to set the value of environment variableOOMMFTCL
. To do this, in Control Panel, selectSystem
->Advanced system settings
(tabAdvanced
) ->Environment variables
. In User variables selectNew...
and typeOOMMFTCL
for Variable name andC:\path\you\remembered\from\step2\oommf.tcl
to Variable value.
Before we install
ubermag
, we need to installPython3
Anaconda package manager. If you do not already have it installed, download Anaconda Python 3.8+ for your operating system and follow the instructions to install it.Now we have everything required to install
ubermag
. Therefore, run in terminal:$ pip install ubermag
To compile OOMMF on MacOS, make sure you have
XCode
(from AppStore) and Git installed.Clone the repository by typing
$ git clone https://github.com/fangohr/oommf.git
To compile OOMMF, change the directory (
cd oommf
) and run:$ make build
This command, apart from building OOMMF, will download and compile Dzyaloshinkii-Moriya extensions for different crystalographic classes. For more information, please refer to the OOMMF repository.
Finally, we have to set the environment variable
OOMMFTCL
, so that Ubermag knows where to find OOMMF. Consequently, in your home directory, add the path tooommf.tcl
file to the end of the.bash_profile
file. More specifically, the line at the end of your file should look like:export OOMMFTCL="/path/to/your/compiled/oommf.tcl"
Please note that after editing
.bash_profile
file, you need to refresh your environment variables (source ~/.bashrc
) or reopen the Terminal window.
To install Ubermag, we first have to make sure you have
pip
installed. Please note that this command requires root privileges (sudo).$ apt-get install python3-pip
(Alternatively, you can use Anaconda Python3 distribution. If you do not already have it installed, download Anaconda Python 3.8+ for your operating system and follow the instructions to install it.)
Now, we can install
ubermag
$ python3 -m pip install ubermag
You can compile OOMMF on your machine by firstly installing the required packages. Please note that this command requires root privileges (sudo).
$ apt-get install git tcl-dev tk-dev
Clone the repository:
$ git clone https://github.com/fangohr/oommf.git
(If you do not have
git
, you can install it usingapt-get install git
.)To compile OOMMF, change the directory (
cd oommf
) and run:$ make build
This command, apart from building OOMMF, will download and compile Dzyaloshinkii-Moriya extensions as well. For more information, please refer to the OOMMF reporsitory.
Finally, we have to set the environment variable
OOMMFTCL
, so that previously installed Ubermag knows where to find OOMMF. Consequently, in your home directory, add the path tooommf.tcl
file to the end of the.bashrc
file. More specifically, the line at the emd of your file should look like:export OOMMFTCL="/path/to/your/oommf.tcl"
Please note that after editing
.bash_profile
file, you need to refresh your environment variables (source ~/.bashrc
) or reopen the Terminal window.
Check the installation#
To check if Ubermag can communicate with your installed OOMMF, you can use these commands in a Python prompt on any operating system:
import oommfc
oommfc.runner.runner.status
or from the command line:
python3 -c "import oommfc; oommfc.runner.runner.status"
This will attempt to run a small simulation using OOMMF.
How does Ubermag find OOMMF?#
oommfc
checks for OOMMF in the following steps until the first method is
successful:
Is the
OOMMFTCL
variable set? If so, use this value to try to find OOMMF there.Is OOMMF in the directory it should be in if both
oommf
andubermag
were installed using conda.If
docker
is available and the docker deamon is running, then OOMMF is used in the Docker container. (The required docker image will be downloaded if necessary.)
Development installation#
The above-explained installation methods are not suitable for the development of
the ubermag
package collection. Detailed guidelines and additional helper
scripts to clone and install all packages in a way that is feasible for package
development are given in our devtools repository. The information given there is only
intended for people developing Ubermag or planning to contribute. For normal
users we recommend following the steps under Standard installation –
recommended.