10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-24 13:23:40 +01:00

Starting implement new TBE format

This commit is contained in:
Mickaël Véril 2019-12-11 20:04:10 +01:00
parent b537719315
commit 46eb7fe9ec

View File

@ -3,7 +3,7 @@ from enum import IntEnum,auto,unique,IntFlag
from .Format import Format from .Format import Format
import re import re
import numpy as np import numpy as np
import itertools
class state: class state:
def __init__(self,number, multiplicity, symetry): def __init__(self,number, multiplicity, symetry):
@ -85,9 +85,9 @@ class dataFileBase(object):
data.molecule=mymolecule data.molecule=mymolecule
data.method=mymethod data.method=mymethod
data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2])) data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2]))
for value in datacls.values(): for datamtbe in datacls.values():
datalist.append(value) datalist.append(datamtbe)
return datalist return list(itertools.chain.from_iterable(datalist))
elif format==Format.COLUMN: elif format==Format.COLUMN:
subtablesindex=list() subtablesindex=list()
firstindex=2 firstindex=2
@ -130,7 +130,7 @@ class dataFileBase(object):
for first, last in subtablesindex: for first, last in subtablesindex:
datacls=dict() datacls=dict()
mymolecule=str(table[first,0]) mymolecule=str(table[first,0])
mymethod=method("TBE",None) mymethod=(method("TBE",None),method("TBE-corr"))
finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState) finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState)
for index,row in enumerate(table[first:last+1,]): for index,row in enumerate(table[first:last+1,]):
def toFloat(x): def toFloat(x):
@ -145,14 +145,20 @@ class dataFileBase(object):
finst=finsts[index] finst=finsts[index]
dt=finst[1] dt=finst[1]
if dt in datacls: if dt in datacls:
data = datacls[dt] datamtbe = datacls[dt]
else: else:
cl=switcher[dt] cl=switcher[dt]
data=cl() datamtbe=[]
data.molecule=mymolecule for met in mymethod:
data.method=mymethod data=cl()
datacls[dt]=data datamtbe.append(cl())
data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2],T1=T1,corrected=corr,forces=oscilatorForces)) data.molecule=mymolecule
data.method=met
datamtbe.append(data)
datacls[dt]=datamtbe
vs=[val,corr]
for i in range(2):
datamtbe[i].excitations.append(excitationValue(firstState,finst[0],vs[i],type=finst[2],T1=T1,forces=oscilatorForces))
for value in datacls.values(): for value in datacls.values():
datalist.append(value) datalist.append(value)
return datalist return datalist
@ -178,11 +184,11 @@ class dataFileBase(object):
if value is not None: if value is not None:
f.write("# {:9s}: {}\n".format(key,value)) f.write("# {:9s}: {}\n".format(key,value))
f.write(""" f.write("""
# Initial state Final state Transition Energies (eV) %T1 Oscilator forces # Initial state Final state Transition Energies (eV) %T1 Oscilator forces
####################### ####################### ######################################## ################# ####### ################### ####################### ####################### ######################################## ############# ####### ###################
# Number Spin Symm Number Spin Symm type E_{:5s} Corr %T1 f \n""".format(self.GetFileType().name.lower())) # Number Spin Symm Number Spin Symm type E_{:5s} %T1 f \n""".format(self.GetFileType().name.lower()))
for ex in self.excitations: for ex in self.excitations:
mystr=" {:8s}{:7s}{:10s}{:8s}{:6s}{:13s}{:40s}{:8s}{:10s}{:15s}{}\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.type)+"}" if ex.type is not None else "_",str(ex.value) if ex.value is not None else "_",str(ex.corrected) if ex.corrected is not None else "_",str(ex.T1) if ex.T1 is not None else "_", str(ex.oscilatorForces) if ex.oscilatorForces is not None else "_") mystr=" {:8s}{:7s}{:10s}{:8s}{:6s}{:13s}{:40s}{:10s}{:15s}{}\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.type)+"}" if ex.type is not None else "_",str(ex.value) if ex.value is not None else "_",str(ex.T1) if ex.T1 is not None else "_", str(ex.oscilatorForces) if ex.oscilatorForces is not None else "_")
f.write(mystr) f.write(mystr)
class method: class method:
def __init__(self,name, *args): def __init__(self,name, *args):
@ -281,5 +287,4 @@ class excitationValue(excitationBase):
supkwarg.pop(item) supkwarg.pop(item)
super(excitationValue,self).__init__(initial, final,**supkwarg) super(excitationValue,self).__init__(initial, final,**supkwarg)
self.value = value self.value = value
self.corrected=kwarg["corrected"] if "corrected" in kwarg else None
self.oscilatorForces=kwarg["forces"] if "forces" in kwarg else None self.oscilatorForces=kwarg["forces"] if "forces" in kwarg else None