mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Ensure time is propagated to secondary particles
This commit is contained in:
parent
24b741f2b3
commit
ef61563079
8 changed files with 35 additions and 32 deletions
|
|
@ -20,7 +20,7 @@ following the same format.
|
|||
|
||||
- **source_bank** (Compound type) -- Source bank information for each
|
||||
particle. The compound type has fields ``r``, ``u``, ``E``,
|
||||
``wgt``, ``delayed_group``, ``surf_id`` and ``particle``,
|
||||
which represent the position, direction, energy, weight,
|
||||
``time``, ``wgt``, ``delayed_group``, ``surf_id`` and ``particle``,
|
||||
which represent the position, direction, energy, time, weight,
|
||||
delayed group, surface ID, and particle type (0=neutron, 1=photon,
|
||||
2=electron, 3=positron), respectively.
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ The current version of the statepoint file format is 17.0.
|
|||
sum-of-squares for each global tally.
|
||||
- **source_bank** (Compound type) -- Source bank information for each
|
||||
particle. The compound type has fields ``r``, ``u``, ``E``,
|
||||
``wgt``, ``delayed_group``, ``surf_id``, and ``particle``, which
|
||||
represent the position, direction, energy, weight, delayed group,
|
||||
surface ID, and particle type (0=neutron, 1=photon, 2=electron,
|
||||
3=positron), respectively.
|
||||
Only present when `run_mode` is 'eigenvalue'.
|
||||
``time``, ``wgt``, ``delayed_group``, ``surf_id``, and
|
||||
``particle``, which represent the position, direction, energy,
|
||||
time, weight, delayed group, surface ID, and particle type
|
||||
(0=neutron, 1=photon, 2=electron, 3=positron), respectively. Only
|
||||
present when `run_mode` is 'eigenvalue'.
|
||||
|
||||
**/tallies/**
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,10 @@ struct SourceSite {
|
|||
Position r;
|
||||
Direction u;
|
||||
double E;
|
||||
double wgt;
|
||||
int delayed_group;
|
||||
int surf_id;
|
||||
double time {0.0};
|
||||
double wgt {1.0};
|
||||
int delayed_group {0};
|
||||
int surf_id {0};
|
||||
ParticleType particle;
|
||||
int64_t parent_id;
|
||||
int64_t progeny_id;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class _SourceSite(Structure):
|
|||
_fields_ = [('r', c_double*3),
|
||||
('u', c_double*3),
|
||||
('E', c_double),
|
||||
('time', c_double),
|
||||
('wgt', c_double),
|
||||
('delayed_group', c_int),
|
||||
('surf_id', c_int),
|
||||
|
|
|
|||
|
|
@ -253,6 +253,8 @@ class SourceParticle:
|
|||
Directional cosines
|
||||
E : float
|
||||
Energy of particle in [eV]
|
||||
time : float
|
||||
Time of particle in [s]
|
||||
wgt : float
|
||||
Weight of the particle
|
||||
delayed_group : int
|
||||
|
|
@ -263,11 +265,12 @@ class SourceParticle:
|
|||
Type of the particle
|
||||
|
||||
"""
|
||||
def __init__(self, r=(0., 0., 0.), u=(0., 0., 1.), E=1.0e6, wgt=1.0,
|
||||
def __init__(self, r=(0., 0., 0.), u=(0., 0., 1.), E=1.0e6, time=0.0, wgt=1.0,
|
||||
delayed_group=0, surf_id=0, particle=ParticleType.NEUTRON):
|
||||
self.r = tuple(r)
|
||||
self.u = tuple(u)
|
||||
self.E = float(E)
|
||||
self.time = float(time)
|
||||
self.wgt = float(wgt)
|
||||
self.delayed_group = delayed_group
|
||||
self.surf_id = surf_id
|
||||
|
|
@ -282,7 +285,7 @@ class SourceParticle:
|
|||
Source particle attributes
|
||||
|
||||
"""
|
||||
return (self.r, self.u, self.E, self.wgt,
|
||||
return (self.r, self.u, self.E, self.time, self.wgt,
|
||||
self.delayed_group, self.surf_id, self.particle.value)
|
||||
|
||||
|
||||
|
|
@ -309,6 +312,7 @@ def write_source_file(source_particles, filename, **kwargs):
|
|||
('r', pos_dtype),
|
||||
('u', pos_dtype),
|
||||
('E', '<f8'),
|
||||
('time', '<f8'),
|
||||
('wgt', '<f8'),
|
||||
('delayed_group', '<i4'),
|
||||
('surf_id', '<i4'),
|
||||
|
|
|
|||
|
|
@ -138,24 +138,25 @@ void initialize_mpi(MPI_Comm intracomm)
|
|||
|
||||
// Create bank datatype
|
||||
SourceSite b;
|
||||
MPI_Aint disp[9];
|
||||
MPI_Aint disp[10];
|
||||
MPI_Get_address(&b.r, &disp[0]);
|
||||
MPI_Get_address(&b.u, &disp[1]);
|
||||
MPI_Get_address(&b.E, &disp[2]);
|
||||
MPI_Get_address(&b.wgt, &disp[3]);
|
||||
MPI_Get_address(&b.delayed_group, &disp[4]);
|
||||
MPI_Get_address(&b.surf_id, &disp[5]);
|
||||
MPI_Get_address(&b.particle, &disp[6]);
|
||||
MPI_Get_address(&b.parent_id, &disp[7]);
|
||||
MPI_Get_address(&b.progeny_id, &disp[8]);
|
||||
for (int i = 8; i >= 0; --i) {
|
||||
MPI_Get_address(&b.time, &disp[3]);
|
||||
MPI_Get_address(&b.wgt, &disp[4]);
|
||||
MPI_Get_address(&b.delayed_group, &disp[5]);
|
||||
MPI_Get_address(&b.surf_id, &disp[6]);
|
||||
MPI_Get_address(&b.particle, &disp[7]);
|
||||
MPI_Get_address(&b.parent_id, &disp[8]);
|
||||
MPI_Get_address(&b.progeny_id, &disp[9]);
|
||||
for (int i = 9; i >= 0; --i) {
|
||||
disp[i] -= disp[0];
|
||||
}
|
||||
|
||||
int blocks[] {3, 3, 1, 1, 1, 1, 1, 1, 1};
|
||||
MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_INT,
|
||||
MPI_INT, MPI_INT, MPI_LONG, MPI_LONG};
|
||||
MPI_Type_create_struct(9, blocks, disp, types, &mpi::source_site);
|
||||
int blocks[] {3, 3, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE,
|
||||
MPI_DOUBLE, MPI_INT, MPI_INT, MPI_INT, MPI_LONG, MPI_LONG};
|
||||
MPI_Type_create_struct(10, blocks, disp, types, &mpi::source_site);
|
||||
MPI_Type_commit(&mpi::source_site);
|
||||
}
|
||||
#endif // OPENMC_MPI
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ void Particle::create_secondary(
|
|||
bank.r = r();
|
||||
bank.u = u;
|
||||
bank.E = settings::run_CE ? E : g();
|
||||
bank.time = time();
|
||||
|
||||
n_bank_second() += 1;
|
||||
}
|
||||
|
|
@ -111,6 +112,8 @@ void Particle::from_source(const SourceSite* src)
|
|||
E() = data::mg.energy_bin_avg_[g()];
|
||||
}
|
||||
E_last() = E();
|
||||
time() = src->time;
|
||||
time_last() = src->time;
|
||||
}
|
||||
|
||||
void Particle::event_calculate_xs()
|
||||
|
|
@ -399,6 +402,7 @@ void Particle::cross_surface()
|
|||
site.r = r();
|
||||
site.u = u();
|
||||
site.E = E();
|
||||
site.time = time();
|
||||
site.wgt = wgt();
|
||||
site.delayed_group = delayed_group();
|
||||
site.surf_id = surf->id_;
|
||||
|
|
|
|||
|
|
@ -147,9 +147,6 @@ SourceSite IndependentSource::sample(uint64_t* seed) const
|
|||
{
|
||||
SourceSite site;
|
||||
|
||||
// Set weight to one by default
|
||||
site.wgt = 1.0;
|
||||
|
||||
// Repeat sampling source location until a good site has been found
|
||||
bool found = false;
|
||||
int n_reject = 0;
|
||||
|
|
@ -227,11 +224,6 @@ SourceSite IndependentSource::sample(uint64_t* seed) const
|
|||
break;
|
||||
}
|
||||
|
||||
// Set delayed group
|
||||
site.delayed_group = 0;
|
||||
// Set surface ID
|
||||
site.surf_id = 0;
|
||||
|
||||
return site;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue