Introduction

Point topological defects are singularities of the orientational field. They are topologically stable entities that form when a certain continuum symmetry is broken, for example at a phase transition1. The examples include Abrikosov vortices in type-II superconductors2, quantized vortices in superfluid Helium3, point disclinations in nematic liquid crystals4, skyrmions in ferromagnets5, and even cosmic strings6. Near the symmetry-breaking phase transition, the system can be universally described by the Ginzburg-Landau equation for the corresponding order parameter7.

Various strategies of superconducting vortex pinning were proposed, like the creation of artificial periodic defect arrays in superconducting films, e.g., holes8,9 or magnetic nanodots10. It is tempting to apply a similar strategy to control the spatiotemporal response of active matter11,12,13,14. As it was pointed out by de Gennes15, there is a deep analogy between Abrikosov vortices and half-integer defects in liquid crystals in 2D.

However, the defect motion in active systems is more subtle than at equilibrium. Dynamics of topological defects at equilibrium is relatively simple: their mutual motion and annihilation minimize the free energy. In non-equilibrium systems, such as active nematics, exemplified by cytoskeletal extracts16,17,18,19,20, cells tissues21,22, or living liquid crystals (LLC)23, the entire concept of thermodynamics is in question. Half-integer topological defects exhibit rich spatiotemporal behavior, like persistent creation and annihilation of disclination pairs, the onset of long-range dynamic order24,25,26, etc. Furthermore, activity makes the dynamics of individual defects non-symmetric: + 1/2 defects drift spontaneously while isolated −1/2 defect remain at rest24,25,27. Thus, defect pinning in active systems is more subtle, and little is known about how active defects can be immobilized28,29.

Among the realm of active nematic-like systems16,17,22,30,31, a suspension of swimming bacteria mixed with a liquid crystal, a living liquid crystal11,23 displays the guidance of bacteria along the nematic director23,32,33,34, transport of cargo along bacterial trajectories35, and dynamic self-assembly of bacterial clusters36. Bacteria swim away from the cores of −1/2 defects and accumulate in the cores of +1/2 topological defects25 (Fig. 1a). The system is simple in preparation and amenable to effective computational modeling25,37,38,39.

Fig. 1: Schematics of experiment and defect snapshots.
figure 1

a Nematic field in the vicinity of +1/2 and −1/2 topological defects. b A schematic view of 3D model of a square lattice of pillars on a glass slide. c A side view of the microscopic pillar inside the experimental microfluidic chamber. d Bright field microscope image of a living liquid crystal in the presence of pillars lattice. Scale bar is 100 μm. e Snapshot illustrating position of bacteria around the pillar. Scale bar is 10 μm. f Reconstructed nematic field lines and topological defects in the vicinity of the pillar, the observation area 100 μm × 100 μm. Scale bar is 20 μm.

To investigate pinning of active topological defects, we conduct experiments with a realization of living liquid crystal: motile bacteria Bacillus subtilis suspended in lyotropic liquid crystal disodium cromoglycate (DSCG). The measurements are performed in a Hele-Shaw-type cell geometry with 3D printed microobstacle arrays. We show that − 1/2 disclinations can be successfully pinned by the obstacles whereas + 1/2 defects remain mobile. Furthermore, we have found that pinning of negative defects results in the overall reduction of mobility of the positive ones. The experimental findings are supported by computational analysis based on models of living liquid crystal developed in25,37. Overall, we obtained good agreement between our theory and the experiment. Our results stimulate new strategies for control and manipulation of active matter via targeting topological defects, in systems where topological charge can be manipulated by designing arbitrary arrays of specifically shaped microscopic irregularities.

Results and discussion

Experimental observations

The micro-chamber for measurements contains a square lattice of 20 μm-tall microscopic pillars resembling negatively curved triangles raising from the glass substrate, alongside a pillar-free control area [see Fig. 1b–e, Supplementary Video 1, and Methods for experimental details]. LLC was sandwiched between the bottom glass slide and a thin film of PDMS supported by the 3D-printed pillars. In this configuration oxygen permeates through the PDMS film, promoting the motility of aerobic bacteria and enabling activity of LLC. The dynamic of LLC is captured by a Prosilica digital camera (1600 × 1200 pixels, 10 frames per second) using bright-field microscopy. A custom MATLAB script reconstructs the nematic field lines of LLC from local bacterial orientations on the snapshots. These field lines allow identification of topological defects, which can then be tracked [Fig. 1f and Supplementary Video 2]. Note that although this method depends on non-zero local concentration of bacteria to identify field lines and defects, at these high concentrations the entire space is occupied by bacteria at almost all times.

