The Muon Playground is a Javascript web app designed to simulate the Free Induction Decay (FID) signal observed in a number of different magnetic field distributions and in presence of relaxation and dynamical processes.
While muon FIDs are often approximated by mathematical models specific to certain field distributions and valid only in certain dynamical regimes (like the Kubo-Toyabe function), the Muon Playground adopts a different approach. Using a numerical modification of the algorithm described in S. Sturniolo, M. Pieruccini, "An exact analytical solution for the evolution of a dipole–dipole interacting system under spherical diffusion in magnetic resonance experiments" [JMR 223 (2012) 138-147], in this app all FIDs are calculated using a Green's function method based simply on a sampling of the static field distribution and an assumption of uncorrelated dynamics with a single relaxation time. This means that the same method can be used for any model in any dynamical regime, without need for specific formulas.
The Muon Playground is a simple static webpage; the necessary files to host and run it are all found in the build
folder. The page can also be seen live on Github pages. From there, it can be embedded within your website if you wanted to. The embedded page can be customised with the use of URL parameters. For example,
https://muon-spectroscopy-computational-project.github.io/muon-outreach/?nodescr&model_type=twosite
will produce a page without the description box and using the "two site" field distribution. Here's a full list of all possible URL parameters:
nodescr
[boolean]: if present, the description box will be removed and plot and controls will be arranged horizontallymodel_type
[string]: designates the model type to use; if present, the "Distribution type" dropdown will be disappeared and the given model will be fixed. Accepted values areuniaxial
,spherical
,planexp
andtwosite
, corresponding respectively to uniaxial and spherical Gaussian, planar exponential, and two site distribution.model_arg_<argument name>
: fixes the value of<argument name>
for the given model. These are the distribution specific arguments: their names and meanings change depending on the model.
Here is a list of arguments, classified by model, that can be used in model_arg_<argument name>
.
None
B_external
[float]: External field applied to the sampleis_transverse
[bool]: If checked, the external field is applied in a direction transverse to the magnetization
lattice_L
[float]: Side of the triangular vortex latticeB_max
[float]: Intensity of the magnetic field at the core of a vortexB_shift
[float]: Intensity of applied magnetic field that shifts the entire distribution by a fixed value
B_central
[float]: Average magnetic field for the two sites
Contributions are welcome. There are no specific style guidelines at the moment, just try to be consistent with what you see. When editing the code, use make
to rebuild JS and CSS files, while make test_server
runs Node's native HTTP server for testing.
If you're interested simply in adding a new model, there are three steps:
- create a new
Distribution
function injs/distributions.js
. The function must return a dictionary containing sampled frequencies and their weights in the form{'freqs': [], 'weights': []}
. Remember to include this in theexports
of the module. - create a new
Model
object injs/models.js
. This must inherit from theModel
prototype and, again, be passed toexports
. Follow the example of the existing models. When creating aModel
, arguments are passed to it defining the way it will be computed. These are theDistribution
used, the starting "spread" parameter for it (for example, the Gaussian's standard deviation), the number of sampled points, the time step and number of time points (by default 0.01 and 150), then a list of additional arguments created asArgDef
objects and finally the minimum and maximum values, in order, for the spread parameter, the jumping frequency, and the relaxation time T1. It's also important to add afullname
member in order to pretty print the model's name in the main page. - finally, in
index.js
, add a reference to the newly created model in$scope.model_funcs
.
Optionally, you can also create a description in build/index.html
, controlled by a ng-switch-when
statement.
The Muon Playground makes use of Node, Angular.js, Chartist, query-string, and Bulma for formatting. Browserify, UglifyJS, SASS and UglifyCSS are also required for building the page during development.
The Muon Playground is released under the MIT License. See the LICENSE
file for more details.