2019-08-28 11:59:18 +02:00
|
|
|
class code {
|
2019-09-26 20:25:51 +02:00
|
|
|
constructor(name, version) {
|
|
|
|
this.name = name;
|
|
|
|
this.version = version;
|
2019-09-03 15:36:32 +02:00
|
|
|
};
|
2019-09-26 20:25:51 +02:00
|
|
|
toString() {
|
|
|
|
var str = this.name;
|
2019-09-03 15:36:32 +02:00
|
|
|
if (this.version) {
|
2019-09-26 20:25:51 +02:00
|
|
|
str = str + ' (' + this.version + ')';
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
|
|
|
return str;
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
static fromString(str) {
|
2019-09-26 20:25:51 +02:00
|
|
|
var vals = str.split(",")
|
|
|
|
if (vals.length >= 2) {
|
|
|
|
return new code(vals[0], vals[1]);
|
2019-09-19 15:05:07 +02:00
|
|
|
} else {
|
2019-09-26 20:25:51 +02:00
|
|
|
return new code(vals[0], null);
|
2019-09-19 15:05:07 +02:00
|
|
|
}
|
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-17 17:19:00 +02:00
|
|
|
class method {
|
2019-09-26 20:25:51 +02:00
|
|
|
constructor(name, basis) {
|
|
|
|
this.name = name;
|
|
|
|
this.basis = basis;
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
static fromString(str) {
|
2019-09-26 20:25:51 +02:00
|
|
|
var vals = str.split(",")
|
|
|
|
if (vals.length == 2) {
|
|
|
|
return new method(vals[0], vals[1]);
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
else {
|
|
|
|
return new method(vals[0], null)
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
toString() {
|
|
|
|
var str = this.name;
|
2019-09-28 14:38:14 +02:00
|
|
|
if (this.basis) {
|
2019-09-26 20:25:51 +02:00
|
|
|
str = str + '/' + this.basis;
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
|
|
|
return str;
|
2019-08-22 10:34:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-26 20:25:51 +02:00
|
|
|
class state {
|
|
|
|
constructor(number, multiplicity, symetry) {
|
|
|
|
this.number = number;
|
|
|
|
this.multiplicity = multiplicity;
|
|
|
|
this.symetry = symetry;
|
2019-09-03 15:36:32 +02:00
|
|
|
};
|
2019-09-26 20:25:51 +02:00
|
|
|
toString() {
|
|
|
|
var str = this.number + ' ^' + this.multiplicity + this.symetry;
|
2019-09-03 15:36:32 +02:00
|
|
|
return str;
|
|
|
|
};
|
|
|
|
toLaTeX() {
|
2019-09-26 20:25:51 +02:00
|
|
|
var tex = String.raw`${this.number}\:\vphantom{\mathrm{${this.symetry.charAt(0)}}}^{${this.multiplicity}}\mathrm{${this.symetry}}`;
|
2019-09-03 15:36:32 +02:00
|
|
|
return tex;
|
|
|
|
};
|
2019-08-22 10:34:07 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
class doi {
|
|
|
|
constructor(doistring) {
|
|
|
|
this.string = doistring
|
2019-09-03 15:36:32 +02:00
|
|
|
};
|
2019-09-26 20:25:51 +02:00
|
|
|
toString() {
|
2019-09-03 15:36:32 +02:00
|
|
|
return this.string;
|
|
|
|
};
|
2019-08-28 11:59:18 +02:00
|
|
|
get url() {
|
2019-09-26 20:25:51 +02:00
|
|
|
return 'https://doi.org/' + this.string;
|
2019-09-03 15:36:32 +02:00
|
|
|
};
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-26 09:32:03 +02:00
|
|
|
|
2019-09-26 20:25:51 +02:00
|
|
|
class excitationBase {
|
|
|
|
constructor(initial, final) {
|
|
|
|
this.initial = initial;
|
|
|
|
this.final = final
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
class excitationValue extends excitationBase {
|
|
|
|
constructor(initial, final, value) {
|
|
|
|
super(initial, final)
|
|
|
|
this.value = value
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-26 20:25:51 +02:00
|
|
|
class excitation extends excitationBase {
|
|
|
|
constructor(initial, final, Eabs, Efluo, EZPE) {
|
|
|
|
super(initial, final)
|
|
|
|
this.Eabs = Eabs
|
|
|
|
this.Efluo = Efluo
|
|
|
|
this.EZPE = EZPE
|
2019-09-19 15:05:07 +02:00
|
|
|
}
|
2019-09-19 18:54:23 +02:00
|
|
|
get Eadia() {
|
2019-09-26 20:25:51 +02:00
|
|
|
return (this.Eabs + this.Efluo) / 2
|
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
get Ezz() {
|
2019-09-26 20:25:51 +02:00
|
|
|
return this.Eadia - this.EZPE
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-03 15:36:32 +02:00
|
|
|
toString() {
|
2019-09-26 20:25:51 +02:00
|
|
|
return this.start + ', ' + this.end + ', ' + noNanPrecision(this.Eabs, 3);
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
|
|
|
|
2019-09-26 09:32:03 +02:00
|
|
|
class dataFileBase {
|
2019-09-26 20:25:51 +02:00
|
|
|
constructor() {
|
|
|
|
this.molecule = ''
|
|
|
|
this.comment = null
|
|
|
|
this.code = null
|
|
|
|
this.method = null
|
|
|
|
this.excitations = []
|
|
|
|
this.DOI = null
|
2019-09-30 10:53:13 +02:00
|
|
|
this.sourceFile=null
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-05 11:31:38 +02:00
|
|
|
static async loadAsync(file) {
|
2019-09-30 10:53:13 +02:00
|
|
|
var dat = this.loadString(await getTextFromFileAsync(getFullDataPath(file)));
|
|
|
|
dat.sourceFile=new websiteFile(file)
|
|
|
|
return dat
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
static readmetaPair(key, value, dat) {
|
|
|
|
switch (key) {
|
2019-09-26 09:32:03 +02:00
|
|
|
case "molecule":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.molecule = value
|
2019-09-26 09:32:03 +02:00
|
|
|
break;
|
|
|
|
case "comment":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.comment = value
|
2019-09-26 09:32:03 +02:00
|
|
|
break;
|
|
|
|
case "code":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.code = code.fromString(value)
|
2019-09-26 09:32:03 +02:00
|
|
|
break;
|
|
|
|
case "method":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.method = method.fromString(value)
|
|
|
|
break;
|
2019-09-26 09:32:03 +02:00
|
|
|
case "doi":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.DOI = new doi(value);
|
2019-09-26 09:32:03 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-05 10:32:46 +02:00
|
|
|
static loadString(text) {
|
2019-08-28 11:59:18 +02:00
|
|
|
// for each line with metadata
|
2019-09-26 20:25:51 +02:00
|
|
|
var ismetaArea = true;
|
2019-08-28 11:59:18 +02:00
|
|
|
//metadata RegExp (start with #; maybe somme spaces; : ; maybe somme space; datas)
|
2019-09-26 20:25:51 +02:00
|
|
|
var meta = /^#\s*([A-Za-z_]+)\s*:\s*(.*)$/;
|
|
|
|
var classname = this.name
|
|
|
|
var dat = eval(String.raw`new ${this.name}()`)
|
|
|
|
function readmeta(line) {
|
2019-08-28 11:59:18 +02:00
|
|
|
// get key value
|
2019-09-26 20:25:51 +02:00
|
|
|
var match = line.match(meta)
|
2019-08-28 11:59:18 +02:00
|
|
|
// normalize key to lower
|
2019-09-26 20:25:51 +02:00
|
|
|
var key = match[1].toLowerCase()
|
2019-08-28 11:59:18 +02:00
|
|
|
//if data has value
|
2019-09-26 20:25:51 +02:00
|
|
|
if (match.length == 3 && match[2]) {
|
|
|
|
var val = match[2]
|
2019-09-26 09:32:03 +02:00
|
|
|
eval(String.raw`${classname}.readmetaPair(key,val,dat)`)
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
function readrow(line) {
|
|
|
|
var vals = line.split(/\s+/);
|
|
|
|
while (vals.length < 8) {
|
2019-09-19 15:05:07 +02:00
|
|
|
vals.push(null);
|
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
|
|
|
|
var start = new state(parseInt(vals[0], 10), parseInt(vals[1], 10), vals[2]);
|
|
|
|
var end = new state(parseInt(vals[3], 10), vals[4], vals[5]);
|
|
|
|
var ex = new excitationValue(start, end, parseFloat(vals[6], 10));
|
2019-08-28 11:59:18 +02:00
|
|
|
dat.excitations.push(ex);
|
|
|
|
};
|
|
|
|
|
2019-09-26 20:25:51 +02:00
|
|
|
for (var line of text.split("\n")) {
|
2019-08-28 11:59:18 +02:00
|
|
|
//if it's not empty line
|
2019-09-26 20:25:51 +02:00
|
|
|
line = line.trim();
|
|
|
|
if (line) {
|
2019-08-28 11:59:18 +02:00
|
|
|
//if # may be metadata or comment
|
2019-09-26 20:25:51 +02:00
|
|
|
if (line.charAt(0) == "#") {
|
2019-08-28 11:59:18 +02:00
|
|
|
//if it's metadata
|
2019-09-26 20:25:51 +02:00
|
|
|
if (ismetaArea && meta.test(line)) {
|
2019-08-28 11:59:18 +02:00
|
|
|
readmeta(line);
|
2019-09-26 20:25:51 +02:00
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
} else { //else its row
|
2019-09-26 20:25:51 +02:00
|
|
|
ismetaArea = false;
|
2019-08-28 11:59:18 +02:00
|
|
|
readrow(line);
|
|
|
|
}
|
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
return dat
|
|
|
|
}
|
2019-08-22 10:34:07 +02:00
|
|
|
}
|
2019-09-26 09:32:03 +02:00
|
|
|
|
|
|
|
class oneStateDataFile extends dataFileBase {
|
2019-09-26 20:25:51 +02:00
|
|
|
constructor() {
|
2019-09-26 09:32:03 +02:00
|
|
|
super()
|
2019-09-26 20:25:51 +02:00
|
|
|
this.geometry = null
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
static readmetaPair(key, value, dat) {
|
|
|
|
if (key == "geom") {
|
|
|
|
dat.geometry = method.fromString(value)
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
else {
|
|
|
|
dataFileBase.readmetaPair(key, value, dat)
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class AbsDataFile extends oneStateDataFile {
|
|
|
|
|
|
|
|
}
|
|
|
|
class FluoDataFile extends oneStateDataFile {
|
|
|
|
|
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
class twoStateDataFileBase extends dataFileBase {
|
|
|
|
constructor() {
|
2019-09-26 09:32:03 +02:00
|
|
|
super()
|
2019-09-26 20:25:51 +02:00
|
|
|
this.GS = null
|
|
|
|
this.ES = null
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
static readmetaPair(key, value, dat) {
|
|
|
|
switch (key) {
|
2019-09-26 09:32:03 +02:00
|
|
|
case "gs":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.GS = method.fromString(value)
|
2019-09-26 09:32:03 +02:00
|
|
|
break;
|
|
|
|
case "es":
|
2019-09-26 20:25:51 +02:00
|
|
|
dat.ES = method.fromString(value)
|
2019-09-26 09:32:03 +02:00
|
|
|
break;
|
2019-09-26 20:25:51 +02:00
|
|
|
default:
|
|
|
|
dataFileBase.readmetaPair(key, value, dat)
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class ZPEDataFile extends twoStateDataFileBase {
|
2019-09-26 20:25:51 +02:00
|
|
|
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
class CombinedData {
|
|
|
|
constructor() {
|
|
|
|
this.Abs = null
|
|
|
|
this.Fluo = null
|
|
|
|
this.ZPE = null
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
|
|
|
get excitations() {
|
2019-09-26 20:25:51 +02:00
|
|
|
var exs = []
|
|
|
|
var dic = new Map()
|
|
|
|
if (this.Abs != null) {
|
|
|
|
for (const el of this.Abs.excitations) {
|
|
|
|
var key = JSON.stringify([el.initial, el.final])
|
|
|
|
if (!dic.has(key)) {
|
|
|
|
dic.set(key, {})
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
dic.get(key)["abs"] = el.value
|
|
|
|
}
|
|
|
|
if (this.Fluo != null) {
|
|
|
|
for (const el of this.Fluo.excitations) {
|
|
|
|
var key = JSON.stringify([el.initial, el.final])
|
|
|
|
if (!dic.has(key)) {
|
|
|
|
dic.set(key, {})
|
|
|
|
}
|
|
|
|
dic.get(key)["fluo"] = el.value
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
}
|
|
|
|
if (this.ZPE != null) {
|
|
|
|
for (const el of this.ZPE.excitations) {
|
|
|
|
var key = JSON.stringify([el.initial, el.final])
|
|
|
|
if (!dic.has(key)) {
|
|
|
|
dic.set(key, {})
|
|
|
|
}
|
|
|
|
dic.get(key)["ZPE"] = el.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dic.forEach((value, key) => {
|
|
|
|
var eabs = NaN
|
|
|
|
var efluo = NaN
|
|
|
|
var eZPE = NaN
|
|
|
|
var mykey = JSON.parse(key)
|
|
|
|
for (var el of mykey) {
|
|
|
|
Reflect.setPrototypeOf(el, state.prototype)
|
|
|
|
}
|
|
|
|
if ("abs" in value) {
|
|
|
|
eabs = value["abs"]
|
|
|
|
}
|
|
|
|
if ("fluo" in value) {
|
|
|
|
efluo = value["fluo"]
|
|
|
|
}
|
|
|
|
if ("ZPE" in value) {
|
|
|
|
eZPE = value["ZPE"]
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
exs.push(new excitation(mykey[0], mykey[1], eabs, efluo, eZPE))
|
2019-09-26 09:32:03 +02:00
|
|
|
})
|
2019-09-26 20:25:51 +02:00
|
|
|
return exs
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|
2019-09-26 20:25:51 +02:00
|
|
|
}
|
2019-09-26 09:32:03 +02:00
|
|
|
}
|