diff --git a/README.md b/README.md
index 582553f..ee54af7 100644
--- a/README.md
+++ b/README.md
@@ -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/).
@@ -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:_
@@ -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/).
diff --git a/Vts.MonteCarlo.CommandLineApplication.Test/Vts.MonteCarlo.Application.Test.csproj b/Vts.MonteCarlo.CommandLineApplication.Test/Vts.MonteCarlo.Application.Test.csproj
index 209c4fe..3cbfa94 100644
--- a/Vts.MonteCarlo.CommandLineApplication.Test/Vts.MonteCarlo.Application.Test.csproj
+++ b/Vts.MonteCarlo.CommandLineApplication.Test/Vts.MonteCarlo.Application.Test.csproj
@@ -19,9 +19,9 @@
-
+
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Vts.MonteCarlo.CommandLineApplication/MonteCarloSetup.cs b/Vts.MonteCarlo.CommandLineApplication/MonteCarloSetup.cs
index 9701ff8..058fa93 100644
--- a/Vts.MonteCarlo.CommandLineApplication/MonteCarloSetup.cs
+++ b/Vts.MonteCarlo.CommandLineApplication/MonteCarloSetup.cs
@@ -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));
///
/// method to read the simulation input from a specified or default file
@@ -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;
}
@@ -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)
@@ -71,7 +71,7 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
message += "\n\t\tparamsweep=,Start,Stop,Count";
}
message += "\n\t\tIgnoring this sweep parameter\n";
- logger.Warn(() => message);
+ Logger.Warn(() => message);
return null;
}
@@ -82,11 +82,11 @@ 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=,NumVals,Val1,...,ValN";
message += "\n\t\tIgnoring this sweep parameter\n";
- logger.Warn(() => message);
+ Logger.Warn(() => message);
return null;
}
}
@@ -94,9 +94,8 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
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
@@ -104,7 +103,7 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
// 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);
@@ -112,14 +111,14 @@ public static SimulationInput ReadSimulationInputFromFile(string inputFile)
// 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]);
}
@@ -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 ApplyParameterSweeps(SimulationInput input, IEnumerable parameterSweeps)
{
- IEnumerable batchInputs = input.AsEnumerable();
+ var batchInputs = input.AsEnumerable();
foreach (var parameterSweep in parameterSweeps)
{
diff --git a/Vts.MonteCarlo.CommandLineApplication/ParameterSweep.cs b/Vts.MonteCarlo.CommandLineApplication/ParameterSweep.cs
index 775d939..f9ee5f4 100644
--- a/Vts.MonteCarlo.CommandLineApplication/ParameterSweep.cs
+++ b/Vts.MonteCarlo.CommandLineApplication/ParameterSweep.cs
@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using Vts.Common;
+using Vts.Common;
namespace Vts.MonteCarlo.CommandLineApplication
{
@@ -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;
}
diff --git a/Vts.MonteCarlo.CommandLineApplication/Program.cs b/Vts.MonteCarlo.CommandLineApplication/Program.cs
index c03a9b5..b1a8016 100644
--- a/Vts.MonteCarlo.CommandLineApplication/Program.cs
+++ b/Vts.MonteCarlo.CommandLineApplication/Program.cs
@@ -14,7 +14,7 @@ namespace Vts.MonteCarlo.CommandLineApplication
#region CommandLine Arguments Parser
/* Simple commandline argument parser written by Ananth B. http://www.ananthonline.net */
- static class CommandLine
+ internal static class CommandLine
{
public class Switch // Class that encapsulates switch data.
{
@@ -78,7 +78,7 @@ select s.InvokeHandler(match.Groups[ValueGroup].Value.Split(','))).Sum() == 0)
///
public static class Program
{
- private static Common.Logging.ILogger logger = LoggerFactoryLocator.GetDefaultNLogFactory().Create(typeof(Program));
+ private static readonly Common.Logging.ILogger Logger = LoggerFactoryLocator.GetDefaultNLogFactory().Create(typeof(Program));
///
/// main Monte Carlo CommandLine (MCCL) application
@@ -102,9 +102,9 @@ public static int Main(string[] args)
args.Process(() =>
{
- logger.Info($"\nVirtual Photonics MC {GetVersionNumber(3)}\n");
- logger.Info("For more information type mc help");
- logger.Info("For help on a specific topic type dotnet mc.dll help=\n");
+ Logger.Info($"\nVirtual Photonics MC {GetVersionNumber(3)}\n");
+ Logger.Info("For more information type mc help");
+ Logger.Info("For help on a specific topic type dotnet mc.dll help=\n");
},
new CommandLine.Switch("help", val =>
{
@@ -123,25 +123,25 @@ public static int Main(string[] args)
new CommandLine.Switch("infile", val =>
{
inFile = val.First();
- logger.Info(() => "input file specified as " + inFile);
+ Logger.Info(() => "input file specified as " + inFile);
}),
new CommandLine.Switch("infiles", val =>
{
inFiles.AddRange(val);
foreach (var file in inFiles)
{
- logger.Info(() => "input file specified as " + file);
+ Logger.Info(() => "input file specified as " + file);
}
}),
new CommandLine.Switch("outname", val =>
{
outName = val.First();
- logger.Info(() => "output name overridden as " + outName);
+ Logger.Info(() => "output name overridden as " + outName);
}),
new CommandLine.Switch("outpath", val =>
{
outPath = val.First();
- logger.Info(() => "output path specified as " + outPath);
+ Logger.Info(() => "output path specified as " + outPath);
}),
new CommandLine.Switch("cpucount", val =>
{
@@ -149,17 +149,17 @@ public static int Main(string[] args)
if (CPUCount == "all")
{
CPUCount = Environment.ProcessorCount.ToString();
- logger.Info(() => "changed to maximum CPUs on system " + CPUCount);
+ Logger.Info(() => "changed to maximum CPUs on system " + CPUCount);
}
else
{
if (!int.TryParse(CPUCount, out var CPUCountInt))
{
- logger.Info(() => "unknown cpucount option " + CPUCount);
+ Logger.Info(() => "unknown cpucount option " + CPUCount);
}
else
{
- logger.Info(() => "number of CPUs specified as " + CPUCount);
+ Logger.Info(() => "number of CPUs specified as " + CPUCount);
}
}
}),
@@ -169,7 +169,7 @@ public static int Main(string[] args)
var sweep = MonteCarloSetup.CreateParameterSweep(sweepString, ParameterSweepType.Count);
if (sweep == null) return;
paramSweep.Add(sweep);
- logger.Info(() => "parameter sweep specified as " + sweepString[0] + " from " + sweepString[1] + " to " + sweepString[2] + ", with a count of " + sweepString[3]);
+ Logger.Info(() => "parameter sweep specified as " + sweepString[0] + " from " + sweepString[1] + " to " + sweepString[2] + ", with a count of " + sweepString[3]);
}),
new CommandLine.Switch("paramsweepdelta", val =>
{
@@ -177,7 +177,7 @@ public static int Main(string[] args)
var sweep = MonteCarloSetup.CreateParameterSweep(sweepString, ParameterSweepType.Delta);
if (sweep == null) return;
paramSweep.Add(sweep);
- logger.Info(() => "parameter sweep specified as " + sweepString[0] + " from " + sweepString[1] + " to " + sweepString[2] + ", with a delta of " + sweepString[3]);
+ Logger.Info(() => "parameter sweep specified as " + sweepString[0] + " from " + sweepString[1] + " to " + sweepString[2] + ", with a delta of " + sweepString[3]);
}),
new CommandLine.Switch("paramsweeplist", val =>
{
@@ -185,7 +185,7 @@ public static int Main(string[] args)
var sweep = MonteCarloSetup.CreateParameterSweep(sweepString, ParameterSweepType.List);
if (sweep == null) return;
paramSweep.Add(sweep);
- logger.Info(() => "parameter sweep specified as " + sweepString[0] + " values");
+ Logger.Info(() => "parameter sweep specified as " + sweepString[0] + " values");
}));
if (!infoOnlyOption)
@@ -201,13 +201,13 @@ public static int Main(string[] args)
Console.Read();
return false;
};
-
+ SimulationInput input;
if (paramSweep.Any() || inFiles.Any())
{
IList inputs;
if (paramSweep.Any())
{
- var input = MonteCarloSetup.ReadSimulationInputFromFile(inFile);
+ input = MonteCarloSetup.ReadSimulationInputFromFile(inFile);
if (input == null)
{
return 1;
@@ -236,38 +236,39 @@ public static int Main(string[] args)
if (int.Parse(CPUCount) > 1 && (inputs.First().Options.Databases != null && inputs.First().Options.Databases.Count != 0))
{
CPUCount = 1.ToString();
- logger.Info(() => "parallel processing cannot be performed when a Database is specified, changed CPUCount to 1");
+ Logger.Info(() => "parallel processing cannot be performed when a Database is specified, changed CPUCount to 1");
}
MonteCarloSetup.RunSimulations(inputs, outPath, int.Parse(CPUCount));
- logger.Info("\nSimulations complete.");
+ Logger.Info("\nSimulations complete.");
return 0;
}
- else
+
+ input = MonteCarloSetup.ReadSimulationInputFromFile(inFile);
+ if (input == null)
{
- var input = MonteCarloSetup.ReadSimulationInputFromFile(inFile);
- if (input == null)
- {
- return 1;
- }
+ return 1;
+ }
- if (!checkValid(input))
- return 2;
+ if (!checkValid(input))
+ return 2;
- if (!string.IsNullOrEmpty(outName))
- {
- input.OutputName = outName;
- }
- // make sure input does not specify Database if CPUCount>1
- if (int.Parse(CPUCount) > 1 && (input.Options.Databases != null && input.Options.Databases?.Count != 0))
- {
- CPUCount = 1.ToString();
- logger.Info(() => "parallel processing cannot be performed when a Database is specified, changed CPUCount to 1");
- }
- MonteCarloSetup.RunSimulation(input, outPath, int.Parse(CPUCount));
- logger.Info("\nSimulation complete.");
- return 0;
+ if (!string.IsNullOrEmpty(outName))
+ {
+ input.OutputName = outName;
+ }
+
+ // make sure input does not specify Database if CPUCount>1
+ if (int.Parse(CPUCount) > 1 && (input.Options.Databases != null && input.Options.Databases?.Count != 0))
+ {
+ CPUCount = 1.ToString();
+ Logger.Info(() =>
+ "parallel processing cannot be performed when a Database is specified, changed CPUCount to 1");
}
+
+ MonteCarloSetup.RunSimulation(input, outPath, int.Parse(CPUCount));
+ Logger.Info("\nSimulation complete.");
+ return 0;
}
LogManager.Configuration = null;
@@ -286,7 +287,7 @@ private static void GenerateDefaultInputFiles()
}
catch (Exception e)
{
- logger.Error($"There was an error generating infiles, check your permissions - {e.Message}");
+ Logger.Error($"There was an error generating infiles, check your permissions - {e.Message}");
}
}
@@ -295,46 +296,46 @@ private static void GenerateDefaultInputFiles()
///
private static void ShowHelp()
{
- logger.Info($"Virtual Photonics MC {GetVersionNumber(3)}");
- logger.Info("\nFor more detailed help type dotnet mc.dll help=");
- logger.Info("\ntopics:");
- logger.Info("\ninfile");
- logger.Info("outpath");
- logger.Info("outname");
- logger.Info("cpucount");
- logger.Info("paramsweep");
- logger.Info("paramsweepdelta");
- logger.Info("paramsweeplist");
- logger.Info("\nlist of arguments:");
- logger.Info("\ninfile\t\tthe input file, accepts relative and absolute paths");
- logger.Info("outpath\t\tthe output path, accepts relative and absolute paths");
- logger.Info("outname\t\toutput name, this value is appended for a parameter sweep");
- logger.Info("cpucount\tnumber of CPUs, default is 1");
- logger.Info("paramsweep\ttakes the sweep parameter name and values in the format:");
- logger.Info("\t\tparamsweep=,Start,Stop,Count");
- logger.Info("paramsweepdelta\ttakes the sweep parameter name and values in the format:");
- logger.Info("\t\tparamsweepdelta=,Start,Stop,Delta");
- logger.Info("paramsweeplist\ttakes the sweep parameter name and values in the format:");
- logger.Info("\t\tparamsweeplist=,NumVals,Val1,Val2,...");
- logger.Info("\ngeninfiles\tgenerates example infiles and names them infile_XXX.txt");
- logger.Info("\t\tinfile_XXX.txt where XXX describes the type of input specified");
- logger.Info("\nlist of sweep parameters (SweepParameterType):");
- logger.Info("\nmua1\t\tabsorption coefficient for tissue layer 1");
- logger.Info("mus1\t\tscattering coefficient for tissue layer 1");
- logger.Info("n1\t\trefractive index for tissue layer 1");
- logger.Info("g1\t\tanisotropy for tissue layer 1");
- logger.Info("\nmua2\t\tabsorption coefficient for tissue layer 2");
- logger.Info("mus2\t\tscattering coefficient for tissue layer 2");
- logger.Info("n2\t\trefractive index for tissue layer 2");
- logger.Info("g2\t\tanisotropy for tissue layer 2");
- logger.Info("\nmuai\t\tabsorption coefficient for tissue layer i");
- logger.Info("musi\t\tscattering coefficient for tissue layer i");
- logger.Info("ni\t\trefractive index for tissue layer i");
- logger.Info("gi\t\tanisotropy for tissue layer i");
- logger.Info("\nnphot\t\tnumber of photons to launch from the source");
- logger.Info("\nseed\t\tseed of random number generator");
- logger.Info("\nsample usage:");
- logger.Info("dotnet mc.dll infile=myinput outname=myoutput paramsweep=mua1,0.01,0.04,4 paramsweep=mus1,10,20,2 paramsweep=nphot,1000000,2000000,2\n");
+ Logger.Info($"Virtual Photonics MC {GetVersionNumber(3)}");
+ Logger.Info("\nFor more detailed help type dotnet mc.dll help=");
+ Logger.Info("\ntopics:");
+ Logger.Info("\ninfile");
+ Logger.Info("outpath");
+ Logger.Info("outname");
+ Logger.Info("cpucount");
+ Logger.Info("paramsweep");
+ Logger.Info("paramsweepdelta");
+ Logger.Info("paramsweeplist");
+ Logger.Info("\nlist of arguments:");
+ Logger.Info("\ninfile\t\tthe input file, accepts relative and absolute paths");
+ Logger.Info("outpath\t\tthe output path, accepts relative and absolute paths");
+ Logger.Info("outname\t\toutput name, this value is appended for a parameter sweep");
+ Logger.Info("cpucount\tnumber of CPUs, default is 1");
+ Logger.Info("paramsweep\ttakes the sweep parameter name and values in the format:");
+ Logger.Info("\t\tparamsweep=,Start,Stop,Count");
+ Logger.Info("paramsweepdelta\ttakes the sweep parameter name and values in the format:");
+ Logger.Info("\t\tparamsweepdelta=,Start,Stop,Delta");
+ Logger.Info("paramsweeplist\ttakes the sweep parameter name and values in the format:");
+ Logger.Info("\t\tparamsweeplist=,NumVals,Val1,Val2,...");
+ Logger.Info("\ngeninfiles\tgenerates example infiles and names them infile_XXX.txt");
+ Logger.Info("\t\tinfile_XXX.txt where XXX describes the type of input specified");
+ Logger.Info("\nlist of sweep parameters (SweepParameterType):");
+ Logger.Info("\nmua1\t\tabsorption coefficient for tissue layer 1");
+ Logger.Info("mus1\t\tscattering coefficient for tissue layer 1");
+ Logger.Info("n1\t\trefractive index for tissue layer 1");
+ Logger.Info("g1\t\tanisotropy for tissue layer 1");
+ Logger.Info("\nmua2\t\tabsorption coefficient for tissue layer 2");
+ Logger.Info("mus2\t\tscattering coefficient for tissue layer 2");
+ Logger.Info("n2\t\trefractive index for tissue layer 2");
+ Logger.Info("g2\t\tanisotropy for tissue layer 2");
+ Logger.Info("\nmuai\t\tabsorption coefficient for tissue layer i");
+ Logger.Info("musi\t\tscattering coefficient for tissue layer i");
+ Logger.Info("ni\t\trefractive index for tissue layer i");
+ Logger.Info("gi\t\tanisotropy for tissue layer i");
+ Logger.Info("\nnphot\t\tnumber of photons to launch from the source");
+ Logger.Info("\nseed\t\tseed of random number generator");
+ Logger.Info("\nsample usage:");
+ Logger.Info("dotnet mc.dll infile=myinput outname=myoutput paramsweep=mua1,0.01,0.04,4 paramsweep=mus1,10,20,2 paramsweep=nphot,1000000,2000000,2\n");
}
///
@@ -346,64 +347,64 @@ private static void ShowHelp(string helpTopic)
switch (helpTopic.ToLower())
{
case "infile":
- logger.Info("\nINFILE");
- logger.Info("This is the name of the input file, it can be a relative or absolute path.");
- logger.Info("If the path name has any spaces enclose it in double quotes.");
- logger.Info("For relative paths, omit the leading slash.");
- logger.Info("EXAMPLES for .txt (json) files:");
- logger.Info("\tinfile=C:\\MonteCarlo\\InputFiles\\myinfile.txt");
- logger.Info("\tinfile=\"C:\\Monte Carlo\\InputFiles\\myinfile.txt\"");
- logger.Info("\tinfile=InputFiles\\myinfile.txt");
- logger.Info("\tinfile=myinfile.txt");
+ Logger.Info("\nINFILE");
+ Logger.Info("This is the name of the input file, it can be a relative or absolute path.");
+ Logger.Info("If the path name has any spaces enclose it in double quotes.");
+ Logger.Info("For relative paths, omit the leading slash.");
+ Logger.Info("EXAMPLES for .txt (json) files:");
+ Logger.Info("\tinfile=C:\\MonteCarlo\\InputFiles\\myinfile.txt");
+ Logger.Info("\tinfile=\"C:\\Monte Carlo\\InputFiles\\myinfile.txt\"");
+ Logger.Info("\tinfile=InputFiles\\myinfile.txt");
+ Logger.Info("\tinfile=myinfile.txt");
break;
case "outpath":
- logger.Info("\nOUTPATH");
- logger.Info("This is the name of the output path, it can be a relative or absolute path.");
- logger.Info("If the path name has any spaces enclose it in double quotes.");
- logger.Info("For relative paths, omit the leading slash.");
- logger.Info("EXAMPLES:");
- logger.Info("\toutpath=C:\\MonteCarlo\\OutputFiles");
- logger.Info("\toutpath=OutputFiles");
+ Logger.Info("\nOUTPATH");
+ Logger.Info("This is the name of the output path, it can be a relative or absolute path.");
+ Logger.Info("If the path name has any spaces enclose it in double quotes.");
+ Logger.Info("For relative paths, omit the leading slash.");
+ Logger.Info("EXAMPLES:");
+ Logger.Info("\toutpath=C:\\MonteCarlo\\OutputFiles");
+ Logger.Info("\toutpath=OutputFiles");
break;
case "outname":
- logger.Info("\nOUTNAME");
- logger.Info("The outname is appended to the folder names if there is a parameter sweep.");
- logger.Info("EXAMPLE:");
- logger.Info("\toutname=mcResults");
+ Logger.Info("\nOUTNAME");
+ Logger.Info("The outname is appended to the folder names if there is a parameter sweep.");
+ Logger.Info("EXAMPLE:");
+ Logger.Info("\toutname=mcResults");
break;
case "cpucount":
- logger.Info("\nCPUCOUNT");
- logger.Info("The cpucount specifies the number of CPUs utilized to process a single simulation.");
- logger.Info($"The number of CPUs on this computer: {Environment.ProcessorCount}");
- logger.Info("EXAMPLE:");
- logger.Info("\tcpucount=4");
+ Logger.Info("\nCPUCOUNT");
+ Logger.Info("The cpucount specifies the number of CPUs utilized to process a single simulation.");
+ Logger.Info($"The number of CPUs on this computer: {Environment.ProcessorCount}");
+ Logger.Info("EXAMPLE:");
+ Logger.Info("\tcpucount=4");
break;
case "paramsweep":
- logger.Info("\nPARAMSWEEP");
- logger.Info("Defines the parameter sweep and its values.");
- logger.Info("FORMAT:");
- logger.Info("\tparamsweep=,Start,Stop,Count");
- logger.Info("EXAMPLES:");
- logger.Info("\tparamsweep=mua1,0.01,0.04,4");
- logger.Info("\tparamsweep=mus1,10,20,2");
+ Logger.Info("\nPARAMSWEEP");
+ Logger.Info("Defines the parameter sweep and its values.");
+ Logger.Info("FORMAT:");
+ Logger.Info("\tparamsweep=,Start,Stop,Count");
+ Logger.Info("EXAMPLES:");
+ Logger.Info("\tparamsweep=mua1,0.01,0.04,4");
+ Logger.Info("\tparamsweep=mus1,10,20,2");
break;
case "paramsweepdelta":
- logger.Info("\nPARAMSWEEPDELTA");
- logger.Info("Defines the parameter sweep and its values.");
- logger.Info("FORMAT:");
- logger.Info("\tparamsweepdelta=,Start,Stop,Delta");
- logger.Info("EXAMPLES:");
- logger.Info("\tparamsweepdelta=mua1,0.01,0.04,0.01");
- logger.Info("\tparamsweepdelta=mus1,10,20,5");
+ Logger.Info("\nPARAMSWEEPDELTA");
+ Logger.Info("Defines the parameter sweep and its values.");
+ Logger.Info("FORMAT:");
+ Logger.Info("\tparamsweepdelta=,Start,Stop,Delta");
+ Logger.Info("EXAMPLES:");
+ Logger.Info("\tparamsweepdelta=mua1,0.01,0.04,0.01");
+ Logger.Info("\tparamsweepdelta=mus1,10,20,5");
break;
case "paramsweeplist":
- logger.Info("\nPARAMSWEEPLIST");
- logger.Info("Defines the parameter sweep and its values.");
- logger.Info("FORMAT:");
- logger.Info("\tparamsweeplist=,NumValues,Val1,Val2,Val3,...");
- logger.Info("EXAMPLES:");
- logger.Info("\tparamsweeplist=mua1,3,0.01,0.03,0.04");
- logger.Info("\tparamsweeplist=mus1,5,0.01,1,10,100,1000");
+ Logger.Info("\nPARAMSWEEPLIST");
+ Logger.Info("Defines the parameter sweep and its values.");
+ Logger.Info("FORMAT:");
+ Logger.Info("\tparamsweeplist=,NumValues,Val1,Val2,Val3,...");
+ Logger.Info("EXAMPLES:");
+ Logger.Info("\tparamsweeplist=mua1,3,0.01,0.03,0.04");
+ Logger.Info("\tparamsweeplist=mus1,5,0.01,1,10,100,1000");
break;
default:
ShowHelp();
@@ -413,22 +414,15 @@ private static void ShowHelp(string helpTopic)
private static string GetVersionNumber(uint limiter = 0)
{
- switch (limiter)
+ var currentAssembly = Assembly.GetExecutingAssembly().GetName();
+ if (currentAssembly.Version == null) return null;
+ return limiter switch
{
- case 1:
- return
- $"{Assembly.GetExecutingAssembly().GetName().Version.Major}";
- case 2:
- return
- $"{Assembly.GetExecutingAssembly().GetName().Version.Major}.{Assembly.GetExecutingAssembly().GetName().Version.Minor}";
- case 3:
- return
- $"{Assembly.GetExecutingAssembly().GetName().Version.Major}.{Assembly.GetExecutingAssembly().GetName().Version.Minor}.{Assembly.GetExecutingAssembly().GetName().Version.Build}";
- default:
- return
- $"{Assembly.GetExecutingAssembly().GetName().Version}";
-
- }
+ 1 => $"{currentAssembly.Version.Major}",
+ 2 => $"{currentAssembly.Version.Major}.{currentAssembly.Version.Minor}",
+ 3 => $"{currentAssembly.Version.Major}.{currentAssembly.Version.Minor}.{currentAssembly.Version.Build}",
+ _ => $"{currentAssembly.Version}"
+ };
}
}
}
diff --git a/Vts.MonteCarlo.CommandLineApplication/Vts.MonteCarlo.Application.csproj b/Vts.MonteCarlo.CommandLineApplication/Vts.MonteCarlo.Application.csproj
index 706c7ce..86bdaef 100644
--- a/Vts.MonteCarlo.CommandLineApplication/Vts.MonteCarlo.Application.csproj
+++ b/Vts.MonteCarlo.CommandLineApplication/Vts.MonteCarlo.Application.csproj
@@ -6,8 +6,8 @@
mc
win-x64;linux-x64;osx-x64
Vts.MonteCarlo.CommandLineApplication
- 7.0.0.0
- 7.0.0.0
+ 7.1.0.0
+ 7.1.0.0
false
Virtual Photonics Technology Initiative
MCCL
@@ -20,7 +20,7 @@
https://github.com/VirtualPhotonics/VTS
C# Monte-Carlo
Git
- 7.0.0
+ 7.1.0
README.md
@@ -32,7 +32,7 @@
-
+
diff --git a/Vts.MonteCarlo.PostProcessor.Test/Vts.MonteCarlo.PostProcessor.Application.Test.csproj b/Vts.MonteCarlo.PostProcessor.Test/Vts.MonteCarlo.PostProcessor.Application.Test.csproj
index cd4a534..f5c5e74 100644
--- a/Vts.MonteCarlo.PostProcessor.Test/Vts.MonteCarlo.PostProcessor.Application.Test.csproj
+++ b/Vts.MonteCarlo.PostProcessor.Test/Vts.MonteCarlo.PostProcessor.Application.Test.csproj
@@ -7,9 +7,9 @@
-
+
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Vts.MonteCarlo.PostProcessor/PostProcessorSetup.cs b/Vts.MonteCarlo.PostProcessor/PostProcessorSetup.cs
index 20cd595..bc9f4fc 100644
--- a/Vts.MonteCarlo.PostProcessor/PostProcessorSetup.cs
+++ b/Vts.MonteCarlo.PostProcessor/PostProcessorSetup.cs
@@ -10,7 +10,7 @@
namespace Vts.MonteCarlo.PostProcessor
{
- public class PostProcessorSetup
+ public static class PostProcessorSetup
{
///
/// method to read the post processor input from a specified or default files
diff --git a/Vts.MonteCarlo.PostProcessor/Program.cs b/Vts.MonteCarlo.PostProcessor/Program.cs
index 1160258..6bbd450 100644
--- a/Vts.MonteCarlo.PostProcessor/Program.cs
+++ b/Vts.MonteCarlo.PostProcessor/Program.cs
@@ -10,7 +10,7 @@ namespace Vts.MonteCarlo.PostProcessor
#region CommandLine Arguments Parser
/* Simple commandline argument parser written by Ananth B. http://www.ananthonline.net */
- static class CommandLine
+ internal static class CommandLine
{
public class Switch // Class that encapsulates switch data.
{
@@ -82,11 +82,11 @@ public static int Main(string[] args)
#if PROCESS_ATTACH_DEBUG
Console.Read();
#endif
- string inFile = "infile.txt";
- string inPath = "";
- string outName = "";
- string outPath = "";
- bool infoOnlyOption = false;
+ var inFile = "infile.txt";
+ var inPath = "";
+ var outName = "";
+ var outPath = "";
+ var infoOnlyOption = false;
args.Process(() =>
{
Console.WriteLine("Virtual Photonics MC Post-Processor 1.0");
@@ -126,41 +126,37 @@ public static int Main(string[] args)
})
);
- if (!infoOnlyOption)
+ if (infoOnlyOption) return 0;
+ var input = PostProcessorSetup.ReadPostProcessorInputFromFile(inFile);
+ if (input == null)
{
- var input = PostProcessorSetup.ReadPostProcessorInputFromFile(inFile);
- if (input == null)
- {
- return 1;
- }
+ return 1;
+ }
- var validationResult = PostProcessorSetup.ValidatePostProcessorInput(input, inPath);
- if (!validationResult.IsValid)
- {
- Console.Write("\nPost-processor) completed with errors. Press enter key to exit.");
- Console.Read();
- return 2;
- }
- // override the output name with the user-specified name
- if (!string.IsNullOrEmpty(outName))
- {
- input.OutputName = outName;
- }
- PostProcessorSetup.RunPostProcessor(input, inPath, outPath);
- Console.WriteLine("\nPost-processing complete.");
- return 0;
+ var validationResult = PostProcessorSetup.ValidatePostProcessorInput(input, inPath);
+ if (!validationResult.IsValid)
+ {
+ Console.Write("\nPost-processor) completed with errors. Press enter key to exit.");
+ Console.Read();
+ return 2;
+ }
+ // override the output name with the user-specified name
+ if (!string.IsNullOrEmpty(outName))
+ {
+ input.OutputName = outName;
}
+ PostProcessorSetup.RunPostProcessor(input, inPath, outPath);
+ Console.WriteLine("\nPost-processing complete.");
return 0;
}
private static void GenerateDefaultInputFiles()
{
var infiles = PostProcessorInputProvider.GenerateAllPostProcessorInputs();
- for (int i = 0; i < infiles.Count; i++)
+ foreach (var file in infiles)
{
- infiles[i].ToFile("infile_" + infiles[i].OutputName + ".txt");
+ file.ToFile("infile_" + file.OutputName + ".txt");
}
-
}
///
diff --git a/Vts.MonteCarlo.PostProcessor/Vts.MonteCarlo.PostProcessor.Application.csproj b/Vts.MonteCarlo.PostProcessor/Vts.MonteCarlo.PostProcessor.Application.csproj
index ad45edc..de5cd0a 100644
--- a/Vts.MonteCarlo.PostProcessor/Vts.MonteCarlo.PostProcessor.Application.csproj
+++ b/Vts.MonteCarlo.PostProcessor/Vts.MonteCarlo.PostProcessor.Application.csproj
@@ -6,8 +6,8 @@
Vts.MonteCarlo.PostProcessor
mc_post
win-x64;linux-x64;osx-x64
- 7.0.0.0
- 7.0.0.0
+ 7.1.0.0
+ 7.1.0.0
David Cuccia; Carole Hayakawa; Lisa Malenfant; Janaka Ranasinghesagara; Jennifer Nguyen; Adam Gardner; Michele Martinelli
Virtual Photonics Technology Initiative
MCPP
@@ -20,11 +20,11 @@
Git
C# Monte-Carlo
false
- 7.0.0
+ 7.1.0
-
+
diff --git a/license.md b/license.md
index 6d90235..0a58589 100644
--- a/license.md
+++ b/license.md
@@ -1,6 +1,6 @@
## The MIT License (MIT)
-#### Copyright (c) 2020 Virtual Photonics Technology Initiative
+#### Copyright (c) 2022 Virtual Photonics Technology Initiative
### Acknowledgement
Use the following acknowledgement in publications or applications that make use of this open source software or underlying technology and research: