This repository contains the (developing) open-source code for simulating bulk spin transport—diffusion and separation—in solid media. Multi-spin-species and magnetic resonance simulations are in development.
This is a Python and FEniCS project. FEniCS is used to numerically solve the spin transport governing partial differential equations.
End users of this project write Python code to interface with FEniCS.
One must first have a working installation of FEniCS. This README assumes the use of Docker for installation, which is documented here.
Install fenicsproject
command with the following command.
curl -s https://get.fenicsproject.org | bash
Then clone this repository to the host machine.
The FEniCS docs have a section on workflow.
There are many ways to instantiate these good practices, but we recommend using the following command, which opens a Docker container, executes the <python script>
, and saves the results to a local file (outside the Docker container).
fenicsproject run stable python3 <python script> <options>
To verify that everything is installed correctly, run the Poisson equation demo ft01_poisson.py
(source) in your container.
If you installed the fenicsproject
script per the instructions above, you can use the following command (working directory: spin-transport
).
$ fenicsproject run stable python3 ft01_poisson.py
If everything is working fine, the output should look something like the following.
$ fenicsproject run stable python3 ft01_poisson.py
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving linear variational problem.
*** Warning: Degree of exact solution may be inadequate for accurate result in errornorm.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Ignoring precision in integral metadata compiled using quadrature representation. Not implemented.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
error_L2 = 0.00823509807335
error_max = 1.33226762955e-15
The directory spin-transport/poisson
should have been created and should contain two files: solution.pvd
and solution000000.vtu
.
These files contain the solution data.
The spin_transport_01.py
script can be executed with the following command.
fenicsproject run stable python3 spin_transport_01.py -p -b
The default steady state IC is derived from a system with no Bloch relaxation or pulse dynamics, which are disabled with the -p
and -b
command line options. The number of cells in the mesh can be changed using the -n
option followed by the number of cells to use. The full list of possible commands can be viewed by using the -h
option.
Use the plot.py
script, as follows.
python3 plot.py
Here the -p
option can be used enable plotting with subplots. The -i
option is used to set the duration to wait between showing the next timestep in ms. The --start
and --end
options are used to specify the index of the first and last timesteps to show. The rest of the options can be viewed using the -h
option.
This work is supported by a grant from the Army Research Office, Materials Science Division under grant proposal Nanoscale Spin Hyperpolarization and Imaging with PI John Marohn, PhD.
This project stems from a collaboration among three institutions:
The lead contributor to this project is Rico Picone, PhD of Saint Martin's University, co-PI on the ARO grant. Other contributors include John Marohn, PhD (Cornell, PI), John A. Sidles, PhD (Washington), Joseph L. Garbini, PhD (Washington), and Cameron Devine (Washington).