pygrpy

Python port of Generalized Rotne Prager Yamakawa hydrodynamic tensors.

https://github.com/radostw/pygrpy

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.1%) to scientific vocabulary

Keywords

fluid-dynamics fluid-mechanics jax physics python soft-matter stokes-flow stokesian-hydrodynamics
Last synced: 6 months ago · JSON representation ·

Repository

Python port of Generalized Rotne Prager Yamakawa hydrodynamic tensors.

Basic Info
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Topics
fluid-dynamics fluid-mechanics jax physics python soft-matter stokes-flow stokesian-hydrodynamics
Created almost 5 years ago · Last pushed 12 months ago
Metadata Files
Readme License Citation

README.md

Tests

PyGRPY

Python port of Generalized Rotne Prager Yakamawa hydrodynamic tensors.

Now also supports jax, and jax.grad.

Original code

Original code in Fortran90 by Pawel Jan Zuk here: https://github.com/pjzuk/GRPY

License

This software is licensed under GNU GPLv3

Copyright (c) Pawel Jan Zuk (2017) - unported code.

Copyright (c) Radost Waszkiewicz (2021) - python port.

How to cite

Waszkiewicz, R., Bartczak M., Kolasa K. and Lisicki M. Pychastic: Precise Brownian Dynamics using Taylor-Ito integrators in Python; SciPost Physics Codebases (2023)

https://scipost.org/SciPostPhysCodeb.11

bibtex @article{Waszkiewicz_2023, title = {Pychastic: Precise Brownian dynamics using Taylor-It{\=o} integrators in Python}, author = {Waszkiewicz, Radost and Bartczak, Maciej and Kolasa, Kamil and Lisicki, Maciej}, year = 2023, journal = {SciPost Physics Codebases}, pages = {11} } and

Zuk, P. J., Cichocki, B. and Szymczak, P. GRPY: an accurate bead method for calculation of hydrodynamic properties of rigid biomacromolecules; Biophys. J. (2018)

Examples

Hydrodynamic size of rigid conglomerate of beads

```python # Copyright (C) Radost Waszkiewicz 2022 # This software is distributed under MIT license # Test if line of four identical beads has correct hydrodynamic size

import pygrpy
import numpy as np
import json

centres_four = np.array([[0,0,0],[0,0,1],[0,0,2],[0,0,3]])
sizes_four = np.array([1,1,1,1])

def test_hydrosize():
    testsize = pygrpy.grpy.stokesRadius(centres_four,sizes_four)
    assert np.allclose(testsize, 1.5409546371938094)

if __name__ == "__main__":
    test_hydrosize()

```

```python
# Copyright (C) Radost Waszkiewicz 2024 # This software is distributed under MIT license # Load shape of Lysozyme-C from different databases. Compare hydrodynamic size

import pygrpy.pdb_loader
import pygrpy.grpy

pdb_content = pygrpy.pdb_loader.get_pdb_from_alphafold("P61626")
coordinates, radii = pygrpy.pdb_loader.centres_and_radii(pdb_content)
alphafold_size = pygrpy.grpy.stokesRadius(coordinates, radii)

pdb_content = pygrpy.pdb_loader.get_pdb_from_pdb("253L")
coordinates, radii = pygrpy.pdb_loader.centres_and_radii(pdb_content)
pdb_size = pygrpy.grpy.stokesRadius(coordinates, radii)

print("Alphafold size [Ang]:")
print(alphafold_size)
print("Protein Data Bank size [Ang]:")
print(pdb_size)

```

Hydrodynamic radius for conformational ensemble

```python # Copyright (C) Radost Waszkiewicz 2022 # This software is distributed under MIT license # Load an ensemble from a .pdb file and compute Rh using locations of Calpha atoms

import argparse
import numpy as np
import pygrpy
from tqdm import tqdm

# Console arguments.
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", default="test.pdb", help="specify input file")
parser.add_argument(
    "-s",
    "--sigmas",
    help="compute standard deviations using bootstrap",
    action="store_true",
)

args = parser.parse_args()

with open(args.input, encoding="utf-8") as f:
    contents = f.read()

lines = contents.splitlines()

ensemble = list()
residues = list()
for line in lines:
    if "ATOM" in line:
        if "CA" in line:
            x = float(line[30:38])
            y = float(line[38:46])
            z = float(line[46:54])
            residues.append([x, y, z])
    elif "END" in line:
        ensemble.append(residues)
        residues = list()

ensemble = np.array(ensemble)
(ensemble_size, molecule_size, _) = ensemble.shape

hydrodynamic_size = pygrpy.grpy.ensembleAveragedStokesRadius(
    ensemble, 4.2 * np.ones(molecule_size)
)  # sizes in angstroms

centre_of_mass = np.mean(ensemble, axis=1)  # shape = (conformer,3)
gyration_radius = np.sqrt(3) * np.sqrt(np.mean((ensemble - centre_of_mass.reshape(-1, 1, 3)) ** 2))

bootstrap_rounds = 5
if args.sigmas:
    hydrodynamic_sizes_stats = np.zeros(bootstrap_rounds)
    for i in tqdm(range(bootstrap_rounds)):
        chosen = np.random.choice(np.arange(ensemble_size), ensemble_size)
        hydrodynamic_sizes_stats[i] = pygrpy.grpy.ensembleAveragedStokesRadius(
            ensemble[chosen], 4.2 * np.ones(molecule_size)
        )

    print(
        f"Hydrodynamic radius [Ang] = {hydrodynamic_size:.4f} +/- {np.std(hydrodynamic_sizes_stats):.4f}"
    )
    print(f"Gyration radius     [Ang] = {gyration_radius:.4f}")

else:
    print(f"Hydrodynamic radius [Ang] = {hydrodynamic_size:.2f}")
    print(f"Gyration radius     [Ang] = {gyration_radius:.2f}")

```

