Skip to content

Commit

Permalink
final touches before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tjira committed Dec 24, 2024
1 parent bda8093 commit a2d186e
Show file tree
Hide file tree
Showing 24 changed files with 387 additions and 28,444 deletions.
37 changes: 8 additions & 29 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,26 @@ Below are all the important features of Acorn divided into categories.
### Quantum Mechanical Methods

* Numerically Exact Adiabatic & Nonadiabatic Quantum Dynamics with Arbitrary Number of States & Dimensions
* Restricted Hartree–Fock for Closed Shell & Generalized Hartree–Fock for Open Shell Systems
* Møller–Plesset Perturbation Theory, Configuration Interaction & Coupled Cluster Methods
* Restricted Hartree–Fock, Møller–Plesset Perturbation Theory & Configuration Interaction Methods

## Compilation

All the libraries the program needs are included in the installation script. To install all the libraries, navigate to the project root directory and execute the following command.
Since the software is coded in zig, you need to have the zig compiler installed on your system. You can download the latest version of the zig compiler from the [official website](https://ziglang.org/download). After you have installed the zig compiler, navigate to the project root and run the following command to compile the project.

```bash
./script/general/library.sh SHARED 1
zig build --release=fast --summary all
```

You can also perform a static compilation. The number at the end is number of cores the compilation process uses. The program needs some heavy libraries so it takes some time. After the library compilation finishes, all the header files and compiled libraries can be found in the *external* directory. If you don't want to wait for the compilation process, you can also download libraries used in the latest release by running the following command.
This will compile the project and create a binary file named `acorn` in the `zig-out/arch-os/acorn` folder, where `arch` is the architecture of your system and `os` is the operating system you are using. You can also perform tests on the project by running the following command.

```bash
./script/general/libdown.sh SHARED
zig build --release=fast --summary all test
```

This command also creates the *external* directory with libraries. After you have obtained the compiled libraries, configure the project by the following command.
If some tests fail, let me know by creating an issue. If all the tests pass, you can run the binary file using the following command.

```bash
cmake -B build -DCMAKE_BUILD_TYPE=Release -DSTATIC=OFF
./zig-out/arch-os/acorn
```

And build with the following command.

```bash
cmake --build build
```

After the compilation, the bin folder will be created along with the executable.

## Examples

All the examples are located in `example/input` folder. To run an example Hartree-Fock calculation, execute the corresponding example file using the `acorn -i example/input/hf.json` command from the project root. Feel free to explore all the examples.

## Credits

* [argparse](https://github.com/p-ranav/argparse) - Argument Parser for Modern C++.
* [eigen](https://gitlab.com/libeigen/eigen) - C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
* [exprtk](https://github.com/ArashPartow/exprtk) - C++ Mathematical Expression Parsing and Evaluation Library.
* [fftw](https://www.fftw.org) - C Subroutine Library for Computing the Discrete Fourier Transform.
* [json](https://github.com/nlohmann/json) - JSON for Modern C++.
* [libint](https://github.com/evaleev/libint) - High-Performance Library for Computing Gaussian Integrals in Quantum Mechanics.
* [pytorch](https://github.com/pytorch/pytorch) - Tensors and Dynamic neural networks in Python with strong GPU acceleration.
You should see the version of the compiler and execution time of the program. If you see this, the program is working correctly.
156 changes: 50 additions & 106 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,153 +12,97 @@ env:
BUILD_TYPE: Release

jobs:
build-libs_linux-shared_x86-64:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Install System Packages
run: sudo apt install libwayland-dev libxkbcommon-dev xorg-dev

- name: Install Python Packages
run: pip install typing-extensions

- name: Download and Compile Libraries
run: ./script/general/library.sh SHARED 2

- name: Remove Redundant Files
run: rm -rf external/lib/cmake external/lib/pkgconfig external/lib/*.la external/include/*.f03

- name: Package the Libraries
run: cd external && tar -czf acorn-libs_linux-shared_x86-64.tar.gz * && cd -

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: libs_linux-shared
path: external/acorn-libs_linux-shared_x86-64.tar.gz

build-libs_linux-static_x86-64:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Install System Packages
run: sudo apt install libwayland-dev libxkbcommon-dev xorg-dev

- name: Install Python Packages
run: pip install typing-extensions

- name: Download and Compile Libraries
run: ./script/general/library.sh STATIC 2

- name: Remove Redundant Files
run: rm -rf external/lib/cmake external/lib/pkgconfig external/lib/*.la external/include/*.f03

- name: Package the Libraries
run: cd external && tar -czf acorn-libs_linux-static_x86-64.tar.gz * && cd -

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: libs_linux-static
path: external/acorn-libs_linux-static_x86-64.tar.gz

build-acorn_linux-shared_x86-64:
runs-on: ubuntu-22.04
needs: [build-libs_linux-shared_x86-64]

steps:
- uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Extract the Libraries
run: mkdir external && mv libs_linux-shared/acorn-libs_linux-shared_x86-64.tar.gz external/ && cd external && tar -xzf acorn-libs_linux-shared_x86-64.tar.gz && cd -

- name: Configure Acorn
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGRAPHIC=OFF -DSTATIC=OFF
- name: Download Zig Compiler
run: mkdir bin && wget -O zig.tar.xz https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz && tar -xvf zig.tar.xz && mv zig-linux*/lib zig-linux*/zig bin && rm -rf zig*

- name: Build Acorn
run: cmake --build build --parallel 2 --verbose
run: ./bin/zig build --release=fast --summary all

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-shared
path: bin/acorn

build-acorn_linux-static_x86-64:
runs-on: ubuntu-22.04
needs: [build-libs_linux-static_x86-64]

steps:
- uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Extract the Libraries
run: mkdir external && mv libs_linux-static/acorn-libs_linux-static_x86-64.tar.gz external/ && cd external && tar -xzf acorn-libs_linux-static_x86-64.tar.gz && cd -

- name: Configure Acorn
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGRAPHIC=OFF -DSTATIC=ON

- name: Build Acorn
run: cmake --build build --parallel 2 --verbose
- name: Rename Binaries
run: cd zig-out && for FOLDER in *; do mv $FOLDER/acorn $FOLDER/acorn-$FOLDER; done

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-static
path: bin/acorn
name: acorn
path: |
zig-out/aarch64-linux/acorn-aarch64-linux
zig-out/aarch64-macos/acorn-aarch64-macos
zig-out/aarch64-windows/acorn-aarch64-windows.exe
zig-out/arm-linux/acorn-arm-linux
zig-out/riscv64-linux/acorn-riscv64-linux
zig-out/x86-64-linux/acorn-x86-64-linux
zig-out/x86-64-macos/acorn-x86-64-macos
zig-out/x86-64-windows/acorn-x86-64-windows.exe
release:
runs-on: ubuntu-latest
needs: [build-acorn_linux-shared_x86-64, build-acorn_linux-static_x86-64]
needs: [build]

steps:
- uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Remove Redundant Scripts
run: rm basis/update.sh example/molecule/generate.sh
- name: Release aarch64-linux Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: acorn/acorn-aarch64-linux
tag: ${{github.ref}}

- name: Release aarch64-macos Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: acorn/acorn-aarch64-macos
tag: ${{github.ref}}

- name: Create x86-64 Linux Shared Packages
run: cp linux-shared/acorn . && tar -czf acorn_linux-shared_x86-64.tar.gz acorn basis example script/plot LICENSE.md
- name: Release aarch64-windows Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: acorn/acorn-aarch64-windows.exe
tag: ${{github.ref}}

- name: Create x86-64 Linux Static Packages
run: cp linux-static/acorn . && tar -czf acorn_linux-static_x86-64.tar.gz acorn basis example script/plot LICENSE.md
- name: Release arm-linux Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: acorn/acorn-arm-linux
tag: ${{github.ref}}

- name: Release linux-shared_x86-64 Version of Acorn
- name: Release riscv64-linux Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: acorn_linux-shared_x86-64.tar.gz
file: acorn/acorn-riscv64-linux
tag: ${{github.ref}}

- name: Release linux-static_x86-64 Version of Acorn
- name: Release x86-64-linux Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: acorn_linux-static_x86-64.tar.gz
file: acorn/acorn-x86-64-linux
tag: ${{github.ref}}

- name: Release linux-shared_x86-64 Version of Acorn Libraries
- name: Release x86-64-macos Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: libs_linux-shared/acorn-libs_linux-shared_x86-64.tar.gz
file: acorn/acorn-x86-64-macos
tag: ${{github.ref}}

- name: Release linux-static_x86-64 Version of Acorn Libraries
- name: Release x86-64-windows Version of Acorn
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: libs_linux-static/acorn-libs_linux-static_x86-64.tar.gz
file: acorn/acorn-x86-64-windows.exe
tag: ${{github.ref}}
49 changes: 4 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,18 @@ on:
permissions:
contents: write

env:
BUILD_TYPE: Debug

jobs:
build-libs_linux-shared_x86-64:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Install System Packages
run: sudo apt install libwayland-dev libxkbcommon-dev xorg-dev

- name: Install Python Packages
run: pip install typing-extensions

- name: Download and Compile Libraries
run: ./script/general/library.sh SHARED 2

- name: Remove Redundant Files
run: rm -rf external/lib/cmake external/lib/pkgconfig external/lib/*.la external/include/*.f03

- name: Package the Libraries
run: cd external && tar -czf acorn-libs_linux-shared_x86-64.tar.gz * && cd -

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: libs_linux-shared
path: external/acorn-libs_linux-shared_x86-64.tar.gz

test_linux-shared_x86-64:
test_linux:
runs-on: ubuntu-22.04
needs: [build-libs_linux-shared_x86-64]

steps:
- uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Extract the Libraries
run: mkdir external && mv libs_linux-shared/acorn-libs_linux-shared_x86-64.tar.gz external/ && cd external && tar -xzf acorn-libs_linux-shared_x86-64.tar.gz && cd -

- name: Configure Acorn
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGRAPHIC=OFF -DSTATIC=OFF

- name: Build Acorn
run: cmake --build build --parallel 2 --verbose
- name: Download Zig Compiler
run: mkdir bin && wget -O zig.tar.xz https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz && tar -xvf zig.tar.xz && mv zig-linux*/lib zig-linux*/zig bin && rm -rf zig*

- name: Run Tests
working-directory: build
run: ctest --verbose
run: ./bin/zig build --release=fast --summary all test

- name: Upload Coverage Reports
uses: codecov/codecov-action@v4.0.1
Expand Down
9 changes: 4 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const std = @import("std");

const targets: []const std.Target.Query = &.{
.{.os_tag = .linux , .cpu_arch = .aarch64},
.{.os_tag = .linux , .cpu_arch = .arm },
.{.os_tag = .linux , .cpu_arch = .riscv64},
.{.os_tag = .linux , .cpu_arch = .x86_64 },
.{.os_tag = .windows, .cpu_arch = .aarch64},
.{.os_tag = .windows, .cpu_arch = .x86_64 },
Expand All @@ -14,7 +16,7 @@ pub fn build(builder: *std.Build) !void {

for (targets) |target| {

const executable = builder.addExecutable(.{
const main_executable = builder.addExecutable(.{
.name = "acorn",
.optimize = optimize,
.root_source_file = builder.path("src/main.zig"),
Expand All @@ -23,17 +25,14 @@ pub fn build(builder: *std.Build) !void {
.target = builder.resolveTargetQuery(target)
});

const output = builder.addInstallArtifact(executable, .{
const output = builder.addInstallArtifact(main_executable, .{
.dest_dir = .{.override = .{.custom = try target.zigTriple(builder.allocator)}}
});

builder.getInstallStep().dependOn(&output.step);
}

const test_filters = builder.option([]const []const u8, "test", "Select only specific tests") orelse &[0][]const u8{};

const test_executable = builder.addTest(.{
.filters = test_filters,
.optimize = optimize,
.root_source_file = builder.path("test/main.zig"),
.single_threaded = true,
Expand Down
3 changes: 0 additions & 3 deletions example/diagram/mbpt2.txt

This file was deleted.

5 changes: 0 additions & 5 deletions example/diagram/mbpt3.txt

This file was deleted.

Loading

0 comments on commit a2d186e

Please sign in to comment.