10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-04 21:24:00 +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]
datamtbe=[]
for met in mymethod:
data=cl() data=cl()
datamtbe.append(cl())
data.molecule=mymolecule data.molecule=mymolecule
data.method=mymethod data.method=met
datacls[dt]=data datamtbe.append(data)
data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2],T1=T1,corrected=corr,forces=oscilatorForces)) 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
@ -179,10 +185,10 @@ class dataFileBase(object):
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