Grand mobility matrices

```python

Copyright (C) Radost Waszkiewicz 2025

This software is distributed under MIT license

Check correctness of grand mobility matrix for two beads

import numpy as np import pygrpy

centrestwo = np.array([[0, 0, 0], [0, 0, 1]]) sizestwo = np.array([1, 1])

gmm_two = np.array( [ [5.3e-2, 0.0, 0.0, 3.8e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.2e-2, 0.0], [0.0, 5.3e-2, 0.0, 0.0, 3.8e-2, 0.0, 0.0, 0.0, 0.0, 1.2e-2, 0.0, 0.0], [0.0, 0.0, 5.3e-2, 0.0, 0.0, 4.3e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [3.8e-2, 0.0, 0.0, 5.3e-2, 0.0, 0.0, 0.0, 1.2e-2, 0.0, 0.0, 0.0, 0.0], [0.0, 3.8e-2, 0.0, 0.0, 5.3e-2, 0.0, -1.2e-2, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 4.3e-2, 0.0, 0.0, 5.3e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, -1.2e-2, 0.0, 4.0e-2, 0.0, 0.0, 9.0e-3, 0.0, 0.0], [0.0, 0.0, 0.0, 1.2e-2, 0.0, 0.0, 0.0, 4.0e-2, 0.0, 0.0, 9.0e-3, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0e-2, 0.0, 0.0, 1.9e-2], [0.0, 1.2e-2, 0.0, 0.0, 0.0, 0.0, 9.0e-3, 0.0, 0.0, 4.0e-2, 0.0, 0.0], [-1.2e-2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.0e-3, 0.0, 0.0, 4.0e-2, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.9e-2, 0.0, 0.0, 4.0e-2], ] )

def testmobilitytwobeads(): testmu = pygrpy.grpytensors.mu(centrestwo, sizestwo) assert type(testmu) == np.ndarray, "grpytesnors.mu should return np.array." assert np.allclose( testmu, gmmtwo, atol=1e-3 ), "grpy_tesnors.mu for two beads should return specified value." return testmu

if name == "main": print(testmobilitytwo_beads()) ```

Owner

  • Login: RadostW
  • Kind: user
  • Company: University of Warsaw

Mathematician / physicist / computer scientist. PhD student studying soft matter at University of Warsaw

Citation (CITATION.cff)

cff-version: 1.2.0

message: "If you use this implementation of PyGRPY, please cite it as below."

authors:
- family-names: "Waszkiewicz"
  given-names: "Radost"
  orcid: "https://orcid.org/0000-0002-0376-1708"
  
- family-names: "Bartczak"
  given-names: "Maciej"
  orcid: "https://orcid.org/0000-0003-1081-3294"
  
- family-names: "Kolasa"
  given-names: "Kamil"
  orcid: "https://orcid.org/0000-0002-2281-1539"
  
- family-names: "Lisicki"
  given-names: "Maciej"
  orcid: "https://orcid.org/0000-0002-6976-0281"
  
title: "Pychastic: Precise Brownian Dynamics using Taylor-Ito integrators in Python"

doi: 10.21468/SciPostPhysCodeb.11
date-released: 2022-09-09
url: "https://scipost.org/10.21468/SciPostPhysCodeb.11"

publisher: SciPost
pages: 11
year: 2023
journal: SciPost Phys. Codebases

GitHub Events

Total
  • Issues event: 2
  • Watch event: 2
  • Issue comment event: 6
  • Push event: 8
Last Year
  • Issues event: 2
  • Watch event: 2
  • Issue comment event: 6
  • Push event: 8

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 50
  • Total Committers: 2
  • Avg Commits per committer: 25.0
  • Development Distribution Score (DDS): 0.04
Past Year
  • Commits: 12
  • Committers: 1
  • Avg Commits per committer: 12.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Radost Waszkiewicz r****z@g****m 48
RadostW 5****W 2

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 1
  • Average time to close issues: about 1 hour
  • Average time to close pull requests: 1 minute
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • RadostW (1)
  • celoy (1)
Pull Request Authors
  • RadostW (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 34 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 1
  • Total versions: 13
  • Total maintainers: 1
pypi.org: pygrpy

Python port of Generalized Rotne Prager Yakamava tensors

  • Versions: 13
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 34 Last month
Rankings
Dependent packages count: 4.8%
Dependent repos count: 21.5%
Forks count: 22.6%
Average: 23.4%
Stargazers count: 31.9%
Downloads: 36.2%
Maintainers (1)
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • docutils ==0.16
  • jax ==0.2.13
  • jaxlib ==0.1.67
  • numpy ==1.20.3
  • pydata-sphinx-theme ==0.6.3
  • scipy ==1.5.4
  • sphinx-copybutton ==0.3.1
  • sphinx-prompt ==1.4.0
  • sphinxcontrib-applehelp ==1.0.2
  • sphinxcontrib-devhelp ==1.0.2
  • sphinxcontrib-htmlhelp ==2.0.0
  • sphinxcontrib-jsmath ==1.0.1
  • sphinxcontrib-napoleon ==0.7
  • sphinxcontrib-qthelp ==1.0.3
  • sphinxcontrib-serializinghtml ==1.1.5
requirements.txt pypi
  • jax ==0.2.13
  • jaxlib ==0.1.66
  • numpy ==1.20.3
  • scipy ==1.5.4
.github/workflows/tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
setup.py pypi