{"id":19872439,"url":"https://github.com/davidace/wl","last_synced_at":"2025-06-27T05:42:13.820Z","repository":{"id":43142528,"uuid":"64013725","full_name":"DavidAce/WL","owner":"DavidAce","description":"Wang-Landau Algorithm, with histogram saturation, 1/t algorithm, MPI-parallelism and adaptive energy sub-windows.","archived":false,"fork":false,"pushed_at":"2022-09-16T13:55:37.000Z","size":3071,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T00:58:40.766Z","etag":null,"topics":["1-over-t","entropic-sampling","monte-carlo","mpi","physics","wang-landau-algorithm"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavidAce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-23T11:44:00.000Z","updated_at":"2024-01-21T10:22:52.000Z","dependencies_parsed_at":"2023-01-18T10:17:43.975Z","dependency_job_id":null,"html_url":"https://github.com/DavidAce/WL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DavidAce/WL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAce%2FWL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAce%2FWL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAce%2FWL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAce%2FWL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavidAce","download_url":"https://codeload.github.com/DavidAce/WL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidAce%2FWL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262201297,"owners_count":23274333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["1-over-t","entropic-sampling","monte-carlo","mpi","physics","wang-landau-algorithm"],"created_at":"2024-11-12T16:15:38.064Z","updated_at":"2025-06-27T05:42:13.792Z","avatar_url":"https://github.com/DavidAce.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Ubuntu 22.04](https://github.com/DavidAce/WL/actions/workflows/ubuntu-22.04.yml/badge.svg?branch=master)](https://github.com/DavidAce/WL/actions/workflows/ubuntu-22.04.yml)\n\n# Wang-Landau Algorithm\n\nThe Wang-Landau algorithm estimates the Density of States (DOS) of discrete models as function of energy and (optionally) magnetization,\noften denoted `g(E)` (or `g(E,M)`) in physics litterature.\n\nThe DOS can give us all the thermodynamic averages by differentiating the partition function `Z= Σ_E g(E,M)exp(-βE)`.\n\nBy default, this program will generate the DOS for a 10x10 2D Ising model. \n\n### In short\nIndependent \"random walkers\" build up the DOS by sampling the phase space while keeping a histogram of visited energies. The probability of \ntaking the next step in phase space depends on the current value of the DOS and the value at the next point. \n\nAt each step of the random walk the DOS at the current energy and magnetization is incremented\nby a modification factor `f`, which starts out as `f=exp(1)`. A stage of the simulation runs until the convergence condition is met, which is when the random walker visits\nenergies with uniform probability, meaning that the histogram is roughly flat. When that happens, the next stage starts with a smaller modification factor,\n`f=exp(0.5)` and runs until the convergence condition is met again. \n\nReducing the modification factor throughout many stages allows the DOS to become\nsmoother and smoother. The simulation ends when the modification factor reaches a very small value, such as `f = f_min = 1e-7`.\n\n \n### Parallelization \nThe algorithm is parallelized by splitting the DOS into overlapping energy windows, and each MPI is assigned a window. The processes perform \nindependent random walks within their own window, but can with a small probability swap windows with other threads. This is to avoid threads becoming\nstuck for too long in one place, which would ruin the smoothness of the DOS.\n\nSome energy windows may reach `f_min` quicker than others, in which case the \"finished\" processes cease their random walks and go\njoin another window, to help that part of the DOS converge quicker. \n\n## Minimum Requirements\n\nThe following software is required to build the project:\n\n- C++17 compiler. Tested with:\n    * *To build dependencies*: Fortran compiler\n- CMake version \u003e= 3.20.\n\n## Dependencies\n\n- [**Eigen**](http://eigen.tuxfamily.org) for tensor and matrix and linear algebra (tested with version \u003e= 3.3).\n- [**h5pp**](https://github.com/DavidAce/h5pp) a wrapper for HDF5.\n- [**fmt**](https://github.com/fmtlib/fmt) for formatting strings (bundled with h5pp).\n- [**spdlog**](https://github.com/gabime/spdlog) for logging (bundled with h5pp).\n- [**CLI11**](https://github.com/CLIUtils/CLI11) For parsing input arguments (WIP).\n- [**OpenMPI**](https://www.open-mpi.org/) For parallelization. On Ubuntu/Debian systems, install with  `sudo apt install openmpi-bin libopenmpi-dev` \n\n\n## Build\nThe simplest way to build is to use a CMake preset. Some common presets are found in `CMakePresets.json`, \nwhich can serve as a starting point for generating your own in `CMakeUserPresets.json`. \n[Read more](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html).\n\nTo list available presets, run\n\n```\ncmake --list-presets\n```\n\nSelecting a preset, for example `release-gcc-11-native-cmake`, which sets the `-march=native` compiler flag and uses\n`WL_PACKAGE_MANAGER=cmake`, to use CMake exclusively to build the dependency tree. To configure and build, run\n\n```\ncmake --preset=release-gcc-11-native-cmake\ncmake --build --preset=release-gcc-11-native-cmake\n```\n\nUse the CMake argument `WL_PACKAGE_MANAGER=\u003cfind|cmake|cpm|conan\u003e` to choose how WL handles dependencies. \nThe option `find` (default) will simply call `find_package(...)` for all dependencies, and leave their installation\nup to the user. \n\nThe CMake flag `WL_PACKAGE_MANAGER` controls the automated behavior for finding or installing dependencies. It can\ntake one of these string values:\n\n| Value                | Description                                                                                                                                         |\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `find` **(default)** | Use CMake's `find_package` to find dependencies                                                                                                     |\n| `cmake` **¹**        | Use isolated CMake instances to install dependencies during configure. Disregards pre-installed dependencies on your system             |\n| `cpm`                | Use [CPM](https://github.com/cpm-cmake/CPM.cmake) to install dependencies. Disregards pre-installed dependencies on your system         |\n| `conan` **²**        | Use the [Conan package manager](https://conan.io/) to install dependencies automatically. Disregards libraries elsewhere on your system |\n\nThere are several variables you can pass to CMake to guide `find_package` calls and install location,\nsee [CMake options](#cmake-options) below.\n\n**¹** Dependencies are installed into `${WL_PKG_INSTALL_DIR}`.\n\n**²** Conan is guided by `conanfile.txt` found in this project's root directory. This method requires conan to be\ninstalled prior (for instance through `pip`, `conda`, `apt`, etc). To let CMake find conan you have three options:\n* \n* Add Conan install (or bin) directory to the environment variable `PATH`.\n* Export Conan install (or bin) directory in the environment variable `CONAN_PREFIX`, i.e. from command\n  line: `export CONAN_PREFIX=\u003cpath-to-conan\u003e`\n* Give the variable `CONAN_PREFIX` directly to CMake, i.e. from command\n  line: `cmake -DCONAN_PREFIX:PATH=\u003cpath-to-conan\u003e ...`\n\n## Run\nThe scripts `run*.sh` show example usage. By default `./run.sh` will run a simulation with `mpirun`\nusing 4 cores.\n\nAll parameters are defined at compile time, by modifying them in the header file `source/params/nmspc_WL_constants.h`.\nPlease refer to the comments in that file to learn more.\n\n\n## Output data\n\nAll output data is placed under the `outdata/` folder as text files.\n \nIn subfolders numbered `outdata/0/` to `outdata/N-1/`, where `N` is the number of MPI threads that were run. \nThese subfolders contain their corresponding part of the DOS and some thermodynamic data\nused for the final averaged results.  \n\nThe folder `outdata/final/`  contains the main results, in the form of thermodynamic averages and corresponding error\nestimates from made from bootstrapping portions of the DOS. For the bootstrap to be meaningful, you need to run multiple simulations. You can\ncontrol the number of independent simulations with the parameter `simulation_reps` found in the header file `source/params/nmspc_WL_constants.h`.\n \nEnable `constants::collect_samples` to obtain a subfolder `outdata/samples/` containing lattice samples that are uniformly\ndistributed in energy and magnetization. This is useful for generating training data for machine learning algorithms, for instance.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidace%2Fwl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidace%2Fwl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidace%2Fwl/lists"}