# A programmatic way of producing nematic liquid crystal alignment diagrams in R

An R package for nematic LC diagrams

During my PhD, I remember often having to complete the arduous task of drawing schematic diagrams that represent the alignmnet of nematic liquid crystals under different surface alignment conditions. Back in those days (a long time ago now!) I used to hand draw those diagrams by copying and pasting ellipses (or rectangles) and distributing them on the Inkscape page until I got to a schematic diagram that worked for my purpose.

Although I have not worked in the field of liquid crystals for many years now, I thought it would be an interesting project to come up with a solution for automating the production of these schematic alignment diagrams in R. The full package `lcdiagrammer` can be seen on my github repository.

This post aims to give a bit of an overview of what it can do.

## Package use

``library(lcdiagrammer)``

The function `lcd` produces a schematic diagram. The minimal use is to provide the tilt angle of rotation at the bottom of the image `theta1` and the tilt angle of rotation at the top of the image `theta2`. Molecule tilt angles will then vary linearly between the two surfaces.

Using the seed argument keeps the same molecule positions between plots.

``````par(mfrow=c(1,2))

# The same angle top and bottom
lcd(theta1 = 0, theta2 = 0, seed=1)

# Some 'splay'
lcd(theta1 = 40, theta2 = -40, seed=1)`````` It’s also possible to include the bounding surfaces in the schematic. Arguments `strate1` and `strate2` define the boundary’s thickness

``````par(mfrow=c(1,2))
lcd(0, 0, strate1 = 0.05, strate2=0.05, seed=1)
lcd(40, -40, strate1 = 0.05, strate2=0.05, seed=1)`````` It is also possible to add noise to the tilt angle in the schematic.

``````par(mfrow=c(2,2))
lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, theta_n = 0)
lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, theta_n = 10)
lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, theta_n = 20)
lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, theta_n = 40)`````` Adding noise of 180 degrees will produce an isotropic schematic

``lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, theta_n = 180)`` The default molecule shape is an ellipse, but a rectangle can also be specified

``````par(mfrow=c(1,2))
lcd(90, -90, strate1 = 0.05, strate2=0.05, seed=1)
lcd(90, -90, strate1 = 0.05, strate2=0.05, seed=1, mol = "rect")`````` The aspect ratio of the schematic can also be altered with the `top` and `right` arguments

``````par(mfrow=c(1,2))
lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, top=2)
lcd(20, 20, strate1 = 0.05, strate2=0.05, seed=1, right=2)`````` The azimuthal (or twist) angle can also be specified with `phi1` on the bottom surface and `phi2` on the top surface. These angles are only meaningful in this code when `theta1` and `theta2` are set to 0.

``````par(mfrow=c(1,2))
lcd(0, 0, phi1 = 0, phi2 = 90, seed=1)
lcd(0, 0, phi1 = 0, phi2 = 90, seed=1, mol = "rect")`````` It is also possible to change the colours! There are many other aesthetic properties that can also be changed. The full list of arguments can also be seen here

``````par(mfrow=c(1,2))
lcd(0, 360, strate1 = 0.05, strate2=0.05, bg_col = "grey", lc_col = "white", seed=2)
lcd(0, 360, strate1 = 0.05, strate2=0.05,
bg_col = "green", lc_col = "purple",
strate1_col = "red", strate2_col = "red", seed=2)``````  ##### Chris Holmes
###### Senior Data Scientist

PhD physicist making his way in the world of data science!