Search found 468 matches

by Johannes
06 Nov 2025, 17:22
Forum: Algorithms
Topic: Strategy for Finding the Lowest Energy State in each Sz sectors
Replies: 1
Views: 10116

Re: Strategy for Finding the Lowest Energy State in each Sz sectors

To get the ground state energy within each sector, the strategy needs to be to just run DMRG for each sector separately, i.e. use charge conservation and run DMRG with an initial state in that sector. In general, turning on charge conservation should not cause any convergence issues with DMRG and es...
by Johannes
22 Oct 2025, 08:01
Forum: HowTos and FAQ for TeNPy
Topic: Mismatch between numerical and MPS Schmidt-rank-1 projection overlap
Replies: 2
Views: 14871

Re: Mismatch between numerical and MPS Schmidt-rank-1 projection overlap

Indeed, psi.set_SL(...) and psi.set_SR(...) just updates the singular values, not the underlying B tensors (as you can easily see by checking the code...), so this is expected. It is meant to be a more low-level function and used by other MPS methods where you additionally also call psi.set_B(...) t...
by Johannes
14 Oct 2025, 10:26
Forum: HowTos and FAQ for TeNPy
Topic: The convergence problem of Spin-1 AFM Heisenberg Chain
Replies: 2
Views: 7269

Re: The convergence problem of Spin-1 AFM Heisenberg Chain

