Introduction

Huge amounts of food waste (FW), agricultural waste, and wastewater sludge occur in many countries. Accumulation of this municipal solid waste (MSW) has experienced a substantial increase due to urbanization, population, and economic growth. With rapid urbanization and population increase, the world generates 2.01 billion tons of municipal solid waste annually and expects to reach 3.40 billion tons by 2050 (Kaza et al. 2018). In 2020, Thailand generated 25.37 million tons of MSW, with an average per capita rate of 1.05 kg/day (Sutthasil et al. 2023). Accordingly, FW accounts for 64% of MSW. Of the FW collected in the Bangkok Metropolis, only 2% is recycled. The remaining are sent to landfill for disposal (Pharino 2021). Additionally, Thailand is primarily an agricultural country with agricultural areas accounting for 65% of the total territorial area (Kajina et al. 2018). Accordingly, the agricultural sector generates abundant organic residues, particularly corn stover (CS). Corn is one of the major cash crops in Thailand, representing the fifth largest plantation areas of 1.124 million hectares. Large quantities of corn stover after harvesting are commonly burned during land preparation, emitting harmful air pollutants, including sulfur dioxide, nitrogen oxides, carbon dioxide, carbon monoxide, black air carbon, and polycyclic aromatic hydrocarbons (PAHs) (Supasri et al. 2020). This widespread release of air pollutants from residue burning poses a significant global environmental challenge, especially due to their potential to cross national borders from the Asian region (Zhang et al. 2008). Addressing this issue is essential to minimize adverse impacts on both the environment and public health. Yongsri et al. (2022) revealed that post-harvest corn stalks, husks, and cobs accumulated phosphorus nutrients at levels of 0.18%, 0.16%, and 0.15% by weight, emphasizing the potential for co-digesting agricultural waste materials. However, CS is a notable digestion substrate, boasting high cellulose (15.1–41.0%) and hemicellulose (13.5–29.9%) content (Li et al. 2020). Thus, prior to utilization for anaerobic digestion (AD), pre-treatment becomes essential to reduce lignocellulose recalcitrance (Zhang et al. 2010). Various techniques, including chemical, biological, alkaline pre-treatment, and hydrothermal pre-treatments (Chandra et al. 2012; Crasta et al. 2023; Hu et al. 2015; Wei et al. 2015), enhance the biodegradability of lignocellulosic materials. This process disassembles complex structures, making the constituent parts more accessible to microbes and ultimately increasing the efficiency of the AD process. Additionally, Wu et al. (2010) investigated the co-digestion of agricultural residues (corn stalks, oat straw, and wheat straw) with swine manure and resulted in a remarkable 11-fold increase in biogas production from corn stalks compared to the control, which involved the mono-digestion of corn stalks. Moreover, municipal wastewater treatment plants generate significant amounts of anaerobically digested sludge, requiring appropriate handling or valuation prior to disposal (Zhu et al. 2013). Normally, digested sludge is sent to land disposal (55%), landfilling (30%), and incineration (15%) (Mulchandani and Westerhoff 2016). As a significant resource, DS dominates a substantial organic content, encompassing proteins and carbohydrates that could be reclaimed through AD. Furthermore, DS contains 1–10% of phosphorus (P), an essential but non-renewable material (Yu et al. 2017). Thus, DS has the potential to serve as an alternative P supply (Xu et al. 2022), while simultaneously the sludge contains a substantial P content and has the capacity to fulfill 12–15% of the total P demand upon successful recovery (Cordell et al. 2009).

Anaerobic digestion (AD) stands out as a promising method for converting organic materials into biogas. Although FW is an optimal substrate for AD due to its rich nutrient content, it poses a challenge with its high nitrogen levels, particularly from proteins, resulting in a low carbon–nitrogen ratio (C/N). A low C/N ratio inhibits efficient AD due to excessive ammonia nitrogen in FW (Xiao et al. 2022). In addition, the AD of mono-substrate FW may encounter heightened sensitivity to acidification and instability with an increased organic loading rate (OLR) (Zou et al. 2023). The potential solution involves anaerobic co-digestion (AcoD), where the low C/N ratio is balanced by co-digesting FW with two or more organic waste streams, optimizing biogas yield and kinetic performance (Awe et al. 2018). Besides C/N ratio, HRT and OLR significantly influence AcoD performance by affecting microbe–substrate contact time and organic loading. Previous studies demonstrated successful AcoD at various HRTs, including 30 days for rice straw (Potdukhe et al. 2021), 25 days for agro-industrial waste (Elif Gulsen Akbay 2024), and 20 days for corn stalk (Wei et al. 2019). Optimizing HRT and OLR is crucial for efficient co-digestion of lignocellulosic CS with readily biodegradable FW to achieve high biogas yields. Anaerobic digestion and co-digestion not only offer sustainable waste management and P recovery but also provide the added advantage of renewable energy production through biogas and methane generation. Biogas utilization for energy generation contributes to a circular system and aligns with efforts to reduce fossil fuel dependence and mitigate climate change. It is imperative to carefully select the suitable co-substrate and blend ratio to enhance synergy, reduce detrimental compounds, optimize methane production, and uphold the quality of the digestate in AcoD processes. Agricultural residues and FW, recognized for their favorable availability, lower cost, and renewability, offer promising options for adjusting the C/N ratio in AcoD systems. Several studies investigated the effectiveness of the approach in ensuring efficient and stable digestion performance, with a focus on biogas production from corn stover pre-treatment and manure (Tawfik et al. 2023; Zhu et al. 2023). However, agricultural countries are already facing a phosphorus shortage with the current crisis in fertilizer prices. Many researchers raise concerns about diminishing phosphate rock reserves within the next 50–100 years (Cordell and White 2014), threatening global food security. Thus, sustainable P management is crucial by emphasizing P utilization efficiency and recovery of P from various food chain wastes (Prathumchai et al. 2018; Thitanuwat et al. 2016). Several studies have been conducted to study the influencing factors for P recovery from various types of wastewater and sludge (slaughterhouse, human urine, and tapioca starch AD effluent) (Lin et al. 2024; Pinatha et al. 2020; Riewklang et al. 2023; Zeng et al. 2021). AD effluent, characterized by high concentrations of inorganic phosphorus and ammonia, facilitates struvite precipitation, a slow-release fertilizer containing magnesium, ammonium, and phosphorus in equimolar concentration (Abel-Denee et al. 2018). Struvite, also known as magnesium ammonium phosphate hexahydrate (MgNH4PO4∙6H2O), offers comparable qualities to standard fertilizers like diammonium phosphate and single superphosphate. Furthermore, there is a scarcity of research on the simultaneous assessment of biogas and phosphorus recovery from FW, CS, and DS. The previous studies have primarily focused either on biogas production or phosphorus recovery separately, with limited attention given to their combined assessment (Arias et al. 2021; Du et al. 2024; Elif Gulsen Akbay 2024).

AcoD can solve most of these problems by co-digesting two or more organic wastes streams for optimizing biogas yield and enhancing P release for recovery back to plantation. To address the above-mentioned research gaps to utilize FW, CS, and DS discharged from the human ecosystem, the following objectives were investigated: (1) to investigate the effect of CS pre-treatment methods and HRT on the efficiency and stability of anaerobic co-digestion involving FW, CS, and DS in achieving high biogas production, P release, and mass balance, (2) to determine the optimum conditions for both P recovery and the quality of P solids obtained from anaerobic co-digestion effluent, and (3) to evaluate the techno-economic feasibility of biogas production and P recovery. Information on product quality of recovered P is important for decision makers to implement commercial-scale P recovery from wastewater. Furthermore, this study was conducted to evaluate physical factors affecting efficiency and quality of P-containing products recovered from AcoD effluent of FW, CS, and DS. This research has the potential to contribute to climate change mitigation by preventing methane emissions from landfills and burning emissions. Also, it aligns with the circular economy model that strives to minimize resources and waste to disposal, closing or slowing down the materials loop.

Materials and methods

Raw material preparation

Raw materials fed to anaerobic co-digesters were food waste, agricultural waste, and digested sludge obtained from canteen, agricultural areas, and wastewater treatment plant, respectively. These raw materials were prepared before using as feedstock in anaerobic co-digester.

Food waste

Raw food waste (FW) was collected from the canteen of the Faculty of Tropical Medicine, Mahidol University, Bangkok, Thailand. This waste primarily consisted of leftovers from cooked foods, including meats, rice, noodles, and vegetables. Items such as chopsticks, toothpicks, plastic bags, toilet paper, and bones were removed. The waste was homogenized using an electric grinder, resulting in an average particle size of 1–2 mm. The FW were analyzed, encompassing an understanding of both its chemical and physical characteristics, as well as the concentration of phosphorus present as presented in Table 1. This analysis aimed to facilitate its application in the subsequent anaerobic co-digestion process. The FW sample was kept into ziplock bags with the amount of daily feeding and stored under frozen condition (− 16 to − 18 °C) to prevent degradation and spoilage before being used in the anaerobic co-digester.

Table 1 Characteristics of food waste, corn stover, and digested sludge

Corn stover and pre-treatment

Corn stover (CS) consists of the stalks, leaves, and husks that remain in the field after the corn harvest. The CS was collected from a corn field in Song District, Phrae Province, Thailand. For future use in the anaerobic co-digestion process, pre-treatment methods of CS have been divided into physical pre-treatment, pre-treatment with chemical, and thermal for improving biomass biodegradation. After collection, CS was chopped, milled, and sieved using a 0.85 mm mesh for physical pre-treatment. For chemical pre-treatment, the pre-treated CS with physical method was digested with 5% of NaOH for 3 days. For thermal pre-treatment, the pre-treated CS were soaked in 80 °C water bath for 6 h to enhance enzymatic hydrolysis. The 5% NaOH chemical treatment for 3 days is based on prior research investigating different NaOH concentrations and pre-treatment durations for biogas production. Previous studies provide insights: Pang et al. (2008) found 6–8% NaOH yielded the highest biogas without a significant difference, while 10% had negative impacts. Zheng et al. (2009) reported no significant biogas difference between 2 and 6% NaOH after 3 days. Zhu et al. (2010) observed 5% NaOH for 1 day gave the highest yield, with lower concentrations being ineffective and higher ones inhibiting methane. A 6-h thermal pre-treatment at 80 °C aims to improve anaerobic digestion efficiency of CS for biogas production, a physical degradation process without added chemicals. This duration and temperature enhanced straw biogas yields in prior studies by Du et al. (2019). However, this pre-treatment may not fully break down the lignin-cellulose structure, potentially limiting the biogas yield increase despite improving digestion efficiency. The characteristics of CS are presented in Table 1. Prior to the thermal treatment, both the CS and distilled water were combined to adjust the moisture content (MC) to 80%. This adjustment was calculated using the method described by Zheng et al. (2009), as presented in Eq. (1).

$${\text{MC}} \left({\%}\right)= {1} -\left[ \, \frac{\text{Dry matter weight of CS}}{\text{Dry matter weight of CS}+\text{Water added}} \, \right]\times 100$$
(1)

During the preparation of CS for FWCS-Chem feeding, 5% NaOH was added to achieve a moisture content of 80%. This condition was appropriate since it allowed the corn stover to thoroughly absorb water and maintain a completely saturated state. The pH values were monitored throughout the experiment. Initially, on Day 1, when 5 g VS/L of FW was mixed with 1 g VS/L of CS (5% NaOH pre-treated CS), the pH reached 11.48. Subsequently, on Day 2, it decreased to 10.54, followed by readings of 10.07 on Day 3, 9.98 on Day 4, 10.03 on Day 5, 10.05 on Day 6, and 10.13 on Day 7. Notably, after Day 3, the pH of the mixed feed remained relatively stable at around 10. Consequently, an adjustment experiment was conducted three days later to bring the pH within the range of 7.0 to 7.5 using hydrochloric acid (HCl) at 37% concentration.

Digested sludge

