Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker Image Ubuntu 12.04
name: Build Docker Image Ubuntu 14.04

on:
push:
Expand All @@ -15,8 +15,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file ubuntu-docker/1204/Dockerfile --tag ubuntu-1204:$(date +%s)
run: docker build . --file ubuntu-docker/1404/Dockerfile --tag ubuntu-1404:$(date +%s)

- name: run example in container
run: cd ubuntu-docker/1204 && docker run -it -v $PWD/mnt nmag nsim sphere1.py
run: cd ubuntu-docker/1404 && docker run -it -v $PWD/mnt nmag nsim sphere1.py

33 changes: 33 additions & 0 deletions ubuntu-docker/1404/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from ubuntu:14.04

workdir /mnt

env NMAG_VERSION 0.2.1

run \
# Install dependencies
apt-get update && \
apt-get install -y wget dpkg-dev g++ libblas-dev libreadline-dev make m4 gawk zlib1g-dev readline-common liblapack-dev

run \
# Initialize Environment
useradd -m -s /bin/bash nmag && \
cd /home/nmag && \
wget --no-check-certificate https://github.com/fangohr/nmag-releases/raw/master/0.2/all/nmag-0.2.1.tar.gz && \
tar xzvf nmag-$NMAG_VERSION.tar.gz && \
chown -R nmag:nmag nmag-$NMAG_VERSION

run \
# Compile code
su - nmag -c "cd nmag-$NMAG_VERSION && make && make clean"

run \
# Link binaries
ln -sf /home/nmag/nmag-$NMAG_VERSION/bin/* /usr/bin

run \
# Clean up
apt-get purge -y wget && \
rm /home/nmag/nmag-$NMAG_VERSION.tar.gz

cmd su nmag
33 changes: 33 additions & 0 deletions ubuntu-docker/1404/Dockerfile~
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from ubuntu:12.04

workdir /mnt

env NMAG_VERSION 0.2.1

run \
# Install dependencies
apt-get update && \
apt-get install -y wget dpkg-dev g++ libblas-dev libreadline-dev make m4 gawk zlib1g-dev readline-common liblapack-dev

run \
# Initialize Environment
useradd -m -s /bin/bash nmag && \
cd /home/nmag && \
wget --no-check-certificate https://github.com/fangohr/nmag-releases/raw/master/0.2/all/nmag-0.2.1.tar.gz && \
tar xzvf nmag-$NMAG_VERSION.tar.gz && \
chown -R nmag:nmag nmag-$NMAG_VERSION

run \
# Compile code
su - nmag -c "cd nmag-$NMAG_VERSION && make && make clean"

run \
# Link binaries
ln -sf /home/nmag/nmag-$NMAG_VERSION/bin/* /usr/bin

run \
# Clean up
apt-get purge -y wget && \
rm /home/nmag/nmag-$NMAG_VERSION.tar.gz

cmd su nmag
24 changes: 24 additions & 0 deletions ubuntu-docker/1404/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# About

This directory contains code to build a docker nmag container based on Ubuntu 12.04.

# Dependencies

* [Docker](https://docs.docker.com/install/)

# Building

In order to build the container run `docker build -t nmag .` from the current directory

# Using

You can start the nmag environment using `docker run -it nmag`.
To give the nmag environment access to the current directory and its children, use the format `docker run -it -v $PWD:/mnt nmag`.

# Testing

Use the sphere1 simulation included in the current directory to test the container like so:
```
docker run -it -v $PWD:/mnt nmag
$ nsim sphere1.py
```
Binary file added ubuntu-docker/1404/sphere1.nmesh.h5
Binary file not shown.
32 changes: 32 additions & 0 deletions ubuntu-docker/1404/sphere1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import nmag
from nmag import SI

#create simulation object
sim = nmag.Simulation()

# define magnetic material
Py = nmag.MagMaterial(name = 'Py',
Ms = SI(1e6, 'A/m'),
exchange_coupling = SI(13.0e-12, 'J/m'))

# load mesh
sim.load_mesh('sphere1.nmesh.h5',
[('sphere', Py)],
unit_length = SI(1e-9, 'm'))

# set initial magnetisation
sim.set_m([1,0,0])

# set external field
sim.set_H_ext([0,0,0], SI('A/m'))

# Save and display data in a variety of ways
sim.save_data(fields='all') # save all fields spatially resolved
# together with average data

# sample demag field through sphere
for i in range(-10,11):
x = i*1e-9 #position in metres
H_demag = sim.probe_subfield_siv('H_demag', [x,0,0])
print "x =", x, ": H_demag = ", H_demag