The Minimize() function runs for a different number of steps for the same input state, and gives a different end state.
Demonstrator code below.
In this code, minimize() is called five times with exactly the same initial magnetisation m (in a for loop), and the output is checked (exemplified here by the magnetisation at an arbitrary cell). This script was run several times.
Result: The end result is different everytime the script is run, as well as for every one of the executions with the same initial state (in the for loop).
Expected Result: the same input should produce exactly the same output. Specially, between runs of the script, but also between runs with the same initial state.
This is a problem because:
- the user expects the same file to produce the same output.
- Often the user will compare different responses of what he expects is the same initial state. If the initial state is produced with Minimize(), the initial state will be different at every run, introducing unexpected differences.
I've quickly checked the code of engine/minimizer.go and cuda/minimize.cu and it is not clear to me what causes this random behaviour.
Demonstrator code:
SetMesh(128, 64, 1, 4e-9, 4e-9, 4e-9, 0, 0, 0);
Msat = 1e6; Aex = 10e-12; alpha = 1.;
tableaddvar(step, "step", "");
tableadd(MaxTorque);
tableAdd(Crop(m, 30, 31, 30, 31, 0, 1)); // mag in one arbitrary cell (more sensitive to small differences than the whole average)
for i := 0; i < 5; i++ {
m = TwoDomain(0.,0,1., 0,1,0, 0,0.,-1.);
step=0;
Minimize();
tablesave(); print(t, step, MaxTorque, Crop(m, 30, 31, 30, 31, 0, 1).average());
}
Outputs.
Here's the output for two runs on the same computer. The columns are:
- time (always 0)
- The number of steps that Minimize() used
- The final MaxTorque
- The m at an arbitrary cell (30,30,1).
Run 1:
//0 1708 1.3587993969904421e-06 [0.24186624586582184 -0.9649359583854675 0.10197720676660538]
//0 706 1.9388212427259442e-06 [0.7151626944541931 -0.6850084662437439 -0.13894522190093994]
//0 1622 1.4579250321644758e-06 [-0.7151928544044495 0.6849732398986816 -0.13896377384662628]
//0 1650 1.943069133851686e-06 [0.5473531484603882 -0.8349050283432007 0.057777922600507736]
//0 1214 1.4078213793882306e-06 [0.5473809838294983 -0.8348858952522278 -0.05779007822275162]
Run 2:
//0 980 1.620687266051533e-06 [0.5473484992980957 -0.8349082469940186 -0.057776421308517456]
//0 842 1.4022564510987115e-06 [0.7151708602905273 -0.6849989295005798 -0.13895045220851898]
//0 924 2.0761421675785363e-06 [0.5473533868789673 -0.8349048495292664 -0.05777806416153908]
//0 776 1.9706511693829087e-06 [0.5473541021347046 -0.8349043130874634 -0.05777836963534355]
//0 964 1.8854423685616054e-06 [0.5473534464836121 -0.8349047303199768 -0.05777810141444206]
The Minimize() function runs for a different number of steps for the same input state, and gives a different end state.
Demonstrator code below.
In this code, minimize() is called five times with exactly the same initial magnetisation m (in a for loop), and the output is checked (exemplified here by the magnetisation at an arbitrary cell). This script was run several times.
Result: The end result is different everytime the script is run, as well as for every one of the executions with the same initial state (in the for loop).
Expected Result: the same input should produce exactly the same output. Specially, between runs of the script, but also between runs with the same initial state.
This is a problem because:
I've quickly checked the code of engine/minimizer.go and cuda/minimize.cu and it is not clear to me what causes this random behaviour.
Demonstrator code:
Outputs.
Here's the output for two runs on the same computer. The columns are:
Run 1:
Run 2: