Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.12"]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install build dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gfortran liblapack-dev libblas-dev pkg-config

- name: Install build dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install gcc pkg-config
# gfortran ships inside the gcc formula
echo "FC=$(brew --prefix gcc)/bin/gfortran" >> "$GITHUB_ENV"
Comment on lines +38 to +41

- name: Build and install
run: python -m pip install --upgrade pip && python -m pip install '.[test]'

- name: Check the console scripts are installed
run: |
csld_main --help
cs-fit --help
polaron_main --help

- name: Run tests
run: python -m pytest tests -v

wheel:
name: Build wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y gfortran liblapack-dev libblas-dev pkg-config

- name: Build wheel
run: |
python -m pip install --upgrade pip build
python -m build --wheel

- uses: actions/upload-artifact@v4
with:
name: csld-wheel
path: dist/*.whl
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build artefacts
build/
builddir/
dist/
*.egg-info/
.mesonpy-*/

# compiled objects
*.so
*.o
*.a
*.mod
*.pyc
__pycache__/

# cython/f2py generated sources
compile/c_util/_c_util.cpp
*module.c
*-f2pywrappers2.f90
.f2py_f2cmap

# tooling
.pytest_cache/
.venv/
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

97 changes: 0 additions & 97 deletions Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions PKG-INFO

This file was deleted.

35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,41 @@ A comprehensive package to study lattice dynamics from first-principles. The int
Getting Started
-------------------

To install CSLD, make sure you have Python, C++ and Fortran 90 compilers.
Then:
CSLD builds C++ and Fortran extensions, so you need a C++ compiler, a Fortran 90
compiler and BLAS/LAPACK. Everything else is handled by `pip`.

$ git clone https://github.com/LLNL/csld.git
$ cd csld
$ ./setup.py install --user
$ pip install .

### With conda

If you do not have compilers or BLAS/LAPACK available, the bundled environment
provides them:

$ conda env create -f environment.yml
$ conda activate csld
$ pip install .

### With a system toolchain

On Debian/Ubuntu, `sudo apt install gfortran liblapack-dev libblas-dev`; on
macOS, `brew install gcc lapack`. Then `pip install .` as above. Use
`pip install --user .` to install without admin rights.

### For development

$ pip install -e . --no-build-isolation

An editable install serves the Python modules straight from the checkout and
rebuilds the compiled extensions on import, replacing the old
`setup.py develop`.

After installing, the `csld_main`, `cs-fit`, `polaron_main` and `phonopy-qha`
commands are on your `PATH`. To check the install:

$ pip install '.[test]'
$ pytest

Documentation
----------------
Expand Down
1 change: 1 addition & 0 deletions compile/c_util/_c_util.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# cython: language_level=3
"""
C code for csld, including
fct_trans
Expand Down
20 changes: 20 additions & 0 deletions compile/c_util/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cython/C++ extension, installed as csld._c_util
py.extension_module(
'_c_util',
[
'_c_util.pyx',
'fct_trans.cpp',
'iid-mc.cpp',
'intDigits.cpp',
'LDCorr.cpp',
'LDFFCorr.cpp',
'nullspace.cpp',
'structure_ordering.cpp',
],
override_options: ['cython_language=cpp'],
cpp_args: ['-DNDEBUG'],
include_directories: [inc_np, include_directories('.')],
dependencies: [py_dep],
install: true,
subdir: 'csld',
)
17 changes: 17 additions & 0 deletions compile/f_util/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# f2py extension, installed as csld.f_util
f_util_gen = custom_target(
'f_utilmodule.c',
input: ['f_util.f90'],
output: ['f_utilmodule.c', 'f_util-f2pywrappers2.f90'],
command: [f2py, '@INPUT@', '-m', 'f_util', '--lower', '--build-dir', '@OUTDIR@'],
)

py.extension_module(
'f_util',
['f_util.f90', f_util_gen, fortranobject_c],
include_directories: [inc_np, inc_f2py],
dependencies: [py_dep],
fortran_args: fortran_args,
install: true,
subdir: 'csld',
)
18 changes: 9 additions & 9 deletions csld/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_space_group_symbol(self):
Returns:
(str): Spacegroup symbol for structure.
"""
return self._space_group_data["international"]
return self._space_group_data.international

def get_space_group_number(self):
"""
Expand All @@ -86,7 +86,7 @@ def get_space_group_number(self):
Returns:
(int): International spacegroup number for structure.
"""
return int(self._space_group_data["number"])
return int(self._space_group_data.number)

def get_hall(self):
"""
Expand All @@ -95,7 +95,7 @@ def get_hall(self):
Returns:
(str): Hall symbol
"""
return self._space_group_data["hall"]
return self._space_group_data.hall

def get_crystal_system(self):
"""
Expand All @@ -105,7 +105,7 @@ def get_crystal_system(self):
Returns:
(str): Crystal system for structure.
"""
n = self._space_group_data["number"]
n = self._space_group_data.number

f = lambda i, j: i <= n <= j
cs = {"triclinic": (1, 2), "monoclinic": (3, 15),
Expand All @@ -131,7 +131,7 @@ def get_lattice_type(self):
Returns:
(str): Lattice type for structure.
"""
n = self._space_group_data["number"]
n = self._space_group_data.number
system = self.get_crystal_system()
if n in [146, 148, 155, 160, 161, 166, 167]:
return "rhombohedral"
Expand All @@ -142,10 +142,10 @@ def get_lattice_type(self):

def get_symmetry_dataset(self):
"""
Returns the symmetry dataset as a dict.
Returns the symmetry dataset as returned by spglib.

Returns:
(dict): With the following properties:
(spglib.SpglibDataset): With the following attributes:
number: International space group number
international: International symbol
hall: Hall symbol
Expand Down Expand Up @@ -219,7 +219,7 @@ def get_point_group_symbol(rotations):
return s[0].strip(), s[1]

def point_group_symbol(self):
return SpacegroupAnalyzer.get_point_group_symbol(self._space_group_data["rotations"])
return SpacegroupAnalyzer.get_point_group_symbol(self._space_group_data.rotations)

def get_point_group_operations(self):
"""
Expand Down Expand Up @@ -254,7 +254,7 @@ def get_symmetrized_structure(self, check_prim=2):
:class:`SymmetrizedStructure` object.
"""
return SymmetrizedStructure(self._structure, self.get_spacegroup(),
self.get_symmetry_dataset()["equivalent_atoms"], self, warn_prim=check_prim)
self.get_symmetry_dataset().equivalent_atoms, self, warn_prim=check_prim)

def get_refined_structure(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions csld/basic_lattice_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .atomic_model import AtomicModel
from .util.mathtool import relativePosition
from .util.tool import pad_right, matrix2text
from _c_util import get_structure_ordering
from csld._c_util import get_structure_ordering
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -274,7 +274,7 @@ def translate_cluster_to_supercell(sc, clus):
coords= clus.frac_coords
use_compiled_code = True
if use_compiled_code:
from f_util import f_util
from csld.f_util import f_util
allclus= f_util.tr_cl_sc(sc._ijkl.T, sc.sc_mat.T, sc.inv_sc_mat.T, sc.sc_ref.T, sc.prim.frac_coords.T, clus._ijkls_np.T).T-1
else:
allclus = [get_structure_ordering((coords+ijk[None,:]).dot(sc.inv_sc_mat), sc.frac_coords,0) for ijk in sc.ijk_ref]
Expand Down
Loading