Page 1 of 1

periodic conditions

Posted: 28 May 2019, 07:23
by Diyora
Hi there,
I am trying to use your method to solve Hamiltonians with periodic conditions.
I saw that from your website you said you can add couplings by >>> self.add_coupling([1.5, 1.], 0, 'Sz', 0, 'Sz', dx)
May I ask what does "[1.5, 1.]" mean here?
thank you!
Diyora Zhang

Re: periodic conditions

Posted: 28 May 2019, 07:49
by Diyora
Actually I am trying to realize this Hamiltonian (an alternative Heisenberg model) \(H = \Sigma_i (J' S_{2i-1} \cdot S_{2i} + J S_{2i} \cdot S_{2i + 1})\). S are the Spin 1/2 operators. I think I need to change somewhere in the codes, but just don't know where to go with the odd and even "i". thank you!

Re: periodic conditions

Posted: 28 May 2019, 08:34
by Johannes
Welcome!

The first argument of add_coupling is the strenght of the coupling. It can be a single value (if the strength is uniform all over the chain/lattice), but also a numpy array or something convertible a numpy array (which is the case here).
The different values just indicate that the strength can vary spatially, e.g. in this case it gives alternating weak and strong couplings
(strong between 0-1, weak between 1-2, strong between 2-3, ...).
How many values you have to specify depends on the boundary conditions, which is why I explicitly mentionied it in the example.
If you specify just two values, they can get "tiled" to an array of 2*L values, which is what is required for a chain with periodic/infinite boundary conditions and an even number of sites.

The boundary conditions are specified in the tenpy.models.lattice.Lattice, see also the Introduction to models.

Re: periodic conditions

Posted: 28 May 2019, 11:45
by Diyora
Hi Johannes,
Thank you for you reply! But I am still a little bit confused on how to apply this package to the Hamiltonian I am focusing on. How could I adjust the odd numbers and even numbers separately?

Thank you,
Diyora

Re: periodic conditions

Posted: 28 May 2019, 20:07
by Johannes
Exactly as in the example you posted: just specify an array/list as "strength" in add_coupling.
In fact, you don't even need to define your own model, if you're happy with the XXZ Chain /SpinChain with alternating strength:

Code: Select all

from tenpy.models.xxz_chain import XXZChain

model_params = {
    'bc_MPS': 'infinite',
    'L': 4, # any even number works
    'Jxx': 1.,  # a single number works
    'Jz': [0.1, 2.],  # The alternating coupling!
    'hz': [0.1, -0.1], # alternating field
}
M = XXZChain(model_params)
print(M.all_coupling_terms().to_TermList())
print(M.all_onsite_terms().to_TermList())
This produces the output

Code: Select all

0.50000 * Sm_0 Sp_1 +
0.50000 * Sp_0 Sm_1 +
0.10000 * Sz_0 Sz_1 +
0.50000 * Sm_1 Sp_2 +
0.50000 * Sp_1 Sm_2 +
2.00000 * Sz_1 Sz_2 +
0.50000 * Sm_2 Sp_3 +
0.50000 * Sp_2 Sm_3 +
0.10000 * Sz_2 Sz_3 +
0.50000 * Sm_3 Sp_4 +
0.50000 * Sp_3 Sm_4 +
2.00000 * Sz_3 Sz_4
-0.10000 * Sz_0 +
0.10000 * Sz_1 +
-0.10000 * Sz_2 +
0.10000 * Sz_3
If you play around, you will see that the code fails if you put 'finite' boundary conditions, no matter what L is.
The reason is simple: With open boundary conditions, you need L values for hz, but only L-1 values for the Jz (because there is one less bond than site). You can "cure" this by explicitly specifying all the L-1 values for Jz and all the L values for hz.

Re: periodic conditions

Posted: 28 Jul 2019, 04:18
by Diyora
Hi Johanne,
Sorry for the late reply. I was sick for a while... and then I rushed to my final exams.
Now I am going to produce the results. I put your code to my jupyter notebook but it responds that
"'XXZChain' object has no attribute 'all_onsite_terms'
and I don't know why... I imported tenpy.
thank you!

Yours
Diyora

Re: periodic conditions

Posted: 29 Jul 2019, 09:17
by Johannes
Could it be that the tenpy you are importing is an old version?
The all_onsite_terms was only introduced fairly recently.

Re: periodic conditions

Posted: 29 Jul 2019, 19:28
by Diyora
Yes, seems like that. Thank you! I am trying to update.