The initial state should be chosen as product_state = ['0.0','1.0','-1.0','0.0']*(L//4) # initial state or even more simply product_state = ['0.0'] * L Note that these are strings, labeling the differen Sz=-1, 0, +1 - this is different from simple integers, which actually give you the index based on...
by Johannes
30 May 2025, 12:03
Forum: HowTos and FAQ for TeNPy
Topic: Finding sum of expectation values
Replies: 1
Views: 23357

Re: Finding sum of expectation values

Just plug in "Bd Bd" and "B B", i.e. write psi.correlation_function("Bd Bd", "B B", sites1=[i], sites2=[i + 1])[0, 0] In general, the get_op function used from correlation_function and friends to translate the name into actual tensors accepts space-separated c...
by Johannes
30 May 2025, 11:57
Forum: HowTos and FAQ for TeNPy
Topic: TDVP and DMRG problem
Replies: 1
Views: 27156

Re: TDVP and DMRG problem

It is expected that SingleSiteTDVP does not increase the bond dimension by defintion - that's how it's constructed and the reason why we have two-site TDVP in the first place (which is not strictly a TDVP anymore), and documented at the top of tdvp.py . As also stated there, the mixer is currently c...
by Johannes
16 Apr 2025, 12:54
Forum: HowTos and FAQ for TeNPy
Topic: 1D Heisenberg model with periodic BC, how to
Replies: 2
Views: 70463

Re: 1D Heisenberg model with periodic BC, how to

Using bc='periodic' for the Lattice does not imply periodic boundary conditions on the MPS, but just makes the add_coupling method add the additional S_{L-1} \cdot S_0 coupling , similar as you did explicitly "by hand" in this case, such that the Hamiltonian implements the same couplings a...
by Johannes
16 Apr 2025, 12:11
Forum: HowTos and FAQ for TeNPy
Topic: Correlation function
Replies: 1
Views: 30165

Re: Correlation function

why do you think you're doing something wrong? do you get error messages or "wrong" and unexpected results? If you want help, you should say that. I guess you're suprised to see all the psi.expectation_value('B') and psi.expectation_value('Bd') being zero, even in the supposedly superfluid...
by Johannes
16 Apr 2025, 11:54
Forum: HowTos and FAQ for TeNPy
Topic: Correlation function
Replies: 3
Views: 31574

Re: Correlation function

Think about what exactly you're trying to calculate.... in your formula, you don't include 1.j*np.pi factors, which you seem to include in the code? I assume you want to include that. Further, you should expand \langle \exp(\sum_{i<j} 1- n_i)\rangle = \langle \prod_{i<j} \exp(1-n_i)\rangle= \langle ...
by Johannes
14 Feb 2025, 18:53
Forum: HowTos and FAQ for TeNPy
Topic: Incorporating staggering in a 2-D model
Replies: 2
Views: 65837

Re: Incorporating staggering in a 2-D model

Sure, just use a corresponding 2D array for the strength should work. It's documented in add_multi_coupling , by the way, but probably not clear enough? The reference in there should have pointed to possible_multi_couplings , which directly gives you the valid shape for the strength, e.g. trying squ...
by Johannes
14 Feb 2025, 16:19
Forum: HowTos and FAQ for TeNPy
Topic: How to write a PXP model right
Replies: 1
Views: 49182

Re: How to write a PXP model right

There's some issue with your models, try reading reading the model guide for more details. Some hints: You're trying to run TEBD, which requires H_bond defined in a NearestNeighbourModel. However, the PXP model is not nearest-Neighbor, so you either need to use a different time evolution method like...
by Johannes
10 Feb 2025, 09:05
Forum: HowTos and FAQ for TeNPy
Topic: Problem defining nearest neighbour model
Replies: 4
Views: 86482

Re: Problem defining nearest neighbour model

Take a look at the userguide for defining new models . The idea is that you rewrite your Hamiltonian H = \sum_{\langle i,j\rangle} A_i B_j = \sum_{i} \sum_{\delta = j-i} A_i A_{i+\delta} and the nearest_neighbor_couplings for a given lattice are the set of \delta you need to sum over. To be precise,...
by Johannes
22 Jan 2025, 15:47
Forum: HowTos and FAQ for TeNPy
Topic: Ordering of exact diagonalization basis
Replies: 5
Views: 119451

Re: Ordering of exact diagonalization basis

Hi Bart, it's essentially defined by the following line in ExactDiag.__init__() self._pipe = npc.LegPipe(legs, qconj=1, sort=(not sparse), bunch=(not sparse)) Unless you use the `sort=False` keyword, the pipe internally sorts by charge values, more precises such that it's `qmap` is lexiographically ...
by Johannes
22 Jan 2025, 14:18
Forum: HowTos and FAQ for TeNPy
Topic: Hamiltonian MPO of different kinds of spins
Replies: 4
Views: 86470

Re: Hamiltonian MPO of different kinds of spins

The fact that you get bond dimension 2 on the boundaries is for technical reasons that we add the "IdL" (ready) and "IdR" (final) states of the MPO finite state machine on each bonds. If you don't want that, overwrite calc_H_MPO in the model by copy-pasting the current implementa...
by Johannes
07 Jan 2025, 13:53
Forum: HowTos and FAQ for TeNPy
Topic: computing correlation function and expectation value
Replies: 1
Views: 52269

Re: computing correlation function and expectation value

This should really give the same. It's been a while since you wrote this - has this been resolved by now? I quickly tried to reproduce this for a random MPS, but it seemed to work as expected. If you still find differences, it would be great if you can open an issue on github and provide a (minimal ...
by Johannes
07 Jan 2025, 12:49
Forum: HowTos and FAQ for TeNPy
Topic: iDMRG Convergence Issues in 2D Triangular Lattice XXZ Model
Replies: 2
Views: 69489

Re: iDMRG Convergence Issues in 2D Triangular Lattice XXZ Model

Try increasing/varying Lx until you see convergence! In general, if you expect symmetry breaking, the ground state with broken symmetry should be commensurate, i.e. the symmetry broken pattern needs to fit into your iDRMG unit cell! Otherwise, the MPS needs to become a "cat" state with mul...
by Johannes
07 Jan 2025, 12:40
Forum: HowTos and FAQ for TeNPy
Topic: Hamiltonian MPO of different kinds of spins
Replies: 4
Views: 86470

Re: Hamiltonian MPO of different kinds of spins

I would recommend to use the tenpy.models.model.CouplingMPOModel , and override the methods as detailed in the model user guide . Since you have all-to-all interactions, you don't really have a chain, so you can use a TrivialLattice to write this down - but that implies that you have to manually sum...
by Johannes
07 Jan 2025, 11:04
Forum: HowTos and FAQ for TeNPy
Topic: Can SpinChainNNN2 in the limits of the TFIM generate same results as TFIModel?
Replies: 1
Views: 46710

Re: Can SpinChainNNN2 in the limits of the TFIM generate same results as TFIModel?

To detect spontaneous symmetry breaking, you shouldn't check the magnetization: it is only nonzero in the symmetry broken states, but you can write an (anti)-symmetric superposition of the symmetry-broken states which has magnetization 0. Instead, you should check the decay of correlations at long d...
by Johannes
14 Oct 2024, 13:46
Forum: HowTos and FAQ for TeNPy
Topic: controlling particle number of independent species
Replies: 4
Views: 100945

Re: controlling particle number of independent species

You have to be a bit more specific - your question is very generic, so I can only guess what your problem might be... What's your lattice, how did you get the 0, 1 and 20, 21 indices in your question? I would assume that you would rather want something like Corr=psi.term_rorrelation_function_right([...
by Johannes
30 Sep 2024, 07:17
Forum: HowTos and FAQ for TeNPy
Topic: problem about installing tenpy
Replies: 2
Views: 59877

Re: problem about installing tenpy

The python ecosystem is a bit confusing with the different ways you can have "virtual environments" in which you can install packages - see this famous xkcd comic , and the situation has not really become better since the comic came out - now you additionally have conda envrionments, and s...
by Johannes
25 Sep 2024, 16:23
Forum: HowTos and FAQ for TeNPy
Topic: controlling particle number of independent species
Replies: 4
Views: 100945

Re: controlling particle number of independent species

I'm not sure what your Hamiltonian is, here - do you have boson hopping between the upper and lower part where you set \mu_{up} and \mu_{down} , respectively, or is there only a density-density interaction? You can only use charge conservation to preserve the respective fillings if H commutes with N...
by Johannes
25 Sep 2024, 16:07
Forum: HowTos and FAQ for TeNPy
Topic: controlling particle number of independent species
Replies: 4
Views: 100945

controlling particle number of independent species

I got the following question by email: I encountered some difficulties when setting conserved quantities. I filled two types of bosons in a two-dimensional bosonsite, and I want to control the filling numbers for each boson. Usually, I control the filling number by controlling their chemical potenti...
by Johannes
25 Sep 2024, 16:03
Forum: HowTos and FAQ for TeNPy
Topic: How to plot spin structure?
Replies: 1
Views: 59850

Re: How to plot spin structure?

AFM, FM, 120°AFM mean that the system spontaneously breaks the symmetry, i.e. you have degenerate ground states. It's important to distinguish between continous and discrete symmetries, which you break here. If you enforce charge conservation, this might indeed force DMRG to write a superposition of...
by Johannes
25 Sep 2024, 15:39
Forum: HowTos and FAQ for TeNPy
Topic: Units of exchange coupling and DMI/anisotropic J
Replies: 1
Views: 58688

Re: Units of exchange coupling and DMI/anisotropic J

1.) Hmm, good question. I never tried, but I'm afraid it wouldn't go well, and strongly advise against it. In theory, I agree that you can choose arbitary units and scale all terms in the hamiltonian accordingly. In practice, we have several points where we discard everything on the order of machine...
by Johannes
25 Sep 2024, 15:19
Forum: HowTos and FAQ for TeNPy
Topic: Strategies to run large-memory calculations?
Replies: 2
Views: 95200

Re: Strategies to run large-memory calculations?

I guess I'm late for you to solve the problem, but maybe as a hint for people trying to solve it in the future: The #SBATCH --nodes=2 asks SLURM for 2 nodes with MPI paralellization. TeNPy can not utilize that (unless you're working in the mpi_parallel branch, which is for very specific use cases on...
by Johannes
25 Sep 2024, 14:44
Forum: HowTos and FAQ for TeNPy
Topic: Why is finite DMRG running so slowly?
Replies: 1
Views: 46656

Re: Why is finite DMRG running so slowly?

TeNPy has comparable speed with other libraries like ITensor , if you fix parameters for a fair comparison. One big difference is the default dmrg_params['lanczos_params']['N_max'] , the maximum number of lanczos iterations for finding the "ground state" before moving on to the next site. ...