joselado / dmrgpy

DMRGPy is a Python library to compute quasi-one-dimensional spin chains and fermionic systems using matrix product states with DMRG as implemented in ITensor. Most of the computations can be performed both with DMRG and exact diagonalization for small systems, which allows one to benchmark the results.
GNU General Public License v3.0
83 stars 20 forks source link

how to set the particle number fixed ? #15

Closed szwiop closed 2 years ago

szwiop commented 2 years ago

Hi, Jose

Great work!

Recently, I am learning to use Itensor. I happened to find your excellent code package dmrgpy.

I finally get dmrgpy package installed on the computer. The example code runs successfully!

Here I have a small question on the example code  "spinless_fermions".

In main.py, I see that  "n "  can be taken a lattice size. and my question is, (1) can we set the number of the spinless fermions? (2) If it is yes, how to set value of the particle number?

Thank your for supplying such a good code package! It helps a lot Wonderful wok!

WL

joselado commented 2 years ago

Hi szwiop,

thank you for your message and your kind feedback.

Regarding your question, the code works in the full space with all the different particle numbers, so that one can also include terms that violate particle number (such as a superconducting pairing). If your Hamiltonian has particle conservation, your eigenstates would be of course diagonal in the particle number operator. The code does not currently allow targeting a specific particle sector by setting the number of electrons. You could target the different particle sectors by adding a global chemical potential, so that the ground state in the full space has the number of particles that you would like.

Best regards, Jose

szwiop commented 2 years ago

Hi Jose,

Thank you very much for your quick reply!

Your answer is very clear and inspiring. It saves me from the puzzle.

Moreover, you give a good solution to the problem I am facing at. This really helps.

Adding global uniform potential is a good idea to meet the need of the problem. Theoretically, after a run we can figure out the number of particles in the systems by adding a line for the observable of particle number.

Since I am a newer, I am not quite familiar with the syntax of the package. Could you do me a favor by telling me how to do this technically?

I guess it's something like, fc.gs_energy(mode="DMRG") Is that fc.particle_number() ?

Best wishes! WL

joselado commented 2 years ago

Hi WL,

you can compute the particle number just by computing its expectation value. You can see an example of this here dmrgpy/examples/sum_mps in short, both the MPS and MPO can be used as if they were matrices and vectors.

I have left an example of how to do this in https://github.com/joselado/dmrgpy/blob/master/examples/total_particle_number/main.py

and below you can see the result it gives for the number of particles as a function of the chemical potential

image

Best regards, Jose

szwiop commented 2 years ago

Hi Jose,

Thank you very much for you fresh code! We benefit from it a lot.

We will cite this package as long as any work is done based on it.

Best regards WL

joselado commented 2 years ago

Hi WL,

thanks for your kind feedback! Great to hear that the package is useful!

Best regards, Jose

szwiop commented 1 year ago

Hi, Jose,

Thank you very much for your quick reply!

Your answer  is very clear and inspiring. It saves me from the puzzle.

Moreover, you give a good solution to the problem I am facing at. This really helps.

Adding global uniform potential is a good idea to meet the need of the problem. Theoretically, after a run we can figure out the number of particles in the systems  by adding a line for the observable of  particle number.

Since I am a newer, I am not quite familiar with the syntax of the package. Could you do me a favor by telling me how to do this technically?

I guess it's something like,         fc.gs_energy(mode="DMRG") Is that          fc.particle_number() ?

Best wishes! WL

Message ID: @.***>

joselado commented 1 year ago

Hi WL,

thanks for writing. You can compute the particle number by just computing the expectation value of the number operator as

n = fc.vev(sum(fc.N))

where "n" will be the particle number.

Best regards, Jose