## Abstract

An ultimate goal of materials science is to deliver materials with desired properties at will. Solving the inverse problem to obtain an appropriate Hamiltonian directly from the desired properties has the potential to reach qualitatively new principles, but most research to date has been limited to quantitative determination of parameters within known models. Here, we develop a general framework that can automatically design a Hamiltonian with desired physical properties by using automatic differentiation. In the application to the quantum anomalous Hall effect, our framework can not only construct the Haldane model automatically but also generate Hamiltonians that exhibit a six-times larger anomalous Hall effect. In addition, the application to the photovoltaic effect gives an optimal Hamiltonian for electrons moving on a noncoplanar spin texture, which can generate ~ 700 Am^{−2} under solar radiation. This framework would accelerate materials exploration by automatic construction of models and principles.

## Introduction

A conventional theoretical approach to materials exploration is to search for Hamiltonians that produce physical properties of interest (Fig. 1a). This is not only tedious but also nontrivial since the parameter space to be explored is usually unknown a priori. Therefore, most of the research to date has been conducted for the known Hamiltonians and their extensions. However, these approaches make it difficult to reach qualitatively new models and principles. In contrast, the inverse approach to find appropriate Hamiltonians directly from the desired properties is not only efficient but also has the potential to unveil qualitatively new physics (Fig. 1a). Many proposals have been made for the inverse approach^{1,2,3,4,5,6,7,8,9,10,11,12,13}. Since the early stage, the perturbation theory^{2,7,14}, the potential interpolation^{15,16}, and the eigenstate-to-Hamiltonian construction^{17} have been employed, but their applications were limited to the objective functions in terms of energy. In recent years, machine learning-based methods, such as the generative models using neural networks^{1,18,19}, the Bayesian optimization using Gaussian processes^{5,20,21}, and the genetic algorithms^{22,23} have been developed, but they require numerous data and computational resources for training. In particular, the Bayesian optimization and the genetic algorithms do not necessarily improve the objective function after parameter update, and the generative models would fail in the parameter space where data is insufficient. For these reasons, the previous research has been limited to the quantitative estimation of a few parameters within known Hamiltonians. Thus, it is still challenging to explore new models and principles by taking full advantage of the inverse problem.

To address these issues, we develop a framework that can automatically design a Hamiltonian with desired physical properties by using automatic differentiation. Automatic differentiation enables us to compute the analytic derivatives of any functions by adapting chain rules, which have been widely used in the field of deep learning in the process of backpropagation^{24}, even for over a trillion parameters^{25}. In recent years, automatic differentiation has been applied to physics, such as computing physical quantities represented by derivatives^{26,27}, calculating conditions for solar cells^{28}, applications to quantum gate control^{29,30,31}, non-equilibrium steady state^{32}, numerical renormalization group^{33}, Hatrtee–Fock calculation^{34,35}, molecular dynamics^{36}, and density functional theory^{37,38}. However, the application to the inverse design of a Hamiltonian has not been fully explored thus far to the best of our knowledge.

In this article, we first describe the framework and its advantages over previous methods. Then, we demonstrate a proof of concept of this framework by applying it to two problems: the anomalous Hall effect (AHE) and the photovoltaic effect (PVE). We show that our framework can automatically construct the Haldane model with the quantum AHE on the honeycomb lattice. Moreover, by applying the framework to a model on the triangular lattice, we find a Hamiltonian that exhibits a six-time larger AHE than that of the Haldane model. For the PVE, we are able to automatically generate a spin-charge-coupled Hamiltonian with electrons moving over an umbrella-shaped spin configuration, which can produce a photocurrent of about 700 A m^{−2}. Our framework is applicable to a wide range of systems and physical properties, including first-principles Hamiltonians, strongly correlated electron systems, and interacting bosonic systems.

## Results and discussion

### Framework

