Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 12 additions & 35 deletions src/lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,46 +260,23 @@ std::pair<double, array<int, 3>> RectLattice::distance(
// Determine the oncoming edge.
double x0 {copysign(0.5 * pitch_[0], u.x)};
double y0 {copysign(0.5 * pitch_[1], u.y)};
double z0;

// Left and right sides
double d {INFTY};
array<int, 3> lattice_trans;
if ((std::abs(x - x0) > FP_PRECISION) && u.x != 0) {
d = (x0 - x) / u.x;
if (u.x > 0) {
lattice_trans = {1, 0, 0};
} else {
lattice_trans = {-1, 0, 0};
}
double d = std::min((x0 - x) / u.x, (y0 - y) / u.y);
if (is_3d_) {
z0 = copysign(0.5 * pitch_[2], u.z);
d = std::min(d, (z0 - z) / u.z);
Comment thread
paulromano marked this conversation as resolved.
Resolved
}

// Front and back sides
if ((std::abs(y - y0) > FP_PRECISION) && u.y != 0) {
double this_d = (y0 - y) / u.y;
if (this_d < d) {
d = this_d;
if (u.y > 0) {
lattice_trans = {0, 1, 0};
} else {
lattice_trans = {0, -1, 0};
}
}
}
array<int, 3> lattice_trans = {0, 0, 0};

// Top and bottom sides
if (std::abs(x + u.x * d - x0) < FP_PRECISION)
lattice_trans[0] = copysign(1, u.x);
if (std::abs(y + u.y * d - y0) < FP_PRECISION)
lattice_trans[1] = copysign(1, u.y);
if (is_3d_) {
double z0 {copysign(0.5 * pitch_[2], u.z)};
if ((std::abs(z - z0) > FP_PRECISION) && u.z != 0) {
double this_d = (z0 - z) / u.z;
if (this_d < d) {
d = this_d;
if (u.z > 0) {
lattice_trans = {0, 0, 1};
} else {
lattice_trans = {0, 0, -1};
}
}
}
if (std::abs(z + u.z * d - z0) < FP_PRECISION)
lattice_trans[2] = copysign(1, u.z);
}

return {d, lattice_trans};
Expand Down
Empty file.
61 changes: 61 additions & 0 deletions tests/regression_tests/lattice_corner_crossing/inputs_true.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version='1.0' encoding='utf-8'?>
<model>
<materials>
<material id="1" name="air">
<density value="0.001" units="g/cc"/>
<nuclide name="N14" ao="1.0"/>
</material>
<material id="2" name="metal">
<density value="7" units="g/cc"/>
<nuclide name="Fe56" ao="1.0"/>
</material>
</materials>
<geometry>
<cell id="1" name="outside_lattice" material="1" region="-5 (-1 | 2 | -3 | 4)" universe="1"/>
<cell id="2" name="inside_lattice" fill="4" region="1 -2 3 -4" universe="1"/>
<cell id="3" material="2" region="-6" universe="2"/>
<cell id="4" material="1" region="-7" universe="3"/>
<lattice id="4">
<pitch>10.0 10.0</pitch>
<dimension>2 2</dimension>
<lower_left>-10.0 -10.0</lower_left>
<universes>
2 3
3 2 </universes>
</lattice>
<surface id="1" name="left" type="x-plane" coeffs="-10.0"/>
<surface id="2" name="right" type="x-plane" coeffs="10.0"/>
<surface id="3" name="bottom" type="y-plane" coeffs="-10.0"/>
<surface id="4" name="top" type="y-plane" coeffs="10.0"/>
<surface id="5" type="z-cylinder" boundary="vacuum" coeffs="0 0 20.0"/>
<surface id="6" type="sphere" coeffs="0.0 0.0 0.0 1e+90"/>
<surface id="7" type="sphere" coeffs="0.0 0.0 0.0 1e+90"/>
</geometry>
<settings>
<run_mode>fixed source</run_mode>
<particles>1000</particles>
<batches>10</batches>
<max_lost_particles>100000000</max_lost_particles>
<source type="independent" strength="1.0" particle="neutron">
<space type="point">
<parameters>-0.7071067811865476 -0.7071067811865475 0.0</parameters>
</space>
<angle type="monodirectional" reference_uvw="0.7071067811865476 0.7071067811865475 0.0"/>
</source>
</settings>
<tallies>
<mesh id="1">
<dimension>10 10 1</dimension>
<lower_left>-20.0 -20.0 -1000000000.0</lower_left>
<upper_right>20.0 20.0 1000000000.0</upper_right>
</mesh>
<filter id="1" type="mesh">
<bins>1</bins>
</filter>
<tally id="1">
<filters>1</filters>
<scores>flux</scores>
<estimator>tracklength</estimator>
</tally>
</tallies>
</model>
201 changes: 201 additions & 0 deletions tests/regression_tests/lattice_corner_crossing/results_true.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
tally 1:
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
2.648775E-03
7.016009E-06
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
2.981847E-03
8.891414E-06
3.331677E-03
1.110007E-05
6.742237E-03
4.545776E-05
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
4.388206E-03
1.925636E-05
2.032104E-03
4.129446E-06
3.014946E-03
9.089898E-06
7.058968E-03
4.982903E-05
9.013188E-04
8.123755E-07
7.501461E-04
5.627191E-07
0.000000E+00
0.000000E+00
5.134898E-03
2.636718E-05
1.207302E-03
1.457579E-06
3.045925E-03
9.277657E-06
4.132399E-03
1.707672E-05
1.055271E-02
5.829711E-05
4.014909E-03
1.611949E-05
2.698215E-03
7.280363E-06
1.751215E-02
1.073504E-04
1.356908E-02
9.589157E-05
5.451466E-03
2.971848E-05
3.165676E-04
1.002151E-07
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
3.724938E-03
1.387516E-05
2.812863E-03
7.278837E-06
1.000700E+01
1.001402E+01
2.345904E-02
2.127641E-04
2.451653E-02
1.750725E-04
8.695904E-03
5.553981E-05
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
4.947565E-03
2.447840E-05
1.725721E-02
8.878803E-05
5.656444E+01
3.199538E+02
2.159961E-02
1.034364E-04
3.091063E-02
5.543317E-04
4.232209E-03
1.791159E-05
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
4.716170E-03
2.224226E-05
1.321855E-02
5.288265E-05
5.309576E-02
7.984865E-04
5.656179E+01
3.199238E+02
2.399311E-02
2.936670E-04
4.680753E-02
9.526509E-04
1.074699E-02
1.154978E-04
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
4.526425E-03
2.048853E-05
3.983003E-03
9.553596E-06
1.726789E-02
9.579848E-05
3.355605E-02
3.331438E-04
3.578422E-02
3.560242E-04
5.649209E+01
3.191358E+02
2.591495E-02
4.169753E-04
9.484744E-03
8.065715E-05
0.000000E+00
0.000000E+00
4.232587E-03
9.113263E-06
5.787378E-03
2.194940E-05
6.193626E-03
2.357423E-05
4.552787E-03
6.987360E-06
9.641308E-03
3.506339E-05
1.303892E-02
4.378408E-05
1.831744E-02
8.836683E-05
3.024725E+01
9.148969E+01
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
1.488204E-03
2.214752E-06
5.067487E-03
1.520987E-05
7.550927E-03
2.993991E-05
3.215559E-03
1.033982E-05
4.258525E-03
1.205064E-05
2.115487E-03
4.475286E-06
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
Loading
Loading