BZone
Date: 2019-10-22

org.jmol.util

## Class BZone

- java.lang.Object
- - org.jmol.util.BZone

-     public class BZone
      extends java.lang.Object

  class to represent and produce Brillouin zone polyhedra and Wigner-Seitz cells based on https://chemapps.stolaf.edu/jmol/jsmol/spt/ext/xtal/bz.spt

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private javajs.util.Lst<java.lang.Double>` | `areas`
    `(package private) static java.lang.String[]` | `bzColors`
    `(package private) boolean` | `bzDrawPointsAndEdges`
    `private javajs.util.Lst<javajs.util.P3>` | `bzFaceCenters`
    `private javajs.util.P3` | `bzGamma`
    `private javajs.util.Lst<javajs.util.P3>` | `bzLatticePts`
    `private javajs.util.P3[]` | `bzLatticePtsAll`
    `private javajs.util.Lst<BZone>` | `bzones`
    `private javajs.util.Lst<javajs.util.P3>` | `bzPlanePts`
    `(package private) boolean` | `bzSavePmeshes`
    `private javajs.util.P3` | `center`
    `private java.lang.String` | `color`
    `private JmolScriptEvaluator` | `eval`
    `private javajs.util.Lst<javajs.util.P3>` | `faceCenters`
    `private javajs.util.Lst<int[]>` | `faceIndices`
    `private javajs.util.Lst<javajs.util.P3[]>` | `faces`
    `private java.lang.String` | `id`
    `private int` | `index`
    `private boolean` | `isWignerSeitz`
    `private javajs.util.Lst<javajs.util.P3>` | `latticePts`
    `private javajs.util.Lst<javajs.util.P3>` | `newLatticePts`
    `private javajs.util.Lst<javajs.util.P3>` | `newPlanePts`
    `private javajs.util.Lst<javajs.util.P4>` | `newPlanes`
    `private javajs.util.P3` | `offset`
    `private javajs.util.Lst<javajs.util.P4>` | `planes`
    `private javajs.util.Lst<javajs.util.P4>` | `planesUnused`
    `private javajs.util.Lst<java.lang.Object>` | `pmeshes`
    `private java.lang.String` | `polyid`
    `private static javajs.util.P3` | `ptInner`
    `private javajs.util.P3[]` | `pts`
    `private javajs.util.Lst<javajs.util.P3>` | `ptsUnused`
    `private java.lang.Object[]` | `ret`
    `private javajs.util.Lst<BZone>` | `subzones`
    `private double` | `totalArea`
    `private float` | `volume`
    `private Viewer` | `vwr`
    `private int` | `zoneIndex`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BZone()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `addBZ(javajs.util.Lst<javajs.util.P4> planes, javajs.util.Lst<javajs.util.P3> pts, javajs.util.Lst<javajs.util.P4> planes0, javajs.util.Lst<javajs.util.P3> pts0, int j)`
    `private javajs.util.P3` | `average(javajs.util.P3[] face)`
    `private java.lang.String` | `bzColor(int i)` give each Brillouin zone a new color
    `private javajs.util.P3[]` | `cleanFace(javajs.util.P3[] face)`
    `private javajs.util.P3` | `closest(javajs.util.P3 center, javajs.util.P3[] ap3)`
    `private void` | `cmd(java.lang.String cmd)`
    `private void` | `createAllBZs(int n, boolean discardPrev, java.lang.String id, float scale)` Starting with 1, build the Brillouin zones as polyhedra, optionally discarding the previous as we go.
    `void` | `createBZ(int zone, java.lang.Object[] array, boolean isK, java.lang.String id, float scale)` Create a Brillouin zone.
    `private void` | `createNextBZ(BZone zone, BZone zonePrev, java.lang.String id)`
    `private void` | `createSubzonePolyhedron(BZone subzone, java.lang.String id)` Generate the polyhedra.
    `void` | `createWS(java.lang.String id)` Create a Wigner-Seitz unitcell centered on {0 0 0}.
    `private void` | `demoBZ(java.lang.Object[] array, boolean isK)`
    `private void` | `drawSubzonePolygons(BZone subzone)`
    `private void` | `drawZoneCenters(BZone zone)`
    `private int[]` | `faceIndices(javajs.util.P3[] p3s, javajs.util.P3[] pts)`
    `private void` | `finalizeZone(BZone zone)` Finalize a Brillouin zone.
    `private void` | `getLatticePoints(int n)` Get the needed lattice points for n Brillouin zones.
    `private void` | `getNewLatticePoints(BZone zone)` Loop through all points, looking for non-excluded points using St.
    `private java.lang.Object` | `getProperty(java.lang.String name, java.lang.String key)`
    `private boolean` | `getSubzonePmeshes(BZone subzone)` Loop through all planes, creating a pmesh for each face.
    `private void` | `getSubzones(BZone zone, BZone zonePrev)`
    `private javajs.util.P3[]` | `join(javajs.util.Lst<javajs.util.P3[]> faces)`
    `private BZone` | `newBZ(int i)` initialize a new Brillouin zone
    `private javajs.util.P3` | `newPoint(int i, int j, int k, javajs.util.P3 pt)`
    `private BZone` | `newSubZone(BZone zone, java.lang.String id, int index)`
    `private javajs.util.P4` | `plane(javajs.util.P3 pt1, javajs.util.P3 pt2, float f)`
    `BZone` | `setViewer(Viewer vwr)`
    `private java.lang.String` | `toScript(javajs.util.P4 p4)`
    `private javajs.util.Lst<javajs.util.P3>` | `within(float radius, javajs.util.P3 center, javajs.util.Lst<javajs.util.P3> pts)`

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

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

- - ### Field Detail

    - #### bzColors

          static java.lang.String[] bzColors

    - #### bzDrawPointsAndEdges

          boolean bzDrawPointsAndEdges

    - #### bzSavePmeshes

          boolean bzSavePmeshes

    - #### bzones

          private javajs.util.Lst<BZone> bzones

    - #### bzGamma

          private javajs.util.P3 bzGamma

    - #### bzFaceCenters

          private javajs.util.Lst<javajs.util.P3> bzFaceCenters

    - #### bzLatticePts

          private javajs.util.Lst<javajs.util.P3> bzLatticePts

    - #### bzLatticePtsAll

          private javajs.util.P3[] bzLatticePtsAll

    - #### bzPlanePts

          private javajs.util.Lst<javajs.util.P3> bzPlanePts

    - #### subzones

          private javajs.util.Lst<BZone> subzones

    - #### isWignerSeitz

          private boolean isWignerSeitz

    - #### vwr

          private Viewer vwr

    - #### eval

          private JmolScriptEvaluator eval

    - #### id

          private java.lang.String id

    - #### index

          private int index

    - #### color

          private java.lang.String color

    - #### latticePts

          private javajs.util.Lst<javajs.util.P3> latticePts

    - #### newLatticePts

          private javajs.util.Lst<javajs.util.P3> newLatticePts

    - #### newPlanePts

          private javajs.util.Lst<javajs.util.P3> newPlanePts

    - #### planes

          private javajs.util.Lst<javajs.util.P4> planes

    - #### newPlanes

          private javajs.util.Lst<javajs.util.P4> newPlanes

    - #### volume

          private float volume

    - #### zoneIndex

          private int zoneIndex

    - #### offset

          private javajs.util.P3 offset

    - #### center

          private javajs.util.P3 center

    - #### planesUnused

          private javajs.util.Lst<javajs.util.P4> planesUnused

    - #### ptsUnused

          private javajs.util.Lst<javajs.util.P3> ptsUnused

    - #### pmeshes

          private javajs.util.Lst<java.lang.Object> pmeshes

    - #### areas

          private javajs.util.Lst<java.lang.Double> areas

    - #### faces

          private javajs.util.Lst<javajs.util.P3[]> faces

    - #### faceIndices

          private javajs.util.Lst<int[]> faceIndices

    - #### faceCenters

          private javajs.util.Lst<javajs.util.P3> faceCenters

    - #### totalArea

          private double totalArea

    - #### ptInner

          private static javajs.util.P3 ptInner

    - #### ret

          private java.lang.Object[] ret

    - #### polyid

          private java.lang.String polyid

    - #### pts

          private javajs.util.P3[] pts

  - ### Constructor Detail

    - #### BZone

          public BZone()

  - ### Method Detail

    - #### setViewer

          public BZone setViewer(Viewer vwr)

    - #### createBZ

          public void createBZ(int zone,
                               java.lang.Object[] array,
                               boolean isK,
                               java.lang.String id,
                               float scale)

      Create a Brillouin zone. /// createBZ or createBZ(1, null, false) just the 1st Brillouin zone /// createBZ(n, null, false) just the nth Brillouin zone /// createbZ(0, [a b c alpha beta gamma], false) create a BZ for a given primitive lattice unit cell /// createbZ(0, [a b c alpha beta gamma], true) create a BZ for a given reciprocal lattice unit cell
      Parameters:
        `scale` -

    - #### createWS

          public void createWS(java.lang.String id)

      Create a Wigner-Seitz unitcell centered on {0 0 0}. /// primitive cell is assumed -- user is responsible for unitcell PRIMITIVE /// executed first (unitcell CONVENTIONAL later if desired) /// createWS("p1") for example.

    - #### createAllBZs

          private void createAllBZs(int n,
                                    boolean discardPrev,
                                    java.lang.String id,
                                    float scale)

      Starting with 1, build the Brillouin zones as polyhedra, optionally discarding the previous as we go. bNote that even for the 4th Brillouin zone, this is time consuming. If n = -1, then this is a Wigner-Seitz cell

    - #### createNextBZ

          private void createNextBZ(BZone zone,
                                    BZone zonePrev,
                                    java.lang.String id)

    - #### newSubZone

          private BZone newSubZone(BZone zone,
                                   java.lang.String id,
                                   int index)

    - #### getSubzones

          private void getSubzones(BZone zone,
                                   BZone zonePrev)

    - #### addBZ

          private void addBZ(javajs.util.Lst<javajs.util.P4> planes,
                             javajs.util.Lst<javajs.util.P3> pts,
                             javajs.util.Lst<javajs.util.P4> planes0,
                             javajs.util.Lst<javajs.util.P3> pts0,
                             int j)

    - #### getNewLatticePoints

          private void getNewLatticePoints(BZone zone)

      Loop through all points, looking for non-excluded points using St. Olaf half-distance sphere test.

    - #### plane

          private javajs.util.P4 plane(javajs.util.P3 pt1,
                                       javajs.util.P3 pt2,
                                       float f)

    - #### within

          private javajs.util.Lst<javajs.util.P3> within(float radius,
                                                         javajs.util.P3 center,
                                                         javajs.util.Lst<javajs.util.P3> pts)

    - #### newBZ

          private BZone newBZ(int i)

      initialize a new Brillouin zone

    - #### bzColor

          private java.lang.String bzColor(int i)

      give each Brillouin zone a new color

    - #### getLatticePoints

          private void getLatticePoints(int n)

      Get the needed lattice points for n Brillouin zones. A calculation is done to ensure that enough points are provided in all directions, which may not be the same number.

    - #### newPoint

          private javajs.util.P3 newPoint(int i,
                                          int j,
                                          int k,
                                          javajs.util.P3 pt)

    - #### cmd

          private void cmd(java.lang.String cmd)

    - #### demoBZ

          private void demoBZ(java.lang.Object[] array,
                              boolean isK)

    - #### getSubzonePmeshes

          private boolean getSubzonePmeshes(BZone subzone)

      Loop through all planes, creating a pmesh for each face. We use resolution 0.001 to indicate we only want the minimum number of triangles (that is, starting with two giant triangles, not a grid of small triangles). Also slab each plane by all other planes to form a face.

    - #### toScript

          private java.lang.String toScript(javajs.util.P4 p4)

    - #### getProperty

          private java.lang.Object getProperty(java.lang.String name,
                                               java.lang.String key)

    - #### createSubzonePolyhedron

          private void createSubzonePolyhedron(BZone subzone,
                                               java.lang.String id)

      Generate the polyhedra.

    - #### faceIndices

          private int[] faceIndices(javajs.util.P3[] p3s,
                                    javajs.util.P3[] pts)

    - #### closest

          private javajs.util.P3 closest(javajs.util.P3 center,
                                         javajs.util.P3[] ap3)

    - #### cleanFace

          private javajs.util.P3[] cleanFace(javajs.util.P3[] face)

    - #### average

          private javajs.util.P3 average(javajs.util.P3[] face)

    - #### join

          private javajs.util.P3[] join(javajs.util.Lst<javajs.util.P3[]> faces)

    - #### drawZoneCenters

          private void drawZoneCenters(BZone zone)

    - #### drawSubzonePolygons

          private void drawSubzonePolygons(BZone subzone)

    - #### finalizeZone

          private void finalizeZone(BZone zone)

      Finalize a Brillouin zone.