repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
finmag | finmag-master/src/finmag/tests/test_skyrmions.py | # every function which starts with test_
# will get automatically by the test runner.
# you can have as many test functions per file as you want.
def test_skyrmion():
TOLERANCE = 1e-6
# Setup your problem, compute some results.
my_result = 1e-5
expected_result = 1e-5
assert abs(my_result - expe... | 345 | 22.066667 | 59 | py |
finmag | finmag-master/src/finmag/tests/test_llg.py | import numpy as np
import dolfin as df
from finmag.physics.llg import LLG
from finmag.util.helpers import components
def test_method_of_computing_the_average_matters():
length = 20e-9 # m
simplices = 10
mesh = df.IntervalMesh(simplices, 0, length)
S1 = df.FunctionSpace(mesh, "Lagrange", 1)
S3 = d... | 662 | 26.625 | 59 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/oscillator/test_oscillator.py | import os
import run as sim
import numpy as np
epsilon = 1e-16
tolerance = 1e-3
nmag_file = os.path.join(sim.MODULE_DIR, "averages_nmag5.txt")
def _test_oscillator():
if not os.path.exists(sim.initial_m_file):
sim.create_initial_state()
sim.run_simulation()
averages = np.loadtxt(sim.averages_fil... | 520 | 23.809524 | 62 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/oscillator/run.py | import os
import numpy as np
from finmag import Simulation as Sim
from finmag.energies import Exchange, Demag
from finmag.util.meshes import from_geofile
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
initial_m_file = os.path.join(MODULE_DIR, "m0.txt")
averages_file = os.path.join(MODULE_DIR, "averages.txt")
... | 1,460 | 26.566038 | 66 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/oscillator/run_nmag5.py | import os
import sys
from nsim.si_units.si import SI, degrees_per_ns
from nmag.nmag5 import Simulation, MagMaterial
from nmag import at, every
from nsim.model import Value
from nsim.netgen import netgen_mesh_from_file
mesh_filename = "mesh.nmesh.h5"
mesh_geo = "mesh.geo"
# create mesh if required
if not os.path.exist... | 1,797 | 25.835821 | 75 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/simple/run_no_stt.py | import os
import numpy as np
from finmag import Simulation as Sim
from finmag.energies import Exchange, Zeeman
from finmag.util.meshes import from_geofile
from finmag.util.consts import mu0
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
averages_file = os.path.join(MODULE_DIR, "averages_no_stt.txt")
mesh = fr... | 967 | 25.888889 | 63 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/simple/run.py | import os
import numpy as np
from math import pi, sin, cos
from finmag import Simulation as Sim
from finmag.energies import Exchange, Zeeman
from finmag.util.meshes import from_geofile
from finmag.util.consts import mu0
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
averages_file = os.path.join(MODULE_DIR, "a... | 1,258 | 27.613636 | 66 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/simple/run_nmag5_no_stt.py | import math
from nmag.common import SI, degrees_per_ns, Tesla, mu0, at, every
from nmag.nmag5 import Simulation, MagMaterial
# Applied field
Happ_dir = [0, 0, 10] # in mT
# Material definition
mat = MagMaterial("Py", Ms=SI(860e3, "A/m"),
exchange_coupling=SI(13e-12, "J/m"),
llg_ga... | 972 | 33.75 | 65 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/simple/run_nmag5.py | import math
from nmag.common import SI, degrees_per_ns, Tesla, mu0, at, every
from nmag.nmag5 import Simulation, MagMaterial
from nsim.model import Value
# Geometry
nm = SI(1e-9, "m")
length = width = 12.5 * nm
height = 2.5 * nm
# Applied field
Happ_dir = [0, 0, 10] # in mT
# Material definition
mat = MagMaterial("... | 1,771 | 31.218182 | 65 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/with_and_without/run.py | import os
import dolfin as df
import numpy as np
from math import pi, sin, cos
from finmag import Simulation as Sim
from finmag.energies import Exchange, UniaxialAnisotropy, Zeeman
from finmag.util.consts import mu0
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
averages_without = os.path.join(MODULE_DIR, "m_... | 2,023 | 27.507042 | 69 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/validation/nmag/run.py | import os
import math
import numpy as np
from nsim.netgen import netgen_mesh_from_string
from nmag.common import SI, degrees_per_ns, Tesla, mu0, at, every
from nmag.nmag5 import Simulation, MagMaterial, uniaxial_anisotropy
from nsim.model import Value
ps = SI(1e-12, "s")
nm = SI(1e-9, "m") # Useful defin... | 2,649 | 39.769231 | 85 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/validation/finmag/test_finmag_validation.py | import os
import numpy as np
from finmag.util.fileio import Tablereader
from run_validation import run_simulation
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
FINMAG_DYNAMICS_FILE = "finmag_validation_light.ndt"
NMAG_FILE = os.path.join(MODULE_DIR, "../nmag/averages_nmag5.txt")
OOMMF_FILE = os.path.join(MOD... | 2,305 | 31.478873 | 70 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/validation/finmag/run_validation.py | import os
import dolfin as df
import numpy as np
from math import pi, sin, cos
from finmag import Simulation as Sim
from finmag.energies import Exchange, UniaxialAnisotropy, Zeeman
from finmag.util.consts import mu0
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
averages_file = os.path.join(MODULE_DIR, "avera... | 1,205 | 28.414634 | 78 | py |
finmag | finmag-master/src/finmag/tests/slonczewski/validation/oommf/run.py | import os
import sys
import numpy as np
if not os.path.isfile("spinxfer-onespin.odt"):
print "Please run oommf on the run.mif file."
sys.exit(1)
oommf_data = np.loadtxt("spinxfer-onespin.odt")
dynamics = np.zeros((oommf_data.shape[0], 4))
dynamics[:, 0] = oommf_data[:, -1] # time
dynamics[:, 1:4] = oommf_dat... | 400 | 25.733333 | 66 | py |
finmag | finmag-master/src/finmag/tests/jacobean/test_jacobean_integration.py | # FinMag - a thin layer on top of FEniCS to enable micromagnetic multi-physics simulations
# Copyright (C) 2012 University of Southampton
# Do not distribute
#
# CONTACT: [email protected]
#
# AUTHOR(S) OF THIS FILE: Dmitri Chernyshenko ([email protected])
import numpy as np
import scipy.integrate
import ... | 3,514 | 37.626374 | 175 | py |
finmag | finmag-master/src/finmag/tests/jacobean/domain_wall_cobalt.py | import numpy as np
import dolfin as df
import math
from finmag.physics.llg import LLG
from finmag.drivers.llg_integrator import llg_integrator
from finmag.energies import Exchange, UniaxialAnisotropy
# Material parameters
Ms_Co = 1400e3 # A/m
K1_Co = 520e3 # A/m
A_Co = 30e-12 # J/m
LENGTH = 100e-9
NODE_COUNT = 100... | 2,127 | 28.971831 | 115 | py |
finmag | finmag-master/src/finmag/tests/jacobean/test_jacobean_computation.py | import numpy as np
import unittest
from domain_wall_cobalt import setup_domain_wall_cobalt
def norm(a):
return np.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])
# Set up the LLG with all parameters close to 1
def setup_llg_params_near_one(node_count=5, A=3.6 * 4e-7 * np.pi, Ms=6.7e5, K1=4.3, do_precession=True)... | 3,117 | 35.682353 | 104 | py |
finmag | finmag-master/src/finmag/tests/jacobean/__init__.py | 0 | 0 | 0 | py | |
finmag | finmag-master/src/finmag/tests/jacobean/test_native_llg.py | import numpy as np
import unittest
from finmag.native import llg as native_llg
from test_jacobean_computation import setup_llg_params_near_one
from finmag.util.time_counter import counter
class NativeLlgTests(unittest.TestCase):
def test_llg_performance(self):
# Unfortunately 100000 nodes is not enough t... | 1,008 | 35.035714 | 96 | py |
finmag | finmag-master/src/finmag/tests/nmag/exchange_3d/run_nmag.py | import nmag
from nmag import SI, every
from nsim.si_units.si import degrees_per_ns
# example 2 of the nmag documentation
# without demag but with external field
mat_Py = nmag.MagMaterial(
name="Py",
Ms=SI(0.86e6, "A/m"),
exchange_coupling=SI(13.0e-12, "J/m"),
llg_damping=0.1)
L = 30.0e-9
H = 10.0e-9
... | 773 | 22.454545 | 74 | py |
finmag | finmag-master/src/finmag/tests/nmag/exchange_3d/run_dolfin.py | import os
import dolfin as df
from finmag import Simulation as Sim
from finmag.energies import Exchange, Zeeman
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def run_simulation():
L = 3e-8
W = 1e-8
H = 1e-8
mesh = df.BoxMesh(df.Point(0, 0, 0), df.Point(L, W, H), 10, 4, 4)
Ms = 0.86e6 ... | 882 | 22.236842 | 79 | py |
finmag | finmag-master/src/finmag/tests/nmag/exchange_3d/test_dynamics_3D.py | import os
import cProfile
import pstats
import pytest
import numpy as np
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
TOLERANCE = 8e-3
def setup_module(module):
import run_dolfin as s
s.run_simulation()
@pytest.mark.slow
def test_compare_averages():
ref = np.loadtxt(os.path.join(MODULE_DIR, ... | 1,042 | 25.075 | 67 | py |
finmag | finmag-master/src/finmag/tests/nmag/exchange_1d/run_nmag.py | # One dimensional magnetic system studied using nsim
import numpy as np
import nmag
from nmag import SI
import nmeshlib.unidmesher as unidmesher
# Details about the layers and the mesh and the material
length = 20.0 # in nanometers
mesh_unit = SI(1e-9, "m") # mesh unit (1 nm)
layers = [(0.0, length)] # t... | 2,097 | 28.138889 | 78 | py |
finmag | finmag-master/src/finmag/tests/nmag/exchange_1d/test_exchange_1d.py | import os
import numpy as np
import finmag.util.helpers as h
from dolfin import IntervalMesh
from finmag import Simulation as Sim
from finmag.energies import Exchange
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def setup_module(module=None):
# define the mesh
x_max = 20e-9 # m
simplexes = 10... | 5,058 | 28.074713 | 81 | py |
finmag | finmag-master/src/finmag/tests/nmag/anisotropy_1d/run_nmag.py | # One dimensional magnetic system studied using nsim
import numpy as np
import nmag
from nmag import SI
import nmeshlib.unidmesher as unidmesher
# Details about the layers and the mesh and the material
length = 100.0 # in nanometers
mesh_unit = SI(1e-9, "m") # mesh unit (1 nm)
layers = [(0.0, length)] # t... | 2,127 | 30.761194 | 79 | py |
finmag | finmag-master/src/finmag/tests/nmag/anisotropy_1d/test_nmag_1d_anisotropy.py | import os
import numpy as np
import finmag.util.helpers as h
from finmag import Simulation as Sim
from finmag.energies import UniaxialAnisotropy
import dolfin
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
averages = []
third_node = []
# run the simulation
def setup_module(module=None):
x_max = 100e-9... | 3,900 | 25.719178 | 78 | py |
finmag | finmag-master/src/finmag/tests/nmag/spinwaves/run_nmag.py | import nmag
from nmag import SI
import math
"""
periodic spinwaves example straight from nmag's documentation
http://nmag.soton.ac.uk/nmag/0.2/manual/html/example_periodic_spinwaves/doc.html
minus the periodic part...
"""
# define magnetic material
Py = nmag.MagMaterial(name="Py",
Ms=SI(1e6, "A... | 1,294 | 26.553191 | 80 | py |
finmag | finmag-master/src/finmag/tests/nmag/spinwaves/test_spinwaves.py | import os
import cProfile
import pstats
import pytest
import numpy as np
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
TOLERANCE = 3e-4
def setup_module(module):
import run_finmag as f
f.run_simulation()
@pytest.mark.slow
def test_compare_averages():
ref = np.loadtxt(os.path.join(MODULE_DIR, ... | 1,202 | 23.55102 | 67 | py |
finmag | finmag-master/src/finmag/tests/nmag/spinwaves/run_finmag.py | import os
from scipy.integrate import ode
from finmag.physics.llg import LLG
from finmag.energies import Exchange
import dolfin as df
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def run_simulation():
"""
Translation of the nmag code.
Mesh generated on the fly.
"""
x0 = 0
x1 = 15... | 1,859 | 23.473684 | 77 | py |
finmag | finmag-master/src/finmag/tests/oommf/convergence_anis_oommf.py | import os
import dolfin as df
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from finmag.util.oommf.comparison import compare_anisotropy
from finmag.util.oommf import mesh
K1 = 45e4 # J/m^3
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
max_rdiffs = [[], []]
mean_r... | 1,630 | 27.614035 | 84 | py |
finmag | finmag-master/src/finmag/tests/oommf/test_anisotropy.py | import dolfin as df
import numpy as np
from finmag.util.oommf import mesh
from finmag.util.oommf.comparison import compare_anisotropy
from finmag.util.helpers import stats
K1 = 45e4 # J/m^31
Ms = 0.86e6
def test_small_problem():
results = small_problem()
REL_TOLERANCE = 1e-15
print "0d: rel_diff_max:", ... | 2,883 | 32.149425 | 106 | py |
finmag | finmag-master/src/finmag/tests/oommf/test_exchange.py | import os
import numpy as np
import dolfin as df
import matplotlib.pyplot as plt
from finmag.util.helpers import stats
from finmag.util.oommf import mesh
from finmag.util.oommf.comparison import compare_exchange
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
Ms = 8.6e6
A = 1.3e-11
def test_one_dimensional_p... | 1,521 | 28.843137 | 90 | py |
finmag | finmag-master/src/finmag/tests/energy_density/test_energy_density.py | import os
import sys
import pytest
import commands
import subprocess
import numpy as np
import dolfin as df
from finmag.field import Field
from finmag.energies import UniaxialAnisotropy, Exchange, Demag, DMI
from finmag.util.consts import mu0
from finmag.util.meshes import sphere
TOL = 1e-14
# TODO: We're missing the... | 6,682 | 29.797235 | 79 | py |
finmag | finmag-master/src/finmag/tests/energy_density/run_nmag_Eexch.py | import os
import numpy as np
import nmag
from nmag import SI
import nmeshlib.unidmesher as unidmesher
L = 10
mesh_unit = SI(1e-9, "m") # mesh unit (1 nm)
layers = [(0.0, L)] # the mesh
discretization = 0.1 # discretization
# Initial magnetization
xfactor = float(SI("m") / (L * mesh_unit))
def m0(r)... | 964 | 25.805556 | 78 | py |
finmag | finmag-master/src/finmag/tests/bugs/test_bug_ndt_file_writing.py | import pytest
# coding: utf-8
# Saving spatially averaged magnetisation into a file
# Bug 8 June 2014. On some machines, we seem to have wrong data in the
# ndt file. Some inspection shows that there are too many columns in
# the ndt file.
# We didn't have a test for this, it was only caught by chance (Max
# lookin... | 5,316 | 30.64881 | 78 | py |
finmag | finmag-master/src/finmag/tests/bugs/segfault-paraview/nobug-2.py |
from paraview import servermanager
import dolfin as df
| 56 | 13.25 | 34 | py |
finmag | finmag-master/src/finmag/tests/bugs/segfault-paraview/bug-1.py | import paraview
import dolfin as df
import finmag
| 50 | 11.75 | 19 | py |
finmag | finmag-master/src/finmag/tests/bugs/segfault-paraview/bug-2.py | import dolfin as df
from paraview import servermanager
| 55 | 17.666667 | 34 | py |
finmag | finmag-master/src/finmag/tests/cython/test_cython.py | """ This is a bit of an odd test: it checks that a work-around for a
particular cython problem is still working. More meant to document
a solution rather than test cython, but can't do much harm.
HF 1 Feb 2013
"""
import subprocess
import os
# Cython complains about this:
# f_callable_normalised = vector_valued_fu... | 1,116 | 21.795918 | 102 | py |
finmag | finmag-master/src/finmag/tests/zhangli/stt_nonlocal_test.py | import os
import dolfin as df
import numpy as np
import matplotlib as mpl
mpl.use("Agg")
import matplotlib.pyplot as plt
from finmag import Simulation as Sim
from finmag.energies import Exchange, UniaxialAnisotropy
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def sech(x):
return 1 / np.cosh(x)
def... | 1,274 | 18.921875 | 72 | py |
finmag | finmag-master/src/finmag/tests/zhangli/standard.py | import os
import dolfin as df
import numpy as np
import matplotlib as mpl
mpl.use("Agg")
import matplotlib.pyplot as plt
from finmag import Simulation as Sim
from finmag.energies import Exchange, Demag
from finmag.util.fileio import Tablereader
from finmag.util.meshes import from_geofile, mesh_info
MODULE_DIR = os.p... | 2,260 | 19.935185 | 76 | py |
finmag | finmag-master/src/finmag/tests/zhangli/zhang_li_test.py | import pytest
import os
import dolfin as df
import numpy as np
import matplotlib as mpl
mpl.use("Agg")
import matplotlib.pyplot as plt
from finmag import Simulation as Sim
from finmag.energies import Exchange, UniaxialAnisotropy
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def sech(x):
return 1 / np... | 4,080 | 19.103448 | 86 | py |
finmag | finmag-master/src/finmag/tests/demag/compute_demag_sphere.py | from test_bem_computation import compute_scalar_potential_native_fk
from finmag.util.meshes import sphere
import numpy as np
from mayavi import mlab
# Create the mesh and compute the scalar potential
mesh = sphere(r=1.0, maxh=0.1)
phi = compute_scalar_potential_native_fk(mesh)
x, y, z = mesh.coordinates().T
values = ... | 760 | 30.708333 | 71 | py |
finmag | finmag-master/src/finmag/tests/demag/__init__.py | 0 | 0 | 0 | py | |
finmag | finmag-master/src/finmag/tests/demag/test_demag_sphere.py | import pytest
import numpy as np
import dolfin as df
from finmag.field import Field
from finmag.util.meshes import sphere
from finmag.energies import Demag
TOL = 1e-2
solvers = ['FK']
@pytest.fixture(scope="module")
def uniformly_magnetised_sphere():
Ms = 1
mesh = sphere(r=1, maxh=0.25)
S3 = df.VectorFun... | 1,328 | 26.6875 | 84 | py |
finmag | finmag-master/src/finmag/tests/demag/test_bem_computation.py | import os
import pytest
import unittest
import numpy as np
import dolfin as df
from finmag.field import Field
from finmag.util.versions import get_version_dolfin
from finmag.native.llg import compute_lindholm_L, compute_lindholm_K, compute_bem_fk, compute_bem_gcr
from finmag.util import time_counter
from finmag.util im... | 12,113 | 41.356643 | 132 | py |
finmag | finmag-master/src/finmag/tests/comparison/test_dmdt.py | import dolfin as df
import numpy as np
from finmag.physics.llg import LLG
from finmag.energies import Zeeman
from finmag.util.oommf import mesh, oommf_dmdt
from finmag.util.helpers import stats
TOLERANCE = 1e-15
L = 20e-9
W = 10e-9
H = 1e-9
nL = 20
nW = 10
nH = 1
msh = df.BoxMesh(df.Point(0, 0, 0), df.Point(L, W, H),... | 2,102 | 29.478261 | 95 | py |
finmag | finmag-master/src/finmag/tests/comparison/exchange/run_nmag.py | # One dimensional magnetic system studied using nsim
import math
import numpy as np
import nmag
from nmag import SI
import nmeshlib.unidmesher as unidmesher
# Details about the layers and the mesh and the material
length = 20.0 # in nanometers
mesh_unit = SI(1e-9, "m") # mesh unit (1 nm)
layers = [(0.0, l... | 1,637 | 31.76 | 70 | py |
finmag | finmag-master/src/finmag/tests/comparison/exchange/test_exchange_compare_magpar.py | import os
import dolfin as df
import numpy as np
from finmag.field import Field
from finmag.util import magpar
from finmag.energies import Exchange
from finmag.util.helpers import vector_valued_function
#df.parameters["allow_extrapolation"] = True
# REL_TOLERANCE = 3e-6 #passes with 'normal magpar'
REL_TOLERANCE = ... | 2,332 | 26.77381 | 81 | py |
finmag | finmag-master/src/finmag/tests/comparison/exchange/test_exchange_field.py | import os
import dolfin as df
import numpy as np
from finmag.field import Field
from finmag.energies import Exchange
from finmag.util.helpers import vectors, norm, stats, sphinx_sci as s
import pytest
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
x0 = 0
x1 = 20e-9
xn = 10
Ms = 0.86e6
A = 1.3e-11
table_deli... | 3,924 | 30.150794 | 106 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/run_nmag.py | import nmag
import numpy as np
from nmag import SI, at
Ms = 0.86e6
K1 = 520e3
a = (1, 0, 0)
x1 = y1 = z1 = 20
# same as in bar.geo file
def m_gen(r):
x = np.maximum(np.minimum(r[0] / x1, 1.0), 0.0) # x, y and z as a fraction
y = np.maximum(np.minimum(r[1] / y1, 1.0), 0.0) # between 0 and 1 in the
z = n... | 1,781 | 31.4 | 79 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/conftest.py | import os
import numpy as np
import dolfin as df
from finmag.field import Field
from finmag.util.meshes import from_geofile
from finmag.energies import UniaxialAnisotropy, CubicAnisotropy
from finmag.util.helpers import sphinx_sci as s
import pytest
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
@pytest.fixt... | 3,299 | 29 | 116 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/retired-test_anis_nmag.py | import numpy as np
import conftest
import os
from finmag.util.helpers import vectors, stats
def test_against_nmag(finmag):
# FIXME: why the tolerance is so large?
REL_TOLERANCE = 7e-2
m_ref = np.genfromtxt(os.path.join(conftest.MODULE_DIR, "m0_nmag.txt"))
m_computed = vectors(finmag["m"].get_numpy_a... | 1,232 | 29.825 | 79 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/retired-test_cubic_anis_nmag.py | import numpy as np
import conftest
import os
from finmag.util.helpers import vectors, stats
def test_cubic_against_nmag(finmag=conftest.setup_cubic()):
REL_TOLERANCE = 1e-6
m_ref = np.genfromtxt(os.path.join(conftest.MODULE_DIR, "m0_nmag.txt"))
m_computed = vectors(finmag["m"].get_numpy_array_debug())
... | 1,285 | 29.619048 | 76 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/anis_all.py | import conftest as test
if __name__ == "__main__":
from test_anis_magpar import test_against_magpar
from test_anis_nmag import test_against_nmag
from test_anis_oommf import test_against_oommf
finmag = test.setup(K2=0)
test_against_magpar(finmag)
test_against_oommf(finmag)
finmag = test.... | 384 | 21.647059 | 52 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/test_cubic_anis_oommf.py | import numpy as np
import conftest
from finmag.util.oommf.comparison import oommf_m0, finmag_to_oommf
from finmag.util.oommf import mesh, oommf_cubic_anisotropy
from finmag.util.helpers import stats
def test_against_oommf(finmag=conftest.setup_cubic()):
REL_TOLERANCE = 7e-2
oommf_mesh = mesh.Mesh(
(... | 1,284 | 34.694444 | 124 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/test_anis_oommf.py | import numpy as np
import conftest
from finmag.util.oommf.comparison import oommf_m0, finmag_to_oommf
from finmag.util.oommf import mesh, oommf_uniaxial_anisotropy
from finmag.util.helpers import stats
def test_against_oommf():
finmag=conftest.setup(K2=0)
REL_TOLERANCE = 9e-2
oommf_mesh = mesh.Mesh(
... | 1,171 | 32.485714 | 86 | py |
finmag | finmag-master/src/finmag/tests/comparison/anisotropy/test_anis_magpar.py | import os.path
import numpy as np
import conftest
import finmag.util.magpar as magpar
from finmag.util.helpers import stats
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def test_against_magpar():
finmag=conftest.setup(K2=0)
REL_TOLERANCE = 5e-7
magpar_result = os.path.join(MODULE_DIR, 'magpar... | 1,184 | 31.916667 | 78 | py |
finmag | finmag-master/src/finmag/tests/comparison/demag/run_nmag.py | import os
import numpy as np
import nmag
from nmag import SI
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
# create simulation object
sim = nmag.Simulation()
# define magnetic material
Py = nmag.MagMaterial(name='Py', Ms=SI(1.0, 'A/m'))
# load mesh
sim.load_mesh("sphere.nmesh.h5", [('main', Py)], unit_len... | 514 | 19.6 | 75 | py |
finmag | finmag-master/src/finmag/tests/comparison/demag/test_demag_field.py | import os
import numpy as np
import dolfin as df
from finmag.field import Field
from finmag.energies import Demag
from finmag.util.meshes import from_geofile
from finmag.util.helpers import stats, sphinx_sci as s
from finmag.util import magpar
from finmag.util.magpar import compare_field_directly, compute_demag_magpar
... | 5,958 | 33.445087 | 110 | py |
finmag | finmag-master/src/finmag/native/init.py |
"""
Provides the symbols from the finmag native extension module.
Importing this module will first compile the finmag extension module, then
load all of its symbols into this module's namespace.
"""
from ..util.native_compiler import make_modules as _make_modules
_make_modules()
| 282 | 27.3 | 74 | py |
finmag | finmag-master/src/finmag/native/__init__.py | # FinMag - a thin layer on top of FEniCS to enable micromagnetic multi-physics simulations
# Copyright (C) 2012 University of Southampton
# Do not distribute
#
# CONTACT: [email protected]
#
# AUTHOR(S) OF THIS FILE: Dmitri Chernyshenko ([email protected])
from init import *
| 289 | 31.222222 | 90 | py |
finmag | finmag-master/src/finmag/example/sphere_inside_airbox.py | import dolfin as df
from finmag.field import Field
from finmag.sim.sim import sim_with
from finmag.util.meshes import sphere_inside_box
from finmag.util.helpers import scalar_valued_dg_function
import numpy as np
def sphere_inside_airbox(r_sphere=5.0, r_shell=10.0, l_box=50.0, maxh_sphere=2.0, maxh_shell=None, maxh_b... | 2,953 | 27.960784 | 187 | py |
finmag | finmag-master/src/finmag/example/macrospin.py | import dolfin as df
from finmag import Simulation, sim_with
from finmag.energies.zeeman import Zeeman
def macrospin(Ms=0.86e6, m_init=(1, 0, 0), H_ext=(0, 0, 1e6), alpha=0.1,
name='macrospin'):
"""
Minimal mesh with two vertices (1 nm apart). No anisotropy,
exchange coupling or demag is pres... | 2,767 | 30.454545 | 100 | py |
finmag | finmag-master/src/finmag/example/bar.py | """
This module provides a few 'standard' simulations that are used
repeatedly in the documentation/manual.
They generally return a simulation object.
"""
import dolfin as df
import finmag
def bar(name='bar', demag_solver_type=None):
"""Py bar with dimensions 30x30x100nm, initial field
pointing in (1,0,1) d... | 2,410 | 30.723684 | 89 | py |
finmag | finmag-master/src/finmag/example/__init__.py | # FinMag - a thin layer on top of FEniCS to enable micromagnetic multi-physics simulations
# Copyright (C) 2012 University of Southampton
# Do not distribute
#
# CONTACT: [email protected]
#
# AUTHOR(S) OF THIS FILE: Hans Fangohr
from bar import bar, barmini
from nanowire import nanowire
from sphere_inside_airbox i... | 367 | 29.666667 | 90 | py |
finmag | finmag-master/src/finmag/example/nanowire.py | """
This module provides a few 'standard' simulations that are used
repeatedly in the documentation/manual.
They generally return a simulation object.
"""
import dolfin as df
import finmag
from math import sin, cos, pi
def nanowire(lx=100, ly=10, lz=3, nx=30, ny=3, nz=1, name='nanowire'):
"""
Permalloy nano... | 864 | 25.212121 | 80 | py |
finmag | finmag-master/src/finmag/example/normal_modes/disk.py | import finmag
import dolfin as df
import os
from finmag.util.mesh_templates import Nanodisk
def disk(d=60, h=10, maxh=5.0, relaxed=True, name='normal_modes_nanodisk', A=13e-12, H_ext_relax=[1e5, 1e3, 0], H_ext_ringdown=[1e5, 0, 0],
demag_solver='FK', demag_solver_type=None, force_relaxation=False):
"""
... | 2,611 | 40.460317 | 139 | py |
finmag | finmag-master/src/finmag/example/normal_modes/__init__.py | # FinMag - a thin layer on top of FEniCS to enable micromagnetic multi-physics simulations
# Copyright (C) 2012 University of Southampton
# Do not distribute
#
# CONTACT: [email protected]
#
# AUTHOR(S) OF THIS FILE: Maximilian Albert
from disk import disk
| 261 | 28.111111 | 90 | py |
finmag | finmag-master/src/finmag/sim/sim.py | from __future__ import division
import os
import time
import inspect
import logging
import itertools
import sys
import dolfin as df
import numpy as np
import cProfile
import pstats
from aeon import timer
from finmag.field import Field
from finmag.physics.llg import LLG
from finmag.physics.llg_stt import LLG_STT
from fi... | 60,159 | 39.026613 | 154 | py |
finmag | finmag-master/src/finmag/sim/sim_savers.py | import finmag
from finmag.util.vtk_saver import VTKSaver
from finmag.util.fileio import FieldSaver
#-------------------------------------------------------------------------
# npy savers
#-------------------------------------------------------------------------
def _save_field_incremental(sim, field_name, filename=... | 3,517 | 33.490196 | 100 | py |
finmag | finmag-master/src/finmag/sim/sim_helpers_test.py | import os
import pytest
import numpy as np
import dolfin as df
import sim_helpers
from datetime import datetime, timedelta
from distutils.version import LooseVersion
from finmag import Simulation
from finmag.example import barmini
from finmag.util.meshes import nanodisk
from finmag.drivers.llg_integrator import llg_int... | 7,978 | 34.780269 | 132 | py |
finmag | finmag-master/src/finmag/sim/normal_mode_sim.py | import os
import re
import types
import logging
import numpy as np
import dolfin as df
from finmag.sim.sim import Simulation, sim_with
from finmag.normal_modes.eigenmodes import eigensolvers
from finmag.util import helpers
from finmag.util.fft import \
compute_power_spectral_density, find_peak_near_frequency, _plot... | 42,241 | 45.831486 | 203 | py |
finmag | finmag-master/src/finmag/sim/hysteresis_test.py | import dolfin as df
import numpy as np
import pytest
import os
from glob import glob
from finmag import sim_with
from finmag.example import barmini
from finmag.util.plot_helpers import plot_hysteresis_loop
ONE_DEGREE_PER_NS = 17453292.5 # in rad/s
H = 0.2e6 # maximum external field strength in A/m
initial_direction... | 2,923 | 37.986667 | 86 | py |
finmag | finmag-master/src/finmag/sim/sim_test.py | import dolfin as df
import numpy as np
import finmag
import itertools
import textwrap
import logging
import pytest
import os
import sh
import matplotlib.pyplot as plt
from glob import glob
from distutils.version import LooseVersion
from finmag import sim_with, Simulation, set_logging_level, normal_mode_simulation
from ... | 76,110 | 37.265963 | 146 | py |
finmag | finmag-master/src/finmag/sim/sim_details.py | import finmag
import dolfin as df
import numpy as np
from finmag.util.consts import exchange_length, bloch_parameter, \
helical_period
from finmag.util.meshes import mesh_info as mesh_information
def _get_length_scales(sim):
lengths = {}
if (sim.has_interaction('Exchange')):
A = sim.get_interacti... | 3,876 | 34.568807 | 105 | py |
finmag | finmag-master/src/finmag/sim/magnetisation_patterns_test.py | import numpy as np
import finmag
from finmag.sim.magnetisation_patterns import *
from finmag.util.meshes import cylinder
def test_vortex_functions():
"""
Testing for correct polarity and 'handiness' of the two vortex functions,
vortex_simple() and vortex_feldtkeller()
"""
mesh = cylinder(10, 1, 3... | 2,381 | 37.419355 | 78 | py |
finmag | finmag-master/src/finmag/sim/init.py | import logging
import argparse
import dolfin as df
import ufl
import ffc
from finmag.util import configuration, ansistrm
from finmag.util.helpers import start_logging_to_file
_FINMAG_LOG_LEVELS = {
"EXTREMEDEBUG": 5,
"DEBUG": logging.DEBUG,
"INFO": logging.INFO,
"WARNING": logging.WARNING,
"ERROR":... | 3,630 | 35.676768 | 89 | py |
finmag | finmag-master/src/finmag/sim/sim_relax.py | import functools
import logging
from finmag.util.consts import ONE_DEGREE_PER_NS
from finmag.util.helpers import compute_dmdt
log = logging.getLogger(name="finmag")
ONE_DEGREE_PER_NS = 17453292.5 # in rad/s
def relax(sim, save_vtk_snapshot_as=None, save_restart_data_as=None,
stopping_dmdt=1.0, dt_limit=... | 7,492 | 44.689024 | 93 | py |
finmag | finmag-master/src/finmag/sim/magnetisation_patterns.py | import finmag
from finmag.util import helpers
from copy import copy
import logging
import math
import numpy as np
from numpy.linalg import norm
log = logging.getLogger("finmag")
def initialise_helix_2D(sim, period, axis=np.array([1, 0])):
"""
Initialise the magnetisation to a pattern resembling a helix alon... | 18,518 | 33.550373 | 80 | py |
finmag | finmag-master/src/finmag/sim/__init__.py | # FinMag - a thin layer on top of FEniCS to enable micromagnetic multi-physics simulations
# Copyright (C) 2012 University of Southampton
# Do not distribute
#
# CONTACT: [email protected]
from init import *
| 213 | 25.75 | 90 | py |
finmag | finmag-master/src/finmag/sim/sim_helpers.py | import time
import finmag
import logging
import shutil
import os
import types
import dolfin as df
import numpy as np
from datetime import datetime, timedelta
from finmag.util.consts import ONE_DEGREE_PER_NS
from finmag.util.meshes import nodal_volume
log = logging.getLogger("finmag")
def save_ndt(sim):
"""
S... | 11,985 | 35.542683 | 198 | py |
finmag | finmag-master/src/finmag/sim/hysteresis.py | import os
import re
import glob
import logging
import textwrap
import fileinput
import numpy as np
from finmag.energies import Zeeman
from finmag.util.helpers import norm
log = logging.getLogger(name="finmag")
def hysteresis(sim, H_ext_list, fun=None, **kwargs):
"""
Set the applied field to the first value i... | 4,925 | 33.93617 | 79 | py |
finmag | finmag-master/src/finmag/normal_modes/__init__.py | # This file is needed just os that python recognises
# the contents as a module, but we're not actually
# exposing any names here.
| 131 | 32 | 52 | py |
finmag | finmag-master/src/finmag/normal_modes/deprecated/custom_colormaps.py |
#################################################################
### ###
### DO NOT EDIT THIS FILE!!! ###
### ###
### It was autogenerated from 'generate_custom_colormap... | 91,838 | 49.157837 | 65 | py |
finmag | finmag-master/src/finmag/normal_modes/deprecated/normal_modes_deprecated.py | from __future__ import division
import dolfin as df
import numpy as np
import logging
import os
import scipy.sparse.linalg
from time import time
from finmag.util import helpers
from finmag.util.meshes import embed3d
from itertools import izip
from math import pi
from finmag.field import Field
logger = logging.getLogger... | 34,945 | 36.216187 | 147 | py |
finmag | finmag-master/src/finmag/normal_modes/deprecated/normal_modes_deprecated_test.py | from finmag.util.mesh_templates import Box, Sphere, Nanodisk, EllipticalNanodisk
from finmag.util.meshes import mesh_info, plot_mesh_with_paraview
from finmag.normal_modes.deprecated.normal_modes_deprecated import *
from finmag import example
from finmag import sim_with, normal_mode_simulation
from math import pi
impor... | 10,328 | 39.347656 | 142 | py |
finmag | finmag-master/src/finmag/normal_modes/deprecated/__init__.py | # This file is needed just os that python recognises
# the contents as a module, but we're not actually
# exposing any names here.
| 131 | 32 | 52 | py |
finmag | finmag-master/src/finmag/normal_modes/deprecated/generate_custom_colormaps.py | import numpy as np
import matplotlib.colors as mcolors
import logging
import textwrap
import sys
from math import pi, cos, sin
logger = logging.getLogger('finmag')
try:
import husl
except:
logger.error(
"Missing python package: 'husl'. Please install it using 'sudo pip install husl'.")
sys.exit()
... | 5,441 | 33.443038 | 101 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/eigensolvers_test.py | from __future__ import division
import pytest
import numpy as np
import itertools
from eigensolvers import *
from eigenproblems import *
from helpers import normalise_rows
np.set_printoptions(precision=3)
# NOTE: Don't change this list without adapting the "known_failures" below!
sample_eigensolvers = [
ScipyLina... | 13,348 | 40.073846 | 106 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/custom_exceptions.py | class EigenproblemVerifyError(Exception):
pass
| 51 | 16.333333 | 41 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/eigensolvers.py | from __future__ import division
import numpy as np
import dolfin as df
import scipy.linalg
import scipy.sparse.linalg
import logging
from finmag.util.helpers import format_time
from helpers import sort_eigensolutions, as_petsc_matrix, is_hermitian, compute_relative_error, as_dense_array
from types import NoneType
logg... | 16,751 | 35.103448 | 165 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/__init__.py | # This file is needed just os that python recognises
# the contents as a module, but we're not actually
# exposing any names here.
| 131 | 32 | 52 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/helpers.py | from __future__ import division
import copy
import logging
import numpy as np
import dolfin as df
from finmag.util.helpers import make_human_readable
from scipy.sparse.linalg import LinearOperator
from scipy.sparse import csr_matrix
from scipy.optimize import minimize_scalar
from custom_exceptions import EigenproblemVe... | 12,261 | 31.099476 | 82 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/helpers_test.py | from __future__ import division
import numpy as np
import pytest
from scipy.sparse.linalg import LinearOperator
from helpers import *
def test_iseven():
for n in [0, 2, 6, 1223456, -18]:
assert(iseven(n))
for n in [1, 7, -19, -5, 787823]:
assert(not iseven(n))
def test_is_hermitian():
A1... | 10,497 | 31.401235 | 79 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/eigenproblems.py | from __future__ import division
import numpy as np
import dolfin as df
import itertools
import inspect
import logging
import sys
import matplotlib.pyplot as plt
from scipy.sparse.linalg import LinearOperator
from finmag.field import Field
from finmag.energies import Exchange
from finmag.util.consts import gamma, mu0
fr... | 24,580 | 32.217568 | 98 | py |
finmag | finmag-master/src/finmag/normal_modes/eigenmodes/eigenproblems_test.py | from __future__ import division
import pytest
import logging
import os
from eigenproblems import *
from eigensolvers import *
from helpers import is_diagonal_matrix
def test_assert_eigenproblems_were_defined():
"""
Check that `available_eigenproblems` is not the empty set and that
a few known eigenproblem... | 12,635 | 37.175227 | 79 | py |
finmag | finmag-master/native/src/cvode/setup.py | #!/usr/bin/env python
import os
#$ python setup.py build_ext --inplace
# Set the environment variable SUNDIALS_PATH if sundials
# is installed in a non-standard location.
SUNDIALS_PATH = os.environ.get('SUNDIALS_PATH', '/usr')
print "[DDD] Using SUNDIALS_PATH='{}'".format(SUNDIALS_PATH)
from numpy.distutils.command ... | 2,754 | 35.733333 | 88 | py |
finmag | finmag-master/native/src/treecode_bem/setup.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
import os
#python setup.py build_ext --inplace
ext_modules = [
Extension("treecode_bem",
sources = ['common.c',
'bem_pbc.c',
... | 746 | 24.758621 | 51 | py |
finmag | finmag-master/native/src/fast_sum_lib/setup.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
import os
#python setup.py build_ext --inplace
#NFFT_DIR = os.path.expanduser('~/nfft-3.2.0')
ext_modules = [
Extension("fast_sum_lib",
sources = ['fast_sum.c','fast_sum_li... | 597 | 22 | 58 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.