## Abstract

Nitrogen-doped graphene (NG) has attracted increasing attention because its properties are significantly different to pristine graphene, making it useful for various applications in physics, chemistry, biology, and materials science. However, the NGs that can currently be fabricated using most experimental methods always have low N concentrations and a mixture of N dopants, which limits the desirable physical and chemical properties. In this work, first principles calculations combined with the local particle-swarm optimization algorithm method were applied to explore possible stable structures of 2D carbon nitrides (C_{1−x}N_{x}) with various C/N ratios. It is predicted that C_{1−x}N_{x} structures with low N-doping concentration contain both graphitic and pyridinic N based on their calculated formation energies, which explains the experimentally observed coexistence of graphitic and pyridinic N in NG. However, pyridinic N is predominant in C_{1−x}N_{x} when the N concentration is above 0.25. In addition, C_{1−x}N_{x} structures with low N-doping concentration were found to have considerably lower formation energies than those with a high N concentration, which means synthesized NGs with low N-doping concentration are favorable. Moreover, we found the restrictions of mixed doping and low N concentration can be circumvented by using different C and N feedstocks, and by growing NG at lower temperatures.

## Introduction

Due to its high carrier mobility of more than 1.5 × 10^{4} cm^{2} V^{−1} s^{−1} at room temperature, graphene is a promising material for future high-speed transistors^{1}. However, graphene field-effect transistors cannot be turned off effectively because they do not have a bandgap^{2}. Heteroatom doping provides a promising approach to tune and control the electronic properties of graphene, in the same way that it is applied in electronics using silicon materials^{3,4,5}. N atoms have similar atomic radii and electronegativity to C atoms, and thus are widely used to dope graphene. Compared with C, N has an additional electron and can hence be used as an electron donor, allowing graphene to be transformed into an n-type semiconductor and have an increased carrier density^{6}. Therefore, N-doped graphenes (NGs) are expected to be preferable to graphene for many applications in electronic devices.

Unfortunately, doping graphene with N atoms in a controllable manner is difficult. Firstly, the doping concentration of N in graphene is usually very low (Supplementary Table 1). Although various methods such as chemical vapor deposition^{7}, thermal annealing^{8}, pyrolysis^{9}, arc discharge^{10}, hydrothermal synthesis^{11}, and plasma treatment^{12} have been widely applied for the N doping of graphene, none of these methods can yield NG with an N concentration higher than 0.2, except for the carbon-nitride materials synthesized from specific aromatic hydrocarbon molecules. Such a low doping concentration greatly limits the control of the carrier concentration in NG. The second challenge for NG fabrication is preventing the doping of N as a mixture of graphitic, pyridinic, and pyrrolic N configurations, resulting in stronger scattering of the carriers during their transport and thus greatly reducing carrier mobility. To prepare NG with a desirable N configuration and concentration, it is essential to understand the conditions that promote the low doping concentration of N, as well as mixed doping types. Several studies have been undertaken to understand the formation of NG. Xiang et al. found that the effective nearest-neighbor interaction between N dopants is highly repulsive because of the strong electrostatic repulsion between N atoms, and this explains why complete nitrogen–carbon phase separation does not occur in NG^{13}. Shi et al. have studied the N-doping limitations of NG and found that the largest achievable graphitic N-doping concentration in NG is 0.333–0.375^{14}. Feng et al. further investigated the most stable structures of two-dimensional (2D) NG with higher N concentration and found that the 2D NGs can be stabilized at high N concentration although structures with lower N concentration are energetically more favorable^{15}. Until now, the inherent reason for the observed doping concentration and type of N in NG has been unclear, despite previous reports.

In this work, we systematically studied the stable structures of carbon nitride with different C/N ratios (C_{1−x}N_{x}, 0 < *x* < 1), based on the particle-swarm optimization (PSO) algorithm^{16} and density functional theory (DFT) calculations. It is found that C_{1−x}N_{x} structures with lower N concentrations (or small *x* values) exhibit lower formation energies and thus are more thermodynamically stable with reference to the chemical potentials of C in graphene and N in N_{2}. In addition, we found that graphitic N and pyridinic N in 2D C_{1−x}N_{x} structures have comparable formation energies at low N-doping concentrations. This explains current experimental observations that 2D carbon nitride films consistently exhibit lower doping concentrations in which graphitic and pyridinic N-doping coexist. With the increase of doping concentration, 2D C_{1−x}N_{x} structures become dominated by pyridinic N due to a significant increase in repulsive interactions between graphitic N atoms, which leads to transformation from a composition with mixed graphitic and pyridinic N to porous structures with only pyridinic N. Further, we found that the concentration of N in C_{1−x}N_{x} can be regulated by adjusting the feedstock used in the fabrication because this changes the chemical potential of the C or N. By appropriately modulating the chemical potential of the C and N atoms or decreasing the growth temperature, C_{1−x}N_{x} with high N concentration can be obtained. 2D C_{1−x}N_{x} structures with different N concentrations have unique electronic properties and are expected to have applications in many fields.

