russellsteadman / mcul

MCUL simplifies the logic behind organizing atoms into molecules

Home Page:https://mcul.js.org/

Repository from Github https://github.comrussellsteadman/mculRepository from Github https://github.comrussellsteadman/mcul

MCUL

MCUL simplifies the logic behind organizing atoms into molecules.

npm downloads package size Patreon donate button

Installation

MCUL can be used in Node.js or with webpack, browserify, etc. Add using NPM or Yarn.

npm i mcul
yarn add mcul

MCUL can also be used over CDN. In this case, mcul loads as window.mcul.

<script src="https://cdn.jsdelivr.net/npm/mcul@0.1.0-alpha3/dist/mcul.js"></script>

Example

Try it out for yourself in the browser.

import { Molecule, Atom } from 'mcul';

let ethanol = new Molecule();

let hydrogen = ethanol.createAtoms('H', 6);
let carbon = [new Atom('C').in(ethanol), ethanol.contains(new Atom('C'))];
let oxygen = ethanol.createAtom('O');

ethanol
    .bond(carbon[0], carbon[1])
    .bond(carbon[0], hydrogen[0])
    .bond(carbon[0], hydrogen[1])
    .bond(carbon[0], hydrogen[2])
    .bond(carbon[1], hydrogen[3])
    .bond(carbon[1], hydrogen[4])
    .bond(carbon[1], oxygen)
    .bond(oxygen, hydrogen[5]);

Documentation

Basic Usage

Molecule

The Molecule class serves as a storage for atoms and as a way to interact with the molecule as a whole.

Molecule.createAtom(symbol)

Accepts a string element symbol (e.g. 'H'), and returns an Atom instance. Atoms created through this method are already associated with the molecule.

Molecule.createAtoms(symbol, count)

Accepts a string element symbol (e.g. 'H') as well as a numeric count (e.g. 4), and returns an array of Atom instances.

Molecule.bond(atomOne, atomTwo, options)

Accepts two atoms and bond options to create a bond.

All Documentation

Visit mcul.js.org for the complete documentation.

Data Sources

Data Source
Average Atomic Masses PubChem

License

Patreon donate button

Copyright © 2020 Russell Steadman. Licensed under an MIT License (see the LICENSE file for terms).

About

MCUL simplifies the logic behind organizing atoms into molecules

https://mcul.js.org/

License:MIT License


Languages

Language:JavaScript 100.0%