1 Introduction

Nitrogen (N) and phosphorus (P) are essential elements for structure and function in living organisms. However, with the rapid development of large-scale agriculture and industry in the past few centuries, large quantities of N and P have been arbitrarily discharged into the natural environment, resulting in water eutrophication (Conley et al. 2009), greenhouse gas emissions (Gu et al. 2021), soil acidification and salinization (Xia et al. 2020). The recovery of N and P from wastewater can not only improve water quality but also save valuable N and P resources, and the environmental and social benefits are apparent (Shakoor et al. 2021). Adsorption is regarded as a highly efficient technique for N and P recovery (Pan et al. 2020). Still, adsorbent regeneration, desorption regeneration, and the high cost and difficulty of solid–liquid separation restrict the broad application of adsorbents. Biochar, a carbon-rich material generated by carbonisation of biomass materials under high temperature and anaerobic or oxygen-limited conditions, has advantages including large specific surface area, well-developed pore structure, high stability, and rich mineral composition (Wu et al. 2021; Zhang et al. 2020). Adsorption is the main characteristic of biochar, which is widely applied for the removal of organic, inorganic pollutants and heavy metals from wastewater (Ahmed et al. 2016) or soil (Ahmad et al. 2014), and various atmospheric pollutants (Chen et al. 2017).

Most N and P pollutants are in the form of NH4+-N and PO43− in wastewater (Dai et al. 2020). Nevertheless, conventional biochar has poor adsorption and removal capacity for NH4+-N and PO43− (Jiang et al. 2018). Hu et al. (2020) used orange peel, pineapple peel and dragon fruit peel biochar, and the maximum adsorption capacity of NH4+-N was only 4.71 mg/g, 5.60 mg/g and 2.65 mg/g, respectively. Xu et al. (2019a, b) reported that straw, wood chip, reed and eggshell biochar had a maximum NH4+-N adsorption of only 4.2 mg/g, 3.3 mg/g, 3.2 mg/g and 2.2 mg/g, respectively. Moreover, most biochar surfaces are negatively charged and adsorb very little PO43−. In some studies, desorption of PO43− from sludge biochar (Peng et al. 2020) and wood waste biochar (Xu et al. 2019a, b) was observed rather than adsorption. Cheng et al. (2021) reported that the simultaneous NH4+-N and PO43− adsorption capacity was only 1.91 mg/g and 2.32 mg/g for Eupatorium adenophorum biochar. Meanwhile, Zhang et al. (2020) reported average maximum adsorption amounts of 11.19 mg/g and 28.90 mg/g for NH4+-N and PO43− by native biochar, respectively. Therefore, improving the ability to simultaneously adsorb NH4+-N and PO43− and applying saturated biochar as a fertiliser is an active research field.

To further improve the adsorption capacity of biochar for NH4+-N and PO43−, modified biochar can be prepared by improving its surface properties and structure (Wu et al. 2020). Wang et al. (2015) used oak sawdust LaCl3-modified biochar, which increased the adsorption capacity of NH4+-N, NO3-N and PO43− by 1.9, 11.2 and 4.5 times, respectively. Peng et al. (2019) used hemp stem TiO2 to modify biochar, and the removal rate of NH4+-N was as high as 99.7%. However, research on the simultaneous adsorption of NH4+-N and PO43− is limited (Xiao et al. 2020). Meanwhile, ion exchange resin, alumina, zeolites, and other materials have been tested for the simultaneous adsorption of NH4+-N and PO43−, but high cost and limited simultaneous adsorption capacity make them impractical (Sun et al. 2020). Therefore, in recent years, chemical modification methods, including introducing oxides of Fe, Al, Ca, Mg and La, have been attempted to enhance the specific adsorption function of biochar, and the as-prepared biochar exhibited excellent adsorption capacity toward NH4+-N and PO43− (Shakoor et al. 2021).

Among these materials, MgB achieved superior simultaneous removal of NH4+-N and PO43− compared with other metals. Xiao et al. (2020) studied the Mg-modified rice straw biochar, and the maximum adsorption capacity of NH4+-N and PO43− was 15.4 mg/g and 21.8 mg/g, respectively. Jiang et al. (2019) tested six Mg-modified straw biochar materials for simultaneous adsorption of NH4+-N and PO43−, and the maximum adsorption amounts were 9.07–24.04 mg/g and 6.77–31.15 mg/g, respectively. In summary, MgB is an environmentally friendly, low-cost adsorbent for NH4+-N and PO43−, and its self-sufficient alkaline behaviour provides a suitable pH range for the formation of struvite (MgNH4PO4·6H2O) (Jiang et al. 2019; Li et al. 2017; Xu et al. 2018). However, most researchers have focused on single magnesium content or pyrolysis temperature (Li et al. 2017; Xia et al. 2016; Zhu et al. 2020, 2021), as well as magnesium salt coupled with other solutions (Li et al. 2016a, b; Xiao et al. 2020), feedstock selection (Jiang et al. 2019; Thant Zin and Kim 2021), and the simultaneous adsorption performance and mechanism of NH4+-N and/or PO43−. Relatively, the knowledge gaps still exist in the synergistic impact of the multi-magnesium contents and pyrolysis temperatures on the physicochemical properties and adsorption capacity of MgB. In addition, to the best of our knowledge, although MgB-A is considered as a potential slow-release fertilizer, its long-term leaching behavior, mechanism and seeding growth for practical application in soil have not been studied.