Anaerobic granular sludge with proper biodegradability and methanogenesis ability was used as an inoculum from a mesophilic anaerobic digester operation. This sludge was obtained from the full-scale sludge digester at the Nong Khaem wastewater treatment plant in Bangkok, Thailand. The temperature range of 25–35 °C was used because the experiment utilized digested sludge inoculum from a mesophilic anaerobic digester operated at ambient temperatures in Bangkok, Thailand. The study was conducted under uncontrolled ambient conditions over eight months (May to December) in Bangkok. During this period, ambient temperatures naturally varied from around 26–35 °C in May to 22–32 °C in December. The characteristics of the digested sludge (DS) are presented in Table 1. The DS, utilizing 50% of the working volume in the AD tank, was used to acclimate an active microbial community and served as a substrate and potential P source due to its rich P content (461.81–872.87 mg P/L). Initially, the concentration of P in DS is equal to 461.81 mg P/L.

Semi-continuous anaerobic co-digester operation

The anaerobic digesters (laboratory-scale) were designed with a working volume of 20 L and constructed using acrylic material. All experiments were conducted at room temperature. It comprised a biogas collection section and an initial feed inlet for the digester, which was positioned on top of the tank, near the agitator motor. The feed to the digester was introduced in a semi-continuous manner (fed-batch). The agitation speed for this digester was set at 80 rpm for 30 min, operating three times a day. After analyzing the characteristics of food waste and agricultural residues, they were employed as initial substrates in different conditions of AcoD reactor. The aim of this process was to investigate suitable conditions for a digestion tank capable of breaking down phosphorus into a form easily usable for producing a considerable quantity of phosphorus fertilizer. To examine the effect of HRT, 10, 20, and 30 days were operated. The digested reactors were operated at different pre-treatment methods (physical, thermal, and chemical pre-treatment). The pre-treated CS was mixed with FW based on the VS mass ratio of 1:5 (6 g VS/L/Day) before feeding to anaerobic co-digester as shown in Fig. 1.

Fig. 1
figure 1

Schematic diagram of pre-treatment methods of agricultural residue for delignification (a) FW without CS; (b) FW with physical pre-treatment of CS; (c) FW with physical and chemical pre-treatment of CS; and (d) FW with physical and thermal pre-treatment of CS

For AD start-up, 50% of DS in the AD tank was introduced into the reactor to cultivate and acclimate an active microbial community, ensuring stabilization of biogas production in each HRT operation. The initial substrate to inoculum (S/I) ratio for each digester was established at 0.5 (based on VS). The assumption was made that the inoculum provided the essential nutrient requirements for anaerobic microorganisms (Labatut et al. 2011). After the acclimation period, the operation began on Day 0 with a loading rate of 6 g VS/L/day, informed by previous studies such as Yong et al. (2015). The FW/straw ratio was established at 5:1, considering the findings regarding straw particle size (0.45–0.60 mm.) to optimize gas production efficiency. The selection of 10, 20, and 30-day HRTs could be aimed at investigating the impact of varying retention times on biogas production efficiency and system stability. Longer HRT allows more complete breakdown of organic material, potentially increasing biogas production. However, shorter HRT allows for quicker processing and may be better suited for certain feedstocks or operational limitations. Additionally, the OLR would vary according to the HRT selected. For example, with a 10-day HRT and a flow rate of 2 L/day, the OLR would be calculated as: (2 L/day) * (6 g VS/L)/20 L = 0.6 g/L/day. The different pre-treatment methods of feedstock (FW/CS) are shown in Fig. 1. The experimental setup included four anaerobic digesters: T1 (FW) utilized food waste alone (6 g VS of FW), T2 (FWCS) used a mixture of 5 g VS of food waste and 1 g VS of corn stover with physical pre-treatment, T3 (FWCS-Chem) combined 5 g VS of food waste and 1 g VS of corn stover with physical and chemical pre-treatment (5% NaOH; 35 °C; 72 h), and T4 (FWCS-Temp) employed 5 g VS of food waste and 1 g VS of corn stover with physical and thermal pre-treatment (Steam; 80 °C; 6 h). The operational conditions specified OLRs of 0.2, 0.3, and 0.6 g VS/L/day, with corresponding HRTs of 30, 20, and 10 days, respectively, and flow rates of 0.67, 1.0, and 2.0 L/day (calculations shown in Eqs. (2) and (3)). In practice, adjusting the OLR allows control over the HRT to optimize treatment performance while ensuring proper wastewater treatment. Higher OLRs result in shorter HRTs, while lower OLRs lead to longer HRTs. The biogas generated by each reactor was collected through an outlet line, and the daily biogas yield was quantified using a water displacement method. The pH in the digester liquid was not controlled over the experimental period but monitored and adjusted by adding feed to maintain a pH range of 7–9 using 5% NaOH solution, with pH checks and adjustments performed each time feeding was conducted. The anaerobic digestion process was conducted under an ambient temperature condition ranging from 25 to 35 °C. The supernatant from each anaerobic co-digester was sampled every 2 days for pH, TS, TSS, COD, and TP analysis. After finishing each HRT, the composition of precipitated P compound mixed with organic matter in the bottom of reactors was analyzed to determine P mass balance.

Phosphorus precipitation experiments

The AD effluent samples were used in these experiments to observe whether pre-treatment and HRT in the AD effluent could enhance P recovery efficiency and improve the quality of P crystals. The tests were performed in 1-L beakers—each filled with 800 mL samples. Since the molar ratios of Mg/P in all samples were found to be in excess for struvite precipitation, no external chemicals were required, except for the addition of alkali to adjust the pH. solutions to pH 9 using droplets of concentrated 5% NaOH. Samples were placed in a jar tester and stirred at 200 rpm for 15 min followed by 50 rpm for 30 min. They were left to stand for 60 min to allow the solids to settle and reach equilibrium. It was reported that this duration was sufficient after 30 min, followed by filtration using filer paper No. 93 (Whatman). After filtration, samples of both liquids and solids were analyzed in the laboratory. All experiments were conducted in triplicate at room temperature (about 25 °C). Any sample analytical result showing a difference in P mass balance of over 10% before and after the experiment was excluded from the computation.

Calculations

Anaerobic co-digestion process

Hydraulic retention time (HRT) and organic loading rate (OLR) are defined in Eq. (2) and in Eq. (3), respectively.

$$\text{HRT (day)} \, \text{=}\left[\frac{V \, }{ \, {\text{Q}} \, }\right]$$
(2)

where V is the working volume of the reactor (L) and Q is flow rate (L/d).

$$\text{OLR (}\text{g/}\text{L}\text{/d}\text{) }\text{ = } \left[\frac{Q \times {C}_{\text{vs}} \, }{ \, {\text{V}}}\right]$$
(3)

where C is the concentration of volatile solid (g/L).

Phosphorus mass balance and recovery efficiency

P input, output, and accumulation in the system were determined for P mass balance consideration. The mass balances were served for understanding fate and transport of phosphorus in the anaerobic co-digestion process, as shown in Eq. (4).

$${\text{P}}_{\text{in}}\text{ = }{\text{P}}_{\text{out}}\text{ } + \, {\text{P}}_{\text{accumulation}} \,$$
(4)

where Pin is the total phosphorus input into the digester (from the feedstock and any water added). Pout is the total phosphorus output from the digester (digestate), and Paccumulation is the change in phosphorus content within the digester, which may include uptake by microorganisms or chemical reactions. The efficiency of P recovery is presented in Eq. (5).

$$\% \;{\text{P}}_{{{\text{recovery}}}} = \left[ { \frac{{C_{0} {-} C _{e} }}{{C _{0} }} } \right] \times 100$$
(5)

where C0 and Ce are the initial and equilibrium P concentrations in the aqueous solution (mg/L), respectively.

Phosphorus content in solid

The amounts of limiting ions from solid composition in the P-composite precipitates were used to calculate the percentage of P content in solid, following the method of Pinatha et al. (2020), as shown in Eq. (6).

$$\% {\text{P}}_{{{\text{crystal}} {\text{content}}}} = \left[ { \frac{{C_{s} \times {\text{MW}} }}{ M } } \right] \times 100$$
(6)

where Cs is the molar concentration of limiting ion (mol/L), MW is the molecular weight of P crystal formed (g/mol), and M is the amount of solids formed in the precipitation experiment (g/L).

Analytical methods

Laboratory analysis

All parameters were analyzed according to Standard methods (APHA 2017). The colorimetric method with the ascorbic acid technique and UV–visible spectrophotometer were employed to determine P concentration in both aqueous and solid phases. Total dissolved solids (TDS) were calculated from the determinations of total solids (TS) and total suspended solids (TSS), which was performed by oven drying at 103-105ºC. The volatile solids (VS) and volatile suspended solids (VSS) were determined after ignition in a muffled furnace at 550ºC. The measurement of nitrogen (N) content was carried out using the total Kjeldahl nitrogen (TKN) method. Chemical oxygen demand (COD) assessment was carried out using dichromate closed reflux and subsequent FAS titration and organic carbon by Walkley and Black method. Detection of other cations, such as magnesium (Mg) and calcium (Ca), was accomplished using an atomic absorption spectrophotometer (AAS) from the Thermo Fisher Scientific iCE 3000 series. The crystalline structure was carried out by X-ray diffraction (XRD) with 2θ of 5 to 80, operating voltage 40 kV, and current 40 mA from D8 DISCOVER, Bruker AXS Inc, USA.

Results and discussion

Characteristics of food waste, corn stover, and digested sludge

From characteristics of FW, CS, and DS shown in Table 1, the moisture content of FW and CS was 72.75% and 6.58%, respectively. The VS values of both substances were closely similar (95% and 93%), and concentrations of phosphorus (P) were 1.58 ± 0.18 mg/g and 1.17 ± 0.17 mg/g for FW and CS, respectively. It could be observed that FW and CS presented low P concentrations. However, with the global generation of approximately 931 million tons of FW in 2019 (Forbes 2021), the P mass within FW became significantly higher. The DS exhibited a VS value of 43.67% and TP concentration of 461.81 mg/L (1.20% P in sludge). Accordingly, 48.43 ± 7.34 mg/L (10.49% of TP) was identified in the form of PO43−, and 89.51% of P was observed in the solids phase. The VSS and FSS constituted 44.87% and 55.13% in DS, respectively. This implies that the P in solids (89.51%) is distributed as organic P (40.16%) and inorganic P (49.34%). The P in the solid phase of the sludge consistently releases simultaneously into the liquid phase during the anaerobic process and could subsequently be easily recovered by precipitation, potentially contributing to anaerobic co-digestion reactors (Yu et al. 2021b). Additionally, DS contained Ca2+ and Mg2+ at concentrations of 100.14 mg/L and 282.79 mg/L, respectively. Furthermore, the soluble orthophosphate, readily combinable with metal ions, and the particulate Ca-P and Mg-P in raw digested sludge define it as an inorganic phosphorus (IP) species (Yu et al. 2021a). Consequently, IP stands as the exclusive species post-anaerobic digestion, making it the key element for substantial P release from sludge.

The primary strategy of incorporating CS was to achieve a balanced C/N ratio. Combining FW with C/N ratio of 10.24 and CS with ratio of 90.44 at 5:1 FW/CS ratio resulted in C/N ratio of 24, making it well-suited for anaerobic co-digestion operations. Previous studies have indicated that the optimal C/N ratios for effective anaerobic co-digestion processes varied within the ranges of 20 to 30 (Puyuelo et al. 2011), 25 to 30 (Li et al. 2013). Furthermore, Wang et al. (2012) identified an ideal C/N ratio of 27.2 through their investigation, which was achieved by utilizing an anaerobic co-digestion processes that involved a mix of three initial substrates, including dairy manure, chicken manure, and wheat straw.

Anaerobic co-digestion performance

The co-digestion process can produce anaerobic biogas along with the conversion of organic and inorganic phosphate to orthophosphate (Zhang et al. 2023b). Subsequently, chemical precipitation of phosphate could have occurred in the reactor and the supernatant effluent that was discharged. The phosphorus-containing supernatant could have been used to induce chemical precipitation and form struvite (MgNH4PO4 (s)) and hydroxyapatite (Ca₅(PO₄)₃ (s)) for a beneficial agricultural fertilizer. This investigation of the anaerobic co-digestion process was carried out using four reactors, as previously mentioned. The characteristics of feedstock and efficiency from digester tank are presented in Fig. 2. It was found that after treatment in HRT of 10, 20, and 30 days for FW, FWCS, and FWCS-Temp, COD removal efficiency ranged from 95 to 98% (Fig. 2). Meanwhile, in the effluent of FWCS-Chem with the chemical pre-treatment process, COD concentration was slightly higher, ranging from 104.8 to 274.6 mg/L, with COD removal of 96.88%, 95.02%, and 98.10% at HRTs of 10, 20, and 30 days, respectively. The increase in COD observed in the anaerobic co-digestion with alkaline condition of CS did not result from lignin. Rather, lignin facilitated the accelerated release of organics (i.e., proteins and carbohydrates) in both DS and CS (He et al. 2022). Furthermore, when using pre-treated FW and CS at HRT of 30, 20, and 10 days, TSS levels remained consistently low on the final day of digestion, as presented in Fig. 2. Therefore, the optimal conditions of anaerobic co-digestion process with different pre-treatment methods of feedstock should consider biogas yield, COD removal efficiency, P release and TSS. Moreover, parameters that affect the stability of anaerobic co-digester and potential for utilizing the supernatant should also be considered.

Fig. 2
figure 2

The characteristics of feedstock and percentage of removal from anaerobic co-digestion under different HRTs and substrates

Biogas production

The biogas productions during anaerobic co-digestion with different HRTs and substrates are shown in Fig. 3. The study revealed an inverse correlation between HRT and biogas production. Decreasing the HRT led to an increase in daily biogas production, while extending the HRT appeared to decrease biogas generation, particularly in FW & FWCS. This trend was observed for HRTs of 30, 20, and 10 days corresponding to feed flow rates of 0.67, 1.0, and 2.0 L/day, respectively, while maintaining consistent feed concentrations. Consequently, the OLRs were 0.2, 0.3, and 0.6 kg VS/m3/day, respectively, and biogas production exhibited a proportional increase with rising OLR values. Literature summary on AcoD of agri-food waste and wastewater sludge is presented in Table 2.

Fig. 3
figure 3

Daily and cumulative biogas production from different substrates of FW, FWCS, FWCS-Chem, and FWCS-Temp

Table 2 Literature summary on anaerobic co-digestion of agri-food waste and wastewater sludge

As a result, it was found that at HRT of 10 days, the highest daily biogas production occurred. With 356.05, 324.85, and 248.55 L/m3-day (7,120.9 ± 560.9, 6,497.1 ± 442.7, 4,971.0 ± 616.3 mL/working volume (L)) for FW, FWCS, and FWCS-Chem, respectively. In terms of cumulative biogas production, HRT 20 days demonstrated the highest accumulation of 4,998, 4,751, and 7,279 L/m3 for FW, FWCS, and FWCS-Chem reactors, respectively. The co-digestion of FW and CS with physical pre-treatment (FWCS) at 30-day HRT significantly increased average daily biogas production by 56.56% (3,249.24 ± 273.65 mL/day, cumulative biogas: 4,874.86 L/m3), compared to FW mono-digestion at 2,072.4 ± 280.0 mL/day (cumulative biogas: 3,108.57 L/m3). At 20-day HRT, the average daily biogas production of FW and FWCS did not exhibit significant difference, with P-value of 0.162 and values of 4,997.83 and 4,751.24 mL/day, respectively. However, with HRT reduced to 10 days, mono-digestion of FW demonstrated the highest efficiency in daily biogas production, potentially due to the longer degradation time of CS compared to FW, as shown in Fig. 3.

In the FWCS-Chem with both physical and chemical pre-treatment, the highest biogas yield was achieved with HRT of 20 days, totaling 7,279.2 mL biogas/day (364.0 L/m3-day), exceeding the biogas production of FW and FWCS by 31.34% and 34.73%, respectively. Furthermore, under 20-day HRT, FWCS-Chem exhibited biogas production levels similar to those observed during 10-day digestion period for FW 7,120.9 mL/day (356.1 L/m3-day) and FWCS 6,497.1 mL/day (324.9 L/m3-day), both utilizing feedstock flow rates that were more than double time (Fig. 3). However, the reduction in biogas production efficiency to 4,971.0 mL/day, observed when FWCS-Chem decreased the HRT to 10 days, was associated with the use of NaOH in pre-treatment and an increased amount of HCl to adjust the pH from 10 to 7 for neutralizing the mixed feedstock. After reducing the HRT to 10 days, the OLR increased by 0.6 kg VS/m3/day, exceeding the values of 20 and 30 days by 3 and 2 times, respectively. Consequently, there was an elevation in corn stover mass, leading to an increase in lignin within the digester tank. The activity of microorganisms involved in hydrolysis and methanogenesis decreased by 46.4% and 65.7%, respectively, as lignin content increased (He et al. 2021), leading to low energy conversion efficiency. To maintain a stable and efficient AD system, precise dosing of HCl is crucial. The addition of HCl can diminish the digester's ability to buffer pH, making it more susceptible to rapid pH fluctuations when there are changes in influent composition. Additionally, excessive acidification can negatively impact microorganisms and disrupt the digestion process (Labatut and Pronto 2018).

