npm.io
1.2.24 • Published 21h ago

mf-from-atomic-ratio

Licence
MIT
Version
1.2.24
Deps
2
Size
112 kB
Vulns
0
Weekly
0
Stars
9

mf-from-atomic-ratio

NPM version npm download

Find a molecular formula from atomic ratio based on a molecular formula range.

Installation

$ npm install --save mf-from-atomic-ratio

Usage

const { mfFromAtomicRatio } = require('mf-from-atomic-ratio');

const mfs = await mfFromAtomicRatio(
  { C: 3, O: 2 },
  {
    ranges: 'C0-10 H0-10 O0-10 N0-10',
    maxElementError: 0.01,
    maxTotalError: 0.02,
  },
);

console.log(mfs[0]);
/*
{
  em: 13.00782503223,
  mw: 13.018676650791026,
  mf: 'CH',
  mfAtomicComposition: [
    { element: 'C', count: 1, theoretical: 0.5 },
    { element: 'H', count: 1, theoretical: 0.5 }
  ],
  atomicRatios: [
    {
      element: 'C',
      experimental: 0.5,
      count: 1,
      theoretical: 0.5,
      error: 0
    },
    {
      element: 'H',
      experimental: 0.5,
      count: 1,
      theoretical: 0.5,
      error: 0
    }
  ],
  totalError: 0
}
*/

License

MIT