Negative nematic defects residing on the pillars is the most distinct feature of active nematics with obstacles, Fig. 1f. The fraction of pillars occupied by −1/2 defects is as high as 0.94, starting from a few seconds after flow in the measurement chamber has settled to zero. Supplementary Video 3 shows a pillar that is initially not occupied by a defect, then, a − 1/2 defect in its vicinity drifts and settles on the pillar. The average filling fraction was obtained by average over all the pillars and the entire duration of the experiment – 6.2 minutes. However, the instant filling fraction can be smaller in some moments of time.

The observed negative charging of pillars is attributed to several factors. The first factor may be considered in the context of equilibrium physics: if the curvature of the obstacle surface is relatively small, the liquid crystal (DSCG) tends to align parallel to the surface40,41,42. This minimizes the free energy by reduction of anchoring energy at a smaller cost of bending deformation. Therefore, orienting action of the pillar facilitates the formation and pinning of a negative defect. However, this effect is not dominant in the phenomenon that we here show. For an equivalent passive system (liquid crystal without bacteria) negative charging of pillars takes place only after several (~20) minutes of relaxation of the nematic director, while at previous times the nematic orientation is dominated by the initial flow established when the micro-chamber is closed [see Supplementary Note 1, Figs. S1, S2, and Video 4]. Additional experiments on a non-active nematic containing 2 μm-long gold rods, Figs. S1 and S2, show non-organized orientation of rods around pillars, also demonstrating that the pillars themselves do not template − 1/2 defects in the corresponding timescale.

An important question here is how the shape of the pillars affects the pinning of negative defects. One may think that only the triangular shape enables the trapping of negative defects by forcing LC to align along the surface. However, even for circular obstacles, the planar alignment of LC along the circular pillar is not necessarily stable. Changing shape from triangular to circular does not guarantee that the nematic alignment remains planar along the surface. We reconstructed the nematic field around triangular star-like, round, and square pillars in a passive liquid crystal to obtain experimental confirmation of this statement (see Fig. S3). One observes no significant difference in the defects distribution around different shapes’ pillars. In fact, due to competition between bending and splay deformations, circular alignment often becomes distorted, leading to a configuration with defects (usually a pair of defects)43. This effect is pronounced when the surface anchoring is not too strong (as in our experiment). Moreover, bacteria do not necessarily move on circular orbits in the vicinity of the pillar. A study in ref. 14 demonstrates that if the concentration of bacteria is above a critical value, the bacteria self-organize their flow, corresponding to a negative (saddle-like) defect.

For the active system (liquid crystal with swimming bacteria), a coupling between bacteria trajectories and a local nematic field orientation23 contributes to the second factor. Collisions of swimming bacteria with obstacles leads to strong hydrodynamic trapping along the edges44,45: bacteria swim parallel to the sides of the pillars and align the nematic field in a shape resembling a negative defect. The role of this factor could be controlled by bacterial activity. An additional contribution comes from the activity of the nematic liquid crystal but does not require triangular shape. Significantly less mobile negative defects are attracted to stationary interfaces25 introduced by pillars. The defect pinning is also affected by the pillar size. Our previous study, ref. 37, shows that the topological charge of isotropic inclusion increases linearly with its size. A similar effect should occur for the pillars. However, the pinning strength should vanish when the pillar size becomes smaller than the defect’s core size, that, in turn, of the order of the bacterial length of 5 μm.

While the majority of negative defects are pinned to pillars, [Fig. 2a, c], positive defects tend to remain at a small distance from the pillars, [Fig. 2b, c and Figs. S4, S5]. A spatial distribution of positive defects clearly indicates three well-defined peaks outside the pillar sides. At large distances from the pillars, the distribution is almost homogeneous. There is a weak depletion of the negative defect density at a distance of about 20 μm from a pillar. This effect could be due to the low mobility of negative defects and their strong attraction to the pillar. This configuration is somewhat similar to the distribution of positive charges forming a layer around a negatively charged colloidal particle46.

Fig. 2: Defect and topological charge distributions.
figure 2

Heat map of the average concentration of negative (a) and positive (b) defects. Color bars represent the defect concentrations. The center of the pillar is located at (X = 0, Y = 0). c Probability distribution function (PDF) of defect concentrations vs distance from the pillars r. The half-distance between pillars is 73 μm. d Topological charge density inside the pillar lattice (X < 500 μm) and in unconstrained area (X > 500 μm). Average values are Cin = (1.9 ± 0.7) × 10−4 μm−2 and Cout = (1.5 ± 0.5) × 10−4 μm−2 respectively. Color bars represent the charge densities. e Average topological charge density around a pillar.

