2019-08-28 11:59:18 +02:00
|
|
|
class code {
|
|
|
|
constructor(name,version){
|
2019-09-03 15:36:32 +02:00
|
|
|
this.name=name;
|
|
|
|
this.version=version;
|
|
|
|
};
|
|
|
|
toString() {
|
|
|
|
var str=this.name;
|
|
|
|
if (this.version) {
|
|
|
|
str=str+' ('+this.version+')';
|
|
|
|
}
|
|
|
|
return str;
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
static fromString(str) {
|
|
|
|
var vals=str.split(",")
|
|
|
|
if(vals.length>=2){
|
|
|
|
return new code(vals[0],vals[1]);
|
|
|
|
} else {
|
|
|
|
return new code(vals[0],null);
|
|
|
|
}
|
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
2019-09-17 17:19:00 +02:00
|
|
|
class method {
|
|
|
|
constructor(name,basis){
|
2019-09-03 15:36:32 +02:00
|
|
|
this.name=name;
|
2019-09-17 17:19:00 +02:00
|
|
|
this.basis=basis;
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
static fromString(str) {
|
|
|
|
var vals=str.split(",")
|
|
|
|
return new method(vals[0],vals[1]);
|
|
|
|
}
|
2019-09-03 15:36:32 +02:00
|
|
|
toString() {
|
|
|
|
var str=this.name;
|
2019-09-17 17:19:00 +02:00
|
|
|
if (this.name) {
|
|
|
|
str=str+'/'+this.basis;
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
|
|
|
return str;
|
2019-08-22 10:34:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-28 11:59:18 +02:00
|
|
|
class state{
|
2019-09-19 15:05:07 +02:00
|
|
|
constructor(number,multiplicity,symetry){
|
2019-08-28 11:59:18 +02:00
|
|
|
this.number=number;
|
|
|
|
this.multiplicity=multiplicity;
|
|
|
|
this.symetry=symetry;
|
2019-09-03 15:36:32 +02:00
|
|
|
};
|
|
|
|
toString() {
|
|
|
|
var str=this.number+ ' ^'+this.multiplicity+this.symetry;
|
|
|
|
return str;
|
|
|
|
};
|
|
|
|
toLaTeX() {
|
2019-09-03 15:38:17 +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-08-28 11:59:18 +02:00
|
|
|
class doi{
|
|
|
|
constructor(doistring){
|
|
|
|
this.string=doistring
|
2019-09-03 15:36:32 +02:00
|
|
|
};
|
|
|
|
toString() {
|
|
|
|
return this.string;
|
|
|
|
};
|
2019-08-28 11:59:18 +02:00
|
|
|
get url() {
|
2019-09-03 15:36:32 +02:00
|
|
|
return 'https://doi.org/'+this.string;
|
|
|
|
};
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
|
|
|
class excitation{
|
2019-09-19 15:05:07 +02:00
|
|
|
constructor(start,end,Eabs,Efluo,EZPE){
|
2019-08-28 11:59:18 +02:00
|
|
|
this.start=start;
|
|
|
|
this.end=end;
|
2019-09-02 09:34:43 +02:00
|
|
|
this.Eabs=Eabs;
|
2019-09-19 15:05:07 +02:00
|
|
|
this.Efluo=Efluo;
|
|
|
|
this.EZPE=EZPE;
|
|
|
|
}
|
2019-09-19 18:54:23 +02:00
|
|
|
get Eadia() {
|
|
|
|
return (this.Eabs+this.Efluo)/2
|
|
|
|
}
|
2019-09-19 15:05:07 +02:00
|
|
|
get Ezz() {
|
2019-09-19 18:54:23 +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-09 10:32:51 +02:00
|
|
|
return this.start+ ', ' + this.end +', '+ this.Eabs.toPrecision(3);
|
2019-09-03 15:36:32 +02:00
|
|
|
}
|
2019-08-28 11:59:18 +02:00
|
|
|
}
|
|
|
|
|
2019-09-19 15:05:07 +02:00
|
|
|
class CalcParams {
|
2019-08-28 11:59:18 +02:00
|
|
|
constructor(){
|
|
|
|
this.code=null;
|
2019-09-16 09:47:57 +02:00
|
|
|
this.method=null;
|
2019-09-19 15:05:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
class StateCalcParams extends CalcParams {
|
|
|
|
constructor(){
|
|
|
|
super()
|
|
|
|
this.geometry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class data {
|
|
|
|
constructor(){
|
|
|
|
this.molecule='';
|
|
|
|
this.comment;
|
|
|
|
this.GS=new StateCalcParams();
|
|
|
|
this.ES=new StateCalcParams();
|
|
|
|
this.ZPE=new CalcParams();
|
2019-08-28 11:59:18 +02:00
|
|
|
this.doi=null;
|
|
|
|
this.excitations=[];
|
|
|
|
}
|
2019-09-05 11:31:38 +02:00
|
|
|
static async loadAsync(file) {
|
2019-09-09 15:15:39 +02:00
|
|
|
return data.loadString(await getTextFromFileAsync(getFullDataPath(file)));
|
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
|
|
|
|
var ismetaArea=true;
|
|
|
|
//metadata RegExp (start with #; maybe somme spaces; : ; maybe somme space; datas)
|
2019-09-19 15:05:07 +02:00
|
|
|
var meta=/^#\s*([A-Za-z_]+)\s*:\s*(.*)$/;
|
2019-08-28 11:59:18 +02:00
|
|
|
var dat=new data();
|
|
|
|
function readmeta(line){
|
|
|
|
// get key value
|
|
|
|
var match=line.match(meta);
|
|
|
|
// normalize key to lower
|
|
|
|
var key=match[1].toLowerCase();
|
|
|
|
//if data has value
|
|
|
|
if(match.length==3 && match[2]) {
|
|
|
|
var val=match[2];
|
|
|
|
switch(key) {
|
2019-09-19 15:05:07 +02:00
|
|
|
case "molecule":
|
|
|
|
dat.molecule=val
|
2019-08-28 11:59:18 +02:00
|
|
|
break;
|
2019-09-19 15:05:07 +02:00
|
|
|
case "comment":
|
|
|
|
dat.comment=val
|
2019-08-28 11:59:18 +02:00
|
|
|
break;
|
2019-09-19 15:05:07 +02:00
|
|
|
case "gs_code":
|
|
|
|
dat.GS.code=code.fromString(val)
|
2019-09-17 17:19:00 +02:00
|
|
|
break;
|
2019-09-19 15:05:07 +02:00
|
|
|
case "gs_method":
|
|
|
|
dat.GS.method=method.fromString(val)
|
|
|
|
break;
|
|
|
|
case "gs_geom":
|
|
|
|
dat.GS.geometry=method.fromString(val)
|
|
|
|
break;
|
|
|
|
case "es_code":
|
|
|
|
dat.ES.code=code.fromString(val)
|
|
|
|
break
|
|
|
|
case "es_method":
|
|
|
|
dat.ES.method=method.fromString(val)
|
|
|
|
break;
|
|
|
|
case "es_geom":
|
|
|
|
dat.ES.geometry=method.fromString(val)
|
|
|
|
break;
|
|
|
|
case "zpe_code":
|
|
|
|
dat.ZPE.code=code.fromString(val)
|
|
|
|
break
|
|
|
|
case "zpe_method":
|
|
|
|
dat.ZPE.method=method.fromString(val)
|
2019-09-17 17:19:00 +02:00
|
|
|
break;
|
2019-08-28 11:59:18 +02:00
|
|
|
case "doi":
|
|
|
|
dat.doi=new doi(val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function readrow(line){
|
2019-09-19 15:05:07 +02:00
|
|
|
var vals=line.split(/\s+/);
|
|
|
|
while (vals.length<8){
|
|
|
|
vals.push(null);
|
|
|
|
}
|
|
|
|
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 excitation(start,end,parseFloat(vals[6],10),parseFloat(vals[7],10),parseFloat(vals[8],10));
|
2019-08-28 11:59:18 +02:00
|
|
|
dat.excitations.push(ex);
|
|
|
|
};
|
|
|
|
|
|
|
|
text.split("\n").forEach(function(line) {
|
|
|
|
//if it's not empty line
|
|
|
|
line=line.trim();
|
|
|
|
if (line){
|
|
|
|
//if # may be metadata or comment
|
|
|
|
if (line.charAt(0)=="#") {
|
|
|
|
//if it's metadata
|
|
|
|
if(ismetaArea && meta.test(line)) {
|
|
|
|
readmeta(line);
|
|
|
|
}
|
|
|
|
} else { //else its row
|
|
|
|
ismetaArea=false;
|
|
|
|
readrow(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return dat
|
|
|
|
}
|
2019-08-22 10:34:07 +02:00
|
|
|
}
|