Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3 A minimal ALF run

In this bare-bones example we use the pyALF interface to run the canonical Hubbard model on a default configuration: a 6×66\times6 square grid, with interaction strength U=4U=4 and inverse temperature β=5\beta = 5.

Bellow we go through the steps for performing the simulation and outputting observables.


1. Import ALF_source and Simulation classes from the py_alf python module, which provide the interface with ALF:

2. Create an instance of ALF_source, downloading the ALF source code from the ALF repository, if alf_dir does not exist. Gets alf_dir from environment variable $ALF_DIR, or defaults to “./ALF”, if not present:

Output
Checking out branch master
Your branch is up to date with 'origin/master'.
Switched to branch 'master'

3. Create an instance of Simulation, overwriting default parameters as desired:

4. Compile ALF. The first time it will also download and compile HDF5, which could take ∼15\sim15 minutes.

Output
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.

5. Perform the simulation as specified in sim:

Output
Prepare directory "/home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square" for Monte Carlo run.
Create new directory.
Run /home/jonas/Programs/ALF/Prog/ALF.out
 ALF Copyright (C) 2016 - 2021 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

6. Perform some simple analysis:

Output
### Analyzing /home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square ###
/home/jonas/Programs/pyALF/Notebooks
Scalar observables:
Ener_scal
Kin_scal
Part_scal
Pot_scal
Histogram observables:
Equal time observables:
Den_eq
Green_eq
SpinT_eq
SpinXY_eq
SpinZ_eq
Time displaced observables:
Den_tau
Green_tau
SpinT_tau
SpinXY_tau
SpinZ_tau

7. Read analysis results into a Pandas Dataframe with one row per simulation, containing parameters and observables:

Output
/home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square
No orbital locations saved.
Output
Loading...

∙\bullet The internal energy of the system (and its error) are accessed by:

Output
Ener_scal0 -29.821914 Ener_scal0_err 0.13032 Ener_scal_sign 1.0 Ener_scal_sign_err 0.0 Name: /home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square, dtype: object

∙\bullet The simulation can be resumed by calling sim.run() again, increasing the precision of results:

Output
Prepare directory "/home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square" for Monte Carlo run.
Resuming previous run.
Run /home/jonas/Programs/ALF/Prog/ALF.out
 ALF Copyright (C) 2016 - 2021 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.
### Analyzing /home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square ###
/home/jonas/Programs/pyALF/Notebooks
Scalar observables:
Ener_scal
Kin_scal
Part_scal
Pot_scal
Histogram observables:
Equal time observables:
Den_eq
Green_eq
SpinT_eq
SpinXY_eq
SpinZ_eq
Time displaced observables:
Den_tau
Green_tau
SpinT_tau
SpinXY_tau
SpinZ_tau
/home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square
No orbital locations saved.
Ener_scal0 -29.609245 Ener_scal0_err 0.136803 Ener_scal_sign 1.0 Ener_scal_sign_err 0.0 Name: /home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square, dtype: object
Output

Running again reduced the error from
 Ener_scal0_err    0.13032
Name: /home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square, dtype: object 
to
 Ener_scal0_err    0.136803
Name: /home/jonas/Programs/pyALF/Notebooks/ALF_data/Hubbard_Square, dtype: object

Note: To run a fresh simulation - instead of performing a refinement over previous run(s) - the Monte Carlo run directory should be deleted before rerunning.


3.1Exercises

  1. Check info/help commands such as help(alf_src), alf_src.get_ham_names(), and alf_src.get_default_params('Hubbard').

  2. Rerun once again and check the new improvement in precision.

  3. Look at a few other observables (sim.analysis() outputs the names of those available).

  4. Change the lattice size by adding, e.g., \"L1\": 4, and \"L2\": 1, to the simulation parameters definitions of sim (step 2).