Simultaneous Electrochemical Nutrient Recovery and Hydrogen Generation from Model Wastewater Using a Sacrificial Magnesium Anode

We have demonstrated the feasibility of struvite production coupled with hydrogen generation for nutrient recovery. Electrochemical struvite was precipitated at low pH from a magnesium anode, eliminating the need for chemical additives and their associated costs. A faradaic efﬁciency (FE) near 30% was achieved while hydrogen was simultaneously produced with a FE near 40%. With the co-generation of two valuable products, costs for the electrochemical process are offset to help increase the feasibility of struvite production. We have also demonstrated control over the ﬁnal product composition to form either an ammonia or an ammonia- free magnesium phosphate (struvite or newberyite, respectively). High temperatures decompose struvite to newberyite in the ﬁnal product; however, at intermediate temperatures, competition between migration and convection dictates product composition. Under convection-dominating regimes, struvite is formed while newberyite forms under migration-dominating regimes. Identiﬁcation of these parameters controlling product composition increases adaptability of the process by enabling customization of N:P ratios to serve a variety of different farming environments. a Hach kit the and a FTIR was performed a Thermo with Germanium attenuated total reﬂectance tip with 512 the Electrochemical The electrochemical corrosion studies were performed with the same reactor setup as described above using a Gamry Reference 600 potentiostat (Gamry Instruments Inc., and an Ag/AgCl reference electrode. The Gamry Echem An- alyst 7.02 software package was used for data analysis and ﬁtting. The corrosion current was obtained by performing a non-linear chi- squared minimization to ﬁt the Tafel data to the Stern-Geary equation with four adjustable parameters: corrosion current I corr , open circuit voltage E corr , and the anodic and cathodic Tafel slopes, β a , β c , re- spectively. The potentiodynamic polarization (PDP) curves were obtained by sweeping the electrode potential from − 2.0 to − 1.2 V versus open circuit potential at a scan rate of 0.5 mV s − 1 . Electrochemical impedance spectroscopy (EIS) was performed with the same reactor setup after 30 min of OCV, and after 1, 2, or 3 hours of polarization with 10 mA of applied current. EIS scans were performed with an AC amplitude of 10 mV In this work, we investigated the simultaneous production of stru- vite, struvite derivatives, and hydrogen from wastewater. By using a sacriﬁcial magnesium anode, no chemical additives were required, with struvite precipitating despite the low pH with a FE of 29% and with a hydrogen FE of 42%. These results show that both struvite and hydrogen can be generated in reasonable quantities in order to proﬁt from two valuable products for the same energy input. We also demonstrated that the ﬁnal composition can be controlled by modifying temperature and ﬂow conditions; higher temperatures stimulate struvite decomposition into newberyite, a magnesium phosphate. The formation of newberyite separates nitrogen from phospho-rusintoaliquidandsolidphase,respectively.ThisseparationofferstheabilitytoﬁnelycontrolN:Pratiosintheendproductbyrecombinationofliquidammoniawithsolidnewberyiteintailoredquantities.Atinter-mediatetemperatures,ﬂowregimesalsocontrolthisseparation.Whenconvectiondominatesovermigration,struviteisformedasexpected.However,whenionmigrationdominates,asinthecaseofanH-cellorslowconvection,newberyiteisformedinstead.Thus,temperaturewasdemonstratedtobethemaindeterminingfactorbetweenform-

With the booming growth of the global population comes a multitude of problems; the goal of producing enough food, clean water, and energy to feed, clean, and shelter everyone is at the forefront of today's issues. To feed over 7 billion people, farms are primarily relying on mined phosphate rock as a component of fertilizer to grow high yields of crops. 1,2 However, phosphate rock is a nonrenewable resource, and some estimates have suggested that the world's phosphate reserves will become depleted within the next 100 years. 2 In addition, due to intensive farming practices such as overapplication and inappropriate fertilizer use, high quantities of nutrients are washed away as runoff. These excess nutrients contribute to eutrophication of surface waters and cost over 2 billion dollars per year in cleanup efforts in the United States alone. 2,3 The ability to vary the nitrogen to phosphorus ratio and the nutrient species' availability is extremely desirable when applying fertilizer in order to reduce these issues. With the spatial distribution problem of both nutrient depletion in soils and over-enrichment of surface waters, there exists an opportunity to develop a process where nutrients are first recovered from wastewater prior to discharge, then are sold as a customizable renewable fertilizer. Ideally, these nutrients will be available in both a rapidly deployed and a slow-release form; the more control we can exert on the form of the nutrients (composition, phase, etc.), the more adaptable the process will be for different applications across different waste streams and farming environments.
Phosphorus and nitrogen can be recovered from wastewater in the form of struvite, a phosphate mineral. Generally, struvite precipitation occurs according to Reaction 1: where n = 0, 1, or 2 depending on solution pH. 4 Struvite has been known to spontaneously form in the pipes of wastewater treatment plants, causing flow issues. As a result of these flow assurance problems, struvite precipitation has been widely investigated so that preventative action can be taken for pipeline blockages. 2,5 Over the last two decades, interest in precipitation of struvite as a sustainable phosphorus recovery method has increased due to struvite's utility as a natural slow-release fertilizer. 6,7 Because = These authors contributed equally to this work.
* Electrochemical Society Student Member. * * Electrochemical Society Member. z E-mail: aherring@mines.edu struvite is composed of equimolar ratios of magnesium, phosphorus, and nitrogen, practical struvite precipitation requires dosing the low magnesium-containing waste streams with magnesium salts to balance the ratios of ions in solution. In addition, pH adjustment is needed as the solubility of struvite is high in acidic and neutral environments. 8,9 The need for these additional chemicals drives up the price of struvite recovery, accounting for up to 97% of process costs. 10 These costs have hindered the practicality of widespread struvite precipitation as a nutrient recovery method. Papers in the last two decades have focused on reducing these costs by finding a low-grade magnesium source as well as reviewing principles of struvite crystallization and identification of key variables such as pH or temperature that affect the crystallization process. 5,9,[11][12][13][14] Recently, efforts have been made to precipitate struvite electrochemically. 4,8,[15][16][17][18][19][20] Electrochemical struvite precipitation with a sacrificial magnesium anode does not require addition of magnesium salts since magnesium metal, which serves as the anode, participates in the reaction by providing electrons and dissolving to form magnesium ions. With the use of pure magnesium, transportation costs associated with transportation of spectator ions in magnesium salts are no longer necessary, thus improving the economics of the process. S. Ben Moussa et al. 8 confirmed the feasibility of struvite precipitation by electrolysis and found that struvite precipitation can occur in neutral environments due to a high local pH at the anode allowing for crystal struvite growth. Hug & Udert showed that electrochemical magnesium dosage was feasible for struvite precipitation from urine, with a high current efficiency and low energy consumption. 15 It was determined that the dissolution of a sacrificial magnesium electrode was cost competitive when compared to the cost of dosing with other magnesium salts. Lin et al. developed a novel technique of utilizing two chamber electrolysis to form struvite from biogas digestion slurry. 19 They achieved a 93% phosphate removal efficiency at a stable pH of 8.6 without addition of chemical reagents. Foroughi et al. combined ultrasound with electrochemical struvite precipitation to facilitate struvite production. 21 The use of ultrasound with electrochemical struvite precipitation has further been demonstrated in Wales by Soneco's Power&Water to treat slurry to 98% P removal. UK Water Industry Research, Southern Water Plc validated this Welsh case study. 20 A pilot plant utilizing electrochemical struvite technology was tested by the Fraunhofer Institute for Interfacial Engineering and Biotechnology in Germany, operating successfully for 1 year utilizing municipal wastewaters. They were able to reduce P-concentrations in domestic wastewater by 99.7% to 2 mg/L while using less than 70 W-h/ m 3 . 7,16,17 While these successes demonstrate the feasibility of the technology, further cost improvements and fundamental electrode understanding are necessary to adapt the system to the commercial scale. Recently, we have shown electrochemical struvite formation in an acidic environment with a magnesium sacrificial anode as the only source of magnesium. 4 The ability to form struvite in a wider pH range reduces the costs associated with pH adjustment and expands the types of wastewater this system can process. Furthermore, there has been little work on collecting hydrogen generated during struvite formation or on controlling N:P ratios in the final product by separating recovered phosphate ions from ammonia nitrogen. Having the ability to manipulate product composition through electrochemical separation of N and P would be of interest to expand applications of nutrient recovery and encourage appropriate fertilizer choice among differing soil compositions. There has also been limited work on the usefulness of struvite derivatives. Struvite is known to decompose into various magnesium phosphates such as newberyite or bobierite. 13,[22][23][24] These magnesium phosphates can be used to extract ammonia from wastewater by reforming struvite. Municipal and animal wastewater streams are the focus of this technology, since these streams typically have a high ratio of ammonia nitrogen to phosphorus. 25 Control over an ammonia or an ammonia-free magnesium phosphate is important as it allows customization of the product to the application, increasing the adaptability of our system for wide utilization across different types of waste streams and technologies.
To further offset costs and to encourage widespread adoption of electrochemical struvite precipitation, we consider the co-production of a value-added byproduct, hydrogen. Hydrogen was reported to evolve on the cathode during struvite production when magnesium is used as a sacrificial anode. 8,15,17,26 In addition to this potential-driven cathodic reaction, hydrogen is also produced on the magnesium surface due to magnesium corrosion. Upon exposing magnesium to aqueous electrolyte, electrochemical corrosion reactions occur at local anodes and cathodes on the surface of magnesium during dissolution. 27 According to Pourbaix, hydrogen evolution occurs at all pH's due to magnesium's high affinity to react with water. 28 Furthermore, it has been known since the mid-1800s that unusually high rates of hydrogen evolution occurs on magnesium during anodic polarization, though no definitive theory has yet been agreed upon to explain this phenomenon. [29][30][31] While these exact elementary mechanisms are still debated in the field, there is good agreement on the global corrosion reaction of Reaction 2: [32][33][34][35][36] Mg Thus, hydrogen is being generated as a byproduct of the magnesium corrosion reaction at the same time that the electrochemical struvite reaction occurs and in addition to cathodic hydrogen generation. To the best of our knowledge, no successful attempt has been made at capturing the hydrogen generated from these reactions despite the large research effort that has been made towards hydrogen energy production and storage. [37][38][39] Hydrogen has important implications in the energy industry, with the potential to serve as a clean, carbon-free energy source in a hydrogen economy. The U.S. Department of Energy has set a target of 2.30 $/kg for the levelized cost of hydrogen production by 2020, underlining the importance of cost effective hydrogen generation processes. 40 With the co-generation of both struvite and hydrogen, costs associated with struvite production can be offset by the ability to profit from hydrogen.
In this work, we have focused on optimizing design conditions for both electrochemical struvite production and hydrogen generation as well as the possibility for ammonia separation from phosphorus. Our goal was to set design rules for a more economical struvite production method that is coupled with hydrogen generation to increase feasibility of nutrient recovery from wastewater. This study focuses first on understanding the fundamentals and key parameters involved in the electrochemical reactor. To probe reactor type, two configurations were used: a simple single chamber batch reactor and a dual chamber reactor with separated anode and cathode compartments. We also investigated how a Nafion membrane can be used to separate specific ions for fine control over N:P ratios in the final product.

Materials and Methods
Materials and general methods.-All electrochemical experiments were conducted with 120 mM (13.83 g.L −1 ) ammonium dihydrogen phosphate (ADP, NH 4 H 2 PO 4 , Sigma-Aldrich, CAS: 7722-76-1). The stock solutions were prepared with Milli-Q water (EMD Millipore, Milli-Q Direct-Q 3 UV Water Purification System, MA, USA). The magnesium foil (≥99.5% Mg basis, P/N: 13103, Sigma-Aldrich) with dimensions of 2 × 0.4 cm and 0.2 mm thickness resulting in a 1.6 cm 2 active surface area, and stainless-steel plate (316SS, ATI Flat Rolled Products, PA, USA) with dimensions of 1 × 1.5 cm and thickness of 0.2 mm, were used as anode and cathode respectively. The pH and conductivity of the solution before and after each experiment were measured with a pH/conductivity benchtop multiparameter meter (Orion star A215, Thermo Scientific, MA, USA) with Orion 8157BNUMD and Orion 013005MD pH and conductivity probes, respectively. Nafion 117 was obtained from Ion Power Inc. and rinsed and stored in DI water at room temperature prior to use.

Reactor setup for electrochemical experiments.-
The electrochemical experiments were performed in either a single-chamber reactor or a dual chamber H-cell as shown in Figure 1.
The single chamber reactor consisted of a 100 mL three-necked flask with a glass sleeve surrounding the cathode enabling hydrogen collection. The dual-chamber reactor was a custom glass H-cell (Adams & Chittenden, nominal volume 15 mL in each half cell) with a Nafion 117 membrane. The reactor was placed in a water bath on a stirrer hotplate. Magnesium and 316 stainless steel were used as anode and cathode, respectively, with an Ag/AgCl reference electrode used in all studies except in the dual-chamber reactor due to size limitations. A potentiostat/galvanostat (Gamry Reference 600) was used to measure the anode potential as well as provide the applied current of 10 mA for the 3 h duration for the chronopotentiometry experiments. Open circuit potential experiments were performed at 20, 30, 40, 50, and 60 • C, while chronopotentiometry experiments were conducted at 20, 40, and 60 • C. A digital thermometer (VWR Scientific, model 100A) was also used.
After each experiment, the precipitate in the bulk solution was collected by vacuum filtration using a 1.5 μm glass microfiber filters (934-AH, Whatman, GE Healthcare, USA) followed by oven-drying at 40°C for 48 h. Solids formed on the magnesium anode were carefully scraped off, subjected to the same oven drying process as the filtrate, then weighed. In order to ensure maximum powder recovery, the filtrate was filtered through a 0.2 μm PTFE membrane syringe (Acrodisc CR 25mm, P/N: 4225T) followed by the same drying method. The oven-dried powders were weighed to estimate the recovery percentage.
Materials characterization.-The ammonia concentration in the solution was measured with a high-range (0.4-50.0 mg/L NH 3 -N) Hach standard kit using the salicylate method and a Hach DR 2800 spectrophotometer. FTIR was performed using a Thermo Scientific Nicolet iN10 infrared microscope with Germanium attenuated total reflectance (ATR) tip with 512 scans in the spectra range of 550-4000 cm −1 with a resolution of 8 cm −1 for all scans. X-ray diffraction (XRD, Siemens D500) from 10 to 40º (2θ/θ) was carried out on the solids with a scan speed of 2 degree/min at 30 kV and 15 mA followed by peak identification and analysis using Match! (Crystal Impact GbR) and Jade 9 (MDI Inc.) software. Scanning electron microscopy (SEM) images were taken of the solids formed on the magnesium anode with a FEI Quanta 600i Environmental SEM prior to their removal from the anode.
Electrochemical measurements.-The electrochemical corrosion studies were performed with the same reactor setup as described above using a Gamry Reference 600 potentiostat (Gamry Instruments Inc., USA) and an Ag/AgCl reference electrode. The Gamry Echem Analyst 7.02 software package was used for data analysis and fitting. The corrosion current was obtained by performing a non-linear chisquared minimization to fit the Tafel data to the Stern-Geary equation with four adjustable parameters: corrosion current I corr , open circuit voltage E corr , and the anodic and cathodic Tafel slopes, β a , β c , respectively. The potentiodynamic polarization (PDP) curves were obtained by sweeping the electrode potential from −2.0 to −1.2 V versus open circuit potential at a scan rate of 0.5 mV s −1 . Electrochemical impedance spectroscopy (EIS) was performed with the same reactor setup after 30 min of OCV, and after 1, 2, or 3 hours of polarization with 10 mA of applied current. EIS scans were performed with an AC amplitude of 10 mV vs E corr over a frequency range of 0.1−1×10 6 Hz.

Results and Discussion
This system is inherently complex and increases in complexity as the reaction proceeds. While the end goal of this project is to control the precipitation of solids with an additional unit operation on the reactor effluent, in the current set up, the solids are simply precipitated on the electrode and elsewhere in the system, certainly increasing the heterogeneity of the electrodes. Therefore, a number of preliminary investigations were performed to give some hope to fully characterize this system. These investigations include open circuit (OCV) experiments, chronopotentiometric experiments, and electrochemical impedance spectroscopy. Chronoamperometry was also carried out as a demonstration. We were able to attain a steady current of 11 mA by applying a potential of −1.4 V vs SHE. The flexibility of running the experiment either potentiometrically or galvanometrically shows the control we maintain over the system. OCV experiments.-Ammonia dihydrogen phosphate (ADP) solution was used as a simplified model for synthetic wastewater without pH correction. Use of this solution as the electrolyte prevented any complicating factors from foreign ions. A concentration of 120 mM was chosen to provide a conductivity of 10 mS/cm and to prevent high solution resistance from obscuring electrochemical data. This concentration leads to a slightly acidic pH of 4.2, which aides in magnesium dissolution to its +2 oxidized state as seen in Pourbaix diagrams. 28,31 To gain initial understanding of the system, open circuit experiments were conducted at varying temperatures in the single chamber reactor, and the potential change over time is displayed in Figure 2a for these open circuit measurements. For low temperatures, the system equilibrated after 10 min. After this time no further changes in potential were observed. However, at 60°C, the OCV did not stabilize until after 20 min. This longer passivation time indicates that the surface of the anode undergoes different changes at 60°C than at the lower temperatures, as discussed in more detail below. Figures 2b and 2c display how the conductivity and pH change. Even though the OCV appeared stable after 10 min, the pH and con-   ductivity of the solution continued to increase during this time frame. It is likely that while magnesium corrosion reached steady state after 10 min, the products of corrosion, namely H 2 and OH − , are still being produced. 4 Thus, the consumption of H + as a result of the corrosion process increases the pH and the production of OH − increases conductivity throughout the experiment. With the production of OH − , the speciation of phosphate will shift from H 2 PO 4 to HPO − 4 and PO 2− 4 , further enhancing struvite precipitation. In addition, the increase in temperature enhances magnesium dissolution, accelerating the corrosion reactions and contributing to the trend of increased conductivity and pH with temperature. However, the conductivity rise at 60°C was much faster than the lower temperatures, and the pH more stable. The increase in magnesium ions from enhanced dissolution at 60°C is not associated with a corresponding increase in hydroxide production as expected from the magnesium corrosion reaction. Clearly, different or additional reactions are occurring at 60°C.
To shed light on these different reactions, FTIR analysis of the solids was carried out. Figure 3 shows the infrared spectrums of the solids formed at the different temperatures and a comparison with pure commercial struvite and newberyite.
From the FTIR data, the solids formed at 40°C and below match that of struvite. However, 50°C and 60°C spectra match newberyite instead. Specifically, there is an absence of ammonium stretches at 2800-3430 and 1430 cm −1 . 41,42 Further analysis by XRD (Figure 4) confirm that at low temperatures, struvite is formed but at temperatures above 50°C, newberyite is formed. Newberyite is simply a magnesium phosphate with the formula Mg(HPO 4 )·3H 2 O. The absence of the ammonium in newberyite accounts for the missing bands observed in the FTIR spectrum of the 50°C and 60°C tests.
The particle size was calculated using the Scherrer equation from the XRD data and is shown in Figure 4b. At temperatures above 50°C, the particle size dramatically decreases, most likely due to the missing ammonium from newberyite's structure compared to that of struvite.
With the accumulation of these characterization data, it is evident that temperature is a key parameter which controls the formation of either struvite or newberyite. We surmise that initially, struvite is formed as expected, but with increases in temperature, struvite then decomposes according to Reaction 3: 22  the hydroxide ions formed from the magnesium dissolution reaction, buffering the pH. With the production of newberyite instead of struvite, ammonia nitrogen is separated from phosphorus in the liquid stream. This separation of nitrogen and phosphorus opens doors to producing a liquid ammonia fertilizer stream or recombining the liquid ammonia with struvite to control the N:P ratio of the final product to desirable quantities.
Chronopotentiometry experiments.-Based on our understanding of the struvite-newberyite formation mechanisms, we then move towards quantifying this process. Chronopotentiometry was carried out by applying 10 mA cm −2 for 3 h in a single chamber or a dual chamber reactor. Temperature was varied between 20-60°C. The faradaic efficiencies of the products in both single and dual chambers are displayed in Figure 5.
In the single chamber reactor, 40°C was the optimum temperature for the formation of both struvite and hydrogen, with a faradaic efficiency (FE) of 29% and 42%, respectively. While these yields appear low, they are underestimated since ohmic losses were not considered for the calculation. We also utilized a smaller, dual-compartment H-cell with a Nafion 117 membrane in order to facilitate separation of N and P. As Figure 5b shows, the calculated efficiency increased just over 100% with this dual-chamber configuration. In addition to the potentially driven and corrosion reactions, hydrogen is generated nonfaradaically, which is not detected by the potentiostat.
In the dual-chamber H-cell, newberyite was formed even at 40°C instead of struvite, albeit at a lower FE. In this configuration, ammonium ions migrated towards the cathode half-cell, resulting in a depletion of ammonium ions near the magnesium anode. Nafion served as a physical barrier to mixing to enhance ion depletion. This lack of ammonium ions near the anode means the ammonium could not be incorporated into the solid precipitate, leading to magnesium phosphate formation (newberyite) instead. With the membrane, the separation of N and P into liquid and solid phases was forced to occur at lower temperatures when compared to the single chamber reactor with no membrane. Thus, ion migration is a critical factor in addition to temperature for determination of final composition. To confirm this idea, the ammonia nitrogen content in the liquid phase was measured after chronopotentiometry experiments for both single and dual chamber configurations. These results are displayed in Figure 6. Initially, the concentration of ammonia nitrogen was 1620 mg/L.
In the single chamber reactor, more ammonia was found in the liquid phase as temperature increases due to the formation of newberyite at these high temperatures, as described previously. In switching to the dual chamber reactor, ion depletion occurred near the magnesium anode, causing high concentrations of ammonia in the cathode with low concentrations in the anode. Migration dominates in the H-cell since the membrane prevents complete mixing between the two compartments.
To test the idea of migration competing with convection to alter product composition, the stir rate was decreased in the single chamber reactor from 600 rpm in previous tests to 100 rpm. With this slower stirring speed, migration should dominate even in the single chamber reactor. It was found that stirring speed did not affect the solid formed at either 20°C or 60°C. However, at 40°C, reduced stirring led to newberyite formation instead of struvite. XRD of the solids formed at both stirring rates at 40°C and their corresponding particle sizes are shown in Figure 7.
Once again, formation of newberyite corresponds to the smaller particle size. With slow convection, migration can dominate in the single chamber reactor and lead to newberyite formation instead of struvite at intermediate temperatures. Thus, we have identified several key parameters which influence N and P separation; temperature serves as a switch to decompose struvite and separate ammonia into the liquid phase. However, at intermediate temperatures and in reactors where migration dominates, this separation can be forced to occur at lower temperatures. Utilization of a membrane aids in this separation.
To further understand the mechanism of these electrochemical reactions, polarization curves were generated and are shown in Figure 8, along with the corresponding anodic and cathodic Tafel slopes (β a and β c , respectively) in Table I.
The Tafel slope indicates the sensitivity of current to applied potential and is calculated for both electrodes, leading to an anodic term accounting for magnesium dissolution and a cathodic term corresponding to hydrogen evolution. However, it is known that surface films involving magnesium oxide and magnesium hydroxide form, Table I. Calculated Tafel slopes (β a , anodic and β c , cathodic)   ) 60 50 40 20 Temperature (°C) Figure 9. Corrosion rate as corrosion current at varying temperatures.
which add complexity to electron transfer processes. These surface films increase the magnitude of the Tafel slopes by acting as a passivation layer. In our data, we did observe high values of both cathodic and anodic Tafel slopes, ranging between 461 mV dec −1 to 700 mV dec −1 . These values agree in magnitude with simulated values that accounted for these surface films. 31 For magnesium in particular, it has also been shown that anodic polarization results in unusually high hydrogen evolution at the anode, termed the negative difference effect. 31 This phenomenon contributes to the different trends between anodic and cathodic slopes. In our experiments, we saw the cathodic slope decrease slightly with temperature, from 530 mV dec −1 at 20°C to 403 mV dec −1 at 50°C. However, at 60°C, the slope increased to 492 mV dec −1 . The opposite trend was true of the anodic slope, which increased with temperature from 461.9 mV dec −1 at 20°C to 700 mV dec −1 at 50°C. Then, the anodic slope decreased to 610 mV dec −1 at 60°C. The anomalous behavior at 60°C observed for the cathodic and anodic slope underlines the different processes that occur at high temperatures where struvite decomposes into newberyite. With the additional decomposition reaction, the magnesium electrode surface changes even further, contributing to the anomalous Tafel slope. From the Tafel plots, the corrosion rate was calculated and displayed in Figure 9. From these data, we once again see a distinction between low temperatures where struvite is formed and high temperatures where newberyite is formed. Generally, the corrosion current is increased at temperatures above 50°C due to the additional struvite decomposition reaction that occurs on the electrode under these conditions. For just the struvite reaction below 40°C, the corrosion rate decreases with temperature. This trend can be explained by looking at the SEM images which are displayed in Figure 10. From 20°C to 40°C, particles aggregate on the anode and these aggregations reduce the available surface area. With the reduction in surface area, less magnesium is in contact with the solution, leading to a slower dissolution rate and corresponding corrosion rate. The same trend is seen for the newberyite reactions at temperatures above 50°C.
The SEM image between 40°C and 60°C (Figures 10b and 10d, respectively) shows a drastic increase in porosity and supports the XRD data: smaller particle sizes are associated with newberyite formation versus struvite. Thus, in forming newberyite instead of struvite, the surface area is increased, allowing for a rise in corrosion and dissolution rate. We can see the transition from struvite to newberyite when comparing Figures 10c and 10d, which show the surface at 60°C after 2 h and 3 h of chronopotentiometry. The struvite solid is beginning to decompose into newberyite and the change in particle size associated with this transition can be observed.
The magnesium dissolution rate was calculated according to the following equation: where v Mg is the rate of total magnesium dissolved in solution (mg cm −2 h −1 ), m Mg is the mass of dissolved magnesium (mg), t is the time (h), and A is the active surface area of anode (cm 2 ). These results along with the magnesium recovery are displayed in Figure 11. At 40°C, the magnesium dissolution rate was low but magnesium recovery in the final product high. These results emphasize the balance that exists between hydrogen generation and nutrient recovery  20 40 60 Temperature (°C) b) Figure 11. a) Average magnesium dissolution rate during chronopotentiometry. b) magnesium recovery after 3 h chronopotentiometry, defined as mass of magnesium recovered from solids divided by mass of dissolved magnesium. since the greatest quantity of struvite production occurs at the lowest magnesium dissolution and corrosion rates. Thus, striking a balance through temperature between these two products, struvite and hydrogen, is important. The magnesium recovery, defined as mass of magnesium recovered divided by mass of dissolved magnesium, highlight 40°C as the optimal operating condition and lies in agreement with the corrosion and magnesium dissolution rate.
To further investigate how the surface varies at different temperatures, electrochemical impedance spectroscopy was carried out at 1, 2, and 3 h intervals during chronopotentiometry for 20°C, which favors struvite formation, and 60°C, which favors newberyite formation. The results are displayed in Figure 12.
With time, the impedance increases, as indicated by larger intercepts on the real axis as well as an increase in capacitance on the imaginary axis. In general, complexity increases with time and the development of three time constants are observed. The first time constant likely corresponds to the formation of struvite film, while the second time constant is attributed to charge transfer resistance for magnesium dissolution. The shape of this second time constant becomes more depressed, with the maximum on the imaginary axis increasing from ca. 10 at 0 h up to 60 after 3 h while the corresponding increases on the real axis is from ca. 50 to 380 . Depressed semicircles are indicative of constant phase elements, which arise from surface inhomogeneities. 46 The third time constant, a Warburg-like diffusion impedance, is observed most notably near 380 on the real axis after 3 h. This feature implies that the double-layer capacitance is lowered. The development of these features with time are the result of the changing surface during the experiment. As the experiment progresses, more solids are produced which accumulate on the magnesium anode, continually changing the homogeneity and morphology. These changes increase the complexity of the anode. It is difficult to accurately model these features due to the constantly changing surface, so we simply make qualitative observations from the EIS data. For 60°C, the high frequency feature is present throughout the duration of the experiment, but the impedance is lower after 3 h compared to 2 h. We see the maximum on the imaginary axis increase from 10 initially up to ca. 70 after 2 h, but then drop back down near 40 after 3h. From previous data, we know that newberyite is formed at the end of the 3 h experiment at these temperatures. The decrease in impedance between 2 and 3 hours is due to the transformation of struvite to newberyite; struvite was shown to exhibit a larger particle size than newberyite from XRD data, and this decomposition process leads to the decreased impedance observed between 2 and 3 h chronopotentiometry. The changing surface is easily seen in the SEM images. As the ammonium in struvite leaves the structure and enters the electrolyte, the conductivity is increased due to the addition of these ions, which then works to decrease the impedance.

