felixplasser / theodore-qc

TheoDORE - A package for Theoretical Density, Orbital Relaxation and Exciton analysis
https://theodore-qc.sourceforge.io/
GNU General Public License v3.0
29 stars 8 forks source link

analyze_tden with SOCs in ORCA #46

Closed maisebastian closed 3 months ago

maisebastian commented 11 months ago

Hi Felix, we get an error when running ORCA with singlets and triplets and with DoSOC=True in ORCA5. Please find the attached minimum reproducing example.

The error is:

Traceback (most recent call last):
  File "/user/sascha/theodore/TheoDORE_3.1.1/bin/theodore", line 6, in <module>
    run()
  File "/user/sascha/theodore/TheoDORE_3.1.1/colt/colt.py", line 386, in __call__
    return self._cls.from_commandline(*args, description=self.description,
  File "/user/sascha/theodore/TheoDORE_3.1.1/colt/colt.py", line 249, in from_commandline
    return cls._from_config(answers, *args, **kwargs)
  File "/user/sascha/theodore/TheoDORE_3.1.1/colt/colt.py", line 309, in _from_config
    return cls.from_config(answer, *args, **kwargs)
  File "/user/sascha/theodore/TheoDORE_3.1.1/theodore/actions/actions.py", line 21, in from_config
    return action.from_config(config)
  File "/user/sascha/theodore/TheoDORE_3.1.1/theodore/actions/actions.py", line 33, in from_config
    return cls.run(**config)
  File "/user/sascha/theodore/TheoDORE_3.1.1/theodore/actions/theotools.py", line 31, in _wrapper
    result = func(*args, **kwargs)
  File "/user/sascha/theodore/TheoDORE_3.1.1/theodore/actions/analyze_tden.py", line 88, in run
    tdena.print_all_eh_pop()
  File "/user/sascha/theodore/TheoDORE_3.1.1/theodore/lib_tden.py", line 140, in print_all_eh_pop
    self.printer_base(title, function, lvprt)
  File "/user/sascha/theodore/TheoDORE_3.1.1/theodore/dens_ana_base.py", line 181, in printer_base
    print(state['name'])
KeyError: 'name'

It appears that TheoDORE tries to print results for all 12 spin-mixed states, and crashes because previously only 6 spin-free states were read. The error disappears if one manually deletes the SOC-state-related tables (i.e., the 8 tables after "SOC CORRECTED TD-DFT/TDA-EXCITATION SPECTRA") from the log file.

I would be happy about your opinion of the bug and how to best solve it. Is that a bug that can only be fixed inside cclib? Or can we do something within TheoDORE?

Best, Sebastian

orca.inp.txt dens_ana.in.txt

felixplasser commented 11 months ago

Hi Sebastian, I'll have a look. This should not be too hard to solve.

felixplasser commented 11 months ago

I see. The problem with Orca is that it prints so many different versions of the excitation energies.

Maybe the cleanest solution is to get rid of cclib altogether and read everything from the binary file. At the moment, TheoDORE just gets the excitation energies and oscillator strengths from cclib. But they should also be available in the binary file. Then we don't need cclib at all. Did you write the code to read the binary files from orca? https://github.com/felixplasser/theodore-qc/blob/master/theodore/cclib_interface.py#L116

felixplasser commented 11 months ago

It looks like the excitation energies are on the binary file. Then we have everything we need to do it without cclib. I'll have a look.

maisebastian commented 11 months ago

Hi Felix, yes, the code for reading the binary files was first written for the SHARC-ORCA interface. Indeed, excitation energies are on the file, but I do not remember about oscillator strengths. I agree that one could do without cclib, but I am not sure whether one can work without touching the ORCA log file (or do you plan to take basis and MOs from the Molden file?). Please tell me if I can be of help.

Best, Sebastian

PS: Once ORCA 6 comes out, all data parsing can probably be done via orca_2json. That might make things easier :)

felixplasser commented 11 months ago

I separated out the Orca interface to not use cclib at all. This is something I wanted to do for a while because there are a number of errors of the sort you described.

You can get the orca-standalone branch and see if it works for you https://github.com/felixplasser/theodore-qc/tree/orca-standalone

As far as I can see it produces the same results as before with the only difference that it does not parse oscillator strengths. But I think that is ok. One can get the oscillator strengths in any other way from the file.

If it looks ok, then I'll include it into the main branch.

felixplasser commented 11 months ago

For your example, I am using the following input file

rtype="orca"
rfile="orca.out"
mo_file="orca.molden.input"
read_binary=True
jmol_orbitals=False
molden_orbitals=False
Om_formula=2
eh_pop=1
comp_ntos=True
print_OmFrag=True
output_file="tden_summ.txt"
prop_list=['Om', 'POSi', 'POSf', 'PR', 'CT', 'PRNTO', 'Z_HE', 'RMSeh']
at_lists=[[1], [2, 3]]

And I get the following output

state       dE(eV)    f     Om   POSi   POSf     PR     CT  PRNTO   Z_HE  RMSeh
--------------------------------------------------------------------------------
1(3)A       2.377      -  1.000  1.711  1.509  1.849  0.490  1.005  1.020  1.535
2(3)A       2.639      -  1.000  1.939  1.520  1.563  0.483  1.007  1.027  1.656
3(3)A       2.861      -  1.000  1.934  1.516  1.569  0.486  1.006  1.024  1.651
1(1)A       3.284      -  1.000  1.814  1.514  1.717  0.493  1.004  1.019  1.600
2(1)A       3.438      -  1.000  1.902  1.513  1.607  0.490  1.002  1.011  1.631
3(1)A       5.748      -  1.000  1.915  1.472  1.589  0.517  1.744  2.173  1.641
felixplasser commented 11 months ago

Just as a note, to include it into the main branch, I'll have to

maisebastian commented 11 months ago

Hi Felix, the new branch also works for me for the given example. The output is the same with the old cclib interface (if I manually remove the SOC tables). So all looks good!

At least for our applications, no oscillator strengths are not really a problem, as they can still be found in the orca.log easily. That should be enough until ORCA 6.

Thanks for your work and best wishes, Sebastian

felixplasser commented 11 months ago

ok! I'll move this over to the main branch. This mixed cclib interface has caused problems before. So, it's good to separate it out ...

maisebastian commented 11 months ago

You might want to consider keeping the cclib interface as well for people that prefer oscillator strengths over SOCs ;)