Pinned negative defects do not annihilate with positive defects in their vicinity. Spontaneous nematic charging of pillars increases fluctuations of topological charge, depicted in Fig. 2d and e. The concentration of ± 1/2 defects in the area with pillars increased roughly by 30% for our experimental conditions in comparison with the basal concentration in the pillar-free region.

To understand how pillars modify the activity of topological defects, we compute the mean squared displacement (MSD) and the average speed of defects, Fig. 3. The MSD is computed as \({\langle {\left\vert {{{{{{{\bf{s}}}}}}}}(t+\Delta t)-{{{{{{{\bf{s}}}}}}}}(t)\right\vert }^{2}\rangle }_{t}\), where s(t) is the (x, y) position of the defect at time t, and 〈…〉t denotes the average along each trajectory. For a valid statistical representation Δt is limited to 1/10 of the total duration of the track. The analysis of the experimental data [Fig. 3a] shows that defects in the vicinity of pillars (small value of r) have a reduced MSD compared with free defects (larger value of r), see Fig. S5.

Fig. 3: Activity of topological defects.
figure 3

a The mean squared displacement (MSD) of defects (obtained by moving average along the trajectory) as a function of time interval (Δt) and the average distance to the nearest pillar (r). Inset: The MSD vs r in semilogarithmic scale for two time intervals Δt. Each point represents the MSD of a defect. b The MSD of defects as a function of time near pillars (25 μm < r < 35 μm, solid line) and far from pillars (r > 140 μm, dashed line). Shaded regions represent the uncertainty resulting from averaging different MSD of defects, red for positive and blue for negative defects, correspondingly. The uncertainty is computed as the standard error of the mean (SEM). The corresponding values of diffusion coefficients are: D+ = 12.2 ± 0.2 μm2 s−1, D = 5.8 ± 0.2 μm2 s−1 at distance from a pillar and D+ = 6.3 ± 0.2 μm2 s−1, D = 4.8 ± 0.2 μm2 s−1 in the pillar vicinity. c Average defect speeds measured over the entire duration of the track as a function of their average distance to the nearest pillar. Error bars show standard deviation (thin lines) and the standard error of the mean (thick lines).

Positive and negative defects are created and annihilated in pairs. For our experimental conditions, the distribution of defect lifetimes in the area located far from pillars can be fitted as an exponential decay ~et/τ, where τ = (4.8 ± 0.1) s. The distribution of τ is shown in Fig. S6. The typical value of τ observed in the experiments is not long enough to accurately extract diffusion coefficients from defect trajectories. At the same time, the collected experimental data allows us to quantify the differences between the MSD of the near-pillar defects (25 μm < r < 35 μm) and unbound defects (r > 140 μm). The linear slope comparison of a temporal evolution of the MSD presented in Fig. 3b shows that motility of both positive and negative defects located in the vicinity of pillars is reduced. The difference in motility is especially noticeable for positive defects. The defect mobility is characterized by their linear speed: the average speed increases with the distance from the pillar, Fig. 3c.

Computational results

To support our findings and extend the analysis beyond experimental limitations we conducted computational studies. We analyzed the system in the framework of a continuous model for living liquid crystals developed previously25,34,37. See Methods and Supplementary Note 2 for details. In this two-dimensional model, the dynamics of a liquid crystal is described by the Beris–Edwards equations for the nematic tensor Q, and the hydrodynamic velocity \(\overrightarrow{v}\). These equations are coupled with equations for the bacterial orientation tensor P, and concentrations of bacteria c+, c moving in opposite directions along the nematic field. Pillars are modeled as isotropic tactoids (normal inclusions), where the nematic order parameter Q is strongly suppressed by modulation of the Landau-de Gennes (LdG) coefficient (see ref. 37). The spatially-modulated LdG coefficient introduces the shapes and positions of the pillars, and the conditions at the interface are simulated by adding a term that anchors the nematic tensor parallel to the surface of the pillars. We solved Eqs. (1)–(7) in a square 512 × 512 μm2 domain with four identical pillars arranged in 2 × 2 squared grid [see Fig. 4a]. Defect positions were determined using a custom defect detection algorithm37 and recorded every 0.1s of equivalent simulations time units and later used to track defects.

Fig. 4: Simulations of the computational model.
figure 4

a Nematic field around four star-like pillars. Director orientation is shown with thick lines and amplitude of the order parameter with color. The color bar represents the magnitude of the order parameter. Negative (b) and positive (c) defect concentrations around a pillar. The pillar contour is depicted by white dots. The color bars represents the defect concentrations. d The probability density function of positive and negative defects vs the distance from the pillar center. e MSD vs time for positive and negative defects near pillars (25 μm < r < 50 μm) and far from pillars (r > 140 μm). Shaded regions represent the standard error of the mean value (SEM), red for positive and blue for negative defects, correspondingly. f Average defect speeds as a function of their average distance to the nearest pillar, calculated for Δt = 8 s. Error bars show standard deviation. The graininess of b, c is due to the coarse binning of the defect probability densities.

We obtained good agreement between theory and experiment, comparing experimental Figs. 2, 3 and computational Fig. 4. Numerical simulations confirm that negative defects reside on the pillar center, while positive defects accumulate at d ≈ 15 − 20 μm distance from the pillar center [Fig. 4a–d], in agreement with the experimental findings [Figs. 2 and 3] and Supplementary experimental Videos 3, 4 and simulation Videos 5, 6. Like in the experiment, the distribution of positive defects has maxima near the concave segments of the pillar, Figs. 2b and 4c. The proximity of pillars also leads to a reduction of defect mobility (Fig. 4e, f). The effective diffusivity of positive and negative defects drops from D+ = 24.7 μm2 s−1, D = 5.6 μm2 s−1 to D+ = 13.9 μm2 s−1 and D = 4 μm2 s−1. Since the motion of defects is not a purely normal diffusion, the provided values are given for a typical lifetime of defects Δt = 5–8 s.

We have found from the simulations that while positive defect accumulation near a pillar is robust, the defect distributions are sensitive to the director anchoring details. For example, if the anchoring is relatively strong and planar, the bend dominates the splay, as shown in supplementary Fig. S7a. Therefore, it will be more energetically favorable for the defect to bind to the concave segment of the pillar, as in the experiment and in our simulations. The opposite case of weak planar/hybrid anchoring is sketched in supplementary Fig. S7b: splay deformations are dominant at the vertices, and the defects preferentially bind near the tips. This situation can be possibly realized by treating the pillars with a substance favoring a homeotropic anchoring47. Similar to the experiment, there is also a depression of the negative defect density at a certain distance from the pillar; compare computational Fig. 4d and experimental Fig. 2c.

To extend our study beyond experimental conditions, we numerically investigate the effect of circular pillars [see Fig. 5 and Supplementary Videos 7, 8]. While defect trapping by pillars is robust, the form of the probability distributions depends on the pillar’s shape. Like in the triangular case, Fig. 4b, c, the distribution of negative defects for circular pillars has a maximum in the center while positive defects have a minimum, Fig. 5b, c. However, the defect distributions for circular pillars are axisymmetric, and the distribution for negative defects is about twice wider than that for triangular pillars. The defect mobility in the proximity of pillars does not exhibit significant differences compared to the triangular case, see Fig. S8.

Fig. 5: Simulations for pillars of circular cross-section.
figure 5

a The probability density function of positive and negative defects vs the distance from the pillar center. The concentration of negative (b) and positive (c) defects, the pillars' contours are depicted by the white lines. The color bars represent the defect concentrations. The graininess of (b), (c) is due to the coarse binning of the defect probability densities.

Fokker–Planck model

As an alternative mathematical description of the system, we model the defect dynamics with a one-dimensional probabilistic model derived from the Langevin defect dynamics, see Methods and ref. 37. A somewhat similar approach was later considered in ref. 48. Here the deterministic drift force is a sum of inter-defects interaction forces and the force on tactoid’s (pillar’s) surface that prevents defects from escaping the tactoid region. Stochastic forces depend on defects’ diffusivities, where positive defects are more mobile than the negative ones, in agreement with the experiment, Figs. 3a and 5a. The corresponding system of two Fokker–Planck (FP) equations for positive and negative defects densities is solved numerically, see Methods. The model provides a qualitative insight into the experiment. The steady-state concentration of positive and negative defects are shown in Fig. S9. This approach explains defects clustering at pillar’s boundary: less active negative defects tend to cluster inside the pillar, while more mobile positive defects escape the potential barrier and spread across the entire domain. The model predicts that the concentration of positive defects approaches the background value faster than that for the negative ones. The discrepancy for the defect concentrations inside the pillar is due to the ambiguity of defect identification in isotropic phase: Unlike the continuous model, in 1D simulations the defects were not allowed to annihilate.

Conclusions

Our work provides a new strategy for tuning the physical properties of active nematics. We demonstrate that microscopic obstacles robustly pin −1/2 topological defects, while the +1/2 defects remain mobile while some of them are trapped in the vicinity of pillars. Our experiments and simulations show that the pinning of negative defects also results in the overall reduction of motility of the positive defects. The experimental findings are supported by computational analysis based on the model of a living liquid crystal. Further numerical studies suggest that the observed phenomenon is not sensitive to the shape of obstacles: qualitatively similar behavior was observed for an array of round obstacles. In addition, we have shown that artificial imperfections can change the overall balance between positive and negative defects. As a result, the active fluid becomes topologically charged, with materials properties that are likely to differ from a “neutral” active fluid. Our work opens up an important future direction on experimental study of a topologically charged fluid.