The flowchart of our framework is shown in Fig. 1b. First, we prepare a Hamiltonian \({{{{{{{\mathcal{H}}}}}}}}({{{{{{{\mathbf{\theta }}}}}}}})\) with a set of parameters **θ**. We also define the objective function *L*(**θ**) to be minimized for achieving the desired properties; for instance, if the objective is to maximize the expectation value of a physical quantity *P*, we can take *L*(**θ**) = −〈*P*(**θ**)〉. Next, we compute the derivative \(\frac{\partial L}{\partial {{{{{{{\mathbf{\theta }}}}}}}}}\) by automatic differentiation. Then, we update the Hamiltonian by changing the parameters **θ** according to \(\frac{\partial L}{\partial {{{{{{{\mathbf{\theta }}}}}}}}}\). By repeating this procedure until **θ** converge, we end up with the Hamiltonian \({{{{{{{\mathcal{H}}}}}}}}({{{{{{{{\mathbf{\theta }}}}}}}}}_{{{{{{{{\rm{opt}}}}}}}}})\) that optimizes the desired properties, where **θ**_{opt} are the parameters after the convergence, as commonly done in machine learning.

Our framework has the following advantages in comparison with the existing methods^{1,2,5,7,14,15,16,17,18,19,20,21,22,23}: (i) It does not require training, hence, there is no need to collect data or consume computational resources on the training. (ii) It performs the optimization by using the analytical derivatives, which can achieve higher accuracy than the approximations based on neural networks even for large parameter space. (iii) It is applicable to a wide range of objective functions, unlike the perturbation theory. Therefore, our framework is able to deal with a large number of parameters in the Hamiltonian, which may lead to the findings of Hamiltonians that have not been reported thus far.

### Automatic construction of the Haldane model showing spontaneous quantum AHE

First, we demonstrate that our framework can automatically find the Haldane model with a spontaneous quantum AHE^{39}. We consider a tight-binding model on a honeycomb lattice with two sublattices, whose Hamiltonian reads

where \({c}_{i}^{{{{\dagger}}} }\) (*c*_{i}) is the creation (annihilation) operator of a spinless fermion at site *i*; the first term describes an on-site staggered potential with real coefficients \({M}^{{a}_{i}}\) (*a*_{i} = *A* or *B* denotes the sublattice), and the second and third terms represent the hopping of fermions to nearest- and second-neighbor sites, respectively. Here, we set *t*_{1} = 1 as an energy unit and parametrize \({t}_{2}^{{d}_{ij}}\) as \({t}_{2}^{{d}_{ij}}=\sigma ({r}^{{d}_{ij}})\exp ({{{{{{{\rm{i}}}}}}}}{\phi }^{{d}_{ij}})\) with real variables \({r}^{{d}_{ij}}\) and \({\phi }^{{d}_{ij}}\), where *σ*(*x*) = 1/(1 + *e*^{−x}) is the sigmoid function to avoid the divergence of the absolute value of \({t}_{2}^{{d}_{ij}}\), and *d*_{ij} denotes the direction of the second-neighbor hopping, *d*_{ij} ∈ {*A*1, *A*2, *A*3, *B*1, *B*2, *B*3} (see Fig. 2a). Thus, the model includes 14 parameters in total represented by \({{{{{{{\mathbf{\theta }}}}}}}}=\{{M}^{A},{M}^{B},\{{r}^{{d}_{ij}}\},\{{\phi }^{{d}_{ij}}\}\}\). The Haldane model is given by taking *M*^{A} = +*M*, *M*^{B} = −*M*, and \({t}_{2}^{{d}_{ij}}={t}_{2}\exp ({{{{{{{\rm{i}}}}}}}}\phi )\) regardless of *d*. The phase diagram is shown in Fig. 2b, which has two topologically nontrivial phases with a spontaneous quantum AHE corresponding to the nonzero Chern numbers *C* = ±1.

With this setup of \({{{{{{{\mathcal{H}}}}}}}}({{{{{{{\mathbf{\theta }}}}}}}})\), we try to obtain a Hamiltonian that maximizes the AHE by the framework in Fig. 1b. For this aim, we take the objective function as *L*(**θ**) = −*σ*_{xy}(**θ**), where *σ*_{xy} is the Hall conductivity. Details of the calculations are described in the “Methods” section. We find that *σ*_{xy} increases monotonically through the optimization, as shown in Fig. 2d. Note that we introduce temperature and control it as shown in Fig. 2c to avoid that \(\frac{\partial L}{\partial {{{{{{{\mathbf{\theta }}}}}}}}}\) becomes zero due to the quantization (*β* is the inverse temperature). In contrast to the continuous change of *σ*_{xy}, the Chern numbers of the two bands, which are separated by the band gap shown in the inset of Fig. 2d, converge quickly to *C* ≃ ±1 in the very early stage of the optimization, as shown in Fig. 2e. The evolution of each parameter is plotted in Figs. 2f–h. We find that both *M*^{A} and *M*^{B} converge to zero, and \(| {t}_{2}^{{d}_{ij}}| \to 1\) and \({\phi }^{{d}_{ij}}\to \pi /2\) for all *d*_{ij}. These values correspond to the center of the topological phase with *C* = 1 in the Haldane model, indicated by the star in Fig. 2b. We confirm that different initial conditions converge to the same state (see Supplementary Note 1). Thus, our framework automatically constructs the Haldane model with a spontaneous quantum AHE under the condition of maximizing *σ*_{xy}. The reason why the optimal state is always at the center of the *C* = 1 phase is due to the introduction of temperature; at nonzero temperature, *σ*_{xy} becomes largest at the center where the band gap becomes largest in the topological phase. We note that the value of *σ*_{xy} in Fig. 2d is considerably smaller than the quantized value +1, which is also due to the finite temperature.

