engine

package
v3.4.0-beta1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2014 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TILE   = 2           // tile size in grains
	LAMBDA = TILE * TILE // expected grains per tile
)
View Source
const (
	EULER = 1
	HEUN  = 2
)
View Source
const (
	X = 0
	Y = 1
	Z = 2
)
View Source
const (
	SCALAR = 1
	VECTOR = 3
)
View Source
const DEFAULT_KERNEL_ACC = 6

Default accuracy setting for demag kernel. TODO: variable?

View Source
const NREGION = 256 // maximum number of regions. (!) duplicated in CUDA
View Source
const VERSION = "mumax3.4.0 BETA1"

Variables

View Source
var (
	Ku1, Kc1              ScalarParam // uniaxial and cubic anis constants
	AnisU, AnisC1, AnisC2 VectorParam // unixial and cubic anis axes

	B_anis     vAdder     // field due to uniaxial anisotropy (T)
	E_anis     *GetScalar // Anisotorpy energy
	Edens_anis sAdder     // Anisotropy energy density
)

Anisotropy variables

View Source
var (
	Msat        ScalarParam
	Bsat        derivedParam
	M_full      vSetter
	B_demag     vSetter
	E_demag     *GetScalar
	Edens_demag sAdder
	EnableDemag = true // enable/disable demag field

)

demag variables

View Source
var (
	E_total     = NewGetScalar("E_total", "J", "Total energy", GetTotalEnergy)
	Edens_total sSetter
)
View Source
var (
	Aex    ScalarParam // Exchange stiffness
	Dex    ScalarParam // DMI strength
	B_exch vAdder      // exchange field (T) output handle

	E_exch     *GetScalar
	Edens_exch sAdder
)
View Source
var (
	BubblePos   = NewGetVector("ext_bubblepos", "m", "Bubble core position", bubblePos)
	BubbleDist  = NewGetScalar("ext_bubbledist", "m", "Bubble traveled distance", bubbleDist)
	BubbleSpeed = NewGetScalar("ext_bubblespeed", "m/s", "Bubble velocity", bubbleSpeed)
)
View Source
var (
	MFM        sSetter
	MFMLift    numberParam
	MFMTipSize numberParam
)
View Source
var (
	Solver = NewSolver(Torque.Set, M.normalize, 1e-15, mag.Gamma0, HeunStep)
	Time   float64 // time in seconds

	Inject = make(chan func()) // injects code in between time steps. Used by web interface.

)
View Source
var (
	TotalShift                      float64                        // accumulated window shift (X) in meter
	ShiftMagL, ShiftMagR            data.Vector                    // when shifting m, put these value at the left/right edge.
	ShiftM, ShiftGeom, ShiftRegions bool        = true, true, true // should shift act on magnetization, geometry, regions?
)
View Source
var (
	Temp ScalarParam

	B_therm     vAdder
	E_therm     *GetScalar
	Edens_therm sAdder
)
View Source
var (
	Alpha        ScalarParam
	Xi           ScalarParam
	Pol          ScalarParam
	Lambda       ScalarParam
	EpsilonPrime ScalarParam
	FixedLayer   VectorParam
	Torque       vSetter    // total torque in T
	LLTorque     vSetter    // Landau-Lifshitz torque/γ0, in T
	STTorque     vAdder     // Spin-transfer torque/γ0, in T
	J            excitation // Polarized electrical current density
	MaxTorque    *GetScalar
)
View Source
var (
	B_ext        excitation
	E_Zeeman     *GetScalar
	Edens_zeeman sAdder
)
View Source
var B_eff vSetter // total effective field
View Source
var CorePos = NewGetVector("ext_corepos", "m", "Vortex core position", corePos)
View Source
var (
	DWPos = NewGetScalar("ext_dwpos", "m", "Position of the simulation window while following a domain wall", GetShiftPos) // TODO: make more accurate
)
View Source
var (
	DWSpeed = NewGetScalar("ext_dwspeed", "m/s", "Speed of the simulation window while following a domain wall", getShiftSpeed)
)

used for speed

View Source
var DWTiltPMA = NewGetScalar("ext_dwtilt", "rad", "PMA domain wall tilt", dwTiltPMA)

PMA domain wall tilt assuming straight wall.

View Source
var (
	GUI = guistate{Quants: make(map[string]Quantity), Params: make(map[string]Param)}
)

global GUI state stores what is currently shown in the web page.

View Source
var M magnetization // reduced magnetization (unit length)
View Source
var OD = "./" // Output directory
View Source
var StartTime = time.Now()
View Source
var Table = *newTable("table") // output handle for tabular data (average magnetization etc.)
View Source
var Timeout = 3 * time.Second

