Presence and absence of intrinsic magnetism in graphitic carbon nitrides designed through C–N–H building blocks

We use the first principle calculation to investigate the intrinsic magnetism of graphitic carbon nitrides (GCNs). By preserving three-fold symmetry, the GCN building blocks have been built out of different combinations between 6 components which are C atom, N atom, s-triazine, heptazine, heptazine with C atom at the center, and benzimidazole-like component. That results in 20 phases where 11 phases have been previously reported, and 9 phases are newly derived. The partial density of states and charge density have been analyzed through 20 phases to understand the origin of the presence and absence of intrinsic magnetism in GCNs. The intrinsic magnetism will be present not only because the GCNs comprising of radical components but also the π\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi$$\end{document}-conjugated states are not the valence maximum to break the delocalization of unpaired electrons. The building blocks are also employed to study alloys between g-C3N4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\hbox {C}_3\hbox {N}_4$$\end{document} and g-C4N3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\hbox {C}_4\hbox {N}_3$$\end{document}. The magnetization of the alloys has been found to be linearly dependent on a number of C atoms in the unit cell and some magnetic alloys are energetically favorable. Moreover, the intrinsic magnetism in GCNs can be promoted or demoted by passivating with a H atom depending on the passivated positions.

Various types of 2-dimensional (2D) materials have been explored their magnetism that suite for spintronics and magnetic devices. For metal-free materials, 2D organic frameworks such as triangulenes and graphitic carbon nitrides (GCNs) are candidates that possess intrinsic magnetism with high Curie temperature and high flexibility [1][2][3][4] . Organic radicals can be linked by a triazine which is a carbon-nitride ring stabilizing paramagnetic 2D organic frameworks 5 . The triangulene which is a fragment of graphene can be scaled its magnetization by increasing a size of the fragment 6,7 . It can be crystallized by connecting its edges with other chemical groups 8 . For graphene, each C atom spends 3 electrons to form σ bonds and leaves one electron forming conjugated π bond suppressing graphene's magnetism while the magnetism in triangulenes exists due to lack of π conjugation. Accordingly, the magnetism of 2D organic frameworks can be suppressed by a delocalization of electrons in π orbitals affected by compressive strain 9 .
The intrinsic magnetism in graphene can be risen by a defect producing a half-filled band of π orbitals 10 . The defects can be either voids or impurities splitting the spin-up and spin-down p z states at the Fermi level ( E F ) and inducing a magnetic moment [11][12][13][14] . One method used to create void defects in graphene is by doping N atoms where the voids are surrounded by N atoms, then N-doped graphene becomes magnetic 15,16 . Although, high doping, void, and passivation concentrations lead to phase instability limiting amounts of spin density in graphene [17][18][19] .
In this work, we focus on GCNs whose several magnetic and non-magnetic phases have been predicted. For instance, g-C 4 N 3 is a magnetic phase with one Bohr magneton ( µ B ) per unit cell 20,21 , and C 14 N 12 bears 2 µ B per unit cell of magnetization 4 . C 9 N 7 and C 10 N 9 are magnetic phases while C 3 N 2 , C 4 N, and C 9 N 4 are nonmagnetic 4,15 . Their magnetism arises from an unpaired electron contributing a magnetic moment to a system. The structure that has two unpaired electrons can be non-magnetic or magnetic depending on they are in singlet or triplet states, respectively 22,23 . Anyhow, magnetic GCNs have not yet achieved in experiments. The GCN that is typically synthesized are g-C 3 N 4 , but it is non-magnetic. It is in a form of s-triazine or heptazine networks and a candidate for photocatalysis and carbon dioxide adsorbing materials [24][25][26][27][28][29][30][31] . Some extra-treatments have been

