Skip to content

Commit

Permalink
timedep excitation extra test file and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
barnex committed Oct 9, 2013
1 parent 357723e commit f7af119
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engine/excitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/mumax/3/cuda"
"github.com/mumax/3/data"
"github.com/mumax/3/script"
"log"
"reflect"
)

Expand Down Expand Up @@ -62,12 +63,13 @@ func assureGPU(s *data.Slice) *data.Slice {
}

// user script: has to be 3-vector
func (e *excitation) SetRegion(region int, value [3]float64) {
e.perRegion.setRegion(region, value[:])
func (e *excitation) SetRegion(region int, f script.VectorFunction) {
e.perRegion.SetRegion(region, f)
}

// for gui (nComp agnostic)
func (e *excitation) setRegion(region int, value []float64) {
log.Println("TODO: time-dep gui")
e.perRegion.setRegion(region, value)
}

Expand Down
3 changes: 3 additions & 0 deletions engine/vectorparam.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package engine
import (
"github.com/mumax/3/script"
"github.com/mumax/3/util"
"log"
"reflect"
)

Expand All @@ -26,8 +27,10 @@ func (p *VectorParam) SetValue(v interface{}) {

func (p *VectorParam) setRegionsFunc(r1, r2 int, f script.VectorFunction) {
if f.Const() {
log.Println(p, "[", r1, ":", r2, "]", "is constant")
p.setRegions(r1, r2, slice(f.Float3()))
} else {
log.Println(p, "[", r1, ":", r2, "]", "is not constant")
p.setFunc(r1, r2, func() []float64 {
return slice(f.Float3())
})
Expand Down
26 changes: 26 additions & 0 deletions test/timedep3Region.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
c:=4e-9
setgridsize(32, 32, 1)
setcellsize(c, c, c)

Msat=860e3
Aex=13e-12
alpha=0.2
m=uniform(1, 1, 0)
setgeom(circle(32*4e-9))

f := 1e9
A := 0.01
defRegion(1, xrange(-inf, inf))
B_ext.setRegion(1, vector(A*sin(2*pi*f*t), A*cos(2*pi*f*t), 0))

tableadd(B_ext)
tableautosave(1e-12)

run(0.2e-9)

m_ := average(m)
print(m_)

expect("mx", m_[0], 0.6783973430765087, 1e-7)
expect("my", m_[1], 0.7192199406365456, 1e-7)
expect("mz", m_[2], 0.0212674352335812, 1e-7)

0 comments on commit f7af119

Please sign in to comment.