1 Introduction

Structured light, referring to custom light fields with tailored intensity, polarization and phase [1, 2], is essential in various fields of research and applications, including imaging [3], microscopy [4, 5], communication [6], quantum information [7], and light-matter interactions [8, 9]. The terahertz frequency range is particularly intriguing due to its nonionizing nature, excellent penetration capability, and its unique ability to carry fingerprint signatures of condensed matter and biomolecules [10]. Thus, the expertise to generate and control structured terahertz radiation holds great promise for advancing terahertz applications. For instance, precise structuring of terahertz wavefronts could enhance the spatial resolution of terahertz microscopy [11, 12], enable terahertz holographic imaging [13], and facilitate novel techniques for terahertz spectroscopy and sensing [14]. Moreover, structured terahertz waves with orbital angular momentum (OAM) and OAM multiplexing could potentially expand terahertz communication bandwidth [15, 16].

Spatial light modulators based on liquid crystals and digital micromirror devices are commonly used to generate structured light at optical frequencies [17, 18]. However, their applications at terahertz frequencies face challenges due to the necessity for the larger sizes of liquid crystals and digital micromirrors. The increased sizes result in higher losses and voltage requirements for liquid crystals, as well as manufacturing challenges for micromirrors. Metasurfaces, utilizing subwavelength meta-atoms, offer an alternative technology for enhanced terahertz wave interaction, providing higher spatial resolution and larger modulation depth [19,20,21,22]. However, these devices usually operate in free space and need to be inserted into the beam path. Furthermore, they often encounter limitations related to low efficiency and narrow manipulation bandwidth. So far, most terahertz metasurfaces demonstrated thus far are passive and unifunctional, requiring the design and manufacture of a specific device for different wave-manipulation functions. Though a few reconfigurable metasurfaces have been realized in the terahertz regime using novel materials such as semiconductors [23, 24], phase-transition materials [25, 26], two-dimensional materials [27,28,29,30,31,32,33] and nonlinear crystals [34], they still encounter limitations related to scalability, bandwidth, and functionality limitations.

Recent progress in spintronic terahertz emitters presents a new avenue to efficiently generate and actively control terahertz waves within a single device. These heterostructure devices, composed of nanometer-thick ferromagnetic (FM) and heavy metal (HM) layers, enable ultrabroadband terahertz emission through the spin-to-charge conversion process via the inverse spin Hall effect (ISHE) within the HM layer with strong spin–orbit coupling [35,36,37]. Furthermore, by fabricating metallic thin films into subwavelength structures (meta-atoms), spintronic-metasurface emitters can produce terahertz radiations with circular polarizations [38], controllable wavefronts [39], and OAM [40].

Nevertheless, existing configurations of spintronic-metasurface emitters have limitations, as the external field can only uniformly saturate the FM magnetization within each meta-atom, restricting the flexibility and diversity for structured terahertz-wave generation. In particular, this limitation hinders simultaneous manipulation of spin and orbital angular momenta. To realize diverse and complex functionalities, individual metasurface devices still need to be manufactured. Although previous research has employed an inhomogeneous field distribution to overcome this limitation and generate elliptically polarized terahertz fields [41], this approach lacks the necessary spatial resolution and field complexity for arbitrary terahertz-wave manipulation.

In this work, we demonstrate a novel programmable spintronic emitter with remarkable capability to generate a variety of structured terahertz waves while simultaneously control both spin and orbital angular momenta. The emitter achieves this capability through the flexible, micrometer-resolution programming of the magnetization pattern at its surface, facilitated by the unidirectional magnetic anisotropy within an FM layer exchange-coupled with an adjacent antiferromagnetic (AFM) layer [42]. The local magnetization direction becomes flexibly programmable through a local field cooling process. Consequently, with a high degree of freedom, we can meticulously design and generate broadband terahertz beams featuring diverse structured polarization states, including spatially separated circular polarizations, azimuthal or radial polarization states, and the creation of a full Poincaré beam. Our results demonstrate the immense potential of the programmable spintronic emitter for advanced terahertz applications.

2 Programming of exchange-biased spintronic emitters

Our experiments are based on a trilayer heterostructure, which is composed of a 6-nm-thick IrMn3 (AFM) layer, a 3-nm-thick Fe21Ni79 (FM) layer, and a 2-nm-thick Pt (HM) layer, as illustrated in Fig. 1a. The entire heterostructure is deposited on a 0.5-mm-thick, double-side polished Al2O3(0001) substrate. Further details about sample preparation can be found in Methods. The selection of FM and HM materials follows standard practice for spintronic emitters, extensively studied in previous works [37, 43]. In our experiment, we optimized the layer thickness to maximize terahertz-generation efficiency. However, the thickness of the IrMn3 layer is critical. While a thinner IrMn3 layer may generate slightly stronger terahertz waves, a robust exchange bias is established only when the IrMn3 layer thickness exceeds 6 nm (see SM Fig. S17), which is the key to realize magnetization programming (see below).

Fig. 1
figure 1

Concept of the programmed exchange-biased spintronic terahertz emitter. a Schematic of the experimental setup. Femtosecond laser pulses are applied to excite the programmed exchange-biased spintronic emitter, which induces spin-polarized current (js) and local terahertz NF ENF. Structured terahertz vector fields are generated in the far field. bd Illustration of the LAMP process. b The magnetization of the FM layer (white arrows) is uniformly pinned in one direction by the exchange interaction with the AFM layer (red arrows). The magnetic hysteresis loop before programming exhibits an exchange-bias field HEB. c The movement of the writing laser beam Pw on the sample surface in the presence of the writing magnetic field Hw leads to a local field cooling, which resets the exchange bias direction in the programmed area (orange arrows) aligned with Hw. d. When both Pw and Hw are removed, the magnetization orientation in the FM layer is stabilized by the local exchange bias. The hysteresis loop in the programmed regions is modified. e. Illustration of the design strategy to derive the magnetization (mag.) pattern M(r) from the target field Etar(r). F. S. P.: Free-space propagation. f. Illustration of different regions for the polarization angle of the local terahertz NF, ΘNF, determined by the design strategy