Results and discussion
Building blocks. The building blocks are C, N, H, s-triazine (TRI), heptazine (HEP and HEC) and tetracyclic benzimidazole (BEN) components where HEC is a heptazine with C atom at the center instead of N atom (see Fig. 1). Each component will be joint with other components in three directions preserving three-fold symmetry except for H atom that will be only dangling with C and N atoms. One can think of an alloy which is a mixture of several components; however, this work is limited to study connections between two types of components where the first component is a core, and the second component is a connector. Therefore, in this study, GCNs are constructed from cores which are TRI, HEP, HEC and BEN, and connectors which are C, N, TRI, and HEP while a H atom is neither a core nor a connector but a passivating atom. GCNs are typically labeled by a tuple of numbers of C and N atoms, ( n C , n N ), in a unit cell which is sometimes ambiguous, so they are, instead, designated as core-connector, e.g. TRI-N whose common name is g-C 3 N 4 is a structure where TRI is a core and N is a connector.
By our constructions, there are 20 phases reported here; 11 phases, to the best of our knowledge, have been reported before 4,20,21,[24][25][26][27][28][29]29,[45][46][47][48][49][50][51][52] , and 9 phases which are HEP-TRI, HEP-HEP, HEC-C, HEC-HEP, and BEN-X (X = C, TRI, HEP, HEC, and BEN) are newly derived by this study (see Fig. S1 in Supplementary Information). www.nature.com/scientificreports/ meV by comparing with the energy of graphene and N 2 molecule. Noting that GCNs can be synthesized from chemical compounds, e.g., melamine, melam, and melon, so their E form would change according to precursors. Figure S2 in Supplementary Information shows that the E form seems to decrease with respect to N concentration. However, it is not a good presentation because different types of GCNs are being compared. Bu et al. 19 shows that the formation energy of N-doped graphene and GCNs with pyridinic N increase similarly with amount of N concentration up to 0.25%. The former starts increasing higher if N concentration is more than 0.3%. The structures with pyrrolic N also have formation energy higher than the structures with pyridinic N. In this work, TRI, HEP, and HEC are components with pyridinic N, while BEN is a component with pyrrolic N. The formation energy of structures with BEN component is thus higher than that of structures without BEN component. The formation energy of structures with HEP component are lower than that of structures with HEC component even HEP is a N-doped HEC. The structures with N connector are more energetically favorable than those with C connector.
TRI-TRI has the highest E form among other phases. The C-N-C angle of TRI component is ideally 120 • . It is 108.4 • in TRI-TRI while it is about 114 • to 120.5 • in other structures whose the TRI component is constituent. This angle in TRI-TRI that is much sharper than other phases may cause high strain on the structure throwing the E form of TRI-TRI to 1.368 eV.
Magnetic and electronic properties. The intrinsic magnetism in GCNs is present or absent due to combinations between cores and connectors. Table 2 presents the magnetizations of GCNs where each phase is constructed from the core and the connector labeled in each column and row, respectively. Since the core and the connector are commutable, the values below diagonal should be the same as the values above diagonal. Most phases, whose intrinsic magnetism are present, have either HEC or BEN as components except for HEC-C, BEN-C and BEN-BEN that are non-magnetic. Two more magnetic phases are TRI-C and HEP-C. The magnetism is absent in C-C, C-N, TRI-N, HEP-N and HEP-HEP where C-C and C-N are graphene and 2D honeycomb carbon nitride, respectively. Noting that N-N is a N 2 molecule, so it is disregarded.
We count a number of valence electrons, which do not form σ bonds, per unit cell ( n e ) of each phase in order to understand a key factor governing presence or absence of the intrinsic magnetism. In a honeycomb structure, a C atom covalently bonds with its three nearest atoms leaving one lone electron, while a N atom leaves two electrons which is a lone pair. In TRI, HEP, HEC, and BEN, the pyridinic and pyrrolic N atoms bonding with only two nearest atoms have n e = 3 ; therefore, TRI and HEP have even n e considered to be non-magnetic components, and HEC and BEN have odd n e considered to be magnetic components. We expect that if the n e is even, all electrons left over from σ bonding will pair together suppressing the intrinsic magnetism of the structure. In contrast, if the n e is odd, a single electron will be a free radical granting a magnetic moment. The parity of the n e of each phase is presented in Table 2 and labeled in blue if the n e is odd and yellow if the n e is even. As labeled, the GCNs are magnetic or non-magnetic if the n e are odd or even, respectively, except for C-N, HEC-HEC and BEN-HEC. The magnetic behavior of the excepted phases, in contrast, can be explained through the projected Table 1. The E form of each GCN is reported in meV per atom unit where each column and row are core and connector components, respectively. The blue-white-red colors are shaded according to the values from lowest to highest. N-N, in contrast, denotes a N 2 molecule. Table 2. The magnetization of each GCN is reported in µ B unit where each column and row are core and connector components, respectively. The parity of the n e of each phase is labeled by blue and yellow denoting odd and even, respectively. www.nature.com/scientificreports/ DOS (PDOS) and the localization of the charge density. The intrinsic magnetism of GCNs is then discussed separately for each core component in subsections below. The PDOS will be shown by types of atoms where C A and N A denote C and N atoms of the A component, respectively.
C-. Particularly, C atoms in graphene spend their three valence electrons to form σ bonds and one valence electron to form conjugated π bonds with the entire structure. Lieb 10 has shown that the net spin is not vanished if numbers of atoms in two sublattices of a bipartite lattice such as graphene are not equal. (Ovchinnikov 53 has proposed the same equation of the net spin for hydrocarbons). The theorem was validated by an existence of magnetic moment in defective and hydrogenated graphenes 13,14 . In this case, C-C is a perfect lattice graphene where the C atoms in two sublattices are equal, so it is non-magnetic. For C-N (equivalent to N-C in Table 2) which also has a honeycomb structure, lone pairs of N atoms and lone electrons of C atoms form π conjugation without defects suppressing the intrinsic magnetism even the n e per the unit cell is odd. This is according to the PDOS of CN (see Fig. S3 in Supplementary Information) that the p z orbitals of C and N atoms dominating the states across the E F . It is because the p z electrons delocalize and pair together across several cells even the n e in the unit cell is odd.
TRI-and HEP-. TRI and HEP components have even n e , so they themselves obtain no magnetic moment, and their combinations, TRI-TRI, HEP-TRI, and HEP-HEP, consequently, yield no magnetism (see Table 2). TRI-N and HEP-N, whose each N connector leaves one lone pair, are also non-magnetic. In contrast to TRI-C and HEP-C, the C connector has one n e which is the p z electron granting a magnetic moment to the whole structures. If that is the case, why does the p z electron of the C connector not delocalize and pair with p z electrons of TRI? Because the p z states of the C connector and C TRI atom are in different energy levels and both are in the same energy levels with p z states of N TRI atom (see Fig. 2). This is also true in HEP-C, TRI-N and HEP-N. For TRI-N and HEP-N, the p z electrons of the N connector already form a lone pair, so the levels mismatch does not matter.
For the electronic property, TRI-TRI and TRI-N are semiconductors with energy gaps 0.87 and 1.56 eV, respectively, while TRI-C is a half-metal with spin-up energy gap 2.15 eV (see Table 3). For TRI-C, the p x and p y states of N TRI atoms dominate the states around the E F , and the p z states of N TRI and the C connector are at a bit below the E F . The p z states of C TRI and N TRI atoms hybridize with one another at below − 3 eV which is at different energy level with the p z states of the C connector (see Fig. 2b). Noting that they appear at the same energy level below − 5 eV, but that is deep from the E F . This result also holds for TRI-N where the p z states of the N connector hybridize with that of N TRI atoms at − 2 eV but not with that of C TRI atoms (see Fig. 2d). For TRI-TRI, since its core and connector are the same, main features of its PDOS are similar to TRI of TRI-C and TRI-N that the p x and p y states dominate at valence states near the E F while the p z states appear at below − 4 eV (see Fig. S4 in Supplementary Information). Besides, in TRI-C and TRI-N, the p z states of N TRI appear two times; one hybridizes with the p z states of the connector, and another one hybridizes with the p z states of C TRI atoms. Mataga 54 has proposed that the electrons of atoms in the ring (TRI) are paired through the π conjugated bonds leaving their non-bonding σ orbitals and non-bonding π orbital of the C connector to be unpaired. This is in accordance to our result that the spin moment comes from the valence states of the p x and p y states of atoms in the ring and the p z states of the C connector. The p z states form a narrow band as in Mataga's discussion, but the p x and p y states form a wide band.
The HEP-X (X = N, TRI, and HEP) structures whose each component obtains even n e are non-magnetic semiconductors with 1.17, 1.53, and 1.21 eV for energy gaps, respectively (see Table 3). Since HEP-C is magnetic, it has two energy gaps which are 1.92 and 0.31 for spin-up and spin-down, respectively. The PDOS of HEP-C (HEP-N) shown in Fig. 3 demonstrates the hybridization between atoms in the core and connector similar to that www.nature.com/scientificreports/ of TRI-C (TRI-N). For HEP-N, the p x and p y DOS between spin-up and spin-down are the same for HEP-N. In contrast, for HEP-C, the feature peak of spin-down DOS shift to above the E F causing the discrepancy between its spin-up and spin-down DOS. This feature also happens if the PDOS of TRI-C and TRI-N are compared. For HEP-TRI and HEP-HEP (see Figs. S5 and S6 in Supplementary Information), the p z states of atoms in the core and connector appear at the same energy level below − 2 eV while their p x and p y states appear near the E F .

