Skip to content

Commit

Permalink
Merge pull request #3 from VirtualPhotonics/new-release
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
lmalenfant authored Dec 23, 2022
2 parents 697a892 + b3fd619 commit 2ee7ce8
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 207 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Vts.MonteCarlo
Monte Carlo .NET Core command applications for running simulations and post processing
Monte Carlo .NET 6.0 command applications for running simulations and post processing

## Releases & Downloads
To access the latest release, past releases and downloads, click [here](https://github.com/VirtualPhotonics/Vts.MonteCarlo/releases/).
Expand All @@ -17,7 +17,7 @@ __Carole K. Hayakawa, Lisa Malenfant, Janaka C. Ranasinghesagara, David J. Cucci

For detailed instructions on software, click [here](https://github.com/VirtualPhotonics/Vts.MonteCarlo/wiki).

In Visual Studio 2010, 2013, 2015 or 2017 open the file Vts.MonteCarlo/Vts.MonteCarlo.sln. Rebuild the application to bring in the nuget packages and run the application.
In Visual Studio 2019 or 2022 open the file Vts.MonteCarlo/Vts.MonteCarlo.sln. Rebuild the application to bring in the nuget packages and run the application.

_Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:_

Expand All @@ -28,4 +28,4 @@ _THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPL
## Copyright
Virtual Tissue Simulator (VTS) Project.

Copyright ©2020 [Virtual Photonics Technology Initiative](https://virtualphotonics.org/).
Copyright ©2022 [Virtual Photonics Technology Initiative](https://virtualphotonics.org/).
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
29 changes: 14 additions & 15 deletions Vts.MonteCarlo.CommandLineApplication/MonteCarloSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

namespace Vts.MonteCarlo.CommandLineApplication
{
public class MonteCarloSetup
public static class MonteCarloSetup
{
private static ILogger logger = LoggerFactoryLocator.GetDefaultNLogFactory().Create(typeof(MonteCarloSetup));
private static readonly ILogger Logger = LoggerFactoryLocator.GetDefaultNLogFactory().Create(typeof(MonteCarloSetup));

/// <summary>
/// method to read the simulation input from a specified or default file
Expand All @@ -25,7 +25,7 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
{
if (string.IsNullOrEmpty(inputFile))
{
logger.Info(" *** No input file specified ***\n\nDefine an input file using mc.exe infile=infile_name.txt");
Logger.Info(" *** No input file specified ***\n\nDefine an input file using mc.exe infile=infile_name.txt");
return null;
}

Expand Down Expand Up @@ -59,7 +59,7 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
if (parameterSweepString.Length != 4)
{

string message =
var message =
" *** Invalid sweep parameter ***" +
"\n\t\tsweep parameters should have 4 values in the format:";
if (type == ParameterSweepType.Delta)
Expand All @@ -71,7 +71,7 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
message += "\n\t\tparamsweep=<Parameter>,Start,Stop,Count";
}
message += "\n\t\tIgnoring this sweep parameter\n";
logger.Warn(() => message);
Logger.Warn(() => message);
return null;

}
Expand All @@ -82,44 +82,43 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
// check that number is an integer and that number of parameters is 2 more than number
if ((number == Math.Floor(number)) && (parameterSweepString.Length != number + 2))
{
string message =
var message =
" *** Invalid sweep parameter: either Number or number of Vals is in error ***" +
"\n\t\tsweep parameters should have format paramsweeplist=<Parameter>,NumVals,Val1,...,ValN";
message += "\n\t\tIgnoring this sweep parameter\n";
logger.Warn(() => message);
Logger.Warn(() => message);
return null;
}
}

try
{
var inputParameterType = parameterSweepString[0];
double start, stop, delta;
int count;
DoubleRange sweepRange = null;
double start, stop;
DoubleRange sweepRange;
switch (type)
{
// batch parameter values should come in fours for Delta and Count
case ParameterSweepType.Delta:
// eg. paramsweepdelta=mua1,0.0,4.0,0.05 paramsweepdelta=mus1,0.5,1.5,0.1 paramsweepdelta=mus2,0.5,1.5,0.1 ...
start = double.Parse(parameterSweepString[1]);
stop = double.Parse(parameterSweepString[2]);
delta = double.Parse(parameterSweepString[3]);
var delta = double.Parse(parameterSweepString[3]);
// use Math.Round to make sure floating point precision doesn't reduce/increase count
sweepRange = new DoubleRange(start, stop, (int)(Math.Round((stop - start) / delta)) + 1);
return new ParameterSweep(inputParameterType, sweepRange);
case ParameterSweepType.Count:
// eg. paramsweep=mua1,0.01,4.0,101 paramsweep=mus1,0.5,1.5,3 paramsweep=mus2,0.5,1.5,3 ...
start = double.Parse(parameterSweepString[1]);
stop = double.Parse(parameterSweepString[2]);
count = int.Parse(parameterSweepString[3]);
var count = int.Parse(parameterSweepString[3]);
sweepRange = new DoubleRange(start, stop, count);
return new ParameterSweep(inputParameterType, sweepRange);
case ParameterSweepType.List:
// eg. paramsweeplist=mua1,2,0.01,0.02
var number = int.Parse(parameterSweepString[1]);
var sweepList = new double[number];
for (int i = 0; i < number; i++)
for (var i = 0; i < number; i++)
{
sweepList[i]=double.Parse(parameterSweepString[i + 2]);
}
Expand All @@ -129,14 +128,14 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
}
catch
{
logger.Error(() => "Could not parse the input arguments.\n\tIgnoring the following input parameter sweep: " + parameterSweepString);
Logger.Error(() => "Could not parse the input arguments.\n\tIgnoring the following input parameter sweep: " + parameterSweepString);
return null;
}
}

public static IEnumerable<SimulationInput> ApplyParameterSweeps(SimulationInput input, IEnumerable<ParameterSweep> parameterSweeps)
{
IEnumerable<SimulationInput> batchInputs = input.AsEnumerable();
var batchInputs = input.AsEnumerable();

foreach (var parameterSweep in parameterSweeps)
{
Expand Down
5 changes: 2 additions & 3 deletions Vts.MonteCarlo.CommandLineApplication/ParameterSweep.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Vts.Common;
using Vts.Common;

namespace Vts.MonteCarlo.CommandLineApplication
{
Expand All @@ -15,7 +14,7 @@ public ParameterSweep(string name, DoubleRange range)
Name = name;
Range = range;
Values = new double[range.Count];
for (int i = 0; i < range.Count; i++)
for (var i = 0; i < range.Count; i++)
{
Values[i] = range.Start + i * range.Delta;
}
Expand Down
Loading

0 comments on commit 2ee7ce8

Please sign in to comment.