The interface exchange interaction between the FM and IrMn3 layers induces a strong unidirectional magnetic anisotropy within the FM layer, resulting in a net magnetization (M) in the absence of an external magnetic field [42]. Under femtosecond laser excitation, nonequilibrium spin-polarized currents (js) are generated and transport from the FM to the Pt (HM) layer. The spin polarization of js aligns with M. The strong spin–orbit coupling of HM then converts the longitudinally propagating js to transverse charge currents jc, according to the ISHE [36]: \({\mathbf{j}}_{c}=\gamma {\mathbf{j}}_{s}\times \mathbf{M}/\left|\mathbf{M}\right|\), where γ represents the spin-Hall angle of HM. As a result, the trilayer heterostructure can emit ultrashort terahertz pulses in a field-free environment upon excitation by femtosecond laser pulses [44], with the polarization of the terahertz field perpendicular to M. While the IrMn3 layer can also deflect spin-polarized currents through ISHE, our experiments demonstrate that the terahertz waves are dominantly generated in the HM layer (see SM Fig. S16).

The programming of the magnetization pattern, M(r), of the spintronic emitter is accomplished through the laser-assisted magnetic programming (LAMP) method [45], as illustrated in Fig. 1b–d. Initially, a uniform unidirectional magnetic anisotropy is established within the FM layer during the sample growth process (see Methods), causing the hysteresis curves to shift due to an exchange bias (Fig. 1b).

In the subsequent step (Fig. 1c), a femtosecond laser beam (referred to as the writing beam) with a power of Pw is focused onto the designated location in the presence of a writing magnetic field Hw = 1000 Oe. The writing laser beam possesses a pulse duration of 110 fs, a repetition rate of 36 MHz, and a central wavelength of 1030 nm. The localized laser heating raises the temperature of the heterostructure beyond the Néel temperature [42], TN, while ensuring it remains below the Curie temperature of the FM layer. As the laser spot traverses along the writing direction with a velocity of vw, the previously heated area of the AFM film undergoes a local field cooling. This field-cooling process induces a rearrangement of the AFM spins within the patterned region due to the exchange coupling with the adjacent FM layer when the spin polarization of the FM layer is uniformly aligned in the direction of Hw (Fig. 1c).

Consequently, once the writing laser Pw and writing field Hw are both removed (Fig. 1d), the magnetization within the FM layer in the programmed area (orange arrows) is pinned by the new unidirectional magnetic anisotropy in the direction of Hw, while the magnetization in the unprogrammed area (white arrows) returns to its original state. The exchange bias in the patterned region is thus modified by this local field cooling process. Further details about the LAMP method can be found in Methods and Supplementary Materials (SM) section S1.

It is noteworthy to mention that resonant phonon excitation in certain AFM materials can directly induce local magnetization switching via optomagnetic effects [46,47,48], offering potential for magnetization programming. However, current applications of these materials require a terahertz or mid-infrared writing laser and low temperatures.

In Fig. 2a, b, we demonstrate the flexible control of exchange bias through the LAMP method. In these experiments, we utilize the same femtosecond laser to excite the specific regions of the heterostructure where the magnetization programming was performed, ensuring that the excitation laser power remained below the threshold fluence (see below). The hysteresis curves are obtained by plotting the signed amplitudes of emitted terahertz waves (Fig. 2c, d) against the magnetic field strength. The hysteresis curves before programming are plotted as the dashed lines, which exhibits a robust exchange-bias shift of HEB≈500 Oe along y (Fig. 2a), and a typical hard-axis-loop behavior along x (Fig. 2b).

Fig. 2
figure 2

Results of the LAMP process. a The hysteresis curves along the y axis, obtained by measuring the signed amplitude of Ex as a function of the applied magnetic field Hy. The dashed lines are the results obtained from the unprogrammed regions. The red and blue solid lines represent the results from the programmed areas with Hw along + y (I) and along -y (II), respectively, during the LAMP process. b Similar to a, hysteresis curves are shown, but for magnetic fields along x. The orange and azure lines represent the hysteresis curves obtained from the programmed area with Hw along + x (III) and along -x (IV), respectively, during the LAMP process. cd The terahertz waveforms under the zero-field condition obtained from the programmed areas with Hw applied along different directions in the LAMP process. The solid lines depict the Ex components, while the dashed lines represent the Ey components. The signed amplitudes of the waveforms are labeled by the solid triangles. e. The Kerr microscopy images of the magnetic domains programmed under different writing laser powers (Pw). f The writing resolution in diameter (Dw) as a function of Pw obtained from the Kerr microscopic measurements. The red solid line represents the fit to the empirical model

In Fig. 2a, we explore two scenarios during the LAMP process: applying Hw along + y (I) and -y (II) directions. Note that under these conditions, the polarization of terahertz radiation aligns with the x-axis (Fig. 2c). Here, we observe a clear shift of the exchange bias when Hw is applied in the opposite directions along y, leading to the opposite polarities of the emitted terahertz waves under zero field (Fig. 2c). Similarly, in Fig. 2b, we further demonstrate control of the exchange bias along the + x (III) and -x (IV) directions, with the corresponding terahertz waveforms shown in Fig. 2d. It is important to note that the temporal terahertz waveforms exhibit remarkable similarity (Fig. 2c, d), which is essential for the broadband application of our method.

