Skip to content

Commit

Permalink
Adapt to changed API in spglib
Browse files Browse the repository at this point in the history
Unpin spglib<2.3
  • Loading branch information
jochym committed Mar 1, 2024
1 parent 004589b commit fc464cf
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 116 deletions.
105 changes: 54 additions & 51 deletions 11_core.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions 15_monitor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"import sys\n",
"from spglib import find_primitive, get_symmetry_dataset\n",
"from collections import Counter\n",
"from hecss.util import load_dfset, get_dfset_len"
"from hecss.util import load_dfset, get_dfset_len, get_cell_data"
]
},
{
Expand Down Expand Up @@ -630,7 +630,7 @@
"#| export\n",
"\n",
"def plot_dofmu_stat(cryst, dofmu, skip=10, window=10, normal=False):\n",
" symm = get_symmetry_dataset(cryst)\n",
" symm = get_symmetry_dataset(get_cell_data(cryst))\n",
" dofmap = symm['mapping_to_primitive']\n",
" dof = set(dofmap)\n",
" dofmul = Counter(symm['mapping_to_primitive'])\n",
Expand Down Expand Up @@ -692,7 +692,7 @@
"#| export\n",
"\n",
"def plot_xs_stat(cryst, xsl, skip=10, window=10):\n",
" symm = get_symmetry_dataset(cryst)\n",
" symm = get_symmetry_dataset(get_cell_data(cryst))\n",
" dofmap = symm['mapping_to_primitive']\n",
" dof = set(dofmap)\n",
" dofmul = Counter(symm['mapping_to_primitive'])\n",
Expand Down
16 changes: 14 additions & 2 deletions 16_util.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"outputs": [],
"source": [
"#| exporti\n",
"from numpy import dot, loadtxt, allclose\n",
"from numpy import dot, loadtxt, allclose, array\n",
"from spglib import find_primitive, get_symmetry_dataset\n",
"from ase import units as un\n",
"import itertools"
Expand Down Expand Up @@ -345,7 +345,19 @@
"id": "c6e20685-a0d2-4759-84b3-1cbe6f1bff9f",
"metadata": {},
"outputs": [],
"source": []
"source": [
"#| exporti\n",
"def get_cell_data(cell):\n",
" '''\n",
" Create new spglib style of cell data from ase cell.\n",
" '''\n",
" \n",
" lattice = array(cell.get_cell().T, dtype=\"double\", order=\"C\")\n",
" positions = array(cell.get_scaled_positions(), dtype=\"double\", order=\"C\")\n",
" numbers = array(cell.get_atomic_numbers(), dtype=\"intc\")\n",
" \n",
" return (lattice, positions, numbers)"
]
}
],
"metadata": {
Expand Down
27 changes: 14 additions & 13 deletions 17_xscale.ipynb

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions 72_DOF_map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"metadata": {},
"outputs": [],
"source": [
"from ase import spacegroup as sg"
"from ase import spacegroup as sg\n",
"from hecss.util import get_cell_data"
]
},
{
Expand Down Expand Up @@ -76,11 +77,11 @@
}
],
"source": [
"puc = spg.find_primitive(cryst)\n",
"puc = spg.find_primitive(get_cell_data(cryst))\n",
"cryst_pc = ase.Atoms(cell=puc[0], scaled_positions=puc[1], numbers=puc[2], pbc=True)\n",
"sym = spg.get_symmetry(cryst_pc)\n",
"symds = spg.get_symmetry_dataset(cryst_pc)\n",
"spg.get_spacegroup(cryst_pc)"
"sym = spg.get_symmetry(get_cell_data(cryst_pc))\n",
"symds = spg.get_symmetry_dataset(get_cell_data(cryst_pc))\n",
"spg.get_spacegroup(get_cell_data(cryst_pc))"
]
},
{
Expand Down Expand Up @@ -223,7 +224,7 @@
"metadata": {},
"outputs": [],
"source": [
"at_map = symds['equivalent_atoms'][spg.get_symmetry_dataset(cryst)['mapping_to_primitive']]"
"at_map = symds['equivalent_atoms'][spg.get_symmetry_dataset(get_cell_data(cryst))['mapping_to_primitive']]"
]
},
{
Expand Down
59 changes: 30 additions & 29 deletions 99_mh.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# HECSS


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

HECSS is a Monte-Carlo, configuration space sampler using sample
Expand Down
2 changes: 1 addition & 1 deletion hecss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.5.18"
__version__ = "0.5.19"

from .core import *

1 change: 1 addition & 0 deletions hecss/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
'hecss.planner': {'hecss.planner.plan_T_scan': ('planner.html#plan_t_scan', 'hecss/planner.py')},
'hecss.util': { 'hecss.util.calc_init_xscale': ('util.html#calc_init_xscale', 'hecss/util.py'),
'hecss.util.create_asap_calculator': ('util.html#create_asap_calculator', 'hecss/util.py'),
'hecss.util.get_cell_data': ('util.html#get_cell_data', 'hecss/util.py'),
'hecss.util.get_dfset_len': ('util.html#get_dfset_len', 'hecss/util.py'),
'hecss.util.load_dfset': ('util.html#load_dfset', 'hecss/util.py'),
'hecss.util.normalize_conf': ('util.html#normalize_conf', 'hecss/util.py'),
Expand Down
7 changes: 5 additions & 2 deletions hecss/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import ase.units as un
from ase.calculators import calculator
from ase.data import chemical_symbols
from hecss.util import get_cell_data
import spglib
from spglib import find_primitive, get_symmetry_dataset

Expand Down Expand Up @@ -358,8 +359,10 @@ def _sampler(self: HECSS, T_goal, N=None, delta_sample=0.01, sigma=2,

nat = len(self.cryst)
dim = (nat, 3)

symm = get_symmetry_dataset(self.cryst, symprec=symprec)
# lattice = np.array(cell.get_cell().T, dtype="double", order="C")
# positions = np.array(cell.get_scaled_positions(), dtype="double", order="C")
# numbers = np.array(cell.get_atomic_numbers(), dtype="intc")
symm = get_symmetry_dataset(get_cell_data(self.cryst), symprec=symprec)
dofmap = symm['mapping_to_primitive']
dof = list(sorted(set(dofmap)))
dofmu = np.ones((len(dof), 3))
Expand Down
3 changes: 2 additions & 1 deletion hecss/mh.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from itertools import islice
from spglib import find_primitive, get_symmetry_dataset
import spglib
from hecss.util import get_cell_data
from collections import Counter
from ase.data import chemical_symbols
from matplotlib import pyplot as plt
Expand Down Expand Up @@ -190,7 +191,7 @@ def print_xs(c, s):
nat = len(cryst)
dim = (nat, 3)

symm = get_symmetry_dataset(cryst, symprec=symprec)
symm = get_symmetry_dataset(get_cell_data(cryst), symprec=symprec)
dofmap = symm['mapping_to_primitive']
dof = list(sorted(set(dofmap)))
dofmu = np.ones((len(dof), 3))
Expand Down
6 changes: 3 additions & 3 deletions hecss/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import sys
from spglib import find_primitive, get_symmetry_dataset
from collections import Counter
from hecss.util import load_dfset, get_dfset_len
from hecss.util import load_dfset, get_dfset_len, get_cell_data

# %% ../15_monitor.ipynb 3
from ase.data import chemical_symbols
Expand Down Expand Up @@ -433,7 +433,7 @@ def plot_acceptance_history(smpl):

# %% ../15_monitor.ipynb 22
def plot_dofmu_stat(cryst, dofmu, skip=10, window=10, normal=False):
symm = get_symmetry_dataset(cryst)
symm = get_symmetry_dataset(get_cell_data(cryst))
dofmap = symm['mapping_to_primitive']
dof = set(dofmap)
dofmul = Counter(symm['mapping_to_primitive'])
Expand Down Expand Up @@ -487,7 +487,7 @@ def plot_dofmu_stat(cryst, dofmu, skip=10, window=10, normal=False):

# %% ../15_monitor.ipynb 23
def plot_xs_stat(cryst, xsl, skip=10, window=10):
symm = get_symmetry_dataset(cryst)
symm = get_symmetry_dataset(get_cell_data(cryst))
dofmap = symm['mapping_to_primitive']
dof = set(dofmap)
dofmul = Counter(symm['mapping_to_primitive'])
Expand Down
14 changes: 13 additions & 1 deletion hecss/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['normalize_conf', 'load_dfset', 'get_dfset_len', 'write_dfset', 'calc_init_xscale']

# %% ../16_util.ipynb 2
from numpy import dot, loadtxt, allclose
from numpy import dot, loadtxt, allclose, array
from spglib import find_primitive, get_symmetry_dataset
from ase import units as un
import itertools
Expand Down Expand Up @@ -169,3 +169,15 @@ def calc_init_xscale(cryst, xsl, skip=None):
for i, el in enumerate(set(elmap)):
xscale[elmap==el] = xs[:,elmap==el,:].mean()
return xscale

# %% ../16_util.ipynb 15
def get_cell_data(cell):
'''
Create new spglib style of cell data from ase cell.
'''

lattice = array(cell.get_cell().T, dtype="double", order="C")
positions = array(cell.get_scaled_positions(), dtype="double", order="C")
numbers = array(cell.get_atomic_numbers(), dtype="intc")

return (lattice, positions, numbers)
2 changes: 1 addition & 1 deletion hecss/xscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from spglib import find_primitive, get_symmetry_dataset
from glob import glob
from matplotlib import pyplot as plt
from hecss.util import normalize_conf
from hecss.util import normalize_conf, get_cell_data
from hecss.monitor import plot_hist
from hecss import *

Expand Down
2 changes: 1 addition & 1 deletion index.ipynb

Large diffs are not rendered by default.

Binary file modified index_files/figure-commonmark/cell-5-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ author = Paweł T. Jochym
author_email = pawel.jochym@ifj.edu.pl
copyright = Paweł T. Jochym
branch = devel
version = 0.5.18
version = 0.5.19
min_python = 3.7
audience = Science/Research
language = English
custom_sidebar = False
license = gpl3
status = 3
requirements = fastcore>=1.5 numpy scipy ase spglib<2.3 tqdm click matplotlib ipython
requirements = fastcore>=1.5 numpy scipy ase spglib tqdm click matplotlib ipython
console_scripts = hecss_sampler=hecss.cli:hecss_sampler plot_stats=hecss.cli:plot_stats plot_bands=hecss.cli:plot_bands calculate_xscale=hecss.cli:calculate_xscale reshape_sample=hecss.cli:reshape_sample
tst_flags = vasp interactive slow quick asap vaspx
nbs_path = .
Expand Down

0 comments on commit fc464cf

Please sign in to comment.