In the context of equilibrium physics, the interplay between correlated disorder and vortex matter results in a variety of nontrivial glassy states49,50. An intriguing question is: whether topological defects in active systems form states similar to “spin glasses”51 or their interaction with the disorder is very different.

Methods

Pillars manufacturing

An array of pillars is 3D-printed on a glass slide by direct laser lithography using Nanoscribe Photonic Professional GT system. The materials used for printing is a high-resolution negative photoresist IP-Dip manufactured by Nanoscribe. The exposed photoresist is developed with Propylene glycol monomethyl ether acetate (PGMEA) from Sigma Aldrich for 20 min and then rinsed with Isopropanol. For best experimental conditions the pillars are made 20 μm tall.

Living liquid crystal preparation

Bacillus subtilis (strain 1085) bacteria initially grown on a Lysogeny Broth (Sigma Aldrich) agar plate are transferred to Terrific Broth (TB) liquid growth medium and kept at 30C for ≈8−12 h. The experiments are performed with a population of bacteria in the early logarithmic phase of growth. The bacteria are concentrated by centrifugation and mixed with a liquid crystal to achieve the final bacteria concentration of ≈5 × 109 cell/cm3. The liquid crystal is obtained by mixing disodium cromoglycate (DSCG) purchased from Spectrum Chemicals with TB at a concentration of 20% by weight. The final concentration of DSCG after mixing with is the concentrated bacterial suspension is 11.5% by weight.

Image acquisition and processing

The dynamics of the system was examined via an inverted microscope Olympus IX71 and recorded by a monochrome camera Prosilica GX 1660 (resolution 1600 × 1200 pixels) at 10 frames per second. The images were processed in MATLAB. The director field was reconstructed from the local bacterial orientations. For finding bacterial orientation, we used a gradient method and assumed that the largest variation of image intensity in the area around a single bacterium is perpendicular to a bacterial body. The director field was interpolated for the areas with no bacteria.

Advection-diffusion computational model of a living liquid crystal

We used the Beris–Edwards (BE) equations for the nematodynamics coupled with two advection-diffusion equations for bacterial concentrations37. The first BE equation describes the evolution of the tensorial order parameter Q:

$$({\partial }_{t}+\overrightarrow{v}\cdot \nabla ){{{{{{{\bf{Q}}}}}}}}-{{{{{{{\bf{S}}}}}}}}-\Gamma {{{{{{{\bf{H}}}}}}}}+{{{{{{{{\bf{F}}}}}}}}}_{{{{{{{{\rm{anch}}}}}}}}}=0,$$
(1)

where \(\overrightarrow{v}\) is the fluid velocity, tensor S describes the nematic flow alignment, H is the tensorial molecular field and Γ is the relaxation rate of the director, see Supplementary Note 2 for the definitions and Table S1 for the parameters used in simulations. The molecular field H is a variational derivative of Landau-de Gennes free energy and takes the following form:

$${{{{{{{\bf{H}}}}}}}}=a{{{{{{{\bf{Q}}}}}}}}-c{{{{{{{\bf{Q}}}}}}}}{{{{{{{\rm{Tr}}}}}}}}{{{{{{{{\bf{Q}}}}}}}}}^{2}+K{\nabla }^{2}{{{{{{{\bf{Q}}}}}}}},$$
(2)

where a and c are the Landau-de Gennes coefficients, K is the elastic constant (a one-constant approximation is used). We model pillars as isotropic tactoids. Pillars of the desired shape are created by prescribing the coefficient a to a negative value in the region of the pillars, strongly suppressing the magnitude of the order parameter. a is positive in the rest of the domain, which has a nematic phase. The coefficient \(c={{{{{{{\rm{const}}}}}}}} \, > \,0\) everywhere in the domain. The equilibrium magnitude of the order parameter remains zero in isotropic tactoids, while for the nematic phase \({q}_{{{{{{{{\rm{eq}}}}}}}}}=\sqrt{a/c} \, > \,0\).

The last term in Eq. (1) imposes strong planar alignment on the pillar’s surfaces. Similar to ref. 37, this term only alters the director orientation and does not change the amplitude of the order parameter:

$${{{{{{{{\bf{F}}}}}}}}}_{{{{{{{{\rm{anch}}}}}}}}}=4{\xi }_{{{{{{{{\rm{anch}}}}}}}}}{{{{{{{\bf{Q}}}}}}}}{{{{{{{{\bf{R}}}}}}}}}_{\pi /2}{{{{{{{\rm{Tr}}}}}}}}\left({{{{{{{\bf{Q}}}}}}}}(\overrightarrow{{f}_{e}}\overrightarrow{{f}_{e}}-{{{{{{{\bf{I}}}}}}}}/2){{{{{{{{\bf{R}}}}}}}}}_{\pi /2}\right){{{{{{{\mathcal{I}}}}}}}}(\overrightarrow{r})$$
(3)

here ξanch is the anchoring strength, Rπ/2 is a π/2 rotation matrix, \({\overrightarrow{f}}_{e}\) is a vector parallel to the pillar’s surface, and \({{{{{{{\mathcal{I}}}}}}}}(\overrightarrow{r})\) is the indicator function: \({{{{{{{\mathcal{I}}}}}}}}(\overrightarrow{r})\) is one near the pillars’ surfaces and zero everywhere else. As shown in ref. 25, this form leads to relaxation of the director orientation towards the vector \({\overrightarrow{f}}_{e}\) as follows:

$$\dot{\theta }=4{\xi }_{{{{{{{{\rm{anch}}}}}}}}}{q}^{2}\sin (2\phi -2\theta ),$$
(4)

where q is the amplitude of the order parameter, ϕ is the orientation angle of the vector \({\overrightarrow{f}}_{e}\), and θ is the director orientation angle. In addition to Eq. (1), the system includes the following equations:

$$\nabla \cdot \left({{{{{{{{\boldsymbol{\sigma }}}}}}}}}_{{{{{{{{\rm{a}}}}}}}}}+{{{{{{{{\boldsymbol{\sigma }}}}}}}}}_{{{{{{{{\rm{s}}}}}}}}}+{{{{{{{{\boldsymbol{\sigma }}}}}}}}}_{{{{{{{{\rm{act}}}}}}}}}+{{{{{{{{\boldsymbol{\sigma }}}}}}}}}_{{{{{{{{\rm{visc}}}}}}}}}-p{{{{{{{\bf{I}}}}}}}}\right)-\zeta \overrightarrow{v}=0.$$
(5)
$${\partial }_{t}{{{{{{{\bf{P}}}}}}}}={a}_{p}{{{{{{{\bf{P}}}}}}}}-4{c}_{p}{{{{{{{{\bf{P}}}}}}}}}^{3}-\frac{{{{{{{{{\bf{F}}}}}}}}}_{{{{{{{{\rm{Q}}}}}}}}}}{{\tau }_{0}}+{D}_{{{{{{{{\rm{p}}}}}}}}}{\nabla }^{2}{{{{{{{\bf{P}}}}}}}}$$
(6)
$$\begin{array}{l}{\partial }_{t}{c}^{+}+\nabla \cdot \left({V}_{0}\overrightarrow{p}{c}^{+}+\overrightarrow{v}{c}^{+}\right)=-\frac{{c}^{+}-{c}^{-}}{\tau }+{D}_{{{{{{{{\rm{c}}}}}}}}}{\nabla }^{2}{c}^{+},\\ {\partial }_{t}{c}^{-}+\nabla \cdot \left(-{V}_{0}\overrightarrow{p}{c}^{-}+\overrightarrow{v}{c}^{-}\right)=-\frac{{c}^{-}-{c}^{+}}{\tau }+{D}_{{{{{{{{\rm{c}}}}}}}}}{\nabla }^{2}{c}^{-}\end{array}$$
(7)

Equation (5) is the balance of linear momentum. The stress includes the elastic σs (symmetric) and σa (antisymmetric), and viscous σvisc contributions, see Supplementary Note 2 for the definitions. σact is the active stress that depends on the bacterial concentration, p is the fluid pressure and \(\zeta \overrightarrow{v}\) is the viscous friction which depends on the sample thickness. Equation (6) describes the evolution of the bacterial orientation tensor \({{{{{{{\bf{P}}}}}}}}=\left\vert {{{{{{{\bf{P}}}}}}}}\right\vert (\overrightarrow{p}\overrightarrow{p}-{{{{{{{\bf{I}}}}}}}}/2)\). The two first terms on the right-hand side control the amplitude P. Similar to Eq. (3), the third term aligns P with the nematic field Q37:

