-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from VirtualPhotonics/feature/88-sda-forward-…
…solvers-need-check-on-optical-properties-to-make-sure-solution-is-valid Added warning if diffusion parameters are such that mua>=musp.
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/Vts.Test/Unit/Modeling/ForwardSolvers/DiffusionParametersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.IO; | ||
using NUnit.Framework; | ||
using Vts.Modeling.ForwardSolvers; | ||
|
||
namespace Vts.Test.Unit.Modeling.ForwardSolvers | ||
{ | ||
[TestFixture] | ||
public class DiffusionParametersTests | ||
{ | ||
/// <summary> | ||
/// Test to verify results of Create Method | ||
/// </summary> | ||
[Test] | ||
public void Validate_Create_method_results() | ||
{ | ||
// test SDA | ||
var ops = new OpticalProperties(0.01, 1.0, 0.8, 1.4); | ||
var diffusionParameters = DiffusionParameters.Create( | ||
ops, | ||
ForwardModel.SDA); | ||
Assert.IsTrue(Math.Abs(2.950078 - diffusionParameters.A) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.330033 - diffusionParameters.D) < 1e-6); | ||
Assert.IsTrue(Math.Abs(214.13747 - diffusionParameters.cn) < 1e-4); | ||
Assert.IsTrue(Math.Abs(0.8 - diffusionParameters.gTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.01 - diffusionParameters.mua) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.174068 - diffusionParameters.mueff) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.0 - diffusionParameters.musTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.01 - diffusionParameters.mutTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.01 - diffusionParameters.mutr) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.947246 - diffusionParameters.zb) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.990099 - diffusionParameters.zp) < 1e-6); | ||
// test deltaP1= | ||
diffusionParameters = DiffusionParameters.Create( | ||
ops, | ||
ForwardModel.DeltaPOne); | ||
Assert.IsTrue(Math.Abs(2.950078 - diffusionParameters.A) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.330033 - diffusionParameters.D) < 1e-6); | ||
Assert.IsTrue(Math.Abs(214.13747 - diffusionParameters.cn) < 1e-4); | ||
Assert.IsTrue(Math.Abs(0.444444 - diffusionParameters.gTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.01 - diffusionParameters.mua) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.174068 - diffusionParameters.mueff) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.799999 - diffusionParameters.musTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.809999 - diffusionParameters.mutTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.01 - diffusionParameters.mutr) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.947246 - diffusionParameters.zb) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.552486 - diffusionParameters.zp) < 1e-6); | ||
// add test to test warning if Mua >= Musp | ||
ops = new OpticalProperties(1.0, 1.0, 0.8, 1.4); | ||
var output = new StringWriter(); | ||
Console.SetOut(output); | ||
diffusionParameters = DiffusionParameters.Create( | ||
ops, | ||
ForwardModel.SDA); | ||
Assert.IsTrue(diffusionParameters != null); | ||
Assert.That(output.ToString(), Is.EqualTo("Warning: Mua >= Musp\r\n")); | ||
} | ||
|
||
/// <summary> | ||
/// Test to verify results of Copy Method | ||
/// </summary> | ||
[Test] | ||
public void Validate_Copy_method_results() | ||
{ | ||
// set diffusion parameters | ||
var ops = new OpticalProperties(0.01, 1.0, 0.8, 1.4); | ||
var originalDiffusionParameters = DiffusionParameters.Create( | ||
ops, | ||
ForwardModel.SDA); | ||
// copy the parameters | ||
var diffusionParameters = DiffusionParameters.Copy(originalDiffusionParameters); | ||
Assert.IsTrue(Math.Abs(2.950078 - diffusionParameters.A) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.330033 - diffusionParameters.D) < 1e-6); | ||
Assert.IsTrue(Math.Abs(214.13747 - diffusionParameters.cn) < 1e-4); | ||
Assert.IsTrue(Math.Abs(0.8 - diffusionParameters.gTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.01 - diffusionParameters.mua) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.174068 - diffusionParameters.mueff) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.0 - diffusionParameters.musTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.01 - diffusionParameters.mutTilde) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.01 - diffusionParameters.mutr) < 1e-6); | ||
Assert.IsTrue(Math.Abs(1.947246 - diffusionParameters.zb) < 1e-6); | ||
Assert.IsTrue(Math.Abs(0.990099 - diffusionParameters.zp) < 1e-6); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters