Skip to content

Commit

Permalink
updated workflow, added badges
Browse files Browse the repository at this point in the history
  • Loading branch information
wolearyc committed Jul 29, 2024
1 parent 3b6ac3d commit 5bb04fa
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 86 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, lint, and run tests with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package
name: Test and Lint

on:
push:
Expand Down Expand Up @@ -31,6 +31,11 @@ jobs:
- name: Analyzing the code with pylint
run: |
pylint $(git ls-files '*.py')
- name: Analyzing the code with flake8
uses: py-actions/flake8@v2
with:
max-line-length: "88"
plugins: "flake8-bugbear==24.4.26"
- name: Test with pytest
run: |
pytest
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
skip: [pylint]
skip: [pylint,flake8]
exclude: EPS_OUTCAR
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -40,3 +40,12 @@ repos:
[
pytest,
]
- repo: https://github.com/pycqa/flake8
rev: '7.1.0' # pick a git hash / tag to point to
hooks:
- id: flake8
args: [--max-line-length=88]
additional_dependencies:
[
flake8-bugbear
]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ramannoodle
===========
[![python](https://img.shields.io/badge/Python-3.12-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/mit)

![Tests](reports/tests-badge.svg)


`ramannoodle` helps you calculate Raman spectra quickly and efficiency based on VASP calculations. **This software is currently being completely overhauled.** Check out the `legacy` branch for the old (and functional!) version.
8 changes: 0 additions & 8 deletions README.rst

This file was deleted.

48 changes: 0 additions & 48 deletions ramannoodle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,48 +0,0 @@
"""
Sample includes:
from dynamics import Phonons
from dynamics import MDTrajectory
from spectrum import RamanSpectrum
from spectrum import VibrationalSpectrum
from spectrometer import RamanSpectrometer
from spectrometer import VibrationalSpectrometer
from spectrum.phonons import PhononRamanSpectrum
from spectrum.md import MDRamanSpectrum
from polarizability import PolarizabilityModel
from polarizability.taylor import LinearPolarizabilityModel
Workflow:
1. Create a Dynamics object from your simulations.
2. Create an InterpolationPolarizabilityModel from your simulations.
- Set up a Symmetry object from an OUTCAR
- Set up a model for that symmetry
- Insert DOF, a set of displacements and polarizabilities (e.g. +,-,
polarizability_plus,polarizability_minus)
- Check that displacements given are colinear.
- That that the new displacements are orthogonal to all existing displacements
- If checks are successful:
- Generate all symmetry equivalent displacements.
- Do sanity check to ensure we're still totally orthogonal
- add interpolation and normalized dof displacements
Run a virtual experiment
- Specify RamanSettings (angle, polycrystalline)
- dynamics.get_spectrum(PolarizabilityModel, SpectrometerSettings) -> RamanSpectrum
Extract Relevant information from RamanSpectrum
- Spectrum.get_intensities(temperature, correction factors, smearing, etc.)
- Spectrum.get_wavenumbers()
-
For now, I will not implement SpectrometerSettings. This can wait.
"""
2 changes: 0 additions & 2 deletions ramannoodle/io/vasp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""Utilities for VASP."""

from pathlib import Path
from typing import TextIO
import numpy as np
from numpy.typing import NDArray

from ...dynamics import Phonons
from ...symmetry import StructuralSymmetry
from ...globals import ATOMIC_WEIGHTS, ATOMIC_NUMBERS
from .vasp_utils import (
_get_atomic_symbol_from_potcar_line,
_read_atomic_symbols_from_outcar,
_read_eigenvector_from_outcar,
_read_cartesian_positions_from_outcar,
Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/io/vasp/vasp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _read_polarizability_from_outcar(outcar_file: TextIO) -> NDArray[np.float64]


def _get_lattice_vector_from_outcar_line(line: str) -> NDArray[np.float64]:
"""e.g. "11.823066970 0.000000000 0.000000000 0.084580423 0.000000000 0.000000000" """
"""Extracts lattice vector from an appropriate line from an outcar"""
return np.array([float(item) for item in line.split()[0:3]])


Expand Down
2 changes: 0 additions & 2 deletions ramannoodle/polarizability/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import numpy as np
from numpy.typing import NDArray
from scipy.interpolate import make_interp_spline, BSpline
import spglib

from . import polarizability_utils
from ..symmetry.symmetry_utils import is_orthogonal_to_all
from ..symmetry import StructuralSymmetry
from ..exceptions import InvalidDOFException, SymmetryException


class PolarizabilityModel(ABC): # pylint: disable=too-few-public-methods
Expand Down
2 changes: 0 additions & 2 deletions ramannoodle/spectrum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Spectra."""

from abc import ABC, abstractmethod

import numpy as np
from numpy.typing import NDArray

Expand Down
3 changes: 1 addition & 2 deletions ramannoodle/symmetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import numpy as np
from numpy.typing import NDArray
from scipy.interpolate import make_interp_spline, BSpline
import spglib

from . import symmetry_utils
from ..exceptions import InvalidDOFException, SymmetryException
from ..exceptions import SymmetryException


class StructuralSymmetry:
Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/symmetry/symmetry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_fractional_positions_permutation_matrix(
def transform_fractional_positions(
positions: NDArray[np.float64],
rotation: NDArray[np.float64],
translation: NDArray[np.float64] = np.array([0.0, 0.0, 0.0]),
translation: NDArray[np.float64],
) -> NDArray[np.float64]:
"""Transforms fractional coordinates and applies periodic boundary
conditions."""
Expand Down
1 change: 1 addition & 0 deletions reports/coverage-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions reports/junit/junit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="23" time="49.055" timestamp="2024-07-28T20:57:27.535556-07:00" hostname="edna.local"><testcase classname="test.tests.test_polarizability" name="test_are_collinear[vector_10-vector_20-False]" time="0.001" /><testcase classname="test.tests.test_polarizability" name="test_are_collinear[vector_11-vector_21-False]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_are_collinear[vector_12-vector_22-True]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_are_collinear[vector_13-vector_23-False]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_check_orthogonal[vector_10-vectors0-2]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_check_orthogonal[vector_11-vectors1--1]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_structural_symmetry[test/data/TiO2_OUTCAR-2-36-known_displacements_shape0]" time="20.316" /><testcase classname="test.tests.test_polarizability" name="test_structural_symmetry[test/data/STO_RATTLED_OUTCAR-135-1-known_displacements_shape1]" time="0.112" /><testcase classname="test.tests.test_polarizability" name="test_structural_symmetry[test/data/LLZO_OUTCAR-9-32-known_displacements_shape2]" time="7.008" /><testcase classname="test.tests.test_polarizability" name="test_get_fractional_positions_permutation_matrix[reference0-permuted0-known0]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_find_duplicates[vectors0-None]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_find_duplicates[vectors1--0.05]" time="0.000" /><testcase classname="test.tests.test_polarizability" name="test_add_dof[test/data/STO_RATTLED_OUTCAR-0-magnitudes0-1]" time="0.114" /><testcase classname="test.tests.test_polarizability" name="test_add_dof[test/data/TiO2_OUTCAR-0-magnitudes1-72]" time="20.385" /><testcase classname="test.tests.test_vasp" name="test_load_phonons_from_outcar[test/data/TiO2_OUTCAR-108-known_wavenumbers0-known_first_displacement0-known_last_displacement0]" time="0.037" /><testcase classname="test.tests.test_vasp" name="test_get_atomic_symbol_from_potcar_line[ POTCAR: PAW_PBE Ti_pv 07Sep2000\n-Ti]" time="0.000" /><testcase classname="test.tests.test_vasp" name="test_get_atomic_symbol_from_potcar_line[ POTCAR: PAW_PBE O 08Apr2002 \n-O]" time="0.000" /><testcase classname="test.tests.test_vasp" name="test_read_atomic_symbols_from_outcar[test/data/TiO2_OUTCAR-known0]" time="0.000" /><testcase classname="test.tests.test_vasp" name="test_read_cartesian_positions_from_outcar[test/data/EPS_OUTCAR-known_first_position0-known_last_position0]" time="0.001" /><testcase classname="test.tests.test_vasp" name="test_read_fractional_positions_from_outcar[test/data/EPS_OUTCAR-known_first_position0-known_last_position0]" time="0.000" /><testcase classname="test.tests.test_vasp" name="test_read_polarizability_from_outcar[test/data/EPS_OUTCAR-known_polarizability0]" time="0.001" /><testcase classname="test.tests.test_vasp" name="test_read_lattice_from_outcar[test/data/TiO2_OUTCAR-known_lattice0]" time="0.000" /><testcase classname="test.tests.test_vasp" name="test_read_lattice_from_outcar[test/data/EPS_OUTCAR-known_lattice1]" time="0.000" /></testsuite></testsuites>
1 change: 1 addition & 0 deletions reports/tests-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flake8
numpy
pre-commit
pylint
Expand Down
26 changes: 8 additions & 18 deletions test/tests/test_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

from .. import EPS_OUTCAR_NUM_ATOMS, PHONONS_OUTCAR_NUM_ATOMS

# pylint: disable=protected-access


@pytest.mark.parametrize(
"outcar_path_fixture, known_num_atoms, known_wavenumbers,"
Expand Down Expand Up @@ -64,9 +66,7 @@ def test_load_phonons_from_outcar(
)
def test_get_atomic_symbol_from_potcar_line(potcar_line: str, known: str) -> None:
"""test"""
result = vasp_utils._get_atomic_symbol_from_potcar_line( # pylint: disable=protected-access
potcar_line
)
result = vasp_utils._get_atomic_symbol_from_potcar_line(potcar_line)
assert result == known


Expand All @@ -80,11 +80,7 @@ def test_read_atomic_symbols_from_outcar(
known: list[str],
) -> None:
"""test"""
atomic_symbols = (
vasp_utils._read_atomic_symbols_from_outcar( # pylint: disable=protected-access
outcar_file_fixture
)
)
atomic_symbols = vasp_utils._read_atomic_symbols_from_outcar(outcar_file_fixture)
assert atomic_symbols == known


Expand All @@ -105,7 +101,7 @@ def test_read_cartesian_positions_from_outcar(
known_last_position: NDArray[np.float64],
) -> None:
"""test"""
cartesian_positions = vasp_utils._read_cartesian_positions_from_outcar( # pylint: disable=protected-access
cartesian_positions = vasp_utils._read_cartesian_positions_from_outcar(
outcar_file_fixture, EPS_OUTCAR_NUM_ATOMS
)

Expand All @@ -131,7 +127,7 @@ def test_read_fractional_positions_from_outcar(
known_last_position: NDArray[np.float64],
) -> None:
"""test"""
fractional_positions = vasp_utils._read_fractional_positions_from_outcar( # pylint: disable=protected-access
fractional_positions = vasp_utils._read_fractional_positions_from_outcar(
outcar_file_fixture, EPS_OUTCAR_NUM_ATOMS
)

Expand Down Expand Up @@ -162,11 +158,7 @@ def test_read_polarizability_from_outcar(
) -> None:
"""test"""

polarizability = (
vasp_utils._read_polarizability_from_outcar( # pylint: disable=protected-access
outcar_file_fixture
)
)
polarizability = vasp_utils._read_polarizability_from_outcar(outcar_file_fixture)

assert np.isclose(polarizability, known_polarizability).all()

Expand Down Expand Up @@ -201,7 +193,5 @@ def test_read_lattice_from_outcar(
outcar_file_fixture: TextIO, known_lattice: NDArray[np.float64]
) -> None:
"""test"""
result = vasp_utils._read_lattice_from_outcar( # pylint: disable=protected-access
outcar_file_fixture
)
result = vasp_utils._read_lattice_from_outcar(outcar_file_fixture)
assert np.isclose(result, known_lattice).all()

0 comments on commit 5bb04fa

Please sign in to comment.