npm.io
2.1.24 • Published yesterday

mf-from-ea

Licence
MIT
Version
2.1.24
Deps
4
Size
128 kB
Vulns
0
Weekly
0
Stars
9

mf-from-ea

NPM version npm download

Find a molecular formula from the result of an elemental analysis based on a molecular formula range.

Installation

$ npm install --save mf-from-ea

Usage

const { mfFromEA } = require('mf-from-ea');

let result = mfFromEA(
  { C: 0.8, H: 0.2 }, // elemental analysis result: 80% C, 20% H
  {
    ranges: 'C0-10 H0-20', // range of molecular formula to explore
    maxElementError: 0.003, // 0.3% Allowed error for each element
    maxTotalError: 0.01, // 1% total error (absolute sum of element errors)
  },
);

console.log(result);
/*
{
  mfs: [
    { mf: 'CH3', totalError: 0.002249567989705492, ea: [Array] },
    { mf: 'C2H6', totalError: 0.002249567989705492, ea: [Array] },
    { mf: 'C3H9', totalError: 0.002249567989705409, ea: [Array] },
    { mf: 'C4H12', totalError: 0.002249567989705492, ea: [Array] },
    { mf: 'C5H15', totalError: 0.002249567989705492, ea: [Array] },
    { mf: 'C6H18', totalError: 0.002249567989705409, ea: [Array] }
  ],
  info: { numberMFEvaluated: 231, numberResults: 6 }
}
*/

License

MIT