MSRdr
Date: 2019-10-22

org.jmol.adapter.readers.cif

## Class MSRdr

- java.lang.Object
- - org.jmol.adapter.readers.cif.MSRdr

- All Implemented Interfaces:
    MSInterface
  Direct Known Subclasses:
    MSCifParser

      public class MSRdr
      extends java.lang.Object
      implements MSInterface

  generalized modulated structure reader class for CIF and Jana -- includes Fourier, Crenel, Sawtooth; displacement, occupancy, and Uij -- handles up to 6 modulation wave vectors -- commensurate and incommensurate, including composites -- not handling _cell_commen_t_section_1
  Author:
    Bob Hanson hansonr@stolaf.edu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `ac`
    `private java.lang.String` | `atModel`
    `private Atom[]` | `atoms`
    `protected int` | `commensurateSection1`
    `protected AtomSetCollectionReader` | `cr`
    `private boolean` | `finalized`
    `private javajs.util.M3` | `gammaE`
    `private boolean` | `haveAtomMods`
    `private boolean` | `haveOccupancy`
    `private java.util.Map<java.lang.String,javajs.util.Lst<Modulation>>` | `htAtomMods`
    `private java.util.Map<java.lang.String,double[]>` | `htModulation`
    `(package private) java.util.Map<java.lang.String,Subsystem>` | `htSubsystems`
    `private int` | `iopLast`
    `protected boolean` | `isCommensurate`
    `private javajs.util.Lst<java.lang.String>` | `legendres`
    `private javajs.util.P3` | `maxXYZ0`
    `private javajs.util.P3` | `minXYZ0`
    `protected boolean` | `modAverage`
    `protected java.lang.String` | `modAxes`
    `private java.lang.String` | `modCell`
    `private boolean` | `modCoord`
    `private int` | `modCount`
    `private boolean` | `modDebug`
    `protected int` | `modDim`
    `private boolean` | `modLast`
    `private javajs.util.Matrix[]` | `modMatrices`
    `private boolean` | `modPack`
    `private int` | `modSelected`
    `private javajs.util.T3` | `modTUV`
    `private java.lang.String` | `modType`
    `private boolean` | `modVib`
    `private int` | `nOps`
    `private double[]` | `qlist100`
    `private javajs.util.P3[]` | `qs`
    `private javajs.util.Matrix` | `sigma`
    `private SymmetryInterface` | `supercellSymmetry`
    `private SymmetryInterface` | `symmetry`
    `private static java.lang.String` | `U_LIST`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MSRdr()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `addAtomModulation(java.lang.String atomName, char axis, char type, double[] params, java.lang.String utens, double[] qcoefs)` Create a list of modulations for each atom type (atom name).
    `boolean` | `addLatticeVector(javajs.util.Lst<float[]> lattvecs, java.lang.String data)`
    `void` | `addModulation(java.util.Map<java.lang.String,double[]> map, java.lang.String id, double[] pt, int iModel)` Types include O (occupation) D (displacement) U (anisotropy) M (magnetic moment) _coefs_ indicates this is a wave description
    `void` | `addSubsystem(java.lang.String code, javajs.util.Matrix w)`
    `private void` | `addUStr(Atom atom, java.lang.String id, float val)`
    `private int` | `approxInt(float fn)`
    `private double[]` | `calculateQCoefs(double[] p)` determine simple linear combination assuming simple -3 to 3 no more than two dimensions.
    `private java.lang.String` | `checkKey(java.lang.String key, boolean checkQ)` Filter keys only for this model.
    `private void` | `expandMinMax(javajs.util.P3 pt, SymmetryInterface sym, javajs.util.P3 minXYZ, javajs.util.P3 maxXYZ)`
    `void` | `finalizeModulation()` Create a script that will run to turn modulation on and to display only atoms with modulated occupancy >= 0.5.
    `private void` | `fixDouble(double[] pt)`
    `private void` | `fixLegendre()`
    `private javajs.util.P3` | `getAtomR0(Atom atom)`
    `SymmetryInterface` | `getAtomSymmetry(Atom a, SymmetryInterface defaultSymmetry)` When applying symmetry, this method allows us to use a set of symmetry operators unique to this particular atom -- or in this case, to its subsystem.
    `private SymmetryInterface` | `getDefaultUnitCell()`
    `private javajs.util.Matrix[]` | `getMatrices(Atom a)`
    `double[]` | `getMod(java.lang.String key)` Modulation data keys are keyed by model number as well as type using [at]n, where n is the model number, starting with 0.
    `char` | `getModType(java.lang.String key)`
    `java.util.Map<java.lang.String,double[]>` | `getModulationMap()`
    `double[]` | `getQCoefs(java.lang.String key)`
    `(package private) javajs.util.Matrix` | `getSigma()`
    `private Subsystem` | `getSubsystem(Atom a)`
    `private SymmetryInterface` | `getSymmetry(Atom a)`
    `SymmetryInterface` | `getSymmetryFromCode(java.lang.String code)`
    `int` | `initialize(AtomSetCollectionReader r, int modDim)`
    `private void` | `initModForStructure(int iModel)`
    `private void` | `modulateAtom(Atom a)` The displacement will be set as the atom vibration vector; the string buffer will be appended with the t value for a given unit cell.
    `void` | `setMinMax0(javajs.util.P3 minXYZ, javajs.util.P3 maxXYZ)`
    `protected void` | `setModDim(int ndim)`
    `void` | `setModulation(boolean isPost, SymmetryInterface symmetry)` Both the Jana reader and the CIF reader will call this to set the modulation for a given model.
    `private void` | `setModulationForStructure(int iModel, boolean isPost)` Called when structure creation is complete and all modulation data has been collected.
    `private void` | `setSubsystem(java.lang.String code, Subsystem system)`
    `private void` | `setSubsystemOptions()`
    `private javajs.util.P3` | `toP3(double[] x)`
    `private void` | `trimAtomSet()`

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

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

- - ### Field Detail

    - #### cr

          protected AtomSetCollectionReader cr

    - #### modDim

          protected int modDim

    - #### modAxes

          protected java.lang.String modAxes

    - #### modAverage

          protected boolean modAverage

    - #### isCommensurate

          protected boolean isCommensurate

    - #### commensurateSection1

          protected int commensurateSection1

    - #### modPack

          private boolean modPack

    - #### modVib

          private boolean modVib

    - #### modType

          private java.lang.String modType

    - #### modCell

          private java.lang.String modCell

    - #### modDebug

          private boolean modDebug

    - #### modSelected

          private int modSelected

    - #### modLast

          private boolean modLast

    - #### sigma

          private javajs.util.Matrix sigma

    - #### htModulation

          private java.util.Map<java.lang.String,double[]> htModulation

    - #### htAtomMods

          private java.util.Map<java.lang.String,javajs.util.Lst<Modulation>> htAtomMods

    - #### iopLast

          private int iopLast

    - #### gammaE

          private javajs.util.M3 gammaE

    - #### nOps

          private int nOps

    - #### haveOccupancy

          private boolean haveOccupancy

    - #### atoms

          private Atom[] atoms

    - #### ac

          private int ac

    - #### haveAtomMods

          private boolean haveAtomMods

    - #### modCoord

          private boolean modCoord

    - #### finalized

          private boolean finalized

    - #### symmetry

          private SymmetryInterface symmetry

    - #### supercellSymmetry

          private SymmetryInterface supercellSymmetry

    - #### legendres

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

    - #### atModel

          private java.lang.String atModel

    - #### modMatrices

          private javajs.util.Matrix[] modMatrices

    - #### qlist100

          private double[] qlist100

    - #### qs

          private javajs.util.P3[] qs

    - #### modCount

          private int modCount

    - #### modTUV

          private javajs.util.T3 modTUV

    - #### U_LIST

          private static final java.lang.String U_LIST

      See Also:
        Constant Field Values

    - #### htSubsystems

          java.util.Map<java.lang.String,Subsystem> htSubsystems

    - #### minXYZ0

          private javajs.util.P3 minXYZ0

    - #### maxXYZ0

          private javajs.util.P3 maxXYZ0

  - ### Constructor Detail

    - #### MSRdr

          public MSRdr()

  - ### Method Detail

    - #### getSigma

          javajs.util.Matrix getSigma()

    - #### initialize

          public int initialize(AtomSetCollectionReader r,
                                int modDim)
                         throws java.lang.Exception

      Specified by:
        `initialize` in interface `MSInterface`
      Throws:
        `java.lang.Exception`

    - #### setSubsystemOptions

          private void setSubsystemOptions()

    - #### setModDim

          protected void setModDim(int ndim)

    - #### addModulation

          public void addModulation(java.util.Map<java.lang.String,double[]> map,
                                    java.lang.String id,
                                    double[] pt,
                                    int iModel)

      Types include O (occupation) D (displacement) U (anisotropy) M (magnetic moment) _coefs_ indicates this is a wave description
      Specified by:
        `addModulation` in interface `MSInterface`
      Parameters:
        `map` -
        `id` -
        `pt` -
        `iModel` -

    - #### setModulation

          public void setModulation(boolean isPost,
                                    SymmetryInterface symmetry)
                             throws java.lang.Exception

      Both the Jana reader and the CIF reader will call this to set the modulation for a given model.
      Specified by:
        `setModulation` in interface `MSInterface`
      Throws:
        `java.lang.Exception`

    - #### finalizeModulation

          public void finalizeModulation()

      Create a script that will run to turn modulation on and to display only atoms with modulated occupancy >= 0.5.
      Specified by:
        `finalizeModulation` in interface `MSInterface`

    - #### checkKey

          private java.lang.String checkKey(java.lang.String key,
                                            boolean checkQ)

      Filter keys only for this model.
      Parameters:
        `key` -
        `checkQ` -
      Returns:
        trimmed key without model part or null

    - #### getMod

          public double[] getMod(java.lang.String key)

      Modulation data keys are keyed by model number as well as type using [at]n, where n is the model number, starting with 0.
      Specified by:
        `getMod` in interface `MSInterface`
      Parameters:
        `key` -
      Returns:
        modulation data

    - #### getModulationMap

          public java.util.Map<java.lang.String,double[]> getModulationMap()

      Specified by:
        `getModulationMap` in interface `MSInterface`

    - #### setModulationForStructure

          private void setModulationForStructure(int iModel,
                                                 boolean isPost)
                                          throws java.lang.Exception

      Called when structure creation is complete and all modulation data has been collected.
      Parameters:
        `iModel` -
        `isPost` -
      Throws:
        `java.lang.Exception`

    - #### initModForStructure

          private void initModForStructure(int iModel)
                                    throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### fixLegendre

          private void fixLegendre()

    - #### fixDouble

          private void fixDouble(double[] pt)

    - #### getQCoefs

          public double[] getQCoefs(java.lang.String key)

      Specified by:
        `getQCoefs` in interface `MSInterface`

    - #### getModType

          public char getModType(java.lang.String key)

      Specified by:
        `getModType` in interface `MSInterface`

    - #### calculateQCoefs

          private double[] calculateQCoefs(double[] p)

      determine simple linear combination assuming simple -3 to 3 no more than two dimensions.
      Parameters:
        `p` -
      Returns:
        {i j k}

    - #### approxInt

          private int approxInt(float fn)

    - #### toP3

          private javajs.util.P3 toP3(double[] x)

    - #### addAtomModulation

          private void addAtomModulation(java.lang.String atomName,
                                         char axis,
                                         char type,
                                         double[] params,
                                         java.lang.String utens,
                                         double[] qcoefs)

      Create a list of modulations for each atom type (atom name).
      Parameters:
        `atomName` -
        `axis` -
        `type` -
        `params` -
        `utens` -
        `qcoefs` -

    - #### addSubsystem

          public void addSubsystem(java.lang.String code,
                                   javajs.util.Matrix w)

      Specified by:
        `addSubsystem` in interface `MSInterface`

    - #### addUStr

          private void addUStr(Atom atom,
                               java.lang.String id,
                               float val)

    - #### modulateAtom

          private void modulateAtom(Atom a)

      The displacement will be set as the atom vibration vector; the string buffer will be appended with the t value for a given unit cell. Modulation generally involves x4 = q.r + t. Here we arbitrarily set t = modT = 0, but modT could be a FILTER option MODT=n. There would need to be one modT per dimension or modU, modV.
      Parameters:
        `a` -

    - #### getAtomR0

          private javajs.util.P3 getAtomR0(Atom atom)

    - #### getAtomSymmetry

          public SymmetryInterface getAtomSymmetry(Atom a,
                                                   SymmetryInterface defaultSymmetry)

      When applying symmetry, this method allows us to use a set of symmetry operators unique to this particular atom -- or in this case, to its subsystem.
      Specified by:
        `getAtomSymmetry` in interface `MSInterface`

    - #### setSubsystem

          private void setSubsystem(java.lang.String code,
                                    Subsystem system)

    - #### getMatrices

          private javajs.util.Matrix[] getMatrices(Atom a)

    - #### getSymmetry

          private SymmetryInterface getSymmetry(Atom a)

    - #### getSubsystem

          private Subsystem getSubsystem(Atom a)

    - #### setMinMax0

          public void setMinMax0(javajs.util.P3 minXYZ,
                                 javajs.util.P3 maxXYZ)

      Specified by:
        `setMinMax0` in interface `MSInterface`

    - #### expandMinMax

          private void expandMinMax(javajs.util.P3 pt,
                                    SymmetryInterface sym,
                                    javajs.util.P3 minXYZ,
                                    javajs.util.P3 maxXYZ)

    - #### trimAtomSet

          private void trimAtomSet()

    - #### getDefaultUnitCell

          private SymmetryInterface getDefaultUnitCell()

    - #### getSymmetryFromCode

          public SymmetryInterface getSymmetryFromCode(java.lang.String code)

      Specified by:
        `getSymmetryFromCode` in interface `MSInterface`

    - #### addLatticeVector

          public boolean addLatticeVector(javajs.util.Lst<float[]> lattvecs,
                                          java.lang.String data)
                                   throws java.lang.Exception

      Specified by:
        `addLatticeVector` in interface `MSInterface`
      Throws:
        `java.lang.Exception`