Separate mx3 code into multiple files

120 views
Skip to first unread message

Michael Hynes

unread,
Aug 17, 2022, 7:45:37 AM8/17/22
to mumax2
Is it possible to run a mumax3 script which calls another mumax3 script?
For example, I have multiple geometries I'd like to define, with a number of different simulations I'd like to perform for each geometry.
Would be nice to call a standard geometry definition and then perform a specific simulation for that geometry. Then if I need to make a change to the simulation, or to the geometry I do not need to change multiple files.

Josh Lauzier

unread,
Aug 19, 2022, 3:25:41 AM8/19/22
to mumax2
Hello,

Not directly/trivially. You can if you use a full go script as input, but I would not recommend this unless you are already very proficient in Golang. While mumax does take go scripts as inputs (and it gives you full access to Golang features), they're significantly more complicated to write and not as well documented.

To do what you're trying to do, a lot of people will write a script in another language like python to generate the mx3 scripts. It's essentially just writing to a text file

Another way would be to write one mx3 script to generate the geometry, save it into an ovf, and then load just load the ovf file into other mx3s. (As far as I know, there isn't a way to load a geom directly from an OVF, although Mykola says it can be done here). What I've found is to using regions and regions.loadfile() instead, which is a bit of a kludge but equivalent. Doing it this way, you would have a master geometry mx3 to generate region ovfs in your particular geometry, and then a secondary mx3 for the simulation. 

Best,
Josh L.
Reply all
Reply to author
Forward
0 new messages