HEC-.
The electronic properties of HEC-X (X = C, N, TRI, HEP, and HEC) shown in Table 3  The HEC component has odd n e ; therefore, its combination with the C connector, HEC-C, is non-magnetic while its combinations with N, TRI, and HEP components are magnetic with one µ B per unit cell. On the one hand, the PDOS of HEC-N (see Fig. 4b) shares similar features to that of TRI-C and HEP-C where the p x and p y spin-up (spin-down) states are at valence maximum (conduction minimum) level and the p z states are at deeper energy level. On the other hand, the PDOS of HEC-C shows a distinguish feature that the p z states of every atom appear at the valance maximum level while their p x and p y states shift to conduction minimum level. Because HEC-C has a number of electrons smaller than HEP-N by two electrons, so the E F which is a function of number of electrons shifts down from above to below the p x and p y PDOS peaks (see Fig. 4a). Moreover, C HEC atoms contribute their p z states to the valence maximum level in contrast to previous phases, so the p z orbitals of C HEC and N HEC atoms and the C connector can form conjugated π bonds delocalizing the electrons and suppressing the intrinsic magnetism. For HEC-TRI and HEC-HEP (see Figs. S7 and S8 in Supplementary Information), their PDOS share similar features to HEP-TRI and HEP-HEP, but they are magnetic.
Despite that HEC-HEC has even n e , it has a magnetization for 2 µ B per unit cell. Here, we run into the second question that why does the reason for the absence of intrinsic magnetism discussed above not be able to use with HEC-HEC? As aforementioned, for TRI, HEP, and HEC components, the p z states of their C atoms are at deep energy level while the p z states of their N atoms appear twice, first at shallow level and second at the energy level as C atoms. Even though the π conjugation in HEC-HEC occurs at energy below − 1 eV, only p z states of N HEC atoms have a contribution near the E F (see Fig. 4c). The electrons in the valence maximum level hence do not form conjugated π bonds, but localize at the p x and p y states of N HEC atoms. HEC-HEC thus obtains 2 µ B per unit cell, one of which comes from each HEC component, and the most discrepancy between spin-up and spin-down DOS is from the p x and p y states.

