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/dev/sandbox/skyrmions/skyrmion2dmesh.py
""" Attempt to visualise some dynimacs using python's visual module. Visualisation probably okay, but some convergence problem in the time integration means this does not look smooth at all, and is very slow. """ import dolfin import dolfin as df import numpy from scipy.integrate import odeint from finmag.sim.llg i...
1,979
25.756757
116
py
finmag
finmag-master/dev/sandbox/skyrmions/spin_waves.py
import dolfin as df import numpy as np import pylab as plt from finmag.energies import Exchange, DMI, Zeeman from finmag import Simulation as Sim tstart = 0 tstatic = 1e-9 tpulse = 0.02e-9 tend = 4e-9 toffset = 1e-20 xdim = 7e-9 ydim = 7e-9 zdim = 1e-9 xv = 5 yv = 5 Ms = 1.567e5 #A/m H_pulse = [0.7*Ms, 0.7*Ms, 0.7*...
1,616
18.719512
55
py
finmag
finmag-master/dev/sandbox/skyrmions/retrieve_timeseries.py
from dolfin import * mesh = Box(0,0,0,30e-9,30e-9,3e-9,10,10,1) V = VectorFunctionSpace(mesh, "CG", 1) m = Function(V) series = TimeSeries("solution/m") times = series.vector_times() output = File("vtk-files/skyrmion.pvd") for t in times: vector = Vector() series.retrieve(vector, t) m.vector()[:] = vecto...
339
19
42
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_varying_D.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Zeeman def m_init_fun(pos): return np.random.random(3)-0.5 def spatial_D(pos): x = pos[0] if x<50: return 4e-3 else: return -4e-3 def relax(mesh): Ms = 8.6e5 sim =...
820
16.847826
57
py
finmag
finmag-master/dev/sandbox/skyrmions/spiral.py
""" Attempt to visualise some dynimacs using python's visual module. Visualisation probably okay, but some convergence problem in the time integration means this does not look smooth at all, and is very slow. """ import dolfin import dolfin as df import numpy from scipy.integrate import odeint from finmag.sim.llg i...
1,384
23.732143
116
py
finmag
finmag-master/dev/sandbox/skyrmions/fftanalysis.py
import numpy as np import pylab as plt import matplotlib.cm as cm npzfile = np.load('output_sinc.npz') mx = npzfile['mx'] my = npzfile['my'] mz = npzfile['mz'] tsim = npzfile['tsim'] mx -= np.average(mx) my -= np.average(my) mz -= np.average(mz) spx = [] spy = [] spz = [] for i in range(mx.shape[0]): for j in r...
1,937
18.575758
47
py
finmag
finmag-master/dev/sandbox/skyrmions/rundmi.py
""" Attempt to visualise some dynimacs using python's visual module. Visualisation probably okay, but some convergence problem in the time integration means this does not look smooth at all, and is very slow. """ import dolfin import dolfin as df import numpy from scipy.integrate import odeint from finmag.sim.llg i...
1,381
22.827586
115
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_current.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Zeeman def m_init_fun(pos): return np.random.random(3)-0.5 def relax(mesh): Ms = 8.6e5 sim = Simulation(mesh, Ms, pbc='2d',unit_length=1e-9) sim.set_m(m_init_fun) sim.alpha = 0.5 ...
1,432
19.183099
57
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion-vtk.py
""" Attempt to visualise some dynimacs using python's visual module. Visualisation probably okay, but some convergence problem in the time integration means this does not look smooth at all, and is very slow. """ import dolfin import dolfin as df import numpy from scipy.integrate import odeint from finmag.sim.llg i...
1,453
23.644068
116
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_timings.py
import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI output = open("timings.txt", "w") mesh = df.Box(0, 0, 0, 30e-9, 30e-9, 3e-9, 10, 10, 1) def run_sim(exc_jac, dmi_jac): sim = Simulation(mesh, Ms=8.6e5) sim.set_m((1, 0, 0)) exchange = Exchange(A=1.3e-11) exchan...
919
26.878788
73
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmiondemo.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Demag, Zeeman from finmag.util.meshes import cylinder #mesh = df.BoxMesh(0,0,0,30,30,3,10,10,1) mesh = cylinder(60, 3, 3) Ms = 8.6e5 sim = Simulation(mesh, Ms, unit_length=1e-9) sim.set_m((1, 1, 1)) A = 1...
620
18.40625
56
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion.py
""" Attempt to visualise some dynimacs using python's visual module. Visualisation probably okay, but some convergence problem in the time integration means this does not look smooth at all, and is very slow. """ import dolfin import dolfin as df import numpy from scipy.integrate import odeint from finmag.sim.llg i...
1,411
23.344828
116
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_pbc_demo_sllg.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Demag, Zeeman from finmag.util.helpers import vector_valued_function from finmag.physics.llb.sllg import SLLG R=150 N=50 #mesh = df.RectangleMesh(0,0,R,R,20,20) mesh = df.RectangleMesh(0,0,R,R,N,N) def m_i...
823
18.162791
56
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_sim.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI_Old, DMI mesh = df.Box(0,0,0,30e-9,30e-9,3e-9,10,10,1) Ms = 8.6e5 sim = Simulation(mesh, Ms) sim.set_m((Ms, 0, 0)) A = 1.3e-11 D = 4e-3 sim.add(Exchange(A)) sim.add(DMI( D)) series = df.TimeSeries("solution...
509
20.25
50
py
finmag
finmag-master/dev/sandbox/skyrmions/sw_no_dmi.py
import dolfin as df import numpy as np import pylab as plt from finmag.energies import Exchange, Zeeman, Demag from finmag import Simulation as Sim from math import pi def plot_excitation(tsinc, Hsinc): """Plot the external excitation signal both in time and frequency domain.""" #time domain plt.subplot(2...
3,712
27.128788
80
py
finmag
finmag-master/dev/sandbox/skyrmions/test_curl_operator.py
from dolfin import * mesh=UnitCubeMesh(1,1,1) V=VectorFunctionSpace(mesh,"CG",1) M=interpolate(Constant((1,1,1)),V) #E=dot(M,M)*dx E=inner(M,curl(M))*dx print "energy=",assemble(E) dE_dM=derivative(E,M) dE_dMvec=assemble(dE_dM) print "vector=",dE_dMvec.array() #curlM=project(somecurlform,V) #print curlM.vector()....
330
14.761905
34
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_stt_nonlocal.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Zeeman def m_init_fun(pos): return np.random.random(3)-0.5 def relax(mesh): Ms = 8.6e5 sim = Simulation(mesh, Ms, pbc='2d',unit_length=1e-9) sim.set_m(m_init_fun) sim.alpha = 0.5 ...
1,472
19.746479
75
py
finmag
finmag-master/dev/sandbox/skyrmions/skyrmion_pbc_demo.py
import numpy as np import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Zeeman def m_init_fun(pos): return np.random.random(3)-0.5 def relax(mesh): Ms = 8.6e5 sim = Simulation(mesh, Ms, pbc='2d',unit_length=1e-9) sim.set_m(m_init_fun) sim.add(Exchange(1....
725
16.707317
57
py
finmag
finmag-master/dev/sandbox/cvode_parallel/hdf5_to_vtk.py
import numpy as np import dolfin as df df.parameters.reorder_dofs_serial = True from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() #mpirun -n 2 python test.py if __name__ == '__main__': mesh = df.BoxMesh(0, 0, 0, 30, 30, 100, 6, 6, 20) S3 = df.VectorFunctionSpace(me...
721
20.878788
68
py
finmag
finmag-master/dev/sandbox/cvode_parallel/test.py
import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import dolfin as df import numpy as np import finmag.native.cvode_petsc as cvode #from mpi4py import MPI #comm = MPI.COMM_WORLD #rank1 = comm.Get_rank() #size1 = comm.Get_size() mpi_world = df.mpi_comm_world() rank = df.MPI.rank(mpi_world) size ...
2,518
23.940594
89
py
finmag
finmag-master/dev/sandbox/cvode_parallel/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,761
35.826667
88
py
finmag
finmag-master/dev/sandbox/cvode_parallel/test_llg.py
import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import dolfin as df import numpy as np import finmag.native.cvode_petsc as cvode2 import finmag.native.llg_petsc as llg_petsc from finmag.physics.llg import LLG from finmag.energies import Exchange, Zeeman, Demag df.parameters.reorder_dofs_serial ...
4,789
30.30719
143
py
finmag
finmag-master/dev/sandbox/basics-fe/shapefunctions.py
import numpy as np import dolfin as df import pylab class Potential(object): """ Idea: Have a potential, say .. math:: V(x) = 0.5*k*(f(x)-m(x))^2 Have degrees of freedom m(x) that can adjust to this potential. The force field H is .. math:: H = -dV/dm = k*(f(x)-m(x)) ...
8,817
29.512111
146
py
finmag
finmag-master/dev/sandbox/basics-fe/test_assemble.py
from dolfin import * import dolfin as df from fractions import Fraction import numpy def my_print_array(a): (m,n)=a.shape for j in range(n): for i in range(m): x=a[i][j] y= Fraction(x).limit_denominator() print "%6s"%y, print '' def compute_assemble(u1,v1,...
1,135
17.031746
47
py
finmag
finmag-master/dev/sandbox/saving_data/example.py
import savingdata as sd import dolfin as df import numpy as np # Define mesh, functionspace, and functions. mesh = df.UnitSquareMesh(5, 5) fs = df.VectorFunctionSpace(mesh, 'CG', 1, 3) f1 = df.Function(fs) f2 = df.Function(fs) f3 = df.Function(fs) f1.assign(df.Constant((1, 1, 1))) f2.assign(df.Constant((2, 2, 2))) f3...
1,798
26.257576
67
py
finmag
finmag-master/dev/sandbox/saving_data/savingdata_test.py
import dolfin as df import numpy as np import json from collections import OrderedDict from savingdata import SavingData, LoadingData h5filename = 'file.h5' npzfilename = 'file.npz' jsonfilename = 'file.json' mesh = df.UnitSquareMesh(10, 10) functionspace = df.VectorFunctionSpace(mesh, 'CG', 1, 3) f = df.Function(func...
1,845
23.613333
74
py
finmag
finmag-master/dev/sandbox/saving_data/savingdata.py
import dolfin as df import numpy as np import json from collections import OrderedDict """ Problems: 1. We have to know the mesh in advance. 2. Merge loading and saving into single class (r, w flags). 3. Appending data. 4. Looking into the file (we have to use python module). """ class SavingData(object): def __...
3,776
31.008475
89
py
finmag
finmag-master/dev/sandbox/scipy_integrate/test_scipy_integrate_odeint_with_dolfin.py
"""One test. We integrate du -- = -2*u dt using (i) scipy.integrate.odeint as one normally does and (ii) within the dolfin framework. The test here is whether we update the right function (u) in the right-hand side when using dolfin. For dolfin, we solve the ODE above on a mesh, where on every mesh point we shou...
3,644
27.928571
114
py
finmag
finmag-master/dev/sandbox/scipy_integrate/test_scipy_integrate_odeint_with_dolfin_sin.py
"""One test. We integrate du -- = -2*u dt using (i) scipy.integrate.odeint as one normally does and (ii) within the dolfin framework. The test here is whether we update the right function (u) in the right-hand side when using dolfin. For dolfin, we solve the ODE above on a mesh, where on every mesh point we shou...
3,572
28.528926
106
py
finmag
finmag-master/dev/sandbox/neb/neb_tests.py
import os import dolfin as df import matplotlib as mpl #mpl.use("Agg") import matplotlib.pyplot as plt import numpy as np import inspect from neb import NEB_Sundials #from finmag.physics.neb import plot_energy_3d def plot_data_2d(): data = np.loadtxt('neb_energy.ndt') fig=plt.figure() xs = range(...
5,143
20.79661
96
py
finmag
finmag-master/dev/sandbox/neb/neb2_tests.py
import os import dolfin as df import matplotlib as mpl #mpl.use("Agg") import matplotlib.pyplot as plt import numpy as np from neb import NEB_Sundials class Sim3(object): """ One spin with two anisotropies """ def check(self,xs): x = xs[0] y = xs[1] if x > np.pi: ...
1,294
17.239437
78
py
finmag
finmag-master/dev/sandbox/neb/neb2.py
import os import dolfin as df import numpy as np import inspect from aeon import default_timer from finmag.native import sundials import logging log = logging.getLogger(name="finmag") def normalise(a): """ normalise the n dimensional vector a """ x = a>np.pi a[x] = 2*np.pi-a[x] x = a<-np....
8,806
26.266254
162
py
finmag
finmag-master/dev/sandbox/neb/neb.py
import os import dolfin as df import numpy as np import inspect from aeon import default_timer import finmag.util.consts as consts from finmag.util import helpers from finmag.physics.effective_field import EffectiveField from finmag.util.vtk_saver import VTKSaver from finmag import Simulation from finmag.native impor...
10,698
28.719444
162
py
finmag
finmag-master/dev/sandbox/two-cubes/run.py
import os import numpy as np import dolfin as df from finmag.util.meshes import from_geofile from finmag import Simulation from finmag.energies import UniaxialAnisotropy, Exchange, Demag MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) mesh = from_geofile(os.path.join(MODULE_DIR, "two-cubes.geo")) #df.plot...
918
17.019608
79
py
finmag
finmag-master/dev/sandbox/new_native_code/__init__.py
0
0
0
py
finmag
finmag-master/dev/sandbox/new_saving_data/example.py
import savingdata as sd import dolfin as df import numpy as np # Define mesh, functionspace, and functions. mesh = df.UnitSquareMesh(5, 5) fs = df.VectorFunctionSpace(mesh, 'CG', 1, 3) f1 = df.Function(fs) f2 = df.Function(fs) f3 = df.Function(fs) f1.assign(df.Constant((1, 1, 1))) f2.assign(df.Constant((2, 2, 2))) f3...
1,293
22.962963
67
py
finmag
finmag-master/dev/sandbox/new_saving_data/savingdata_test.py
import dolfin as df import numpy as np import json from collections import OrderedDict from savingdata import SavingData, LoadingData h5filename = 'file.h5' jsonfilename = 'file.json' mesh = df.UnitSquareMesh(10, 10) functionspace = df.VectorFunctionSpace(mesh, 'CG', 1, 3) f = df.Function(functionspace) t_array = np.l...
1,379
22.793103
74
py
finmag
finmag-master/dev/sandbox/new_saving_data/savingdata.py
import dolfin as df import numpy as np import json from collections import OrderedDict class SavingData(object): def __init__(self, h5filename, jsonfilename, functionspace): self.functionspace = functionspace self.h5filename = h5filename self.jsonfilename = jsonfilename self.h5fil...
2,853
29.688172
89
py
finmag
finmag-master/dev/sandbox/domains/use_regions.py
import dolfin as df # # The mesh contains two regions. # region 1: A disk (cylinder). # region 2: The cuboid around the disk. # mesh = df.Mesh("embedded_disk.xml.gz") regions = df.MeshFunction("uint", mesh, "embedded_disk_mat.xml") # # Example 1 # Compute the volume of the regions and the total mesh. # dxx = df...
1,960
28.268657
79
py
finmag
finmag-master/dev/sandbox/domains/import_mesh.py
from finmag.util.meshes import from_geofile from_geofile("embedded_disk.geo")
79
19
43
py
finmag
finmag-master/dev/sandbox/treecode/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("fastsum_lib", sources = ['fast_sum.c','fast_sum_lib...
602
22.192308
58
py
finmag
finmag-master/dev/sandbox/treecode/test_fast_sum.py
import dolfin as df import numpy as np import time from fastsum_lib import FastSum def exact(xs,xt,charge): res=np.zeros(len(xt)) for j in range(len(xt)): for k in range(len(xs)): r=np.sqrt((xt[j,0]-xs[k,0])**2+(xt[j,1]-xs[k,1])**2+(xt[j,2]-xs[k,2])**2) res[j]+=1.0*charge[k]/...
1,833
20.833333
97
py
finmag
finmag-master/dev/sandbox/treecode/compare.py
import dolfin as df import numpy as np from finmag.native import sundials from finmag.util.timings import default_timer from finmag.energies import Demag if __name__ == '__main__': x0 = y0 = z0 = 0 x1 = 500e-9 y1 = 500e-9 z1 = 2e-9 nx = 120 ny = 120 nz = 3 mesh = df.Box(x0, y0, z0, x1, ...
680
20.967742
59
py
finmag
finmag-master/dev/sandbox/treecode/fastdemag.py
from dolfin import * import dolfin as df import numpy as np import time from fastsum_lib import FastSum import cProfile _nodes =( (0.,), (-0.5773502691896257, 0.5773502691896257), (-0.7745966692414834, 0., 0.7745966692414834), (-0.861136311594053, -0.3399810435848562, 0.3399810435848562, 0.861136311594053), ...
15,200
26.994475
114
py
finmag
finmag-master/dev/sandbox/treecode/__init__.py
0
0
0
py
finmag
finmag-master/dev/sandbox/fkdemag_solver_benchmark/post_processing.py
import numpy as np import dolfin as df import matplotlib.pyplot as plt def column_chart(results, solvers, preconditioners, offset=None, ymax=10): slowest = results.max(0) fastest = results.min(0) default = results[0] no_prec = results[1] fig = plt.figure(figsize=(8, 4)) ax = fig.add_subplot(11...
2,372
38.55
94
py
finmag
finmag-master/dev/sandbox/fkdemag_solver_benchmark/benchmark.py
import dolfin as df import numpy as np import finmag.energies.demag.fk_demag as fk from finmag.util.helpers import vector_valued_function from finmag.native.llg import compute_bem_fk from aeon import default_timer def prepare_demag(S3, m, Ms, unit_length, s_param, solver, p_param, preconditioner, bem, boundary_to_glo...
4,268
43.46875
120
py
finmag
finmag-master/dev/sandbox/fkdemag_solver_benchmark/measurement_runner.py
import dolfin as df import pickle import numpy as np import finmag.energies.demag.fk_demag as fk import matplotlib.pyplot as plt from table_printer import TablePrinter from finmag.util.helpers import vector_valued_function from finmag.native.llg import compute_bem_fk from aeon import default_timer def _prepare_demag_...
10,002
40.506224
139
py
finmag
finmag-master/dev/sandbox/fkdemag_solver_benchmark/run.py
import dolfin as df from finmag.util.meshes import sphere from benchmark import run_demag_benchmark print "List of Krylov subspace methods.\n" for name, description in df.krylov_solver_methods(): print "{:<20} {}".format(name, description) print "\nList of preconditioners.\n" for name, description in df.krylov_so...
1,383
33.6
134
py
finmag
finmag-master/dev/sandbox/fkdemag_solver_benchmark/table_printer.py
""" Contains helpers to build and output tables which look like the following. | xlabel0 xlabel1 xlabel2 ... xlabeln --------|---------------------------------------------------- ylabel0 | entry0 entry1 entry2 ... entryn ylabel1 | entry0 entry1 entry2 ... entryn ylab...
4,028
33.435897
86
py
finmag
finmag-master/dev/sandbox/fkdemag_solver_benchmark/compare_with_lu/memory_profile.py
import time import numpy as np import dolfin as df from finmag.energies import Demag from finmag.util.meshes import sphere @profile def run_benchmark(solver): radius = 10.0 maxh = 0.5 unit_length = 1e-9 mesh = sphere(r=radius, maxh=maxh, directory="meshes") S3 = df.VectorFunctionSpace(mesh, "Lagran...
1,382
26.66
72
py
finmag
finmag-master/dev/sandbox/saving_timesteps_demo_for_FEniCS_guys/diffusion_demo_with_saving.py
""" Extension of the FEniCS tutorial demo for the diffusion equation with Dirichlet conditions. """ from dolfin import * import numpy from time import sleep import tables as pytables # Create mesh and define function space nx = ny = 20 mesh = UnitSquareMesh(nx, ny) V = FunctionSpace(mesh, 'Lagrange', 1) # Define bou...
2,827
25.933333
72
py
finmag
finmag-master/dev/sandbox/mesh/netgen_demag_test.py
import dolfin as df import finmag import numpy as np from finmag.energies import Demag from finmag import Simulation as Sim from finmag.util.mesh_templates import Nanodisk # ############################################# # ###### MESH GENERATOR # LENGTHS lex = 5.76 # nm (Exchange length) # The length of the nanotube...
1,167
25.545455
61
py
finmag
finmag-master/dev/sandbox/mesh/extend_mesh.py
import dolfin as df def test_triangle_mesh(): # Create mesh object and open editor mesh = df.Mesh() editor = df.MeshEditor() editor.open(mesh, 2, 2) editor.init_vertices(3) editor.init_cells(1) # Add vertices editor.add_vertex(0, 0.0, 0.0) editor.add_vertex(1, 1.0, 0.0) editor.add_vertex(2, 0...
1,841
17.237624
44
py
finmag
finmag-master/dev/sandbox/mesh/mshr_demag_test.py
from mshr import Cylinder import dolfin as df import mshr import finmag import numpy as np from finmag.energies import Demag from finmag import Simulation as Sim # ############################################# # ###### MESH GENERATOR # LENGTHS lex = 5.76 # nm (Exchange length) L = 2000. # nm r_ext = 3 * lex # Ext...
1,372
22.271186
71
py
finmag
finmag-master/dev/sandbox/pele/relax.py
import os import dolfin as df import numpy as np from finmag.util import helpers from finmag.physics.effective_field import EffectiveField from finmag.energies import Exchange, DMI, UniaxialAnisotropy from finmag import Simulation as Sim import logging log = logging.getLogger(name="finmag") ONE_DEGREE_PER_NS = 17...
3,349
23.275362
97
py
finmag
finmag-master/dev/sandbox/fenmag/compute_jacobian.py
from dolfin import * class MyLLG(object): def __init__(self, V, alpha, gamma, Ms, M): self.V = V self.alpha = alpha self.gamma = gamma self.Ms = Ms self.M = M self.p = Constant(self.gamma / (1 + self.alpha ** 2)) def H_eff(self): """Very temporary funct...
1,129
27.974359
104
py
finmag
finmag-master/dev/sandbox/fenmag/analytic_solution.py
import numpy as np def macrospin_analytic_solution(alpha, gamma, H, t_array): """ Computes the analytic solution of magnetisation x component as a function of time for the macrospin in applied external magnetic field H. Source: PhD Thesis Matteo Franchin, http://eprints.soton.ac.uk/161207/1.h...
827
32.12
72
py
finmag
finmag-master/dev/sandbox/normal_modes/cases.py
import dolfin as df from finmag import Simulation from finmag.energies import Demag, Exchange, Zeeman from finmag.util.consts import Oersted_to_SI class StdProblem(object): def __init__(self): self.box_size = [200., 200., 5.] # nm self.box_divisions = [40,40,1] # divisions def setup_sim(self,...
1,476
24.465517
77
py
finmag
finmag-master/dev/sandbox/normal_modes/normal_modes.py
import dolfin as df import sys from finmag import Simulation from finmag.energies import Demag, Exchange, Zeeman from finmag.util.consts import Oersted_to_SI, gamma import h5py import scipy.sparse.linalg import numpy as np from finmag.util.helpers import fnormalise def read_relaxed_state(problem): fn = problem.nam...
7,268
26.224719
89
py
finmag
finmag-master/dev/sandbox/normal_modes/normal_modes_tests.py
import dolfin as df import math import numpy as np from finmag import Simulation from finmag.energies import Demag, Zeeman, Exchange from finmag.util.consts import mu0, Oersted_to_SI from finmag.util.helpers import fnormalise from normal_modes import differentiate_fd4 from normal_modes import differentiate_fd2 from nor...
3,392
30.416667
123
py
finmag
finmag-master/dev/sandbox/normal_modes/compute_ground_state.py
from sandbox.normal_modes.normal_modes import find_relaxed_state if __name__=="__main__": ns = [29, 15, 5] find_relaxed_state(ns)
139
22.333333
64
py
finmag
finmag-master/dev/sandbox/normal_modes/__init__.py
__author__ = 'chern'
21
10
20
py
finmag
finmag-master/dev/sandbox/normal_modes/vecfields.py
0
0
0
py
finmag
finmag-master/dev/sandbox/demag/interiorboundary.py
"""A Utility Module for generating interior boundaries in Fenics""" __author__ = "Gabriel Balaban" __copyright__ = __author__ __project__ = "Finmag" __organisation__ = "University of Southampton" #Note when restricting forms ('+') will be on the outside of the submesh, #and ('-') will be on the inside #TODO Expand th...
6,856
34.900524
104
py
finmag
finmag-master/dev/sandbox/demag/FKtruncationsolver.py
from dolfin import * from finmag.demag import solver_base as sb import numpy as np import progressbar as pb ##class FKSolver(sb.DeMagSolver): ## """Class containing methods shared by FK solvers""" ## def __init__(self, problem, degree=1): ## super(FKSolver, self).__init__(problem, degree) class FKSolve...
3,618
32.82243
113
py
finmag
finmag-master/dev/sandbox/demag/timings_Krylov_vs_LU_solver/benchmark_solver_types.py
#!/usr/bin/env python import dolfin as df import numpy as np import sys try: solver_type = sys.argv[1] except IndexError: print("Usage: time_solver_types.py SOLVER_TYPE [N]") sys.exit() try: N = int(sys.argv[2]) except IndexError: N = 3 from finmag.example import barmini, bar from finmag.example...
906
25.676471
83
py
finmag
finmag-master/dev/sandbox/demag/domain_truncation/doffinder.py
"""A Utility Module used to locate the Dofs that lie on a common boundary""" __author__ = "Gabriel Balaban" __copyright__ = __author__ __project__ = "Finmag" __organisation__ = "University of Southampton" from dolfin import * import numpy as np def bounddofs(fspace, facetfunc, num): """BOUNDary DOFS fspace...
1,640
31.176471
81
py
finmag
finmag-master/dev/sandbox/demag/domain_truncation/prob_trunc_testcases.py
"""Standard Demagnetisation Testproblems for truncated solvers""" __author__ = "Gabriel Balaban" __copyright__ = __author__ __project__ = "Finmag" __organisation__ = "University of Southampton" from dolfin import * import numpy as np import prob_base as pb class MagUnitInterval(pb.TruncDemagProblem): ""...
2,679
32.5
93
py
finmag
finmag-master/dev/sandbox/demag/domain_truncation/test_doffinder.py
#Test the dofinder module from doffinder import bounddofs from prob_trunc_testcases import * def test_doffinder1d(): problem = MagUnitInterval() degree = 1 V = FunctionSpace(problem.mesh,"CG",degree) bounddofset = bounddofs(V, problem.coreboundfunc,2) print bounddofset assert len(bounddofset) ...
496
28.235294
117
py
finmag
finmag-master/dev/sandbox/demag/domain_truncation/prob_base.py
"""Base classes for Demagnetisation Problems""" __author__ = "Gabriel Balaban" __copyright__ = __author__ __project__ = "Finmag" __organisation__ = "University of Southampton" from dolfin import * from finmag.util.interiorboundary import InteriorBoundary class TruncDemagProblem(object): """Base cla...
2,241
32.969697
83
py
finmag
finmag-master/dev/sandbox/demag/domain_truncation/solver_nitsche.py
"""Nitsche's Method for a discontinuous variational formulation is used to solve a given demag field problem. The parameter gamma tweaks the amount of discontinuity we allow over the core boundary""" __author__ = "Gabriel Balaban" __copyright__ = __author__ __project__ = "Finmag" __organisation__ = "University of Sout...
9,376
41.622727
116
py
finmag
finmag-master/dev/sandbox/demag/domain_truncation/test_meshsetup.py
"""A set of tests to insure that the quality of the submesh and boundary generation of Interiorboundary and TruncDemagProblem""" __author__ = "Gabriel Balaban" __copyright__ = __author__ __project__ = "Finmag" __organisation__ = "University of Southampton" from dolfin import * import prob_trunc_testcases as pttc #Gl...
2,994
41.183099
161
py
finmag
finmag-master/dev/sandbox/dg_sim/demag_test.py
import dolfin as df import numpy as np from math import pi from finmag.util.meshes import sphere from fk_demag import FKDemagDG as FKDemag from finmag.util.consts import mu0 radius = 1.0 maxh = 0.2 unit_length = 1e-9 volume = 4 * pi * (radius * unit_length) ** 3 / 3 def setup_demag_sphere(Ms): mesh = sphere(r=ra...
3,648
33.102804
106
py
finmag
finmag-master/dev/sandbox/dg_sim/sim.py
import logging import numpy as np import dolfin as df from finmag.util import helpers from finmag.util.meshes import mesh_volume import finmag.util.consts as consts from finmag.native import sundials from finmag.native import llg as native_llg from finmag.util.fileio import Tablewriter from finmag.energies import...
5,948
28.019512
101
py
finmag
finmag-master/dev/sandbox/dg_sim/exchange.py
import dolfin as df import numpy as np import logging from finmag.util.consts import mu0 from finmag.util import helpers import scipy.sparse as sp import scipy.sparse.linalg as spl from scipy.sparse.linalg.dsolve import linsolve logger=logging.getLogger('finmag') """ Compute the exchange field in DG0 space with the h...
15,900
25.996604
90
py
finmag
finmag-master/dev/sandbox/dg_sim/sim_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 sim import Sim from finmag.energies import Zeeman from exchange import ExchangeDG as Exchange MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) def test_sim(do_plot=False): mesh = df...
1,596
22.144928
75
py
finmag
finmag-master/dev/sandbox/dg_sim/fk_demag.py
""" A copy from the existing FK code. This is not a real/pure DG method, I mean, the demagnetisation fields including the magnetic potential are not totally computed by DG methods, such as IP method or the mixed form using BDM and DG space. The idea is actually even we use DG space to represent the effective field an...
11,598
35.589905
117
py
finmag
finmag-master/dev/sandbox/dg_sim/exchange_test.py
import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import pytest import numpy as np import dolfin as df from exchange import ExchangeDG from finmag.energies.exchange import Exchange from finmag.util.consts import mu0 from finmag.util.meshes import box from finmag.field import Field @pytest.fixtu...
3,556
23.531034
107
py
finmag
finmag-master/dev/sandbox/dg_sim/__init__.py
0
0
0
py
finmag
finmag-master/dev/sandbox/dg_sim/experiment/compare_exch2.py
import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import finmag import dolfin as df import numpy as np xs=np.linspace(0.5,2*np.pi-0.5,10) def delta_cg(mesh,expr): V = df.FunctionSpace(mesh, "CG", 1) Vv = df.VectorFunctionSpace(mesh, "CG", 1) u = df.interpolate(expr, Vv) u...
2,851
21.108527
71
py
finmag
finmag-master/dev/sandbox/dg_sim/experiment/compare_exch.py
import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import finmag import dolfin as df import numpy as np xs=np.linspace(1e-10+0.5,2*np.pi-0.5,10) def delta_cg(mesh,expr): V = df.FunctionSpace(mesh, "CG", 1) u = df.interpolate(expr, V) u1 = df.TrialFunction(V) v1 = df.TestFu...
4,050
22.017045
71
py
finmag
finmag-master/dev/sandbox/dg_sim/experiment/cg2dg_fields.py
""" The functions below are intend to test how to obtain the fields in DG0 space for the case that the potential is stored in CG space. """ import dolfin as df import numpy as np df.parameters.reorder_dofs_serial = False def compute_field1(mesh,phi): V = df.FunctionSpace(mesh, 'CG', 1) DG3 = df.VectorFunctio...
1,522
18.525641
84
py
finmag
finmag-master/dev/sandbox/dg_sim/experiment/demag_test_dg.py
import dolfin as df import numpy as np df.parameters.reorder_dofs_serial = False mu0=np.pi*4e-7 #import matplotlib as mpl #mpl.use("Agg") #import matplotlib.pyplot as plt def compute_phi(mesh,m): V = df.FunctionSpace(mesh, 'CG', 1) W = df.VectorFunctionSpace(mesh, 'CG', 1) w = df.TrialFunction(W) v ...
4,295
22.347826
84
py
finmag
finmag-master/dev/sandbox/dg_sim/experiment/compare_exch_dg_cg.py
import dolfin as df import numpy as np import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt def delta_cg(mesh,expr): V = df.FunctionSpace(mesh, "CG", 1) u = df.interpolate(expr, V) u1 = df.TrialFunction(V) v1 = df.TestFunction(V) K = df.assemble(df.inner(df.grad(u1), df.gr...
2,246
22.904255
71
py
finmag
finmag-master/dev/sandbox/crazy_spin/sim2.py
import dolfin as df import numpy as np import pylab as plt from finmag import Simulation as Sim from finmag.energies import Exchange, DMI, Zeeman from finmag.energies.zeeman import TimeZeemanPython from finmag.util.meshes import nanodisk from finmag.util.consts import mu0 def skyrm_init(x): r = (x[0]**2 + x[1]**2)...
1,686
19.325301
60
py
finmag
finmag-master/dev/sandbox/crazy_spin/sim.py
import dolfin as df import numpy as np import pylab as plt from finmag import Simulation as Sim from finmag.energies import Exchange, DMI, Zeeman from finmag.util.meshes import nanodisk from finmag.util.consts import mu0 def skyrm_init(x): r = (x[0]**2 + x[1]**2)**0.5 if r < 50e-9: return (0, 0, -1) ...
1,753
20.13253
67
py
finmag
finmag-master/dev/sandbox/repeatability/sundials_ode.py
import os import numpy as np from finmag.native import sundials def call_back(t, y): return y**2-y**3 class Test_Sundials(object): def __init__(self, call_back, x0): self.sim = call_back self.x0 = x0 self.x = x0.copy() self.ode_count = 0 self...
1,295
22.142857
72
py
finmag
finmag-master/dev/sandbox/repeatability/repeatable.py
import os import dolfin as df import numpy as np import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import finmag.util.consts as consts from sundials_ode import Test_Sundials MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) alpha = 0.01 H0 = 1e5 Ms = 8.6e5 def call_back(t,y): ...
2,013
20.655914
75
py
finmag
finmag-master/dev/bin/ipynbdoctest.py
#!/usr/bin/env python # IPython notebook testing script. This is based on the gist [1] (revision 5). # # Each cell is submitted to the kernel, and the outputs are compared # with those stored in the notebook. If the output is an image this is # currently ignored. # # https://gist.github.com/minrk/2620735 """ IPython...
20,556
37.640977
238
py
finmag
finmag-master/dev/logbooks/finmaglogs.py
""" Using CherryPy to put together very basic webserver to display today's discussions on the IRC channel. Hans Fangohr, 6 September 2012 """ import os import time import cherrypy REFRESHCODE = """<META HTTP-EQUIV="REFRESH" CONTENT="60"> """ class HelloWorld: def index(self): # CherryPy will call this m...
1,743
31.296296
111
py
finmag
finmag-master/doc/generate_doc.py
import os module_import_error = """ Unable to import the %s module Error: %s Did you forget to update your PYTHONPATH variable?""" modules = open("modules.txt", "r").readlines() for module in modules: module = module.split() name = ' '.join(module[:-1]) filename = '_'.join(module[:-1]) + '.rst' module...
895
26.151515
68
py
finmag
finmag-master/doc/ipynb_sphinxext.py
''' Sphinx/docutils extension to convert .ipynb files to .html files and create links to the generated html in the source. To use it, include something like the following in your .rst file: :ipynb:`path/to/notebook.ipynb` XXX TODO: Currently this only works for the 'html' builder (not for singlehtml or...
3,152
33.271739
153
py
finmag
finmag-master/doc/conf.py
# -*- coding: utf-8 -*- # # Finmag documentation build configuration file, created by # sphinx-quickstart on Thu Feb 23 12:34:28 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All ...
8,297
31.541176
80
py
finmag
finmag-master/doc/create_wrapper_for_ipynb_html_file.py
#!/usr/bin/env python # This script takes a .ipynb file as input and generates a minimal # .rst file that wraps the converted .html output of the ipython # notebook using sphinx's :raw: directive. It also adds a title, which # is extracted from the notebook cells if present (otherwise it just # uses the input filename...
2,775
33.7
152
py
finmag
finmag-master/doc/add_heading_if_needed.py
#!/usr/bin/env python """ Scan a given file 'FILENAME.rst' for header lines up to a certain level. If no such lines are encountered, a header line of the following form is added at the top of the file: FILENAME.ipynb ============== """ import sys import re import os # Heading symbols used by nbconvert, in des...
2,176
32.492308
81
py
finmag
finmag-master/doc/raw-notes/demag-Fredkin-Koehler-method-and-macro-geometry/script/demag_pbc_1d_ringdown.py
import numpy as np import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Demag, Zeeman, UniaxialAnisotropy from finmag.energies.zeeman import TimeZeemanPython import matplotlib.pyplot as plt from finmag.util.f...
2,294
19.491071
76
py
finmag
finmag-master/doc/raw-notes/demag-Fredkin-Koehler-method-and-macro-geometry/script/demag_pbc_1d.py
import numpy as np import matplotlib as mpl mpl.use("Agg") import matplotlib.pyplot as plt import dolfin as df from finmag import Simulation from finmag.energies import Exchange, DMI, Demag, Zeeman, UniaxialAnisotropy from finmag.energies.zeeman import TimeZeemanPython import matplotlib.pyplot as plt from finmag.util.f...
1,995
21.942529
76
py
finmag
finmag-master/doc/ipython_notebooks_src/2D_square_sim.py
""" Script to relax a skyrmion in the middle of a 2D square system (trying to replicate a Heisenberg model system) IMPORTANT: We are using the DMI expression from [1] D(m_x * dm_z/dx - m_z * dm_x/dx) + D(m_y * dm_z/dy - m_z * dm_y/dy) * df.dx References: [1] Rohart, S. and Thiaville A., Phys. Rev. B 88, 1844...
12,781
31.524173
79
py
finmag
finmag-master/doc/tailored_tutorials/make-tailored-tutorial-tarball.py
# ## need to move these configuration details into a separate file #tutorials = ['tutorial-example2','tutorial-saving-averages-demo','tutorial-use-of-logging'] #conf = {'nameshort':'Hesjedahl', # 'names': ('Thorsten Hesjedahl','Shilei Zhang'), # 'header':".. contents::\n\n", # 'ipynbdir':"The raw ...
8,130
36.470046
112
py