Skip to content

Commit

Permalink
Merge branch 'main' into optimize_json_loading
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 authored Feb 3, 2024
2 parents 57943b7 + 9d20e3d commit 30d0d5e
Show file tree
Hide file tree
Showing 57 changed files with 84 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: trailing-whitespace
exclude: setup.cfg
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
args: [--line-length=80]
Expand Down
1 change: 1 addition & 0 deletions mbuild/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild: a hierarchical, component based molecule builder."""

from mbuild.box import Box
from mbuild.coarse_graining import coarse_grain
from mbuild.compound import *
Expand Down
1 change: 1 addition & 0 deletions mbuild/box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild box module."""

from warnings import warn

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions mbuild/coarse_graining.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for coarse-grained systems."""

from collections import OrderedDict
from copy import deepcopy

Expand Down
30 changes: 24 additions & 6 deletions mbuild/compound.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for working with mBuild Compounds."""

__all__ = ["clone", "Compound", "Particle"]

import itertools
Expand Down Expand Up @@ -1864,7 +1865,11 @@ def particles_in_range(
return particle_array[idxs]

def visualize(
self, show_ports=False, backend="py3dmol", color_scheme={}
self,
show_ports=False,
backend="py3dmol",
color_scheme={},
bead_size=0.3,
): # pragma: no cover
"""Visualize the Compound using py3dmol (default) or nglview.
Expand All @@ -1882,6 +1887,8 @@ def visualize(
keys are strings of the particle names
values are strings of the colors
i.e. {'_CGBEAD': 'blue'}
bead_size : float, Optional, default=0.3
Size of beads in visualization
"""
viz_pkg = {
"nglview": self._visualize_nglview,
Expand All @@ -1890,7 +1897,9 @@ def visualize(
if run_from_ipython():
if backend.lower() in viz_pkg:
return viz_pkg[backend.lower()](
show_ports=show_ports, color_scheme=color_scheme
show_ports=show_ports,
color_scheme=color_scheme,
bead_size=bead_size,
)
else:
raise RuntimeError(
Expand All @@ -1903,7 +1912,9 @@ def visualize(
"Visualization is only supported in Jupyter Notebooks."
)

def _visualize_py3dmol(self, show_ports=False, color_scheme={}):
def _visualize_py3dmol(
self, show_ports=False, color_scheme={}, bead_size=0.3
):
"""Visualize the Compound using py3Dmol.
Allows for visualization of a Compound within a Jupyter Notebook.
Expand All @@ -1917,6 +1928,8 @@ def _visualize_py3dmol(self, show_ports=False, color_scheme={}):
keys are strings of the particle names
values are strings of the colors
i.e. {'_CGBEAD': 'blue'}
bead_size : float, Optional, default=0.3
Size of beads in visualization
Returns
-------
Expand Down Expand Up @@ -1951,15 +1964,20 @@ def _visualize_py3dmol(self, show_ports=False, color_scheme={}):

view.setStyle(
{
"stick": {"radius": 0.2, "color": "grey"},
"sphere": {"scale": 0.3, "colorscheme": modified_color_scheme},
"stick": {"radius": bead_size * 0.6, "color": "grey"},
"sphere": {
"scale": bead_size,
"colorscheme": modified_color_scheme,
},
}
)
view.zoomTo()

return view

def _visualize_nglview(self, show_ports=False, color_scheme={}):
def _visualize_nglview(
self, show_ports=False, color_scheme={}, bead_size=0.3
):
"""Visualize the Compound using nglview.
Allows for visualization of a Compound within a Jupyter Notebook.
Expand Down
1 change: 1 addition & 0 deletions mbuild/conversion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for handling conversions in mBuild."""

import os
import sys
from collections import defaultdict
Expand Down
1 change: 1 addition & 0 deletions mbuild/coordinate_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Coordinate transformation functions."""

from warnings import simplefilter, warn

simplefilter("always", DeprecationWarning)
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/cassandramcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
https://cassandra-mc.readthedocs.io/en/latest/guides/input_files.html#molecular-connectivity-file
"""

from __future__ import division

import warnings
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/gsdwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
https://gsd.readthedocs.io/en/stable/
"""

import numpy as np

from mbuild.utils.geometry import coord_shift
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/hoomd_forcefield.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""HOOMD v3 forcefield format."""

import itertools
import operator
import warnings
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/hoomd_simulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""HOOMD simulation format."""

import itertools
import operator
import warnings
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/hoomd_snapshot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""HOOMD snapshot format."""

import operator
from collections import namedtuple

Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/hoomdxml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""HOOMD xml format."""

import operator
from collections import namedtuple
from math import radians
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/json_formats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""JSON format."""

import json
from collections import OrderedDict

Expand Down
5 changes: 2 additions & 3 deletions mbuild/formats/lammpsdata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""LAMMPS data format."""

import itertools as it
from collections import OrderedDict
from warnings import warn
Expand Down Expand Up @@ -708,9 +709,7 @@ def _get_bond_types(
(
round(
bond.type.k
* (
sigma_conversion_factor**2 / epsilon_conversion_factor
),
* (sigma_conversion_factor**2 / epsilon_conversion_factor),
bond_precision,
),
round(bond.type.req / sigma_conversion_factor, bond_precision),
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/par_writer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CHARMM Par format."""

import warnings

__all__ = ["write_par"]
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A language-agnostic data serialization format developed by Google
https://developers.google.com/protocol-buffers
"""

import ele
import numpy as np
from google.protobuf.text_format import Merge, PrintMessage
Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/vasp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""VASP POSCAR format."""

import warnings
from itertools import chain

Expand Down
1 change: 1 addition & 0 deletions mbuild/formats/xyz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""XYZ format."""

from warnings import warn

import numpy as np
Expand Down
7 changes: 4 additions & 3 deletions mbuild/lattice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild lattice module for working with crystalline systems."""

import itertools as it
import pathlib
import warnings
Expand Down Expand Up @@ -679,8 +680,8 @@ def populate(self, compound_dict=None, x=1, y=1, z=1):

# if coordinates are below a certain threshold, set to 0
tolerance = 1e-12
ret_lattice.xyz_with_ports[
ret_lattice.xyz_with_ports <= tolerance
] = 0.0
ret_lattice.xyz_with_ports[ret_lattice.xyz_with_ports <= tolerance] = (
0.0
)

return ret_lattice
1 change: 1 addition & 0 deletions mbuild/lib/atoms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild library of atoms."""

from mbuild.lib.atoms.c3 import C3
from mbuild.lib.atoms.h import H
from mbuild.lib.atoms.n4 import N4
1 change: 1 addition & 0 deletions mbuild/lib/atoms/c3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A tri-valent, planar carbon atom."""

import numpy as np

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/atoms/h.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""An H atom."""

import numpy as np

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/atoms/n4.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild atom library for tetravalent nitrogen."""

import numpy as np

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/bulk_materials/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""mBuild bulk materials library."""

from mbuild.lib.bulk_materials.amorphous_silica_bulk import AmorphousSilicaBulk
1 change: 1 addition & 0 deletions mbuild/lib/bulk_materials/amorphous_silica_bulk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A bulk structure of amorphous silica."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild library of common chemical moieties."""

from mbuild.lib.moieties.ch2 import CH2
from mbuild.lib.moieties.ch3 import CH3
from mbuild.lib.moieties.ester import Ester
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/ch2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CH2 moiety."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/ch3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild CH3 moiety."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/ester.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Ester moiety."""

import numpy as np

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/h2o.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A water molecule."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/peg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild polyethylene glycol (PEG) monomer moiety."""

__author__ = "jonestj1"

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/moieties/silane.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A Silane (Si(OH)2) moiety."""

import numpy as np

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/molecules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Library of molecules for mBuild."""

from mbuild.lib.molecules.ethane import Ethane
from mbuild.lib.molecules.methane import Methane
from mbuild.lib.molecules.water import (
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/molecules/ethane.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""An ethane molecule."""

import mbuild as mb
from mbuild.lib.moieties import CH3

Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/molecules/methane.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A methane molecule."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/molecules/water.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Water molecules with geometries from different models."""

import numpy as np

import mbuild as mb
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Library of recipes for mBuild."""

from mbuild.lib.recipes.alkane import Alkane
from mbuild.lib.recipes.monolayer import Monolayer
from mbuild.lib.recipes.polymer import Polymer
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/alkane.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild recipe for a generic alkane chain."""

import mbuild as mb
from mbuild.lib.moieties import CH2, CH3
from mbuild.lib.molecules import Ethane, Methane
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/monolayer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild monolayer recipe."""

from copy import deepcopy
from warnings import warn

Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/polymer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Recipe for an mBuild polymer."""

import itertools as it

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/silica_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild recipe for a silica interface."""

import math
import random

Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/tiled_compound.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for creating TiledCompounds."""

__all__ = ["TiledCompound"]

import itertools as it
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/recipes/water_box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""mBuild recipe for building a water box."""

import itertools
import math as math
from collections.abc import Iterable
Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/surfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""mBuild surface library."""

from mbuild.lib.surfaces.amorphous_silica_surface import AmorphousSilicaSurface
from mbuild.lib.surfaces.betacristobalite import Betacristobalite
1 change: 1 addition & 0 deletions mbuild/lib/surfaces/amorphous_silica_surface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Amorphous silica surface."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/lib/surfaces/betacristobalite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Beta-cristobalite surface."""

import mbuild as mb


Expand Down
1 change: 1 addition & 0 deletions mbuild/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
http://leandro.iqm.unicamp.br/m3g/packmol/home.shtml
"""

import os
import sys
import tempfile
Expand Down
Loading

0 comments on commit 30d0d5e

Please sign in to comment.