Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fidimag great again #138

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f27295d
Port Fidimag to C++
rpep May 9, 2019
53722a8
Switch to C++ complex proper
rpep May 9, 2019
a3e0f6e
Remove accidentally committed cython generated sources
rpep May 9, 2019
1437040
Fix various tiny bugs which caused warnings in Pytest
rpep May 9, 2019
ef1a64d
Simplify setup.py by removing regex search for version, moving out so…
rpep May 9, 2019
ca06d0f
Fix bug in tools.py with module_name not defined
rpep May 9, 2019
7e42a94
Move micro C++ files to native directory and resolve duplicate functi…
rpep May 9, 2019
f8b6107
Move common and atomistic to native directory
rpep May 9, 2019
22ceb97
Refactor all Python code so that tests pass with new extensions location
rpep May 10, 2019
5f698a4
Fix linker bug on MacOS
rpep May 10, 2019
d9b1045
Set Makefile to appropriate defaults for Linux
rpep May 10, 2019
f25964a
Pass through directly the CPPFLAGS argument to setup.py
rpep May 10, 2019
8307070
Tweak some of the setup
rpep May 10, 2019
ed68830
Consolidate vector mathematics into a single C++ file native/c_vector…
rpep May 10, 2019
16534ec
Add c_vectormath.h
rpep May 10, 2019
a263c83
Switch to using pragma once for header files, and replace multiple de…
rpep May 10, 2019
27e4891
Add C++ Energy class
rpep May 10, 2019
53db2c5
Updated Ubuntu version in Docker
May 10, 2019
e273782
Add constants file to avoid issues on macOS with M_PIl not being defined
rpep May 11, 2019
a1256a6
Add initial Energy class implementation
rpep May 13, 2019
3f1d3a8
Removed empty file
davidcortesortuno May 17, 2019
09ad07e
Implementing a Cython wrapper for the C++ energy class, only Exchange…
davidcortesortuno May 17, 2019
0a431b6
Added test for new energy class wrapper
davidcortesortuno Jun 6, 2019
d4132dc
Fixed cython interface to c++ energy classes
davidcortesortuno Jun 7, 2019
fa53fec
Fixed bug in exchange class; problem was in the argument order in the…
davidcortesortuno Jun 7, 2019
5677941
Updated exchange class and started sim c++ class
davidcortesortuno Jun 10, 2019
46b765d
Added micro sim cpp file
davidcortesortuno Jun 10, 2019
e8b15b0
Added method to add interactions to sim C class using cython wrappers…
davidcortesortuno Jun 11, 2019
2f19fcf
Made energy class setup to depend on the micro sim class. Updated tes…
davidcortesortuno Jun 12, 2019
5268274
Added new micromagnetic Anisotropy and DMI energy classes
davidcortesortuno Jun 12, 2019
aa2aa4b
Implemented compute eff field in sim class. Simplified interactions a…
davidcortesortuno Jun 12, 2019
c7e7728
Added new driver
davidcortesortuno Jun 14, 2019
eaccbf5
Starting implementation of micro driver
davidcortesortuno Jul 29, 2019
ec0e239
Setting micro driver class and sketching integrators
davidcortesortuno May 19, 2021
ac5b65f
Implementing RK4 integrator
davidcortesortuno May 20, 2021
8268499
Removing RHS fun dependence on iterators to make it easy for Cython
davidcortesortuno May 21, 2021
1ff7c48
Driver problem: pass RHS fun to integrator
davidcortesortuno May 21, 2021
a8229fc
Setting wrappers for C++ driver classes
davidcortesortuno May 21, 2021
38dfa1e
Added static func to set up RHS func for the integrator
davidcortesortuno May 25, 2021
4d8cd3c
Using static variables to call integrator function
davidcortesortuno May 25, 2021
e936b4c
Refactored integrator with void pointers a-la-C, to allow any number …
davidcortesortuno May 26, 2021
e4c87f7
Templated integrator, now accepting extra parameters in a safer way. …
davidcortesortuno May 27, 2021
e90fd89
Implemented micro driver in Cython wrapper
davidcortesortuno May 27, 2021
e50c6aa
Testing setting the integrator
davidcortesortuno May 27, 2021
b46de63
remove blat out of .cpp files; not reliable if add cpp sources
rpep May 31, 2021
7897a07
remove setting CC and CXX from Makefile; should always get from envir…
rpep May 31, 2021
484a7bd
Made dmdt vector in integrator
davidcortesortuno Jun 1, 2021
9e29f7d
Refining integrator, made dmdt vector; removing old variables and com…
davidcortesortuno Jun 1, 2021
2a5b4d4
Started adding tests to integrators
davidcortesortuno Jan 26, 2022
88e831b
Fixed test of integrator. Added cython wrapper
davidcortesortuno Jan 27, 2022
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
*.pdf
*.tmp
*.so
*.o
*.dSYM
fidimag/**/*.cpp


local/
*~
*.bak
Expand Down
43 changes: 38 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,50 @@ EXTENSIONS_DIR = ${PROJECT_DIR}/fidimag/extensions
PYTHON = python3
PYTEST = ${PYTHON} -m pytest

#####################
# Cython Extensions #
#####################
FFTW_INC=local/include
FFTW_LIB=local/lib

SUNDIALS_INC=local/include
SUNDIALS_LIB=local/lib

