HEXRD / hexrd

A cross-platform, open-source library for the analysis of X-ray diffraction data.
Other
56 stars 25 forks source link

command line interface to make a new material #712

Open saransh13 opened 3 weeks ago

saransh13 commented 3 weeks ago

The usage is as follows:

usage: hexrd make-material [-h] [-f FILE] [-x XTAL]

make a new material file in the hdf5 format using the command line. user specifies the file and crystal names

options:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  name of h5 file, default = test.h5
  -x XTAL, --xtal XTAL  name of crystal, default = xtal```

The command line guides the users through a series of informational prompts and question. Here is an example for making a Ni crystal with isotropic Debye-waller factors

```(hexrd) szechuan:Desktop soderlind3$ hexrd make-material --file test.h5 --xtal Ni

  This is a program to create a HDF5 file for storing crystallographic information.
  The following inputs are required:
          Crystal System:
                 1. Cubic
                 2. Tetragonal
                 3. Orthorhombic
                 4. Hexagonal
                 5. Trigonal
                 6. Monoclinic
                 7. Triclinic

         Space group number
         Atomic number (Z) for all species in unit cell
         Asymmetric positions for all atoms in unit cell
         Debye-Waller factors for all atoms in the unit cell
         You'll be prompted for these values now

 Note about the trigonal system:
 -------------------------------
 Primitive trigonal crystals are defined with respect to a HEXAGONAL
 reference frame.  Rhombohedral crystals can be referenced with
 respect to a HEXAGONAL basis (first setting), or with respect to
 a RHOMBOHEDRAL basis (second setting).  The default setting for
 trigonal symmetry is the hexagonal setting.  When you select
 crystal system 5 above, you will be prompted for the setting. 

Crystal System (1-7 use the legend above): 1  
a [nm] : 0.361

195: P 2 3      196: F 2 3      197: I 2 3      198: P 21 3     
199: I 21 3     200: P m 3      201: P n 3      202: F m 3      
203: F d 3      204: I m 3      205: P a 3      206: I a 3      
207: P 4 3 2    208: P 42 3 2   209: F 4 3 2    210: F 41 3 2   
211: I 4 3 2    212: P 43 3 2   213: P 41 3 2   214: I 41 3 2   
215: P -4 3 m   216: F -4 3 m   217: I -4 3 m   218: P -4 3 n   
219: F -4 3 c   220: I -4 3 d   221: P m 3 m    222: P n 3 n    
223: P m 3 n    224: P n 3 m    225: F m 3 m    226: F m 3 c    
227: F d 3 m    228: F d 3 c    229: I m 3 m    230: I a 3 d    

Space group number (use legend above): 225
------------------------------------ Periodic Table of the Elements --------------------------------------
1:H                                                                                                    2:He
3:Li  4:Be                                                               5:B   6:C   7:N   8:O   9:F  10:Ne
11:Na 12:Mg                                                             13:Al 14:Si 15:P  16:S  17:Cl 18:Ar
19:K  20:Ca 21:Sc 22:Ti 23:V  24:Cr 25:Mn 26:Fe 27:Co 28:Ni 29:Cu 30:Zn 31:Ga 32:Ge 33:As 34:Se 35:Br 36:Kr
37:Rb 38:Sr 39:Y  40:Zr 41:Nb 42:Mo 43:Tc 44:Ru 45:Rh 46:Pd 47:Ag 48:Cd 49:In 50:Sn 51:Sb 52:Te 53: I 54:Xe
55:Cs 56:Ba ----- 72:Hf 73:Ta 74:W  75:Re 76:Os 77:Ir 78:Pt 79:Au 80:Hg 81:Tl 82:Pb 83:Bi 84:Po 85:At 86:Rn
87:Fr 88:Ra -----
57:La 58:Ce 59:Pr 60:Nd 61:Pm 62:Sm 63:Eu 64:Gd 65:Tb 66:Dy 67:Ho 68:Er 69:Tm 70:Yb 71:Lu
89:Ac 90:Th 91:Pa 92:U
 ----------------------------------------------------------------------------------------------------------
Enter atomic number of species :   28
Enter asymmetric position of atom in unit cell separated by comma (fractional coordinates) :  0,0,0
Enter site occupation :    1
Isotropic or anisotropic Debye-Waller factor? 
              1 for isotropic, 2 for anisotropic : 1
Enter isotropic Debye-Waller factor [nm^(-2)] : 0.0033
Another atom? (y/n) : n

The cli creates a test.h5 file and the xtal is named Ni. Screenshot below:

Screenshot 2024-08-20 at 3 07 09 PM
pep8speaks commented 3 weeks ago

Hello @saransh13! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2024-08-20 22:18:01 UTC
codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 7.14286% with 39 lines in your changes missing coverage. Please review.

Project coverage is 33.38%. Comparing base (5f1f4c5) to head (6355483).

Files Patch % Lines
hexrd/material/mksupport.py 5.26% 18 Missing :warning:
hexrd/cli/make_material.py 0.00% 14 Missing :warning:
hexrd/material/unitcell.py 16.66% 5 Missing :warning:
hexrd/cli/main.py 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #712 +/- ## ========================================== - Coverage 33.50% 33.38% -0.12% ========================================== Files 129 130 +1 Lines 21253 21262 +9 ========================================== - Hits 7120 7099 -21 - Misses 14133 14163 +30 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.