## Results and discussion

### Effect of N type and concentration on C_{1−x}N_{x} stability

Generally, there are three bonding configurations that appear in the NG lattice. As described by Wang et al.^{17}: (1) a graphitic N atom is an N atom that replaces a C atom in the graphene lattice and bonds with three other adjacent C atoms in the hexagonal ring; (2) a pyridinic N bonds with two C atoms at the edges or defects of graphene and contributes one p electron to the π system; and (3) a pyrrolic N contributes two p electrons to the π system, though this is not restricted to a five-membered ring, as in pyrrole. Comparing these nitrogen types, pyridinic N and graphitic N are *sp*^{2} hybridized and pyrrolic N is *sp*^{3} hybridized. To determine the probability of producing different N configurations in NG, we calculated their formation energy per N atom. Firstly, we define the total formation energy of the structure, *E*_{f}(C_{1−x}N_{x}; *Gr*, N_{2}) as

where \(E_{{\rm{C}}_{1 - x}{\rm{N}}_x}\) is the free energy of C_{1−x}N_{x}, \(\mu _{{\rm{C}}(Gr)}\) is the chemical potential of C in perfect graphene and \(\mu _{{\rm{N}}({\rm{N}}_2)}\) is the chemical potential of N in N_{2} (for details see Supplementary Note 1). In general, this is dependent on the temperature and partial pressure of N_{2}, but we consider the system at 0 K first. Figure 1 shows the calculated values of \(E_f({\rm{C}}_{1 - x}{\rm{N}}_x;Gr,{\rm{N}}_2)\) for various values of *x* at 0 K. In each structure, the doping percentage of N is limited to less than 1 at% (*x* < 0.01) to minimize the interactions between the neighboring N dopants. Figure 1 shows that graphitic and pyridinic N in a hexagonal pore have much lower formation energies (~3 eV per N atom) than the pyrrolic pore (~1 eV per N atom). The lower formation energies indicate that graphitic and pyridinic N have higher probability of forming (based on thermodynamic considerations), therefore only graphitic and pyridinic N in a hexagonal pore (pyri-N-3) were considered in the following NG structural search.

Graphitic N–N pairs in NG are reported to be unfavorable due to the strong electrostatic repulsion between N atoms^{13}. This effect also prevents complete nitrogen–carbon phase separation and leads to the formation of carbon-nitride materials. To search for the most stable structures of graphitic NG (C_{1−x}N_{x}) in various N concentration ranges, we calculated the nearest-neighbor interaction between N dopants. A 12 × 12 supercell of graphene is used to calculate the interaction between two graphitic N atoms in the results presented below. Larger supercell sizes were found to give similar results. As shown in the inset of Fig. 2a, the honeycomb lattice of graphene can be considered to consist of two interpenetrating triangular sublattices: sublattice A and sublattice B. We consider the interaction between an N atom at an arbitrarily chosen site (labeled as 0A) and those at other sites that have different interaction distances to the 0A N atom. The pair-interaction energy (*E*_{p}) between N atoms is calculated by Eq. (1), where each C_{1−x}N_{x} structure contains only two N atoms. The calculated values of *E*_{p} for N atoms within an interaction range of 6.5 Å are plotted in Fig. 2a and shown as a function of the N–N distance. It can be seen that *E*_{p} increases with the shortening of the N–N distance, especially when the distance is less than 3 Å (or 0A–3B in Fig. 2a). Two local minima, the 0A–3B and 0A–7B pairs, were identified in the calculated energy curve, which is consistent with a previous report which also found these two local minima^{13}.

