Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaFuwa committed Jun 25, 2024
1 parent 6a07e9b commit 6b831af
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 61 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Base.@kwdef mutable struct HMCParameters
hmc_steps::Int64 = 10
hmc_friction::Float64 = 0.0
hmc_integrator::String = "Leapfrog"
hmc_rafriction::Float64 = 1.0
hmc_numsmear_gauge::Int64 = 0
hmc_numsmear_fermion::Int64 = 0
hmc_rhostout_gauge::Float64 = 0.0
Expand All @@ -216,17 +217,20 @@ Base.@kwdef mutable struct GradientFlowParameters
end

Base.@kwdef mutable struct SystemParameters
backend::String = "cpu"
float_type::String = "float64"
ensemble_dir::String = ""
log_to_console::Bool = true
verboselevel::Int64 = 1
loadU_format::String = ""
loadU_dir::String = ""
loadU_fromfile::Bool = false
loadU_filename::String = ""
saveU_format::String = ""
saveU_every::Int64 = 1
save_config_format::String = ""
save_config_every::Int64 = 0
save_checkpoint_format::String = ""
save_checkpoint_every::Int64 = 0
load_config_fromfile::Bool = false
load_config_format::String = ""
load_config_path::String = ""
load_checkpoint_fromfile::Bool = false
load_checkpoint_format::String = "jld2"
load_checkpoint_path::String = ""
randomseed::Union{UInt64,Vector{UInt64}} = 0x0000000000000000
overwrite::Bool = false
end
Expand Down
8 changes: 4 additions & 4 deletions docs/src/dirac.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ and the a Boolean indicating whether there are antiperiodic boundary conditions
direction (yes, only periodic and antiperiodic BCs are supported so far). \\
To create a Dirac operators, use the constructors below. One thing to note is that dirac
operators can be constructed using any `Abstractfield` and so the gauge background is always
set to `nothing`. In order to then add a gauge background, must use the dirac operator as
a functor on a `Gaugefield`, like `D_U = D_free(U)` (This does not overwrite the `U` in
`D_free` but creates a new dirac operator, that references the same temporary fermion field
as the parent).
set to `nothing` on construction. In order to then add a gauge background, must use the
dirac operator as a functor on a `Gaugefield`, like `D_U = D_free(U)` (This does not
overwrite the `U` in `D_free` but creates a new dirac operator, that references the same
temporary fermion field as the parent).

