Skip to content

Commit

Permalink
Merge pull request #25 from htz1992213/main
Browse files Browse the repository at this point in the history
upgrade lint and test checks
  • Loading branch information
htz1992213 committed Feb 5, 2024
2 parents 4f2af18 + bcc3572 commit b3d4dab
Show file tree
Hide file tree
Showing 34 changed files with 683 additions and 684 deletions.
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Configuration file for the Sphinx documentation builder.
"""Configuration file for the Sphinx documentation builder."""
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
Expand All @@ -10,10 +10,10 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from __future__ import annotations

import os
import sys
import sphinx_rtd_theme, sphinx_autodoc_typehints
from typing import List

sys.path.insert(0, os.path.abspath("../../mdgo"))

Expand Down Expand Up @@ -55,7 +55,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List[str] = []
exclude_patterns: list[str] = []


# -- Options for HTML output -------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions mdgo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# coding: utf-8
# Copyright (c) Tingzheng Hou.
# Distributed under the terms of the MIT License.

"""
This package contains core modules and classes molecular dynamics simulation setup and analysis.
"""
"""This package contains core modules and classes molecular dynamics simulation setup and analysis."""

from __future__ import annotations

__author__ = "Mdgo Development Team"
__email__ = "tingzheng_hou@berkeley.edu"
__maintainer__ = "Tingzheng Hou"
Expand Down
33 changes: 17 additions & 16 deletions mdgo/conductivity.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# coding: utf-8
# Copyright (c) Tingzheng Hou.
# Distributed under the terms of the MIT License.

"""
This module implements functions to calculate the ionic conductivity.
"""
from typing import Union
"""This module implements functions to calculate the ionic conductivity."""

from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np
from tqdm.auto import tqdm
from scipy import stats
from MDAnalysis import Universe, AtomGroup
from tqdm.auto import tqdm

from mdgo.msd import msd_fft

if TYPE_CHECKING:
from MDAnalysis import AtomGroup, Universe

__author__ = "Kara Fong, Tingzheng Hou"
__version__ = "0.3.0"
__maintainer__ = "Tingzheng Hou"
Expand All @@ -26,10 +28,10 @@ def calc_cond_msd(
anions: AtomGroup,
cations: AtomGroup,
run_start: int,
cation_charge: Union[int, float] = 1,
anion_charge: Union[int, float] = -1,
cation_charge: float = 1,
anion_charge: float = -1,
) -> np.ndarray:
"""Calculates the conductivity "mean square displacement" over time
"""Calculates the conductivity "mean square displacement" over time.
Note:
Coordinates must be unwrapped (in dcd file when creating MDAnalysis Universe)
Expand All @@ -51,15 +53,14 @@ def calc_cond_msd(
anion_list = anions.split("residue")
# compute sum over all charges and positions
qr = []
for ts in tqdm(u.trajectory[run_start:]):
for _ts in tqdm(u.trajectory[run_start:]):
qr_temp = np.zeros(3)
for anion in anion_list:
qr_temp += anion.center_of_mass() * anion_charge
for cation in cation_list:
qr_temp += cation.center_of_mass() * cation_charge
qr.append(qr_temp)
msd = msd_fft(np.array(qr))
return msd
return msd_fft(np.array(qr))


def get_beta(
Expand Down Expand Up @@ -127,14 +128,14 @@ def choose_msd_fitting_region(
def conductivity_calculator(
time_array: np.ndarray,
cond_array: np.ndarray,
v: Union[int, float],
v: float,
name: str,
start: int,
end: int,
T: Union[int, float],
T: float,
units: str = "real",
) -> float:
"""Calculates the overall conductivity of the system
"""Calculates the overall conductivity of the system.
Args:
time_array: times at which position data was collected in the simulation
Expand Down
Loading

0 comments on commit b3d4dab

Please sign in to comment.