In Fig. 2e, we present the Kerr microscopy images of the programmed magnetic domains under different writing laser power Pw. The diameter of the writing laser beam (D0) is approximately 60 μm on the sample surface, moving at a linear speed of vw = 500 μm s−1 (see Methods). We observe that the domain width can be precisely controlled by Pw. To quantify this effect, we plot the magnetic domain width (Dw) as a function of Pw in Fig. 2f. The data can be well fitted to an empirical model \({D}_{w}=\frac{{D}_{0}}{\sqrt{2}}\sqrt{-\text{ln}\left(\frac{{P}_{th}}{{P}_{w}}\right)}\), where Pth = 0.46 W represents a threshold power (see SM Section S1), corresponding to a threshold fluence of ~ 0.45 mJ/cm2. This threshold power (Pth) denotes the minimum laser power required to reach TN under the current laser conditions. Furthermore, our results reveal that the heterostructure suffers permanent damage when Pw exceeds 1.5 W (see SM Fig. S2). For subsequent demonstrations, we prudently select a writing power of Pw = 1.2 W, providing a spatial resolution for the magnetization-pattern programming of approximately 40 μm.

The magnetization pattern on each heterostructure sample can be reliably reprogrammed by overriding old pattern with newly designed ones. In addition, the existing pattern can be erased by a field-cooling process in a heater oven. Throughout this study, we repetitively programmed a single heterostructure sample with various patterns, observing no significant degradation of the sample.

3 Design strategy of magnetization patterns

In order to generate a target far-field terahertz beam with complex spatial and polarization characteristics, it is important to establish a generic strategy for designing the magnetization pattern M(r), where r denotes the position vector in the transverse plane (Fig. 1e). Here, we adopt the paraxial approximation and assume that the terahertz electric fields are confined in the transverse plane. The target far-field terahertz beam, under the circular polarization basis (eL and eR), can be described as

$${\mathbf{E}}_{tar} \left( {\mathbf{r}} \right) = A_{tar}^{L} \left( {\mathbf{r}} \right)e^{{i{\Phi }_{L} \left( {\mathbf{r}} \right)}} {\mathbf{e}}_{L} + A_{tar}^{R} \left( {\mathbf{r}} \right)e^{{i{\Phi }_{R} \left( {\mathbf{r}} \right)}} {\mathbf{e}}_{R}$$
(1)

In Eq. (1), \({A}_{tar}^{L(R)}\) and \({\Phi }_{L(R)}\) denote the far-field amplitude and phase of the left- (right-) handed circular polarization [LCP (RCP)] component, respectively. The local near-field (NF) terahertz waves at the emitter’s surface, denoted as ENF(r), can then be calculated following scalar diffraction theory [49] (Fig. 1e):

$${\mathbf{E}}_{NF} \left( {\mathbf{r}} \right) = \smallint {\tilde{\mathbf{E}}}_{tar} \left( {{\mathbf{k}}_{\parallel } } \right)G\left( {{\mathbf{k}}_{\parallel } } \right)e^{{i{\mathbf{k}}_{\parallel } \cdot {\mathbf{r}}}} {\text{d}}{\mathbf{k}}_{\parallel }$$
(2)

Here, \({\widetilde{\mathbf{E}}}_{tar}\left({\mathbf{k}}_{\parallel }\right)=\int {\mathbf{E}}_{tar}(\mathbf{r}){e}^{-i{\mathbf{k}}_{\parallel }\cdot \mathbf{r}}\text{d}\mathbf{r}\) denotes the Fourier-space representation of the target field, with \({\mathbf{k}}_{\parallel }\) being the transverse wavevector (Fig. 1e). The transfer function of free-space propagation, G(\({\mathbf{k}}_{\parallel }\)), is given by [49].