BEN-.
The BEN component has odd n e , so BEN-C and BEN-BEN are non-magnetic, and BEN-X (X = N, TRI, and HEP, HEC) are magnetic with one µ B per unit cell except for BEN-HEC which has the magnetization about 0.45µ B per unit cell (see Table 2). For the electronic property, BEN-TRI (BEN-HEP) is a semiconductor with spin-up and spin-down energy gap about 0.12 (0.11) and 0.61 (0.49) eV, respectively, BEN-HEC is a metal, and others are semimetals (see Table 3).
The BEN component contains a C hexagonal ring and three pyrroles (see Fig. 5a-d for structures of BEN-X for X = C, N, HEC, and BEN, respectively). Its PDOS shows that the p x and p y states are at energy level lower than the p z states (see Fig. 5h). Near the E F , the p z DOS of C BEN atoms and the p x and p y DOS of N BEN atoms are high while DOS of connector C {TRI,HEP,HEC} atoms are tiny. Consequently, the valence states of BEN-BEN are dominated by the p z states of C BEN atoms, and the p x and p y states of N BEN atoms appear at lower energy level (see Fig. 5h). For BEN-C, it is non-magnetic, so there is no discrepancy between spin-up and spin-down DOS (see Fig. 5e). Because its number of electrons is smaller than BEN-BEN, so its E F drops below the p z states causing the p x and p y states are at the valence maximum level. Although, the p z states of C BEN and N BEN atoms and the C connector appear from the E F down to − 4 eV showing a sign of the π conjugation but its PDOS near the E F is tiny (see Fig. 5i).
For BEN-N, the p z states show the discrepancy between spin-up and spin-down DOS while the p x and p y states are slightly discrepant between spin-up and spin-down DOS (see Fig. 5f). Therefore, a spin moment of BEN-N comes from electrons in the p z states in contrast to, e.g., TRI-C and HEP-C that their spin moments come from electrons in the p x and p y states of N atoms. Because BEN-N has a number of electrons higher than BEN-C by one electron, so the E F shifts to higher than the p z states becoming the valence maximum. For BEN-TRI and BEN-HEP, their PDOS features near the E F are from the p z states which is clearly induced by the BEN component (see Figs. S9 and S10 in Supplementary Information). The p z states of C TRI atoms show no contribution here while those of C HEP atoms have small contributions. The p x and p y states of N TRI and N HEP atoms are discrepant in contrast to the PDOS of phases discussed in previous sections. The spin moments of BEN-TRI and BEN-HEP are also from the electrons in the p z states which is similar to BEN-N.
For BEN-HEC, its PDOS is a mixing between the characteristics of BEN and HEC components (see Fig. 5g). At the E F , the spin-up and spin-down DOS are from the p z states and the p x and p y states, respectively, where the former is dominated by the PDOS of C BEN atoms, and the latter is dominated by the PDOS of N HEC and C HEC atoms. The p z states at the E F are actually from the PDOS of every atom except C HEC atoms, so the π conjugation does not occur at this level but at below -1.0 eV. Therefore, BEN and HEC components obtain different spin moments where the spin moment of the BEN component is greater.
Summary. The building blocks can be grouped by their PDOS characteristics into three groups which are the atoms, i.e., C and N atoms, the carbon nitride rings, i.e., TRI, HEP, and HEC components, and BEN component. www.nature.com/scientificreports/ their valence maximum states dominated by the p x and p y states of N atoms, and their C and N atoms form π bonds at deeper energy level. The BEN component has the p z states of C atoms as its valence maximum states and the p x and p y states of N atoms at the energy level next to the valence maximum states. If the π conjugation forms across the core and the connector of GCNs near the E F , the intrinsic magnetism of GCNs will be suppressed. Otherwise, for a structure with odd n e , the magnetic moment will be localized in the p x and p y states ( p z states) of N (C) atoms if the structure is a combination with the carbon nitride rings (BEN component). Besides, there are three structures which are C-N, HEC-HEC, and BEN-HEC that their magnetism cannot be determined by counting the n e . The C-N is non-magnetic because of the π conjugation at the valence maximum level. The HPEC-HEC and BEN-HEC, in contrast, lack of the π conjugation at the valence maximum level, so their magnetic moments are localized at each component to the system. Two factors thereupon playing the important role to raise or demote the intrinsic magnetism of GCNs are the n e and the π conjugation. The components with odd (even) n e tend to contribute the unpaired (paired) electrons to the system. Their combinations mostly result in presence and absence of the intrinsic magnetism if the n e in  www.nature.com/scientificreports/ the unit cell is odd and even, respectively. For the odd-odd combinations, i.e., C-C, HEC-C, and BEN-C, the p z orbitals of the core and connector form the conjugated π bonds pairing electrons across the structures. For the odd-even combinations, e.g., TRI-C, HEP-C, and HEC-N, the π conjugation does not occur because the p z states of the C and N connectors are at the energy level same as (different from) the p z states of N (C) atoms of the cores. The p z states of N and C atoms of the cores are also hybridizing at the same energy level but at deeper level. In the even-even case, it does not matter if there are conjugated π bonds near the E F . The electrons in each component are paired and contribute no magnetic moment.
Alloys. The g-C 3 N 4 or TRI-N has been synthesized while the g-C 4 N 3 or TRI-C has yet existed only in the simulation 27 . TRI-C is magnetic, but its E form is 133 meV higher than TRI-N (see Table 1). To achieve the intrinsic magnetism, the connectors are alloyed between C and N atoms, so the magnetization can be arisen proportional to a number of C connectors ( C con ). The structures of the alloy can be represented by different ordered patterns of C and N connectors created up to 42 atoms per primitive cell for 52 structures (including TRI-C and TRI-N) by using Hart and Forcade's algorithm 55 where some of order structures are illustrated in Fig. 6a. Figure 6b is a plot of ratio between the magnetization and the number of C con in an ordered structure with respect to a ratio between C con and total number of the connectors in the ordered structure. As expected, the magnetization of order structure increases linearly as the number of C con in the structure increasing because each C con contributes a radical to the system. Figure 6c shows that the formation energy of the ordered solid solutions is below zero with respect to those of TRI-N and TRI-C indicating that the connector C and N atoms are likely to be chemically ordered at low temperature in thermodynamic equilibrium. The transition temperature between order-disordered phase that helps to verify a structure found in the experiment, for instance, HEP/TRI-C/N 56 , hence needs to be investigated 19 , but it is beyond the scope of this work.
Hydrogenation. The intrinsic magnetism of GCNs can be altered by a hydrogenation 39 . Therefore, an atom in each GCN is here passivated by one H atom per unit cell in order to investigate the change in magnetism and the thermodynamically stability. Each GCN has several atomic positions for H atom to passivate, for example, H atom can passivate on C TRI , N TRI , and the C connector of TRI-C which are 3 configurations in total. As a result, the configurations of each GCNs except C-N, that the H atom is passivating with N atoms, have the E form lower than their non-hydrogenated phases. The H atom passivating with C atom of GCNs yields high E form because it induces high strain on the structure while the passivation with N atom is on the side of the structure inducing less strain (see Fig. S11 in Supplementary Information).
Since different configurations yield different results in the magnetizations and the E form , Table 4 shows the magnetization of the configuration of each hydrogenated GCN that has the lowest E form . Noting that the magnetization of hydrogenated graphene (C-C) is one µ B per unit cell, but it is not reported in Table 4 because its E form is higher than graphene. For hydrogenated HEC-X, the HEC component whose N HEC atom is passivated by H atom has even n e , so hydrogenated HEC-X obtains one µ B of magnetization per unit cell for X = C and HEC and zero magnetization for X = N, TRI, and HEP.
For hydrogenated BEN-X, the HEC component whose N HEC atom is passivated by H atom has also even n e , so hydrogenated BEN-X obtains zero magnetization for X = N, TRI, and HEP. Accordingly, the magnetization of hydrogenated BEN-HEC is one µ B per unit cell because one of its components has even n e while another has odd n e , so the magnetic moments between BEN and HEC are no more annihilated in the hydrogenated case. In contrast, the magnetization of hydrogenated BEN-C is 0.20µ B per unit cell even its n e is odd because its valence electrons can be shared through the π conjugation at the valence maximum states.
For hydrogenated TRI-X, the TRI component whose N HEC atom is passivated by H atom has odd n e , so hydrogenated TRI-X obtains zero magnetization for X = C and 0.84 and 1 µ B per unit cell for X = N and TRI, respectively. Notwithstanding that hydrogenated HEP-X for X = N, TRI, and HEP obtain odd n e , their thermodynamically favorable configurations yield zero magnetization.