CPPFLAGS = -fPIC -g -Iinclude/ \
-I${FFTW_INC} -L${FFTW_LIB} \
-I${SUNDIALS_INC} -L${SUNDIALS_LIB} \
-Inative/include \
-lm \
-lfftw3_omp -lfftw3 \
-lsundials_cvodes -lsundials_nvecserial -lsundials_nvecopenmp \
-lblas -llapack \
-fopenmp \
-std=c++14

LDFLAGS = -shared
SOURCES = $(shell echo native/src/*.cpp)
OBJECTS = $(SOURCES:.cpp=.o)
LIBRARY = local/lib/libfidimag.so

########
# Build
########


all: $(LIBRARY) build


$(LIBRARY) : $(OBJECTS)
$(CXX) $(CPPFLAGS) $(OBJECTS) -o $@ $(LDFLAGS)


build: $(LIBRARY)
CC=${CC} CXX=${CXX} CPPFLAGS="${CPPFLAGS}" ${PYTHON} setup.py build_ext --inplace

build:
${PYTHON} setup.py build_ext --inplace

clean:
rm -rf ${EXTENSIONS_DIR}/*
touch ${EXTENSIONS_DIR}/__init__.py
rm -rf build
rm -rf $(OBJECTS) $(TARGET) *.dSYM


docker:
docker build -t fidimag -f ./docker/travis/Dockerfile .
Expand Down
2 changes: 1 addition & 1 deletion docker/travis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

# To build this image `docker build -t fidimag .`
# Then you can drop into a live bash shell with `docker run -it fidimag`.
Expand Down
3 changes: 0 additions & 3 deletions fidimag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,3 @@
Processor: {}
"""
print(message.format(FIDIMAG_DIR, e, platform.machine(), platform.platform(), platform.processor()))


__version__ = '0.2'
12 changes: 7 additions & 5 deletions fidimag/atomistic/lib/clib.pyx → fidimag/atomistic/a_clib.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# distutils: language = c++
import numpy
cimport numpy as np
cimport fidimag.common.vectormath as vmath
np.import_array()

cdef extern from "fidimag_random.h":


cdef extern from "a_random.h":
ctypedef struct mt19937_state:
pass

Expand All @@ -18,7 +22,7 @@ cdef extern from "time.h":
ctypedef int time_t
time_t time(time_t *timer)

cdef extern from "clib.h":
cdef extern from "a_clib.h":
void run_step_mc(mt19937_state *state, double *spin, double *new_spin,
int *ngbs, int *nngbs, int n_ngbs,
double J, double J1, double D, double D1,
Expand Down Expand Up @@ -95,8 +99,6 @@ cdef extern from "clib.h":

# -------------------------------------------------------------------------

void normalise(double *m, int *pins, int n)

# used for sllg
void llg_rhs_dw_c(double *m, double *h, double *dm, double *T, double *alpha,
double *mu_s_inv, int *pins, double *eta, int n,
Expand Down Expand Up @@ -270,7 +272,7 @@ def compute_demag_full(double [:] spin,

def normalise_spin(np.ndarray[double, ndim=1, mode="c"] spin,
np.ndarray[int, ndim=1, mode="c"] pins, n):
normalise(&spin[0], &pins[0], n)
vmath.normalise(&spin[0], &pins[0], n)

def compute_llg_rhs_dw(double [:] dm,
double [:] spin,
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/anisotropy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
import numpy as np
from .energy import Energy
import fidimag.common.helper as helper
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/atomistic_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from fidimag.common.driver_base import DriverBase

import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
import fidimag.extensions.cvode as cvode
from fidimag.common.vtk import VTK
import fidimag.common.constant as const
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/demag_full.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
import numpy as np
from .energy import Energy

Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/dmi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
from .energy import Energy
import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/exchange.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
import numpy as np
from .energy import Energy

Expand Down
4 changes: 2 additions & 2 deletions fidimag/atomistic/hexagonal_mesh.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

"""
r"""
Represent hexagonal 2D mesh.

The hexagons are pointy topped (as against flat topped). We use axial
Expand Down Expand Up @@ -38,6 +37,7 @@
Coordinates a

"""

import numpy as np
from math import sqrt

Expand Down
122 changes: 0 additions & 122 deletions fidimag/atomistic/lib/clib.h

This file was deleted.

2 changes: 1 addition & 1 deletion fidimag/atomistic/llg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import print_function

# Use the common C library for the LLG equation in the atomistic case
import fidimag.extensions.common_clib as clib
import fidimag.extensions.c_clib as clib

from .atomistic_driver import AtomisticDriver

Expand Down
3 changes: 1 addition & 2 deletions fidimag/atomistic/llg_stt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import division

import fidimag.extensions.common_clib as clib
import fidimag.extensions.c_clib as clib
import numpy as np

from .atomistic_driver import AtomisticDriver
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/llg_stt_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import types

import fidimag.extensions.common_clib as clib
import fidimag.extensions.c_clib as clib
import numpy as np

from .atomistic_driver import AtomisticDriver
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import print_function
import os
import numpy as np
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
from fidimag.common.fileio import DataSaver
import fidimag.common.helper as helper
import fidimag.common.constant as const
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import fidimag.common.skyrmion_number
import fidimag.common.helper as helper
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
import numpy as np

from fidimag.common.sim_base import SimBase
Expand Down
2 changes: 1 addition & 1 deletion fidimag/atomistic/sllg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division
import numpy as np
import fidimag.extensions.clib as clib
import fidimag.extensions.a_clib as clib
import fidimag.common.helper as helper
import fidimag.common.constant as const

Expand Down
Loading