### Finding a Hamiltonian with large quantum AHE on a triangular lattice

To demonstrate that our framework can find more complex models automatically, we apply it to a triangular lattice assuming a four-sublattice unit cell (Fig. 3a). The Hamiltonian reads

We take \({t}_{1}^{ij}=\exp ({{{{{{{\rm{i}}}}}}}}{\phi }_{1}^{ij})\) and \({t}_{m}^{ij}=\sigma ({r}_{m})\exp ({{{{{{{\rm{i}}}}}}}}{\phi }_{m}^{ij})\) for *m* = 2 and 3 (see the arrows in Fig. 3a). Thus, the model includes 38 parameters in total represented by \({{{{{{{\mathbf{\theta }}}}}}}}=\{{r}_{2},{r}_{3},\{{\phi }_{1}^{ij}\},\{{\phi }_{2}^{ij}\},\{{\phi }_{3}^{ij}\}\}\). As in the previous calculation, we take *L*(**θ**) = −*σ*_{xy}(**θ**) to maximize the AHE. We optimize the parameters with a schedule of temperature shown in Fig. 3b. At each optimization step, the fermion density is fixed at half filling by tuning the chemical potential using the bisection method.

We find that the Chern numbers for four bands converge to *C* = 5, 1, −3, and −3 from the lower band, as shown in Fig. 3d. This indicates that *σ*_{xy} reaches 6 at half filling, which is six times larger than that in the Haldane model, although *σ*_{xy} in Fig. 3c is much smaller due to the finite temperature similar to the previous case. The band structure is shown in Fig. 3e with the Berry curvature Ω (see the “Methods” section). Note that the system recovers (approximately) threefold rotational symmetry after the convergence (see Supplementary Note 2). Ω of the lowest energy band is positive at all wave numbers, whose sum gives the largest *C* = 5, while the other bands include negative contributions. This indicates that our framework tries to maximize *C* for the lowest energy band. We note that the same conclusion is obtained for many other initial conditions, while some cases converge to *C* = 3, 3, −1, and −5 from the lower band, which gives the same value of *σ*_{xy} = 6. The reason why the solution in Fig. 3 is rather preferred is the finite temperature introduced in the optimization process, for the same reason as in the honeycomb lattice model for which the center of the topological phase was obtained (see Supplementary Note 2).

Let us discuss the optimized parameters. We find that both ∣*t*_{2}∣ and ∣*t*_{3}∣ converge to ≃1, while the phases take the various values shown by colors in Fig. 3a. We show, however, that their sums along closed loops in the counter-clockwise direction, \({{{\Phi }}}_{m}=\sum {\phi }_{m}^{ij}\), representing the fictitious magnetic fluxes, take some regular values: Φ_{1} ≃ 7*π*/4 for the smallest triangles composed of *t*_{1} (Fig. 3f), and Φ_{2} takes ≃0.91*π* and ≃1.59*π* for larger triangles of *t*_{2} facing right and left, respectively (Fig. 3g), while Φ_{3} is always ≃ *π* (\({\phi }_{3}^{ij}\) is either ≃ 0 or *π*). Although \({\phi }_{m}^{ij}\) take different values for different initial conditions, Φ_{m} converges to the same values. These results indicate that our framework automatically finds a model whose complex hoppings realize spontaneous fictitious magnetic fluxes to maximize *σ*_{xy}, which is hard to obtain by intuition. Based on the results, we can also refine the Hamiltonian by taking more regular values of the phases (multiples of *π*/4) (see Supplementary Note 2).

