Monthly archives: November, 2014

Cool code: plotting columns from many data files with Grace

Grace a.k.a. xmgrace is a really useful tool for plotting histograms from tabular data files. Its power comes from the command line control and being scriptable. Yes, there are other options which are sometimes more suitable for specific situations (e.g. GNUplot, Matplotlib/PyLab), but for quick, basic plotting I usually find myself relying on xmgrace.

Here is an example of a single line command to plot two columns from each of a large number of data files:

for i in ./a*/field.log; do echo -n " -block $i -bxy 10:44" ; done | xargs xmgrace

The command searches all current subdirectories with names beginning “a” for files called field.log. For each field.log file found it uses an echo command to generate a commandline argument string that we normally use to make a 2D plot with the 10th (x axis) and 44th (y axis) columns using xmgrace. The -n option for echo makes sure there is no newline after each echo, generating one long collection of commands. We next want to pass this on to xmgrace…

xmgrace does not take input from stdin so we first pipe the total echo output to xargs, which is a tool used to construct command line parameters from stdin. xargs then passes these command line arguments to xmgrace.

This little code snippet saves a lot of typing, which grows of the order N for N data files. Now I need to work out how to name each data set on the fly too.

 




“Battenberg” structured magnets, new paper published in APL

Our new, cake-themed paper on nanostructured permanent magnets has now been published in Applied Physics Letters.

In the paper we present results from micromagnetic simulations that assess the performance of multi-phase nanostructured permanent magnets, whose cross-section resemble that of a Battenberg cake. By including a super-hard outer shell we are able to counteract the effects of thermal fluctuations and surface defects, both of which are detrimental to the performance of such permanent magnets.  Such magnets are important for the motors in electric vehicles and for the generators in wind turbines, and these machines usually operate at elevated temperatures.

Click here to download the author-formatted reprint (free) or here for the official, journal-formatted version ($).

A home made Battenberg Cake, end view, with a slice leaning on it [Creative Commons Attribution 3.0 Unported – Author:Henrycooksey, Wikimedia Commons]

In case you are wondering, the soft cores in our magnet are like the sponge, the interdiffusion layer is like the jam-sponge mix you get at the surfaces of the sponge, the hard matrix is the jam and the super hard shell is like the marzipan. The difference is that our model has 3D periodicity while a typical Battenberg cake has only 2D periodicity, like a checkerboard prism. Battenberg cakes can be made in a number of different configurations, and so can Battenberg magnets! Stay tuned for more cake-inspired magnetic nanostructures in the future!

Proposed microstructure of a nano-composite per- manent magnet. Each grain is composed of soft magnetic inclusions embedded in a hard magnetic phase. Both phases are coupled through a thin inter-diffusion layer with proper- ties that may be different from either of the two phases. A grain may have a super-hard shell with an anisotropy field exceeding that of the hard magnetic matrix phase. At the surface a ferromagnetic layer with small or zero anisotropy is assumed (defect layer).

Fig. 1 Proposed microstructure of a nano-composite per-
manent magnet. Each grain is composed of soft magnetic
inclusions embedded in a hard magnetic phase. Both phases
are coupled through a thin inter-diffusion layer with proper-
ties that may be different from either of the two phases. A
grain may have a super-hard shell with an anisotropy field
exceeding that of the hard magnetic matrix phase. At the
surface a ferromagnetic layer with small or zero anisotropy is
assumed (defect layer).

Left: Data and fit of the energy barrier of a single grain as function of the applied field without the super-hard shell (hollow diamonds and dashed line) and with (filled circles and solid line). Right: B(H) loops for a single grain at 450 K. The circles indicate the working point where the energy product reaches its maximum. Dashed lines: Fe 65 Co 35 /Nd 2 Fe 14 B, solid lines: Fe 65 Co 35 /Nd 2 Fe 14 B/Sm 2 Fe 17 N 3 .

Fig. 2 Left: Data and fit of the energy barrier of
a single grain as function of the applied field without
the super-hard shell (hollow diamonds and dashed line)
and with (filled circles and solid line). Right: B(H)
loops for a single grain at 450 K. The circles indicate
the working point where the energy product reaches its
maximum. Dashed lines: Fe 65 Co 35 /Nd 2 Fe 14 B, solid lines:
Fe 65 Co 35 /Nd 2 Fe 14 B/Sm 2 Fe 17 N 3 .