$$G\left( {{\mathbf{k}}_{\parallel } } \right) = \left\{ \begin{gathered} e^{{iz_{0} \sqrt {\left| {{\mathbf{K}}_{0} } \right|^{2} - \left| {{\mathbf{k}}_{\parallel } } \right|^{2} } }} ,\quad \left| {{\mathbf{k}}_{\parallel } } \right| < \left| {{\mathbf{K}}_{0} } \right| \hfill \\ 0,\quad \quad \quad \quad \quad \left| {{\mathbf{k}}_{\parallel } } \right| \ge \left| {{\mathbf{K}}_{0} } \right| \hfill \\ \end{gathered} \right.$$
(3)

Here, K0 represents the terahertz wavevector with \(\left|{\mathbf{K}}_{0}\right|=\frac{2\uppi }{\lambda }\) (Fig. 1e), where λ is the terahertz wavelength, and z0 is the distance from the emitter’s surface to the transverse plane of interest.

To generate complex structured terahertz fields in the far field, it is necessary to exert control over both the amplitude and polarization states of ENF(r). First, the amplitude |ENF(r)| can be regulated by varying the local intensity of the excitation laser. In this work, as lasers with Gaussian profiles were employed to excite various programmed emitters, the amplitude design on ENF(r) was not pursued. Second, the linear polarization of ENF(r) aligns with the flowing direction of the transverse current density jc(r) at the same location following Ohm’s law [36]: \({\mathbf{E}}_{NF}\left(\mathbf{r}\right)\propto {\mathbf{j}}_{c}\left(\mathbf{r}\right)\). The orientation of the local magnetization M(r) is then derived by \(\frac{\mathbf{M}(\mathbf{r})}{\left|\mathbf{M}(\mathbf{r})\right|}=\frac{{\mathbf{j}}_{c}\left(\mathbf{r}\right)\times {\mathbf{j}}_{s}}{\left|{\mathbf{j}}_{c}\left(\mathbf{r}\right)\times {\mathbf{j}}_{s}\right|}\), according to the ISHE [36]. Further details about the design strategy can be found in Methods.

4 Generation of complex structured terahertz fields

Following the design strategy, we first demonstrate the generation of terahertz beams with spatially separated circular polarizations. Here, the target terahertz field can be expressed as

$${\mathbf{E}}_{tar} \left( {x,y} \right) = A_{0} e^{{ - \left[ {\frac{{\left( {x + x_{0} } \right)^{2} + y^{2} }}{{w^{2} }}} \right]}} e^{{ - ik_{0} x}} {\mathbf{e}}_{L} + A_{0} e^{{ - \left[ {\frac{{\left( {x - x_{0} } \right)^{2} + y^{2} }}{{w^{2} }}} \right]}} e^{{ik_{0} x}} {\mathbf{e}}_{R}$$
(4)

where A0 is the field amplitude, w is the Gaussian beam radius, and k0 is the transverse wavevector defined by \({k}_{0}=\frac{2\pi }{\lambda }\left|\text{sin}{\varphi }_{e}\right|\) with φe being the emission angle. The transverse offset of the beams at the target plane, denoted as x0, is given by \({x}_{0}={z}_{0}\left|\text{tan}{\varphi }_{e}\right|\). For this demonstration, we intentionally set φe =  ± 30° for the terahertz waves with a wavelength of λ = 300 μm (corresponding to 1 THz). The radius of the excitation laser beam is set to w = 1.8 mm.

In Fig. 3a, b, we respectively plot the local terahertz NF ENF(r) and the corresponding magnetization pattern M(r) obtained from our design strategy (see SM Section S3). The separation of the terahertz waves carrying opposite spin angular momenta results in a rotating local-field polarization along x, and its spatial periodicity Λ is 600 μm.

Fig. 3
figure 3

Programmed terahertz emitter with spatially separated circular polarizations. a The distribution of local terahertz NF ENF(r) obtained from the design strategy. The trajectory for the focused-beam excitation measurement is illustrated with a scanning position of xs. b The magnetization pattern M(r) obtained from ENF(r) in a. c The symbols represent the signed amplitudes of the Ex and Ey fields obtained from the focused-beam excitation measurements as a function of the scanning position, xs. The solid lines depict results obtained from the wave-propagation simulations with a focused excitation laser spot and the trajectory shown in a. de The spatio-spectral distribution of the experimentally measured terahertz waves with LCP and RCP, respectively, under the zero-field condition. The dashed lines represent the spatial chirp of the terahertz waves. fg Similar to d and e, simulation results obtained from the wave-propagation simulations for the LCP and RCP components. hi The three-dimensional temporal profiles of the terahertz waveforms emitted at φe =  + 30° and −30°, respectively

For the experimental realization, we program a heterostructure sample with transverse dimensions of 1 cm × 1 cm, following the pattern of M(r) shown in Fig. 3b. Since the polarization of the emitted terahertz wave is perpendicular to the local magnetization, we employ a focused-beam excitation setup to evaluate the accuracy of the programmed heterostructure. In this setup, a laser beam is focused to excite the local magnetic domains, and the laser spot is scanned along the x-axis following the trajectory shown in Fig. 3a. Simultaneously, the amplitudes of Ex and Ey terahertz components are recorded (see Methods and SM Section S2). The results, as depicted in Fig. 3c, exhibit sinusoidal oscillations as a function of the scanning position (xs) with a phase offset of π/2 between Ey and Ex. The obtained results are in excellent agreement with our wave-propagation simulations (see Methods), which exhibits a chiral variation of M(r) along x with a superlattice constant of Λ = 600 μm. These results clearly demonstrate the successful programming of the exchange-biased emitter.

The emission of terahertz radiation from the entire programmed heterostructure is excited using an amplifier laser beam (25 fs pulse duration, 10 kHz repetition rate, and a central wavelength of 1030 nm) with a large beam radius of approximately 1.8 mm, effectively covering multiple lattice constants. The excitation laser fluence is reduced to below the writing threshold fluence. The spatial distribution of the polarization states is subsequently detected using an angle-resolved detection setup (see Methods and SM Section S7).

In Fig. 3d, e, we respectively present the experimental spatial distribution of the LCP and RCP terahertz radiations. The results reveal that the LCP and RCP radiations are emitted at different angles, with LCP observed at φe < 0 and RCP at φe > 0. Moreover, the terahertz waves with the frequency of 1 THz are emitted at φe =  ± 30°, consistent with our design. The diffraction from the superlattice further results in the angular dispersion of the terahertz waves, as described by \(f=\frac{c}{\Lambda \left|\text{sin}{\varphi }_{e}\right|}\) (Fig. 3d, e), where f represents the terahertz frequency and c is the speed of light. The angular dispersion may prove beneficial in some applications, allowing the separation of different terahertz frequencies through simple spatial filtering. The experimental results can be well reproduced by our wave-propagation simulations (Fig. 3f, g), where the finite spot size of the excitation laser and the experimental terahertz spectrum are considered (see Methods). In Fig. 3h, i, we present the experimental temporal profiles of terahertz radiations emitted at φe = −30° and 30°, respectively, clearly showing distinct LCP and RCP chirality.

In the second case, we demonstrate the generation of an azimuthally polarized terahertz beam. The target terahertz field can be expressed under the radial coordinate (r, ϕ) by

$${\mathbf{E}}_{tar} \left( {r,\phi } \right) = A_{0} e^{{ - \frac{{r^{2} }}{{w^{2} }}}} e^{{i\left( {\phi + \frac{\pi }{2}} \right)}} {\mathbf{e}}_{L} + A_{0} e^{{ - \frac{{r^{2} }}{{w^{2} }}}} e^{{ - i\left( {\phi + \frac{\pi }{2}} \right)}} {\mathbf{e}}_{R}$$
(5)

In Fig. 4a, b, we plot the local NF ENF(r) and the magnetization pattern M(r), respectively. The design process is described in SM Section S4. The generation of azimuthally polarized terahertz fields requires a radially polarized distribution of M(r) (Fig. 4b).

Fig. 4
figure 4

Programmed terahertz emitter with azimuthal polarization. a The distribution of local terahertz NF ENF(r) obtained from the design strategy. The trajectory for the focused-beam excitation measurement is illustrated with a radius of rs and a scanning angle of θs. b The magnetization pattern M(r) obtained from ENF(r) in a. c The symbols represent the results from the focused-beam excitation measurements as a function of the scanning angle, θs. The solid lines depict results from the wave-propagation simulations with a focused excitation laser spot and the trajectory shown in a. d1d4 The experimentally measured intensity (|Etar|2) and phase profiles of the emitted terahertz waves at a frequency of 0.47 THz for polarizations parallel to y (‖y) and perpendicular to y (⊥y). e1e4 Similar to d, simulation results obtained from the wave-propagation simulations

For the experimental realization, we reprogram the same heterostructure according to the pattern of M(r) in Fig. 4b. In the focused-beam excitation setup, we scan the laser spot along a circular trajectory around the center, with a radius of rs = 250 μm (Fig. 4a). The Ex and Ey amplitudes are plotted in Fig. 4c, exhibiting sinusoidal behaviors against the scanning angle θs with a phase offset of π/2. These results confirm the radial distribution of M(r).

The emission of terahertz radiation from the entire heterostructure is excited using a femtosecond laser amplifier (50 fs pulse duration, 1 kHz repetition rate, and a central wavelength of 780 nm). The excitation beam is normal incident to the emitter’s surface with a beam radius of 4.5 mm, its beam center aligned with the center of the programmed structure. The excitation laser fluence is below the writing threshold fluence. The spatio-temporal profiles of the radiation are measured using a polarization-resolved terahertz digital holographic imaging system [50] (TDHIS, see Methods and SM Section S8).

In Fig. 4d1, d2, we present the experimentally measured spatial profiles of the intensity (|Etar|2) and phase of the terahertz radiation, respectively, for the polarization component parallel to y (‖y), while Fig. 4d3, d4 depict the corresponding results for the polarization orthogonal to y (⊥y). The observed profiles exhibit two distinct lobes along a line perpendicular to the polarization direction, with the polarities of the terahertz waves flipping across the beam center. These results provide clear evidence for the generation of azimuthally polarized terahertz beams. Our wave-propagation simulations reproduce these experimental results, as shown in Fig. 4e1–e4.

Interestingly, despite employing a Gaussian beam profile for the target terahertz field [see Eq. (5)], the rapid polarization rotation within a small area at the beam center results in diffraction with a transverse wavevector exceeding 2π/λ, which is forbidden in free-space wave propagation [see Eq. (3)]. As a result, both the experimental and simulation results exhibit a suppression of the field intensity at the beam center.

In Fig. 4d, e, we present the results obtained specifically at the terahertz frequency of f = 0.47 THz. The results at other terahertz frequencies are provided in SM Section S4, highlighting the broad bandwidth of the generated azimuthally polarized terahertz beams. Additionally, by programming M(r) to an azimuthally polarized distribution, we can effectively generate broadband radially polarized terahertz radiation (see SM Section S5).

By achieving flexible and subwavelength control over the polarization states of local terahertz emitters, we acquire the capability to manipulate both the spin and orbital angular momenta of the far-field terahertz beams. In the last case, we demonstrate this capability by generating a terahertz beam that provides all the states of polarization in the beam cross-section, also known as the full Poincaré (FP) beam [51]. The polarization properties of the FP beam have attracted attention due to its potential applications in various fields, generating special optical forces [52], achieving a flat-top intensity profile [52], facilitating single-shot polarimetry measurements [53], and generating polarization speckles [54]. Our work could extend these applications to the terahertz wavelengths.

The target terahertz beam is a superposition of two lowest order Laguerre-Gaussian (LG) beams (with a radial index of p = 0), carrying opposite circular polarizations. Here, we choose the scalar LG beam (the Gaussian beam) for the LCP field, while assigning the LG beam with OAM of l = −2 to the RCP field. Consequently, the target field can be defined as

$${\mathbf{E}}_{tar} \left( {r,\phi } \right) = A_{R} C_{lp}^{LG} \left( {\frac{r\sqrt 2 }{{w_{R} }}} \right) e^{{ - \frac{{r^{2} }}{{w_{R}^{2} }}}} L_{p}^{\left| l \right|} \left( {\frac{{2r^{2} }}{{w_{R}^{2} }}} \right) e^{il\phi } {\mathbf{e}}_{R} + A_{L} e^{{ - \frac{{r^{2} }}{{w_{L}^{2} }}}} e^{i\vartheta } {\mathbf{e}}_{L}$$
(6)

where AR(L) and wR(L) represent the field amplitude and the beam radius of the RCP (LCP) light, respectively, ϑ denotes a phase difference between the RCP and LCP components, \({L}_{p}^{\left|l\right|}\) is the generalized Laguerre polynomials, and \({C}_{lp}^{LG}\) is the normalized constant: \({C}_{lp}^{LG}=\sqrt{\frac{2p!}{\pi \left(p+\left|l\right|\right)!}}\). In this design, we set wR = 550 μm and wL = 333 μm, respectively, to fit the LCP beam within the singularity at the center of the RCP beam. The target terahertz frequency is f = 0.5 THz, and the phase ϑ is set to be -1.2π.

Figures 5a, b display the distributions of ENF(r) and M(r), respectively, obtained from our design strategy (see SM Section S6). The spin angular momentum of the emitted terahertz wave is generated by the spatial rotation of M(r), while the vortex Fresnel zone plate pattern of M(r) leads to the generation and focusing of the OAM beam. The accuracy of our programmed heterostructure is again verified by the focused-beam excitation measurements (Fig. 5c). A complete mapping of the entire heterostructure is provided in SM Fig. S12.

Fig. 5
figure 5

Programmed terahertz emitter for the full Poincaré beam. a The distribution of local terahertz NF ENF(r) obtained from the design strategy. The trajectory for the focused-beam excitation measurement is illustrated with a radius of rs and a scanning angle of θs. b The magnetization pattern M(r) obtained from ENF(r) in a. c The symbols represent the results from the focused-beam excitation measurements as a function of the scanning angle, θs. The solid lines depict results from the wave-propagation simulations with a focused excitation laser spot and the trajectory shown in a. d The experimental distribution of polarization ellipses across the beam cross-section of the FP beam. The red-colored ellipses correspond to LCP, while the blue ones represent RCP. Right panel: The experimentally measured intensity |ENF|2 and phase profiles of the RCP and LCP components of the FP beam. e. The distribution of polarization ellipses obtained from the wave-propagation simulations. Right panel: The simulation results of the intensity and phase profiles of the RCP and LCP components

The terahertz emission is excited by the same femtosecond laser amplifier used in the last case and measured by the TDHIS system. The excitation beam radius is 4.5 mm. In the right panel of Fig. 5d, we plot the experimental intensity profiles and phases of the RCP and LCP terahertz components at a frequency of f = 0.5 THz. We observe that due to the aberration of the vortex zone plate, the vortex at the center of the RCP beam splits into two in the far field. Still, the phase of the RCP beam varies by 2π as it rotates by an angle ϕ of -180° around the two vortices, demonstrating the generation of OAM with l = −2. The LCP beam exhibits a simple Gaussian profile with a flat phase distribution, consistent with our design. The results obtained by the wave-propagation simulation are also shown in the right panel of Fig. 5e for comparison.

We calculate the Stokes parameters S0, S1, S2 and S3, allowing us to further determine the orientation and ellipticity of the terahertz fields across the beam cross-section. In Fig. 5d, we plot the experimental distribution of polarization ellipses. The interference of l = 0 and l = −2 vortex beams results in a complex polarization distribution, exhibiting variations from LCP at the beam center to RCP at the fringes, and linear polarizations with changing orientations at the boundaries. We find that the polarization states cover the entire Poincaré sphere for a beam radius of 800 μm, confirming the generation of FP beam (see SM Section S6). The corresponding simulation results are shown in Fig. 5e.

5 Discussion

In this work, we show that the flexible programming of the exchange-biased magnetic heterostructure enables the direct generation of various structured terahertz beams with complex polarization distributions. In the above demonstrations, we did not perform amplitude design on ENF(r), as lasers with Gaussian profiles were utilized to excite various programmed emitters. To exert control over local NF amplitudes, spatial light modulators can be further employed to manipulate the amplitude profiles of excitation lasers.

It is important to acknowledge that, owing to the inherent capability of generating only linearly polarized ENF locally, a crucial constraint arises: the NF terahertz amplitudes for the LCP and RCP components must be equal at all locations, leading to \({A}_{NF}^{L}(\mathbf{r})={A}_{NF}^{R}(\mathbf{r})\) at the emitter’s surface. As a consequence, both LCP and RCP terahertz fields are simultaneously generated in the far field. In situations where terahertz beams with a pure polarization state are of interest, one can strategically design the magnetization pattern so that desired polarization state is focused at the center, while surrounding it with other polarizations. By employing simple spatial filtering, this pure polarization state can be isolated and utilized. This concept was demonstrated by the LCP Gaussian beam in the last demonstration, where different spatial phase gradients were applied on the LCP and RCP light beams, allowing for their spatial separation in the far field.

Furthermore, by fabricating the heterostructures into appropriately oriented micro-structures, one can induce confinements onto the local charge currents [38,39,40]. This enables independent control over the x- and y-components of the local terahertz fields, potentially facilitating the realization of an arbitrary terahertz wave generator.

During the submission of this work, we became aware of the recent publication by Pettine et al., which demonstrates the nanoscale manipulation of local charge currents using asymmetric nanoantennas via the photothermoelectric effect [55]. As an immediate application, the authors demonstrated the generation of radially and azimuthally polarized terahertz fields. Although in this study, a 40-μm programming resolution was employed for various demonstrations, we note that the ultimate spatial resolution of our LAMP method can be significantly reduced to ~ 250 nm, as recently demonstrated in Ref. 45. Consequently, our approach offers an alternative for manipulating nanoscale charge currents with programming capability.

In conclusion, our study introduces a novel programmable spintronic emitter that enables the generation of diverse structured terahertz waves. This approach utilizes the laser-induced local field cooling of an exchange-biased magnetic heterostructure, which allows precise and micrometer-level programming of the magnetization pattern on the emitter’s surface. Our method offers highly flexible and broadband control over the polarization states across the terahertz beam cross-section, which can open up new possibilities for various applications in terahertz microscopy, quantum information and communications.

6 Methods

6.1 Sample fabrication

The trilayer heterostructures Pt/Py/IrMn3 were deposited on the double-side polished Al2O3(0001) substrates using magnetron sputtering, where Py is the permalloy Fe21Ni79. In our experiments, the Al2O3(0001) substrates were chosen because of their high thermal conductivity. We also prepared samples on the SiO2 substrates, which exhibit a lower laser-damage threshold due to relatively lower thermal conductivity. All the Al2O3 substrates were first ultrasonically cleaned in acetone, alcohol, and deionized water. Then, they were annealed at 150 °C for one hour in the sputtering chamber with a base pressure of 2 × 10–8 torr. The substrates were mounted on a sample holder equipped with a pair of permanent magnets that can apply a bias field during sample growth, achieving a field strength of approximately 250 mT. All the Pt, Fe21Ni79, and IrMn3 films were grown by sputtering at room temperature under a working Ar pressure of 3 mTorr. The IrMn3 layer was grown through co-sputtering from the Mn and Ir50Mn50 targets. The thickness of all the layers was determined by the sputtering time, and their growth rates were calibrated by X-ray reflectivity measurement. The growth rate is 0.22 Å/s for Pt layers, 0.26 Å/s for the Fe21Ni79 layers, and 0.44 Å/s for the IrMn3 layers. Finally, an 8-nm Al2O3 layer was deposited to prevent oxidation.

6.2 LAMP method

The LAMP method was performed using a custom-made magnetic writing system. The schematic is shown in SM Fig. S1. The writing laser used was a power-stabilized fiber oscillator (FIBRE SP, Nanjing Keyun Optoelectronics Ltd.) with a pulse duration of 110 fs, a repetition rate of 36 MHz, a central wavelength of 1030 nm and a maximum power of 3.3 W. The power of the writing laser beam was adjusted by a combination of a half waveplate and a polarizer. The writing laser beam was focused using a 20-cm lens onto the sample surface, resulting in a beam diameter of approximately 60 μm. The trilayer heterostructure was mounted on a 2D motion stage, allowing precise motion along the x and y directions with a precision of < 1 μm and a full range of 25 mm. The magnetic patterns were written by the raster-scanning of the sample position at a linear speed of vw = 500 μm s−1. For setting the angle of local magnetization, an orientated electromagnet was employed, providing a writing magnetic field (Hw) of 1000 oe in the xy plane.

In this study, the writing power was determined through characterization of the programming outcomes using MOKE microscopy. As shown in Fig. 2 e, f, for each heterostructure sample with different growth conditions, we first conducted programming tests on the sample by writing short lines under different writing powers. Then, the programmed regions were examined using a MOKE microscope, and the width of the programmed lines as the function of writing power was determined (Fig. 2f). This approach enables us to determine the threshold writing power (Pth) and select an appropriate writing power to achieve a specific writing resolution. While we observed slightly different parameters for samples grown under different conditions, parameters remained robust for samples grown under the same conditions.

6.3 Design strategy

The local NF terahertz waves at the emitter’s surface, ENF(r), can be calculated following Eqs. (13). These local NF terahertz waves can be expressed in the circular polarization basis: \({\mathbf{E}}_{NF}\left(\mathbf{r}\right)={\sigma }_{NF}^{L}\left(\mathbf{r}\right){\mathbf{e}}_{L}+{\sigma }_{NF}^{R}\left(\mathbf{r}\right){\mathbf{e}}_{R}\). The complex amplitude \({\sigma }_{NF}^{L(R)}\left(\mathbf{r}\right)\) can be represented by \({\sigma }_{NF}^{L(R)}\left(\mathbf{r}\right)={A}_{NF}^{L(R)}\left(\mathbf{r}\right){e}^{i{\varphi }_{L(R)}\left(\mathbf{r}\right)}\), where \({A}_{NF}^{L(R)}\) and \({\varphi }_{L(R)}\) denote the amplitude and phase of the NF LCP (RCP) component, respectively.

Because only linearly polarized terahertz waves can be generated locally from the programmed magnetic domains, we have an important constrain: \({A}_{NF}^{L}\left(\mathbf{r}\right)={A}_{NF}^{R}\left(\mathbf{r}\right)={A}_{NF}(\mathbf{r})\). As a result, the NF terahertz waves can be expressed as \({\mathbf{E}}_{NF}\left(\mathbf{r}\right)={A}_{NF}\left(\mathbf{r}\right)\left[{e}^{i{\varphi }_{L}\left(\mathbf{r}\right)}{\mathbf{e}}_{L}+{e}^{i{\varphi }_{R}\left(\mathbf{r}\right)}{\mathbf{e}}_{R}\right]\).

In order to manipulate the terahertz NF, it is essential to control both the field amplitude, ANF(r), and the phase terms φL(R). The amplitude control can be achieved by manipulating the local intensity of excitation lasers, which can be realized by spatial light modulators. In this work, as lasers with Gaussian profiles were utilized to excite various programmed emitters, we did not perform the amplitude design on ENF(r).

On the other hand, the phases of the LCP and RCP NF components φL(R) can be controlled by the polarization orientation of local terahertz NF. To facilitate the design process, we further define

$$\left\{ {\begin{array}{*{20}c} {\theta \left( {\mathbf{r}} \right) = \left[ {\varphi_{R} \left( {\mathbf{r}} \right) - \varphi_{L} \left( {\mathbf{r}} \right)} \right]/2} \\ {\psi \left( {\mathbf{r}} \right) = \left[ {\varphi_{R} \left( {\mathbf{r}} \right) + \varphi_{L} \left( {\mathbf{r}} \right)} \right]/2} \\ \end{array} } \right.$$
(7)

Here, θ(r) represents the polarization orientation of ENF(r) constrained in the range of [0, π), and ψ(r) further defines the polarity of the terahertz NF. The polarization direction of ENF(r) is then determined by \({\Theta }_{NF}(\mathbf{r})=\left\{\begin{array}{c} \theta \left(\mathbf{r}\right),\text{ cos}\left[\psi (\mathbf{r})\right]\ge 0 \\ \theta \left(\mathbf{r}\right)+\pi ,\text{ cos}\left[\psi (\mathbf{r})\right]<0\end{array}\right.\). Here, the continuous distribution of \(\psi (\mathbf{r})\) is discretized to the regions where cos[ψ(r)] ≥ 0 and cos[ψ(r)] < 0. When cos[ψ(r)] < 0, it indicates a spatial reversal of local field polarization, representing a π phase shift of the local terahertz wave (see Fig. 1d).

In various demonstration cases, the pattern of θ(r) and ψ(r) can be numerically derived from the target fields [Eqs. (46)] using the design strategy, thereby allowing for the calculation of the polarization distribution of ENF(r). According to Ohm’s law [36], the local charge current density is directly proportional to the local terahertz NF, given by \({\mathbf{j}}_{c}(\mathbf{r})\propto {\mathbf{E}}_{NF}\left(\mathbf{r}\right)\). Finally, the magnetization pattern is determined by the ISHE [36]: \(\frac{\mathbf{M}(\mathbf{r})}{\left|\mathbf{M}(\mathbf{r})\right|}=\frac{{\mathbf{j}}_{c}(\mathbf{r})\times {\mathbf{j}}_{s}}{\left|{\mathbf{j}}_{c}(\mathbf{r})\times {\mathbf{j}}_{s}\right|}\).

6.4 Wave-propagation simulations

The simulation of far-field terahertz waves was carried out through wave-propagation simulations using a Python program. In this simulation, broadband terahertz pulses with a spectrum matching the experimental signal were assigned to emit from the surface of a programmed spintronic emitter. The polarization orientation and polarity of the locally emitted wave, ENF(r), were set according to the magnetization pattern M(r). The amplitude of ENF(r) was determined based on the local intensity of the excitation laser. The far-field spatio-spectral profiles of the Ex and Ey components were then obtained by considering the propagation of each frequency component of the terahertz waves to the far-field plane.

To simulate the experimental results obtained from the focused-beam excitation measurements, the simulations employed a small excitation laser spot traversing across the sample surface following the designated trajectories. The simulation results of the Ex and Ey fields were plotted in comparison with the experimental results.

6.5 Focused-beam excitation setup

The programmed magnetization pattern was verified using a focused-beam excitation setup. The schematic of the focused-beam excitation setup is shown in SM Fig. S4. This setup utilized the same fiber laser employed during the LAMP process. The laser beam was focused onto the programmed heterostructure achieving a beam radius of 250 μm, while the laser power density was limited to less than 9.2 × 107 W cm−2. The emitted terahertz waves were collected and focused by a pair of off-axis parabolic mirrors. The Ex and Ey components were selected by a terahertz polarizer, and respectively detected using the electro-optic sampling (EOS) method. The EOS crystal utilized was a 1-mm thick GaP crystal. The heterostructure was moved by the 2D motion stage following the designed trajectory, and the terahertz fields emitted from the illuminated areas were recorded.

6.6 Angle-resolved terahertz detection setup

The large angle distribution of the terahertz waves with spatially separated circular polarizations was measured using an angle-resolved terahertz detection setup. The setup is illustrated in the SM Fig. S14. The excitation pulses were obtained from a Yb:KGW laser amplifier (PHAROS SP, Light-Conversion) with a repetition rate of 10 kHz, a center wavelength of 1030 nm. The spectrum of laser pulses was first broadened using an all-solid-state pulse compressor based on periodic layered Kerr medium (PLKM) [56, 57]. The pulse compression from 170 to 25 fs was achieved through dispersion correction using a set of chirped mirrors. The excitation laser beam was focused on the sample surface, resulting in a beam radius of approximately 1.8 mm. The programmed sample was positioned on a rotation stage that allowed rotation about the y-axis, exposing terahertz radiations emitted at different angles (φe) to a polarization-resolved EOS detection setup. The excitation laser beam remained normal incident onto the sample surface. A terahertz polarizer was employed to select the Ex and Ey components.

6.7 TDHIS setup

The schematic of the setup is shown in SM Fig. S15. This system represents an extension of terahertz time domain spectroscopy, wherein both the terahertz and probe beams are expanded to realize spatial imaging. In this study, we employs a Ti:Sapphire regenerative amplifier (Spitfire Ace, Spectra-Physics) to generate an ultrashort pulse of 50 fs with a central wavelength of 780 nm, a 1 kHz repetition rate, and a 9 mm spot diameter. The laser beam is divided into two beams: the generation beam and the detection beam. The generation beam excites the sample to generate the terahertz waves, detected by a 2-mm thick ZnTe crystal. Between the sample and the detection crystal, a 500-μm thick silicon wafer is placed to block the remaining generation beam. Using a half waveplate (HWP) and a polarizer (P), we control the polarization state of the probe beam. The probe beam, upon reflected from the front surface of the ZnTe crystal, is modulated by the terahertz beam via electro-optic effect in the crystal. Consequently, the polarization of the probe beam is altered. This modulated probe beam is captured by the detection unit, which consists of a quarter waveplate (QWP), a Wollaston prism (WP), two lenses, and a charge-coupled device (CCD). We capture two mutually orthogonal components of the probe beams, the difference between which is proportional to the applied terahertz-field amplitude on the crystal. By altering the time delay between the terahertz and probe pulses, the spatial distributions of terahertz field at different delay times can be obtained. At each pixel of the CCD image, a time-domain signal of terahertz wave can be extracted. Following Fourier transform, the phase and amplitude spectra of the terahertz wave at this pixel can be obtained. Thus, the spatial, phase, and amplitude information of the far-field terahertz beam can be simultaneously measured [58].