To determine an efficient organic degradation process, the influence of VS removal efficiency on cumulative biogas production is shown in Fig. 4. For FW alone, the VS removal efficiency was the highest at 26.90%, 24.31%, and 21.20% for 20-, 10-, and 30-day HRTs, respectively. For substrates containing other non-biodegradable materials (FWCS, FWCS-Chem, and FWCS-Temp), the volatile solids (VS) removal efficiencies were lower than those of mono-substrates. At 20-day HRT, the VS removal efficiency tended to decrease, while the cumulative biogas production increased for FWCS-Chem (with alkaline pre-treatment), compared to FWCS (without alkaline pre-treatment). This indicates that the alkaline pre-treatment improved biogas production, even though it led to a decrease in VS removal efficiency (implying an increase in residual VS concentration). This could explain that the alkaline pre-treatment with NaOH made more VS available for digestion, resulting in higher biogas production (Pang et al. 2008). The pre-treatment helps disrupt the lignocellulosic structure, increasing porosity and accessibility of enzymes to cellulose, which improves digestibility and biogas production (Dong et al. 2018; Zhu et al. 2010). Regarding the effect of HRTs on VS removal, at a 10-day HRT, the pre-treatment did not affect the VS removal efficiency. Therefore, at the 20-day HRT, as the system rapidly converted readily degradable VS into biogas, the VS removal tended to decrease while the cumulative biogas production increased. This highlights an inverse relationship between these two parameters. It revealed that, after alkaline pre-treatment, FWCS-Chem showed the lowest VS removal efficiency, possibly attributed to the precipitation of nutrients such as iron, calcium, and phosphorus within the reactor (Al Rabadi et al. 2024; Pimpeach et al. 2023).

Fig. 4
figure 4

VS removal efficiency and cumulative biogas production from different substrates of FW, FWCS, FWCS-Chem, and FWCS-Temp and HRTs

