In this example we use the pyALF interface to run ALF’s projective algorithm with the Mz choice of Hubbard Stratonovich transformation on a 4-site ring.
The projective approach is the method of choice if one is interested in ground-state properties. The starting point is a pair of trial wave functions, , that are not orthogonal to the ground state :
The ground-state expectation value of any observable can then be computed by propagation along the imaginary time axis:
where defines the imaginary time range where observables (time displaced and equal time) are measured and varies from 0 to in the calculation of time-displace observables. For further details, see Sec. 3 of ALF documentation.
1. Import Simulation class from the py_alf python module, which provides the interface with ALF, as well as numerical and plotting packages:
import matplotlib.pyplot as plt # Plotting library
#
import numpy as np # Numerical library
from py_alf import ALF_source, Simulation # Interface with ALF
alf_src = ALF_source(branch='main') # Obtain ALF source codeOutput
Checking out branch main
Your branch is up to date with 'origin/main'.
Already on 'main'
2. Create instances of Simulation, specifying the necessary parameters, in particular the Projector to True:
sims = [] # Vector of Simulation instances
print('Theta values used:')
for theta in [0.1, 0.25, 0.5, 1.0, 2.0, 3.0]: # Values of Theta
print(theta)
sim = Simulation(
alf_src,
'Hubbard', # Hamiltonian
{ # Model and simulation parameters for each Simulation instance
'Model': 'Hubbard', # Base model
'Lattice_type': 'N_leg_ladder', # Lattice type
'L1': 4, # Lattice length in the first unit vector direction
'L2': 1, # Lattice length in the second unit vector direction
'Checkerboard': False, # Whether checkerboard decomposition is used or not
'Symm': True, # Whether symmetrization takes place
'Projector': True, # Whether to use the projective algorithm
'Theta': theta, # Projector parameter
'ham_T': 1.0, # Hopping parameter
'ham_U': 4.0, # Hubbard interaction
'ham_Tperp': 0.0, # For bilayer systems
'beta': 0.5, # Inverse temperature
'Ltau': 0, # '1' for time-displaced Green functions; '0' otherwise
'NSweep': 600, # Number of sweeps per bin
'NBin': 50, # Number of bins
'Dtau': 0.05, # Ltrot=beta/Dtau
'Mz': True, # If true, sets the M_z-Hubbard model: Nf=2, N_sum=1,
}, # HS field couples to z-component of magnetization
)
sims.append(sim)Output
Theta values used:
0.1
0.25
0.5
1.0
2.0
3.0
3. Compile ALF, this may take a few minutes:
sims[0].compile() # Compilation needs to be performed only onceOutput
Compiling ALF...
Cleaning up Prog/
Cleaning up Libraries/
Cleaning up Analysis/
Compiling Libraries
entanglement_mod.F90:35:2:
35 | #warning "You are compiling entanglement without MPI. No results possible"
| 1~~~~~~
Warning: #warning "You are compiling entanglement without MPI. No results possible" [-Wcpp]
ar: creating modules_90.a
ar: creating libqrref.a
Compiling Analysis
Compiling Program
Parsing Hamiltonian parameters
filename: Hamiltonians/Hamiltonian_Kondo_smod.F90
filename: Hamiltonians/Hamiltonian_Hubbard_smod.F90
filename: Hamiltonians/Hamiltonian_Hubbard_Plain_Vanilla_smod.F90
filename: Hamiltonians/Hamiltonian_tV_smod.F90
filename: Hamiltonians/Hamiltonian_LRC_smod.F90
filename: Hamiltonians/Hamiltonian_Z2_Matter_smod.F90
Compiling program modules
Link program
Done.
4. Perform the simulations and display info file, as specified in each element of sim:
for sim in sims:
sim.run() # Perform the actual simulation in ALF
sim.print_info_file() # Display info fileOutput
Prepare directory "/Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=0.1_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True" for Monte Carlo run.
Create new directory.
Run /Users/indra/Documents/ALF/Prog/ALF.out
ALF Copyright (C) 2016 - 2022 The ALF project contributors
This Program comes with ABSOLUTELY NO WARRANTY; for details see license.GPL
This is free software, and you are welcome to redistribute it under certain conditions.
No initial configuration
Setting N_FL = 2 since this is mandatory for Mz-Hubbard model
===== /Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=0.1_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True/info =====
START TIME: 2026-10-06T17:17:14.113+02:00
=====================================
Model is : Hubbard
Lattice is : N_leg_ladder
# unit cells : 4
# of orbitals : 1
Flux_1 : 0.0000000000000000
Flux_2 : 0.0000000000000000
Twist as phase factor in bulk
HS couples to z-component of spin
Checkerboard : F
Symm. decomp : T
Projective version
Theta : 0.10000000000000001
Tau_max : 0.50000000000000000
dtau,Ltrot_eff: 5.0000000000000003E-002 14
N_SUN : 2
N_FL : 2
t : 1.0000000000000000
Ham_U : 4.0000000000000000
Ham_chem : 0.0000000000000000
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
No initial configuration, Seed_in 790789
Sweeps : 600
Bins : 50
No CPU-time limitation
Measure Int. : 3 12
Stabilization,Wrap : 10
Nstm : 2
Ltau : 0
# of interacting Ops per time slice : 4
Default sequential updating
Number of mpi-processes : 1
This executable represents commit 1a56b7fa of branch main.
LOG is defined
Precision Green Mean, Max : 8.2554829183931598E-015 4.3182278151632659E-011
Precision Phase, Max : 7.1892044519119127E-012
Acceptance : 0.41402648809523812
Effective Acceptance : 0.41402648809523812
CPU Time : 5.6831610000000001
FIN TIME: 2026-10-06T17:17:19.813+02:00
Prepare directory "/Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=0.25_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True" for Monte Carlo run.
Create new directory.
Run /Users/indra/Documents/ALF/Prog/ALF.out
ALF Copyright (C) 2016 - 2022 The ALF project contributors
This Program comes with ABSOLUTELY NO WARRANTY; for details see license.GPL
This is free software, and you are welcome to redistribute it under certain conditions.
No initial configuration
Setting N_FL = 2 since this is mandatory for Mz-Hubbard model
===== /Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=0.25_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True/info =====
START TIME: 2026-10-06T17:17:20.716+02:00
=====================================
Model is : Hubbard
Lattice is : N_leg_ladder
# unit cells : 4
# of orbitals : 1
Flux_1 : 0.0000000000000000
Flux_2 : 0.0000000000000000
Twist as phase factor in bulk
HS couples to z-component of spin
Checkerboard : F
Symm. decomp : T
Projective version
Theta : 0.25000000000000000
Tau_max : 0.50000000000000000
dtau,Ltrot_eff: 5.0000000000000003E-002 20
N_SUN : 2
N_FL : 2
t : 1.0000000000000000
Ham_U : 4.0000000000000000
Ham_chem : 0.0000000000000000
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
No initial configuration, Seed_in 790789
Sweeps : 600
Bins : 50
No CPU-time limitation
Measure Int. : 6 15
Stabilization,Wrap : 10
Nstm : 2
Ltau : 0
# of interacting Ops per time slice : 4
Default sequential updating
Number of mpi-processes : 1
This executable represents commit 1a56b7fa of branch main.
LOG is defined
Precision Green Mean, Max : 1.5460118396158495E-014 6.5902281377882927E-011
Precision Phase, Max : 8.8638940726461805E-012
Acceptance : 0.40869812500000002
Effective Acceptance : 0.40869812500000002
CPU Time : 7.6205559999999997
FIN TIME: 2026-10-06T17:17:28.338+02:00
Prepare directory "/Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=0.5_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True" for Monte Carlo run.
Create new directory.
Run /Users/indra/Documents/ALF/Prog/ALF.out
ALF Copyright (C) 2016 - 2022 The ALF project contributors
This Program comes with ABSOLUTELY NO WARRANTY; for details see license.GPL
This is free software, and you are welcome to redistribute it under certain conditions.
No initial configuration
Setting N_FL = 2 since this is mandatory for Mz-Hubbard model
===== /Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=0.5_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True/info =====
START TIME: 2026-10-06T17:17:29.266+02:00
=====================================
Model is : Hubbard
Lattice is : N_leg_ladder
# unit cells : 4
# of orbitals : 1
Flux_1 : 0.0000000000000000
Flux_2 : 0.0000000000000000
Twist as phase factor in bulk
HS couples to z-component of spin
Checkerboard : F
Symm. decomp : T
Projective version
Theta : 0.50000000000000000
Tau_max : 0.50000000000000000
dtau,Ltrot_eff: 5.0000000000000003E-002 30
N_SUN : 2
N_FL : 2
t : 1.0000000000000000
Ham_U : 4.0000000000000000
Ham_chem : 0.0000000000000000
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
No initial configuration, Seed_in 790789
Sweeps : 600
Bins : 50
No CPU-time limitation
Measure Int. : 11 20
Stabilization,Wrap : 10
Nstm : 3
Ltau : 0
# of interacting Ops per time slice : 4
Default sequential updating
Number of mpi-processes : 1
This executable represents commit 1a56b7fa of branch main.
LOG is defined
Precision Green Mean, Max : 1.5816939382935608E-014 1.9593877388031069E-010
Precision Phase, Max : 2.7918339445608183E-011
Acceptance : 0.40501916666666665
Effective Acceptance : 0.40501916666666665
CPU Time : 10.711501999999999
FIN TIME: 2026-10-06T17:17:39.979+02:00
Prepare directory "/Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=1.0_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True" for Monte Carlo run.
Create new directory.
Run /Users/indra/Documents/ALF/Prog/ALF.out
ALF Copyright (C) 2016 - 2022 The ALF project contributors
This Program comes with ABSOLUTELY NO WARRANTY; for details see license.GPL
This is free software, and you are welcome to redistribute it under certain conditions.
No initial configuration
Setting N_FL = 2 since this is mandatory for Mz-Hubbard model
===== /Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=1.0_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True/info =====
START TIME: 2026-10-06T17:17:40.923+02:00
=====================================
Model is : Hubbard
Lattice is : N_leg_ladder
# unit cells : 4
# of orbitals : 1
Flux_1 : 0.0000000000000000
Flux_2 : 0.0000000000000000
Twist as phase factor in bulk
HS couples to z-component of spin
Checkerboard : F
Symm. decomp : T
Projective version
Theta : 1.0000000000000000
Tau_max : 0.50000000000000000
dtau,Ltrot_eff: 5.0000000000000003E-002 50
N_SUN : 2
N_FL : 2
t : 1.0000000000000000
Ham_U : 4.0000000000000000
Ham_chem : 0.0000000000000000
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
No initial configuration, Seed_in 790789
Sweeps : 600
Bins : 50
No CPU-time limitation
Measure Int. : 21 30
Stabilization,Wrap : 10
Nstm : 5
Ltau : 0
# of interacting Ops per time slice : 4
Default sequential updating
Number of mpi-processes : 1
This executable represents commit 1a56b7fa of branch main.
LOG is defined
Precision Green Mean, Max : 1.5509364294465238E-014 1.9403913808464471E-010
Precision Phase, Max : 2.6544694611729281E-011
Acceptance : 0.40201433333333331
Effective Acceptance : 0.40201433333333331
CPU Time : 17.392689000000001
FIN TIME: 2026-10-06T17:17:58.318+02:00
Prepare directory "/Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=2.0_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True" for Monte Carlo run.
Create new directory.
Run /Users/indra/Documents/ALF/Prog/ALF.out
ALF Copyright (C) 2016 - 2022 The ALF project contributors
This Program comes with ABSOLUTELY NO WARRANTY; for details see license.GPL
This is free software, and you are welcome to redistribute it under certain conditions.
No initial configuration
Setting N_FL = 2 since this is mandatory for Mz-Hubbard model
===== /Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=2.0_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True/info =====
START TIME: 2026-10-06T17:17:59.222+02:00
=====================================
Model is : Hubbard
Lattice is : N_leg_ladder
# unit cells : 4
# of orbitals : 1
Flux_1 : 0.0000000000000000
Flux_2 : 0.0000000000000000
Twist as phase factor in bulk
HS couples to z-component of spin
Checkerboard : F
Symm. decomp : T
Projective version
Theta : 2.0000000000000000
Tau_max : 0.50000000000000000
dtau,Ltrot_eff: 5.0000000000000003E-002 90
N_SUN : 2
N_FL : 2
t : 1.0000000000000000
Ham_U : 4.0000000000000000
Ham_chem : 0.0000000000000000
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
No initial configuration, Seed_in 790789
Sweeps : 600
Bins : 50
No CPU-time limitation
Measure Int. : 41 50
Stabilization,Wrap : 10
Nstm : 9
Ltau : 0
# of interacting Ops per time slice : 4
Default sequential updating
Number of mpi-processes : 1
This executable represents commit 1a56b7fa of branch main.
LOG is defined
Precision Green Mean, Max : 1.5392618368986997E-014 2.7152033244131391E-010
Precision Phase, Max : 3.8987144696327908E-011
Acceptance : 0.40105546296296296
Effective Acceptance : 0.40105546296296296
CPU Time : 30.692913999999998
FIN TIME: 2026-10-06T17:18:29.917+02:00
Prepare directory "/Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=3.0_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True" for Monte Carlo run.
Create new directory.
Run /Users/indra/Documents/ALF/Prog/ALF.out
ALF Copyright (C) 2016 - 2022 The ALF project contributors
This Program comes with ABSOLUTELY NO WARRANTY; for details see license.GPL
This is free software, and you are welcome to redistribute it under certain conditions.
No initial configuration
Setting N_FL = 2 since this is mandatory for Mz-Hubbard model
===== /Users/indra/Downloads/ALF_data/Hubbard_N_leg_ladder_L1=4_L2=1_Checkerboard=False_Symm=True_Projector=True_Theta=3.0_T=1.0_U=4.0_Tperp=0.0_beta=0.5_Dtau=0.05_Mz=True/info =====
START TIME: 2026-10-06T17:18:30.886+02:00
=====================================
Model is : Hubbard
Lattice is : N_leg_ladder
# unit cells : 4
# of orbitals : 1
Flux_1 : 0.0000000000000000
Flux_2 : 0.0000000000000000
Twist as phase factor in bulk
HS couples to z-component of spin
Checkerboard : F
Symm. decomp : T
Projective version
Theta : 3.0000000000000000
Tau_max : 0.50000000000000000
dtau,Ltrot_eff: 5.0000000000000003E-002 130
N_SUN : 2
N_FL : 2
t : 1.0000000000000000
Ham_U : 4.0000000000000000
Ham_chem : 0.0000000000000000
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
Degen of right trial wave function: 6.2829267843054593E-002
Degen of left trial wave function: 6.2829267843054593E-002
No initial configuration, Seed_in 790789
Sweeps : 600
Bins : 50
No CPU-time limitation
Measure Int. : 61 70
Stabilization,Wrap : 10
Nstm : 13
Ltau : 0
# of interacting Ops per time slice : 4
Default sequential updating
Number of mpi-processes : 1
This executable represents commit 1a56b7fa of branch main.
LOG is defined
Precision Green Mean, Max : 1.5437358186552447E-014 1.5340505746601957E-009
Precision Phase, Max : 5.5526181084456847E-011
Acceptance : 0.40079660256410254
Effective Acceptance : 0.40079660256410254
CPU Time : 45.519432999999999
FIN TIME: 2026-10-06T17:19:16.408+02:00
5. Calculate the internal energies:
%%capture
ener = np.empty((len(sims), 2)) # Matrix for storing energy values
thetas = np.empty((len(sims),)) # Matrix for Thetas values, for plotting
for i, sim in enumerate(sims):
print(sim.sim_dir) # Directory containing the simulation output
sim.analysis() # Perform default analysis
thetas[i] = sim.sim_dict['Theta'] # Store Theta value
obs = sim.get_obs()
ener[i] = obs.iloc[0][['Ener_scal0', 'Ener_scal0_err']] # Store energy valueOutput
Where the cell magic %%capture suppresses the output of sim.analysis(), which lists the data directories and observables.
print('For Theta values', thetas, 'the measured energies are:\n', ener)Output
For Theta values [0.1 0.25 0.5 1. 2. 3. ] the measured energies are:
[[-1.7036705 0.00333066]
[-1.90927291 0.00304812]
[-2.05352132 0.00463096]
[-2.1085726 0.00680212]
[-2.10894491 0.00828483]
[-2.12211566 0.0074775 ]]
6. Plot the internal energies:
plt.xlabel(r'$\Theta~(1/t)$')
plt.ylabel(r'Energy$~(t)$')
plt.errorbar(thetas, ener[:, 0], ener[:, 1])<ErrorbarContainer object of 3 artists>
6.2.1Exercises¶
A ladder system consists of chains assembled one next to the other, for instance, setting
L1=14,L2=3defines a 3-leg ladder. It is a well-known result (Dagotto and Rice, Science 271, 5249, (1996) pp. 618) that spin correlations in ladder systems decay as power laws (apart from logarithmic corrections) for odd-leg ladders, and exponentially for even-leg ladders. The paper presents numerical results for the Heisenberg model. How do these correlations behave for the Hubbard model at half-filling?
- Dagotto, E., & Rice, T. M. (1996). Surprises on the Way from One- to Two-Dimensional Quantum Magnets: The Ladder Materials. Science, 271(5249), 618–623. 10.1126/science.271.5249.618