Skip to content

Commit

Permalink
update pyxtal test_oc script
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Aug 18, 2024
1 parent 084a827 commit b0683b0
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 23 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<img src="https://raw.githubusercontent.com/qzhu2017/PyXtal/master/images/512px_type1.png" alt="PyXtal" width="300"/>
<img src="https://raw.githubusercontent.com/MaterSim/PyXtal/master/images/512px_type1.png" alt="PyXtal" width="300"/>

[![Documentation Status](https://readthedocs.org/projects/pyxtal/badge/?version=latest)](https://pyxtal.readthedocs.io/en/latest/?badge=latest)
[![Test Status](https://github.com/qzhu2017/PyXtal/workflows/tests/badge.svg)](https://github.com/qzhu2017/PyXtal/actions)
[![Test Status](https://github.com/MaterSim/PyXtal/workflows/tests/badge.svg)](https://github.com/MaterSim/PyXtal/actions)
[![Download Status](https://img.shields.io/pypi/pyversions/pyxtal)](https://pypi.org/project/pyxtal/)
[![Download Status](https://img.shields.io/pypi/v/pyxtal)](https://pypi.org/project/pyxtal/)
[![Downloads](https://pepy.tech/badge/pyxtal)](https://pepy.tech/project/pyxtal)
[![DOI](https://zenodo.org/badge/128165891.svg)](https://zenodo.org/badge/latestdoi/128165891)
[![Gitter](https://badges.gitter.im/PyXtal/community.svg)](https://gitter.im/PyXtal/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
<img align="right" width="450" src="https://raw.githubusercontent.com/qzhu2017/PyXtal/master/images/water.gif">
<img align="right" width="450" src="https://raw.githubusercontent.com/MaterSim/PyXtal/master/images/water.gif">


## Table of content
Expand All @@ -27,10 +27,10 @@ To contribute to this project, please check [How to contribute?](#how-to-contrib

## Quick Start

- [Atomic crystal](https://nbviewer.jupyter.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/01_atomic_crystals.ipynb)
- [Molecular crystal](https://nbviewer.jupyter.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/02_molecular_crystals.ipynb)
- [XRD](https://nbviewer.jupyter.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/03_pxrd.ipynb)
- [Molecular Packing](https://nbviewer.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/05-crystal-packing.ipynb)
- [Atomic crystal](https://nbviewer.jupyter.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/01_atomic_crystals.ipynb)
- [Molecular crystal](https://nbviewer.jupyter.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/02_molecular_crystals.ipynb)
- [XRD](https://nbviewer.jupyter.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/03_pxrd.ipynb)
- [Molecular Packing](https://nbviewer.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/05-crystal-packing.ipynb)

## Current Features

Expand All @@ -53,7 +53,7 @@ pip install pyxtal
or

```sh
pip install --upgrade git+https://github.com/qzhu2017/PyXtal.git@master
pip install --upgrade git+https://github.com/MaterSim/PyXtal.git@master
```

## Citation
Expand Down Expand Up @@ -115,7 +115,7 @@ Zhu Q, Tang W-L, Hattori S. (2022).

This is an open-source project. Its growth depends on the community. To contribute to PyXtal, you don't necessarily have to write the code. Any contributions from the following list will be helpful.

- [![Star on GitHub](https://img.shields.io/github/stars/qzhu2017/pyxtal.svg?style=social)](https://github.com/qzhu2017/pyxtal/stargazers)
- [![Star on GitHub](https://img.shields.io/github/stars/qzhu2017/pyxtal.svg?style=social)](https://github.com/MaterSim/pyxtal/stargazers)
the PyXtal project and recommend it to your colleagues/friends
- Open an [![GitHub issues](https://img.shields.io/github/issues/qzhu2017/pyxtal.svg)](https://github.com/qzhu2017/pyxtal/issues/) to report the bug or address your wishlist or improve our documentation
- [![GitHub forks](https://img.shields.io/github/forks/qzhu2017/pyxtal?style=social)](https://github.com/qzhu2017/PyXtal/network/members) the repository and send us the pull request
- Open an [![GitHub issues](https://img.shields.io/github/issues/qzhu2017/pyxtal.svg)](https://github.com/MaterSim/pyxtal/issues/) to report the bug or address your wishlist or improve our documentation
- [![GitHub forks](https://img.shields.io/github/forks/qzhu2017/pyxtal?style=social)](https://github.com/MaterSim/PyXtal/network/members) the repository and send us the pull request
2 changes: 1 addition & 1 deletion doc/COMMAND_MODE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ accessed by invoking the ``-h`` command:
----------------------(version 0.1.4 )----------------------

A Python package for random crystal generation
The source code is available at https://github.com/qzhu2017/pyxtal
The source code is available at https://github.com/MaterSim/pyxtal
Developed by Zhu's group at University of Nevada Las Vegas


Expand Down
6 changes: 3 additions & 3 deletions doc/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ or make a copy of the source code, and then install it manually.

::

$ git clone https://github.com/qzhu2017/pyxtal
$ git clone https://github.com/MaterSim/pyxtal
$ cd pyxtal
$ pip install .

Expand All @@ -60,7 +60,7 @@ or update the code to our developing version

::

$ pip install --upgrade git+https://github.com/qzhu2017/PyXtal.git@master
$ pip install --upgrade git+https://github.com/MaterSim/PyXtal.git@master


This will install the module. You can check the installation of the code by a
Expand All @@ -86,7 +86,7 @@ You expect to see the following output.
----------------------(version 0.0.1 )----------------------

A Python package for random crystal generation
The source code is available at https://github.com/qzhu2017/pyxtal
The source code is available at https://github.com/MaterSim/pyxtal
Developed by Zhu's group at University of Nevada Las Vegas


Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
author = "Qiang Zhu, Scott Fredericks, Kevin Parrish"

# The short X.Y version
version = "1.0.0"
version = "1.0.1"
# The full version, including alpha/beta/rc tags
release = "1.0.0"
release = "1.0.1"

# -- General configuration ---------------------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ ab-initio generation of random crystal structures. It has the following features
- Structural manipulation via symmetry relation (both subgroup and supergroup)
- Geometry optimization from built-in and external optimization methods

The current version is ``1.0.0`` at `GitHub <https://github.com/qzhu2017/PyXtal>`_.
The current version is ``1.0.1`` at `GitHub <https://github.com/MaterSim/PyXtal>`_.
It is available for use under the MIT license. Expect updates upon request by
`Qiang Zhu\'s group <https://qzhu2017.github.io>`_ at the
University of North Carolina at Charlotte.

PyXtal is an open source project. You are welcome to contribute it directly via
the `GitHub platform <https://github.com/qzhu2017/PyXtal>`_ or send your
comments and suggestions to the `developer <http://www.physics.unlv.edu/~qzhu/>`_.
the `GitHub platform <https://github.com/MaterSim/PyXtal>`_ or send your
comments and suggestions to the `developer <https://qzhu2017.github.io>`_.


A basic tutorial is provided below for common functions. Additionally,
Expand All @@ -40,9 +40,9 @@ documentation and source code are provided for individual modules.
For an experienced Python user who are familiar with Jupyter notebook, you are
also encouraged to check out the following examples

- `Atomic crystal <https://nbviewer.jupyter.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/01_atomic_crystals.ipynb>`_
- `Molecular crystal <https://nbviewer.jupyter.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/02_molecular_crystals.ipynb>`_
- `XRD <https://nbviewer.jupyter.org/github/qzhu2017/PyXtal/blob/master/examples/tutorials_notebook/03_pxrd.ipynb>`_
- `Atomic crystal <https://nbviewer.jupyter.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/01_atomic_crystals.ipynb>`_
- `Molecular crystal <https://nbviewer.jupyter.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/02_molecular_crystals.ipynb>`_
- `XRD <https://nbviewer.jupyter.org/github/MaterSim/PyXtal/blob/master/examples/tutorials_notebook/03_pxrd.ipynb>`_

Tutorial
========================
Expand Down
80 changes: 80 additions & 0 deletions tests/test_oc_relax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os
from pyxtal.db import database
from pyxtal.optimize.common import optimizer
from pyxtal.representation import representation

db = database("pyxtal/database/test.db")
row = db.get_row("ACSALA")
xtal1 = db.get_pyxtal("ACSALA")
smile = row.mol_smi

# Prepare prm
w_dir = "tmp"
os.makedirs(w_dir, exist_ok=True)

c_info = row.data["charmm_info"]
with open(w_dir + "/pyxtal.prm", "w") as prm:
prm.write(c_info["prm"])
with open(w_dir + "/pyxtal.rtf", "w") as rtf:
rtf.write(c_info["rtf"])

res = optimizer(xtal1, c_info, w_dir, skip_ani=True)
xtal1, eng = res["xtal"], res["energy"]
rep0 = xtal1.get_1D_representation()
print(rep0.to_string(eng))

data="""
82 7.48 14.98 8.83 89.3 1 0 0.63 0.99 0.72 119.2 -43.2 -162.6 -104.9 1.4 -162.2 0 # -20.229
83 11.93 8.09 10.32 114.1 1 0 0.69 0.24 0.16 177.8 6.9 -50.4 -78.0 10.7 -179.0 0 # -21.083
82 15.73 7.54 7.11 91.0 1 0 0.36 0.19 0.23 49.9 27.0 -60.6 72.5 15.9 4.6 0 # -21.806
83 10.09 8.11 10.50 95.4 1 0 0.22 0.02 0.28 14.1 57.4 -97.6 68.8 3.7 -154.6 0 # -21.054
81 10.09 9.68 8.95 101.9 1 0 0.22 0.47 0.24 -66.8 58.1 45.1 -119.2 -16.7 -158.4 0 # -21.673
83 11.43 8.72 17.41 93.4 1 0 0.46 0.62 0.89 162.8 19.1 -30.6 -97.3 -10.0 173.3 0 # -20.371
83 7.23 12.62 24.83 92.1 1 0 0.16 0.28 0.90 -17.9 0.9 -102.1 -139.0 10.5 4.1 0 # -20.165
82 8.55 8.08 12.75 99.7 1 0 0.93 0.12 0.19 65.8 -20.1 -64.9 146.5 1.7 2.8 0 # -21.595
82 21.78 6.34 6.37 89.1 1 0 0.87 0.07 0.17 -15.1 14.3 53.3 87.8 6.7 23.9 0 # -21.703
81 10.64 24.45 6.54 105.8 1 0 0.75 0.99 1.00 26.7 2.6 58.9 -95.8 -8.9 -22.0 0 # -18.588
81 17.91 11.03 8.54 77.7 1 0 0.60 0.19 0.65 -154.8 -0.5 153.4 -68.2 -11.6 160.8 0 # -19.887
83 17.33 7.11 6.94 89.5 1 0 0.59 0.11 0.25 44.6 -18.0 -12.7 85.2 5.5 6.2 0 # -22.601
83 7.38 9.45 12.02 85.0 1 0 0.75 0.29 0.73 -33.7 2.8 65.4 -139.0 1.4 -3.0 0 # -22.578
81 7.62 7.19 16.62 78.4 1 0 0.72 0.14 0.36 -24.3 23.4 -100.0 79.2 5.4 -146.2 0 # -21.578
81 20.29 6.30 11.11 82.9 1 0 0.36 0.58 0.52 43.6 -28.4 -151.6 84.9 6.1 -171.1 0 # -21.478
83 13.60 10.68 5.91 89.5 1 0 0.61 0.79 0.01 -92.9 -8.4 -112.3 67.2 10.3 20.1 0 # -22.065
83 12.90 7.43 9.82 68.4 1 0 0.46 0.40 0.31 -154.9 4.7 -127.4 -79.0 4.8 -178.9 0 # -21.339
82 14.16 7.19 8.59 89.4 1 0 0.99 0.40 0.76 144.0 23.3 5.4 -131.3 1.8 -131.6 0 # -21.648
82 10.69 8.58 9.58 92.7 1 0 0.40 0.91 0.70 -137.3 -14.1 102.0 -56.2 2.9 -26.2 0 # -21.350
82 7.14 9.93 12.66 99.4 1 0 0.57 0.71 0.37 174.2 29.5 -82.0 -68.2 -3.7 -25.4 0 # -21.642
82 12.81 9.29 7.47 106.4 1 0 0.51 0.76 0.08 -72.1 -53.4 -58.6 94.1 -5.0 -152.4 0 # -21.591
83 15.45 5.42 10.42 74.5 1 0 0.58 0.88 0.25 114.9 -40.3 139.5 -131.8 14.4 -5.8 0 # -21.126
83 7.17 8.80 14.96 76.6 1 0 0.70 0.52 0.78 98.0 7.9 -97.4 -140.3 1.0 6.0 0 # -20.570
81 8.51 9.72 10.95 80.4 1 0 0.15 0.03 0.66 -105.6 48.1 -165.5 79.0 9.8 -164.2 0 # -20.798
81 10.80 6.21 13.22 105.8 1 0 0.26 0.50 0.98 -7.0 16.5 -121.9 76.4 10.7 23.2 0 # -21.623
83 9.75 17.07 5.49 79.8 1 0 0.79 0.40 0.34 -89.9 -31.1 131.5 124.1 -3.7 -164.8 0 # -21.549
83 8.79 14.19 7.55 114.4 1 0 0.19 0.90 0.11 -14.5 -35.7 -41.2 -103.5 -1.9 -163.5 0 # -21.481
82 9.50 11.03 8.50 76.8 1 0 0.92 0.26 0.44 -147.4 24.1 174.0 66.9 -5.9 -155.0 0 # -21.454
82 18.63 11.08 4.05 92.5 1 0 0.14 0.68 0.50 -112.3 -30.7 -179.4 -140.1 6.3 7.5 0 # -22.506
81 7.46 17.37 7.12 105.2 1 0 0.54 0.89 0.50 8.2 56.6 151.3 143.0 1.9 143.0 0 # -21.609
82 9.60 9.16 9.92 102.9 1 0 0.46 0.76 0.31 -65.0 -7.7 51.9 -86.0 8.9 -174.2 0 # -21.469
81 8.07 15.16 7.85 116.7 1 0 0.15 0.56 0.78 124.0 -7.5 -161.3 107.1 -4.5 164.5 0 # -20.655
82 9.51 8.48 11.02 100.8 1 0 0.60 0.11 0.39 69.4 -45.4 130.6 116.5 -5.0 -28.0 0 # -21.952
83 8.20 12.36 8.66 90.9 1 0 0.30 0.54 0.18 -73.6 -44.1 -81.7 -73.5 -4.2 -4.6 0 # -21.365
82 9.39 9.43 10.22 65.5 1 0 0.82 0.06 0.41 -15.5 37.7 81.7 107.0 -6.7 166.0 0 # -21.372
82 7.08 17.03 8.16 64.1 1 0 0.79 0.57 0.87 35.5 4.5 80.6 -73.7 -3.2 -5.8 0 # -21.481
81 6.25 8.84 15.75 86.1 1 0 0.26 0.01 0.84 23.5 5.3 83.1 72.6 7.5 -161.0 0 # -21.397
82 5.72 10.11 14.41 100.0 1 0 0.91 0.65 0.34 -80.8 44.0 -52.6 -62.4 -2.2 -40.9 0 # -21.069
81 17.87 9.41 6.88 97.2 1 0 0.82 0.67 0.38 -96.0 -4.2 -164.9 148.0 4.4 -14.3 0 # -19.779
81 7.29 14.97 8.03 101.2 1 0 0.46 0.88 0.98 -53.7 -66.0 138.7 137.1 0.8 -15.4 0 # -22.045
82 6.71 19.21 6.60 76.0 1 0 0.05 0.59 0.73 -39.1 -1.1 -170.6 -122.2 -1.5 27.4 0 # -21.238
"""

# Split the data into lines
lines = data.strip().splitlines()

for line in lines:
strs = line.split("#")[0]; print('Ref', line)
rep = representation.from_string(strs, [smile])
xtal = rep.to_pyxtal()
res = optimizer(xtal, c_info, w_dir, skip_ani=True)
xtal2, eng = res["xtal"], res["energy"]
rep0 = xtal2.get_1D_representation()
print(rep0.to_string(eng))

0 comments on commit b0683b0

Please sign in to comment.