$${{{{{{{{\bf{F}}}}}}}}}_{{{{{{{{\rm{Q}}}}}}}}}=4{{{{{{{\bf{P}}}}}}}}{{{{{{{{\bf{R}}}}}}}}}_{\pi /2}{{{{{{{\rm{Tr}}}}}}}}\left({{{{{{{\bf{PQ}}}}}}}}{{{{{{{{\bf{R}}}}}}}}}_{\pi /2}\right)$$
(8)

here τ0 is an alignment time for a bacterium with respect imposed nematic direction (about a second), and Dp is the bacterial orientation diffusion. Eqs. (7) account for the bacterial concentrations c± that swim parallel and antiparallel to the orientation vector \(\overrightarrow{p}\). τ is the bacterial reversal rate and Dc is the concentration diffusion, V0 is the magnitude of bacterial velocity.

We positioned four identical pillars in a 2 × 2 squared grid (see Fig. 4(a)). Their shape and size were similar to the experimental ones. Their boundaries in polar coordinates were described by: \(f(r)=\frac{{r}_{0}}{0.2+\left\vert \cos (1.5\theta )\right\vert }\), where we set r0 = 2.5 μm. This formula was used to create spatially-modulated Landau-de Gennes coefficient a(x, y), which was negative inside and positive outside of the regions of pillars. Additional details for this computational model can be found in37. Simulation parameters are listed in Table S1.

Simplified Fokker-Planck model

We model the transport of defects with the 1D Langevin equation37. We assume that the system contains equal number of positive and negative defects N± residing either in the nematic phase or on the pillar modeled by a isotropic tactoid. We assume that well-separated defects interact similarly to electrical charges (those with the same topological charge repel, those with different attract) and the interaction strength decays with distance as 1/x. Thus, two contributions: one due to defect interaction and another due to a barrier on the tactoid’s surface control the defect dynamics. Our computational 1D domain \(x\in \left[0;L\right]\) consists of a small tactoid region \(x\in \left[0;a\right]\), and the rest is occupied by a nematic medium. The potential barrier prevents the defects from escaping isotropic phase and has a form of a step function:

