Skip to content

Commit bd8f550

Browse files
committed
2 parents 970d49f + 8408ffc commit bd8f550

35 files changed

+1889
-1000
lines changed

.travis.yml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,14 @@
1-
language: python
2-
python:
3-
- "3.6"
4-
- "3.5"
5-
- "3.4"
6-
- "2.7"
1+
sudo: required
72

3+
dist: trusty
4+
group: deprecated-2017Q4
85

9-
before_install:
10-
# We do this conditionally because it saves us some downloading if the
11-
# version is the same.
12-
- deactivate # Deactivate virtualenv
13-
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
14-
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
15-
else
16-
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
17-
fi
18-
- bash miniconda.sh -b -p $HOME/miniconda
19-
- export PATH=/home/travis/miniconda/bin:$PATH
20-
- sudo apt-get install liblapack-dev libblas-dev
21-
install:
22-
- conda create -q -y -n fidimag-test python=$TRAVIS_PYTHON_VERSION cython matplotlib pytest scipy pytest-cov gcc cmake psutil
23-
- source activate fidimag-test
24-
- pip install pyvtk six nbval
25-
- pip install pyvtk six ipywidgets
26-
- pip install git+https://github.com/computationalmodelling/nbval.git
27-
# Download and compile FFTW & Sundials locally
28-
- bash bin/install-sundials.sh
29-
- bash bin/install-fftw.sh
6+
services:
7+
- docker
308

31-
before_script:
32-
- conda list
33-
- make build
34-
- export PYTHONPATH="$TRAVIS_BUILD_DIR:$PYTHONPATH"
35-
- export LD_LIBRARY_PATH="$TRAVIS_BUILD_DIR/local/lib:$LD_LIBRARY_PATH"
36-
- export LD_RUN_PATH="$TRAVIS_BUILD_DIR/local/lib:$LD_RUN_PATH"
37-
- export OMP_NUM_THREADS=1
38-
- export MPLBACKEND=Agg
39-
# Tells matplotlib (?) to use PyQt class v2 APIs (I think)
40-
- export QT_API=pyqt
41-
42-
# command to run tests
439
script:
44-
- make test-without-run-oommf
45-
- make test-ipynb
46-
10+
- make travis
4711

