Creating new random seed automatically between runs?

17 views
Skip to first unread message

Harrison Jin

unread,
Oct 21, 2025, 1:20:36 PMOct 21
to mumax2
I've been trying to randomly generate distribution of timing variations for my current density, like this:

randSeed(int)
p1 := (1e-9 + (((Rand()*2) - 1) * 0.25e-9))

J.RemoveExtraTerms()  
run(p1)
saveas(m, "pulse1_rest")

Is there a way to change randSeed() automatically between each run?


Felipe Garcia

unread,
Oct 28, 2025, 3:20:02 PM (8 days ago) Oct 28
to mum...@googlegroups.com
Hi,

You can modify the random seed for each run.
One can use the number of nanoseconds of the time.

tvar:=now().nanosecond()
randseed(tvar)

This will create a different sequence in each run. It is better if you keep the seed in the log, so that you can run if necessary with the same seed.
For example adding 
print(tvar)
You may think you want something totally random but then to reproduce the results becomes impossible. Then it is always better to have this value saved.

if you include that in a loop, then you have to define something like
tvar:=1 // this defines tvar as integer

and inside the loop becomes
tvar=now().nanosecond()
randseed(tvar)


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 visit https://groups.google.com/d/msgid/mumax2/d5d0192d-97a7-41ad-946e-c9fd4d702dc7n%40googlegroups.com.

Harrison Jin

unread,
Nov 3, 2025, 1:34:19 PM (2 days ago) Nov 3
to mum...@googlegroups.com
Thank you, I appreciate the response! I will look into it.

You received this message because you are subscribed to a topic in the Google Groups "mumax2" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mumax2/Rzj3q3TsC_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mumax2+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mumax2/CAE-O8RnwdZ_GrMTiC4Kd_E0Y4z8-nPeZPvYFNgbBS_K%2BGi2Spw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages