Skip to content

Commit fadd76b

Browse files
committed
Ensure mccode.sim in split scanner subdirs, shift seed pr. thread
1 parent 24c0cfe commit fadd76b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/Python/mcrun/optimisation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ def _simulate_point(args):
230230
mcstas = copy.deepcopy(mcstas_config) # You need to define a way to deepcopy or clone your mcstas object
231231
par_values = []
232232

233+
# Ensure we get a mccode.sim pr. thread subdir (e.g. for monitoring seed value
234+
mcstas.simfile = join(mcstas_dir, 'mccode.sim')
235+
236+
# Shift thread seed to avoid duplicate simulations / biasing
237+
mcstas.options.seed = (i*1024)+mcstas.options.seed
238+
233239
for key in intervals:
234240
mcstas.set_parameter(key, point[key])
235241
par_values.append(point[key])
@@ -330,6 +336,11 @@ def run(self):
330336

331337
mcstas_dir = self.mcstas.options.dir or '.'
332338

339+
if self.mcstas.options.seed is None:
340+
dt=datetime.now()
341+
LOG.info('No incoming seed from cmdline, setting to current Unix epoch (%d)!' % dt.timestamp())
342+
self.mcstas.options.seed=dt.timestamp()
343+
333344
# Prepare data to pass into processes
334345
args_list = [
335346
(i, point, self.intervals, self.mcstas, mcstas_dir)

0 commit comments

Comments
 (0)