### Maximizing photovoltaic current generation in a spin-charge-coupled system

Finally, we apply our framework to optimize the PVE in a bulk system with broken spatial inversion symmetry^{40,41,42,43,44}. An example is the shift current, which is understood as a shift in the real space of electron wave functions excited by light. For simplicity, here we focus on (quasi-)one-dimensional spin-charge-coupled systems where the spin configurations break spatial inversion symmetry^{45}. The schematic is shown in Fig. 4a. Note that the model approximately describes chiral magnetic metals, such as CrNb_{3}S_{6}^{46} and Yb(Ni_{1−x}Cu_{x})_{3}Al_{9}^{47}. The Hamiltonian reads

where \({c}_{i\alpha }^{{{{\dagger}}} }\) (*c*_{iα}) denotes the creation (annihilation) operator of an electron at site *i* with spin *α*. Here, we take \({t}_{1}=\sqrt{2}\tanh ({r}_{t})\cos ({\theta }_{t})\times 0.1\) [eV], \({t}_{2}=\sqrt{2}\tanh ({r}_{t})\sin ({\theta }_{t})\times 0.1\) [eV], and \(J=\log (1+\exp ({r}_{J}))\) [eV]; the spins are treated as classical and their configurations are parametrized as \({{{{{{{{\bf{S}}}}}}}}}_{i}=(\sin {\theta}_{i}\cos {\phi }_{i},\sin {\theta }_{i}\sin {\phi }_{i},\cos {\theta }_{i})\), with *θ*_{i} = *π**σ*(*η*_{i}). ∣*t*_{1}∣ and ∣*t*_{2}∣ are represented by the hyperbolic tangent functions to be bounded, otherwise, they will become too large through the optimization since the shift current increases with increasing momentum derivatives of the band dispersions. We set ∣*t*_{1}∣ and ∣*t*_{2}∣ to be within about 0.1 eV, considering the situation in the real materials. *J* is set to be positive without loss of generality. We set the number of sublattice sites to *N* = 12. Thus, the model includes 3 + 2*N* = 27 parameters in total represented by **θ** = {*r*_{t}, *θ*_{t}, *r*_{J}, {*η*_{i}}, {*ϕ*_{i}}}. The quantity of our interest is the photocurrent under solar radiation, defined as *I* = ∫*d**ω**σ*_{PVE}(*ω*)∣*E*(*ω*)∣^{2} [A m^{−2}], where *σ*_{PVE}(*ω*) is the nonlinear optical conductivity^{48,49}, and ∣*E*(*ω*)∣^{2} denotes the intensity of the linearly polarized solar light with frequency *ω*, approximately given by blackbody radiation at *T* = 5500 K (the inset of Fig. 4a) (see the “Methods” section); we take *L*(**θ**) = −*I*. We consider a three-dimensional system in which the one-dimensional chains are arranged in a square lattice fashion for simplicity, taking the lattice constants *a*_{z} = 9 Å in the chain direction and *a*_{x} = *a*_{y} = 4 Å in the orthogonal directions, referring to a chiral magnet^{47}. The fermion density is fixed at half filling as for the previous model.

Figure 4c shows the optimization process of the photocurrent *I* under the schedule of temperature shown in Fig. 4b. We obtain *I* ~ 700 A m^{−2} after the convergence. This value is comparable to or larger than those for Ge semiconductors^{50} and perovskites substances^{51,52}. Changes in the parameters *t*_{1}, *t*_{2}, and *J* are plotted in the inset of Fig. 4c. The optimized spin configuration is an umbrella-shaped chiral state with a three-site period, as shown in Fig. 4d–f. We also note that other noncoplanar spin configurations are also obtained for different initial conditions, but they generate smaller *I* (see Supplementary Note 3).

