Skip to content

Commit

Permalink
Found another validation check that could be downgraded to warning. A…
Browse files Browse the repository at this point in the history
…dded unit test.
  • Loading branch information
hayakawa16 committed Aug 8, 2024
1 parent 5306b4a commit 9331e5a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public void Validate_ellipsoid_tissue_with_off_zaxis_center_and_cylindrical_dete
}

/// <summary>
/// Test to verify input cylindrical detector and ellipsoid in tissue is invalid
/// Test to verify input cylindrical detector and ellipsoid in tissue issues warning
/// but continues as valid input
/// </summary>
[Test]
public void Validate_ellipsoid_tissue_without_cylindrical_symmetry_and_cylindrical_detectors_issues_warning()
Expand All @@ -130,6 +131,35 @@ public void Validate_ellipsoid_tissue_without_cylindrical_symmetry_and_cylindric
Assert.That(output.ToString(), Is.EqualTo("Warning: ellipsoid with Dx != Dy in tissue with cylindrical detector defined: user discretion advised\r\n"));
}

/// <summary>
/// Test to verify input cylindrical detector and voxel in tissue issues warning
/// but continues as valid input
/// </summary>
[Test]
public void Validate_voxel_tissue_and_cylindrical_detectors_issues_warning()
{
// generate input embedded ellipsoid tissue and cylindrical detector
var input = new SimulationInput
{
TissueInput = new SingleVoxelTissueInput
{
VoxelRegion = new VoxelTissueRegion
{
X = new DoubleRange(-1.0, 1.0, 2),
Y = new DoubleRange(-1.0, 1.0,2),
Z = new DoubleRange(0.01, 1, 2)
}
},
DetectorInputs = new List<IDetectorInput> { new ROfRhoDetectorInput() }
};
// set to catch Console output
var output = new StringWriter();
Console.SetOut(output);
var result = SimulationInputValidation.ValidateInput(input);
Assert.IsTrue(result.IsValid); // only warning
Assert.That(output.ToString(), Is.EqualTo("Warning: voxel in tissue with cylindrical detector defined: user discretion advised\r\n"));
}

/// <summary>
/// Test to verify input with angled source and cylindrical detectors outputs warning
/// but continues as valid input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ private static ValidationResult ValidateDetectorInput(SimulationInput si)
/// and source, tissue, detector definitions. The philosophy here is that if the transport will
/// not error, a warning is issued and the validation result remains true. This allows users to
/// specify inconsistent combinations, e.g. angled source and cylindrical coordinate detectors,
/// receive a warning and have the simulation proceed.
/// receive a warning and have the simulation proceed. However, if the transport will error then
/// the validation result will be false, the validationRule and remarks output and simulation stops,
/// e.g. embedded ellipsoid in tissue that overlaps tissue layer.
/// </summary>
/// <param name="input">input to be validated</param>
/// <returns>An instance of ValidationResult with IsValid set and error message if false</returns>
Expand Down Expand Up @@ -201,10 +203,11 @@ private static ValidationResult ValidateCombinedInputParameters(SimulationInput
{
if (detectorInput.TallyDetails.IsCylindricalTally)
{
return new ValidationResult(
false,
"Cannot use Single Voxel Tissue for cylindrical tallies",
"Change detector inputs to specify non-cylindrical type tallies");
Console.WriteLine("Warning: voxel in tissue with cylindrical detector defined: user discretion advised");
return new ValidationResult(
true,
"Warning: voxel in tissue with cylindrical detector defined",
"User discretion advised: change detector inputs to specify non-cylindrical type tallies");
}

if (detectorInput.TallyType != TallyType.ROfFx) continue;
Expand Down

0 comments on commit 9331e5a

Please sign in to comment.