schrodinet


Nameschrodinet JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/NLESC-JCER/Schrodinet
SummarySolving the Schrodinger equation using RBF Neural Net
upload_time2023-05-08 09:24:38
maintainer
docs_urlNone
author['Nicolas Renaud', 'Felipe Zapata']
requires_python
licenseApache Software License 2.0
keywords schrodinet
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # 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)

Quantum Monte-Carlo Simulations of one-dimensional problem using Radial Basis Functions Neural Networks.
<p align="center">
<img src="./pics/morse.gif" title="Optimization of the wave function">
</p>


## Installation

Clone the repo and `pip` insatll the code

```
git clone https://github.com/NLESC-JCER/Schrodinet/
cd Schrodinet
pip install .
```

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

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NLESC-JCER/Schrodinet",
    "name": "schrodinet",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "schrodinet",
    "author": "['Nicolas Renaud', 'Felipe Zapata']",
    "author_email": "n.renaud@esciencecenter.nl",
    "download_url": "https://files.pythonhosted.org/packages/f4/8a/a60d3d1c7ddafa38858076aa9e1f389a089ee19ce028e83ca8492bf4c364/schrodinet-0.1.2.tar.gz",
    "platform": null,
    "description": "# Schrodinet\n\n![Build Status](https://travis-ci.com/NLESC-JCER/Schrodinet.svg?branch=master)\n[![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)\n\nQuantum Monte-Carlo Simulations of one-dimensional problem using Radial Basis Functions Neural Networks.\n<p align=\"center\">\n<img src=\"./pics/morse.gif\" title=\"Optimization of the wave function\">\n</p>\n\n\n## Installation\n\nClone the repo and `pip` insatll the code\n\n```\ngit clone https://github.com/NLESC-JCER/Schrodinet/\ncd Schrodinet\npip install .\n```\n\n## Harmonic Oscillator in 1D\n\nThe script below illustrates how to optimize the wave function of the one-dimensional harmonic oscillator.\n\n```python\nimport torch\nfrom torch import optim\n\nfrom schrodinet.sampler.metropolis import Metropolis\nfrom schrodinet.wavefunction.wf_potential import Potential\nfrom schrodinet.solver.solver_potential import SolverPotential\nfrom schrodinet.solver.plot_potential import plot_results_1d, plotter1d\n\ndef pot_func(pos):\n    '''Potential function desired.'''\n    return 0.5*pos**2\n\n\ndef ho1d_sol(pos):\n    '''Analytical solution of the 1D harmonic oscillator.'''\n    return torch.exp(-0.5*pos**2)\n\n# Define the domain and the number of RBFs\n\n# wavefunction\nwf = Potential(pot_func, domain, ncenter, fcinit='random', nelec=1, sigma=0.5)\n\n# sampler\nsampler = Metropolis(nwalkers=1000, nstep=2000,\n                     step_size=1., nelec=wf.nelec,\n                     ndim=wf.ndim, init={'min': -5, 'max': 5})\n\n# optimizer\nopt = optim.Adam(wf.parameters(), lr=0.05)\nscheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.75)\n\n# Solver\nsolver = SolverPotential(wf=wf, sampler=sampler,\n                         optimizer=opt, scheduler=scheduler)\n\n# Train the wave function\nplotter = plotter1d(wf, domain, 100, sol=ho1d_sol)\nsolver.run(300, loss='variance', plot=plotter, save='model.pth')\n\n# Plot the final wave function\nplot_results_1d(solver, domain, 100, ho1d_sol, e0=0.5, load='model.pth')\n```\n\nAfter otpimization the following trajectory can easily be generated :\n\n<p align=\"center\">\n<img src=\"./pics/ho1d.gif\" title=\"Optimization of the wave function\">\n</p>\n\nThe 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.\n\n<p align=\"center\">\n<img src=\"./pics/rbf1d_summary.png\" title=\"Results of the optimization\">\n</p>\n\n\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Solving the Schrodinger equation using RBF Neural Net",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/NLESC-JCER/Schrodinet"
    },
    "split_keywords": [
        "schrodinet"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6534f0d0586d95b401b968c3523ce85321e61321c58a01abbe144b7546c5c7d1",
                "md5": "d218b0efe5103f92002fb700eacb4913",
                "sha256": "7f40f000ea7a8a99bbab12d9ee588cad9624f902429c442874b00409aa4f2fa3"
            },
            "downloads": -1,
            "filename": "schrodinet-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d218b0efe5103f92002fb700eacb4913",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 28711,
            "upload_time": "2023-05-08T09:24:36",
            "upload_time_iso_8601": "2023-05-08T09:24:36.361132Z",
            "url": "https://files.pythonhosted.org/packages/65/34/f0d0586d95b401b968c3523ce85321e61321c58a01abbe144b7546c5c7d1/schrodinet-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f48aa60d3d1c7ddafa38858076aa9e1f389a089ee19ce028e83ca8492bf4c364",
                "md5": "555520efcb7dc5fb412191ff7ee8c363",
                "sha256": "9eb95a73ffc3aa49c3c1d0f28ef40a6a9a75afc4a5cb30efa2004b4a47fecb29"
            },
            "downloads": -1,
            "filename": "schrodinet-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "555520efcb7dc5fb412191ff7ee8c363",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23576,
            "upload_time": "2023-05-08T09:24:38",
            "upload_time_iso_8601": "2023-05-08T09:24:38.393645Z",
            "url": "https://files.pythonhosted.org/packages/f4/8a/a60d3d1c7ddafa38858076aa9e1f389a089ee19ce028e83ca8492bf4c364/schrodinet-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-08 09:24:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NLESC-JCER",
    "github_project": "Schrodinet",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "schrodinet"
}
        
Elapsed time: 0.15850s