Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions assets/js/alps-download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Download tutorial scripts without navigating away from the page.
//
// The scripts live in ALPSim/ALPS, so the links are cross-origin and the HTML
// `download` attribute is ignored. raw.githubusercontent.com sends
// `access-control-allow-origin: *`, so we can fetch the file and hand the
// browser a same-origin blob to save instead.
//
// If the fetch fails (offline, rate limited, file moved) we fall back to
// opening the raw URL in a new tab, so the link is never a dead end.
(function () {
"use strict";

document.addEventListener("click", function (event) {
if (event.defaultPrevented || event.button !== 0) return;
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;

var link = event.target.closest("a.alps-download");
if (!link) return;

event.preventDefault();

var url = link.href;
var filename = link.dataset.filename || url.split("/").pop();

fetch(url)
.then(function (response) {
if (!response.ok) throw new Error("HTTP " + response.status);
return response.blob();
})
.then(function (blob) {
var objectURL = URL.createObjectURL(blob);
var temp = document.createElement("a");
temp.href = objectURL;
temp.download = filename;
document.body.appendChild(temp);
temp.click();
temp.remove();
URL.revokeObjectURL(objectURL);
})
.catch(function () {
window.open(url, "_blank", "noopener");
});
});
})();
8 changes: 4 additions & 4 deletions content/en/tutorials/mcs/mc01a.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This tutorial can be run either on the command line or in Python. We recommend t

### Setting up and running the simulation on the command line

To set up and run the simulation on the command line, we first create a parameter file that specifies the parameters of the simulation(s). The <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-01-autocorrelations/parm1a" download>downloadable file</a> will be titled `parm1a`, with the following contents:
To set up and run the simulation on the command line, we first create a parameter file that specifies the parameters of the simulation(s). The downloadable file will be titled <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-01-autocorrelations/parm1a" data-filename="parm1a" target="_blank" rel="noopener">`parm1a`</a>, with the following contents:

```
LATTICE="square lattice"
Expand Down Expand Up @@ -100,7 +100,7 @@ Look at all six tasks and, by studying the binning analysis in the files `parm1a

The `pyalps` package is a wrapper for ALPS: All it does is call the commands described in the previous section as if they were run in a terminal. It is superior for plotting because the output of the simulation can be read directly into a Python data structure and accessed by `matplotlib`. It also comes with a wrapper `pyalps.plot` for certain matplotlib functions to neatly plot data generated by `pyalps`.

To set up and run the simulation in Python, we create a script named <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-01-autocorrelations/tutorial1a.py" download>`tutorial1a.py`</a>. The first part of this script must import the required modules and prepare the input job and task files. Instead of writing a parameter file and using `convert2xml`, we store a list containing each task's parameters as a dictionary, like so:
To set up and run the simulation in Python, we create a script named <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-01-autocorrelations/tutorial1a.py" data-filename="tutorial1a.py" target="_blank" rel="noopener">`tutorial1a.py`</a>. The first part of this script must import the required modules and prepare the input job and task files. Instead of writing a parameter file and using `convert2xml`, we store a list containing each task's parameters as a dictionary, like so:

```Python
import pyalps
Expand Down Expand Up @@ -197,7 +197,7 @@ We therefore repeat the simulations with cluster updates, using fewer thermaliza

### Command line

The downloadable parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-01-autocorrelations/parm1b" download>`parm1b`</a> has the following contents:
The downloadable parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-01-autocorrelations/parm1b" data-filename="parm1b" target="_blank" rel="noopener">`parm1b`</a> has the following contents:

```
LATTICE="square lattice"
Expand All @@ -224,7 +224,7 @@ spinmc --Tmin 10 --write-xml parm1b.in.xml

### Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-01-autocorrelations/tutorial1b.py" download>`tutorial1b.py`</a> follows the same structure as `tutorial1a.py`, with the updated parameters and `parm1b` as the file prefix:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-01-autocorrelations/tutorial1b.py" data-filename="tutorial1b.py" target="_blank" rel="noopener">`tutorial1b.py`</a> follows the same structure as `tutorial1a.py`, with the updated parameters and `parm1b` as the file prefix:

```Python
import pyalps
Expand Down
4 changes: 2 additions & 2 deletions content/en/tutorials/mcs/mc01b.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Both are checked by inspecting the time series of a measured observable — in t

### Preparing and running the simulation on the command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-01b-equilibration-and-convergence/parm1a" download>`parm1a`</a> sets up a single simulation of the Ising model on a $48 \times 48$ square lattice at the critical temperature:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-01b-equilibration-and-convergence/parm1a" data-filename="parm1a" target="_blank" rel="noopener">`parm1a`</a> sets up a single simulation of the Ising model on a $48 \times 48$ square lattice at the critical temperature:

```
LATTICE="square lattice"
Expand All @@ -44,7 +44,7 @@ spinmc --Tmin 10 --write-xml parm1a.in.xml

### Preparing and running the simulation in Python

