Skip to content

Commit

Permalink
Merge branch 'v0.5.1' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Amphiluke committed Aug 30, 2017
2 parents fcce25b + 5580f4c commit 535c6ae
Show file tree
Hide file tree
Showing 13 changed files with 487 additions and 760 deletions.
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scripts

.idea
.babelrc
.eslint*
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ You may instantiate the `Varshni3` class as follows:
let varshni = new potprox.Varshni3({d0: 0.0368, r0: 5.389, b: 0.0597});
```

### Potential class methods
### Potential class members

All the classes in the `potprox` object have a few common methods listed below.
All the classes in the `potprox` object have a few members listed below.

#### `type`

The *static* read-only property containing the name of the potential class (e.g. `"LennardJones"`, `"Morse"`, `"Buckingham"` etc.).

#### `from(data [, settings])`

Expand Down
92 changes: 80 additions & 12 deletions dist/potprox.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// potprox v0.5.1
// https://amphiluke.github.io/potprox/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.potprox = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
let instanceData = new WeakMap();

Expand All @@ -9,6 +11,17 @@ class Buckingham {
this.a = a;
}

/**
* The name of the potential class. To be used instead of
* `instance.constructor.name` (since in the minified version names are mangled)
* @type {String}
* @readonly
* @static
*/
static get type() {
return "Buckingham";
}

/**
* Create an instance of the Buckingham potential via approximation of input data.
* This method performs fast initial approximation and is not very accurate.
Expand Down Expand Up @@ -173,7 +186,7 @@ class Buckingham {
}

toJSON() {
return {type: "Buckingham", d0: this.d0, r0: this.r0, a: this.a};
return {type: Buckingham.type, d0: this.d0, r0: this.r0, a: this.a};
}
}

Expand All @@ -188,6 +201,17 @@ class LennardJones {
this.sigma = sigma;
}

/**
* The name of the potential class. To be used instead of
* `instance.constructor.name` (since in the minified version names are mangled)
* @type {String}
* @readonly
* @static
*/
static get type() {
return "LennardJones";
}

/**
* Create an instance of the Lennard-Jones potential via approximation of input data
* @param {Array.<{r: Number, e: Number}>} data - Coordinates for approximation
Expand Down Expand Up @@ -242,6 +266,13 @@ class LennardJones {
instanceData.get(this).sigma = value;
}

get r0() {
return 1.122462048309373 * this.sigma;
}
set r0(value) {
this.sigma = value / 1.122462048309373;
}

/**
* Calculate the energy for the given interatomic distance
* @param {Number} r
Expand All @@ -259,7 +290,7 @@ class LennardJones {
}

toJSON() {
return {type: "LennardJones", epsilon: this.epsilon, sigma: this.sigma};
return {type: LennardJones.type, epsilon: this.epsilon, sigma: this.sigma};
}
}

Expand All @@ -275,6 +306,17 @@ class Morse {
this.a = a;
}

/**
* The name of the potential class. To be used instead of
* `instance.constructor.name` (since in the minified version names are mangled)
* @type {String}
* @readonly
* @static
*/
static get type() {
return "Morse";
}

/**
* Create an instance of the Morse potential via approximation of input data.
* This method performs fast initial approximation and is not very accurate.
Expand Down Expand Up @@ -433,7 +475,7 @@ class Morse {
}

toJSON() {
return {type: "Morse", d0: this.d0, r0: this.r0, a: this.a};
return {type: Morse.type, d0: this.d0, r0: this.r0, a: this.a};
}
}

Expand All @@ -449,6 +491,17 @@ class Rydberg {
this.b = b;
}

/**
* The name of the potential class. To be used instead of
* `instance.constructor.name` (since in the minified version names are mangled)
* @type {String}
* @readonly
* @static
*/
static get type() {
return "Rydberg";
}

/**
* Create an instance of the Rydberg potential via approximation of input data.
* This method performs fast initial approximation and is not very accurate.
Expand Down Expand Up @@ -608,7 +661,7 @@ class Rydberg {
}

toJSON() {
return {type: "Rydberg", d0: this.d0, r0: this.r0, b: this.b};
return {type: Rydberg.type, d0: this.d0, r0: this.r0, b: this.b};
}
}

Expand All @@ -624,6 +677,17 @@ class Varshni3 {
this.b = b;
}

/**
* The name of the potential class. To be used instead of
* `instance.constructor.name` (since in the minified version names are mangled)
* @type {String}
* @readonly
* @static
*/
static get type() {
return "Varshni3";
}

/**
* Create an instance of the Varshni potential (III) via approximation of input data.
* This method performs fast initial approximation and is not very accurate.
Expand Down Expand Up @@ -782,19 +846,23 @@ class Varshni3 {
}

toJSON() {
return {type: "Varshni3", d0: this.d0, r0: this.r0, b: this.b};
return {type: Varshni3.type, d0: this.d0, r0: this.r0, b: this.b};
}
}

module.exports = Varshni3;
},{}],6:[function(require,module,exports){
let potprox = {
LennardJones: require("./potentials/lennard-jones.js"),
Buckingham: require("./potentials/buckingham.js"),
Morse: require("./potentials/morse.js"),
Rydberg: require("./potentials/rydberg.js"),
Varshni3: require("./potentials/varshni3.js")
};
let potentialClasses = [
require("./potentials/lennard-jones.js"),
require("./potentials/buckingham.js"),
require("./potentials/morse.js"),
require("./potentials/rydberg.js"),
require("./potentials/varshni3.js")
];

let potprox = Object.create(null);

potentialClasses.forEach(potentialClass => potprox[potentialClass.type] = potentialClass);

// Other properties of the potprox object are non-enumerable to avoid mixing them with
// potential classes when using such methods as Object.keys, Object.values etc.
Expand Down
4 changes: 3 additions & 1 deletion dist/potprox.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 535c6ae

Please sign in to comment.