CastepReader
Date: 2019-10-22

org.jmol.adapter.readers.xtal

## Class CastepReader

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

- All Implemented Interfaces:
    javajs.api.GenericLineReader

      public class CastepReader
      extends AtomSetCollectionReader

  CASTEP (http://www.castep.org) .cell file format relevant section of .cell file are included as comments below preliminary .castep, .phonon frequency reader -- hansonr@stolaf.edu 9/2011 -- Many thanks to Keith Refson for his assistance with this implementation -- atom's mass is encoded as bfactor -- FILTER options include "q=n" where n is an integer "q={1/4 1/4 0}" "q=ALL" -- for non-simple fractions, you must use the exact form of the wavevector description: -- load "xxx.phonon" FILTER "q=(-0.083333 0.083333 0.500000) -- for simple fractions, you can also just specify SUPERCELL {a b c} where the number of cells matches a given wavevector -- SUPERCELL {4 4 1}, for example note: following was never implemented? -- following this with ".1" ".2" etc. gives first, second, third, etc. occurance: -- load "xxx.phonon" FILTER "q=1.3" .... -- load "xxx.phonon" FILTER "{0 0 0}.3" ....
  Version:
    1.2
  Author:
    Joerg Meyer, FHI Berlin 2009 (meyer@fhi-berlin.mpg.de)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private float` | `a`
    `private javajs.util.V3[]` | `abc`
    `private int` | `ac`
    `private float` | `alpha`
    `private javajs.util.P3[]` | `atomPts`
    `private float` | `b`
    `private float` | `beta`
    `private float` | `c`
    `private java.lang.String` | `chargeType`
    `private java.lang.String` | `desiredQ`
    `private javajs.util.V3` | `desiredQpt`
    `private float` | `gamma`
    `private boolean` | `haveCharges`
    `private boolean` | `havePhonons`
    `private boolean` | `isAllQ`
    `private boolean` | `isCell`
    `private boolean` | `isOutput`
    `private boolean` | `isPhonon`
    `private boolean` | `isTS`
    `private java.lang.String` | `lastQPt`
    `private static float[]` | `lengthUnitFactors`
    `private static java.lang.String[]` | `lengthUnitIds`
    `private javajs.util.M4` | `matSupercell`
    `private int` | `qpt2`
    `private static float` | `RAD_TO_DEG`
    `private java.lang.String[]` | `tokens`
    `private java.lang.String` | `tsType`
    `private static double` | `TWOPI`

    - ### 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
    `CastepReader()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `checkLine()`
    `protected void` | `finalizeSubclassReader()` optional reader-specific method run first.
    `private java.lang.String` | `getFractionalCoord(javajs.util.V3 qvec)`
    `private void` | `getTensor(Atom atom, java.lang.String line0)`
    `void` | `initializeReader()`
    `private static boolean` | `isInt(float f)`
    `private void` | `readAtomData(float factor)`
    `private void` | `readEnergy(int pt, java.lang.String prefix)`
    `private boolean` | `readFileData()`
    `private void` | `readLatticeAbc()`
    `private void` | `readLatticeCart()`
    `private float` | `readLengthUnit(java.lang.String units)`
    `private int` | `readOutputAtomIndex()`
    `private void` | `readOutputAtoms()`
    `private void` | `readOutputBornChargeTensors()`
    `private void` | `readOutputCharges()` read Mulliken or Hirshfield charges
    `private void` | `readOutputUnitCell()`
    `private void` | `readPhononFractionalCoord()`
    `private void` | `readPhononFrequencies()`
    `private void` | `readPhononTrajectories()`
    `private void` | `readPhononUnitCell()`
    `private void` | `readPositionsAbs()`
    `private void` | `readPositionsFrac()`
    `private void` | `setDesiredQpt(java.lang.String s)`
    `private void` | `setLatticeVectors()`
    `private void` | `setPhononVector(float[] data, Atom atom, javajs.util.V3 rTrans, javajs.util.V3 qvec, javajs.util.V3 v)` transform complex vibration vector to a real vector by applying the appropriate translation, storing the results in v
    `private int` | `tokenizeCastepCell()`

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

      `addAtomXYZSymName, addExplicitLatticeVector, addJmolScript, addSites, addSiteScript, appendLoadNote, appendUunitCellInfo, applySymmetryAndSetTrajectory, 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

    - #### RAD_TO_DEG

          private static final float RAD_TO_DEG

      See Also:
        Constant Field Values

    - #### tokens

          private java.lang.String[] tokens

    - #### isPhonon

          private boolean isPhonon

    - #### isTS

          private boolean isTS

    - #### isOutput

          private boolean isOutput

    - #### isCell

          private boolean isCell

    - #### a

          private float a

    - #### b

          private float b

    - #### c

          private float c

    - #### alpha

          private float alpha

    - #### beta

          private float beta

    - #### gamma

          private float gamma

    - #### abc

          private javajs.util.V3[] abc

    - #### ac

          private int ac

    - #### atomPts

          private javajs.util.P3[] atomPts

    - #### havePhonons

          private boolean havePhonons

    - #### lastQPt

          private java.lang.String lastQPt

    - #### qpt2

          private int qpt2

    - #### desiredQpt

          private javajs.util.V3 desiredQpt

    - #### desiredQ

          private java.lang.String desiredQ

    - #### chargeType

          private java.lang.String chargeType

    - #### isAllQ

          private boolean isAllQ

    - #### haveCharges

          private boolean haveCharges

    - #### tsType

          private java.lang.String tsType

    - #### lengthUnitIds

          private static final java.lang.String[] lengthUnitIds

    - #### lengthUnitFactors

          private static final float[] lengthUnitFactors

    - #### matSupercell

          private javajs.util.M4 matSupercell

    - #### TWOPI

          private static final double TWOPI

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CastepReader

          public CastepReader()

  - ### Method Detail

    - #### initializeReader

          public void initializeReader()
                                throws java.lang.Exception

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

    - #### setDesiredQpt

          private void setDesiredQpt(java.lang.String s)

    - #### readFileData

          private boolean readFileData()
                                throws java.lang.Exception

      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`

    - #### readOutputUnitCell

          private void readOutputUnitCell()
                                   throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readOutputAtoms

          private void readOutputAtoms()
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readEnergy

          private void readEnergy(int pt,
                                  java.lang.String prefix)
                           throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readPhononTrajectories

          private void readPhononTrajectories()
                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### 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`

    - #### setLatticeVectors

          private void setLatticeVectors()

    - #### readLatticeAbc

          private void readLatticeAbc()
                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readLatticeCart

          private void readLatticeCart()
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readPositionsFrac

          private void readPositionsFrac()
                                  throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readPositionsAbs

          private void readPositionsAbs()
                                 throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readLengthUnit

          private float readLengthUnit(java.lang.String units)
                                throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readAtomData

          private void readAtomData(float factor)
                             throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### tokenizeCastepCell

          private int tokenizeCastepCell()
                                  throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readOutputBornChargeTensors

          private void readOutputBornChargeTensors()
                                            throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readOutputAtomIndex

          private int readOutputAtomIndex()

    - #### getTensor

          private void getTensor(Atom atom,
                                 java.lang.String line0)
                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readOutputCharges

          private void readOutputCharges()
                                  throws java.lang.Exception

      read Mulliken or Hirshfield charges
      Throws:
        `java.lang.Exception`

    - #### readPhononUnitCell

          private void readPhononUnitCell()
                                   throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readPhononFractionalCoord

          private void readPhononFractionalCoord()
                                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readPhononFrequencies

          private void readPhononFrequencies()
                                      throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### getFractionalCoord

          private java.lang.String getFractionalCoord(javajs.util.V3 qvec)

    - #### isInt

          private static boolean isInt(float f)

    - #### setPhononVector

          private void setPhononVector(float[] data,
                                       Atom atom,
                                       javajs.util.V3 rTrans,
                                       javajs.util.V3 qvec,
                                       javajs.util.V3 v)

      transform complex vibration vector to a real vector by applying the appropriate translation, storing the results in v
      Parameters:
        `data` - from .phonon line parsed for floats
        `atom` -
        `rTrans` - translation vector in unit fractional coord
        `qvec` - q point vector
        `v` - return vector