Skip to content

Commit

Permalink
PEP8 fixes. Moved two_origin_choice to materials.symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
saransh13 committed Aug 20, 2024
1 parent 8655bd4 commit 5602363
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 129 deletions.
90 changes: 38 additions & 52 deletions hexrd/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
zeros_3x1 = np.zeros((3, 1))
zeros_6x1 = np.zeros((6, 1))

# reference beam direction and eta=0 ref in LAB FRAME for standard geometry
'''reference beam direction and
eta=0 ref in LAB FRAME for standard geometry'''
beam_vec = -lab_z
eta_vec = lab_x

Expand Down Expand Up @@ -162,7 +163,9 @@
3628800.]).astype(np.complex128)

"""
>> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab, [email protected]
>> @AUTHOR: Saransh Singh,
Lawrence Livermore National Lab,
[email protected]
>> @DATE: 11/28/2022 SS 1.0 original
>> @DETAILS: constants for rodrigues FZ
"""
Expand All @@ -177,7 +180,9 @@
)

'''
>> @AUTHOR: Saransh Singh, Lawrence Livermore National Lab, [email protected]
>> @AUTHOR: Saransh Singh,
Lawrence Livermore National Lab,
[email protected]
>> @DATE: 10/28/2020 SS 1.0 original
>> @DETAILS: constants for sphere sectors used for IPF coloring
'''
Expand Down Expand Up @@ -263,7 +268,8 @@ def set_numba_cache():
4. The NUMBA_CACHE_DIR environment variable is not defined
If all of these are true, then numba will try to write to a
directory where it doesn't have permission, and cause the application to
directory where it doesn't have permission,
and cause the application to
freeze. Avoid that by setting the cache dir ourselves.
"""

Expand Down Expand Up @@ -316,8 +322,10 @@ def is_writable_file(path):
cRestmass = 9.1093837090E-31

'''
adding another parametrization of the scattering factors. these are more recent
and more accurate. also used in Vesta (copied from there). see:
adding another parametrization of the
scattering factors. these are more recent
and more accurate. also used in Vesta
(copied from there). see:
New Analytical coherent Scattering-Factor Functions for Free Atoms and Ions
BY D. WAASMAIER AND A. KIRFEL
Expand Down Expand Up @@ -638,7 +646,9 @@ def is_writable_file(path):
'Cf': ['0']
}
'''
this dictionary tabulates the small nuclear Thomson term fNT for all elements up to Z=92
this dictionary tabulates the small
nuclear Thomson term fNT for all
elements up to Z=92
'''
fNT = {
'H':-0.00054423,'He':-0.00054817,'Li':-0.00071131,'Be':-0.00097394,'B':-0.0012687,'C':-0.0016442,'N':-0.0019191,'O':-0.0021944,
Expand Down Expand Up @@ -737,8 +747,10 @@ def is_writable_file(path):
229
])

''' this variable encodes all the generators (including translations) for all 230 space groups
will be used to compute the full space group symmetry operators
''' this variable encodes all the generators
(including translations) for all 230 space groups
will be used to compute the full space group symmetry
operators
'''
SYM_GL = [
"000 ", "100 ", "01cOOO0 ",
Expand Down Expand Up @@ -996,8 +1008,10 @@ def is_writable_file(path):
}

'''
this dictionary contains the generators encoded in each letter of the generator string
the full symmetry is generated by the repeated action of the generator matrix
this dictionary contains the generators encoded
in each letter of the generator string
the full symmetry is generated by the repeated
action of the generator matrix
'''

''' rotational, inversions, mirrors etc. components
Expand Down Expand Up @@ -1100,49 +1114,21 @@ def is_writable_file(path):
SYM_GENERATORS['Y'] = -1./4.
SYM_GENERATORS['Z'] = -1./8.

''' this dictionary contains the space group numbers
which have two origin choices the two values are the
site symmetries of the origin. There are 24 such space
groups
'''
two_origin_choice = {
48 : ['222', '-1'],
50 : ['222/n', '-1'],
59 : ['mm2/n', '-1'],
68 : ['222', '-1'],
70 : ['222', '-1'],
85 : ['-4', '-1'],
86 : ['-4', '-1'],
88 : ['-4', '-1'],
125: ['422', '2/m'],
126: ['422/n', '-1'],
129: ['-4m2', '2/m'],
130: ['-4/ncn', '-1'],
133: ['-4121/c', '-1'],
134: ['-42m', '2/m'],
137: ['-4m2/n', '-1'],
138: ['-4cg', '2/m'],
141: ['-4m2', '2/m'],
142: ['-4c21', '-1'],
201: ['23', '-3'],
203: ['23', '-3'],
222: ['432', '-3'],
224: ['-43m', '-3m'],
227: ['-43m', '-3m'],
228: ['23', '-3'],
}


'''
@AUTHOR Saransh Singh, Lawrence Livermore National Lab, [email protected]
@AUTHOR Saransh Singh,
Lawrence Livermore National Lab,
[email protected]
@DATE 11/23/2020 SS 1.0 original
@DETAIL. this list of symbols will help us to genrate the point group symmetries
in the cartesian space for any point group. this is needed for the
supergroup symmetry usd in the coloring scheme used in the package. this
needs to be a separate set of routines because the supergroup can be a
point group which is not the laue group of the crystal (e.g. m-3 --> m-3m)
the notation used will be the same as the one used for the space group
without any translations.
@DETAIL. this list of symbols will help us to genrate
the point group symmetries in the cartesian
space for any point group. this is needed for
the supergroup symmetry usd in the coloring
scheme used in the package. this needs to be a
separate set of routines because the supergroup
can be a point group which is not the laue group
of the crystal (e.g. m-3 --> m-3m) the notation
used will be the same as the one used for the
space group without any translations.
'''
SYM_GL_PG = {
'c1': '1a', # only identity rotation
Expand Down
13 changes: 7 additions & 6 deletions hexrd/material/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

from hexrd.material.crystallography import PlaneData as PData
from hexrd.material import symmetry, unitcell
from hexrd.material.symbols import two_origin_choice
from hexrd.valunits import valWUnit
from hexrd.constants import (ptable,
ptableinverse,
chargestate,
two_origin_choice)
ptableinverse,
chargestate)

from os import path
from pathlib import Path
Expand Down Expand Up @@ -79,6 +79,7 @@ def _kev(x):
def _key(x):
return x.name


def get_default_sgsetting(sgnum):
if sgnum in two_origin_choice:
return 1
Expand Down Expand Up @@ -187,8 +188,8 @@ def __init__(
elif isinstance(material_file, h5py.Group) or form in h5_suffixes:
self._readHDFxtal(fhdf=material_file, xtal=name)
if sgsetting is not None:
if sgsetting in [0, 1]:
self._sgsetting = sgsetting
if sgsetting in [0, 1]:
self._sgsetting = sgsetting
else:
# default name
self._name = Material.DFLT_XTAL
Expand Down Expand Up @@ -1436,7 +1437,7 @@ def loadMaterialList(cfgFile):


def load_materials_hdf5(
f, dmin=None, kev=None):
f, dmin=None, kev=None):
"""Load materials from an HDF5 file
The file uses the HDF5 file format.
Expand Down
22 changes: 13 additions & 9 deletions hexrd/material/mksupport.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from hexrd.material.symbols import pstr_Elements, sitesym, \
tworig, PrintPossibleSG, TRIG, pstr_spacegroup,\
pstr_mkxtal
from hexrd.material.symbols import (pstr_Elements,
two_origin_choice,
PrintPossibleSG,
TRIG,
pstr_spacegroup,
pstr_mkxtal)
import h5py
import os
import numpy as np
import datetime
import getpass
from hexrd.material.unitcell import _StiffnessDict, _pgDict


