See https://tenpy.readthedocs.io/en/latest/ ... igner.html
If you use FermionSite, it is probably enough to just put conserve=“parity“ in your model parameters
Search found 31 matches
- 19 Mar 2026, 15:17
- Forum: HowTos and FAQ for TeNPy
- Topic: How Do I implement fermionic parity?
- Replies: 1
- Views: 320
- 30 Jan 2026, 12:13
- Forum: HowTos and FAQ for TeNPy
- Topic: Evaluate energy expectation value in infinite Purification MPS
- Replies: 1
- Views: 10237
Re: Evaluate energy expectation value in infinite Purification MPS
Hi!
In MPS.expectation_value, use the axes parameter.
Hope this already helps, if not, post again =)
Cheers
Jakob
In MPS.expectation_value, use the axes parameter.
Hope this already helps, if not, post again =)
Cheers
Jakob
- 05 Dec 2025, 11:47
- Forum: HowTos and FAQ for TeNPy
- Topic: Error when using calc_H_bond() for both coupling and onsite terms
- Replies: 3
- Views: 27409
Re: Error when using calc_H_bond() for both coupling and onsite terms
Have a look at the models guide
https://tenpy.readthedocs.io/en/latest/intro/model.html
If you need a finite periodic system, simply dont inherit from NearestNeighbourModel, then you can still do everything except TEBD
https://tenpy.readthedocs.io/en/latest/intro/model.html
If you need a finite periodic system, simply dont inherit from NearestNeighbourModel, then you can still do everything except TEBD
- 05 Dec 2025, 11:43
- Forum: HowTos and FAQ for TeNPy
- Topic: Error when using calc_H_bond() for both coupling and onsite terms
- Replies: 3
- Views: 27409
Re: Error when using calc_H_bond() for both coupling and onsite terms
This is expected behavior.
The nearest neighbor model needs to be nearest neighbor in the MPS geometry of an open chain. From the MPS point of view, your model has one single long range coupling between the first and last site.
You can have such a model with infinite MPS, but not with finite MPS
The nearest neighbor model needs to be nearest neighbor in the MPS geometry of an open chain. From the MPS point of view, your model has one single long range coupling between the first and last site.
You can have such a model with infinite MPS, but not with finite MPS
- 07 Oct 2025, 14:35
- Forum: HowTos and FAQ for TeNPy
- Topic: Calculate excitations after iDMRG
- Replies: 1
- Views: 111871
- 07 Oct 2025, 14:34
- Forum: HowTos and FAQ for TeNPy
- Topic: "Excitations with DMRG and segment boundary conditions" notebook questions
- Replies: 3
- Views: 167027
- 06 Oct 2025, 08:45
- Forum: HowTos and FAQ for TeNPy
- Topic: Defining operator_t and operator_t0 in SpectralSimulation
- Replies: 1
- Views: 75142
Re: Defining operator_t and operator_t0 in SpectralSimulation
Hi, Based on a quick look at https://tenpy.readthedocs.io/en/latest/reference/tenpy.simulations.time_evolution.TimeDependentCorrelation.html#tenpy.simulations.time_evolution.TimeDependentCorrelation I assume that a list as operator_t0 has a different meaning, it will apply them all instead of loopin...
- 06 Oct 2025, 08:40
- Forum: HowTos and FAQ for TeNPy
- Topic: Acceleration via GPU
- Replies: 1
- Views: 109476
Re: Acceleration via GPU
Hi,
GPUs are not supported yet. We are working on it for version 2. We hope to get a working pre-release version ready before christmas.
GPUs are not supported yet. We are working on it for version 2. We hope to get a working pre-release version ready before christmas.
- 06 Oct 2025, 08:37
- Forum: HowTos and FAQ for TeNPy
- Topic: custom AKLT models
- Replies: 2
- Views: 39139
Re: custom AKLT models
Hi, the AKLTChain is one of the few models in tenpy that is not defined via the CouplingModel framework, so this error is expected behavior. If you want to modify the existing AKLTChain, take a look at how it is defined and adjust the ``H_bond`` in ``__init__`` to include your extra term. Note that ...
- 05 Aug 2025, 15:43
- Forum: HowTos and FAQ for TeNPy
- Topic: Best practice for measuring <SxSx> correlations in DMRG with conserve='Sz' for the XXZ model?
- Replies: 2
- Views: 117676
Re: Best practice for measuring <SxSx> correlations in DMRG with conserve='Sz' for the XXZ model?
Also note that for an Sz conserving state, <Sp Sp> = 0 = <Sm Sm>.
- 05 Aug 2025, 15:39
- Forum: HowTos and FAQ for TeNPy
- Topic: Best practice for measuring <SxSx> correlations in DMRG with conserve='Sz' for the XXZ model?
- Replies: 2
- Views: 117676
Re: Best practice for measuring <SxSx> correlations in DMRG with conserve='Sz' for the XXZ model?
It is not possible to have an Sx operator when conserving Sz, precisely because applying Sx has no well defined action on the conserved Sz charge. You can think of the action of Sx as a superposition of both raising and lowering the Sz charge. This can not be done while enforcing Sz conservation. Yo...
- 26 Jun 2025, 16:21
- Forum: HowTos and FAQ for TeNPy
- Topic: Random truncation of MPS
- Replies: 1
- Views: 88626
Re: Random truncation of MPS
Hi,
This looks correct, and seems like a good implementation of your goal.
I am not sure why you would want to do this random truncation in the first place, but the code should be able to do it nicely.
This looks correct, and seems like a good implementation of your goal.
I am not sure why you would want to do this random truncation in the first place, but the code should be able to do it nicely.
- 18 Jun 2025, 15:15
- Forum: HowTos and FAQ for TeNPy
- Topic: How to add additional U(1) Symmetry in BosonSite for Tenpy
- Replies: 1
- Views: 74613
Re: How to add additional U(1) Symmetry in BosonSite for Tenpy
Hi, These types of position dependent charges are not available in the live tenpy version yet There is an unmerged PR at https://github.com/tenpy/tenpy/pull/183 It seems, however, that it is not very stable for infinite systems and not tested well enough. I would not blindly trust it. In the infinit...
- 08 Apr 2025, 10:11
- Forum: HowTos and FAQ for TeNPy
- Topic: Isotropic spin-spin correlator for 1D J1–J2 model with PBC
- Replies: 1
- Views: 111254
Re: Isotropic spin-spin correlator for 1D J1–J2 model with PBC
The code you pasted already fails before this line. E.g. Sx = [model.lat.mps_sites().Sx for i in range(L)] fails, as model.lat.mps_sites() is a list. The failure you report is expected behavior as well. An operator, like the entries in your Sx list are Arrays and do not know what site they came from...
- 07 Apr 2025, 10:46
- Forum: HowTos and FAQ for TeNPy
- Topic: Changing Bose-Hubbard model
- Replies: 9
- Views: 1161041
Re: Changing Bose-Hubbard model
1) - line before the three: initialize a BosonSite, with its opertors etc. next we modify it by adding the new operator - extract alpha from the model_params, this is just a convenient way to tell the model the value for alpha - N_diag is a helper for defining the operator. It is the diagonal of the...
- 03 Apr 2025, 16:09
- Forum: HowTos and FAQ for TeNPy
- Topic: Changing Bose-Hubbard model
- Replies: 9
- Views: 1161041
Re: Changing Bose-Hubbard model
The operator you want is not one of the pre-defined operators of the BosonSite, so you would need to add it explicitly. You probably want to do something like this: class MyExtendedBoseHubbarModel(tenpy.BoseHubbardModel): def init_sites(self, model_params): site = super().init_sites(model_params) al...
- 03 Apr 2025, 07:19
- Forum: HowTos and FAQ for TeNPy
- Topic: Changing Bose-Hubbard model
- Replies: 9
- Views: 1161041
Re: Changing Bose-Hubbard model
Ah I see. In that case you can replace the hopping for u1, u2, dx in self.lat.pairs['nearest_neighbors']: self.add_coupling(-t, u1, 'Bd', u2, 'B', dx, plus_hc=True) that generates \sum_{<i,j>} (b^\dagger_i b_j + hc) with for u1, u2, dx in self.lat.pairs['nearest_neighbors']: self.add_coupling(-t, u1...
- 02 Apr 2025, 14:35
- Forum: HowTos and FAQ for TeNPy
- Topic: Changing Bose-Hubbard model
- Replies: 9
- Views: 1161041
Re: Changing Bose-Hubbard model
If you want to extend the BH model without rewriting everything, you can do sth like class MyExtendedBHModel(tenpy.BoseHubbardModel): def init_terms(self, model_params): super().init_terms(model_params) gamma = model_params.get('gamma', 0, 'real_or_array') for u in range(len(self.lat.unit_cell)): se...
- 02 Apr 2025, 14:33
- Forum: HowTos and FAQ for TeNPy
- Topic: Changing Bose-Hubbard model
- Replies: 9
- Views: 1161041
Re: Changing Bose-Hubbard model
The term you want is called parity or 'P' in the BosonSite, with definition P = 1 - 2 (n \text{ mod } 2) = (-1)^n = \mathrm{exp}(\mathrm{i} \pi n) . So for H = \sum_i \gamma_i * \mathrm{exp}(\mathrm{i} \pi n_i) + H_\text{other} you could do something like def init_terms(self, model_params): ... # ot...
- 02 Apr 2025, 14:25
- Forum: HowTos and FAQ for TeNPy
- Topic: Obtainin expectation value of number operator in BH model
- Replies: 3
- Views: 125225
Re: Obtainin expectation value of number operator in BH model
Have a look at these examples that simulate groundstate expectation values
https://tenpy.readthedocs.io/en/latest/ ... _dmrg.html
https://tenpy.readthedocs.io/en/latest/ ... _dmrg.html
- 20 Mar 2025, 15:08
- Forum: HowTos and FAQ for TeNPy
- Topic: Converting to state vector gives wrong energy
- Replies: 2
- Views: 92958
Re: Converting to state vector gives wrong energy
See https://github.com/tenpy/tenpy/pull/495 for functions that export tenpy objects (MPS or Hamitlonians from a model) to full matrix representations.
- 19 Mar 2025, 10:05
- Forum: HowTos and FAQ for TeNPy
- Topic: Obtainin expectation value of number operator in BH model
- Replies: 3
- Views: 125225
Re: Obtainin expectation value of number operator in BH model
I assume you mean the Bose Hubbard model?
In what state do you want to take the expectation value?
If you want it in the groundstate, you can take an MPS psi resulting from DMRG and use
psi.expectation_value('N'), which gives you the particle number on every single site.
In what state do you want to take the expectation value?
If you want it in the groundstate, you can take an MPS psi resulting from DMRG and use
psi.expectation_value('N'), which gives you the particle number on every single site.
- 19 Mar 2025, 09:56
- Forum: HowTos and FAQ for TeNPy
- Topic: Converting to state vector gives wrong energy
- Replies: 2
- Views: 92958
Re: Converting to state vector gives wrong energy
tenpy, with charge conservation has a basis order that might be surprising. See e.g. the warning in Site So I assume that you are writing down H_sp in an incompatible basis (probably you use {|up>, |down>}, and if you use charge conservation, tenpy will use {|down>, |up>}). Have a look at model.lat....
- 14 Feb 2025, 16:27
- Forum: HowTos and FAQ for TeNPy
- Topic: DMRG on a IrregularLattice Transverse Field Ising Model
- Replies: 3
- Views: 122549
Re: DMRG on a IrregularLattice Transverse Field Ising Model
Confirmed that the workaround above works for my quick test.
For the fix see https://github.com/tenpy/tenpy/pull/481
For the fix see https://github.com/tenpy/tenpy/pull/481
- 14 Feb 2025, 16:05
- Forum: HowTos and FAQ for TeNPy
- Topic: DMRG on a IrregularLattice Transverse Field Ising Model
- Replies: 3
- Views: 122549
Re: DMRG on a IrregularLattice Transverse Field Ising Model
Hi, Looks like this is bug in the consistency_check ecosystem, specifically for IrregularLattices. TeNPy tries to warn users if the lattice has too large N_sites_per_ring. This check causes an error, because N_sites_per_ring is None for the IrregularLattice. I will push a fix soon. In the meantime y...