engine

package
v3.0.12+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2013 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

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

Variables

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

	B_anis adder // field due to uniaxial anisotropy (T)
	E_anis = NewGetScalar("E_anis", "J", "Anisotropy energy (uni+cubic)", getAnisotropyEnergy)
)

Anisotropy variables

View Source
var (
	Msat            ScalarParam
	Bsat            derivedParam
	M_full, B_demag setter
	E_demag         = NewGetScalar("E_demag", "J", "Magnetostatic energy", getDemagEnergy)
	EnableDemag     = true // enable/disable demag field

)

demag variables

View Source
var (
	M             magnetization // reduced magnetization (unit length)
	B_eff, Torque setter
)
View Source
var (
	Aex, Dex ScalarParam
	B_exch   adder // exchange field (T) output handle

	E_exch = NewGetScalar("E_exch", "J", "Exchange energy (normal+DM)", getExchangeEnergy)
)
View Source
var (
	Solver cuda.Heun
	Time   float64 // time in seconds  // todo: hide? setting breaks autosaves

	Inject = make(chan func()) // injects code in between time steps. Used by web interface.
)
View Source
var (
	Alpha, Xi ScalarParam
	LLTorque  setter     // Landau-Lifshitz torque/γ0, in T
	STTorque  adder      // Spin-transfer torque/γ0, in T
	JPol      excitation // Polarized electrical current density
	MaxTorque = NewGetScalar("maxTorque", "T", "", GetMaxTorque)
)
View Source
var (
	B_ext    excitation
	E_Zeeman = NewGetScalar("E_Zeeman", "J", "Zeeman energy", getZeemanEnergy)
)
View Source
var (
	E_total = NewGetScalar("E_total", "J", "Total energy", GetTotalEnergy)
)
View Source
var FFTM fftm // FFT of m
View Source
var (
	KeepAlive = func() time.Time { return time.Time{} } // overwritten by gui server

)
View Source
var OD = "./" // Output directory
View Source
var StartTime = time.Now()
View Source
var Table = *newTable("datatable") // output handle for tabular data (average magnetization etc.)
View Source
var UNAME = VERSION + runtime.GOOS + "_" + runtime.GOARCH + " " + runtime.Version() + "(" + runtime.Compiler + ")"
View Source
var World = script.NewWorld()

Functions

func AsyncSave

func AsyncSave(fname string, s *data.Slice, info data.Meta)

Asynchronously save slice to file. Slice should be on CPU and not be written after this call.

func AutoSave

func AutoSave(quant Getter, period float64)

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

func Average

func Average(s Getter) []float64

average in userspace XYZ order does not yet take into account volume. pass volume parameter, possibly nil?

func Close

func Close()

Cleanly exits the simulation, assuring all output is flushed.

func DeclConst

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

func DeclFunc

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

func DeclLValue

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

func DeclPure

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

func DeclROnly

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

func DeclVar

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

func DefRegion

func DefRegion(id int, s Shape)

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

func DoOutput

func DoOutput()

Called to save everything that's needed at this time.

func Doc

func Doc(nComp int, name, unit string) doc

func Download

func Download(q Getter) *data.Slice

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

func Eval

func Eval(code string, gui *gui.Doc)

func Expect

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

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

func Fprintln

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

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

func GetMaxTorque

func GetMaxTorque() float64

TODO: could implement maxnorm(torque) (getfunc)

func GetTotalEnergy

func GetTotalEnergy() float64

Returns the total energy in J.

func Info

func Info(nComp int, name, unit string, m *data.Mesh) info

func InjectAndWait

func InjectAndWait(task func())

inject code into engine and wait for it to complete.

func LoadFile

func LoadFile(fname string) *data.Slice

Read a magnetization state from .dump file.

func MakeAvg

func MakeAvg(s Getter) *reduced

func MakeAvgRegion

func MakeAvgRegion(s Getter, region int) *reduced

func Mesh

func Mesh() *data.Mesh

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 Run

func Run(seconds float64)

Run the simulation for a number of seconds.

func RunWhile

func RunWhile(condition func() bool)

Runs as long as condition returns true.

func Save

func Save(q Getter)

Save once, with auto file name

func SaveAs

func SaveAs(q Getter, 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 SetGeom

func SetGeom(s Shape)

func SetMesh

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

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.

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 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 Vector

func Vector(x, y, z float64) [3]float64

Constructs a vector

func WorldSize

func WorldSize() [3]float64

Types

type Config

type Config func(x, y, z float64) [3]float64

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

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) 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) Save

func (t *DataTable) Save()

type GetFunc

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

simple implementation of getVec

func NewGetScalar

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

INTERNAL

func NewGetVector

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

INTERNAL

func (*GetFunc) NComp

func (i *GetFunc) NComp() int

func (*GetFunc) TableData

func (g *GetFunc) TableData() []float64

type Getter

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

type Param

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

displayable in GUI Parameters section

type Regions

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

func (*Regions) Get

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

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

func (*Regions) Gpu

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

Get the region data on GPU, first uploading it if needed.

func (*Regions) Mesh

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

func (*Regions) NComp

func (i *Regions) NComp() int

func (*Regions) SetCell

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

Set the region of one cell

type ScalarParam

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

specialized param with 1 component

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) Region

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

func (*ScalarParam) SetRegion

func (p *ScalarParam) SetRegion(region int, value float64)

func (*ScalarParam) SetValue

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

func (*ScalarParam) TableData

func (p *ScalarParam) TableData() []float64

Parameter TableData is region 0

func (*ScalarParam) Type

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

type Shape

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

geometrical shape for setting sample geometry

func Cell

func Cell(k, j, i 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 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 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) 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 {
	TableData() []float64 // TODO: output float32s only
	Name() string
	Unit() string
	NComp() int
}

can be saved in table

type VectorParam

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

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) Region

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

func (*VectorParam) SetRegion

func (p *VectorParam) SetRegion(region int, value [3]float64)

func (*VectorParam) SetValue

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

func (*VectorParam) TableData

func (p *VectorParam) TableData() []float64

Parameter TableData is region 0

func (*VectorParam) Type

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

Jump to

Keyboard shortcuts

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