The full script is available as <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-01b-equilibration-and-convergence/tutorial1a.py" download>`tutorial1a.py`</a>.
The full script is available as <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-01b-equilibration-and-convergence/tutorial1a.py" data-filename="tutorial1a.py" target="_blank" rel="noopener">`tutorial1a.py`</a>.
It begins by importing the required modules and defining the simulation parameters:

```Python
Expand Down
18 changes: 9 additions & 9 deletions content/en/tutorials/mcs/mc02.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The comparison highlights two key contrasts: how quantum fluctuations modify the

#### Setting up and running on the command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/parm2a" download>`parm2a`</a> sets up simulations of the classical ferromagnetic Heisenberg model on a chain of 60 sites across a range of temperatures:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/parm2a" data-filename="parm2a" target="_blank" rel="noopener">`parm2a`</a> sets up simulations of the classical ferromagnetic Heisenberg model on a chain of 60 sites across a range of temperatures:

```
LATTICE="chain lattice"
Expand Down Expand Up @@ -56,7 +56,7 @@ spinmc --Tmin 10 --write-xml parm2a.in.xml

#### Setting up and running in Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/tutorial2a.py" download>`tutorial2a.py`</a> sets up and runs the same simulation. Place it in the same folder as `parm2a`:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/tutorial2a.py" data-filename="tutorial2a.py" target="_blank" rel="noopener">`tutorial2a.py`</a> sets up and runs the same simulation. Place it in the same folder as `parm2a`:

```Python
import pyalps
Expand Down Expand Up @@ -110,7 +110,7 @@ Aside from the lattice change and the two couplings, the simulation setup is ide

#### Setting up and running on the command line

Download <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/parm2b" download>`parm2b`</a> and place it in the same folder:
Download <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/parm2b" data-filename="parm2b" target="_blank" rel="noopener">`parm2b`</a> and place it in the same folder:

```
LATTICE="ladder"
Expand Down Expand Up @@ -147,7 +147,7 @@ spinmc --Tmin 10 --write-xml parm2b.in.xml

#### Setting up and running in Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/tutorial2b.py" download>`tutorial2b.py`</a> is a copy of `tutorial2a.py` with three changes: the prefix renamed to `parm2b`, `LATTICE` set to `"ladder"`, and `J` replaced by `J0` and `J1` (both `-1`).
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/tutorial2b.py" data-filename="tutorial2b.py" target="_blank" rel="noopener">`tutorial2b.py`</a> is a copy of `tutorial2a.py` with three changes: the prefix renamed to `parm2b`, `LATTICE` set to `"ladder"`, and `J` replaced by `J0` and `J1` (both `-1`).

## Quantum Heisenberg models

Expand All @@ -162,7 +162,7 @@ The key parameter changes, relative to the classical case, are:

#### Setting up and running on the command line

Download <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/parm2c" download>`parm2c`</a>:
Download <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/parm2c" data-filename="parm2c" target="_blank" rel="noopener">`parm2c`</a>:

```
LATTICE="chain lattice"
Expand Down Expand Up @@ -200,7 +200,7 @@ loop parm2c.in.xml

#### Setting up and running in Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/tutorial2c.py" download>`tutorial2c.py`</a> adapts `tutorial2a.py` to the quantum parameters and calls `loop` instead of `spinmc`:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/tutorial2c.py" data-filename="tutorial2c.py" target="_blank" rel="noopener">`tutorial2c.py`</a> adapts `tutorial2a.py` to the quantum parameters and calls `loop` instead of `spinmc`:

```Python
input_file = pyalps.writeInputFiles('parm2c', parms)
Expand All @@ -223,7 +223,7 @@ Unlike the gapless chain, the two-leg antiferromagnetic Heisenberg ladder has a

#### Setting up and running on the command line

Download <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/parm2d" download>`parm2d`</a>:
Download <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/parm2d" data-filename="parm2d" target="_blank" rel="noopener">`parm2d`</a>:

```
LATTICE="ladder"
Expand Down Expand Up @@ -257,11 +257,11 @@ loop parm2d.in.xml

#### Setting up and running in Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/tutorial2d.py" download>`tutorial2d.py`</a> adapts `tutorial2c.py`: rename the prefix to `parm2d`, change `LATTICE` to `"ladder"`, and replace `J` with `J0` and `J1` (both `1`).
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/tutorial2d.py" data-filename="tutorial2d.py" target="_blank" rel="noopener">`tutorial2d.py`</a> adapts `tutorial2c.py`: rename the prefix to `parm2d`, change `LATTICE` to `"ladder"`, and replace `J` with `J0` and `J1` (both `1`).

## Combining all four simulations

After running all four simulations in the same folder, the script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-02-susceptibilities/tutorial2full.py" download>`tutorial2full.py`</a> loads all results together and overlays them on a single plot.
After running all four simulations in the same folder, the script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-02-susceptibilities/tutorial2full.py" data-filename="tutorial2full.py" target="_blank" rel="noopener">`tutorial2full.py`</a> loads all results together and overlays them on a single plot.

```Python
import pyalps
Expand Down
10 changes: 5 additions & 5 deletions content/en/tutorials/mcs/mc03.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The temperature is low enough that the results are close to the ground-state mag

#### Setting up and running on the command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-03-magnetization/parm3a" download>`parm3a`</a>:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-03-magnetization/parm3a" data-filename="parm3a" target="_blank" rel="noopener">`parm3a`</a>:

```
LATTICE="chain lattice"
Expand Down Expand Up @@ -61,7 +61,7 @@ dirloop_sse --Tmin 10 --write-xml parm3a.in.xml

#### Setting up and running in Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-03-magnetization/tutorial3a.py" download>`tutorial3a.py`</a>:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-03-magnetization/tutorial3a.py" data-filename="tutorial3a.py" target="_blank" rel="noopener">`tutorial3a.py`</a>:

```Python
import pyalps
Expand Down Expand Up @@ -114,7 +114,7 @@ We use 20 rungs (40 sites total) and extend the field range to $h = 3.5$ to reac

#### Setting up and running on the command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-03-magnetization/parm3b" download>`parm3b`</a> uses the same structure as `parm3a` with these changes:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-03-magnetization/parm3b" data-filename="parm3b" target="_blank" rel="noopener">`parm3b`</a> uses the same structure as `parm3a` with these changes:

```
LATTICE="ladder"
Expand Down Expand Up @@ -154,7 +154,7 @@ dirloop_sse --Tmin 10 --write-xml parm3b.in.xml

#### Setting up and running in Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-03-magnetization/tutorial3b.py" download>`tutorial3b.py`</a> adapts `tutorial3a.py`: rename the prefix to `parm3b`, change `LATTICE` to `"ladder"`, replace `J` with `J0=J1=1`, and extend the field scan to 3.5.
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-03-magnetization/tutorial3b.py" data-filename="tutorial3b.py" target="_blank" rel="noopener">`tutorial3b.py`</a> adapts `tutorial3a.py`: rename the prefix to `parm3b`, change `LATTICE` to `"ladder"`, replace `J` with `J0=J1=1`, and extend the field scan to 3.5.

#### Evaluating and plotting

Expand All @@ -175,7 +175,7 @@ In contrast to the chain, the ladder magnetization is zero up to a finite lower

## Combining both simulations

After running both simulations in the same folder, the script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-03-magnetization/tutorial3full.py" download>`tutorial3full.py`</a> overlays the two magnetization curves on a single plot:
After running both simulations in the same folder, the script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-03-magnetization/tutorial3full.py" data-filename="tutorial3full.py" target="_blank" rel="noopener">`tutorial3full.py`</a> overlays the two magnetization curves on a single plot:

```Python
import pyalps
Expand Down
4 changes: 2 additions & 2 deletions content/en/tutorials/mcs/mc04.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The small system size allows a fast simulation; finite-size effects are signific

### Command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-04-measurements/parm4" download>`parm4`</a> enables three additional measurement flags alongside the standard parameters:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-04-measurements/parm4" data-filename="parm4" target="_blank" rel="noopener">`parm4`</a> enables three additional measurement flags alongside the standard parameters:

```
MODEL="spin"
Expand Down Expand Up @@ -53,7 +53,7 @@ dirloop_sse --Tmin 10 --write-xml parm4.in.xml

### Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-04-measurements/tutorial4.py" download>`tutorial4.py`</a>:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-04-measurements/tutorial4.py" data-filename="tutorial4.py" target="_blank" rel="noopener">`tutorial4.py`</a>:

```Python
import pyalps
Expand Down
8 changes: 4 additions & 4 deletions content/en/tutorials/mcs/mc05.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Hilbert space is truncated at `Nmax=2` bosons per site, which is a good appr

### Command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-05-bosons/parm5a" download>`parm5a`</a>:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-05-bosons/parm5a" data-filename="parm5a" target="_blank" rel="noopener">`parm5a`</a>:

```
LATTICE="square lattice"
Expand Down Expand Up @@ -58,7 +58,7 @@ worm --Tmin 10 --write-xml parm5a.in.xml

### Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-05-bosons/tutorial5a.py" download>`tutorial5a.py`</a>:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-05-bosons/tutorial5a.py" data-filename="tutorial5a.py" target="_blank" rel="noopener">`tutorial5a.py`</a>:

```Python
import pyalps
Expand Down Expand Up @@ -115,7 +115,7 @@ We simulate three system sizes $L = 4, 6, 8$ on a fine grid of hopping values ar

### Command line

The parameter file <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-05-bosons/parm5b" download>`parm5b`</a>:
The parameter file <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-05-bosons/parm5b" data-filename="parm5b" target="_blank" rel="noopener">`parm5b`</a>:

```
LATTICE="square lattice"
Expand Down Expand Up @@ -159,7 +159,7 @@ worm --Tmin 10 --write-xml parm5b.in.xml

### Python

The script <a href="https://github.com/ALPSim/ALPS/blob/master/tutorials/mc-05-bosons/tutorial5b.py" download>`tutorial5b.py`</a>:
The script <a class="alps-download" href="https://raw.githubusercontent.com/ALPSim/ALPS/master/tutorials/mc-05-bosons/tutorial5b.py" data-filename="tutorial5b.py" target="_blank" rel="noopener">`tutorial5b.py`</a>:

```Python
import pyalps
Expand Down
Loading