The most direct way to realize carbon sink and resource utilization is the carbonization of straw (Meng et al. 2019). Hence, we selected corn stalks (CW) as the raw material and used MgCl2·6H2O as a modifier. The main research objectives were: (1) to explore the effects of multi-pyrolysis temperatures and Mg2+ contents on the ability of MgB to adsorb NH4+-N and PO43−, (2) to use adsorption isotherms, kinetic models and material characterisation methods to analyse the adsorption mechanism of MgB, (3) to reveal the long-term leaching behaviour and mechanism of MgB-A for NH4+-N and PO43−, and assess its effect on the growth of crop seedlings. These findings provide a basis for further exploring the mechanism of simultaneous NH4+-N and PO43− recovery and the production of slow-release struvite biochar-based fertilizers.

2 Materials and methods

2.1 Materials

First, CW material was washed, dried at 105 °C for 24 h, ground, and passed through a 60-mesh sieve. Reagents were purchased from Sinopharm (analytical grade). Chemical fertiliser (CF) was purchased from Jiangsu Huachang Chemical Co.

2.2 Preparation of Mg-modified biochar

First, MgCl2·6H2O solutions at different concentrations (Mg2+ concentration 0–3.6 g/L) were prepared, and 10 g of CW was mixed with the above solutions and stirred magnetically at room temperature for 12 h. Samples were dried in an oven at 105 °C, covered with tinfoil, placed in a covered crucible in a muffle furnace (Thermo Scientific F62700), and heated from 350 to 650 °C at a rate of 10 °C/min to carbonise for two hours. After pyrolysis and upon reaching room temperature, samples were crushed, passed through an 80-mesh sieve and sealed in a container prior to further characterization and adsorption experiments.

2.3 Adsorption experiment

Modified biochar samples (0.1 g) were placed in 100 mL of a mixture of NH4+-N (NH4Cl) and PO43− (K2HPO4) at a concentration of 100 mg/L, and shaken at 120 rpm for 24 h at a constant temperature of 25 °C. The resulting supernatant was filtered through a 0.45 μm syringe filter and subjected to SEPA measurement. The residual NH4+-N and PO43− contents were analysed by ammonium molybdate-ascorbic acid and Berthelot spectrophotometry (Shimadzu UV-1800) at wavelengths of 700 nm and 550 nm, respectively (SEPA 2013). The NH4+-N and PO43− adsorption capacity was calculated as shown in Text S1.

Adsorption isotherms were acquired at different concentrations of K2HPO4 and NH4Cl (5–1000 mg/L). Experimental data were analysed using isotherm models (Langmuir, Freundlich, Langmuir–Freundlich and Separation factor). Adsorption isotherm equations are shown in Text S2. Kinetic models (pseudo-first-order, pseudo-second-order and intraparticle diffusion) were studied at different sampling times (5–1440 min). And adsorption kinetics equations are shown in Text S3.

Factors affecting NH4+-N and PO43− adsorption were investigated, including pH (4.0–10.0), coexisting ions (0.05 M/L, anions NO3, Cl, CO3, cations Na+, K+, Ca2+) at pH 7.0, ion forms and the type of Mg2+ (Mg, Mg+B and MgB). Other experimental conditions were similar as described above.

2.4 Leaching and pot analyses of adsorption by Mg-modified biochar

Soil samples were taken from the 0–20 cm surface layer from Jiangnan University. Soil properties, MgB-A, and CF composition are shown in Table S1. The amount of MgB-A added was 2% of the dry weight of the soil. PO43− source was supplemented to ensure that the initial NH4+-N and PO43− levels of MgB-A (NH4+-N 38.42 mg/g, PO43− 74.91 mg/g) and CF (NH4+-N 104.16 mg/g, PO43− 54.28 mg/g) were consistent. Leaching was performed according to the US EPA method (US EPA 2014). A schematic diagram of the soil leaching column and leaching water volume, sampling points are shown in Fig. S1 and Text S4.

Zea mays L. and Lolium perenne L. were selected as seed germination and seedling growth pot experiment materials, and the treatments included CK (soil only), MgB and MgB-A (2% dry soil weight), and CF (TN and TP levels consistent with MgB-A). The experimental soil was the same as above. All plants were grown at room temperature and given 120 mL of water per day (per pot). One week before the experiment, the germination status of each group was checked every day. By the 20th day, plants were selected to measure physical and chemical properties. The chlorophyll content was determined by the acetone-spectrophotometric method (Ritchie 2006).

2.5 Characterisation and statistical analysis

A Vario micro cube elemental analyser (Elementar, Germany), a Belsorp-Max specific surface area analyser (MircotractBEL, Japan), a IRTracer-100 Fourier-transform infrared (FTIR) spectrometer (Shimadzu, Japan), a Bruker D8 advance X-ray diffraction (XRD) instrument (Bruker), a Nova nano 450 scanning electron microscopy (SEM) energy dispersive spectroscopy (EDS) instrument (Thermo Fisher, USA) and an ESCALAB 250Xi X-ray photoelectron spectroscopy (XPS) instrument (Thermo Fisher Scientific) were used for biochar characterisation.

