Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make read smooth #87

Merged
merged 5 commits into from
Apr 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.2
current_version = 0.5.3
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ url: 'https://atomrdf.pyscal.org'
license: "MIT"
repository-code: https://github.com/pyscal/atomRDF
type: software
version: 0.5.2
version: 0.5.3
6 changes: 6 additions & 0 deletions atomrdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ def add_structure(self, structure):

def _is_valid(self, input_list):
valid = False
flat_list = []
for x in input_list:
if isinstance(x,list):
flat_list.extend(x)
else:
flat_list.append(x)
for x in flat_list:
if x is not None:
valid = True
break
Expand Down
48 changes: 46 additions & 2 deletions atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import json
import shutil
import tarfile
import warnings

import pyscal3.structure_creator as pcs
from pyscal3.grain_boundary import GrainBoundary
Expand Down Expand Up @@ -136,6 +137,45 @@ def _read_structure(filename,
basis_box=None,
basis_positions=None,
):
"""
Read in structure from file or ase object

Parameters
----------
filename: string
name of file

format: optional, string
format of the file

graph: optional
if provided, the structure will be added to the graph

names: bool, optional
if True, human readable names instead of random ids will be created.

species: list, optional
if provided lammps types will be matched to species. For example, if types 1 and 2 exist
in the input file, and species = ['Li', 'Al'] is given, type 1 will be matched to 'Li' and
type 2 will be matched to 'Al'

lattice: str, optional
currently supported lattices are {simple_cubic, bcc, fcc, hcp, dhcp, diamond, a15, l12, b2}
if provided, information such as the unit cell, basis positions, space groups, etc are automatically added

lattice_constant: float, optional
specify the lattice constant of the system

basis_box: 3x3 list, optional
specify the basis unit cell. Not required if lattice is provided

basis_positions: nX3 list, optional
specify the relative positions of atoms in the unit cell. Not required if lattice is provided

Returns
-------
Structure
"""
datadict = {}
if lattice is not None:
if lattice in structure_dict.keys():
Expand All @@ -149,7 +189,7 @@ def _read_structure(filename,
datadict['positions'] = basis_positions

s = System(filename, format=format, species=species,
graph=graph, names=names)
graph=graph, names=names, warn_read_in=False)
s.lattice_properties = datadict
s.to_graph()
return s
Expand Down Expand Up @@ -191,8 +231,12 @@ def __init__(self, filename = None,
species = None,
source=None,
graph=None,
names=False):
names=False,
warn_read_in=True):

if (filename is not None) and warn_read_in:
warnings.warn('To provide additional information, use the System.read.file method')

super().__init__(filename = filename,
format = format,
compressed = compressed,
Expand Down
1,295 changes: 1,295 additions & 0 deletions examples/07_read_in.ipynb

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions examples/conf.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ITEM: TIMESTEP
0
ITEM: NUMBER OF ATOMS
2
ITEM: BOX BOUNDS pp pp pp
0.0 2.87
0.0 2.87
0.0 2.87
ITEM: ATOMS x y z type id
0.0 0.0 0.0 1 1
1.435 1.435 1.435 1 2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='atomrdf',
version='0.5.2',
version='0.5.3',
author='Abril Azocar Guzman, Sarath Menon',
author_email='[email protected]',
description='Ontology based structural manipulation and quering',
Expand Down
Loading