From 0c74be22f42aa1fecbb896ea1c6c6b687a0f18b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Sun, 24 Nov 2019 19:40:57 +0100 Subject: [PATCH] Add TBE corection --- static/js/data.js | 43 ++++++++++++++++++------------------------- tools/lib/data.py | 18 +++++++++++++----- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/static/js/data.js b/static/js/data.js index e198ab3a..8471d309 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -20,32 +20,23 @@ class code { } } class method { - constructor(name, basis=null,TBEcorr=null) { + constructor(name, basis=null) { this.name = name; this.basis = basis; - this.TBEcorr=TBEcorr } static fromString(str) { var vals = str.split(",") - switch (vals.lenght) { - case 3: - return new method(vals[0], vals[1],vals[2]); - break; - case 2: - return new method(vals[0], vals[1]) - break; - case 1: - return new method(vals[0]) - break; + if (vals.length == 2) { + return new method(vals[0], vals[1]); + } + else { + return new method(vals[0], null) } } toString() { var str = this.name; if (this.basis) { str = str + '/' + this.basis; - if (this.TBEcorr) { - str+=" ("+this.TBEcorr +")" - } } return str; } @@ -85,17 +76,10 @@ class excitationBase { } } class excitationValue extends excitationBase { - constructor(initial, final, value) { + constructor(initial, final, value,Correction) { super(initial, final) this.value = value - } -} - -class excitationValueCorrected extends excitationBase { - constructor(initial, final, value) { - super(initial, final) - this.value = value - this.Correction=value + this.correction = correction } } @@ -123,10 +107,14 @@ class dataFileBase { this.comment = null this.code = null this.method = null + this.TBEmethod=null this.excitations = [] this.DOI = null this.sourceFile=null } + get isTBE(){ + return this.TBEmethod!==null; + } static async loadAsync(file) { switch (trueTypeOf(file)) { case String.name: @@ -158,6 +146,9 @@ class dataFileBase { case "doi": dat.DOI = new DOI(value); break; + case "tbemethod": + dat.TBEmethod=new method.fromString(value) + break; default: } } @@ -187,7 +178,9 @@ class dataFileBase { var start = new state(parseInt(vals[0], 10), parseInt(vals[1], 10), vals[2]); var end = new state(parseInt(vals[3], 10), parseInt(vals[4],10), vals[5]); - var ex = new excitationValue(start, end, parseFloat(vals[6], 10)); + val=((vals.length>=5) ? parseFloat(vals[6], 10): NaN) + cor=((vals.length>=6) ? parseFloat(vals[7], 10): NaN) + var ex = new excitationValue(start, end, val,cor); dat.excitations.push(ex); }; diff --git a/tools/lib/data.py b/tools/lib/data.py index d98b4058..ddb7abcd 100644 --- a/tools/lib/data.py +++ b/tools/lib/data.py @@ -22,9 +22,14 @@ class dataFileBase(object): self.comment = '' self.code = None self.method = None + self.TBECorrMethod=None self.excitations = [] self.DOI = '' + @property + def IsTBE(): + return self.TBECorrMethod is not None + @staticmethod def GetFileType(): pass @@ -124,6 +129,8 @@ class dataFileBase(object): dic["Comment"]=self.comment dic["code"]="" if self.code is None else self.code.toDataString() dic["method"]="" if self.method is None else self.method.toDataString() + if self.TBECorrMethod is not None: + dic["TBECorrMethod"]=self.TBECorrMethod.toDataString() dic["DOI"]="" if self.DOI is None else self.DOI return dic @@ -140,15 +147,14 @@ class dataFileBase(object): f.write(""" # Initial state Final state Energies (eV) ####################### ####################### ############### -# Number Spin Symm Number Spin Symm E_{}\n""".format(self.GetFileType().name.lower())) +# Number Spin Symm Number Spin Symm E_{} Correction\n""".format(self.GetFileType().name.lower())) for ex in self.excitations: - mystr=" {:8s}{:7s}{:10s}{:8s}{:6s}{:13s}{}\n".format(str(ex.initial.number),str(ex.initial.multiplicity),ex.initial.symetry,str(ex.final.number),str(ex.final.multiplicity),ex.final.symetry,str(ex.value)) + mystr=" {:8s}{:7s}{:10s}{:8s}{:6s}{:13s}{5s}{}\n".format(str(ex.initial.number),str(ex.initial.multiplicity),ex.initial.symetry,str(ex.final.number),str(ex.final.multiplicity),ex.final.symetry,str(ex.value) if ex.value is not None else "_",str(ex.Correction) if ex.Correction is not None else "_") f.write(mystr) class method: def __init__(self,name, *args): self.name = name self.basis=args[0] if len(args)>0 else None - self.TBECorr=args if len(args)>1 else None @staticmethod def fromString(string): @@ -237,6 +243,8 @@ class excitationBase: self.final = final class excitationValue(excitationBase): - def __init__(self,initial, final, value): + def __init__(self,initial, final, value,*args): super(excitationValue,self).__init__(initial, final) - self.value = value \ No newline at end of file + self.value = value + if len(args)>0: + self.Correction=args[0] \ No newline at end of file