exit finished simulation this long after browser was closed

View Source
var UNAME = VERSION + " " + runtime.GOOS + "_" + runtime.GOARCH + " " + runtime.Version() + " (" + runtime.Compiler + ")"
View Source
var World = script.NewWorld()

holds the script state (variables etc)

Functions

func AddAnisotropyField

func AddAnisotropyField(dst *data.Slice)

Add the anisotropy field to dst

func AddExchangeField

func AddExchangeField(dst *data.Slice)

Adds the current exchange field to dst

func AddSTTorque

func AddSTTorque(dst *data.Slice)

Adds the current spin transfer torque to dst

func AddThermalField

func AddThermalField(dst *data.Slice)

func AutoSave

func AutoSave(quant Quantity, period float64)

Register quant to be auto-saved every period. period == 0 stops autosaving.

func CenterWall

func CenterWall(magComp int)

This post-step function centers the simulation window on a domain wall between up-down (or down-up) domains (like in perpendicular media). E.g.:

PostStep(CenterPMAWall)

func Close

func Close()

Cleanly exits the simulation, assuring all output is flushed.

func Comp

func Comp(parent Averagable, c int) *comp

func Const

func Const(e script.Expr) bool

checks if a script expression contains t (time)

func DeclConst

func DeclConst(name string, value float64, doc string)

Add a constant to the script world

func DeclFunc

func DeclFunc(name string, f interface{}, doc string)

Add a function to the script world

func DeclLValue

func DeclLValue(name string, value script.LValue, doc string)

Add an LValue to the script world. Assign to LValue invokes SetValue()

func DeclROnly

func DeclROnly(name string, value interface{}, doc string)

Add a read-only variable to the script world. It can be changed, but not by the user.

func DeclVar

func DeclVar(name string, value interface{}, doc string)

Add a (pointer to) variable to the script world

func DefRegion

func DefRegion(id int, s Shape)

Define a region with id (0-255) to be inside the Shape.

func DefRegionCell

func DefRegionCell(id int, x, y, z int)

func DoOutput

func DoOutput()

Periodically called by run loop to save everything that's needed at this time.

func Download

func Download(q Quantity) *data.Slice

Download a quantity to host, or just return its data when already on host.

func EulerStep

func EulerStep(s *solver, y *data.Slice)

Euler method, can be used as solver.Step.

func Eval

func Eval(code string)

func EvalFile

func EvalFile(code *script.BlockStmt)

evaluate code, exit on error (behavior for input files)

func Expect

func Expect(msg string, have, want, maxError float64)

Test if have lies within want +/- maxError, and print suited message.

func ExpectV

func ExpectV(msg string, have, want data.Vector, maxErr float64)

func Fprintln

func Fprintln(filename string, msg ...interface{})

Append msg to file. Used to write aggregated output of many simulations in one file.

func GetAnisotropyEnergy

func GetAnisotropyEnergy() float64

func GetDemagEnergy

func GetDemagEnergy() float64

Returns the current demag energy in Joules.

func GetExchangeEnergy

func GetExchangeEnergy() float64

Returns the current exchange energy in Joules. Note: the energy is defined up to an arbitrary constant, ground state energy is not necessarily zero or comparable to other simulation programs.

func GetMaxTorque

func GetMaxTorque() float64

Gets

func GetShiftPos

func GetShiftPos() float64

func GetThermalEnergy

func GetThermalEnergy() float64

func GetTotalEnergy

func GetTotalEnergy() float64

Returns the total energy in J.

func GetZeemanEnergy

func GetZeemanEnergy() float64

func HeunStep

func HeunStep(s *solver, y *data.Slice)

Adaptive Heun method, can be used as solver.Step

func Index2Coord

func Index2Coord(ix, iy, iz int) data.Vector

converts cell index to coordinate, internal coordinates

func Info

func Info(nComp int, name, unit string) info

func InjectAndWait

func InjectAndWait(task func())

inject code into engine and wait for it to complete.

func KeepAlive

func KeepAlive() time.Time

func LoadFile

func LoadFile(fname string) *data.Slice

Read a magnetization state from .dump file.

func LogInput

func LogInput(msg ...interface{})

func LogOutput

func LogOutput(msg ...interface{})

func Mesh

func Mesh() *data.Mesh

func NewSlice

func NewSlice(ncomp, Nx, Ny, Nz int) *data.Slice

Returns a new new slice (3D array) with given number of components and size.

func NewSolver