The cation exchange capacity (CEC) was determined by the ammonium acetate displacement method (Pan et al. 2021). Determination of magnesium components was performed as described previously (Klammer et al. 2020), and Mg2+ content was determined using an Optima 8300 inductively-coupled plasma emission spectrometer (ICP) instrument (PE company, USA). The pH and conductivity (EC) were measured by pH meter (DELTA-320) and conductivity meter (S230 SevenCompact).

Both the amount of NH4+-N and PO43− adsorbed are expressed as mean ± standard error. One-way or Two-way analysis of variance (ANOVA) was used to compare differences within or between groups (at the 5% level) using SPSS software (SPSS. 26.0, IBM, USA).

3 Results and discussion

3.1 Physical and chemical properties of MgB

The effects of pyrolysis temperature and Mg2+ concentration on MgB element composition, yield and pH are shown in Table S2. As Mg2+ increased, the C content gradually decreased at the same pyrolysis temperature. The results indicated that there may be a mixture of C and Mg2+ in MgB (Li et al. 2016a, b). When the pyrolysis temperature was 350 °C, the Mg2+ content was 0~3.6g/L , the C content reduced from 59.71 to 55.21%, and the same was true for other temperatures. The H/C ratio is inversely proportional to the degree of carbonisation and aromaticity (Fang et al. 2014). In the present study, with increasing amounts of Mg2+, H/C steadily increased. When the pyrolysis temperature was 450 °C and Mg2+ was 0–3.6 g/L, H/C increased from 0.54 to 0.68. These results are consistent with those of Zhu et al. (2020) and Jiang et al. (2019). As the pyrolysis temperature increased, the C structure in the biomass was destroyed or volatilised, resulting in a decrease in yield (Zhu et al. 2020). When the pyrolysis temperature increases from 350 to 650 °C, the yield of CK treatment drops from 64.75 to 31.27%. With increasing amounts of Mg2+, the pH and yield of biochar increased, and this was negatively correlated with C content.

3.2 Effect of pyrolysis temperatures and Mg2+ addition on NH4 +-N and PO4 3− adsorption

The influence of pyrolysis temperatures and Mg2+ contents on the adsorption of NH4+-N by MgB is shown in Fig. 1a. The adsorption capacity of CK was only 3.68 mg/g, which was significantly lower than other treatments (p < 0.001). Keiluweit et al. (2010) and Li et al. (2018) reported that as the pyrolysis temperature increased, the polar functional groups and CEC decreased, which caused the Qe of NH4+-N reduction. The same results were shown in our study that with the increase of carbonization temperature, the adsorption capacity of NH4+-N increased first and then decreased. However, with the rise of Mg2+ content, NH4+-N adsorption increased rapidly and then stabilized. The results of Two-Way ANOVA showed that the pyrolysis temperature (F = 220.22, p < 0.001), the amount of Mg2+ (F = 950.22, p < 0.001) and the interaction between them (F = 14.83, p < 0.001) had a significant effect on adsorbed NH4+-N. The comprehensive comparison showed that the pyrolysis temperature of 450 °C (p < 0.001) and Mg2+ content of 2.4 g/L (p < 0.001), the maximum adsorption capacity of MgB for NH4+-N was 36.92 mg/g.

Fig. 1
figure 1

Effect of pyrolysis temperatures and Mg2+ contents on adsorption of NH4+-N (a) and PO43− (b), pH (c) and coexisting ions (d)

The effect of MgB on PO43− adsorption is shown in Fig. 1b. Consistent with results reported in previous studies (Dai et al. 2020; Zhang et al. 2020), hardly any PO43− (0.06 mg/g) was adsorbed in the CK treatment. With the increasing of carbonization temperatures, the adsorption capacity of PO43− increased rapidly until the temperature reached 450 °C, and the adsorption capacity of PO43− no longer increased (56.45 mg/g, p < 0.001). With increasing Mg2+ content, the adsorption capacity for PO43− increased continuously. However, when Mg2+ reached more than 2.4 g/L (Qe = 64.96 mg/g), any further increase in Mg2+ content did not increase the adsorption capacity for PO43− (p > 0.05). These results are consistent with those of Li et al. (2016a, b) and Jiang et al. (2019). The results of Two-Way ANOVA showed that pyrolysis temperature (F = 325.38, p < 0.001), Mg2+ addition (F = 8093.01, p < 0.001) and the interaction between them (F = 65.18, p < 0.01) had a significant effect on the adsorption of PO43−.

In detail, when the pyrolysis temperature was 450 °C and the amount of Mg2+ added was 2.4 g/L, the adsorption effect of MgB on NH4+-N and PO43− was greatest. Therefore, these conditions were chosen for subsequent experiments.

3.2.1 Microstructure characterisation of MgB