4812
notifications:
4913
email:
5014
on_failure: always
51-
52-
after_success:
53-
- bash <(curl -s https://codecov.io/bash)

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt -y update
4+
RUN apt install -y git python3 python3-pip gcc psutils cmake wget make
5+
RUN apt install -y gfortran libblas-dev liblapack-dev python3-tk sudo fonts-lato
6+
RUN pip3 install cython matplotlib pytest scipy psutil pyvtk ipywidgets
7+
RUN pip3 install --no-cache-dir notebook
8+
9+
RUN ln -s /usr/bin/python3 /usr/bin/python
10+
11+
WORKDIR /usr/local
12+
RUN git clone https://github.com/computationalmodelling/fidimag.git
13+
WORKDIR /usr/local/fidimag
14+
# Work with stable release
15+
RUN git checkout tags/v2.9
16+
# Install CVODE and FFTW libraries
17+
WORKDIR /usr/local/fidimag/bin
18+
RUN bash install-fftw.sh
19+
RUN bash install-sundials.sh
20+
21+
ENV PYTHONPATH="/usr/local/fidimag:$PYTHONPATH"
22+
ENV LD_LIBRARY_PATH="/usr/local/fidimag/local/lib:$LD_LIBRARY_PATH"
23+
24+
WORKDIR /usr/local/fidimag
25+
RUN python3 setup.py build_ext --inplace
26+
RUN python3 -c "import matplotlib"
27+
# Headless Matplotlib:
28+
ENV MPLBACKEND=Agg
29+
30+
# Headless Matplotlib:
31+
ENV MPLBACKEND=Agg
32+
33+
# Set threads for OpenMP:
34+
ENV OMP_NUM_THREADS=2
35+
# WORKDIR /io
36+
37+
# User to make Binder happy
38+
ENV NB_USER magnetism
39+
ENV NB_UID 1000
40+
ENV HOME /home/${NB_USER}
41+
42+
RUN adduser --disabled-password \
43+
--gecos "Default user" \
44+
--uid ${NB_UID} \
45+
${NB_USER}
46+
47+
# Make sure the contents of our repo are in ${HOME}
48+
COPY . ${HOME}
49+
USER root
50+
RUN chown -R ${NB_UID} ${HOME}
51+
USER ${NB_USER}
52+
53+
WORKDIR /home/${USER}/magnetism/doc/ipynb

Makefile

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
PROJECT_DIR = $(abspath .)
22
EXTENSIONS_DIR = ${PROJECT_DIR}/fidimag/extensions
3-
PYTHON = python
3+
PYTHON = python3
4+
PYTEST = py.test-3
45

56
#####################
67
# Cython Extensions #
78
#####################
89

9-
1010
build:
1111
${PYTHON} setup.py build_ext --inplace
1212

1313
clean:
1414
rm -rf ${EXTENSIONS_DIR}/*
1515
touch ${EXTENSIONS_DIR}/__init__.py
1616

17+
docker:
18+
docker build -t fidimag -f ./docker/travis/Dockerfile .
19+
docker run -ti -d --name fidimag fidimag
20+
1721
#########
1822
# Tests #
1923
#########
2024

25+
test-docker: docker
26+
docker exec fidimag make test-basic
27+
#docker exec fidimag make test-without-run-oommf
28+
#docker exec fidimag make test-ipynb
29+
30+
travis: test-docker
31+
docker exec fidimag make codecov
32+
33+
codecov:
34+
bash <(curl -s https://codecov.io/bash)
35+
codecov: SHELL:= /bin/bash
36+
# or the recipe fails with /bin/sh complaining
37+
# `/bin/sh: 1: Syntax error: "(" unexpected`.
38+
2139
# Quick tests, also not using OOMMF tests
2240
test:
23-
cd tests && py.test -v -m "not slow and not run_oommf"
41+
cd tests && ${PYTEST} -v -m "not slow and not run_oommf"
2442

2543
test-clean:
2644
rm -rf neb*.ndt
@@ -51,16 +69,16 @@ test-clean:
5169
test2:
5270
# like test, but run also outside the 'tests' directory.
5371
# Doesn't work on Hans laptop.
54-
py.test -v -m "not slow and not run_oommf"
72+
${PYTEST} -v -m "not slow and not run_oommf"
5573

5674
test-all: create-dirs
57-
py.test -v --junitxml=$(PROJECT_DIR)/test-reports/junit/test-pytest.xml
75+
${PYTEST} -v --junitxml=$(PROJECT_DIR)/test-reports/junit/test-pytest.xml
5876

5977
test-without-run-oommf: create-dirs
60-
py.test -v -m "not run_oommf" --cov=fidimag --cov-report=html --junitxml=$(PROJECT_DIR)/test-reports/junit/test-pytest.xml
78+
${PYTEST} -v -m "not run_oommf" --cov=fidimag --cov-report=html --junitxml=$(PROJECT_DIR)/test-reports/junit/test-pytest.xml
6179

6280
test-basic:
63-
cd tests && py.test -v
81+
cd tests && ${PYTEST} -v
6482

6583
# Convenience name for commonly used quick running of tests
6684
tq:
@@ -71,10 +89,10 @@ test-quick:
7189

7290

7391
test-ipynb: create-dirs
74-
cd doc/ipynb && py.test . -v --current-env --nbval --sanitize-with sanitize_file --junitxml=$(PROJECT_DIR)/test-reports/junit/test-ipynb-pytest.xml
92+
cd doc/ipynb && ${PYTEST} . -v --current-env --nbval --sanitize-with sanitize_file --junitxml=$(PROJECT_DIR)/test-reports/junit/test-ipynb-pytest.xml
7593

7694
test-oommf:
77-
py.test -v -m "oommf"
95+
${PYTEST} -v -m "oommf"
7896

7997
create-dirs:
8098
mkdir -p test-reports/junit
@@ -93,4 +111,4 @@ doc-%:
93111
@echo $*
94112
make -C doc $*
95113

96-
.PHONY: extensions-directory build clean create-dirs test test-basic test-ipynb doc doc-clean doc-html doc-latexpdf doc-singlehtml
114+
.PHONY: extensions-directory build clean create-dirs test test-basic test-ipynb doc doc-clean doc-html doc-latexpdf doc-singlehtml docker test-docker travis codecov

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FIDIMAG
22
=======
33

4+
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/computationalmodelling/fidimag/master)
45
[![Build Status](https://travis-ci.org/computationalmodelling/fidimag.svg?branch=master)](https://travis-ci.org/computationalmodelling/fidimag)
56
[![Documentation Status](https://readthedocs.org/projects/fidimag/badge/?version=latest)](http://fidimag.readthedocs.org/en/latest/?badge=latest)
67
[![codecov](https://codecov.io/gh/computationalmodelling/fidimag/branch/master/graph/badge.svg)](https://codecov.io/gh/computationalmodelling/fidimag)
@@ -42,11 +43,12 @@ BibTeX:
4243
}
4344
</pre>
4445

45-
# Acknowledgement
46+
# Acknowledgements
4647

4748
We acknowledge financial support from
4849

4950
- EPSRC’s Centre for Doctoral Training in Next Generation
50-
Computational Modelling, http://ngcm.soton.ac.uk (#EP/L015382/1) and
51-
EPSRC’s Doctoral Training Centre in Complex System Simulation
52-
((EP/G03690X/1), http://icss.soton.ac.uk
51+
Computational Modelling, (EP/L015382/1)
52+
53+
- EPSRC’s Doctoral Training Centre in Complex System Simulation
54+
(EP/G03690X/1)

doc/core_eqs.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ effective field is
7979
In the continuum limit the exchange energy can be written as
8080

8181
.. math::
82-
E_{ex} = \int_{V} A (\nabla \vec{m})^2 dx
82+
E_{ex} = \int_{V} A (\nabla \vec{m})^2 \mathrm{d}V
8383
8484
with :math:`V` as the volume of the system and :math:`A` the anisotropy constant
8585
in :math:`\text{J m}^{-1}`. Correspondingly, the effective
@@ -176,27 +176,34 @@ For bulk materials :math:`\vec{D}_{ij} = D \vec{r}_{ij}` and for interfacial DMI
176176
In the continuum limit the bulk DMI energy is written as
177177

178178
.. math::
179-
E_{dmi} = \int_\Omega D_a \vec{m} \cdot (\nabla \times \vec{m}) dx
179+
E_{\text{DMI}} = \int_V D_a \vec{m} \cdot (\nabla \times \vec{m}) \, \mathrm{d}V
180180
181-
where :math:`D_a = -D/a^2` and the effective field is
181+
where :math:`V` is the volume of the sample and :math:`D_a = -D/a^2`. The corresponding
182+
effective field is
182183

183184
.. math::
184185
\vec{H}=-\frac{2 D_a}{\mu_0 M_s} (\nabla \times \vec{m})
185186
186187
187-
188188
For the interfacial case, the effective field becomes,
189189

190190
.. math::
191-
\vec{H}=\frac{2 D}{M_s a^2} (\vec{e}_x \times \frac{\partial \vec{m}}{\partial y} - \vec{e}_y \times \frac{\partial \vec{m}}{\partial x} )
191+
\vec{H}=\frac{2 D}{M_s a^2} (\hat{x} \times \frac{\partial \vec{m}}{\partial y} - \hat{y} \times \frac{\partial \vec{m}}{\partial x} )
192192
193193
Compared with the effective field [PRB 88 184422]
194194

195195
.. math::
196-
\vec{H}=\frac{2 D_a}{\mu_0 M_s} ((\nabla \cdot \vec{m}) \vec{e}_z - \nabla m_z)
196+
\vec{H}=\frac{2 D_a}{\mu_0 M_s} ((\nabla \cdot \vec{m}) \hat{z} - \nabla m_z)
197197
198198
where :math:`D_a = D/a^2`. Notice that there is no negative sign for the interfacial case.
199199

200+
In the micromagnetic code, it is also implemented the DMI for materials with
201+
:math:`D_{2d}` symmetry. The energy of this interaction reads
202+
203+
.. math::
204+
E_{\text{DMI}} = \int_V D_a \vec{m} \cdot \left( \frac{\partial \vec{m}}{\partial x} \times \hat{x} - \frac{\partial \vec{m}}{\partial y} \times \hat{y} \right) \, \mathrm{d}V
205+
206+
where :math:`D_a` is the DMI constant.
200207

201208
.. Similar to the exchange case, the effective field in the continuum case
202209
.. can be computed by the same codes with

docker/travis/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM ubuntu:16.04
2+
3+
# To build this image `docker build -t fidimag .`
4+
# Then you can drop into a live bash shell with `docker run -it fidimag`.
5+
ENTRYPOINT ["/bin/bash"]
6+
SHELL ["/bin/bash", "-c"]
7+
8+
RUN apt-get update -y
9+
RUN apt-get install -y build-essential cmake cython3 python3-dev python3-pip \
10+
python3-psutil python3-pytest python3-pytest-cov \
11+
python3-matplotlib python3-numpy python3-scipy \
12+
liblapack-dev libopenblas-dev \
13+
wget
14+
# next line for codecov target
15+
RUN apt-get install -y curl git
16+
17+
# ----------
18+
# hack to fix sudden breakage in CI
19+
# (fix from https://github.com/getsentry/sentry/issues/3143)
20+
# (first occurance of fail at https://travis-ci.org/computationalmodelling/fidimag/builds/319708056?utm_source=github_status&utm_medium=notification)
21+
# (which is part of this pull request: https://github.com/computationalmodelling/fidimag/pull/106)
22+
RUN pip3 install --upgrade setuptools==20.4
23+
# ----------
24+
25+
# ----------
26+
# hack to fix sudden breakage in CI
27+
# (fix from https://github.com/getsentry/sentry/issues/3143)
28+
# (first occurance of fail at https://travis-ci.org/computationalmodelling/fidimag/builds/319708056?utm_source=github_status&utm_medium=notification)
29+
# (which is part of this pull request: https://github.com/computationalmodelling/fidimag/pull/106)
30+
RUN pip3 install --upgrade setuptools==20.4
31+
# ----------
32+
33+
RUN pip3 install ipywidgets nbval pyvtk six
34+
35+
WORKDIR /fidimag
36+
ADD . /fidimag
37+
RUN ./bin/install-sundials.sh
38+
RUN ./bin/install-fftw.sh
39+
RUN make build
40+
41+
ENV PYTHONPATH=/fidimag \
42+
LD_LIBRARY_PATH=/fidimag/local/lib LD_RUN_PATH=/fidimag/local/lib \
43+
OMP_NUM_THREADS=1 MPLBACKEND=Agg QT_API=pyqt

examples/mc/skx.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,18 @@
55
import numpy as np
66
from fidimag.atomistic import MonteCarlo
77
from fidimag.common import DataReader, CuboidMesh
8-
9-
10-
def init_m(pos):
11-
x,y,z = pos
12-
13-
return (0,0,1)
8+
import fidimag.common.constant as const
149

1510
def random_m(pos):
1611
return np.random.random(3) - 0.5
1712

18-
1913
def run(mesh):
20-
2114
mc = MonteCarlo(mesh, name='test1')
2215
mc.set_m(random_m)
23-
mc.set_options(H=[0,0,0.0], J=50.0, D=0.27*50, T=5.0, Kc=50*0.1)
24-
mc.run(steps=20000, save_m_steps=None, save_vtk_steps=1000, save_data_steps=10)
16+
J = 50*const.k_B
17+
mc.set_options(H=[0,0,0.0], J=J, D=0.27*J, T=4.0)
18+
mc.run(steps=100000, save_m_steps=None, save_vtk_steps=50000, save_data_steps=50000)
2519

2620
if __name__=='__main__':
27-
28-
#mesh = CuboidMesh(nx=174,ny=150, nz=1, pbc='2d')
29-
mesh = CuboidMesh(nx=100, ny=100, nz=1, periodicity = (True, True, False))
30-
31-
run(mesh)
21+
mesh = CuboidMesh(nx=58, ny=33, nz=1, periodicity = (True, True, False))
22+
run(mesh)

0 commit comments

Comments
 (0)