func NewSolver(torqueFn func(dst *data.Slice), postStep func(), dt_si, dt_mul float64, step func(*solver, *data.Slice)) solver

func OverrideExchangeLength

func OverrideExchangeLength(region1, region2 int, exlen float64)

Defines the exchange coupling between different regions by specifying the exchange length of the interaction between them.

lex := sqrt(2*Aex / Msat)

In case of different materials it is not always clear what the exchange between them should be, especially if they have different Msat. By specifying the exchange length, it is up to the user to decide which Msat to use. A negative length may be specified to obtain antiferromagnetic coupling.

func PostStep

func PostStep(f func())

Register function f to be called after every time step. Typically used, e.g., to manipulate the magnetization.

func RemoveLRSurfaceCharge

func RemoveLRSurfaceCharge(region int, mxLeft, mxRight float64)

For a nanowire magnetized in-plane, with mx = mxLeft on the left end and mx = mxRight on the right end (both -1 or +1), add a B field needed to compensate for the surface charges on the left and right edges. This will mimic an infinitely long wire.

func Run

func Run(seconds float64)

Run the simulation for a number of seconds.

func RunInteractive

func RunInteractive()

Enter interactive mode. Simulation is now exclusively controlled by web GUI

func RunWhile

func RunWhile(condition func() bool)

Runs as long as condition returns true.

func Save

func Save(q Quantity)

Save once, with auto file name

func SaveAs

func SaveAs(q Quantity, fname string)

Save under given file name (transparant async I/O).

func Serve

func Serve(port string)

Start web gui on given port, blocks.

func SetCellSize

func SetCellSize(cx, cy, cz float64)

func SetDemagField

func SetDemagField(dst *data.Slice)

Sets dst to the current demag field

func SetEffectiveField

func SetEffectiveField(dst *data.Slice)

Sets dst to the current effective field (T).

func SetGeom

func SetGeom(s Shape)

func SetGridSize

func SetGridSize(Nx, Ny, Nz int)

func SetLLTorque

func SetLLTorque(dst *data.Slice)

Sets dst to the current Landau-Lifshitz torque

func SetMFM

func SetMFM(dst *data.Slice)

func SetMFull

func SetMFull(dst *data.Slice)

Sets dst to the full (unnormalized) magnetization in A/m

func SetMesh

func SetMesh(Nx, Ny, Nz int, cellSizeX, cellSizeY, cellSizeZ float64, pbcx, pbcy, pbcz int)

Set the simulation mesh to Nx x Ny x Nz cells of given size. Can be set only once at the beginning of the simulation. TODO: dedup arguments from globals

func SetOD

func SetOD(od string, force bool)

SetOD sets the output directory where auto-saved files will be stored. The -o flag can also be used for this purpose.

func SetPBC

func SetPBC(nx, ny, nz int)

func SetSolver

func SetSolver(typ int)

func SetTorque

func SetTorque(dst *data.Slice)

Sets dst to the current total torque

func SetTotalEdens

func SetTotalEdens(dst *data.Slice)

func Shift

func Shift(dx int)

shift the simulation window over dx cells in X direction

func Steps

func Steps(n int)

Run the simulation for a number of steps.

func TableAdd

func TableAdd(col TableData)

func TableAutoSave

func TableAutoSave(period float64)

func TableSave

func TableSave()

func ThermSeed

func ThermSeed(seed int)

Seeds the thermal noise generator

func Vector

func Vector(x, y, z float64) data.Vector

Constructs a vector

func Voronoi

func Voronoi(grainsize float64, numRegions, seed int)

Types

type Averagable

type Averagable interface {
	Quantity
	// contains filtered or unexported methods
}

type Config

type Config func(x, y, z float64) data.Vector

Magnetic configuration returns m vector for position (x,y,z)

func AntiVortex

func AntiVortex(circ, pol int) Config

func Antiskyrmion

func Antiskyrmion(charge, pol int) Config

func RandomMag

func RandomMag() Config

func Skyrmion

func Skyrmion(charge, pol int) Config

func TwoDomain

func TwoDomain(mx1, my1, mz1, mxwall, mywall, mzwall, mx2, my2, mz2 float64) Config

Make a 2-domain configuration with domain wall. (mx1, my1, mz1) and (mx2, my2, mz2) are the magnetizations in the left and right domain, respectively. (mxwall, mywall, mzwall) is the magnetization in the wall. The wall is smoothed over a few cells so it will easily relax to its ground state. E.g.:

TwoDomain(1,0,0,  0,1,0,  -1,0,0) // head-to-head domains with transverse (Néel) wall
TwoDomain(1,0,0,  0,0,1,  -1,0,0) // head-to-head domains with perpendicular (Bloch) wall
TwoDomain(0,0,1,  1,0,0,   0,0,-1)// up-down domains with Bloch wall

func Uniform

func Uniform(mx, my, mz float64) Config

Returns a uniform magnetization state. E.g.:

M = Uniform(1, 0, 0)) // saturated along X

func Vortex

func Vortex(circ, pol int) Config

Make a vortex magnetization with given circulation and core polarization (+1 or -1). The core is smoothed over a few exchange lengths and should easily relax to its ground state.

func VortexWall

func VortexWall(mleft, mright float64, circ, pol int) Config

Make a vortex wall configuration.

func (Config) Add

func (c Config) Add(weight float64, other Config) Config

func (Config) RotZ

func (c Config) RotZ(θ float64) Config

Rotates the configuration around the Z-axis, over θ radians.

func (Config) Scale

func (c Config) Scale(sx, sy, sz float64) Config

Scale returns a scaled copy of configuration c.

func (Config) Transl

func (c Config) Transl(dx, dy, dz float64) Config

Transl returns a translated copy of configuration c. E.g.:

M = Vortex(1, 1).Transl(100e-9, 0, 0)  // vortex with center at x=100nm

type DataTable

type DataTable struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func (*DataTable) Add

func (t *DataTable) Add(output TableData)

func (*DataTable) NComp

func (i *DataTable) NComp() int

func (*DataTable) Name

func (i *DataTable) Name() string

func (*DataTable) Save

func (t *DataTable) Save()

func (*DataTable) Unit

func (i *DataTable) Unit() string

type GetScalar

type GetScalar struct {
	// contains filtered or unexported fields
}

func NewGetScalar

func NewGetScalar(name, unit, doc string, get func() float64) *GetScalar

INTERNAL

func (*GetScalar) Average

func (g *GetScalar) Average() float64

func (*GetScalar) Get

func (g *GetScalar) Get() float64

type GetVector

type GetVector struct {
	// contains filtered or unexported fields
}

func NewGetVector

func NewGetVector(name, unit, doc string, get func() []float64) *GetVector

INTERNAL

func (*GetVector) Average

func (g *GetVector) Average() data.Vector

func (*GetVector) Get

func (g *GetVector) Get() data.Vector

type Param

type Param interface {
	NComp() int
	Name() string
	Unit() string

	IsUniform() bool
	// contains filtered or unexported methods
}

displayable quantity in GUI Parameters section

type Quantity

type Quantity interface {
	Slice() (q *data.Slice, recycle bool) // get quantity data (GPU or CPU), indicate need to recycle
	NComp() int
	Name() string
	Unit() string
	Mesh() *data.Mesh
}

Any space-dependent quantity

type Regions

type Regions struct {
	// contains filtered or unexported fields
}

stores the region index for each cell

func (*Regions) Gpu

func (r *Regions) Gpu() *cuda.Bytes

Get the region data on GPU

func (*Regions) HostArray

func (r *Regions) HostArray() [][][]byte

func (*Regions) HostList

func (r *Regions) HostList() []byte

func (*Regions) Mesh

func (r *Regions) Mesh() *data.Mesh

func (*Regions) NComp

func (i *Regions) NComp() int

func (*Regions) Name

func (i *Regions) Name() string

func (*Regions) SetCell

func (r *Regions) SetCell(ix, iy, iz int, region int)

Set the region of one cell TODO dedup

func (*Regions) Slice

func (r *Regions) Slice() (*data.Slice, bool)

Get returns the regions as a slice of floats, so it can be output.

func (*Regions) Unit

func (i *Regions) Unit() string

type ScalarParam

type ScalarParam struct {
	// contains filtered or unexported fields
}

specialized param with 1 component

func (*ScalarParam) Average

func (p *ScalarParam) Average() float64

func (*ScalarParam) Child

func (p *ScalarParam) Child() []script.Expr

func (*ScalarParam) Eval

func (p *ScalarParam) Eval() interface{}

func (*ScalarParam) GetRegion

func (p *ScalarParam) GetRegion(region int) float64

func (*ScalarParam) InputType

func (p *ScalarParam) InputType() reflect.Type

func (*ScalarParam) IsUniform

func (p *ScalarParam) IsUniform() bool

func (*ScalarParam) Mesh

func (p *ScalarParam) Mesh() *data.Mesh

func (*ScalarParam) Name

func (p *ScalarParam) Name() string

func (*ScalarParam) Region