Conclusions
Firstly, we present building blocks comprising 19 GCNs (and graphene) and the reason behind their emergent intrinsic magnetism through bonding states and charge density. The structure that has even n e is non-magnetic because all valence electrons are paired suppressing the magnetic moment. The structure that has odd n e can be either magnetic or non-magnetic depending on the valence maximum states are localized or delocalized, respectively. The valence maximum states are ensured to be localized if they are from the p x and p y orbitals but are not necessary to be delocalized if they are from the p z orbitals. The p z orbitals of every atom in the core and connector must present in the valence maximum states to form the π conjugation; otherwise, the unpaired electron will be localized in its component (core or connector) producing the magnetic moment.
Secondly, we also apply the building-blocks scheme to study alloys mixing between g-C 3 N 4 and g-C 4 N 3 . The magnetization of the alloy increases linearly as a concentration of the C connector, and some promising alloys are energetically favorable. Lastly, a H atom attached on GCN lowers the E form of the structure. The H atom can change the magnetization of the system depending on a position it is passivating. Therefore, these understandings could lead to the future design for stable GCNs that maintain to be radicals with magnetism.

Methods
The VASP package 57,58 used to perform a first principle calculation based on spin-polarized density functional theory (DFT) has been employed to study the structural, electronic, and magnetic properties of GCNs. In the spin-polarized DFT, the charge density and the magnetization density can be written as 59 www.nature.com/scientificreports/ www.nature.com/scientificreports/ where σ σ σ is (σ x , σ y , σ z ) , a vector of the Pauli matrices and α and β are spin indices, spin up ( ↑ ) or spin down ( ↓ ). The collinear spin-polarization treats the spins to be aligned in the same direction, typically z direction, so σ σ σ = (0, 0, σ z ) . The spin density matrix is thus Therefore, the charge density and magnetization density, respectively, can be computed by where n ↑ and n ↓ are eigenvalues of the spin density matrix solved by the Kohn-Sham equation 60 . The DFT calculation is used the projector augmented wave (PAW) method 61 for a pseudopotential and the Perdew-Berke-Erzenhof (PBE) for an exchange-correlation functional 62 . All calculations have been performed by including the van der Waals correction using Grimme DFT-D3 method 63 . The energy cutoff is 600 eV, and the k-point interval has been set to be 0.02 Å −1 at most for every size of unit cell. The c-axis has been constrained to be 20 Å in order to avoid an interaction between layers. The tetrahedron method 64 has been performed to calculate the spin-polarized density of states (DOS).
The formation energy ( E form ) of carbon nitrides and hydrogenated carbon nitrides systems per atom has been calculated using where E(C x N y H z ) is the energy of C x N y H z , and E(C 2 ) , E(N 2 ) , and E(H 2 ) are the energy of graphene, N 2 molecule, and H 2 molecule, respectively.
(3) n(r) = n ↑ (r) + n ↓ (r), (4) m(r) = n ↑ (r) − n ↓ (r). x + y + z , Table 4. The magnetization of each hydrogenated GCN is reported in µ B unit where each column and row are core and connector components, respectively. The pink (grey) labels the phase that its magnetization does (not) different from its non-hydrogenated phase.