Skip to content

Commit

Permalink
migrate mof_builder to pyxtal
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Aug 18, 2024
1 parent 0204948 commit 3d70a8f
Show file tree
Hide file tree
Showing 22 changed files with 2,741 additions and 957 deletions.
4 changes: 4 additions & 0 deletions doc/Usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ Executing this above scripts will lead to the following output:
This way, you can easily find derivative crystals in the suboptimal representations. Conversely, it is also possible to identify the likely supergroup xtal. The following snippet codes can be used to design illustrate pyxtal functionalities.

.. code-block:: Python
from pyxtal import pyxtal
# load a graphite crystal and make the subgroup representation
Expand Down Expand Up @@ -957,6 +958,7 @@ between Pyxtal and its 1D representation. With this module, one can represent th
c1.from_seed('pyxtal/database/cifs/aspirin.cif', ['CC(=O)OC1=CC=CC=C1C(=O)O.smi'])
rep = c1.get_1D_representation()
print(rep.to_string())
::
81 11.23 6.54 11.23 95.9 1 0.23 0.59 0.03 44.1 -25.2 32.5 82.9 2.8 -178.3 1
Expand Down Expand Up @@ -1003,6 +1005,7 @@ To create a new database file (e.g., `test.db`),
print("Initial list of codes", db.codes)
db.add_from_code('NAPHTA')
print("Updated list of codes", db.codes)
::
0 ACSALA
Expand All @@ -1017,6 +1020,7 @@ To view the database file,
.. code-block:: Python
$ ase db test.db
::
csd_code|space_group|mol_smi
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.1"
version = "1.0.2"
# The full version, including alpha/beta/rc tags
release = "1.0.1"
release = "1.0.2"

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

Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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.1`` at `GitHub <https://github.com/MaterSim/PyXtal>`_.
The current version is ``1.0.2`` 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.
Expand Down
1 change: 0 additions & 1 deletion doc/pyxtal.interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ Submodules
pyxtal.interface.gulp
pyxtal.interface.lammpslib
pyxtal.interface.vasp
pyxtal.interface.vasprun
7 changes: 7 additions & 0 deletions doc/pyxtal.lego.SO3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyxtal.lego.SO3 module
==========================

.. automodule:: pyxtal.lego.SO3
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyxtal.interface.vasprun module
pyxtal.lego.basinhopping module
===============================

.. automodule:: pyxtal.interface.vasprun
.. automodule:: pyxtal.lego.basinhopping
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions doc/pyxtal.lego.builder.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyxtal.lego.builder module
==========================

.. automodule:: pyxtal.lego.builder
:members:
:undoc-members:
:show-inheritance:
17 changes: 17 additions & 0 deletions doc/pyxtal.lego.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pyxtal.lego package
===================

.. automodule:: pyxtal.lego
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

pyxtal.lego.builder
pyxtal.lego.SO3
pyxtal.lego.basinhopping
7 changes: 0 additions & 7 deletions doc/pyxtal.optimize.basin_hopping.rst

This file was deleted.

1 change: 0 additions & 1 deletion doc/pyxtal.optimize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ Submodules
pyxtal.optimize.QRS
pyxtal.optimize.WFS
pyxtal.optimize.base
pyxtal.optimize.basin_hopping
pyxtal.optimize.benchmark
pyxtal.optimize.common
1 change: 1 addition & 0 deletions doc/pyxtal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Subpackages

pyxtal.database
pyxtal.interface
pyxtal.lego
pyxtal.optimize
pyxtal.potentials

Expand Down
6 changes: 3 additions & 3 deletions pyxtal/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,9 @@ def clean_structures(self, ids=(None, None), dtol=2e-3, etol=1e-3, criteria=None
"""
Clean up the db by removing the duplicate structures
Here we check the follow criteria
- same number of atoms
- same density
- same energy
- same number of atoms
- same density
- same energy
Args:
dtol (float): tolerance of density
Expand Down
71 changes: 36 additions & 35 deletions pyxtal/interface/LJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,38 +311,39 @@ def symmetrized_stress(self, stress):
return m2


from spglib import get_symmetry_dataset

from pyxtal.crystal import random_crystal

for _i in range(10):
crystal = random_crystal(11, ["C"], [4], 1.0)
if crystal.valid:
crystal1 = deepcopy(crystal)
test = LJ(epsilon=0.01, sigma=3.40, rcut=8.0)
struc = (crystal1.lattice_matrix, crystal1.frac_coords, [6] * 4)
eng, enth, force, stress = test.calc(crystal1)
sg = get_symmetry_dataset(struc)["number"]
print(f"\nBefore relaxation Space group: {sg:4d} Energy: {eng:12.4} Enthalpy: {enth:12.4}")

dyn1 = FIRE(crystal1, test, f_tol=1e-5, dt=0.2, maxmove=0.2) # , symmetrize=True)
dyn1.run(500)
eng, enth, force, stress = test.calc(crystal1)
struc = (dyn1.struc.lattice_matrix, dyn1.struc.frac_coords, [6] * 4)
sg = get_symmetry_dataset(struc, symprec=0.1)["number"]
print(f"After relaxation without symm Space group: {sg:4d} Energy: {eng:12.4} Enthalpy: {enth:12.4}")

dyn1 = FIRE(crystal, test, f_tol=1e-5, dt=0.2, maxmove=0.2, symmetrize=True)
dyn1.run(500)
eng, enth, force, stress = test.calc(crystal)
struc = (dyn1.struc.lattice_matrix, dyn1.struc.frac_coords, [6] * 4)
sg = get_symmetry_dataset(struc, symprec=0.02)["number"]
if sg is None:
sg = 0
print(f"After relaxation with symm Space group: {sg:4d} Energy: {eng:12.4} Enthalpy: {enth:12.4}")
# dyn1 = FIRE(crystal, test, f_tol=1e-5, dt=0.2, maxmove=0.2)
# struc = (dyn1.struc.lattice_matrix, dyn1.struc.frac_coords, [6]*4)
# sg = get_symmetry_dataset(struc, symprec=0.02)['number']
# print('After relaxation without symm Space group: {:4d} Energy: {:12.4} Enthalpy: {:12.4}'.format(sg, eng, enth))
# right now, it seems structures goes to either HCP of FCC after relaxation, which is expected for 3D LJ system
# need to compare with other code to see if the energy is correct
if __name__ == "__main__":
from spglib import get_symmetry_dataset
from pyxtal import pyxtal

for _i in range(10):
crystal = pyxtal()
crystal.from_random(3, 11, ["C"], [4])
if crystal.valid:
crystal1 = deepcopy(crystal)
test = LJ(epsilon=0.01, sigma=3.40, rcut=8.0)
struc = (crystal1.lattice_matrix, crystal1.frac_coords, [6] * 4)
eng, enth, force, stress = test.calc(crystal1)
sg = get_symmetry_dataset(struc)["number"]
print(f"\nBefore relaxation Space group: {sg:4d} Energy: {eng:12.4} Enthalpy: {enth:12.4}")

dyn1 = FIRE(crystal1, test, f_tol=1e-5, dt=0.2, maxmove=0.2) # , symmetrize=True)
dyn1.run(500)
eng, enth, force, stress = test.calc(crystal1)
struc = (dyn1.struc.lattice_matrix, dyn1.struc.frac_coords, [6] * 4)
sg = get_symmetry_dataset(struc, symprec=0.1)["number"]
print(f"After relaxation without symm Space group: {sg:4d} Energy: {eng:12.4} Enthalpy: {enth:12.4}")

dyn1 = FIRE(crystal, test, f_tol=1e-5, dt=0.2, maxmove=0.2, symmetrize=True)
dyn1.run(500)
eng, enth, force, stress = test.calc(crystal)
struc = (dyn1.struc.lattice_matrix, dyn1.struc.frac_coords, [6] * 4)
sg = get_symmetry_dataset(struc, symprec=0.02)["number"]
if sg is None:
sg = 0
print(f"After relaxation with symm Space group: {sg:4d} Energy: {eng:12.4} Enthalpy: {enth:12.4}")
# dyn1 = FIRE(crystal, test, f_tol=1e-5, dt=0.2, maxmove=0.2)
# struc = (dyn1.struc.lattice_matrix, dyn1.struc.frac_coords, [6]*4)
# sg = get_symmetry_dataset(struc, symprec=0.02)['number']
# print('After relaxation without symm Space group: {:4d} Energy: {:12.4} Enthalpy: {:12.4}'.format(sg, eng, enth))
# right now, it seems structures goes to either HCP of FCC after relaxation, which is expected for 3D LJ system
# need to compare with other code to see if the energy is correct
2 changes: 1 addition & 1 deletion pyxtal/interface/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def read_OSZICAR(self, path="OSZICAR"):
self.energy = energy # this is actually enthalpy

def read_bandgap(self, path="vasprun.xml"):
from pyxtal.interface.vasprun import vasprun
from vasprun import vasprun

myrun = vasprun(path)
self.gap = myrun.values["gap"]
Expand Down
Loading

0 comments on commit 3d70a8f

Please sign in to comment.