# Plotting topological defects with VectorPlot

I have been trying to create a table with the graphs of the lowest winding number topological defects that can appear in a nematic Liquid Crystal.

That is what I have been able to do so far:

ρ[x_, y_] := Sqrt[x^2 + y^2];
Θ[x_, y_] := ArcTan[x, y];

OptStrSt = {{Red, AbsoluteThickness[3]}};

points = Join[{#, -1.} & /@ Range[-1, 1, .2], {#, 1.} & /@
Range[-1, 1, .2]];

Table[VectorPlot[{Cos[Θ[x, y] q],
Sin[Θ[x, y] q]}, {x, -1, 1}, {y, -1, 1},
VectorPoints -> 10, StreamStyle -> OptStrSt,
StreamPoints -> {points, Automatic, 2}, StreamScale -> None,
Frame -> False, VectorStyle -> OptVecSt, VectorScale -> 0.06,
ImageSize -> Medium], {q, 1/2, 2, 1/2}]


And this is the output:

Now, I would like to have more uniform distribution of streamlines. I am happy with their thickness and the fact that they are continuous across the $x$-axes, but I would need the streamlines to extend to those regions that are white at the moment.

Any ideas?

Also, it would be nice to be able to use manipulate to vary the following settings:

• number of vectors,
• density of streamlines,
• thickness of vectors and streamlines,

but, especially for the second one, I have no idea how to proceed. Thanks in advance!

• You could change the branch cut to be on the positive $x$-axis by using VectorPlot[{Cos[(Θ[-x, -y] + π) q], Sin[(Θ[-x, -y] + π) q]}, ...] and then switch to StreamPoints -> Coarse. i.sstatic.net/ZdHY1.png
– user484
Commented Jun 30, 2016 at 15:44
• This is definitely helpful, thanks! Commented Jun 30, 2016 at 15:48
• It doesn't give the desired result for q=1/2 though. Any ideas? Commented Jun 30, 2016 at 16:11
• Isn't q=1/2 the leftmost image? It looks fine to me, how is it different from the desired result? i.sstatic.net/ZdHY1.png
– user484
Commented Jun 30, 2016 at 16:38
• P.S. In retrospect instead of changing VectorPlot it would be better to just change Θ[x_, y_] := ArcTan[-x, -y] + π.
– user484
Commented Jun 30, 2016 at 16:40

Your answer is a nice solution. It's better than StreamPlot, because StreamPlot assumes polar order and thus cannot show half-integer defects. I extended your solution by adding a hand icon that revolves around the defect showing the winding number.

First, load an icon from this reference:

fingerpointing =
Import["https://symbols.getvecta.com/stencil_169/30_index-pointing-\


Functions for making the hand show up in the right place and constant size while winding around the defect:

squareBoxRotatingScaleFactor[
winding_] := (1 + (Sqrt[2] - 1) Abs[Sin[2 winding]])
(*numbers from the size of the fingerpointing image*)
scaleFactor[amp_, winding_] :=
2 amp squareBoxRotatingScaleFactor[winding]
offset[amp_,
winding_] := {amp, amp} squareBoxRotatingScaleFactor[winding]


Now, use the VectorPlot to make a defect of charge q

Θ[x_, y_] := ArcTan[x, y];

OptStrSt = {{Red, Dotted, AbsoluteThickness[3]}};

points = Join[{#, -1.} & /@ Range[-1, 1, .2], {#, 1.} & /@
Range[-1, 1, .2]];

nematicPos[winding_] := .8 {Cos[winding], Sin[winding]}
nematicAng[q_, winding_, spinOffset_] :=
q (winding + spinOffset) + Pi/2
nematicParts[q_, winding_, spinOffset_, amp_] :=
Show[{VectorPlot[{Cos[(Θ[x, y] + spinOffset) q],
Sin[(Θ[x, y] + spinOffset) q]}, {x, -1, 1}, {y, -1,
1}, VectorPoints -> 10, StreamStyle -> OptStrSt,
StreamPoints -> {points, Automatic, 2}, StreamScale -> None,
Frame -> False, VectorStyle -> OptVecSt, VectorScale -> 0.06,
ImageSize -> Medium,
PlotLabel -> ToString[q, InputForm] <> " charge"],
Graphics[{Inset[
ImageRotate[fingerpointing, nematicAng[q, 0, spinOffset]],
nematicPos[0] - offset[amp, 0], {0, 0}, scaleFactor[amp, 0]],
Inset[
ImageRotate[fingerpointing, nematicAng[q, winding, spinOffset]],
nematicPos[winding] -
offset[amp, winding - spinOffset Pi/2], {0, 0},
scaleFactor[amp, winding - spinOffset Pi/2]]},
PlotRange -> {{-1, 1}, {-1, 1}}]}]


Slow the winding at the end, so it is clear when the hands align or anti-align at the end of the full turn

SlowRamp[param_] := 2 Pi Sin[Pi/2 param]
nematicIllustration[q_, winding_, spinOffset_] :=
nematicParts[q, SlowRamp[winding], SlowRamp[spinOffset], 0.3]

pairManipulator[q_] :=
Manipulate[
With[{amp = 0.3},
GraphicsGrid[{{nematicIllustration[q, windingPlus,
spinOffsetPlus]}, {nematicIllustration[-q, windingMinus,
spinOffsetMinus]}}]], {windingPlus, 0, 1}, {spinOffsetPlus, 0,
1}, {windingMinus, 0, 1}, {spinOffsetMinus, 0, 1}]

halfDefect = pairManipulator[1/2]
oneDefect = pairManipulator[1]
twoDefect = pairManipulator[2]


Now save it as animated GIFs:

ManToGif[man_, name_String, step_Integer] :=
Export[name <> ".gif",
Import[Export[name <> ".mov", man], "ImageList"][[1 ;; -1 ;; step]]]

SetDirectory[NotebookDirectory[]];
ManToGif[halfDefect, "./half-integer-defects", 2]
ManToGif[oneDefect, "./one-integer-defects", 2]
ManToGif[twoDefect, "./two-integer-defects", 2]


You can find original GIFs uploaded here: +1/2, -1/2 and +1,-1 and +2,-2.

• Welcome to Mathematica StackExchange! This is a really nice answer! I have just slightly fixed the formatting of your code, and included smaller GIFs, retaining the link to the original ones. Commented Apr 30, 2023 at 13:34