Since there is no N–C phase separation in NG, it seems likely that we can construct C_{1−x}N_{x} superstructures with uniform distributions of N dopants. Figure 2b shows the calculated formation energies of the most stable structures of C_{1−x}N_{x} 2D materials with different N/C ratios. These structures and the values of the formation energies are shown in Supplementary Fig. 1. Figure 2b clearly shows that the formation energies of the C_{1−x}N_{x} materials increase with N concentration. The most stable structure of each C_{1−x}N_{x} (*x* < 0.25) is mainly composed of 0A–3B and 0A–7B N–N pairs that have low pair interaction energies (Supplementary Fig. 2), demonstrating that the N–N pair interaction plays an important role in determining the structures of C_{1−x}N_{x} (*x* < 0.25). For C_{1−x}N_{x} structures with *x* > 0.25, the formation energies increase dramatically with the N concentration because of the short distance and hence strong repulsion of the N–N pairs.

C_{1−x}N_{x} structures composed of pyridinic N are also considered in our calculations since pyridinic N has a similar formation energy to that of graphitic N at low doping concentration (Fig. 1). Unlike graphitic N-dopants, which preserve the honeycomb structure of graphene, doping of pyridinic N in graphene leads to porous C_{1−x}N_{x} structures where each edge of the pore is composed of N atoms. Figure 3a shows the formation energies of pyridinic N in hexagonal pores. To test for a pore-size effect, the number of N atoms at the edge is increased from 1 to 4. It is clear that the formation energy of pyridinic N increases with pore size, demonstrating that it is more energetically favorable to have pyridinic N in small pores. Using the smallest hexagonal pore as a building block, we can construct C_{1−x}N_{x} superstructures with a uniform distribution of hexagonal pores. As shown in Fig. 3b, a series of superstructures with different pore densities are constructed by reducing the distance between the pores. This also leads to an increase in the N concentration. From the calculated energy curve of Fig. 3b, we can clearly see that the formation energies of the porous structures increase with N concentration. This prevents the formation of large pores and produces graphite materials with pyridinic N structures that have uniformly spaced small pores. It should be noted that only C_{1−x}N_{x} structures with N concentrations up to 0.5 are considered, since the structures with higher N concentration involve both pyridinic and graphitic N and will be discussed later.

To understand the formation probability of observing graphitic and pyridinic N in NG, we compared the formation energies of the most stable C_{1−x}N_{x} structures with graphitic or pyridinic N. The N concentration of the C_{1−x}N_{x} structures was varied from 0 to 0.5. The local PSO algorithm was used to search all the stable structures of 2D C_{1−x}N_{x} (Supplementary Fig. 4). It is worth noting that the structure search for hexagonal pyridinic N with very low N-doping concentration requires large lattice parameters, which is not easily achievable using PSO algorithm searching. Therefore, all the pyridinic N structures with low N concentration were constructed manually and optimized using DFT calculations (Supplementary Fig. 5). Figure 4a and b show the formation energies and the most stable structures with graphitic N or pyridinic N in hexagonal pores. It shows that graphitic N and pyridinic N have formation energies that are within ~0.1 eV atom^{−1} at very low N-doping concentrations (<0.08, which is shown as Region-I in Fig. 4a). When the doping concentration of N increases (Region-II shown in Fig. 4a), the pyridinic NG becomes more energetically favorable than graphitic NG. This means the increased N-doping concentration can increase the formation probability of pyridinic N. When the N concentration is higher than 0.25 (Region-III shown in Fig. 4a), the energy difference between graphitic and pyridinic N becomes much larger (>0.1 eV atom^{−1}), which means the C_{1−x}N_{x} structures with high N concentration predominantly contain pyridinic N. Interestingly, further calculations demonstrate that the coexistence of pyridinic and graphitic N in 2D C_{1−x}N_{x} decreases the formation energies of these structures (Supplementary Figs. 6 and 7). In particular, we found that g-C_{3}N_{4} (*x* = 0.57), which consists of pyridinic and graphitic N (Supplementary Fig. 8), has lower formation energy than CN (*x* = 0.50) which is composed of pyridinic N only, demonstrating that co-doping of pyridinic and graphitic N in 2D C_{1−x}N_{x} is beneficial to the energetic stability of the structure. This is consistent with numerous previous experimental observations that show pyridinic and graphitic N coexist in NG with low doping concentrations^{7,18,19} (Supplementary Table 1), and particularly with the stability of experimentally synthesized g-C_{3}N_{4}, which contains both graphitic and pyridinic N^{18}.

Figure 4a also demonstrates that formation of NG with low doping concentration is more thermodynamically favorable than those with high doping concentrations, and this is consistent with the fact that the experimentally synthesized NGs typically have very low N-doping concentrations^{19}.

Of all the structures considered, C_{3}N (*x* = 0.25 for graphitic N structures) demonstrate enhanced stability because their formation energies are the local minimum of the energy curves. The enhanced stability of C_{3}N composed of graphitic N can be attributed to the existence of 0A–3B N–N pairs, which we have demonstrated to be stable (Supplementary Fig. 2), and the high symmetry of the structure^{13}. It should be noted that the graphitic N-doped C_{3}N (*x* = 0.25) has already been synthesized and characterized in recent experiments^{20,21}. Experimentally, pyrrolic N has also been widely observed in NG as a defect. To compare with experiments, we also considered the effect of pyrrolic N on the formation energy of NG structures. It is found that the existence of a small concentration of pyrrolic N in NG greatly increases the formation energy of the 2D C_{1−x}N_{x} structures. (Supplementary Figs. 6 and 7). The addition of pyrrolic N into the NG structures containing only pyridinic N or both pyridinic and graphitic N leads to an increase of the formation energy. This demonstrates that pyrrolic N is not energetically favorable in NG, and the experimentally observed pyrrolic N in NG may be attributed to the formation of pyrrolic N at the edges of the structures. Moreover, we studied the formation of pyrrolic N in the experimentally synthesized C_{2}N (Supplementary Fig. 9) and g-C_{3}N_{4} (Supplementary Fig. 10). Similarly to the 2D C_{1−x}N_{x} structures discussed above, the formation energies of both C_{2}N and g-C_{3}N_{4} increase with addition of pyrrolic N defects. Considering systems with the same proportion of pyrrolic N defects, but in different positions, C_{2}N (or g-C_{3}N_{4}) with large distances between the defects leads to a lower formation energy of the structure. (Supplementary Figs. 9 and 10). Furthermore, for g-C_{3}N_{4} with high defect concentrations of pyrrolic N, the strain introduced by addition of the defects is so high that it causes the C–N bond to break in the calculations, and this reduces the formation energy of the system (Supplementary Fig. 10).

### Regulation of the structure of C_{1−x}N_{x}

The calculations of formation energies above are with reference to *μ*_{C(Gr)} for C in graphene and \(\mu _{{\rm{N}}({\rm{N}}_2)}\) for N in N_{2} at 0 K. Since the chemical potential of C and N will vary with temperature, partial pressure of the feedstock and the type of feedstock, the formation free energies can be tuned by changing these parameters^{22,23}. A general expression for the formation energy is given by Eq. (S20) of Supplementary Note 1. Figure 5a and b show how the formation free energies of NG change with change in *μ*_{C} and *μ*_{N} due to change in the feedstock, at fixed temperature and pressure. Figure 5a shows the results obtained when *μ*_{C} is fixed at the chemical potential of a C atom in graphene at 0 K and *μ*_{N} is increased from 0 to 1.0 eV. In this case, the formation energies of the C_{1−x}N_{x} structures decrease, and the effect is greatest when the structures have high N concentrations as the formation energy is dependent on *x* (Eq. (1)). This means that C_{1−x}N_{x} structures with high N concentration become more energetically favorable than those with low N concentration when the chemical potential changes by about 0.5 eV. However, if *μ*_{N} is kept constant at the chemical potential of an N atom in N_{2} and *μ*_{C} is increased (Fig. 5b), the formation energies of C_{1−x}N_{x} structures decrease, but structures with low N concentrations have a more substantial reduction in energy. Therefore, C_{1−x}N_{x} structures with low N-doping concentration become much more energetically favorable than structures with high N-doping concentration, which finally leads to the production of C_{1−x}N_{x} materials with a higher percentage of graphitic N. To increase the proportion of C_{1−x}N_{x} materials with higher concentrations of N, a feedstock with a lower value of *μ*_{C} than graphene would need to be selected.

In experiments, the chemical potential of C and N atom in different feedstocks (defined in Eqs. (S2) and (S3) of Supplementary Information) can be calculated at different temperatures and pressures. The chemical potential of C in C_{m}H_{n} (*m* and *n* are integers), \(\mu _{{\rm{C}}({\rm{C}}_m{\rm{H}}_n)}\), is given by

where *G* is the free energy, *T* is the temperature, *P*_{X} is the partial pressure of *X*, *P*^{0} = 0.1 MPa is the standard pressure, \({\Delta}_fG_X^0(T)\) is free energy of formation of *X* at standard pressure, and \({\Delta}_TG_X(T) \equiv G_X(T) - G_X(0)\), (see Supplementary Information).

