MathieuMoalic / amumax

fork of mumax3
Other
8 stars 1 forks source link

Amumax

fork of mumax3 meant to increase the integration with a python processing workflow. I made my own wrapper around zarr called pyzfn which leverages the mumax data in the zarr format.

The solvers ( and results ) are unchanged, this is just list of massive quality of life improvements making working with the output data much more efficient and convenient.

It's not 100% compatible with the original .mx3 files. See changes below.

Installation

Linux

Install script

Don't just run an script on the internet. Read it, check what it does and then you can run this command to install amumax:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/MathieuMoalic/amumax/main/install.sh)"

Manually

Download cufft and curand, unpack and add the shared objects to $PATH, or just install the full CUDA suite with your package manager. Download the latest release:

curl -L https://github.com/mathieumoalic/amumax/releases/latest/download/amumax > amumax
amumax -v

libcurand.so and libcufft.so must either be in the same folder as amumax or on $PATH.

Windows

Differences from mumax3

New way to define the mesh

Tx,Ty,Tz,Nx,Ny,Nz,dx,dy,dz,PBCx,PBCy,PBCz are now predefined variables. You define the Mesh through them. You don't need to call a function to initiate the Mesh, it is automatically done the first time you run a solver but you can't redefine the Mesh after that ! Tx is the total size along the x axis. Nx is the number of cells along the x axis. dx is the number of cells along the x axis. Keep in mind that variables in mx3 script files aren't case sensitive so tx is like Tx for example.

old:

SetGridSize(256,256,10)
SetCellSize(1e-9,1e-9,1e-9)
SetPBC(32,32,0)

new:

Nx = 256
Ny = 256
Nz = 10
dx = 1e-9
dy = 1e-9
dz = 1e-9
PBCx = 32 // Optionnal
PBcy = 32 // Optionnal
PBCz = 0 // Optionnal

new (alternative but equivalent):

Nx = 256
Ny = 256
Nz = 10
Tx = 256e-9
Ty = 256e-9
Tz = 10e-9
PBCx = 32 // Optionnal
PBcy = 32 // Optionnal

Variables that you define are automatically saved:

lattice_constant := 500e-9
ref_paper := "X et al. (2023)"

You can access it in the file .zattrs. Or using pyzfn:

print(job.lattice_constant)
print(job.ref_paper)

You can save data by chunks

Nx = 16
Ny = 32
Nz = 10
Tx = 16e-9
Ty = 32e-9
Tz = 10e-9
SetGeom(Universe())
sampling_interval = 5e-12
AutoSaveAsChunk(m,"m_chunked", sampling_interval, Chunk(1, 1, Nz, 3))
Run(1e-9)

This code will save the magnetization as chunks:

Other changes

Building from source

Using nix:

nix run .#git

Using podman or docker:

git clone https://github.com/MathieuMoalic/amumax
cd amumax
podman run --rm -v $PWD:/src docker.io/oven/bun:1.1.27 bash -c "cd /src/frontend && bun run build && mv /src/frontend/dist /src/api/static"
podman build -t matmoa/amumax:build .
podman run --rm -v $PWD:/src matmoa/amumax:build
./build/amumax -v

The amumax binary and cuda libraries are then found in build.

Manually

You need to install git, bun, go, cuda. Then

git clone https://github.com/MathieuMoalic/amumax
cd frontend
bun install
bun run build
cd ..
mv frontend/dist api/static
export CGO_LDFLAGS="-lcufft -lcuda -lcurand -L/usr/local/cuda/lib64/stubs/ -Wl,-rpath -Wl,\$ORIGIN" 
export CGO_CFLAGS_ALLOW='(-fno-schedule-insns|-malign-double|-ffast-math)'
go build -v .

Contribution

I'm happy to consider any feature request. Don't hesitate to submit issues or PRs.

TODO