@@ -391,7 +391,7 @@ def parse_excitation(self):
391391 while self [stop ].strip (): stop += 1
392392 df = self .pandas_dataframe (start , stop , ncol = 6 )
393393 df .columns = ['excitation' , 'energy' , 'energy_ev' , 'osc' , 'tau' , 'symmetry' ]
394- nan = np .where (list ( map ( lambda x : any ( x ), df .isna ().values )) )[0 ]
394+ nan = np .where (df .isna ().values )[0 ]
395395 df .loc [nan , 'symmetry' ] = df .loc [nan , 'tau' ].copy ()
396396 df .loc [nan , 'tau' ] = 0.0
397397 df ['tau' ] = df ['tau' ].astype (float )
@@ -536,7 +536,7 @@ def parse_frequency(self):
536536 else :
537537 start = stop + 4
538538 stop = start + natoms
539- freqs = list (map (lambda x : float ( x ) , self [start - 2 ].split ()))
539+ freqs = list (map (float , self [start - 2 ].split ()))
540540 ncol = len (freqs )
541541 df = self .pandas_dataframe (start , stop , ncol = 1 + 3 * ncol )
542542 tmp = list (map (lambda x : x .split ('.' ), df [0 ]))
@@ -660,26 +660,9 @@ def parse_gradient(self):
660660 self .gradient = grad
661661
662662 def parse_excitation (self ):
663- _reexc = "no. E/a.u. E/eV f"
664- found = self .find (_reexc , keys_only = True )
665- if not found :
666- return
667- # there should only be one in the entire output
668- start = found [0 ] + 2
669- stop = start
670- while self [stop ].strip (): stop += 1
671- df = self .pandas_dataframe (start , stop , ncol = 6 )
672- df .columns = ['excitation' , 'energy' , 'energy_ev' , 'osc' , 'tau' , 'symmetry' ]
673- nan = np .where (list (map (lambda x : any (x ), df .isna ().values )))[0 ]
674- df .loc [nan , 'symmetry' ] = df .loc [nan , 'tau' ].copy ()
675- df .loc [nan , 'tau' ] = 0.0
676- df ['tau' ] = df ['tau' ].astype (float )
677- df ['excitation' ] = [int (x [:- 1 ]) for x in df ['excitation' ].values ]
678- df .index = df ['excitation' ] - 1
679- df .drop ('excitation' , axis = 1 , inplace = True )
680- df ['frame' ] = 0
681- df ['group' ] = 0
682- self .excitation = df
663+ # the output has not changed from the last few iterations
664+ # of ADF
665+ ADF .parse_excitation (self )
683666
684667 def parse_electric_dipole (self ):
685668 _reexc = "Excitation energies E in a.u. and eV, dE wrt prev. cycle"
@@ -707,21 +690,20 @@ def parse_electric_dipole(self):
707690 tdm = self .pandas_dataframe (start , stop , ncol = 10 )
708691 tdm .dropna (axis = 1 , how = 'all' , inplace = True )
709692 if tdm .shape [1 ] == 9 :
710- spinorbit = True
693+ # TODO: should we get the magnitude here instead?
711694 tdm .columns = ['excitation' , 'energy_ev' , 'osc' , 'remu_x' ,'remu_y' , 'remu_z' ,
712695 'immu_x' , 'immu_y' , 'immu_z' ]
713696 else :
714697 tdm .columns = ['excitation' , 'energy_ev' , 'osc' , 'mu_x' ,'mu_y' , 'mu_z' ]
715- spinorbit = False
716698 tdm ['excitation' ] -= 1
717699 diff = np .setdiff1d (df ['excitation' ].values .flatten (),
718700 tdm ['excitation' ].values .flatten ())
719701 if len (diff ) > 0 :
720- for idx in range ( len ( diff )) :
721- df1 = tdm .loc [range (diff [ idx ] )]
722- df2 = tdm .loc [range (diff [ idx ] , tdm .shape [0 ])]
723- new_line = [diff [ idx ] , df .loc [diff [ idx ] , 'energy_ev' ],
724- df .loc [diff [ idx ] , 'osc' ]]+ [0.0 ]* int (len (tdm .columns )- 3 )
702+ for d in diff :
703+ df1 = tdm .loc [range (d )]
704+ df2 = tdm .loc [range (d , tdm .shape [0 ])]
705+ new_line = [d , df .loc [d , 'energy_ev' ],
706+ df .loc [d , 'osc' ]]+ [0.0 ]* int (len (tdm .columns )- 3 )
725707 new_line = pd .DataFrame ([new_line ], columns = tdm .columns )
726708 new_df = pd .concat ([df1 , new_line , df2 ], ignore_index = True )
727709 tdm = new_df .copy ()
0 commit comments