Git Product home page Git Product logo

Comments (6)

RichRick1 avatar RichRick1 commented on July 28, 2024

@PaulWAyers Me and @Pavlo3P can't find the P-condition in thesis. Should we take a look at other sources or it has a different name?

As for the T2', The only condition we found is
image
It's not straight forward which transformation we need to apply to $\Gamma$ to get T2'.
For the $T_2'^{\dagger}$ it doable using this formula:
image

from pyci.

PaulWAyers avatar PaulWAyers commented on July 28, 2024

So the $T_2'$ matrix has four blocks, a $m^3 \times m^3$ block, a $m^3 \times m$ block, a $m \times m^3$ block (adjoint of the previous block, and a $m \times m$ block. This all gives you an $(m^3 + m) \times (m^3 + m)$ matrix which is positive semidefinite.

The $T_2^\dagger$ formula is F.9. The $T_2$ formula is Eq. (2.60).

Both equations from Ward Poelman's thesis.

from pyci.

PaulWAyers avatar PaulWAyers commented on July 28, 2024

The P condition is merely that the 2-electron reduced density matrix is positive semi-definite. The inverse of the (identity) mapping is the identity. I.e., the P condition is $\mathcal{L}(\Gamma) = \Gamma = \mathcal{L}^\dagger(\Gamma)$

from pyci.

Pavlo3P avatar Pavlo3P commented on July 28, 2024

@PaulWAyers So, the semicolon means reshaping of array? For example, if T2-transformation gives array of (1, 2, 3, 4, 5, 6) shape, it should be reshaped to (1*2*3, 4*5*6) in a straightforward way (i.e. with np.reshape)?

from pyci.

PaulWAyers avatar PaulWAyers commented on July 28, 2024

No semicolon's show up. It's simple using NumPy documentation for reshape or ChatGPT. Her's what the latter said....

  1. Understand the dimensions: Your initial array is a 6-dimensional array of shape $(n, n, n, n, n, n) $. The total number of elements in this array is $n^6$.

  2. Calculate the desired shape: You want to reshape this into a square matrix with $n^3 $ rows and $ n^3 $ columns. Thus, the target shape of the matrix is $(n^3, n^3) $.

  3. Use np.reshape: You can use np.reshape to transform the array. This function needs the new shape you want to convert your array into. For your case, it should be reshaped as mentioned above.

Here's how you can do it in Python:

import numpy as np

# Assume n is known and your array `a` is defined as:
a = np.random.rand(n, n, n, n, n, n)  # This creates a 6D array with random values

# Reshape the array to a square matrix of shape (n^3, n^3)
reshaped_matrix = np.reshape(a, (n**3, n**3))

Make sure that n is set appropriately, as the reshape operation requires that the total number of elements remains constant. In this case, since both the original array and the reshaped array have $n^6$ elements, this condition is naturally satisfied.

You need to be careful to understand how the indices are ordered and to make sure the right indices are being combined. This can be controlled somewhat by intrinsic orderings in reshape but you may have to use moveaxis in some cases. I always suggest looking at a simple example in detail to be sure the numpy functionality is doing what you want.

from pyci.

RichRick1 avatar RichRick1 commented on July 28, 2024

I think the semicolon @Pavlo3P is referring to is the semicolon in the notation for constructing matrices from tensors.
I created a simple wrapper around numpy.reshape function to convert tensors into arrays. I made it a separate function so that it's easier to add some extra functionality on top of it, such as swapping axis, etc. if we need it in the future.

I think for now it would be good if calc_T2_prime function return just a matrix for which we will impose positive semidefinite constraint later.

So, the code can look something like this:

def calc_T2_prime(gamma, N, conjugate=False):
    if not conjugate:
        T2 = calc_T2(gamma, N)
        omega = ...
        rho = ...
        omega_conj = ....
        row_1 = np.hstack([
                flatten_tensor(T2, (N**3, N**3)), flatten_tensor(omega, (N***3, N))])
        row_2 = np.hstack([
                flatten_tensor(omega_conj, (N, N**3)),  rho])
        return np.vstack([row_1, row_2])

from pyci.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.