$$U(x)=\left\{\begin{array}{ll}0,\quad &{{{{{{{\rm{for}}}}}}}}\quad 0 \, < \,x \, < \,a,\\ A,\quad &{{{{{{{\rm{for}}}}}}}}\quad x \, > \,a,\end{array}\right.$$
(9)

The Langevine equations for the positions xi of each individual defect can cast as following:

$$\begin{array}{l}{\partial }_{t}{x}_{i}^{+}={U}^{{\prime} }({x}_{i}^{+})+\mu \left(\mathop{\sum }\limits_{j=0}^{N}\frac{1}{{x}_{j}^{-}-{x}_{i}^{+}}-\mathop{\sum }\limits_{j=0,j\ne i}^{N}\frac{1}{{x}_{j}^{+}-{x}_{i}^{+}}\right)+{\xi }^{+},\\ {\partial }_{t}{x}_{i}^{-}={U}^{{\prime} }({x}_{i}^{-})+\mu \left(\mathop{\sum }\limits_{j=0}^{N}\frac{1}{{x}_{j}^{+}-{x}_{i}^{-}}-\mathop{\sum }\limits_{j=0,j\ne i}^{N}\frac{1}{{x}_{j}^{-}-{x}_{i}^{-}}\right)+{\xi }^{-},\end{array}$$
(10)

where μ is the interaction strength, ξ± are random forces with the magnitude D±.

Following ref. 37, we introduce the probability density distribution functions of positive and negative defects P±. Then, the sums in Eq. (10) can be cast as integrals over P±. The corresponding Fokker-Planck equations for the probability density distribution of positive (P+) and negative (P) defects are then of the form37:

$$\begin{array}{l}{\partial }_{t}{P}^{+}(x,t)={D}^{+}{\partial }_{xx}{P}^{+}-{\partial }_{x}\left[\left(-{U}^{{\prime} }(x)+\mu \int\nolimits_{0}^{L}\frac{{P}^{+}({x}^{{\prime} },\,t)-{P}^{-}({x}^{{\prime} },\,t)}{x-{x}^{{\prime} }}d{x}^{{\prime} }\right){P}^{+}(x,t)\right],\\ {\partial }_{t}{P}^{-}(x,t)={D}^{-}{\partial }_{xx}{P}^{-}-{\partial }_{x}\left[\left(-{U}^{{\prime} }(x)-\mu \int\nolimits_{0}^{L}\frac{{P}^{+}({x}^{{\prime} },\,t)-{P}^{-}({x}^{{\prime} },\,t)}{x-{x}^{{\prime} }}d{x}^{{\prime} }\right){P}^{-}(x,t)\right],\end{array}$$
(11)

where and D± are the diffusivities of positive and negative defects correspondingly. The diffusivities are expressed via magnitude of the noise terms ξ±. We assume that D+ > D, reflecting the fact that positive defects are more mobile (see Fig. 3(c)).

We are looking for a stationary solution to Eqs. (11). Integrating both equations, we obtain:

$$\begin{array}{l}{D}^{+}\left({\partial }_{x}{P}^{+}+{R}^{+}\right)=\left(-{U}^{{\prime} }(x)+\mu \int\nolimits_{0}^{L}\frac{{P}^{+}({x}^{{\prime} },\,t)-{P}^{-}({x}^{{\prime} },\,t)}{x-{x}^{{\prime} }}d{x}^{{\prime} }\right){P}^{+}(x,t),\\ {D}^{-}\left({\partial }_{x}{P}^{-}+{R}^{-}\right)=\left(-{U}^{{\prime} }(x)-\mu \int\nolimits_{0}^{L}\frac{{P}^{+}({x}^{{\prime} },\,t)-{P}^{-}({x}^{{\prime} },\,t)}{x-{x}^{{\prime} }}d{x}^{{\prime} }\right){P}^{-}(x,t),\end{array}$$
(12)

where R± are the integration constants to be determined. Eqs. (12) can be transformed using a general formula for the solution of a 1st order inhomogenious ordinary differential equation (integration factor):

$${P}^{\pm }(x)={s}_{a}^{\pm }(x)\left({C}^{\pm }-{s}_{b}^{\pm }(x)\right),$$
(13)

where C± are another pair of integration constants and the following notations are introduced:

$$z(x)=\int\nolimits_{0}^{L}\left({P}^{+}({x}^{{\prime} })-{P}^{-}({x}^{{\prime} })\right)\log \left\vert x-{x}^{{\prime} }\right\vert d{x}^{{\prime} },$$
(14)
$${s}_{a}^{\pm }(x)=\exp \left[\int\nolimits_{0}^{x}\left(-\frac{{U}^{{\prime} }(x)}{{D}^{\pm }}\pm \frac{\mu }{{D}^{\pm }}\int\nolimits_{0}^{L}\frac{{P}^{+}({x}^{{\prime} },t)-{P}^{-}({x}^{{\prime} },t)}{x-{x}^{{\prime} }}d{x}^{{\prime} }\right)dx\right]\exp \left[\frac{1}{{D}^{\pm }}\left(-U(x)\pm z(x)\right)\right],$$
(15)
$${s}_{b}^{\pm }(x)=\int\nolimits_{0}^{x}\frac{{R}^{\pm }}{{s}_{a}^{\pm }({x}^{{\prime} })}d{x}^{{\prime} },$$
(16)

To find the integration constant R±, we use the Neumann boundary condition (which also accounts for probability reflection on the boundary, since the potential is constant at the boundaries) at the right boundary, δxP±(L) = 0. Substituting it into Eq. (12), we obtain:

$${R}^{\pm }=\pm \frac{\mu {P}^{\pm }(L)}{{D}^{\pm }}\int\nolimits_{0}^{L}\frac{{P}^{+}({x}^{{\prime} })-{P}^{-}({x}^{{\prime} })}{L-{x}^{{\prime} }}d{x}^{{\prime} }$$
(17)

To find the integration constants C±, we use the normalization condition for positive and negative defect densities \(\int\nolimits_{0}^{L}{P}^{\pm }(x)dx=L{P}_{0}\). From Eq. (13) we find:

$${C}^{\pm }=\frac{L{P}_{0}+\int\nolimits_{0}^{L}{s}_{a}^{\pm }(x){s}_{b}^{\pm }(x)dx}{\int\nolimits_{0}^{L}{s}_{a}^{\pm }(x)dx}$$
(18)

We obtain P±(x) using the iterative relaxation method. Given initial guesses \({P}_{0}^{\pm }(x)\), we calculate tentative \({\tilde{P}}_{0}^{\pm }(x)\) using Eq. (13). We then update the probability densities by weighted average of the previous and current values:

$${P}_{n}^{\pm }(x)=\alpha {P}_{n-1}^{\pm }(x)+(1-\alpha ){\tilde{P}}_{n-1}^{\pm }(x),$$
(19)

where α = 0.999. Such method rapidly converges to the stationary solutions \({P}_{* }^{\pm }(x)\). The results are shown on Fig. S9. While the results generally agree with the experiment, especially for round pillars. There are also some discrepancies. The main difference is that positive defects also peak inside the tactoid, although positive peak amplitude is smaller than the negative one. This can be attributed to an oversimplification of the Fokker-Planck model. For example, mutual annihilation can lead to depletion of positive defects inside the tactoid.