Copy restricted VBase to unrestriced VBase

Hi all,

I have a code which reads in a restricted KS system, but then needs to compute KS potentials from an unrestricted calculation.

Specifically, in the below code, my goal is to replace meta-code “UnrestrictedCopyOf” by efficient psi4 back-end routines.

DR # density matrix in restricted
DA # alpha density matrix
DB # beta density matrix

VPot = wfn.V_potential() # Restricted VBase object
VPot.set_D([DR,])
VPot.compute_V([VR,]) # Output potential to VR
VPotU = UnrestrictedCopyOf(VPot) # KEY LINE
VPotU.set_D([DA,DB])
VPotU.compute_V([VA,VB]) # Output potential to VA and VB

I’ve tried various things, but can’t pin down from the documentation where the “restricted” tag is set. So I haven’t been able to get things working.

Any help would be very appreciated!

All the best,
Tim

The flag gets set via VBase but has missing documentation.
The arg2 can be RV, UV or SAP (as string) and then builds the restricted, unrestricted or SAP potential object.
The new object then also needs initialize() which will also build a new grid.

Thanks so much for your help.

VPot = psi4.core.VBase.build(OldVPot.basis(), OldVPot.functional(), "UV")
VPot.initialize()

seems to cross the first hurdle. But it seems the RKS/UKS is not confined to VBase as I then get:

RuntimeError:
Fatal Error: Passed in functional was unpolarized for UV reference.

And the documentation for super_functional doesn’t seem to have any discussion on spin whatsoever, nor could I find examples in the tutorials (not to say they’re not there!).

So I guess my question now is how do I make a new superfunctional that clones an existing RKS one but transforms it into UKS?

All the best,

Tim

Right, the superfunctional build functions take a boolean flag to switch to spin polarised.

I think the only way currently is to construct a new one. A possible cloning function would work via a dictionary since we already can build a superfunctional with a dict.

A superfunctional->dictionary converter is a good idea to add on our side, i think,

These more internal functions are poorly documented for new users. Do you have a custom functional or a standard functional to handle?

Cheers. I hacked it to work (see below)

I need it to handle arbitrary functionals (not range-separated hybrids, for now). I’m writing a Python library that takes an existing RKS wavefunction object and spits out something cool. :slight_smile:

EDIT: The following routine seems to work

sf_from_dict =  psi4.driver.dft.build_superfunctional_from_dictionary
def sf_RKS_to_UKS(DFA):
    DFA_Dict = { 'name':DFA.name()+'_u'}
    DFA_Dict['x_functionals']={}
    DFA_Dict['c_functionals']={}
    for x in DFA.x_functionals():
        Name = x.name()[3:]
        alpha = x.alpha()
        DFA_Dict['x_functionals'][Name] = {"alpha": alpha,}
    for c in DFA.c_functionals():
        Name = c.name()[3:]
        alpha = c.alpha()
        DFA_Dict['c_functionals'][Name] = {"alpha": alpha,}
    npoints = psi4.core.get_option("SCF", "DFT_BLOCK_MAX_POINTS")
    DFAU, _ = sf_from_dict(DFA_Dict,npoints,1,False)
    return DFAU

All the best,

Tim

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.