As shown in Table 1, the specific surface area of CK was 12.29 m2/g, and with increasing Mg2+, the specific surface area of MgB increased from 10.63 to 18.72 m2/g, total pores increased from 0.0097 to 0.0223 cm3/g, and the average pore diameter increased from 3.15 to 6.88 nm. These results are consistent with those of Zhu et al. (2020). The pyrolysis and dehydration process of MgCl2·6H2O is beneficial for promoting the cleavage of volatile glycosidic bonds (Al-Wabel et al. 2013), and the resulting MgO inhibits the hot chain extension reaction of free radicals (Hwang et al. 2015). Therefore, the addition of Mg2+ could hinder the formation of tar and other substances from promoting the formation of pore structures (Zhu et al. 2018). However, when the Mg2+ content was 0.6–2.4 g/L, the specific surface area and total pores of MgB gradually increased, then slowly decreased, consistent with the change in CEC. At the same time, the average pore diameter continually decreased. These results indicated that adding a large amount of Mg2+ may cause pore clogging (Liu et al. 2015). In summary, adding Mg2+ at 2.4 g/L resulted in a larger specific surface area (19.16 m2/g) and higher porosity (0.0318 cm3/g).

Table 1 Effect of Mg2+ contents on the physical and chemical properties of MgB

Additionally, as the pyrolysis temperature increased, the content of total Mg2+ and acid-soluble Mg2+ increased (Table 2). The content of water-soluble Mg2+ at 350–450 °C continuously decreased, and the content of acid-soluble Mg2+ reached its maximum at 450 °C, then decreased as the temperature was further increased. The results showed that at 450 °C, Mg2+ formed an organomagnesium complex with oxygen (O) atoms that was unstable at high temperatures and may decompose to produce active components and release small molecular gases. During the pyrolysis process, Mg oxide will repeatedly form and destroy the C–O–Mg bond, causing Mg2+ to migrate from the inside of biochar to the surface (Zhu et al. 2021), increasing the content of biochar active components and enhancing the potential for volatile formation. Furthermore, the unstable Mg2+ was continuously converted to MgO at high temperatures and remained stably on the surface of the biochar. Therefore, a higher temperature and Mg2+ content were not conducive to developing a specific surface area and pore structure (Zhu et al. 2020).

Table 2 Effect of pyrolysis temperatures on magnesium compositions of MgB

3.2.2 Characterisation of biochar before and after modification

The microstructure of biochar before and after modification is shown in Fig. 2A and B. The surface structure of CK is relatively smooth. The EDS spectrum of CK revealed a large amount of C (84.60%) and O (15.30%) on the surface and a small amount of N and silicon (Si). However, the surface of MgB is relatively rough, with a large number of sharp protrusions and microcrystalline structures. Also, the C content (56.86%) decreased significantly, while the O (29.94%) and Mg (12.87%) contents increased greatly on the surface of MgB. This result is consistent with elemental analysis. The results showed that Mg2+ was successfully loaded on the surface of biochar, and oxygen-containing compounds of biochar increased greatly. In addition, in the FTIR spectrum (Fig. S2a), the most prominent peak of CK and MgB at 3424 cm−1 was attributed to the stretching vibration of hydroxyl (–OH) and Mg=OH (Wang et al. 2021), and the peak at 1608 cm−1 was assigned to C=O (Luo et al. 2021). The peak of MgB at 474 cm−1 was attributed to Mg–O (Li et al. 2017; Zhu et al. 2020), consistent with the elemental analysis results and SEM–EDS spectroscopy. In addition, in the XRD image (Fig. S2b), MgB had five 2θ diffraction peaks at 29.3°, 38.4°, 44.4°, 59.2° and 82.0°, indicating the formation of MgO (JCPDS:30-0794) during pyrolysis, while four diffraction peaks at 15.4°, 31.5°, 32.4° and 40.6° confirmed the existence of MgOHCl (JCPDS:03-0100) (Jiang et al. 2019).

Fig. 2
figure 2

SEM–EDS characterization of B (A), MgB (B) and MgB-A (C)

3.2.3 Characterisation of MgB after adsorption of NH4 +-N and PO4 3−

As shown in Fig. 2C, the sharp MgO flakes on the surface of MgB-A disappeared and were replaced by new solids. EDS spectral analysis further proved the presence of N and P elements in the solid particles in MgB-A. Furthermore, in the FTIR spectrum (Fig. S2a), strong peaks at 571 cm−1 and 1004 cm−1 were attributed to PO43− group vibration, and the peak at 1444 cm−1 belonged to the NH4+ vibration (Li et al. 2016a, b, 2017; Zhu et al. 2020). To further analyse the composition of the surface material of MgB-A, XRD spectroscopy (Fig. S2b) was performed. The results revealed a series of strong 2θ signals at 15.0°, 15.8°, 20.9°, 21.5°, 30.6°, 31.9°, 33.3° and 46.3°, corresponding to MgNH4PO4·6H2O (JCPDS:15-0762). In addition, characteristic diffraction peaks of MgHPO4 (JCPDS:19-0761) were also observed at 2θ of 22.1°, 27.1°, 29.5°, 34.1° and 43.8°.

3.3 MgB adsorption performance

3.3.1 Adsorption kinetics

As shown in Fig. 3a, the amount of NH4+-N adsorbed by MgB and the associated mechanism displayed a distinct trend. In the initial stage (0–5 min), the adsorption capacity of NH4+-N increased rapidly, accounting for 61.43% of the saturated adsorption capacity. At 5–90 min, the adsorption capacity was followed by a slow increase, reaching 95.40%. However, after 90–240 min, there was no significant change.

