pairinteraction / pairinteraction

A Rydberg Interaction Calculator
https://pairinteraction.github.io/
GNU General Public License v3.0
41 stars 32 forks source link

Python calculation of C3 coefficient #129

Open Babalion opened 2 years ago

Babalion commented 2 years ago

I try to calculate the C3 coefficient between two states in a python-script. Here is a minimal working example:

import os

from pairinteraction import pireal as pi

if not os.path.exists("./cache"):
    os.makedirs("./cache")
cache = pi.MatrixElementCache("./cache")

stateDD = pi.StateTwo(["K", "K"],
                      [62, 61],
                      [1, 2],
                      [0.5, 1.5],
                      [-0.5, -0.5])
theta = 0
calculator = pi.PerturbativeInteraction(theta, cache)
C_3 = calculator.getC3(stateDD)
print("The C3 coefficient is {} GHz µm^3.".format(C_3))

The error is:

File "/home/tux/miniconda/envs/quimbEnv/lib/python3.10/site-packages/pairinteraction/pireal.py", line 2263, in getC3
    return _pireal.PerturbativeInteraction_getC3(self, states)
TypeError: in method 'PerturbativeInteraction_getC3', argument 2 of type 'std::vector< StateTwo,std::allocator< StateTwo > > const &'

It seems to be a type error, but when calculating the C6 coefficient, the type matches. Is this an error or am I not using this function correctly? Thanks in advance!

hmenke commented 2 years ago

There is only a single overload of getC3 for std::vector<StateTwo>, whereas getC6 has overloads for both StateTwo and std::vector< StateTwo>. That's why it works with getC6. As a workaround you can use for now

-C_3 = calculator.getC3(stateDD)
+C_3 = calculator.getC3([stateDD])