To elaborate the mechanism behind the optimization of the photocurrent, we plot the *ω* dependence of \(I(\omega) = \sigma_{\rm PVE}(\omega) |E(\omega)|^2\) in Fig. 4g, together with *σ*_{PVE}(*ω*)*ω*^{2} and ∣*E*(*ω*)∣^{2} in the inset. We find that *I*(*ω*) has a sharp peak at *ω* ~ 7.15 × 10^{14} [rad s^{−1}], due to the peak of *σ*_{PVE}(*ω*)*ω*^{2} located at the frequency where ∣*E*(*ω*)∣^{2} becomes large. We show that dominant contributions to the peak come from the interband processes between the conduction and valence bands split by 2*J* ≃ 0.5 [eV] ≃ 7.15 × 10^{14} [rad s^{−1}], as shown in Fig. 4h (see the “Methods” section). The results indicate that the enhanced photocurrent of ~ 700 A m^{−2} under solar radiation is generated by band engineering with automatic optimization of *t*_{1}, *t*_{2}, *J*, and the spin configurations. We note that the peak value of *σ*_{PVE}(*ω*) ~ 0.06 A V^{−2} is considerably large compared to existing materials, such as BaTiO_{3}^{40,53} and TaAs^{54}, and is also even an order of magnitude larger than the value obtained in the previous theoretical study^{45}, while we may need substantially large competing magnetic interactions to stabilize the umbrella spin configuration at room temperature.

## Conclusions

Through the applications to AHE and PVE, our framework has proven capable of automatically finding Hamiltonians that optimize the physical properties of interest. The key aspect is in the use of automatic differentiation in the inverse problem, which provides the derivatives of the objective function in terms of a large number of parameters; although the current studies are limited to several tens of parameters, we can practically deal with a million or more. Since automatic differentiation is a versatile technique, our framework has a wide range of applicability, such as first-principles Hamiltonians computed by the Kohn–Sham equations, strongly correlated electron systems, quantum spin systems, and interacting bosonic systems, as long as the forward computation can be performed efficiently. In addition, it is applicable to a wide range of physical properties to be optimized, including the reproduction of experimental raw data. Thus, our findings will be useful for the exploration of new models and principles in materials science.

## Methods

### Application to the AHE

The Hall conductivity is calculated by using the Kubo formula as

where *e* is the elementary charge, *h* is the Planck constant, *V* is the volume of the Brillouin zone, *N*_{k} is the number of **k** points, *f*(*E*, *β*) is the Fermi distribution function at inverse temperature *β*, *E*_{kn} is the energy at **k** in *n*th band; Ω(**k**) is the Berry curvature given by

where \(\left\vert {{{{{{{\bf{k}}}}}}}}n\right\rangle\) is an eigenstate at **k** in *n*th band. We take *e* = *h* = 1, *N*_{k} = 100^{2}, and *δ* = 10^{−5}.

The optimization starts from initial parameters randomly chosen as *M*^{A}, *M*^{B} ∈ (−1, 1), \({r}^{{d}_{ij}}\in (0,1)\), and \({\phi }^{{d}_{ij}}\in (-\pi ,\pi )\) for the honeycomb lattice model, and *r*_{2}, *r*_{3} ∈ (0, 1) and \({\phi }_{1}^{ij},{\phi }_{2}^{ij},{\phi }_{3}^{ij} \in (-\pi ,\pi )\) for the triangular lattice model. Automatic differentiation is implemented using JAX^{55}. Note that \(\frac{\partial {{{{{{{\mathcal{H}}}}}}}}}{\partial {k}_{x}}\) and \(\frac{\partial {{{{{{{\mathcal{H}}}}}}}}}{\partial {k}_{y}}\) in Eq. (5) are also calculated by using automatic differentiation. We employ RMSPROP^{56} as an optimization method, in which we take the learning rate, the decay factor, and the infinitesimal as 0.1, 0.99, and 10^{−8}, respectively.

### Application to the PVE

According to the second-order optical response theory^{44,45}, a nonlinear electric current produced by electric fields *E*(*ω*_{1}) and *E*(*ω*_{2}) with two frequencies *ω*_{1} and *ω*_{2}, respectively, is given by

with the second-order optical conductivity *σ*_{opt}(*ω*_{1} + *ω*_{2}; *ω*_{1}, *ω*_{2}). In the case of *ω*_{1} = − *ω*_{2}, a DC current is generated as

where *I*(*ω*) = *I*(0; *ω*, −*ω*) and *σ*_{PVE}(*ω*) = *σ*_{opt}(0; *ω*, −*ω*). The *ω* integral *I* = ∫d*ω**I*(*ω*) gives a photocurrent generated by the shift current mechanism^{42,43,45}, which is used for the objective function in the main text. We approximate solar radiation by blackbody radiation *B*(*ω*, *T*) at 5500 K as

where *μ*_{0}, *c*, and *C*_{solar} are the magnetic constant, speed of light, and solar constant, respectively;