Fig. 3
figure 3

Adsorption kinetics and isotherms of MgB. NH4+-N (a, c, e), PO43− (b, d, f)

In addition, during the initial stage (0–5 min), adsorption of PO43− by MgB increased rapidly, reaching 76.71% of the adsorption capacity (Fig. 3b). We conclude that the initial rapid adsorption of PO43− may be due to electrostatic attraction between positively charged MgO and negatively charged PO43− (Li et al. 2016a, b). At 5–60 min, the adsorption rate gradually slowed down to 96.56%, and thereafter (60–240 min), the adsorption rate of PO43− gradually stabilised. This phenomenon may be that with the gradual decrease of PO43− concentration, the repulsive forces are easily generated between PO43− adsorbed on the surface of MgB, thus the adsorption rate continues to slow down (Lalley et al. 2016). Although the modified materials or sources of magnesium were different, the adsorption behaviour of PO43− was similar to LaCl3 oak sawdust-modified biochar (Wang et al. 2015), magnesium-modified straw biochar (Xiao et al. 2020), magnesium-modified diatomaceous earth (Xia et al. 2016) and magnesium modified Sugarcane leaf biochar (Li et al. 2017). However, the adsorption rate peaked earlier than magnesium-modified bamboo biochar (80–90 h) (Jiang et al. 2018) and magnesium-modified corn straw biochar (> 24 h) (Zhu et al. 2020).

As shown in Table S3, the pseudo-second-order kinetic model (R2 = 0.9973, 0.9983) fitted the data slightly better than the pseudo-first-order kinetic model. The results showed that the adsorption of NH4+-N and PO43− by MgB was mainly controlled by surface chemistry (Lalley et al. 2016). The fitting of the kinetic model was consistent with most magnesium-modified materials (Huan-Ping et al. 2019; Li et al. 2017; Xia et al. 2016; Xiao et al. 2020).

As shown in Fig. 3d and e, the intraparticle diffusion model results showed that the NH4+-N and PO43− adsorption process undergo external mass transfer stage (I), intraparticle diffusion stage (II) and adsorption equilibrium stage (III). The line did not pass through the origin (C ≠ 0), indicating that intraparticle diffusion was not likely to be the rate-limiting step. And film diffusion (external mass transfer) or intraparticle diffusion (internal surface diffusion) may both act as rate-determining steps for NH4+-N and PO43− adsorption (Huan-Ping et al. 2019). As shown in Table S3, the values of kp (93.58%, 94.97%) and C (3.3120, 4.2957) revealed that the adsorption rate was highest during the first stage. This phenomenon indicated that the adsorption of NH4+-N and PO43− in this stage is mainly affected by the boundary effect (Xiong et al. 2017). As the adsorption time continues, the active sites on the surface of MgB are entirely occupied, and NH4+-N and PO43− then enter the inner pores of MgB and are adsorbed by the internal active sites. The adsorption rate decelerated in the second phase, corresponding to the adsorption rate-limiting step (Huan-Ping et al. 2019). The adsorption equilibrium and the available adsorption active sites for NH4+-N and PO43− were depleted (Zhu et al. 2020). The third stage was the adsorption saturation stage, which indicates that the adsorption equilibrium and the available adsorption active sites for NH4+-N and PO43− are depleted (Xiao et al. 2020; Zhu et al. 2020).

3.3.2 Adsorption isotherm

As shown in Fig. 3e and f, at low concentrations (5–300 mg/L), the adsorption of NH4+-N and PO43− by MgB increased rapidly, as the concentration increased (400–1000 mg/L), the adsorption capacity increased slowly and tended to be stable. As shown by the data fitting in Table S3, the maximum adsorption capacities of NH4+-N and PO43− were 37.72 mg/g and 73.29 mg/g, respectively. Compared with the Freundlich model (R2 = 0.8552, 0.8317), the other two models fitted the adsorption data well (R2 = 0.9797, 0.9988). The Langmuir–Freundlich model achieved the highest degree of fitting for the adsorption of NH4+-N and PO43− (R2 = 0.9974, 0.9988). These results indicate that the adsorption of MgB may be affected by various mechanisms, which is consistent with the kinetic model fitting results.

The RL is negatively correlated with the initial concentrations of the adsorption solution (Li et al. 2019). As the initial concentration of NH4+-N and PO43− increased from 5 to 1000 mg/L, the RL decreased from 0.8569 to 0.0291 and 0.8866 to 0.0376, respectively, satisfying the condition of 0 < RL < 1, further showing that MgB had favourable adsorption for both NH4+-N and PO43−.

3.3.3 Effect of pH and coexisting ions on adsorption

As shown in Fig. 1c, the NH4+-N adsorption capacity was 22.93–41.47 mg/g when the pH was 4.0–8.0. At lower pH, the H+ and NH4+ were prone to competitive adsorption (Kizito et al. 2015).

$${\text{MgB{-}Mg}}^{{{2} + }} + {\text{NH}}_{{4}}^{ + } \leftrightarrow {\text{Mg}}^{{{2} + }} + {\text{MgB{-}NH}}_{{4}}^{ + }$$
(1)

At pH > 8.0, the NH4+-N adsorption capacity decreased sharply to 2.63 mg/g. The reaction relationship of NH4+-N in solution is as follows (Weatherley and Miladinovic 2004).

