hall-symbols 0.1.0.2 → 0.1.0.3
raw patch · 4 files changed
+86/−20 lines, 4 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Crystallography.HallSymbols: hallSymbols' :: CharParser () (LatticeSymbol, [MatrixSymbol], OriginShift)
+ Crystallography.HallSymbols: parser :: CharParser () (LatticeSymbol, [MatrixSymbol], OriginShift)
Files
- README.md +26/−1
- hall-symbols.cabal +6/−5
- src/Crystallography/HallSymbols.hs +50/−10
- src/Crystallography/HallSymbols/SpacegroupSymbols.hs +4/−4
README.md view
@@ -2,7 +2,32 @@ Haskell Hall Symbols Library +# Quickstart++```shell+% stack repl+```++```haskell+-- prepare+repl> :set -package matrix-as-xyz+repl> :m Data.Matrix.AsXYZ+repl> :l Crystallography.HallSymbols++-- print general positions+repl> fmap prettyXYZ $ fromHallSymbols' "C -2yc"++ ["x,y,z","x+1/2,y+1/2,z","x,-y,z+1/2","x+1/2,-y+1/2,z+1/2"]++-- print generators+repl> fmap prettyXYZ $ fromHallSymbols'' "C -2yc"++["x,y,z","x+1/2,y+1/2,z","x,-y,z+1/2"]+```+++ ## License -See the [LICENSE](https://github.com/narumij/hall-symbols/LICENSE)+See the [LICENSE](LICENSE) file in the repository.
hall-symbols.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.28.2.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: d12bbdc0541111541cff37cd9476b103519c83cb6f35480d7c6234e0e14cda37+-- hash: 702da6b77b983eb8b29d4431755b69ea93d2ecadc33590f79090f8406752c85a name: hall-symbols-version: 0.1.0.2+version: 0.1.0.3 synopsis: Symmetry operations generater of Hall Symbols description: Please see the README on GitHub at <https://github.com/narumij/hall-symbols#readme> category: Chemistry@@ -17,10 +19,9 @@ license: BSD3 license-file: LICENSE build-type: Simple-cabal-version: >= 1.10 extra-source-files:- ChangeLog.md README.md+ ChangeLog.md source-repository head type: git
src/Crystallography/HallSymbols.hs view
@@ -23,7 +23,8 @@ fromHallSymbols, fromHallSymbols', hallSymbols,- hallSymbols',+-- hallSymbols',+ parser, LatticeSymbol, MatrixSymbol, OriginShift,@@ -110,8 +111,8 @@ space' = oneOf " _" -- | Primitive parser-hallSymbols' :: CharParser () ( LatticeSymbol, [MatrixSymbol], OriginShift )-hallSymbols' = do+parser :: CharParser () ( LatticeSymbol, [MatrixSymbol], OriginShift )+parser = do l <- latticeSymbol nat <- many1 (try ms) v <- option (0,0,0) os@@ -124,15 +125,21 @@ space' originShift --- | Parser with convert+-- | Parse and make Generators.+generators :: CharParser () [Matrix Rational]+generators = do+ raw <- parser+ return $ decodeSymbols raw++-- | Parse and make General Positions. hallSymbols :: CharParser () [Matrix Rational] hallSymbols = do- raw <- hallSymbols'+ g <- generators -- Step 1: Decode space-group symbols -- decodeSymbols関数で省略された軸情報を復元し、seiz matrixを生成します -- Step 2: Generate symmetry operators -- generate関数で得られたseiz matrixをgeneratorとして、一般点を生成します- let equivalentPositions = generate . decodeSymbols $ raw+ let equivalentPositions = generate g -- generate関数が計算に失敗すると空の配列を返すので、その場合パースエラーとして処理します if null equivalentPositions then@@ -141,9 +148,29 @@ -- 正常に終了すると、一般座標の行列を返します。 return equivalentPositions +-- | Parse and make General Positions.+generateLikeITC :: CharParser () [Matrix Rational]+generateLikeITC = do+ raw <- parser+ let equivalentPositions = likeITC raw+ if null equivalentPositions+ then+ fail "something happen when decode or generate process."+ else+ -- 正常に終了すると、一般座標の行列を返します。+ return equivalentPositions++likeITC :: ( LatticeSymbol, [MatrixSymbol], OriginShift ) -> [Matrix Rational]+likeITC raw = if null h then [] else r + where+ constructMatrices' (l,nat,v) = fmap (mapOriginShfit v) [lattice l, map matrix nat]+ [a,b] = constructMatrices' . restoreDefaultAxis $ raw+ h = generate $ [identity] ++ b+ r = generate $ h ++ a+ -- | Generate general equivalent positions by 4x4 matrix fromHallSymbols :: String -> Either ParseError [Matrix Rational]-fromHallSymbols s = parse hallSymbols ("while reading " ++ show s) s+fromHallSymbols s = parse generateLikeITC ("while reading " ++ show s) s -- | Generate general equivalent positions by 4x4 matrix (unsafe version) fromHallSymbols' :: String -> [Matrix Rational]@@ -151,7 +178,20 @@ Left e -> error $ show e Right mm -> mm --- パーズした簡約記号からseiz matrixを復元します+-- | Generate Generators by 4x4 matrix (unsafe version)+fromHallSymbols'' :: String -> [Matrix Rational]+fromHallSymbols'' s = case gg s of+ Left e -> error $ show e+ Right mm -> mm+ where+ gg s = parse generators ("while reading " ++ show s) s++-- | Generate general equivalent positions by 4x4 matrix+-- same as old version fromHallSymbols+fromHallSymbols''' :: String -> Either ParseError [Matrix Rational]+fromHallSymbols''' s = parse hallSymbols ("while reading " ++ show s) s++-- パースした簡約記号からseiz matrixを復元します decodeSymbols :: ( LatticeSymbol, [MatrixSymbol], OriginShift ) -> [Matrix Rational] decodeSymbols = constructMatrices . restoreDefaultAxis @@ -223,11 +263,11 @@ -- 注意点として、恒等操作が二つあるなどしただけで、計算結果が変化するようである。 -- このため、計算に供する行列はジェネレーターの組み合わせとして正しいかどうか配慮する必要がある。 gn :: Int -> [Matrix Rational] -> [Matrix Rational] -> [Matrix Rational]-gn n s m | length m == length mm = m+gn n s m | length (nub m) == length mm = mm -- 計算が収束しなかった場合、空の配列を返し終了する. -- 既存の空間群の対称操作の生成が最大4回の繰り返しで足りるので、なんとなくで10回にしています | n > 10 = []- | otherwise = gn (succ n) s mm+ | otherwise = gn (succ n) (nub s) mm where mm = nub . map (modulus1 . foldl1 multStd) . sequenceA $ [s,m]
src/Crystallography/HallSymbols/SpacegroupSymbols.hs view
@@ -171,7 +171,7 @@ ( "28:cab", "P 2 m b", "P -2b 2" ), ( "28:-cba", "P 2 c m", "P -2c 2" ), ( "28:bca", "P c 2 m", "P -2c -2c" ),- ( "28:a-c", "b P m 2 a", "P -2a -2a" ),+ ( "28:a-cb", "P m 2 a", "P -2a -2a" ), ( "29", "P c a 21", "P 2c -2ac" ), ( "29:ba-c", "P b c 21", "P 2c -2b" ), ( "29:cab", "P 21 a b", "P -2b 2a" ),@@ -396,7 +396,7 @@ ( "88:1", "I 41/a:1", "I 4bw -1bw" ), ( "88:2", "I 41/a:2", "-I 4ad" ), ( "89", "P 4 2 2", "P 4 2" ),- ( "90", "P 42 1 2", "P 4ab 2ab" ),+ ( "90", "P 4 21 2", "P 4ab 2ab" ), ( "91", "P 41 2 2", "P 4w 2c" ), ( "92", "P 41 21 2", "P 4abw 2nw" ), ( "93", "P 42 2 2", "P 4c 2" ),@@ -473,8 +473,8 @@ ( "152", "P 31 2 1", "P 31 2\"" ), ( "153", "P 32 1 2", "P 32 2c (0 0 -1)" ), ( "154", "P 32 2 1", "P 32 2\"" ),- ( "155:H", "R 32:H", "R 3 2\"" ),- ( "155:R", "R 32:R", "P 3* 2" ),+ ( "155:H", "R 3 2:H", "R 3 2\"" ),+ ( "155:R", "R 3 2:R", "P 3* 2" ), ( "156", "P 3 m 1", "P 3 -2\"" ), ( "157", "P 3 1 m", "P 3 -2" ), ( "158", "P 3 c 1", "P 3 -2\"c" ),