diff --git a/include/openmc/mcpl_interface.h b/include/openmc/mcpl_interface.h index c931f1774..64f15c13a 100644 --- a/include/openmc/mcpl_interface.h +++ b/include/openmc/mcpl_interface.h @@ -2,9 +2,9 @@ #define OPENMC_MCPL_INTERFACE_H #include "openmc/particle_data.h" +#include "openmc/vector.h" #include -#include namespace openmc { diff --git a/src/mcpl_interface.cpp b/src/mcpl_interface.cpp index e9bc64830..a38891478 100644 --- a/src/mcpl_interface.cpp +++ b/src/mcpl_interface.cpp @@ -6,6 +6,7 @@ #include "openmc/settings.h" #include "openmc/simulation.h" #include "openmc/state_point.h" +#include "openmc/vector.h" #include @@ -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; @@ -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::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; diff --git a/tests/regression_tests/source_mcpl_file/results_true.dat b/tests/regression_tests/source_mcpl_file/results_true.dat index 5651efde7..0a98e9d8c 100644 --- a/tests/regression_tests/source_mcpl_file/results_true.dat +++ b/tests/regression_tests/source_mcpl_file/results_true.dat @@ -1,2 +1,2 @@ k-combined: -2.943088E-01 2.093028E-03 +3.009416E-01 3.229999E-03 diff --git a/tests/regression_tests/source_mcpl_file/settings.xml b/tests/regression_tests/source_mcpl_file/settings.xml index 2e511461f..47b010bff 100644 --- a/tests/regression_tests/source_mcpl_file/settings.xml +++ b/tests/regression_tests/source_mcpl_file/settings.xml @@ -1,6 +1,5 @@ - 1234 diff --git a/tests/regression_tests/source_mcpl_file/test.py b/tests/regression_tests/source_mcpl_file/test.py index 60e0ad50f..84ec005ae 100644 --- a/tests/regression_tests/source_mcpl_file/test.py +++ b/tests/regression_tests/source_mcpl_file/test.py @@ -11,7 +11,6 @@ pytestmark = pytest.mark.skipif( settings1=""" - 1234 @@ -35,7 +34,7 @@ settings2 = """ 1000 - source.10.{0} + source.10.{} """