A while ago, we had a challenge related to antiferromagnetism (AF) in two dimensions. Now, on a 2-d square lattice, antiferromagnetic is antiferromagnetic, and that is all there is to it. Moving to other lattice types or higher dimensionality, things get more interesting. Here, we will explore the second route: magnetic order on the 3-d cubic lattice1.
We will consider the following spin patterns, as illustrated in the figure. The cubes are repeated periodically in every direction (“periodic boundary conditions”).
- G-type is the most straightforward generalization from 2-D AF: antiferromagnetic in all directions
- A-type: antiferromagnetically coupled ferromagnetic planes
- C-type: ferromagnetically coupled antiferromagnetic planes (a.k.a “checkerboard”)
- D-type: criss-crossing stripes
- E-type and F-type: “ferrimagnetic planes”?
- B-type is ferromagnetic (FM) order
adapted from E. Dagotto, Nanoscale phase separation and colossal magnetoresistance
The challenge
Your code should take a string as input specifying a magnetic order and a lattice plane, and output the spin arrangement on that plane, in the orientation specified below. Output should be “drawn“ in some sense: writing to STDOUT, graphical output, or similar; a function returning a string is not enough.
You must support at least A-, C-, and G-type (the more familiar AF arrangements); B-, E-, and F-type may be supported optionally. Your score will be code length per order type supported.
Input
Input will be of the form S (a b c)
, i.e., a token S specifying the order type, a space, and three integers a,b,c defining a lattice plane, enclosed in parentheses and delimited by spaces.
The string S will be either “AF-T” with T ∈ {A, C, D, E, F, G} for the antiferromagnetic cases, or “FM” in the ferromagnetic case (B).
We define the following coordinate system relative to the figure: the x-axis points to the right, the y-axis into the screen, and the z-axis upwards; the origin is the lower left front corner of the cube, and the lattice parameter (the side length of the cube) will be 1.
For simplicity, exactly one of the integers a,b,c will be nonzero. The plane of projection is perpendicular to the corresponding axis and displaced from the origin by that number of unit cells.2 To get the proper orientation, look along the axis of displacement in positive/negative direction according to the displacement, and rotate such that the first in-plane axis (alphabetically: y for the yz-plane, x otherwise) increases to the right. Examples are given below.
Output
On the selected plane, the spins are arranged on a square lattice. Your code should draw 2×2 spins (the “magnetic unit cell”) on this plane, taking into account the periodicity and the proper orientation.
A ↑ by any other name …
Spin “up” and “down” are just names,3 and I do not want to limit your artistic freedom. Choose any (visually distinguishable) symbols for the spin directions you like, they only have to be consistent and laid out on a “square” lattice (as rectangular as necessary according to output format). You can use ASCII/Unicode art, graphical output, what have you. Leading or trailing white space does not matter.
Examples of input, valid output, and orientation
A (0 0 1) C (1 0 0) D (0 0 2) E (0 1 0) F (0 -2 0) G (0 0 7)
- - ↓ ↑ ud 0 1 -> -> 🔫 •
- - ↓ ↑ ud 1 0 -> <- • 🔫
--> x --> y --> x ^ z --> x --> x
| | | | | |
V y V z V y --> x V z V y
Scoring
Your score is B/O, the length B of your code in bytes divided by the number of patterns O your code supports (O is between 3 and 7). Smallest score wins.
In your answer, please indicate (i) code length, (ii) supported orders, and (iii) sample output, and (iv) the correspondence of your symbols with +
and -
in the figure, if yours are different.
1. Which is the analogue of the square lattice in three dimensions. The general term would be “hypercubic”.
2. They are a perverted variation of Miller indices.
3. We are being strictly non-relativistic here.