Package org.jmol.util

Class SimpleUnitCell

java.lang.Object
org.jmol.util.SimpleUnitCell
Direct Known Subclasses:
UnitCell

public class SimpleUnitCell extends Object
general-purpose simple unit cell for calculations and as a super-class of unitcell, which is only part of Symmetry allows one-dimensional (polymer) and two-dimensional (slab) periodicity
  • Field Details

    • PARAM_STD

      public static final int PARAM_STD
      See Also:
    • PARAM_VAX

      public static final int PARAM_VAX
      See Also:
    • PARAM_VBX

      public static final int PARAM_VBX
      See Also:
    • PARAM_VCX

      public static final int PARAM_VCX
      See Also:
    • PARAM_VCZ

      public static final int PARAM_VCZ
      See Also:
    • PARAM_OXYZ

      public static final int PARAM_OXYZ
      See Also:
    • PARAM_M4

      public static final int PARAM_M4
      See Also:
    • PARAM_M33

      public static final int PARAM_M33
      See Also:
    • PARAM_SUPERCELL

      public static final int PARAM_SUPERCELL
      See Also:
    • PARAM_SCALE

      public static final int PARAM_SCALE
      See Also:
    • PARAM_SLOP

      public static final int PARAM_SLOP
      See Also:
    • PARAM_COUNT

      public static final int PARAM_COUNT
      See Also:
    • INFO_IS_RHOMBOHEDRAL

      public static final int INFO_IS_RHOMBOHEDRAL
      See Also:
    • INFO_IS_HEXAGONAL

      public static final int INFO_IS_HEXAGONAL
      See Also:
    • INFO_DIMENSIONS

      public static final int INFO_DIMENSIONS
      See Also:
    • INFO_GAMMA

      public static final int INFO_GAMMA
      See Also:
    • INFO_BETA

      public static final int INFO_BETA
      See Also:
    • INFO_ALPHA

      public static final int INFO_ALPHA
      See Also:
    • INFO_C

      public static final int INFO_C
      See Also:
    • INFO_B

      public static final int INFO_B
      See Also:
    • INFO_A

      public static final int INFO_A
      See Also:
    • HEX_TO_RHOMB

      public static final String HEX_TO_RHOMB
      See Also:
    • RHOMB_TO_HEX

      public static final String RHOMB_TO_HEX
      See Also:
    • toRadians

      protected static final double toRadians
      See Also:
    • SLOPSP

      public static final float SLOPSP
      allowance for rounding in [0,1)
      See Also:
    • SLOPDP

      public static final float SLOPDP
      See Also:
    • SLOP_PARAMS

      public static final float SLOP_PARAMS
      See Also:
    • unitCellParams

      protected float[] unitCellParams
    • slop

      protected float slop
      initial value is set in subclass UnitCell
    • matrixCartesianToFractional

      public M4 matrixCartesianToFractional
    • matrixFractionalToCartesian

      public M4 matrixFractionalToCartesian
    • matrixCtoFNoOffset

      protected M4 matrixCtoFNoOffset
    • matrixFtoCNoOffset

      protected M4 matrixFtoCNoOffset
    • volume

      public double volume
    • dimension

      protected int dimension
    • a

      protected float a
    • b

      protected float b
    • c

      protected float c
    • alpha

      protected float alpha
    • beta

      protected float beta
    • gamma

      protected float gamma
    • cosAlpha

      protected double cosAlpha
    • sinAlpha

      protected double sinAlpha
    • cosBeta

      protected double cosBeta
    • sinBeta

      protected double sinBeta
    • cosGamma

      protected double cosGamma
    • sinGamma

      protected double sinGamma
    • cA_

      protected double cA_
    • cB_

      protected double cB_
    • a_

      protected double a_
    • b_

      protected double b_
    • c_

      protected double c_
  • Constructor Details

    • SimpleUnitCell

      protected SimpleUnitCell()
  • Method Details

    • getPrecision

      public float getPrecision()
    • setPrecision

      public void setPrecision(float slop)
    • isSupercell

      public boolean isSupercell()
    • isValid

      public static boolean isValid(float[] parameters)
    • newA

      public static SimpleUnitCell newA(float[] params)
      Parameters:
      params - len = 6 [a b c alpha beta gamma] len = 6 [a b -1 alpha beta gamma] // slab len = 6 [a -1 -1 alpha beta gamma] // polymer or len = 15 [-1 -1 -1 -1 -1 -1 va[3] vb[3] vc[3]] // vectors only or len = 15 [a -1 -1 -1 -1 -1 va[3] vb[3] vc[3]] // polymer, vectors only or len = 15 [a b -1 -1 -1 -1 va[3] vb[3] vc[3]] // slab, vectors only or len = 22 [a b c alpha beta gamma m00 m01 .. m33] // matrix included and/or len = 25 [...................... na nb nc] // supercell and/or len = 26 [...................... na nb nc scale] // scaled supercell and/or len = 27 [..................................... slop] // precision
      Returns:
      a simple unit cell
    • getDimensionFromParams

      public static int getDimensionFromParams(float[] params)
    • init

      protected void init(float[] params)
    • newParams

      public static float[] newParams(float[] params, float slop)
    • addVectors

      public static void addVectors(float[] params)
    • fillParams

      public static void fillParams(V3 va, V3 vb, V3 vc, float[] p)
    • getFractionalOrigin

      public P3 getFractionalOrigin()
      Get the fractional origin for the UccageRenderer. NOTE: This is NOT a copy
      Returns:
      fractionalOrigin
    • toSupercell

      public P3 toSupercell(P3 fpt)
      convenience return only after changing fpt
      Parameters:
      fpt -
      Returns:
      adjusted fpt
    • toCartesian

      public final void toCartesian(T3 pt, boolean ignoreOffset)
    • toFractionalM

      public void toFractionalM(M4 m)
    • toFractional

      public final void toFractional(T3 pt, boolean ignoreOffset)
    • isPolymer

      public boolean isPolymer()
    • isSlab

      public boolean isSlab()
    • getUnitCellParams

      public final float[] getUnitCellParams()
    • getUnitCellAsArray

      public final float[] getUnitCellAsArray(boolean vectorsOnly)
    • getInfo

      public final float getInfo(int infoType)
    • getReciprocal

      public static T3[] getReciprocal(T3[] abc, T3[] ret, float scale)
      Generate the reciprocal unit cell, scaled as desired
      Parameters:
      abc - [a,b,c] or [o,a,b,c]
      ret -
      scale - 0 for 2pi, teneral reciprocal lattice
      Returns:
      oabc
    • setAbc

      public static T3[] setAbc(String abcabg, float[] params, T3[] ucnew)
      set cell vectors by string. Does not set origin.
      Parameters:
      abcabg - "a=...,b=...,c=...,alpha=...,beta=..., gamma=..." or null
      params - to use if not null
      ucnew - to create and return; null if only to set params
      Returns:
      T3[4] ucnew as [origin, a, b, c], with origin unchanged or {0 0 0}
    • setAbcFromParams

      public static T3[] setAbcFromParams(float[] params, T3[] ucnew)
    • unitizeDim

      public void unitizeDim(int dimension, T3 pt)
      Used for just about everything; via UnitCell including SpaceGroup.getSiteMultiplicity, Symmetry.getInvariantSymops, Symmetry.removeDuplicates, Symmetry.unitize, Symmetry.toUnitCell, SymmetryDesc.getTransform. Low precision here unless SET HIGHPRECISION TRUE has been issued.
      Parameters:
      dimension -
      pt -
    • unitizeDimRnd

      public static void unitizeDimRnd(int dimension, T3 pt, float slop)
      Only used for getting equivalent points and checking for duplicates. Presumption here is that two points should not be close together regardless of lattice distances.
      Parameters:
      dimension -
      pt -
      slop -
    • unitizeX

      public static float unitizeX(float x, float slop)
    • unitizeXRnd

      public static float unitizeXRnd(float x, float slop)
      Slightly higher precision -- only used for cmdAssignSpaceGroup checking for duplicates
      Parameters:
      x -
      slop -
      Returns:
      rounded value +/-slop
    • twelfthsOf

      public int twelfthsOf(float f)
    • twelfthify

      public void twelfthify(P3 pt)
    • ijkToPoint3f

      public static void ijkToPoint3f(int nnn, P3 cell, int offset, int kcode)
      Expanded cell notation: 111 - 1000 --> center 5,5,5; range 0 to 9 or -5 to +4 1000000 - 1999999 --> center 50,50,50; range 0 to 99 or -50 to +49 1000000000 - 1999999999 --> center 500, 500, 500; range 0 to 999 or -500 to +499 for example, a 3x3x3 block of 27 cells: {444 666 1} or {1494949 1515151 1} or {1499499499 1501501501 1}
      Parameters:
      nnn -
      cell -
      offset - 0 or 1 typically; invalid input: '<' 0 means "apply no offset"
      kcode - Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}. Here, our offset -- initially 0 or 1 from the uccage renderer, but later -500 or -499 -- tells us which code we are
    • ptToIJK

      public static P4 ptToIJK(T3 pt, int scale)
      Convert user's {3 2 1} to {1500500500, 1503502501, 0 or 1, 1500501}
      Parameters:
      pt -
      scale - 1 for block of unit cells; 0 for one large supercell
      Returns:
      converted P4
    • escapeMultiplier

      public static String escapeMultiplier(T3 pt)
      Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}
      Parameters:
      pt -
      Returns:
      String representation for state
    • setMinMaxLatticeParameters

      public static void setMinMaxLatticeParameters(int dimension, P3i minXYZ, P3i maxXYZ, int kcode)
      Parameters:
      dimension -
      minXYZ -
      maxXYZ -
      kcode - Generally the multiplier is just {ijk ijk scale}, but when we have 1iiijjjkkk 1iiijjjkkk scale, floats lose kkk due to Java float precision issues so we use P4 {1iiijjjkkk 1iiijjjkkk scale, 1kkkkkk}. Here, our offset -- initially 0 or 1 from the uccage renderer, but later -500 or -499 -- tells us which code we are looking at, the first one or the second one.
    • isHexagonal

      public static boolean isHexagonal(float[] params)
      Parameters:
      params -
      Returns:
      true if approximately hexagonal
    • isRhombohedral

      public static boolean isRhombohedral(float[] params)
      Parameters:
      params -
      Returns:
      true if approximately rhombohedral
    • approx0

      protected static boolean approx0(float f)
      Parameters:
      f -
      Returns:
      true or false
    • getCellRange

      public static int getCellRange(T3 fset, P3[] cellRange)
    • toString

      public String toString()
      Overrides:
      toString in class Object