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.compute_V([VR,]) # Output potential to VR
VPotU = UnrestrictedCopyOf(VPot) # KEY LINE
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,

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 =, OldVPot.functional(), "UV")

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

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,


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''_u'}
    for x in DFA.x_functionals():
        Name =[3:]
        alpha = x.alpha()
        DFA_Dict['x_functionals'][Name] = {"alpha": alpha,}
    for c in DFA.c_functionals():
        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,


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