load ovf-file using a go script

165 views
Skip to first unread message

nico...@gmail.com

unread,
Jul 20, 2022, 11:55:17 AM7/20/22
to mumax2
Hi,

I would like to run a simulation on mumax3 using a go script.

I have seen some examples in the mumax3 repository, but I still have a question about how to load the magnetization from an OVF file. Then make some modifications.

package main

import (
"github.com/mumax/3/data"
. "github.com/mumax/3/engine"
"github.com/mumax/3/oommf"
"math"
         "fmt"


func main() {

defer InitAndClose()()

N x := 512
Ny := 128
nz := 1

cellsize := 1.0e-9
SetGridSize(Nx, Ny, Nz)
SetCellSize(cellsize, cellsize, cellsize)

        vec := oommf.ReadFile("Example.ovf")



}

I obtain that "assignment mismatch: 1 variable but oommf.ReadFile returns 3 values". I don't understand very well how I should declare the vec function to be able to load the magnetization, I have tried in different ways.

Thanks.

Nicolas

Felipe Garcia

unread,
Jul 20, 2022, 1:49:20 PM7/20/22
to mumax2
Hi Nicolas,

This has nothing to do with mumax. It is more a go question. The function Readfile returns 3 variables and you are assigning to only 1. That is a problem.
The three variables have the type
s *data.Slice, meta data.Meta, err error
Then one can do like it used inside engine/utils.go
s, _, err = oommf.Read("Example.ovf")

Best regards,
Felipe

--
You received this message because you are subscribed to the Google Groups "mumax2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mumax2+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mumax2/ca20f7f8-8aa7-4b19-93c3-cadb11b1d4d4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages