Loading in Molecule Files#

Molecule input files are stored in PorousMaterials.PATH_TO_MOLECULES. Each molecule possesses its own directory and contains two files: point_charges.csv and lennard_jones_spheres.csv, comma-separated-value files describing the point charges and Lennard Jones spheres, respectively, comprising the molecule. Only rigid molecules are currently supported. Units of length are in Angstrom; units of charges are electrons.

using PorousMaterials

m = Molecule("CO2")

PorousMaterials will then output information about the molecule you just loaded:

Molecule species: CO2
Center of mass (fractional coords): [0.0, 0.0, 0.0]
Atoms:

        atom = C_CO2, xf = [0.000, 0.000, 0.000]
        atom = O_CO2, xf = [-1.160, 0.000, 0.000]
        atom = O_CO2, xf = [1.160, 0.000, 0.000]
Point charges:
        charge = 0.700000, xf = [0.000, 0.000, 0.000]
        charge = -0.350000, xf = [-1.160, 0.000, 0.000]
        charge = -0.350000, xf = [1.160, 0.000, 0.000]

Building Blocks of PorousMaterials: Molecules#

molecule = Molecule("CO2") # fractional coords in terms of unit cube box

# access Lennard-Jones spheres & point charges that comprise molecule
molecule.atoms
molecule.charges

# translate to [1.0, 2.0, 3.0] fractional coordinates
translate_to!(molecule, [1.0, 2.0, 3.0])

# translate by [0.1, 0.0, 0.0] fractional coordinates
translate_by!(molecule, [0.1, 0.0, 0.0])

# conduct a uniform random rotation
rotate!(molecule, UnitCube()) # b/c now fractional coords defined in context of a unit cube

Molecules#

# PorousMaterials.MoleculeType.

Data structure for a molecule/adsorbate.

Attributes

source

# PorousMaterials.n_atomsFunction.

num_atoms = n_atoms(molecules)

calculates the total number of atoms in an array of molecules

Arguments

Returns

source

# PorousMaterials.translate_to!Function.

translate_to!(molecule, xf)
translate_to!(molecule, x, box)

Translate a molecule a molecule to point xf in fractional coordinate space or to x in Cartesian coordinate space. For the latter, a unit cell box is required for context. The molecule is translated such that its center of mass is at xf/x`.

Arguments

source

# PorousMaterials.rotate!Function.

rotate!(molecule, box)

Conduct a random rotation of the molecule about its center of mass. The box is needed because the molecule contains only its fractional coordinates.

Arguments

source

# PorousMaterials.rotation_matrixMethod.

r = rotation_matrix()

Generate a 3x3 random rotation matrix r such that when a point x is rotated using this rotation matrix via r * x, this point x is placed at a uniform random distributed position on the surface of a sphere of radius norm(x). See James Arvo. Fast Random Rotation Matrices.

https://pdfs.semanticscholar.org/04f3/beeee1ce89b9adf17a6fabde1221a328dbad.pdf

Returns

source

# PorousMaterials.rotation_matrixMethod.

R = rotation_matrix(θ, u, assume_unit_vector=false) # 3 by 3 rotation matrix, angle θ about vector u
R = rotation_matrix(θ, dim) # 3 by 3 rotation matrix, angle θ about axis `dim`

Determine the 3D rotation matrix to rotate an angle θ (radians) about axis u.

See Wikipedia.

Arguments

internal to this function.

Returns

source

# PorousMaterials.rand_point_on_unit_sphereFunction.

u = rand_point_on_unit_sphere()

Generate a unit vector with a random orientation.

Returns

source

# PorousMaterials.chargedMethod.

charged_flag = charged(molecule, verbose=false)

Determine if a molecule has point charges

Arguments

Returns

source

Molecular Movement#

# PorousMaterials.insert_molecule!Function.

insert_molecule!(molecules, box, template)

Inserts an additional adsorbate molecule into the simulation box using the template provided. The center of mass of the molecule is chosen at a uniform random position in the simulation box. A uniformly random orientation of the molecule is chosen by rotating about the center of mass.

Arguments

source

# PorousMaterials.delete_molecule!Function.

delete_molecule!(molecule_id, molecules)

Removes a random molecule from the current molecules in the framework. molecule_id decides which molecule will be deleted, for a simulation, it must be a randomly generated value

Arguments

source

# PorousMaterials.translate_molecule!Function.

translate_molecule!(molecule, box)

Perturbs the Cartesian coordinates of a molecule about its center of mass by a random vector of max length δ. Applies periodic boundary conditions to keep the molecule inside the simulation box. Returns a deep copy of the old molecule in case it needs replaced if the Monte Carlo proposal is rejected.

Arguments

Returns

source

# PorousMaterials.reinsert_molecule!Function.

reinsert_molecule(molecule, box)

Move molecule to a new center of mass randomly distrubted in the unit cell and choose a random orientation for it. Return a deep copy of the starting molecule for possible restoration. This MC move can be viewed as a more aggressive translate_molecule!.

Arguments

source

# PorousMaterials.rotatableFunction.

need_to_rotate = rotatable(molecule)

Determines whether or not a given molecule needs to be rotated. For example, rotating a single atom isn't necessary.

Arguments

Returns

source