Skip to content

Commit

Permalink
Fix source definition in source_mcpl_file test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Dec 23, 2022
1 parent 6147034 commit 954a2bd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/openmc/mcpl_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define OPENMC_MCPL_INTERFACE_H

#include "openmc/particle_data.h"
#include "openmc/vector.h"

#include <string>
#include <vector>

namespace openmc {

Expand Down
31 changes: 14 additions & 17 deletions src/mcpl_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "openmc/settings.h"
#include "openmc/simulation.h"
#include "openmc/state_point.h"
#include "openmc/vector.h"

#include <fmt/core.h>

Expand Down Expand Up @@ -57,9 +58,8 @@ SourceSite mcpl_particle_to_site(const mcpl_particle_t* particle)
site.u.y = particle->direction[1];
site.u.z = particle->direction[2];

// mcpl stores kinetic energy in MeV
// MCPL stores kinetic energy in [MeV], time in [ms]
site.E = particle->ekin * 1e6;
// mcpl stores time in ms
site.time = particle->time * 1e-3;
site.wgt = particle->weight;

Expand Down Expand Up @@ -155,29 +155,26 @@ void write_mcpl_source_bank(mcpl_outfile_t file_id, bool surf_source_bank)
mpi::intracomm, MPI_STATUS_IGNORE);
#endif
// now write the source_bank data again.
for (vector<SourceSite>::iterator _site = source_bank->begin();
_site != source_bank->end(); _site++) {
for (const auto& site : *source_bank) {
// particle is now at the iterator
// write it to the mcpl-file
mcpl_particle_t p;
p.position[0] = _site->r.x;
p.position[1] = _site->r.y;
p.position[2] = _site->r.z;
p.position[0] = site.r.x;
p.position[1] = site.r.y;
p.position[2] = site.r.z;

// mcpl requires that the direction vector is unit length
// which is also the case in openmc
p.direction[0] = _site->u.x;
p.direction[1] = _site->u.y;
p.direction[2] = _site->u.z;
p.direction[0] = site.u.x;
p.direction[1] = site.u.y;
p.direction[2] = site.u.z;

// mcpl stores kinetic energy in MeV
p.ekin = _site->E * 1e-6;
// MCPL stores kinetic energy in [MeV], time in [ms]
p.ekin = site.E * 1e-6;
p.time = site.time * 1e3;
p.weight = site.wgt;

p.time = _site->time * 1e3;

p.weight = _site->wgt;

switch (_site->particle) {
switch (site.particle) {
case ParticleType::neutron:
p.pdgcode = 2112;
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/source_mcpl_file/results_true.dat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
k-combined:
2.943088E-01 2.093028E-03
3.009416E-01 3.229999E-03
1 change: 0 additions & 1 deletion tests/regression_tests/source_mcpl_file/settings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<settings>
<seed>1234</seed>
<state_point batches="10" />
<source_point mcpl="true" separate="true" />
<eigenvalue>
Expand Down
3 changes: 1 addition & 2 deletions tests/regression_tests/source_mcpl_file/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

settings1="""<?xml version="1.0"?>
<settings>
<seed>1234</seed>
<state_point batches="10" />
<source_point mcpl="true" separate="true" />
<eigenvalue>
Expand All @@ -35,7 +34,7 @@
<particles>1000</particles>
</eigenvalue>
<source>
<filename> source.10.{0} </filename>
<file>source.10.{}</file>
</source>
</settings>
"""
Expand Down

0 comments on commit 954a2bd

Please sign in to comment.