New architecture for experiments
In my opinion, the ExperimentalSetup
leads to more problems than it solves. Its primary purpose was to organize the experiments, somehow storing their results. However, in its current form, it leads to unnecessary overhead and unexpected responsibilities. We have two classes (sample and exp setup) holding similar state information, and both provide means to visualize (part) of it. Moreover, the experimental setup does not solve the issue of validating experimental results with each other. For example, currently, it is possible to set a magnetization, then calculate eigenmodes, then put a different magnetization, and then calculate the linewidths of the same eigenmodes but with the wrong equilibrium.
The physical state of the magnetic system at a given time should be in one object. Therefore, stuff like an external field or microwave antennae should be part of the sample. Therefore, when inspecting the sample, one has all the information.
Currently, we have two different kinds of experiments (actually 2.5). Experiments that change the state of the sample (like relax()
and later also evolve()
with LLG), and experiments that do some post-processing. In principle, the eigenmodes()
is also just post-processing on a calculated equilibrium state. However, due to its heavy weight, it should be considered on the same level as relax()
and evolve()
. However, absorption, linewidths, etc., are just post-processing on a given eigenspectrum.
Thus, I propose the following changes:
- Proper experiments like
relax()
andeigenmodes()
should be simply functions that take aSample
as an argument. Each experiment returns aResult
object that stores the outcome (or the path to it) and some metadata. It can be read from or written to a file. - Visualization and post-processing, like calculating the linewidths of modes, are then called as methods on the result.
from tetrax.experiments import eigenmodes
spectrum = eigenmodes(sample)
spectrum.plot()
spectrum.show_mode(...)
...
linewidths = spectrum.get_linewidths(alpha=.008)
There is a caveat: We plan to add rate equations for weakly nonlinear dynamics in the future. This could also be understood as post-processing but is complex enough to be a proper experiment. We could consider making it an experiment that takes an eigenspectrum as an argument.