func (p *ScalarParam) Region(r int) *sOneReg

func (*ScalarParam) Set

func (p *ScalarParam) Set(v float64)

func (*ScalarParam) SetRegion

func (p *ScalarParam) SetRegion(region int, f script.ScalarFunction)

func (*ScalarParam) SetValue

func (p *ScalarParam) SetValue(v interface{})

func (*ScalarParam) Type

func (p *ScalarParam) Type() reflect.Type

func (*ScalarParam) Unit

func (p *ScalarParam) Unit() string

type Shape

type Shape func(x, y, z float64) bool

geometrical shape for setting sample geometry

func Cell

func Cell(ix, iy, iz int) Shape

Single cell with given index

func Circle

func Circle(diam float64) Shape

func Cuboid

func Cuboid(sidex, sidey, sidez float64) Shape

3D Rectangular slab with given sides.

func Cylinder

func Cylinder(diam, height float64) Shape

cylinder along z.

func Ellipse

func Ellipse(diamx, diamy float64) Shape

func Ellipsoid

func Ellipsoid(diamx, diamy, diamz float64) Shape

Ellipsoid with given diameters

func ImageShape

func ImageShape(fname string) Shape

func Layers

func Layers(a, b int) Shape

Cell layers #a (inclusive) up to #b (exclusive).

func Rect

func Rect(sidex, sidey float64) Shape

2D Rectangle with given sides.

func Universe

func Universe() Shape

func XRange

func XRange(a, b float64) Shape

All cells with x-coordinate between a and b

func YRange

func YRange(a, b float64) Shape

All cells with y-coordinate between a and b

func ZRange

func ZRange(a, b float64) Shape

All cells with z-coordinate between a and b

func (Shape) Add

func (a Shape) Add(b Shape) Shape

Union of shapes a and b (logical OR).

func (Shape) Intersect

func (a Shape) Intersect(b Shape) Shape

Intersection of shapes a and b (logical AND).

func (Shape) Inverse

func (s Shape) Inverse() Shape

Inverse (outside) of shape (logical NOT).

func (Shape) Repeat

func (s Shape) Repeat(periodX, periodY, periodZ float64) Shape

Infinitely repeats the shape with given period in x, y, z. A period of 0 or infinity means no repetition.

func (Shape) RotX

func (s Shape) RotX(θ float64) Shape

Rotates the shape around the X-axis, over θ radians.

func (Shape) RotY

func (s Shape) RotY(θ float64) Shape

Rotates the shape around the Y-axis, over θ radians.

func (Shape) RotZ

func (s Shape) RotZ(θ float64) Shape

Rotates the shape around the Z-axis, over θ radians.

func (Shape) Scale

func (s Shape) Scale(sx, sy, sz float64) Shape

Scale returns a scaled copy of the shape.

func (Shape) Sub

func (a Shape) Sub(b Shape) Shape

Removes b from a (logical a AND NOT b)

func (Shape) Transl

func (s Shape) Transl(dx, dy, dz float64) Shape

Transl returns a translated copy of the shape.

func (Shape) Xor

func (a Shape) Xor(b Shape) Shape

Logical XOR of shapes a and b

type TableData

type TableData interface {
	Name() string
	Unit() string
	NComp() int
	// contains filtered or unexported methods
}

can be saved in table

type VectorParam

type VectorParam struct {
	// contains filtered or unexported fields
}

vector input parameter, settable by user

func (*VectorParam) Average

func (p *VectorParam) Average() data.Vector

func (*VectorParam) Child

func (p *VectorParam) Child() []script.Expr

func (*VectorParam) Comp

func (p *VectorParam) Comp(c int) *comp

func (*VectorParam) Eval

func (p *VectorParam) Eval() interface{}

func (*VectorParam) GetRegion

func (p *VectorParam) GetRegion(region int) [3]float64

func (*VectorParam) InputType

func (p *VectorParam) InputType() reflect.Type

func (*VectorParam) IsUniform

func (p *VectorParam) IsUniform() bool

func (*VectorParam) Mesh

func (p *VectorParam) Mesh() *data.Mesh

func (*VectorParam) Name

func (p *VectorParam) Name() string

func (*VectorParam) Region

func (p *VectorParam) Region(r int) *vOneReg

func (*VectorParam) SetRegion

func (p *VectorParam) SetRegion(region int, f script.VectorFunction)

func (*VectorParam) SetValue

func (p *VectorParam) SetValue(v interface{})

func (*VectorParam) Type

func (p *VectorParam) Type() reflect.Type

func (*VectorParam) Unit

func (p *VectorParam) Unit() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL