# Model

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

Name | Type | Description
--- | --- | ---
`atoms` | crystcif.Atoms | Atomic structure, in crystcif's Atoms format
`parameters` | Object | 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)

Source:
  - model.js, line 917

### Members

#### # (readonly) all :ModelView

ModelView containing all the atoms of the image

Type:

- ModelView

Source:
  - model.js, line 1199

#### # (readonly) atoms :Array.<AtomImage>

Atom images in this model

Type:

- Array.<AtomImage>

Source:
  - model.js, line 1190

#### # (readonly) axes :AxesMesh

Graphical object representing the unit cell's axes

Type:

- AxesMesh

Source:
  - model.js, line 1208

#### # (readonly) box :BoxMesh

Graphical object representing the unit cell's box

Type:

- BoxMesh

Source:
  - model.js, line 1217

#### # (readonly) cell :Array.<Array>

Unit cell of the model's original cell

Type:

- Array.<Array>

Source:
  - model.js, line 1118

#### # (readonly) crystalLabels :Array.<String>

Crystallographic labels of each atom

Type:

- Array.<String>

Source:
  - model.js, line 1163

#### # (readonly) info :Object

Additional information from the model's original cell

Type:

- Object

Source:
  - model.js, line 1136

#### # (readonly) length :int

Number of atoms in this model's original cell

Type:

- int

Source:
  - model.js, line 1073

#### # (readonly) numbers :Array.<int>

Atomic numbers in this model's original cell

Type:

- Array.<int>

Source:
  - model.js, line 1091

#### # (readonly) pbc :Array.<bool>

Periodic boundary conditions

Type:

- Array.<bool>

Source:
  - model.js, line 1127

#### # (readonly) periodic :bool

Whether this model is periodic in all three directions of space

Type:

- bool

Source:
  - model.js, line 1145

#### # (readonly) positions :Array.<Array>

Coordinates of the atoms in this model's original cell

Type:

- Array.<Array>

Source:
  - model.js, line 1100

#### # renderer :Renderer

Renderer used for this model's graphics

Type:

- Renderer

Source:
  - model.js, line 1243

#### # (readonly) scaledPositions :Array.<Array>

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

Type:

- Array.<Array>

Source:
  - model.js, line 1109

#### # (readonly) speciesIndices :Array.<int>

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

Type:

- Array.<int>

Source:
  - model.js, line 1154

#### # (readonly) supercell :Array.<int>

Shape of the supercell for this model

Type:

- Array.<int>

Source:
  - model.js, line 1172

#### # (readonly) supercellGrid :Array.<Array>

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

Type:

- Array.<Array>

Source:
  - model.js, line 1181

#### # (readonly) symbols :Array.<String>

Chemical symbols in this model's original cell

Type:

- Array.<String>

Source:
  - model.js, line 1082

#### # (readonly) vdwElementScaling :Object

Table of scaling factors by element for Van der Waals radii

Type:

- Object

Source:
  - model.js, line 1235

#### # (readonly) vdwScaling :float

Global scaling factor for Van der Waals radii

Type:

- float

Source:
  - model.js, line 1226

### Methods

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

Convert absolute coordinates to fractional

Parameters:

Name | Type | Description
--- | --- | ---
`x` | Array.<float> | Absolute coordinates

Source:
  - model.js, line 1649

Returns:

Fractional coordinates

Type
  Array.<float>

#### # addLink(from, to, name, label, parameters)

Add link drawn on model

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`from` | Atom | Array |  | Starting point
`to` | Atom | Array |  | End point
`name` | String | link | Name to use for the link object
`label` | String | null | Text label to add to the link
`parameters` | Object |  | Additional parameters (see LineMesh)

Source:
  - model.js, line 1326

#### # addSphere(center, radius, name, parameters)

Add a sphere drawn on model

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`center` | Atom | Array |  | Center of the sphere
`radius` | float |  | Radius of the sphere
`name` | String | sphere | Name to use for the sphere object
`parameters` | Object |  | Additional parameters (see EllipsoidMesh)

Source:
  - model.js, line 1361

#### # clearGraphics()

Remove all graphical objects

Source:
  - model.js, line 1407

#### # deleteArray(name)

Delete an array from the underlying Atoms object

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | Name of the array to delete

Source:
  - model.js, line 1310

#### # find(query) → {ModelView}

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

Parameters:

Name | Type | Description
--- | --- | ---
`query` | Array | A search query for atoms. Must use nested lists of types and arguments, and can use logic operators $and, $or and $xor.

Source:
  - model.js, line 1700

Returns:

ModelView object for found atoms

Type
  ModelView

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

Convert fractional coordinates to absolute

Parameters:

Name | Type | Description
--- | --- | ---
`fx` | Array.<float> | Fractional coordinates

Source:
  - model.js, line 1632

Returns:

Absolute coordinates

Type
  Array.<float>

#### # getArray(name) → {Array}

Retrieve an array from the underlying Atoms object

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | Name of the array to retrieve

Source:
  - model.js, line 1293

Returns:

Retrieved array

Type
  Array

#### # hasArray(name) → {bool}

Check if an array exists in the underlying Atoms object

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | Name of the array to check

Source:
  - model.js, line 1302

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:

Name | Type | Description
--- | --- | ---
`r` | float | Maximum distance that must be contained within the supercell

Source:
  - model.js, line 1667

#### # removeGraphics(name)

Remove the graphical object with a given name

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | Name of the graphical object to remove

Source:
  - model.js, line 1396

#### # setArray(name, arr)

Set an array for the underlying Atoms object

Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | Name of the array to use
`arr` | Array | Array to store

Source:
  - model.js, line 1284

#### # view(indices) → {ModelView}

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

Parameters:

Name | Type | Description
--- | --- | ---
`indices` | Array | Indices of atoms to include in the ModelView

Source:
  - model.js, line 1710

Returns:

ModelView object for specified indices

Type
  ModelView