Metadata-Version: 2.1
Name: schrodinet
Version: 0.1.0
Summary: Solving the Schrodinger equation using RBF Neural Net
Home-page: https://github.com/NLESC-JCER/Schrodinet
Author: ['Nicolas Renaud', 'Felipe Zapata']
Author-email: n.renaud@esciencecenter.nl
License: Apache Software License 2.0
Keywords: schrodinet
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Scientific/Engineering :: Chemistry
Description-Content-Type: text/markdown
Requires-Dist: autograd
Requires-Dist: cython
Requires-Dist: matplotlib
Requires-Dist: numpy
Requires-Dist: pyyaml (>=5.1)
Requires-Dist: schema
Requires-Dist: scipy
Requires-Dist: tqdm
Requires-Dist: torch
Provides-Extra: dev
Requires-Dist: prospector[with_pyroma] ; extra == 'dev'
Requires-Dist: yapf ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Provides-Extra: doc
Requires-Dist: recommonmark ; extra == 'doc'
Requires-Dist: sphinx ; extra == 'doc'
Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
Provides-Extra: test
Requires-Dist: coverage ; extra == 'test'
Requires-Dist: pycodestyle ; extra == 'test'
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'
Requires-Dist: pytest-runner ; extra == 'test'

# Schrodinet

![Build Status](https://travis-ci.com/NLESC-JCER/Schrodinet.svg?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/38b540ecc5464901a5a48a9be037c924)](https://app.codacy.com/gh/NLESC-JCER/Schrodinet?utm_source=github.com&utm_medium=referral&utm_content=NLESC-JCER/Schrodinet&utm_campaign=Badge_Grade_Dashboard)

Solving the Schrodinger equations in 1, 2 or 3D  using quantum monte carlo and radial basis function neural network to encode the wavefunction.

## Harmonic Oscillator in 1D

The script below illustrates how to optimize the wave function of the one-dimensional harmonic oscillator.

```python
import torch
from torch import optim

from schrodinet.sampler.metropolis import Metropolis
from schrodinet.wavefunction.wf_potential import Potential
from schrodinet.solver.solver_potential import SolverPotential
from schrodinet.solver.plot_potential import plot_results_1d, plotter1d

def pot_func(pos):
    '''Potential function desired.'''
    return 0.5*pos**2


def ho1d_sol(pos):
    '''Analytical solution of the 1D harmonic oscillator.'''
    return torch.exp(-0.5*pos**2)

# Define the domain and the number of RBFs
domain, ncenter = {'min': -5., 'max': 5.}, 11

# wavefunction
wf = Potential(pot_func, domain, ncenter, fcinit='random', nelec=1, sigma=0.5)

# sampler
sampler = Metropolis(nwalkers=1000, nstep=2000,
                     step_size=1., nelec=wf.nelec,
                     ndim=wf.ndim, init={'min': -5, 'max': 5})

# optimizer
opt = optim.Adam(wf.parameters(), lr=0.05)
scheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.75)

# Solver
solver = SolverPotential(wf=wf, sampler=sampler,
                         optimizer=opt, scheduler=scheduler)

# Train the wave function
plotter = plotter1d(wf, domain, 100, sol=ho1d_sol) 
solver.run(300, loss='variance', plot=plotter, save='model.pth')

# Plot the final wave function
plot_results_1d(solver, domain, 100, ho1d_sol, e0=0.5, load='model.pth')
```

After otpimization the following trajectory can easily be generated :

<p align="center">
<img src="./pics/ho1d.gif" title="Optimization of the wave function">
</p>

The same procedure can be done on different potentials. The figure below shows the performace of the method on the harmonic oscillator and the morse potential.

<p align="center">
<img src="./pics/rbf1d_summary.png" title="Results of the optimization">
</p>