where *ℏ* and *k*_{B} are the reduced Planck constant and the Boltzmann constant, respectively. In Eq. (7), *σ*_{PVE}(*ω*) is computed as^{44,45}

where

Here, *a*, *b*, and *c* denote the bands; *E*_{ab} = *E*_{ka}−*E*_{kb}, *f*_{ab} = *f*(*E*_{ka}, *β*)−*f*(*E*_{kb}, *β*), and \({J}_{ab}^{(n)}=\left\langle ka\right\vert \frac{{\partial }^{n}{{{{{{{\mathcal{H}}}}}}}}}{\partial {k}^{n}}\left\vert kb\right\rangle\). We use \(V=\frac{{(2\pi )}^{3}}{{a}_{x}{a}_{y}N{a}_{z}}\), *N*_{k} = 100, and *γ* = 2*π* × 10^{13} [rad s^{−1}]. \(\frac{{\partial }^{n}{{{{{{{\mathcal{H}}}}}}}}}{\partial {k}^{n}}\) in \({J}_{ab}^{(n)}\) are calculated by using automatic differentiation. We also calculate the contribution to *I* from each *k* point in each band, *I*_{band}(*k*), by calculating *I* without taking the summations of *k* and the band indices in Eqs. (11)–(14). The optimization starts from initial parameters randomly chosen as *r*_{t} ∈ (−1, 1), *θ*_{t} ∈ (−*π*, *π*), *r*_{J} ∈ (0, 0.5), *η*_{i} ∈ (−1, 1), and *ϕ*_{i} ∈ (−*π*, *π*).

## Data availability

All the data can be generated from the code below.

## Code availability

We have published the code to reproduce all the results on https://github.com/koji-inui/automatic-hamiltonian-design.git.

## References

Sanchez-Lengeling, B. & Aspuru-Guzik, A. Inverse molecular design using machine learning: generative models for matter engineering.

*Science***361**, 360–365 (2018).Weymuth, T. & Reiher, M. Inverse quantum chemistry: concepts and strategies for rational compound design.

*Int. J. Quantum Chem.***114**, 823–837 (2014).Kuhn, C. & Beratan, D. N. Inverse strategies for molecular design.

*J. Phys. Chem.***100**, 10595–10599 (1996).Zunger, A. Inverse design in search of materials with target functionalities.

*Nat. Rev. Chem.***2**, 0121 (2018).Tamura, R. & Hukushima, K. Method for estimating spin–spin interactions from magnetization curves.

*Phys. Rev. B***95**, 064407 (2017).Yu, S., Gao, Y., Chen, B.-B. & Li, W. Learning the effective spin hamiltonian of a quantum magnet.

*Chin. Phys. Lett.***38**, 097502 (2021).Fujita, H., Nakagawa, Y. O., Sugiura, S. & Oshikawa, M. Construction of hamiltonians by supervised learning of energy and entanglement spectra.

*Phys. Rev. B***97**, 075114 (2018).Franceschetti, A. & Zunger, A. The inverse band-structure problem of finding an atomic configuration with given electronic properties.

*Nature***402**, 60–63 (1999).Hart, G. L. W., Blum, V., Walorski, M. J. & Zunger, A. Evolutionary approach for determining first-principles hamiltonians.

*Nat. Mater.***4**, 391–394 (2005).Mertz, T. & Valentí, R. Engineering topological phases guided by statistical and machine learning methods.

*Phys. Rev. Res.***3**, 013132 (2021).Ajoy, A. & Cappellaro, P. Quantum simulation via filtered hamiltonian engineering: application to perfect quantum transport in spin networks.

*Phys. Rev. Lett.***110**, 220503 (2013).Greiter, M., Schnells, V. & Thomale, R. Method to identify parent Hamiltonians for trial states.

*Phys. Rev. B***98**, 081113 (2018).Pakrouski, K. Automatic design of Hamiltonians.

*Quantum***4**, 315 (2020).Kosman, W. M. & Hinze, J. Inverse perturbation analysis: improving the accuracy of potential energy curves.

*J. Mol. Spectrosc.***56**, 93–103 (1975).Ho, T., Rabitz, H., Choi, S. E. & Lester, M. I. An inverse method for obtaining smooth multidimensional potential energy surfaces: application to ar+oh a2+(

*v*= 0).*J. Chem. Phys.***102**, 2282–2285 (1995).Zhang, D. H. & Light, J. C. Potential inversion via variational generalized inverse.

*J. Chem. Phys.***103**, 9713–9720 (1995).Chertkov, E. & Clark, B. K. Computational inverse method for constructing spaces of quantum models from wave functions.

*Phys. Rev. X***8**, 031029 (2018).Yao, Z. et al. Inverse design of nanoporous crystalline reticular materials with deep generative models.

*Nat. Mach. Intell.***3**, 76–86 (2021).Liu, Z., Zhu, D., Raju, L. & Cai, W. Tackling photonic inverse design with machine learning.

*Adv. Sci.***8**, 2002923 (2021).von Toussaint, U. Bayesian inference in physics.

*Rev. Mod. Phys.***83**, 943–999 (2011).Ikebata, H., Hongo, K., Isomura, T., Maezono, R. & Yoshida, R. Bayesian molecular design with a chemical language model.

*J. Comput.-Aided Mol. Des.***31**, 379–391 (2017).Supady, A., Blum, V. & Baldauf, C. First-principles molecular structure search with a genetic algorithm.

*J. Chem. Inf. Model.***55**, 2338–2348 (2015).Yoshikawa, N. et al. Population-based de novo molecule generation, using grammatical evolution.

*Chem. Lett.***47**, 1431–1434 (2018).Rumelhart, D. E., Hinton, G. E. & Williams, R. J. Learning representations by back-propagating errors.

*Nature***323**, 533–536 (1986).Fedus, W., Zoph, B. & Shazeer, N. Switch transformers: scaling to trillion parameter models with simple and efficient sparsity.

*J. Mach. Learn. Res.***23**, 120 (2022).Xie, H., Liu, J.-G. & Wang, L. Automatic differentiation of dominant eigensolver and its applications in quantum physics.

*Phys. Rev. B***101**, 245139 (2020).Liao, H.-J., Liu, J.-G., Wang, L. & Xiang, T. Differentiable programming tensor networks.

*Phys. Rev. X***9**, 031041 (2019).Mann, S. et al. ∂pv: an end-to-end differentiable solar-cell simulator.

*Comput. Phys. Commun.***272**, 108232 (2022).Leung, N., Abdelhafez, M., Koch, J. & Schuster, D. Speedup for quantum optimal control from automatic differentiation based on graphics processing units.

*Phys. Rev. A***95**, 042318 (2017).Abdelhafez, M., Schuster, D. I. & Koch, J. Gradient-based optimal control of open quantum systems using quantum trajectories and automatic differentiation.

*Phys. Rev. A***99**, 052327 (2019).Torlai, G., Carrasquilla, J., Fishman, M. T., Melko, R. G. & Fisher, M. P. A. Wave-function positivization via automatic differentiation.

*Phys. Rev. Res.***2**, 032060 (2020).Vargas-Hernández, R. A., Chen, R. T. Q., Jung, K. A. & Brumer, P. Fully differentiable optimization protocols for non-equilibrium steady states.

*New J. Phys.***23**, 123006 (2021).Rigo, J. B. & Mitchell, A. K. Automatic differentiable numerical renormalization group.

*Phys. Rev. Res.***4**, 013227 (2022).Tamayo-Mendoza, T., Kreisbeck, C., Lindh, R. & Aspuru-Guzik, A. Automatic differentiation in quantum chemistry with applications to fully variational Hartree–Fock.

*ACS Cent. Sci.***4**, 559–566 (2018).Yoshikawa, N. & Sumita, M. Automatic differentiation for the direct minimization approach to the Hartree–Fock method.

*The J. Phys. Chem. A***126**, 8487–8493 (2022).Schoenholz, S. & Cubuk, E. D. Jax md: a framework for differentiable physics. In

*Advances in Neural Information Processing Systems*, Vol. 33 (eds Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M. & Lin, H.) 11428–11441 (Curran Associates, Inc., 2020).Li, L. et al. Kohn-sham equations as regularizer: building prior knowledge into machine-learned physics.

*Phys. Rev. Lett.***126**, 036401 (2021).Kasim, M. F., Lehtola, S. & Vinko, S. M. Dqc: a python program package for differentiable quantum chemistry.

*J. Chem. Phys.***156**, 084801 (2022).Haldane, F. D. M. Model for a quantum Hall effect without landau levels: condensed-matter realization of the “parity anomaly".