Hence, the investigation revealed that 20-day HRT proved to be the most effective for anaerobic co-digestion of FWCS-Chem, resulting in the highest daily biogas production. If the reduction of food waste and corn stover is preferred, adopting 10-day HRT for the digestion of FW and FWCS are presented as alternative way to produce biogas. This approach enables a feedstock load that exceed twice that of a 20-day HRT while halving the digestion time. Previous studies have demonstrated successful AcoD of rice straw and waste activated sludge with 30-day HRT (Potdukhe et al. 2021), agro-industrial waste and municipal sewage sludge with 25-day HRT (Elif Gulsen Akbay 2024), and corn stalk with sewage sludge with 20-day HRT (Wei et al. 2019). Moreover, alkaline NaOH pre-treatment induces bond-cleaving reactions in the lignocellulosic matrix: saponification cleaves ester linkages, nucleophilic substitution fragments lignin's aromatic rings (Chandra et al. 2007), and amorphogenesis disrupts cellulose's crystalline regions (Fan et al. 1980). These processes lead to extensive delignification, hemicellulose removal, and cellulose amorphization, enhancing substrate accessibility for microbial degradation and biogas production (Hendriks and Zeeman 2009). The high pH conditions also solubilized organic phosphorus compounds (phytates) via pH-catalyzed hydrolysis of covalent P-O ester bonds (Bel'skii et al. 1970). Inorganic phosphate precipitates became more soluble under alkaline conditions due to the increasing hydroxide concentration disrupting their ionic lattice structures (Qiu and Ting 2014). This increased solubility of both organic and inorganic phosphorus fractions under the alkaline pre-treatment conditions facilitated their release as soluble orthophosphate (Müller et al. 2015), as depicted in Fig. 5. Primarily, the alkaline pre-treatment catalyzed key reactions that deconstructed the recalcitrant polysaccharide-lignin composite, while the mild thermal conditions alone were insufficient to disrupt the strong chemical bonds that provide resistance. On the other hand, this enabled superior carbohydrate biodegradability and P bioavailability under the chemical approach (Zheng et al. 2014).

Fig. 5
figure 5

Alkaline and thermal pre-treatments methods of lignocellulosic feedstock for anaerobic co-digestion

Utilizing 80 °C for a 6-h pre-treatment of CS in the FWCS-Temp reactor for AcoD had adverse effects on microbial activity. This resulted in the inability to produce biogas within both 10 and 20 days of HRT except for a 30-day period (Fig. 3). Thermal pre-treatment at 6 h 80 °C led to some solubilization and hydrolysis of hemicellulose polymers, facilitating anaerobic digestion into biogas (Zheng et al. 2014). However, it was insufficient to disrupt crystalline cellulose fibrils or cleave lignin bonds effectively (Mosier et al. 2005). Cellulose's crystalline regions require temperatures above 200–240 °C for significant decrystallization (Laureano-Perez et al. 2005), while lignin's complex structure demands even higher thermal energy to cleave its bonds (Paudel et al. 2017). Consequently, intact cellulose and lignin fractions after pre-treatment continued to restrict microbial access to polysaccharides, limiting biodegradation and biogas production (Jönsson and Martín 2016), as presented in Fig. 5. Due to the unexpected reactions that may have been initiated by the selected temperatures and duration, inhibitory compounds were released, ultimately impacting biogas production. As a result of steam pre-treatment, lignocellulosic biomass commonly generates phenolic compounds through lignin degradation, thereby inhibiting the AD process (Akizuki et al. 2023). The increased accumulation of phenolic substances may have adverse effects on AD, potentially leading to its failure. Borja et al. (1996) indicated that phenolic compounds pose challenges for degradation by both aerobic and anaerobic microorganisms; in the pre-treated condition, the concentration of these compounds gradually increased and remained within the range of 1,200–1,400 mg/L. Currently, the evaluation of steam pre-treatment efficacy has primarily relied on batch AD processes, with limited exploration in continuous processes. And Uygur and Kargi (2004) showed that phenol concentrations above 400 mg/L had detrimental effects on removal of nutrients in four-step sequencing batch reactor (SBR). Additionally, lignin-rich feedstocks in AD led to slower digestion rates, extended retention times, reduced process efficiency, and presented challenges in optimizing gas production when compared to carbohydrates and fats (Gao et al. 2022; Hashemi et al. 2021). It's important to highlight that lignin can enhance processes involved to the production of short-chain fatty acids, such as solubilization, acidogenesis, and homoacetogenesis, however, it significantly inhibits methanogenesis (He et al. 2022). Therefore, anaerobic fermentation seems to be more effective than anaerobic digestion for producing methane in sludge or other organic solid waste with high lignin content. This study focuses on investigating semi-continuous AcoD to improve biogas production and enhance P recovery efficiency. However, the current investigation does not include an examination of lignin properties in FW, CS, and DS, with suspicion focusing on lignin release from CS during pre-treatment. The results emphasize the importance of implementing additional measures to address lignin toxicity to methanogens during AD, and further research is recommended to validate these findings in future.

Phosphorus mass balances and recovery

This P mass balance process involves a meticulous tracking of phosphorus-related inflows, outflows, and internal processes to gain a comprehensive understanding of its behavior during anaerobic digestion. Key elements of the P mass balance include the consideration of P inputs in FW, CS, and DS, outputs in the form of P releasing in the supernatant and accumulation, representing the change in P content within the digester tank. Internal processes involve biological uptake, where microorganisms in the digester assimilate P for metabolic activities, and potential chemical reactions leading to the formation of P precipitation (Wadchasit et al. 2023). This study revealed significant insights into the daily release of P in the supernatant from the AcoD using different HRT and pre-treatment methods. At 30 days of HRT, P release slightly stabilized from day 21 onwards, with concentrations ranging from 22.00 to 25.44 mg P/L. Contrastingly, 10 and 20 days of HRT indicated a consistent reduction in P release, with concentrations ranging from 20.99 to 35.23 mg/L and 19.42 to 31.23 mg/L, respectively. As illustrated Fig. 6, 10 days of HRT show the maximum release of P at concentrations of 31.98 and 35.23 mg P/L for FWCS and FWCS-Chem, respectively. For the biogas production as described in Sect. "Biogas production", at 10 days of HRT, FWCS is capable of as 324.85 L/m3-day, accompanied by P release rate of as much as 31.98 mg P/L per day. However, it was observed that only 19.07% P in FWCS and 19.59% P in FWCS-Chem were released, resulting in an accumulated P content in the tank of approximately 80%. With high P concentration in the sludge at 461.81 mg/L leads to a very low mass transfer efficiency, specifically for organic P during anaerobic fermentation, as well as inorganic P, contributing to more severe reprecipitation of PO43− (Yu et al. 2021b). Consequently, this results in limited P release. Moreover, the P release efficiency after anaerobic fermentation was only 11% and 5% from sludge P concentrations of 939 mg/L and 4,048 mg/L, as reported by Liu et al. (2019); Liu et al. (2020), respectively. Conversely, for sludge P levels below 500 mg/L, the P release efficiency after anaerobic fermentation with alkali pre-treatment reached 35% when the total P concentration was 300 mg/L (Wu et al. 2017). It proved the P mass balance exhibited the lowest P release capability at 10-day HRT, indicating a potential need for more time in the releasing of P in the form of PO43−. The use of 5% NaOH for chemical pre-treatment of CS (FWCS-Chem) resulted in the highest concentration of P release from the initial substrate among all HRTs operated. In fact, the second pre-treatment process, which includes 5% NaOH treatment of CS followed by neutralization with HCl in FWCS-Chem, leads to the highest P release. In order to prevent the collapse of the AF system and maximize the effectiveness of P release, a well-regulated acid state is required (Wu et al. 2020). Thermal treatment had the least effect on solubilizing organic phosphorus compounds (phytates) or inorganic precipitates (struvites/calcium phosphates), as hydrolysis of phytate's covalent P-O-C bonds or disruption of inorganic phosphate precipitate lattices typically requires more severe conditions, resulting in low phosphorus solubilization and release (Müller et al. 2015). Therefore, at 20 days of HRT, FWCS-Chem exhibited the highest P release at 29.67% as depicted in Fig. 7, demonstrating its capacity to produce biogas simultaneously with P release in the digestion tank. Thus, understanding the P mass balance informs essential management strategies, prompting adjustments of feedstock or additional treatments. It supports a systematic approach to manage nutrient sources for sustainable and efficient operation.

Fig. 6
figure 6

Daily phosphorus releasing from different HRTs and substrates

Fig. 7
figure 7

P mass balance in anaerobic co-digestion tanks from FW, FWCS, and FWCS-Chem at 20 days

In terms of P recovery and chemical precipitation, the effluent from all digesters exhibited a Mg/P ratio above 1, suitable for struvite precipitation without the requirement of adding an external source of Mg. As presented in Table 3, P content in solids ranged from 8.29% to 11.96% with a P recovery of 62.59% to 71.73%. P concentration in the effluents of FWCS and FWCS-Chem at 10-day HRT was approximately 31.98 and 35.23 mg P/L, respectively. However, these short HRTs allowed for only 62.59% to 63.81% P recovery. Conversely, 30-day HRT showed the highest P recovery ranging from 70.30% to 71.73%. This is because of the capacity of the system for releasing the organic P concentration in the supernatant. It indicated that high yields of P recovery are associated with a low organic P concentration in the effluent. Therefore, when considering biogas production and P recovery, 20-day HRT was appropriate for AcoD of FW, CS, and DS with maximum biogas production and optimal P release. Accordingly, P recovery was found to be 63.64%, 69.75%, and 70.19%, with P content in solids of 9.45%, 9.43%, and 8.29% for FW, FWCS, and FWCS-Chem, respectively (Fig. 6), comparable to commercial single superphosphate fertilizer (8.80% P).

Table 3 The economic and cost-effectiveness evaluation of anaerobic co-digestion and P precipitation

Furthermore, the X-ray diffraction (XRD) analysis revealed that the precipitating solids from the effluent of FW, FWCS, and FWCS-Chem were in the form of amorphous phases, with P content in solids ranging from 8.29 to 9.45%, as illustrated in Fig. 8a. This is likely attributed to the influence of suspended solids from the supernatant, leading to high VS and low P contents in the precipitating solids (Ye et al. 2018). As presented in Fig. 8b, the precipitating solids were incinerated at 550 °C to determine the volatile fraction converted into fixed phosphorus solids (Zeng et al. 2021). The XRD patterns revealed participation in the formation of hydroxyapatite and struvite precipitates, resulting in an increase in the percentage of P content, reaching approximately 64.23%, 73.06%, and 96.74% for FW, FWCS, and FWCS-Chem, respectively. These represent roughly twice the volatile solids lost, as illustrated in Fig. 8c. The findings from this study suggest that incinerating the precipitates could improve the final product of P fertilizer for commercial use, yielding high-quality P in solids up to 15.52%, 16.32%, and 16.31% for FW, FWCS, and FWCS-Chem, respectively.

Fig. 8
figure 8

XRD patterns of (a) total precipitating solids (TS) and (b) fixed precipitating solids (FS) after incineration, and (c) percentage of FS and VS, and P in solids content of TS and FS from anaerobic co-digestion effluent at 20-day HRT

Cost evaluation of biogas production and phosphorus recovery

The cost evaluation involves a comprehensive analysis of the positive and negative impacts of technology across various aspects. This ensures that the introduction and utilization of technology are approached thoughtfully, balancing potential benefits against any associated risks or drawbacks in its adoption. The economic and cost-effectiveness evaluation of the technology used in AcoD for biogas production and the chemical precipitation process to convert P back into fertilizer for cultivation involved calculating the amount of chemicals used in the reaction, the quantity of electricity consumed in the process, and the monetary value of the products (recycled phosphorus fertilizer and biogas). This assessment aimed to estimate the economic value associated with the operation of the reaction tank. The results were presented as cost per unit of product and the return rate in project operation, extensive operational costs, electricity expenses, and chemical costs for FW, FWCS, and FWCS-Temp tanks—which had similar expenses. However, the FWCS-Chem tank incurred additional costs for HCl chemicals used for pH adjustment after the 5% NaOH pre-treatment of CS. Additionally, the fertilizer cost was calculated based on the %P content in solids produced with the price of SSP (16-20-0) being 8.8% P and the selling price of 0.646 USD/kg (OEA 2022).

Based on the experiment of FW, FWCS, FWCS-Chem, and FWCS-Temp for anaerobic co-digester as presented in Table 3, it was found that the FW tank with a 20-day HRT had the highest positive outcome at + 0.669 USD/m3, following by FWCS tank with a 20-day HRT which showed the economic profit of + 0.606 USD/m3, contributing to the highest cumulative biogas production. The most negative outcome was -2.225 USD/m3 in the FWCS-Chem tank with a 10-day HRT, due to reduced biogas production efficiency, while costs operation remained the same. In the overall assessment of the economic and cost-effectiveness, it was observed that the highest cost was contributed from chemical expenses (NaOH and HCl) for pre-treatment of CS and neutralization before feeding into the AcoD. Although the chemical pre-treatment (FWCS-Chem) enhanced the efficiency of the AcoD process, resulting in the highest biogas production at HRT 20 days, it was evident that the 5% NaOH for chemical pre-treatment would be deemed economically unviable since its cost would surpass the energy and fertilizer produced. Then, in cases of requirement for chemical pre-treatment, it might have been required to adjust the NaOH concentration to decrease the neutralization agent, or an alternative to replace HCl chemical must be explored in future studies. Adding HCI acid to adjust pH incurs higher costs compared to co-digesting with FW; however, co-digestion with FW is not effective in managing pH. According to several studies, the low market price of mineral phosphorus makes it unfeasible to profit solely from P recovery from sewage sludge (Mayer et al. 2016). In the general process of phosphorus chemical precipitation, a source of Mg is typically to enhance the efficiency of chemical precipitation (Bradford-Hartke et al. 2021). In this research, the effluent from all anaerobic co-digesters had an Mg/P ratio exceeding 1, which was sufficient for the struvite (NH₄MgPO₄·6H₂O) reaction. Therefore, there would have been no cost associated with MgCl2 and sea salt. If introduced, the cost would have risen to 32.901 USD/kg for MgCl2·6 H₂O and 0.461 USD/kg for sea salt (Table 3). As a result of non-negligible operating and chemical costs, P recovery from wastewater sludge with high economic value, such as struvite and vivianite, is considered unprofitable (Daneshgar et al. 2019). Contrastingly, Xie et al. (2023) found that the most socio-economically feasible method was to recover struvite as P fertilizer from sewage sludge. Using sea salt proved to be an efficient option for P recovery in cases where the effluent used for precipitation lacked sufficient Mg concentration (Pinatha et al. 2020). Simultaneously developing AcoD for biogas production and P recovery technologies enhances the economic feasibility and applicability of utilizing FW, CS, and DS. This approach not only brings economic and energy benefits but may also lead to lower and more competitive prices for P recovery products in the market.

Conclusions and recommendations

This research examined anaerobic co-digestion of FW, CS, and DS for biogas production and P recovery. Co-digesting FW/CS achieved a suitable C/N ratio for efficient biogas production. DS with a high P content served as a valuable P source, allowing P release as PO43− for chemical precipitation. At a 20-day HRT, FWCS-Chem demonstrated the highest biogas yield (31.34% and 34.73% higher than FW and FWCS) and P release. However, the 10-day FWCS-Chem showed reduced biogas efficiency despite economic benefits. FWCS-Temp inhibited biogas production at 10 and 20-day HRTs. The digesters' effluent had Mg/P > 1, suitable for struvite precipitation without external Mg. P recovery in solids ranged from 62.59 to 71.73% with 8.29–11.96% P content, comparable to commercial fertilizers. Incinerating the precipitates could produce high-quality P fertilizers. A 20-day HRT was optimal for maximizing biogas, P recovery and net profit. A 10-day HRT proved to be a suitable option for required disposal of FW and CS, allowing for increased feeding frequency, reduced time, and still achieving the highest daily biogas production. Findings support the government's Bio-Circular-Green Economy models for sustainable economic growth.

Based on the findings of this work, soluble COD (SCOD) is an important parameter to identify the effect of pre-treatment on the hydrolysis. Therefore, it is recommended to analyze SCOD in both mono and mixed feedstocks in further studies for examining the impact of pre-treatment on biogas production and P release.