CrystalReader
Date: 2019-10-22

org.jmol.adapter.readers.xtal

## Class CrystalReader

- java.lang.Object
- - org.jmol.adapter.smarter.AtomSetCollectionReader
  - - org.jmol.adapter.readers.xtal.CrystalReader

- All Implemented Interfaces:
    javajs.api.GenericLineReader

      public class CrystalReader
      extends AtomSetCollectionReader

  A reader of OUT and OUTP files for CRYSTAL http://www.crystal.unito.it/
  Version:
    1.4 special model auxiliaryInfo include: primitiveToCrystal M3 transforming primitive lattice to conventional lattice mat4PrimitiveToCrystal M4 for use in transforming symmetry operations mat4CrystalToPrimitive M4 convenience inverse of mat4PrimitiveToCrystal fileSymmetryOperations List symmetry operators (primitive) Drawing primitive unitcell operations: ops = _M.fileSystemOperations DRAW SYMOP @{ops[2]} If using the conventional cell, you can use its operators, or you can limit yourself this primitive subset using: mp2c = _M.mat4PrimitiveToCrystal mc2p = _M.mat4CrystalToPrimitive DRAW SYMOP @{mc2p * ops[2] * mp2c} for a specific model in the set, use load "xxx.out" n as for all readers, where n is an integer > 0 for final optimized geometry use load "xxx.out" 0 (that is, "read the last model") as for all readers for conventional unit cell -- input coordinates only, use load "xxx.out" filter "conventional" to NOT load vibrations, use load "xxx.out" FILTER "novibrations" to load just the input deck exactly as indicated, use load "xxx.out" FILTER "input" now allows reading of frequencies and atomic values with conventional as long as this is not an optimization.
  Author:
    Pieremanuele Canepa, Room 104, FM Group School of Physical Sciences, Ingram Building, University of Kent, Canterbury, Kent, CT2 7NH United Kingdom, pc229@kent.ac.uk, Bob Hanson hansonr@stolaf.edu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `ac`
    `private int[]` | `atomFrag`
    `private int` | `atomIndexLast`
    `private boolean` | `checkModelTrigger`
    `private int` | `cpno`
    `private static java.lang.String[]` | `crtypes`
    `private javajs.util.V3[]` | `directLatticeVectors`
    `private boolean` | `directLatticeVectorsFirst` CRYSTAL 17 moves directLatticeVectors before LATTICE PARAMETERS
    `private java.lang.Double` | `energy`
    `private float[]` | `f14`
    `private float[]` | `f16`
    `private java.lang.String` | `firstLine`
    `private boolean` | `fullSymmetry`
    `private boolean` | `getLastConventional`
    `private boolean` | `haveCharges`
    `private boolean` | `havePrimitiveMapping`
    `private java.util.Map<java.lang.String,javajs.util.Lst<java.lang.Object>>` | `htCriticalPoints`
    `private boolean` | `inputOnly`
    `private boolean` | `isLongMode`
    `private boolean` | `isPolymer`
    `private boolean` | `isProperties`
    `private boolean` | `isSlab`
    `private boolean` | `isVersion3`
    `private javajs.util.Lst<java.lang.String>` | `lstCoords`
    `private float[]` | `nuclearCharges`
    `private float` | `primitiveDensity`
    `private int[]` | `primitiveToIndex`
    `private float` | `primitiveVolume`
    `private javajs.util.P3` | `ptOriginShift`
    `private static int[]` | `smap`
    `private java.lang.String` | `spaceGroupName`
    `private int` | `state`
    `private static int` | `STATE_FREQ`
    `private static int` | `STATE_INPUT`
    `private static int` | `STATE_INPUT_FROM`
    `private static int` | `STATE_NONE`
    `private static int` | `STATE_OPT_FINAL`
    `private static int` | `STATE_OPT_POINT`
    `private static int` | `STATE_WAVEFUNCTION`
    `private javajs.util.Lst<java.lang.String>` | `symops`

    - ### Fields inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader

      `addedData, addedDataKey, addVibrations, allowPDBFilter, ANGSTROMS_PER_BOHR, applySymmetryToBonds, asc, baseAtomIndex, binaryDoc, bsFilter, bsModels, calculationType, continuing, debugging, desiredModelNumber, desiredSpaceGroupIndex, desiredVibrationNumber, doApplySymmetry, doCentralize, doCheckUnitCell, doConvertToFractional, doPackUnitCell, doProcessLines, doReadMolecularOrbitals, dssr, fileName, fileOffset, filePath, fileScaling, fillRange, filter, filterHetero, fixJavaFloat, forcePacked, getHeader, haveAtomFilter, haveModel, havePartialChargeFilter, htParams, ignoreFileSpaceGroupName, ignoreFileSymmetryOperators, ignoreFileUnitCell, ignoreStructure, iHaveFractionalCoordinates, iHaveSymmetryOperators, iHaveUnitCell, isBinary, isConcatenated, isDSSP1, isFinalized, isMolecular, isPrimitive, isSequential, isTrajectory, latticeCells, latticeScaling, latticeType, line, lstNCS, matUnitCellOrientation, modDim, modelNumber, ms, mustFinalizeModelSet, next, out, packingError, prevline, primitiveToCrystal, ptLine, ptSupercell, reader, readerName, requiresBSFilter, reverseModels, rotateHexCell, sgName, stateScriptVersionInt, strSupercell, symmetry, templateAtomCount, thisBiomolecule, trajectorySteps, unitCellOffset, unitCellParams, useAltNames, useFileModelNumbers, validation, vibrationNumber, vibsFractional, vwr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CrystalReader()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private boolean` | `addModel()`
    `void` | `applySymmetryAndSetTrajectory()`
    `protected boolean` | `checkLine()`
    `protected void` | `finalizeSubclassReader()` optional reader-specific method run first.
    `private static java.lang.String` | `fixAtomName(java.lang.String s)` MN33 becomes Mn33
    `private int` | `getAtomicNumber(java.lang.String token)`
    `private int` | `getAtomIndexFromPrimitiveIndex(int iPrim)` Get the atom index from a primitive index.
    `private java.lang.String` | `getCPAtomInfo(java.lang.String line, javajs.util.Lst<java.lang.Object> list)` Process a CP data line
    `private void` | `getDirect()`
    `private int` | `getModelForMode(int i0, int mode)`
    `private boolean` | `getQuadrupoleTensors()`
    `protected void` | `initializeReader()`
    `private void` | `newAtomSet()`
    `private void` | `newLattice(boolean isConv)`
    `private void` | `processCoordLines()` Now create atoms from the coordinate lines.
    `private void` | `processNextCriticalPoint()`
    `private boolean` | `readAtoms()`
    `private boolean` | `readBornChargeTensors()`
    `private void` | `readCoordLines()` Read coordinates, either input or crystallographic, just saving their lines in a vector for now.
    `private boolean` | `readData(java.lang.String name, int nfields)` For spin and magnetic moment data, read the data block and save it as property_spin or propert_magneticMoment.
    `private void` | `readFreqFragments()` Select only specific atoms for frequency generation.
    `private void` | `readFrequencies()`
    `private boolean` | `readGradient()` Read minimization measures
    `private boolean` | `readHeader()`
    `private void` | `readLatticeParams(boolean isPrimitive)` Read the lattice parameters.
    `private boolean` | `readPartialCharges()`
    `private void` | `readPrimitiveLatticeVectors()` Read transform matrix primitive to conventional.
    `private javajs.util.Lst<java.lang.String>` | `readRaman(javajs.util.Lst<java.lang.String> ramanData)`
    `private boolean` | `readShift()` Read the origin shift
    `private void` | `readSymmetryOperators()`
    `private boolean` | `readTotalAtomicCharges()`
    `private void` | `setEnergy()`
    `private void` | `setFreqValue(float freq, java.lang.String[] data)`
    `private void` | `setSymmOps()`
    `private void` | `setUnitCellOrientation()`

    - ### Methods inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader

      `addAtomXYZSymName, addExplicitLatticeVector, addJmolScript, addSites, addSiteScript, appendLoadNote, appendUunitCellInfo, applySymTrajASCR, checkCurrentLineForScript, checkFilterKey, checkLastModel, checkLineForScript, clearUnitCell, cloneLastAtomSet, discardLinesUntilBlank, discardLinesUntilContains, discardLinesUntilContains2, discardLinesUntilNonBlank, discardLinesUntilStartsWith, discardPreviousAtoms, doGetModel, doGetVibration, doPreSymmetry, fill3x3, fillDataBlock, fillDataBlockFixed, fillFloatArray, fillFrequencyData, filterAtom, filterReject, finalizeMOData, finalizeModelSet, finalizeReaderASCR, finalizeSubclassSymmetry, forceSymmetry, fractionalizeCoordinates, getElementSymbol, getFilter, getFortranFormatLengths, getInterface, getNewSymmetry, getStrings, getSymmetry, getTokens, getTokensFloat, initializeSymmetry, initializeSymmetryOptions, initializeTrajectoryFile, isLastModel, newAtomSet, parseFloat, parseFloatRange, parseFloatStr, parseInt, parseIntAt, parseIntRange, parseIntStr, parseToken, parseTokenNext, parseTokenRange, parseTokenStr, processBinaryDocument, processDOM, rd, read3Vectors, readDataObject, readLines, readNextLine, rejectAtomName, RL, set2D, setAtomCoord, setAtomCoordScaled, setAtomCoordTokens, setAtomCoordXYZ, setChainID, setElementAndIsotope, setFilter, setFilterAtomTypeStr, setFractionalCoordinates, setIsPDB, setLoadNote, setModelPDB, setSpaceGroupName, setSymmetryOperator, setTransform, setUnitCell, setUnitCellItem, setup, setupASCR`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### isVersion3

          private boolean isVersion3

    - #### isPolymer

          private boolean isPolymer

    - #### isSlab

          private boolean isSlab

    - #### haveCharges

          private boolean haveCharges

    - #### inputOnly

          private boolean inputOnly

    - #### isLongMode

          private boolean isLongMode

    - #### getLastConventional

          private boolean getLastConventional

    - #### havePrimitiveMapping

          private boolean havePrimitiveMapping

    - #### isProperties

          private boolean isProperties

    - #### STATE_NONE

          private static final int STATE_NONE

      See Also:
        Constant Field Values

    - #### STATE_INPUT

          private static final int STATE_INPUT

      See Also:
        Constant Field Values

    - #### STATE_INPUT_FROM

          private static final int STATE_INPUT_FROM

      See Also:
        Constant Field Values

    - #### STATE_WAVEFUNCTION

          private static final int STATE_WAVEFUNCTION

      See Also:
        Constant Field Values

    - #### STATE_OPT_POINT

          private static final int STATE_OPT_POINT

      See Also:
        Constant Field Values

    - #### STATE_OPT_FINAL

          private static final int STATE_OPT_FINAL

      See Also:
        Constant Field Values

    - #### STATE_FREQ

          private static final int STATE_FREQ

      See Also:
        Constant Field Values

    - #### state

          private int state

    - #### ac

          private int ac

    - #### atomIndexLast

          private int atomIndexLast

    - #### atomFrag

          private int[] atomFrag

    - #### primitiveToIndex

          private int[] primitiveToIndex

    - #### nuclearCharges

          private float[] nuclearCharges

    - #### lstCoords

          private javajs.util.Lst<java.lang.String> lstCoords

    - #### energy

          private java.lang.Double energy

    - #### ptOriginShift

          private javajs.util.P3 ptOriginShift

    - #### directLatticeVectors

          private javajs.util.V3[] directLatticeVectors

    - #### spaceGroupName

          private java.lang.String spaceGroupName

    - #### checkModelTrigger

          private boolean checkModelTrigger

    - #### fullSymmetry

          private boolean fullSymmetry

    - #### htCriticalPoints

          private java.util.Map<java.lang.String,javajs.util.Lst<java.lang.Object>> htCriticalPoints

    - #### directLatticeVectorsFirst

          private boolean directLatticeVectorsFirst

      CRYSTAL 17 moves directLatticeVectors before LATTICE PARAMETERS

    - #### cpno

          private int cpno

    - #### crtypes

          private static final java.lang.String[] crtypes

    - #### symops

          private javajs.util.Lst<java.lang.String> symops

    - #### f14

          private final float[] f14

    - #### f16

          private final float[] f16

    - #### smap

          private static final int[] smap

    - #### primitiveVolume

          private float primitiveVolume

    - #### primitiveDensity

          private float primitiveDensity

    - #### firstLine

          private java.lang.String firstLine

  - ### Constructor Detail

    - #### CrystalReader

          public CrystalReader()

  - ### Method Detail

    - #### initializeReader

          protected void initializeReader()
                                   throws java.lang.Exception

      Overrides:
        `initializeReader` in class `AtomSetCollectionReader`
      Throws:
        `java.lang.Exception`

    - #### checkLine

          protected boolean checkLine()
                               throws java.lang.Exception

      Overrides:
        `checkLine` in class `AtomSetCollectionReader`
      Returns:
        true if need to read new line
      Throws:
        `java.lang.Exception`

    - #### processNextCriticalPoint

          private void processNextCriticalPoint()
                                         throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getCPAtomInfo

          private java.lang.String getCPAtomInfo(java.lang.String line,
                                                 javajs.util.Lst<java.lang.Object> list)

      Process a CP data line
      Parameters:
        `line` - full TOPOND data line
        `list` - entries to fill with information
      Returns:
        matrix information for eigenvectors

    - #### newLattice

          private void newLattice(boolean isConv)
                           throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### addModel

          private boolean addModel()
                            throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readSymmetryOperators

          private void readSymmetryOperators()
                                      throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### setSymmOps

          private void setSymmOps()

    - #### finalizeSubclassReader

          protected void finalizeSubclassReader()
                                         throws java.lang.Exception

      Description copied from class: `AtomSetCollectionReader`
      optional reader-specific method run first.
      Overrides:
        `finalizeSubclassReader` in class `AtomSetCollectionReader`
      Throws:
        `java.lang.Exception`

    - #### getDirect

          private void getDirect()
                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### setUnitCellOrientation

          private void setUnitCellOrientation()

    - #### readPrimitiveLatticeVectors

          private void readPrimitiveLatticeVectors()
                                            throws java.lang.Exception

      Read transform matrix primitive to conventional.
      Throws:
        `java.lang.Exception`

    - #### readShift

          private boolean readShift()

      Read the origin shift
      Returns:
        true

    - #### readHeader

          private boolean readHeader()
                              throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readLatticeParams

          private void readLatticeParams(boolean isPrimitive)
                                  throws java.lang.Exception

      Read the lattice parameters.
      Parameters:
        `isNewSet` -
      Throws:
        `java.lang.Exception`

    - #### getAtomIndexFromPrimitiveIndex

          private int getAtomIndexFromPrimitiveIndex(int iPrim)

      Get the atom index from a primitive index. Used for atomic properties and frequency fragments. Note that primitive to conventional is not a 1:1 mapping. We don't consider that.
      Parameters:
        `iPrim` -
      Returns:
        the original number or the number from the primitive.

    - #### readAtoms

          private boolean readAtoms()
                             throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### fixAtomName

          private static java.lang.String fixAtomName(java.lang.String s)

      MN33 becomes Mn33
      Parameters:
        `s` -
      Returns:
        fixed atom name

    - #### getAtomicNumber

          private int getAtomicNumber(java.lang.String token)

    - #### readCoordLines

          private void readCoordLines()
                               throws java.lang.Exception

      Read coordinates, either input or crystallographic, just saving their lines in a vector for now.
      Throws:
        `java.lang.Exception`

    - #### processCoordLines

          private void processCoordLines()
                                  throws java.lang.Exception

      Now create atoms from the coordinate lines.
      Throws:
        `java.lang.Exception`

    - #### applySymmetryAndSetTrajectory

          public void applySymmetryAndSetTrajectory()
                                             throws java.lang.Exception

      Overrides:
        `applySymmetryAndSetTrajectory` in class `AtomSetCollectionReader`
      Throws:
        `java.lang.Exception`

    - #### newAtomSet

          private void newAtomSet()
                           throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### setEnergy

          private void setEnergy()

    - #### readPartialCharges

          private boolean readPartialCharges()
                                      throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readTotalAtomicCharges

          private boolean readTotalAtomicCharges()
                                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readFreqFragments

          private void readFreqFragments()
                                  throws java.lang.Exception

      Select only specific atoms for frequency generation. (See freq_6for_001.out)
      Throws:
        `java.lang.Exception`

    - #### readFrequencies

          private void readFrequencies()
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### setFreqValue

          private void setFreqValue(float freq,
                                    java.lang.String[] data)

    - #### readRaman

          private javajs.util.Lst<java.lang.String> readRaman(javajs.util.Lst<java.lang.String> ramanData)
                                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getModelForMode

          private int getModelForMode(int i0,
                                      int mode)

    - #### readGradient

          private boolean readGradient()
                                throws java.lang.Exception

      Read minimization measures
      Returns:
        true
      Throws:
        `java.lang.Exception`

    - #### readData

          private boolean readData(java.lang.String name,
                                   int nfields)
                            throws java.lang.Exception

      For spin and magnetic moment data, read the data block and save it as property_spin or propert_magneticMoment.
      Parameters:
        `name` -
        `nfields` -
      Returns:
        true
      Throws:
        `java.lang.Exception`

    - #### getQuadrupoleTensors

          private boolean getQuadrupoleTensors()
                                        throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readBornChargeTensors

          private boolean readBornChargeTensors()
                                         throws java.lang.Exception

      Throws:
        `java.lang.Exception`