*Phys. Rev. Lett.***61**, 2015–2018 (1988).Miller, R. C. Optical harmonic generation in single crystal BaTiO

_{3}.*Phys. Rev.***134**, A1313–A1319 (1964).Glass, A. M., von der Linde, D. & Negran, T. J. High voltage bulk photovoltaic effect and the photorefractive process in LiNbO

_{3}.*Appl. Phys. Lett.***25**, 233–235 (1974).von Baltz, R. & Kraut, W. Theory of the bulk photovoltaic effect in pure crystals.

*Phys. Rev. B***23**, 5590–5596 (1981).Young, S. M., Zheng, F. & Rappe, A. M. First-principles calculation of the bulk photovoltaic effect in bismuth ferrite.

*Phys. Rev. Lett.***109**, 236601 (2012).Parker, D. E., Morimoto, T., Orenstein, J. & Moore, J. E. Diagrammatic approach to nonlinear optical response with application to Weyl semimetals.

*Phys. Rev. B***99**, 045121 (2019).Okumura, S., Morimoto, T., Kato, Y. & Motome, Y. Quadratic optical responses in a chiral magnet.

*Phys. Rev. B***104**, L180407 (2021).Togawa, Y. et al. Magnetic soliton confinement and discretization effects arising from macroscopic coherence in a chiral spin soliton lattice.

*Phys. Rev. B***92**, 220412 (2015).Matsumura, T. et al. Chiral soliton lattice formation in monoaxial helimagnet Yb(Ni

_{1−x}Cu_{x})_{3}Al_{9}.*J. Phys. Soc. Jpn.***86**, 124702 (2017).Boyd, R. W.

*Nonlinear Optics*(Academic Press, 2020).Hanamura, E., Kawabe, Y. & Yamanaka, A.

*Quantum Nonlinear Optics*(Springer Science & Business Media, 2007).Singh, P. & Ravindra, N. Temperature dependence of solar cell performance-an analysis.

*Sol. Energy Mater. Sol. Cells***101**, 36–45 (2012).Snaith, H. J. et al. Anomalous hysteresis in perovskite solar cells.

*J. Phys. Chem. Lett.***5**, 1511–1515 (2014).Commandeur, D., Morrissey, H. & Chen, Q. Solar cells with high short circuit currents based on cspbbr3 perovskite-modified ZnO nanorod composites.

*ACS Appl. Nano Mater.***3**, 5676–5686 (2020).Young, S. M. & Rappe, A. M. First principles calculation of the shift current photovoltaic effect in ferroelectrics.

*Phys. Rev. Lett.***109**, 116601 (2012).Osterhoudt, G. B. et al. Colossal mid-infrared bulk photovoltaic effect in a type-i Weyl semimetal.

*Nat. Mater.***18**, 471–475 (2019).Bradbury, J. et al.

*JAX: Composable Transformations of Python+NumPy Programs*. http://github.com/google/jax (2018).Hinton, G., Srivastava, N. & Swersky, K.

*Neural Networks for Machine Learning Lecture 6a Overview of Mini-batch Gradient Descent*http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture-slides-lec6.pdf (2012).

## Acknowledgements

The authors thank Y. Kato, S. Okumura, R. Pohle, and K. Shimizu for fruitful discussions. This work is supported by KAKENIHI Grant No. 20H00122, and a Grant-in-Aid for Scientific Research on Innovative Areas “Quantum Liquid Crystals” (KAKENHI Grant No. JP19H05825) from JSPS of Japan. It is also supported by JST CREST Grant No. JPMJCR18T2.

## Author information

### Authors and Affiliations

### Contributions

K.I. conceived and implemented the algorithm through the discussion with Y.M. K.I. and Y.M. conceived the models, interpreted the results, and wrote the manuscript.

### Corresponding author

## Ethics declarations

### Competing interests

K.I. has filed a patent based on the algorithm reported in this paper. Y.M. has no competing interests.

## Peer review

### Peer review information

*Communications Physics* thanks the anonymous reviewers for their contribution to the peer review of this work. Peer reviewer reports are available.

## 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

Inui, K., Motome, Y. Inverse Hamiltonian design by automatic differentiation.
*Commun Phys* **6**, 37 (2023). https://doi.org/10.1038/s42005-023-01132-0

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s42005-023-01132-0

## Comments

By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.