Similarly, \(\mu _{{\rm{N}}({\rm{N}}_k{\rm{H}}_l)}\) is given by

The differences in chemical potential of C and N in the feedstock and that in graphene or nitrogen at 0 K can be defined as

respectively, and values 0 K for a number of feedstocks are given in Supplementary Table 2. Using these definitions, the free energy for the formation of C_{1−x}N_{x} at temperature of *T*, and pressure of *P*, from C_{m}H_{n} and N_{k}H_{l}, *E*_{f}(C_{1−x}N_{x}; C_{m}H_{n}, N_{k}H_{l}, *T*, *P*), can be expressed as

where we assume that the thermal contribution to the free energy of carbon in graphene equals the thermal contribution to the free energy of C_{1−x}N_{x} (details can be found in Supplementary Information).

Based on the calculated Δ*μ*_{C} and Δ*μ*_{N} in different feedstocks with typical experimental temperatures and pressures (Supplementary Table 3, *T* = 1300 K, *P*_{0} = 0.1 MPa, \(P_{{\rm{H}}_2} = P_{\rm{feedstock}} = 10^{ - 6}\,{\mathrm{MPa}}\)), the formation energies of C_{1−x}N_{x} can be calculated. Figure 5c shows the effect of different N feedstocks, when CH_{4} is used as the C feedstock. The N feedstocks considered are N_{2}, NH_{3}, and N_{2}H_{4}. It is clear that N_{2} favors the formation of C_{1−x}N_{x} with low N concentration, whereas N_{2}H_{4} enhances the formation probability of C_{1−x}N_{x} with high N concentration. Figure 5d shows the effect of different C feedstocks, when NH_{3} is used as the N feedstock. The C feedstocks considered are CH_{4}, C_{2}H_{4}, and C_{2}H_{2}. We can see that use of C_{2}H_{2} makes the free energy curve flatter than with CH_{4} or C_{2}H_{4}. This means the formation of C_{1−x}N_{x} with high N concentration and pyridinic N is more likely in this case. These predictions are consistent with previous experimental observations. For example, Wei et al. found that using CH_{4} and NH_{3} as the feedstock, the synthesized NGs have both pyridinic and graphitic N^{24}, while Luo et al. observed the synthesized NGs were composed purely of pyridinic N by changing the feedstock to C_{2}H_{4} and NH_{3}^{25}.

Equations (2) and (3) demonstrate that the growth temperature can also be used to tune the structures of C_{1−x}N_{x} by changing the chemical potential of C and N. This is demonstrated in Fig. 5e where the effect of temperature on a system with CH_{4} and NH_{3} feedstock and typical experimental pressures is shown. Higher temperatures lead to the production of C_{1−x}N_{x} with an increased percentage of graphitic N and decreased N-doping concentration. This has been observed in a previous research where the percentage of graphitic N increases with the temperature, and the N concentration of the NG decreases with the temperature^{26,27}. For example, Zhang et al. and Guo et al. synthesized NG with high N concentration and quite precise doping at low temperatures, and they found the samples contain abundant pyridinic N^{28,29}. The pressure also has significant effect on the formation energies of the C_{1−x}N_{x} structures. Compared with the case where the partial pressures of H_{2}, C and N feedstocks are fixed as 10^{−5} bar (black line + circle in Fig. 5f), decreasing the pressure ratio of C feedstock and H_{2} (\(P_{\rm{C}}/P_{{\rm{H}}_2}\) = 0.1, blue line + triangular in Fig. 5f) results in smaller slope of the line, which means the formation of C_{1−x}N_{x} structures with high N-doping concentration and more pyridinic N. However, increasing the pressure ratio of C feedstock and H_{2} (\(P_{\rm{C}}/P_{{\rm{H}}_2} \equiv P_{{\rm{C}}_m{\rm{H}}_n}/P_{{\rm{H}}_2} = 10\), blue line + pentagon in Fig. 5f)) promotes the formation of C_{1−x}N_{x} structures with low N-doping concentration and more graphitic N. In contrast, decreasing the pressure ratio of N feedstock and H_{2} (\(P_{\rm{N}}/P_{{\rm{H}}_2} \equiv P_{{\rm{N}}_k{\rm{H}}_l}/P_{{\rm{H}}_2} = 0.1\), red line + rectangular in Fig. 5f) favors the formation of C_{1−x}N_{x} structures with low N-doping concentration and more graphitic N, while increasing the pressure ratio of N feedstock and H_{2} (\(P_{\rm{N}}/P_{{\rm{H}}_2} = 10\), red line + star in Fig. 5f) favors the formation of C_{1−x}N_{x} structure with high N-doping concentration and more pyridinic N.