Conclusions
In this work, we investigated the simultaneous production of struvite, struvite derivatives, and hydrogen from wastewater. By using a sacrificial magnesium anode, no chemical additives were required, with struvite precipitating despite the low pH with a FE of 29% and with a hydrogen FE of 42%. These results show that both struvite and hydrogen can be generated in reasonable quantities in order to profit from two valuable products for the same energy input.
We also demonstrated that the final composition can be controlled by modifying temperature and flow conditions; higher temperatures stimulate struvite decomposition into newberyite, a magnesium phosphate. The formation of newberyite separates nitrogen from phosphorus into a liquid and solid phase, respectively. This separation offers the ability to finely control N:P ratios in the end product by recombination of liquid ammonia with solid newberyite in tailored quantities. At intermediate temperatures, flow regimes also control this separation. When convection dominates over migration, struvite is formed as expected. However, when ion migration dominates, as in the case of an H-cell or slow convection, newberyite is formed instead. Thus, temperature was demonstrated to be the main determining factor between forming an ammonia or an ammonia-free magnesium phosphate (struvite versus newberyite, respectively) with convection playing a secondary role by affecting product composition at intermediate temperatures.
From these completed batch studies, we have identified temperature, convection, and ion migration as vital parameters for separating ammonia nitrogen and phosphorus from wastewaters. Moving forward, we aim to apply this system in a flow reactor coupled with an ion exchange membrane in order to demonstrate the process as it would run in practice (continuously). With the flow cell, we will be able to expand on these preliminary investigations and probe the ability to finely control product composition. Having the ability to tailor the magnesium phosphate composition will increase the versatility of the process, and, coupled with hydrogen generation, can reduce costs for nutrient recovery from wastewater.