Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning if diffusion parameters are such that mua>=musp. #160

Merged
Show file tree
Hide file tree
Changes from all commits
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
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);
}
}
}
3 changes: 3 additions & 0 deletions src/Vts/Modeling/ForwardSolvers/DiffusionParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public static DiffusionParameters Create(OpticalProperties op, ForwardModel fm)
var tempMutTilde = op.Mua + tempMusTilde;
var tempZp = 1 / tempMutTilde;

// put out warning if mus' on order of mua
if (op.Mua >= op.Musp) Console.WriteLine("Warning: Mua >= Musp");

return new DiffusionParameters(tempA, tempMueff, tempZb, tempZp, tempMutTilde, tempMusTilde, tempMutr, tempGTilde, tempD, tempCn, tempMua);
}

Expand Down
Loading