### Electronic properties of C_{1−x}N_{x}

The structure of 2D C_{1−x}N_{x} has important effect on its properties. The electronic properties of graphitic NG and pyridinic NG were studied by both Perdew–Burke–Ernzerhof (PBE) and HSE06 calculations. For 2D C_{1−x}N_{x} structures with graphitic N, most structures are metallic except C_{12}N and C_{3}N, which are semiconductors with medium band gaps (Supplementary Fig. 11). The 2D C_{1−x}N_{x} structures with pyridinic N, C_{12}N, C_{8}N, C_{6}N, and C_{10}N_{3} have the special graphene-like Dirac cone band structures, while the other structures are semiconductors with a direct bandgap (Supplementary Fig. 12). To obtain more accurate bandgaps for the C_{1−x}N_{x} structures, the HSE06 functional was used to calculate the bandgaps of C_{12}N, C_{3}N, C_{2}N, and CN, of which C_{3}N and C_{2}N have been synthesized experimentally. Table 1 shows the calculated bandgaps for these materials together with the experimental results. The results of the HSE06 calculations indicate that C_{3}N (*x* = 0.25) composed of graphitic N has a bandgap of 1.22 eV. Experimentally, the measured bandgaps of C_{3}N are highly dependent on the flake size of the materials. When the size of C_{3}N quantum dots (QDs) varies from 1.8 to 5.5 nm, the bandgap changes from 2.74 to 1.57 eV^{20,21}. The calculated bandgap of C_{2}N (*x* = 0.33), which is composed of pyridinic N, is 2.46 eV, and the experimentally measured bandgaps are between 1.69 and 2.8 eV when the size of C_{2}N QDs changes from 3.8 to 4.8 nm^{30,31}. The HSE06 calculations demonstrate that C_{12}N (*x* = 0.08) composed of graphitic N has a bandgap of 0.99 eV and CN (*x* = 0.50) composed of pyridinic N has a bandgap of 3.46 eV (Table 1 and Supplementary Fig. 13).

In addition, we found the carrier mobilities, μ_{2D}, of structures composed of graphitic N (e.g., C_{3}N) are much higher than the structures composed of pyridinic N (e.g., C_{2}N), (see Supplementary Note 2, Table 2, and Supplementary Fig. 14). These studies demonstrate that controlling the structure of C_{1−x}N_{x} is an important way to obtain carbon-nitride materials with desired properties.

In conclusion, by comparing the formation energies of graphitic and pyridinic N under different N concentrations, we found that graphitic and pyridinic N have similar formation energies in structures with low N-doping concentration. However, increasing the N-doping concentration leads to a high probability of formation of C_{1−x}N_{x} composed of purely pyridinic N. The low N-doping concentration of graphene in previous experiments can be attributed to the low formation energies of NG with low N concentration. Our theoretical calculations demonstrate that the doping concentration can be tuned by choosing the feedstock and growth temperature and pressure.

## Methods

### Structure searching

The structures of C_{1−x}N_{x} for various values of *x* were predicted using the local PSO algorithm, as implemented in the crystal structure analysis by particle swarm optimization software^{16}. Structure prediction was for a fixed cell of C_{1−x}N_{x} with no more than 30 atoms and the population size is set to 30. For each step of the searching simulation, 80% of the predicted structures passed to the next step the other 20% of the structures were randomly generated. The structural searching simulations for each system were stopped after ~35 generations (1050 generated structures). Based on the PSO search results, ten to fifteen different structures of each C_{1−x}N_{x} were selected for further structural relaxation using DFT calculations as implemented in Vienna ab initio simulation package^{32,33}.

### First-principles calculations

