Skip to content

Commit

Permalink
Merge branch 'master' into 42a-inaccurate-fdpm-amplitude-and-phase-de…
Browse files Browse the repository at this point in the history
…rivative-values-with-respect-to-mu_a-and-mu_s
  • Loading branch information
Lisa Malenfant authored Apr 3, 2024
2 parents 49af8cc + 3d21517 commit d743567
Show file tree
Hide file tree
Showing 4 changed files with 499 additions and 185 deletions.
82 changes: 77 additions & 5 deletions src/Vts.Test/MonteCarlo/Tissues/BoundedTissueTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using NUnit.Framework;
using NUnit.Framework;
using System;
using Vts.Common;
using Vts.MonteCarlo;
using Vts.MonteCarlo.Tissues;
Expand All @@ -14,7 +14,8 @@ public class BoundedTissueTests
{
private BoundedTissue _oneLayerTissueBoundedByVoxel, _twoLayerTissueBoundedByVoxel;
/// <summary>
/// Validate general constructor of Tissue for a one layer and two layer tissue cylinder
/// Validate general constructor of Tissue for a one layer and two layer tissue bounded
/// by voxel
/// </summary>

/// <summary>
Expand Down Expand Up @@ -49,10 +50,10 @@ public void Create_instance_of_class()
new OpticalProperties(0.0, 1e-10, 1.0, 1.0))
});
_twoLayerTissueBoundedByVoxel = new BoundedTissue(
new VoxelTissueRegion(
new CaplessVoxelTissueRegion(
new DoubleRange(-1, 1, 2), // x range
new DoubleRange(-1, 1, 2), // y range
new DoubleRange(1, 10, 2), // z range
new DoubleRange(0, 10, 2), // z range
new OpticalProperties(0.01, 1.0, 0.8, 1.0)),
new ITissueRegion[]
{
Expand Down Expand Up @@ -85,6 +86,77 @@ public void Verify_GetRegionIndex_method_returns_correct_result()
Assert.AreEqual(1, index);
}

/// <summary>
/// Validate method GetDistanceToBoundary return correct "projected" distance
/// </summary>
[Test]
public void Verify_GetDistanceToBoundary_method_returns_correct_result()
{
// the following cases sets S to 0 to make sure "projected" distance is calculated
// first test the layer boundaries
var photon = new Photon( // towards bottom of 2nd layer pointed up
new Position(0, 0, 9),
new Direction(0.0, 0, -1.0),
1.0,
_twoLayerTissueBoundedByVoxel,
2,
new Random())
{
S = 0
};
var distance = _twoLayerTissueBoundedByVoxel.GetDistanceToBoundary(photon);
Assert.IsTrue(Math.Abs(distance - 7) < 1e-6);
photon = new Photon( // towards bottom of 1st layer pointed up
new Position(0, 0, 1.8),
new Direction(0.0, 0, -1.0),
1.0,
_twoLayerTissueBoundedByVoxel,
1,
new Random())
{
S = 0
};
distance = _twoLayerTissueBoundedByVoxel.GetDistanceToBoundary(photon);
Assert.IsTrue(Math.Abs(distance - 1.8) < 1e-6);
photon = new Photon( // towards bottom of 2nd layer pointed down
new Position(0, 0, 9),
new Direction(0.0, 0, 1.0),
1.0,
_twoLayerTissueBoundedByVoxel,
2,
new Random())
{
S = 0
};
distance = _twoLayerTissueBoundedByVoxel.GetDistanceToBoundary(photon);
Assert.IsTrue(Math.Abs(distance - 1) < 1e-6);
photon = new Photon( // towards bottom of 1st layer pointed down
new Position(0, 0, 1.8),
new Direction(0.0, 0, 1.0),
1.0,
_twoLayerTissueBoundedByVoxel,
1,
new Random())
{
S = 0
};
distance = _twoLayerTissueBoundedByVoxel.GetDistanceToBoundary(photon);
Assert.IsTrue(Math.Abs(distance - 0.2) < 1e-6);
// next test the surrounding voxel region
photon = new Photon( // in top layer pointed to right
new Position(0.8, 0, 0.8),
new Direction(1.0, 0, 0.0),
1.0,
_twoLayerTissueBoundedByVoxel,
1,
new Random())
{
S = 0
};
distance = _twoLayerTissueBoundedByVoxel.GetDistanceToBoundary(photon);
Assert.IsTrue(Math.Abs(distance - 0.2) < 1e-6);
}

/// <summary>
/// Validate method GetNeighborRegionIndex for oneLayerTissueBoundedByVoxel return correct Boolean
/// </summary>
Expand Down
Loading

0 comments on commit d743567

Please sign in to comment.