10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-08-26 06:01:49 +02:00

Add TBE corection

This commit is contained in:
Mickaël Véril 2019-11-24 19:40:57 +01:00
parent 934e136e56
commit 0c74be22f4
2 changed files with 31 additions and 30 deletions

View File

@ -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);
};

View File

@ -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
self.value = value
if len(args)>0:
self.Correction=args[0]