For the DFT calculations, the projector-augmented-wave method was used to mimic the ionic cores^{34,35}. The generalized gradient approximation (GGA) with the PBE exchange-correlation function was used with the plane-wave cutoff energy set at 400 eV for all calculations^{36}. The bandgaps of the C_{1−x}N_{x} structures were obtained using the nonlocal hybrid functional (HSE)^{37}, where the percentage (known as the mixing parameter α) of the semilocal GGA exchange potential was replaced by screened Fock exchange^{36}. The space between the C_{1−x}N_{x} layers was set to be at least 15 Å to eliminate the interaction between the layers. The geometries of the structures were relaxed until the force on each atom was less than 0.01 eV Å^{−1}, and the energy convergence criterion of 1 × 10^{−5} eV was met. The Brillouin zone was represented by a Monkhorst–Pack special k-point mesh (details are given in Supplementary Note 3) for the geometry optimization of C_{1−x}N_{x} structures^{38}.

## Data availability

The data that support the findings within this paper are available from the corresponding authors upon reasonable request.

## References

Castro Neto, A. H., Guinea, F., Peres, N. M. R., Novoselov, K. S. & Geim, A. K. The electronic properties of graphene.

*Rev. Mod. Phys.***81**, 109–162 (2009).Geim, A. K. Graphene: status and prospects.

*Science***324**, 1530–1534 (2009).Martins, T. B., Miwa, R. H., Da Silva, A. J. R. & Fazzio, A. Electronic and transport properties of boron-doped graphene nanoribbons.

*Phys. Rev. Lett.***98**, 196803 (2007).Cui, T. et al. Synthesis of nitrogen-doped carbon thin films and their applications in solar cells.

*Carbon***49**, 5022–5028 (2011).Denis, P. A. Band gap opening of monolayer and bilayer graphene doped with aluminium, silicon, phosphorus, and sulfur.

*Chem. Phys. Lett.***492**, 251–257 (2010).Wang, X. et al. N-doping of graphene through electrothermal reactions with ammonia.

*Science***324**, 768–771 (2009).Lv, R. et al. Nitrogen-doped graphene: beyond single substitution and enhanced molecular sensing.

*Sci. Rep.***2**, 586 (2012).Sheng, Z. H. et al. Catalyst-free synthesis of nitrogen-doped graphene via thermal annealing graphite oxide with melamine and its excellent electrocatalysis.

*ACS Nano***5**, 4350–4358 (2011).Long, D. et al. Preparation of nitrogen-doped graphene sheets by a combined chemical and hydrothermal reduction of graphene oxide.

*Langmuir***26**, 16096–16102 (2010).Panchakarla, L. S. et al. Synthesis, structure, and properties of boron- and nitrogen-doped graphene.

*Adv. Mater.***21**, 4726–4730 (2009).Zhang, H., Kuila, T., Kim, N. H., Yu, D. S. & Lee, J. H. Simultaneous reduction, exfoliation, and nitrogen doping of graphene oxide via a hydrothermal reaction for energy storage electrode materials.

*Carbon***69**, 66–78 (2014).Shao, Y. et al. Nitrogen-doped graphene and its electrochemical applications.

*J. Mater. Chem.***20**, 7491–7496 (2010).Xiang, H. J. et al. Ordered semiconducting nitrogen-graphene alloys.

*Phys. Rev. X***2**, 011003 (2012).Shi, Z., Kutana, A. & Yakobson, B. I. How much N-doping can graphene sustain?

*J. Phys. Chem. Lett.***6**, 106–112 (2015).Feng, Y. et al. The atomic structures of carbon nitride sheets for cathode oxygen reduction catalysis.

*J. Chem. Phys.***138**, 164706 (2013).Wang, Y., Lv, J., Zhu, L. & Ma, Y. Crystal structure prediction via particle-swarm optimization.

*Phys. Rev. B***82**, 094116 (2010).Wang, H., Maiyalagan, T. & Wang, X. Review on recent progress in nitrogen-doped graphene: synthesis, characterization, and its potential applications.

*ACS Catal.***2**, 781–794 (2012).Zhou, Z., Zhang, Y., Shen, Y., Liu, S. & Zhang, Y. Molecular engineering of polymeric carbon nitride: advancing applications from photocatalysis to biosensing and more.

*Chem. Soc. Rev.***47**, 2298–2321 (2018).Xu, J. et al. 2D Frameworks of C

_{2}N and C_{3}N as new anode materials for lithium-ion batteries.*Adv. Mater*.**29**, 1702007 (2017).Yang, S. et al. C

_{3}N—A 2D crystalline, hole-free, tunable-narrow-bandgap semiconductor with ferromagnetic properties.*Adv. Mater.***29**, 1605625 (2017).Mahmood, J. et al. Two-dimensional polyaniline (C

_{3}N) from carbonized organic single crystals in solid state.*Proc. Natl Acad. Sci. USA***113**, 7414–7419 (2016).Zhang, W., Wu, P., Li, Z. & Yang, J. First-principles thermodynamics of graphene growth on Cu surfaces.

