Skip to content

Commit d755f6a

Browse files
committed
Adaptation of MCPL_TOF_train to global/particle tof train
1 parent b80c1d8 commit d755f6a

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

mcstas-comps/examples/Prototypes/ODIN_MCPL_TOF_train4/DiskChopper.comp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ TRACE
170170
} else {
171171

172172
// Check whether each t_offset carried by the ray make it through
173-
double weight_update = p/_particle->p_last_time_manipulation;
174-
_particle->p_last_time_manipulation = 0;
173+
double weight_update = p/p_last_time_manipulation;
174+
p_last_time_manipulation = 0;
175175

176176
int train_index;
177177
int one_did_hit = 0;
@@ -180,26 +180,26 @@ TRACE
180180

181181
for (train_index=0; train_index<adaptive_N; train_index++) {
182182

183-
if (_particle->p_trains[train_index] == 0) continue;
183+
if (p_trains[train_index] == 0) continue;
184184
all_dead = 0;
185185

186-
this_train_t = t + _particle->t_offset[train_index];
186+
this_train_t = t + t_offset[train_index];
187187
toff = fabs (this_train_t - atan2 (x, yprime) / omega - delay - (jitter ? jitter * randnorm () : 0));
188188

189189
/* does neutron hit outside slit? */
190190
if (fmod (toff + To / 2.0, Tg) > To)
191-
_particle->p_trains[train_index] = 0; // T_ABSORB
191+
p_trains[train_index] = 0; // T_ABSORB
192192
else {
193193
// T_TRANSMIT
194194
one_did_hit = 1;
195-
_particle->p_trains[train_index] *= weight_update;
196-
_particle->p_last_time_manipulation += _particle->p_trains[train_index];
195+
p_trains[train_index] *= weight_update;
196+
p_last_time_manipulation += p_trains[train_index];
197197
}
198198

199199
}
200200
if (!one_did_hit || all_dead) ABSORB;
201201

202-
p = _particle->p_last_time_manipulation;
202+
p = p_last_time_manipulation;
203203

204204
}
205205
SCATTER;

mcstas-comps/examples/Prototypes/ODIN_MCPL_TOF_train4/ESS_butterfly.comp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,14 @@ TRACE
552552

553553
if (total_N_sent == 0) {
554554
#pragma acc atomic
555-
adaptive_N = _particle->N_trains;
555+
adaptive_N = N_trains;
556556
} else {
557557
long tmp = ceil(target_tsplit*total_N_sent/total_arrived);
558558
#pragma acc atomic
559559
adaptive_N = tmp;
560-
if (adaptive_N > _particle->N_trains) {
560+
if (adaptive_N > N_trains) {
561561
#pragma acc atomic
562-
adaptive_N = _particle->N_trains;
562+
adaptive_N = N_trains;
563563
}
564564
}
565565

@@ -602,13 +602,13 @@ TRACE
602602
// Generate ray as normal with its associated p and t
603603
// Save these to t_offset and p_train
604604

605-
_particle->t_offset[train_index] = t;
606-
_particle->p_trains[train_index] = p/adaptive_N;
607-
_particle->p_last_time_manipulation += _particle->p_trains[train_index];
605+
t_offset[train_index] = t;
606+
p_trains[train_index] = p/adaptive_N;
607+
p_last_time_manipulation += p_trains[train_index];
608608
}
609609
// Set base particle t and p, now p will be decoupled from the source intensity.
610610
t=0;
611-
p=_particle->p_last_time_manipulation;
611+
p=p_last_time_manipulation;
612612

613613
SCATTER;
614614
%}

mcstas-comps/examples/Prototypes/ODIN_MCPL_TOF_train4/Monitor_nD.comp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ TRACE
424424
#define thread_offdata offdata
425425
#endif
426426

427-
double *pp_array=malloc(sizeof(double)*_particle->N_trains);
427+
double *pp_array=malloc(sizeof(double)*N_trains);
428428

429429
/* this is done automatically
430430
STORE_NEUTRON(INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p);
@@ -571,7 +571,7 @@ TRACE
571571

572572
int train_index;
573573
double p_original = p;
574-
double p_factor = p/_particle->p_last_time_manipulation;
574+
double p_factor = p/p_last_time_manipulation;
575575

576576
if (adaptive_target) {
577577
#pragma acc atomic
@@ -584,9 +584,9 @@ TRACE
584584
double t_original = t;
585585
for (train_index=0; train_index<adaptive_N; train_index++) {
586586

587-
if (_particle->p_trains[train_index] > 0) {
588-
p = p_factor*_particle->p_trains[train_index];
589-
t = t_original + _particle->t_offset[train_index];
587+
if (p_trains[train_index] > 0) {
588+
p = p_factor*p_trains[train_index];
589+
t = t_original + t_offset[train_index];
590590

591591
pp_array[train_index] = Monitor_nD_Trace (&DEFS, &Vars, _particle);
592592

@@ -613,7 +613,7 @@ TRACE
613613
// Now just use normal p
614614
double total_p = 0;
615615
for (train_index=0; train_index<N_trains; train_index++) {
616-
if (_particle->alive_trains[train_index]) total_p += p_original*_particle->p_trains[train_index];
616+
if (alive_trains[train_index]) total_p += p_original*p_trains[train_index];
617617
}
618618

619619
p = total_p;

mcstas-comps/examples/Prototypes/ODIN_MCPL_TOF_train4/MultiDiskChopper.comp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ TRACE
281281
} else {
282282

283283
// Check whether each t_offset carried by the ray make it through
284-
double weight_update = p/_particle->p_last_time_manipulation;
285-
_particle->p_last_time_manipulation = 0;
284+
double weight_update = p/p_last_time_manipulation;
285+
p_last_time_manipulation = 0;
286286

287287
int train_index;
288288
int one_did_hit = 0;
@@ -292,10 +292,10 @@ TRACE
292292
double p_total = 0;
293293
for (train_index=0; train_index<adaptive_N; train_index++) {
294294

295-
if (_particle->p_trains[train_index] == 0) continue;
295+
if (p_trains[train_index] == 0) continue;
296296
all_dead = 0;
297297

298-
this_train_t = t + _particle->t_offset[train_index];
298+
this_train_t = t + t_offset[train_index];
299299
// where does the neutron hit the disk ?
300300
phi = atan2 (xprime, yprime) + omega * (this_train_t - delay - (jitter ? jitter * randnorm () : 0));
301301

@@ -308,17 +308,17 @@ TRACE
308308

309309
islit++;
310310
}
311-
if (this_t_hit == 0) _particle->p_trains[train_index] = 0;
311+
if (this_t_hit == 0) p_trains[train_index] = 0;
312312
else {
313313
one_did_hit = 1;
314-
_particle->p_trains[train_index] *= weight_update;
315-
_particle->p_last_time_manipulation += _particle->p_trains[train_index];
314+
p_trains[train_index] *= weight_update;
315+
p_last_time_manipulation += p_trains[train_index];
316316
}
317317
}
318318
// if not a single t_offset made it through a slit, absorb this ray
319319
if (!one_did_hit || all_dead) ABSORB;
320320

321-
p = _particle->p_last_time_manipulation;
321+
p = p_last_time_manipulation;
322322
}
323323
}
324324
%}

0 commit comments

Comments
 (0)