lib/model.js~ Model

new Model(atoms, parameters)

An object containing an Atomic structure and taking care of its periodic nature, allowing querying and selection, and so on.

Parameters:
NameTypeDescription
atomscrystcif.Atoms

Atomic structure, in crystcif's Atoms format

parametersObject

Additional options:

  • supercell
  • molecularCrystal (if true, load full molecules in central unit cell)
  • useNMRActiveIsotopes (if true, all isotopes are set by default to the most common one with non-zero spin)
  • vdwScaling (scale van der Waals radii by a constant factor)
  • vdwElementScaling (table of per-element factors to scale VdW radii by)

Members

(readonly) all :ModelView

ModelView containing all the atoms of the image

Type:
  • ModelView

(readonly) atoms :Array.<AtomImage>

Atom images in this model

Type:
  • Array.<AtomImage>

(readonly) axes :AxesMesh

Graphical object representing the unit cell's axes

Type:
  • AxesMesh

(readonly) box :BoxMesh

Graphical object representing the unit cell's box

Type:
  • BoxMesh

(readonly) cell :Array.<Array>

Unit cell of the model's original cell

Type:
  • Array.<Array>

(readonly) crystalLabels :Array.<String>

Crystallographic labels of each atom

Type:
  • Array.<String>

(readonly) info :Object

Additional information from the model's original cell

Type:
  • Object

(readonly) length :int

Number of atoms in this model's original cell

Type:
  • int

(readonly) numbers :Array.<int>

Atomic numbers in this model's original cell

Type:
  • Array.<int>

(readonly) pbc :Array.<bool>

Periodic boundary conditions

Type:
  • Array.<bool>

(readonly) periodic :bool

Whether this model is periodic in all three directions of space

Type:
  • bool

(readonly) positions :Array.<Array>

Coordinates of the atoms in this model's original cell

Type:
  • Array.<Array>

renderer :Renderer

Renderer used for this model's graphics

Type:
  • Renderer

(readonly) scaledPositions :Array.<Array>

Fractional coordinates of the atoms in this model's original cell

Type:
  • Array.<Array>

(readonly) speciesIndices :Array.<int>

Indices of each atom by their species (e.g. C1, C2, H1, C3, H2, etc.)

Type:
  • Array.<int>

(readonly) supercell :Array.<int>

Shape of the supercell for this model

Type:
  • Array.<int>

(readonly) supercellGrid :Array.<Array>

Full grid of origin coordinates of the cells making up the supercell

Type:
  • Array.<Array>

(readonly) symbols :Array.<String>

Chemical symbols in this model's original cell

Type:
  • Array.<String>

(readonly) vdwElementScaling :Object

Table of scaling factors by element for Van der Waals radii

Type:
  • Object

(readonly) vdwScaling :float

Global scaling factor for Van der Waals radii

Type:
  • float

Methods

absToFrac(x) → {Array.<float>}

Convert absolute coordinates to fractional

Parameters:
NameTypeDescription
xArray.<float>

Absolute coordinates

Returns:

Fractional coordinates

Type: 
Array.<float>

Add link drawn on model

Parameters:
NameTypeDefaultDescription
fromAtom | Array

Starting point

toAtom | Array

End point

nameStringlink

Name to use for the link object

labelStringnull

Text label to add to the link

parametersObject

Additional parameters (see LineMesh)

addSphere(center, radius, name, parameters)

Add a sphere drawn on model

Parameters:
NameTypeDefaultDescription
centerAtom | Array

Center of the sphere

radiusfloat

Radius of the sphere

nameStringsphere

Name to use for the sphere object

parametersObject

Additional parameters (see EllipsoidMesh)

clearGraphics()

Remove all graphical objects

deleteArray(name)

Delete an array from the underlying Atoms object

Parameters:
NameTypeDescription
nameString

Name of the array to delete

find(query) → {ModelView}

Find a group of atoms based on a given query and return as AtomImages

Parameters:
NameTypeDescription
queryArray

A search query for atoms. Must use nested lists of types and arguments, and can use logic operators $and, $or and $xor.

Returns:

ModelView object for found atoms

Type: 
ModelView

fracToAbs(fx) → {Array.<float>}

Convert fractional coordinates to absolute

Parameters:
NameTypeDescription
fxArray.<float>

Fractional coordinates

Returns:

Absolute coordinates

Type: 
Array.<float>

getArray(name) → {Array}

Retrieve an array from the underlying Atoms object

Parameters:
NameTypeDescription
nameString

Name of the array to retrieve

Returns:

Retrieved array

Type: 
Array

hasArray(name) → {bool}

Check if an array exists in the underlying Atoms object

Parameters:
NameTypeDescription
nameString

Name of the array to check

Returns:

Whether the array exists

Type: 
bool

minimumSupercell(r)

Compute and return the minimum supercell that guarantees containing all atoms at a maximum distance r from those in the [0,0,0] cell.

Parameters:
NameTypeDescription
rfloat

Maximum distance that must be contained within the supercell

removeGraphics(name)

Remove the graphical object with a given name

Parameters:
NameTypeDescription
nameString

Name of the graphical object to remove

setArray(name, arr)

Set an array for the underlying Atoms object

Parameters:
NameTypeDescription
nameString

Name of the array to use

arrArray

Array to store

view(indices) → {ModelView}

Create a new ModelView for this model, using a given list of indices

Parameters:
NameTypeDescription
indicesArray

Indices of atoms to include in the ModelView

Returns:

ModelView object for specified indices

Type: 
ModelView