$${\text{NH}}_{{3}} + {\text{H}}_{{2}} {\text{O}} \leftrightarrow {\text{NH}}_{{3}} \cdot {\text{H}}_{{2}} {\text{O}} \leftrightarrow {\text{NH}}_{{4}}^{ + } + {\text{OH}}^{ - }$$
(2)

At this point, it was not favourable for MgB to undergo ion exchange adsorption, and only physical adsorption on the surface was possible.

When the initial pH increased from 4.0 to 10.0, the adsorption capacity of PO43−decreased from 82.68 to 11.68 mg/g. At pH 4.0–10.0, H2PO43− and HPO42− were the main forms of PO43−, and the free energy of adsorption of H2PO43− was lower than that of HPO42−. Therefore, H2PO43− was more easily adsorbed than HPO42− (Li et al. 2016a, b). In this study, the pHZPC of MgB was close to 12 (Li et al. 2017), and the pH of the solution was lower than pHZPC on the surface of MgB, indicating that MgB has favourable adsorption of PO43−.

It can also be seen from Fig. 1c that the initial pH was 4.0–8.0, and the final pH was maintained at 8.13–9.61. Alkalinity in solution was correlated with self-sufficient behaviour of MgB. As shown in the chemical formula.

$${\text{MgO}} + {\text{H}}_{2} {\text{O}} \to {\text{MgOH}}^{ + } + {\text{OH}}^{ - }$$
(3)

Stratful et al. (2001) reported that struvite crystallisation started at pH 7.5, performed best at pH 8.5, and decreased at pH > 10.0. In the present study, the initial pH was 4.0–8.0, and the final pH was 8.15–9.61, which provides good pH conditions for the formation of struvite. Based on the NH4+-N and PO43− adsorption efficiency and experimental operability, we selected an initial pH of 7.0 to investigate coexisting ions adsorption.

The influence of coexisting ions on the adsorption of NH4+-N and PO43− is shown in Fig. 1d. Compared with CK, except for CO3, other anions (NO3, Cl) had no significant effect on the adsorption of NH4+-N and PO43− (p > 0.05). This may be due to the precipitation of MgCO3, which inhibited the formation of struvite crystallisation (Huan-Ping et al. 2019). Compared with CK, the presence of Na+, K+ and Ca2+ all significantly reduced the adsorption of NH4+-N (p < 0.05), by 12.70%, 14.55% and 52.48%, respectively. This phenomenon illustrates the important role of ion exchange in the adsorption of NH4+-N (Xiao et al. 2020). When Ca2+ was present, the adsorption capacity of PO43− was increased significantly from 70.47 to 76.73 mg/g (p < 0.01). This result shows that when Ca2+ was also present, it was easy for Ca3(PO4)2 to precipitate (Huan-Ping et al. 2019), and when K+ was present, struvite potassium may be formed, which slightly promoted PO43− adsorption (Huang et al. 2014; Xia et al. 2016).

3.3.4 Effect of different Mg2+ forms on adsorption

The effect of Mg, Mg + B and MgB addition on the adsorption of NH4+-N and PO43− is shown in Fig. 4. The adsorption capacity of NH4+-N and PO43− for the three different magnesium components was 24.67, 29.65 and 38.18 mg/g, respectively. Simultaneously, the adsorption capacity of PO43− was 64.93, 64.18 and 74.37 mg/g, respectively. The adsorption capacity of MgB was significantly higher than that of the other two types (p < 0.01).

Fig. 4
figure 4

Effect of magnesium compositions on adsorption

Full spectrum scans of Mg, Mg+B and MgB-A are shown in Fig. S3. Curve fitting of Mg 1s spectra showed that the three types of samples displayed peaks at three binding energies of 1306.00, 1303.38 and 1304.50 eV. The 1306.00 eV peak belonged to magnesium oxide compounds (Luo et al. 2021; Xu et al. 2018), 1303.38 eV belonged to metallic magnesium compounds (Zhu et al. 2020), and 1304.50 eV corresponded to struvite crystal formation (Chen et al. 2012). These results are consistent with those of SEM–EDS and XRD analyses.

The addition of Mg+B and MgB resulted in a binding energy peak at 398.50 eV, which was attributed to the C–N bond, and it may be due to N-containing organic matter on the surface of the biochar. In addition, the binding energy peaked at 402.00 eV due to the N–H bond. It may reflect the adsorption of NH4+ on the surface of biochar to negatively charged surface functional groups or cation exchange. The proportions of Mg+B and MgB on NH4+ adsorption by surface charge or cation exchange were calculated to be 14.06% and 22.72%, respectively. These results were consistent with the CEC results in Table 1, and further demonstrated that the introduction of Mg2+ improved the NH4+ adsorption performance of biochar significantly (Xiao et al. 2020). The signal of 400.40 eV was more robust and attributed to the N–C=O peak, which may be caused by NH4+ crystal precipitation of struvite (Wei et al. 2019). Comparing the addition of Mg, Mg+B and MgB showed that the proportion of NH4+ adsorption contributed by struvite precipitation was 42.27%, 48.46% and 72.15%, respectively. The binding energies of Mg, Mg+B and MgB had pronounced peaks at 133.80, 134.00 and 135.20 eV, mainly corresponding to HPO42−, PO43− and H2PO4, respectively. Therefore, HPO42− and H2PO4− peaks should be attributed to the surface adsorption mechanism, and PO43− may correspond to struvite. The proportions of PO43− removed by adsorption with Mg, Mg+B and MgB were 48.89%, 43.74% and 20.45%, respectively, and 51.12%, 56.26%, 79.55% of PO43− was removed by struvite precipitation. These results are consistent with XRD results (Xu et al. 2018).