def mk(filename, xtalname):

# print some initial information for the user
Expand All @@ -23,7 +27,7 @@ def mk(filename, xtalname):

AtomInfo = GetAtomInfo()
AtomInfo.update({'file': filename, 'xtalname': xtalname,
'xtal_sys': xtal_sys, 'SG': space_group,\
'xtal_sys': xtal_sys, 'SG': space_group,
'SGsetting': iset})

Write2H5File(AtomInfo, lat_param)
Expand Down Expand Up @@ -275,14 +279,15 @@ def GetSpaceGroup(xtal_sys, btrigonal, bhexset):
def SpaceGroupSetting(sgnum):

iset = 1
if(sgnum in tworig):
idx = tworig.index(sgnum)
if(sgnum in two_origin_choice):
sitesym1 = two_origin_choice[sgnum][0]
sitesym2 = two_origin_choice[sgnum][1]
print(' ---------------------------------------------')
print(' This space group has two origin settings.')
print(' The first setting has site symmetry : ' +
sitesym[2*idx - 2])
sitesym1)
print(' the second setting has site symmetry : ' +
sitesym[2*idx - 1])
sitesym2)
iset = input(' Which setting do you wish to use (1/2) : ')
if(not iset.isdigit()):
raise ValueError("Invalid integer value for atomic number.")
Expand All @@ -294,7 +299,6 @@ def SpaceGroupSetting(sgnum):

return iset-1


def GetAtomInfo():

print(pstr_Elements)
Expand Down
42 changes: 31 additions & 11 deletions hexrd/material/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,37 @@
'89:Ac 90:Th 91:Pa 92:U' + "\n" \
' ----------------------------------------------------------------------------------------------------------'

sitesym = ['222 ',' -1 ','222/n ',' -1 ','mm2/n ',' -1 ', \
'222 ',' -1 ','222 ',' -1 ','-4 ',' -1 ', \
'-4 ',' -1 ','-4 ',' -1 ','422 ','2/m ', \
'422/n ',' -1 ','-4m2 ','2/m ','-4/ncn ',' -1 ', \
'-4121/c',' -1 ','-42m ','2/m ','-4m2/n ',' -1 ', \
'-4cg ','2/m ','-4m2 ','2/m ','-4c21 ',' -1 ', \
'23 ',' -3 ','23 ',' -3 ','432 ',' -3 ', \
'-43m ','-3m ','-43m ','-3m ','23 ',' -3 ']

tworig = [48,50,59,68,70,85,86,88,125,126,129,130,133,134,137,138,\
141,142,201,203,222,224,227,228]
''' this dictionary contains the space group numbers
which have two origin choices the two values are the
site symmetries of the origin. There are 24 such space
groups
'''
two_origin_choice = {
48 : ['222', '-1'],
50 : ['222/n', '-1'],
59 : ['mm2/n', '-1'],
68 : ['222', '-1'],
70 : ['222', '-1'],
85 : ['-4', '-1'],
86 : ['-4', '-1'],
88 : ['-4', '-1'],
125: ['422', '2/m'],
126: ['422/n', '-1'],
129: ['-4m2', '2/m'],
130: ['-4/ncn', '-1'],
133: ['-4121/c', '-1'],
134: ['-42m', '2/m'],
137: ['-4m2/n', '-1'],
138: ['-4cg', '2/m'],
141: ['-4m2', '2/m'],
142: ['-4c21', '-1'],
201: ['23', '-3'],
203: ['23', '-3'],
222: ['432', '-3'],
224: ['-43m', '-3m'],
227: ['-43m', '-3m'],
228: ['23', '-3'],
}


def PrintPossibleSG(xtal_sys):
Expand Down
Loading

0 comments on commit 5602363

Please sign in to comment.