*J. Phys. Chem. C***115**, 17782–17787 (2011).Chase, M.

*NIST-JANAF Thermochemical Tables*, 4th edn. (Journal of Physical and Chemical Reference Data Monographs) American Insitute of Physics, Woodbury, NY, USA (1998).Wei, D. et al. Synthesis of N-doped graphene by chemical vapor deposition and its electrical properties.

*Nano Lett.***9**, 1752–1758 (2009).Luo, Z. et al. Pyridinic N doped graphene: synthesis, electronic structure, and electrocatalytic property.

*J. Mater. Chem.***21**, 8038–8044 (2011).Lu, Y. F. et al. Nitrogen-doped graphene sheets grown by chemical vapor deposition: synthesis and influence of nitrogen impurities on carrier transport.

*ACS Nano***7**, 6522–6532 (2013).Zhang, W., Bu, S., Yuan, Q., Xu, Q. & Hu, M. Controllable nitrogen-doping of nanoporous carbons enabled by coordination frameworks.

*J. Mater. Chem. A***7**, 647–656 (2019).Zhang, Y., Fugane, K., Mori, T., Niu, L. & Ye, J. Wet chemical synthesis of nitrogen-doped graphene towards oxygen reduction electrocatalysts without high-temperature pyrolysis.

*J. Mater. Chem.***22**, 6575–6580 (2012).Guo, D. et al. Active sites of nitrogen-doped carbon materials for oxygen reduction reaction clarified using model catalysts.

*Science***351**, 361–365 (2016).Mahmood, J. et al. Nitrogenated holey two-dimensional structures.

*Nat. Commun.***6**, 6486 (2015).Hu, X. et al. Versatile, aqueous soluble C

_{2}N quantum dots with enriched active edges and oxygenated groups.*J. Am. Chem. Soc.***142**, 4621–4630 (2020).Kresse, G. & Furthmüller, J. Efficient iterative schemes for ab initio total-energy calculations using a plane-wave basis set.

*Phys. Rev. B***54**, 11169–11186 (1996).Kresse, G. & Furthmiiller, J. Efficiency of ab-initio total energy calculations for metals and semiconductors using a plane-wave basis set.

*Comput. Mater. Sci.***6**, 15–50 (1996).Blochl, P. E. Projector augmented-wave method.

*Phys. Rev. B***50**, 17953–17979 (1994).Kresse, G. & Joubert, D. From ultrasoft pseudopotentials to the projector augmented-wave method.

*Phys. Rev. B***59**, 1758–1775 (1999).Perdew, J. P., Burke, K. & Ernzerhof, M. Generalized gradient approximation made simple.

*Phys. Rev. Lett.***77**, 3865–3868 (1996).Heyd, J., Scuseria, G. E. & Ernzerhof, M. Hybrid functionals based on a screened Coulomb potential.

*J. Chem. Phys.***118**, 8207–8215 (2003).Monkhorst, H. J. & Pack, J. D. Special points for Brillouin-zone integretions.

*Phys. Rev. B***13**, 5188–5192 (1976).

## Acknowledgements

This work was financially supported by the National Natural Science Foundation of China (Grant No 21673075) and the Australian Research Council through the Discovery Early Career Research Program (DE170101403). This research was undertaken with the assistance of the ECNU Multifunctional Platform for Innovation (001) from East China Normal University, Shanghai Supercomputer Center, the University of Queensland Research Computing Center (RCC) using their Tinaroo high-performance computer cluster, the NCI National Facility at the Australian National University, and the PAWSEY Supercomputing Centre located in Western Australia using their Magnus high-performance computer cluster.

## Author information

### Authors and Affiliations

### Contributions

S.B. and N.Y. contributed equally to this work. S.B. and N.Y. performed the calculations. Q.Y. and D.J.S. conceived the idea and wrote the paper. All authors analyzed the results and revised the paper.

### Corresponding authors

## Ethics declarations

### Competing interests

The authors declare no competing interests.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Supplementary information

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Bu, S., Yao, N., Hunter, M.A. *et al.* Design of two-dimensional carbon-nitride structures by tuning the nitrogen concentration.
*npj Comput Mater* **6**, 128 (2020). https://doi.org/10.1038/s41524-020-00393-5

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s41524-020-00393-5