3.4 Leaching characteristics and pot experiment analysis of MgB-A

3.4.1 Leaching behaviour investigation of MgB-A

Soil pH and EC are vital factors limiting plant growth and productivity, inhibiting plant growth through ionic toxicity and osmotic stress and reducing productivity by altering ionic relationships and binding pH changes, leading to nutrient imbalance (Borsani et al. 2001). Changes in pH and EC of CF and MgB-A leaching are shown in Fig. 5a and b. The effects of CF and MgB-A on pH and EC were mainly reflected in the early stage of leaching (0.05–2 L/S). When the first leaching was performed, the pH of MgB-A was 7.68, which was 0.88 units higher than that of the CF addition. Due to the rapid hydrolysis of CF, the release of NH4+-N and PO43− continue to rise, which in turn causes a rapid decrease in pH. By contrast, the initial pH increase caused by MgB-A addition can be shown in the following chemical reactions (Rahman et al. 2011).

$${\mathrm{MgNH}}_{4}{\mathrm{PO}}_{4}\cdot 6{\mathrm{H}}_{2}\mathrm{O}\to {\mathrm{NH}}_{4}^{+}+{\mathrm{Mg}}^{2+}+{\mathrm{PO}}_{4}^{3-}$$
(4)
$${\text{H}}_{2} {\text{O}} \to {\text{OH}}^{ - } + {\text{H}}^{ + }$$
(5)
$${\text{NH}}_{4}^{ + } + {\text{OH}}^{ - } \to {\text{NH}}_{4} {\text{OH}}$$
(6)
Fig. 5
figure 5

Effect of CF and MgB-A leaching behaviour on soil pH (a), EC (b), NH4+-N (c, e) and PO43− (d, f)

When L/S reached 0.2 L/kg, the pH of the two treatments both reached their lowest values (7.51 and 5.73). The lower pH of CF would easily lead to soil acidification and inhibit the growth of plants and microorganisms. When L/S reached 2.0 L/kg, the pH of the two treatments gradually stabilised at ~ 7.0. These results are consistent with Rahman et al. (2011) that used struvite fertiliser and chemical fertiliser and measured soil leaching pH changes.

Compared with pH, the effects of CF and MgB-A addition on EC were more pronounced. After the initial leaching, the EC of MgB-A addition reached a maximum (0.33 mS/cm) then decreased continuously. Nevertheless, the EC in CF increased with increasing water leaching, reaching the maximum value, reducing, and stabilising. Consistent with the change in pH, when L/S reached 0.2 L/kg, EC with CF reached a maximum (6.45 mS/cm), which was 31.78 times higher than that of MgB-A, consistent with the leaching rates for NH4+-N and PO43−. These results indicated that MgB-A had better NH4+-N and PO43− slow-release characteristics than CF.

The studies showed that struvite is a slow-release fertilizer that releases nutrients slowly to the surrounding environment. Thus, it is necessary to investigate the nutrient leaching behaviour of struvite in soil (Ahmed et al. 2018). The leaching behaviour and the cumulative leaching amounts of CF and MgB-A on NH4+-N and PO43− are shown in Fig. 5c and d. At the first leaching, CF addition caused rapid leaching of NH4+-N (5.85 mg/g) and PO43− (21.46 mg/g), which accounted for 7.61% and 14.32% of the total leaching amount. What’s more, the data showed that the CF first leaching (NH4+-N and PO43−) was 60.69 and 113.81 times higher than that of MgB-A leached NH4+-N (0.10 mg/g) and PO43− (0.19 mg/g), respectively. When L/S reached 0.2 L/kg, the leaching amount reached a maximum of 16.36 mg/g (41.36%) and 36.78 mg/g (54.76%), respectively, consistent with the lowest pH (5.73) and highest EC (6.45 mS/cm). This result indicated that NH4+-N and PO43− leaching were the main reasons for the decrease in pH and the increase in EC. When L/S reached 4.0 L/kg, the leaching amounts were essentially stable. However, the leaching behaviour of MgB-A was utterly different from that of CF. During the whole period of leaching, the amount of NH4+-N and PO43− leached showed a steady, continuously increasing trend. When L/S reached 4.0 L/kg (equivalent to 1 year of rainfall in WuXi), the cumulative NH4+-N and PO43− leaching amounts were only 2.28 mg/g (2.97%) and 13.22 mg/g (8.82%). By the end of the experiment (equivalent to 6 years of rainfall in WuXi), the cumulative leaching was 11.36 mg/g (14.79%) and 56.56 mg/g (41.90%), which was significantly lower than that following CF addition, by 5.66 and 2.60 times, respectively. The struvite structure formed by MgB-A significantly reduced the leaching of NH4+-N and PO43−, which proved that the fertiliser had an excellent slow-release effect (Rahman et al. 2014).