```@docs
WilsonDiracOperator
Expand Down
33 changes: 24 additions & 9 deletions docs/src/gaugefields.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
# Creating Fields on the lattice

To create 4-dimensional SU(3) gauge field, use the constructor `U = Gaugefield(...)`
(see below) and set the initial conditions with `identity_gauges!(U)` or
`random_gauges!(U)`. \\
You can create a 4-dimensional SU(3) gauge field by specifying the backend, floating point
precision, gauge action, dimensions and coupling parameter beta:
```julia
backend = CPU
prec = Float64
action = WilsonGaugeAction
Ns = Nt = 12
beta = 6.0
U = Gaugefield{backend,prec,action}(Ns, Ns, Ns, Nt, beta) # all links are set to 0
```
and set the initial conditions with `identity_gauges!(U)` (cold) or
`random_gauges!(U)` (hot). \\
Gaugefields and the other two fields conatining group/algebra valued elements are structs
that contain a main Array `U`, which is a 5-dimensional array of statically sized 3x3
complex matrices, i.e., `SMatrix` objects from `StaticArrays.jl` (where arrays are stored as
Tuples under the hood. The different backends are handles by `Kernelabstractions.jl` which
Tuples under the hood. The different backends are handled by `Kernelabstractions.jl` which
exports a `zeros` method such that the array can be created on all supported backends with
no extra work. \\
The fact that the elements are statically sized immutable arrays means that, for one, there
are no allocations when performing linear algebra operations with them and second and
secondly, we always just override the matrices in the arrays instead of mutating them. This
are no allocations when performing linear algebra operations with them and secondly that we
always just override the matrices in the arrays instead of mutating them. This
yields enormous benefits in terms of less headaches during development and lets us define
custom linear algebra routines for SMatrices and SVectors. \\

Expand All @@ -27,16 +36,22 @@ struct called `EvenOdd` such that we can overload all functions on that type. Ou
is to define the fields on the even sites. While we haven't tested whether the following is
actually more performant, we map all even sites to the first half of the array to have
contiguous memory accesses. The function `eo_site` does exactly this mapping. \\
For `Fermionfield`s we have the `ones!` and `gaussian_pseudofermions!` methods to init them.
`Fermionfield`s are created in the same way as `Gaugefield`s bar the gauge action type
parameter. For `Fermionfield`s we have the `ones!` and `gaussian_pseudofermions!` methods
to init them.

```@docs
Gaugefield
```

```@docs
Temporaryfield
Fermionfield
```

```@docs
Colorfield
```

```@docs
CoeffField
Expfield
```
30 changes: 3 additions & 27 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Inspired by the [LatticeQCD.jl](https://github.com/akio-tomiya/LatticeQCD.jl/tre
- Staggered fermions
- Even-odd preconditioner
- RHMC to simulate odd number of flavours
- Support for CUDA and ROCm backends
- Support for CUDA and ROCm(not tested) backends

## Installation:
First make sure you have a Julia version 1.9.x or 1.10.x installed. You can use [juliaup](https://github.com/JuliaLang/juliaup) for that or just install the release from the [Julia website](https://julialang.org/downloads/).

The package in not in the general registry. So you will have to either
The package is not in the general registry. So you will have to either
- Add the package to your Julia environment (**not recommended**) via:
```
julia> ] add https://github.com/GianlucaFuwa/MetaQCD.jl
Expand All @@ -48,28 +48,4 @@ or
pkg> instantiate
```

If you want to use a GPU, make sure you not only have CUDA.jl or AMDGPU.jl installed, but also a fairly recent version of the CUDA Toolkit or ROCm.

## Quick Start:
1. Set parameters using one of the templates in template folder
2. From shell, do:
```
julia --threads=auto run.jl parameters.toml
```

or

2. Start Julia (with project):
```
julia --threads=auto --project
```
3. Import MetaQCD package:
``` julia
using MetaQCD
```
4. Begin Simulation with prepared parameter file "parameters.toml":
``` julia
run_sim("parameters.toml")
```

If you want to use a GPU, make sure you not only have CUDA.jl or AMDGPU.jl installed, but also a fairly recent version of the CUDA Toolkit or ROCm.
If you want to use a GPU, make sure you not only have CUDA.jl (v4.4.2) or AMDGPU.jl installed, but also a fairly recent version of the CUDA Toolkit or ROCm.
18 changes: 11 additions & 7 deletions docs/src/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Base.@kwdef mutable struct HMCParameters
hmc_steps::Int64 = 10
hmc_friction::Float64 = 0.0
hmc_integrator::String = "Leapfrog"
hmc_rafriction::Float64 = 1.0
hmc_numsmear_gauge::Int64 = 0
hmc_numsmear_fermion::Int64 = 0
hmc_rhostout_gauge::Float64 = 0.0
Expand All @@ -100,17 +101,20 @@ Base.@kwdef mutable struct GradientFlowParameters
end

Base.@kwdef mutable struct SystemParameters
backend::String = "cpu"
float_type::String = "float64"
ensemble_dir::String = ""
log_to_console::Bool = true
verboselevel::Int64 = 1
loadU_format::String = ""
loadU_dir::String = ""
loadU_fromfile::Bool = false
loadU_filename::String = ""
saveU_format::String = ""
saveU_every::Int64 = 1
save_config_format::String = ""
save_config_every::Int64 = 0
save_checkpoint_format::String = ""
save_checkpoint_every::Int64 = 0
load_config_fromfile::Bool = false
load_config_format::String = ""
load_config_path::String = ""
load_checkpoint_fromfile::Bool = false
load_checkpoint_format::String = "jld2"
load_checkpoint_path::String = ""
randomseed::Union{UInt64,Vector{UInt64}} = 0x0000000000000000
overwrite::Bool = false
end
Expand Down
6 changes: 6 additions & 0 deletions docs/src/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The first positional is the actual update algorithm
U = Gaugefield(...)
random_gauges!(U)

MAXIT = 100
numHB = 1
or_alg = MeatQCD.Updates.Subgroups
numOR = 4
update_alg = MeatQCD.Updates.Heatbath(U, MAXIT, numHB, or_alg, numOR)

update!(update_alg, U; ...)
```

Expand Down
45 changes: 42 additions & 3 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,63 @@ If you just want to perform a simulation with some parameters, then
1. Set parameters using one of the templates in template folder
2. From shell, do:
```
julia --threads=auto run.jl parameters.toml
julia --threads=auto metaqcd_sim.jl parameters.toml
```

or

2. Start Julia (with project):
```
julia --threads=auto --project
julia --threads=auto --project=/path/to/dir/containing/MetaQCD.jl
```
3. Import MetaQCD package (this may prompt you to install dependencies):
3. Import MetaQCD package:
``` julia
using MetaQCD
```
4. Begin Simulation with prepared parameter file "parameters.toml":
``` julia
run_sim("parameters.toml")
```
To use another backend, just append its name to the command:
```
julia --threads=auto metaqcd_sim.jl parameters.toml cuda
```

Logs, measurements and the lot are all written to files in the `ensembles` directory under
the specified directory name. If no directory name is provided, one is generated based on
time the simulation was started at.

## Build a Bias:
1. Set parameters using the "parameters_build.toml" example in template folder
2. From shell, do:
```
julia --threads=auto metaqcd_build.jl parameters.toml
```

or

2. Start Julia (with project):
```
julia --threads=auto --project=/path/to/dir/containing/MetaQCD.jl
```
3. Import MetaQCD package:
``` julia
using MetaQCD
```
4. Begin build with prepared parameter file "parameters.toml":
``` julia
build_bias("parameters.toml")
```

## Visualization:
We include the ability to visualize your data. For that, you just have to pass the directory where your ensemble lives:
```julia
pkg> measurements = MetaMeasurements("my_ensemble")
pkg> timeseries(measurements, :my_observable)
```

You can also create a holder of a bias potential and plot it. MetaQCD.jl creates the bias files with an extension that gives their type (.metad or .opes), but if you changed the extension you have to provide the bias type as a symbol under the kwarg `which`:
```julia
bias = MetaBias(myfile, which=:mytype)
biaspotential(bias)
```
7 changes: 4 additions & 3 deletions docs/src/viz.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ ens = "my_ensemble"
measurements = MetaMeasurements(ens)
```

Now we can plot a timeseries of any observables measured on the ensemble via the
Now we can plot a timeseries of any observables at flow time `tf` measured on the ensemble
via the
`timeseries` method:
```julia
timeseries(measurements, :myobservable)
timeseries(measurements, :myobservable, tf=0)
```

For hadron correlators there is a special function `hadroncorrelator` that plots the
mean values of all time slices (without statistical uncertainties). Just specify the hadron
whose correlator you want to see:
```julia
hadroncorrelator(measurements, :pion; logscale=true, calc_meff=false, tf=0.0)
hadroncorrelator(measurements; logscale=true, calc_meff=false, tf=0.0)
```

You can also create a holder of a bias potential and plot it. MetaQCD.jl creates the bias
Expand Down
2 changes: 1 addition & 1 deletion src/viz/Viz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ end
@userplot HadronCorrelator

"""
hadroncorrelator(m::MetaMeasurements, correlator::Symbol)
hadroncorrelator(m::MetaMeasurements, corr::Symbol; logscale=false, style=:line, tf=0)
Plot the effective mass plot of the hadron correlator `correlator` from the measurements in `m`.
"""
Expand Down

0 comments on commit 6b831af

Please sign in to comment.