Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
b1592 committed Jul 6, 2021
0 parents commit ff3cbc5
Showing 351 changed files with 245,630 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Mac
.DS_Store

# Profile results
*.lprof
examples/iPEPS/test_*.py
mprofile*.dat

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so
*.dylib

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
adpepsenv/
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 b1592

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# TODO

- General code cleanup
- Observables (`adpeps/ipeps/observables.py` not used)
- Rewrite `run_ipeps_gs.py` Objective class
- Fix the numerous evaluation methods in `ipeps.py`
- Documentation


# AD-PEPS

Basic implementation of iPEPS ground-state and excited-state optimization using automatic differentiation.

The package contains three main parts:

- The core iPEPS and CTM code, contained in `adpeps/ipeps`
- Executable scripts that run the simulations in `adpeps/simulation`
- Helper classes and functions, with custom contraction and other operations in `adpeps/tensor` and general utilities in `adpeps/utils`

## Installation

Download this repository

```
git clone https://github.com/b1592/ad-peps.git
```

Install the package using `pip`

```
cd ad-peps
pip install -e .
```

## Usage

As a general starting point for simulations the package can be executed as

```
python -m adpeps <options>
```

### Ground states

For ground states, the package can be used with the `gs` option:

```
python -m adpeps gs <config_file>
```

For each simulation, a configuration file in `yaml` format should be supplied that contains all relevant settings.
An example can be found in `examples/heis_D2.yaml`, with a description of each setting.

### Excited states

For excitations, the option to be used is `exci`:

```
python -m adpeps exci <config_file> <arguments>
```

In order to prepare for a simulation, first a ground-state simulation should be performed.
After this, a base file for the excited-state simulation can be created with the `-i` argument:

```
python -m adpeps exci <config_file> -i
```

This will converge the ground-state boundary tensors, normalize the ground state tensors, shift the Hamiltonian by the ground-state energy and finally compute a basis of vectors that are orthogonal to the ground state.

Once this is completed, the full simulation can be performed, which computes the full effective energy and norm matrices, by supplying the 'momentum index'.
This index corresponds to a certain path through momentum space, controlled by the `momentum_path` option in the configuration file.
For example, the first point in the `Bril1`, which is at `(pi,0)`, can be computed by running

```
python -m adpeps exci <config_file> -p 1
```

After the simulations are done, the results can be evaluated with the `-e` argument:

```
python -m adpeps exci <config_file> -e
```
9 changes: 9 additions & 0 deletions adpeps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from pathlib import Path

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT_DIR = Path(ROOT_DIR).parent
87 changes: 87 additions & 0 deletions adpeps/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""
Main runner
"""

import argparse
from .simulation import run_ipeps_gs, run_ipeps_exci

from jax.config import config
config.update("jax_enable_x64", True)

import adpeps
from adpeps.utils import io

"""
Main executable module for iPEPS simulations
Select one of two modes:
> python3 -m adpeps gs <config_file>
> python3 -m adpeps exci <config_file> -p <momentum_ix>
Where <config_file> corresponds to a .yaml configuration file
The following environment variables can be set for the locations
of configuration and output files:
- CONFIGDIR: base folder where the simulations look for configuration
files
- DATADIR: base folder where output data is saved
The naming conventions for both modes are defined in utils.io as follows:
- Ground states: <DATADIR>/<out_prefix>_<model>_D<D>_X<chi>.npz
- Excited states: <DATADIR>/<out_prefix>_<model>_D<D>_X<chi>/<p_ix>_<px>_<py>.npz
"""

def get_parser():
# create the top-level parser
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version', dest='version',
action='store_true',
help='Show version')

subparsers = parser.add_subparsers(help='Simulation mode', dest='sim_mode')

# Ground-state parser
parser_gs = subparsers.add_parser('gs', help='Ground-state simulation')
parser_gs.add_argument('config_file', type=str,
help='Configuration (.yml) file for the simulation options')

# Excited-state parser
parser_exci = subparsers.add_parser('exci', help='Excited-state simulation')
parser_exci.add_argument('config_file', type=str,
help='config file of excited-state simulation')
parser_exci.add_argument('-p', '--p_ix', dest='momentum_ix',
default=0, type=int,
help='momentum index')
parser_exci.add_argument('-e', '--eval', dest='evaluate',
action='store_true',
help='Prepare excitation base')
parser_exci.add_argument('-i', '--init', dest='init',
action='store_true',
help='Prepare excitation base')
return parser

if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args()
print(args)

if args.version:
print('Adpeps version:')
print(adpeps.__version__)

elif args.sim_mode == 'gs':
print('Running ground-state sim')
args.config_file = io.localize_config_file(args.config_file)
run_ipeps_gs.run(args.config_file)

elif args.sim_mode == 'exci':
print('Running excited-state sim')
print(args.config_file)
args.config_file = io.localize_config_file(args.config_file)
print(args.config_file)
if args.evaluate:
run_ipeps_exci.evaluate(args.config_file, args.momentum_ix-1)
elif args.init:
run_ipeps_exci.prepare(args.config_file)
else:
run_ipeps_exci.run(args.config_file, args.momentum_ix-1)
Loading

0 comments on commit ff3cbc5

Please sign in to comment.