The leaching kinetic models for MgB-A and CF are shown in Fig. 6a and b and Table S4. The leaching kinetics of CF for NH4+-N and PO43− fitted better to a pseudo-second-order model (R2 = 0.9703, 0.9776), which indicated that the leaching of NH4+-N and PO43− was controlled by a combined mechanism of dissolution, release and diffusion (Yao et al. 2013), consistent with previous studies (Luo et al. 2021). NH4+-N and PO43− leaching kinetic of MgB-A fitted to both pseudo-first-order and pseudo-second-order models (R2 = 0.9943–0.9944, 0.9988–0.9989), which indicated that the release of NH4+-N and PO43− by MgB-A may be controlled by the initial concentration of NH4+-N and PO43− and the diffusion mechanism (Luo et al. 2021). In addition, most of the N and P contained in CF is water-soluble, while struvite, MgHPO4 and Mg(H2PO4)2 contained in MgB-A had low solubility, which further enhanced the sustained release effect of MgB-A.

Fig. 6
figure 6

Leaching kinetic of MgB-A (a, b) and CF (c, d)

3.4.2 Pot experiment

As shown in Figs. 7a and S4a, after 21 days of growth, compared with other treatments (CK, MgB and CF), the addition of MgB-A had a better effect on the growth of corn and ryegrass. As shown in Figs. 7b and S4b, MgB-A treatment exhibited a higher seed germination rate of 100% compared with CF (36.67% and 43.33%) treatments in the first 7 days, which was 2.73 times and 2.31 times lower than those for MgB-A. Consistent with the previous study, the addition of CF caused a rapid release of NH4+-N and PO43−, resulting in osmotic stress (soil acidification and increased EC) in the early stage, which caused the delay of seed germination and seed growth (Luo et al. 2021). Due to the excellent adsorption of NH4+-N and PO43− by MgB, the nutritional competition effect caused by MgB addition delayed the germination time of maize and ryegrass seeds by 2 and 3 days, respectively. At the end of the experiment, the soil was removed, and there were a large number of ungerminated and rotten seeds found in CF treatment. This phenomenon further illustrates the stress effect of the direct addition of CF on the seedling stage of plants.

Fig. 7
figure 7

Effect of different treatments on Zea mays L. growth (a), cumulative seed germination (b), chlorophyll contents (c) and rhizome height or weight (d)

As shown in Figs. 7c, d and S4c, d, the application of MgB-A promoted the chlorophyll content of corn (1.23–2.0 times) and ryegrass (1.10–1.84 times) compared with CF and CK. In addition, MgB promoted the chlorophyll content of corn and ryegrass, by 1.26 and 1.35 times that of CK, respectively, indicating that Mg2+ contained in MgB was helpful to improve the chlorophyll content of corn and ryegrass. MgB-A supported sustained release of NH4+-N and PO43−, and utility of Mg2+ further promoted the growth of plants in the seedling stage. Additionally, the MgB-A also improved the root length, plant height, root weight, and stem weight of the two plants. In summary, CF treatment easily led to soil pH acidification and EC increase, and NH4+-N and PO43− released rapidly, which was not conducive to the full utilization of plant nutrients and colonization (seedling) growth.

On the contrary, the stable carbon structure of MgB-A contributed to the activities of soil microorganisms and promoted the growth of plants. On the other hand, the struvite crystal structure and abundant Mg2+ in MgB-A further promoted the nutrients needed for plant growth. Its excellent slow-release ability better matches the nutrient assimilation rate of plants, especially conducive to the stable accumulation of nutrients for plants for a long time (Luo et al. 2021).

4 Conclusions

This study proved that both pyrolysis temperature and Mg content significantly affect the physicochemical properties of MgB and the adsorption capacity. A pyrolysis temperature of 450 °C and 2.4 g/L Mg2+ achieved the largest NH4+-N and PO43− adsorption capacity (37.72 and 73.29 mg/g, respectively). The adsorption process of NH4+-N and PO43− by MgB conformed to Langmuir–Freundlich and pseudo-second-order kinetic models (R2 = 0.9973–0.9988). Characterizations (XRD, SEM–EDS, FTIR and XPS), adsorption kinetics and isotherms indicated that the struvite crystallization was the predominant reason to remove NH4+-N and PO43−. In addition, some weak forces may be other mechanisms (ion exchange, surface precipitation or electrostatic attraction) for NH4+-N and PO43− removal. Meanwhile, the long-term slow-release behaviour of MgB-A was confirmed by leaching and pot experiments, which realize the production of efficient slow-release fertilizer to match and promote the plants growth. Compared with CF, MgB-A exhibited excellent long-term slow release of both NH4+-N and PO43−, and its release process was controlled by both the diffusion mechanism and the dissolution rate of struvite and Mg-P. Thus, MgB-A could be utilised as a carbon-based fertiliser to promote the seed germination, chlorophyll content, plant height and dry weight of Z. mays L. and L. perenne L. Our findings from this work exhibited that biochar is recommended to be applied to wastewater to recover the nutrient due to its adsorption capacity, and the formed struvite biochar-based fertilizers provide important informative support for agricultural applications of biochar.