Skip to content

Commit d7bd4cc

Browse files
committed
Renamed the monte-carlo folder and added folders and readmes for the additional demos, updated the scripts to reflect the folder changes
1 parent bd9a1eb commit d7bd4cc

10 files changed

Lines changed: 73 additions & 1530 deletions

File tree

forward-solvers/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This folder will contain the Forward Solver demos.

inverse-solutions/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This folder will contain the Inverse Solution demos.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
The VTS libraries should be copied into this folder. Get the latest VTS library (VTS.dll) and its dependencies from the releases section of this repository https://github.com/VirtualPhotonics/Vts.Scripting.Python/releases
1+
The VTS libraries should be copied into this folder. Get the latest VTS library (VTS.dll) and its dependencies from the releases section of this repository https://github.com/VirtualPhotonics/Vts.Scripting.Python/releases

scripting/monte_carlo/demo_02_DAW_vs_CAW.ipynb renamed to monte-carlo/daw_vs_caw.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"#Import the Operating System so we can access the files for the VTS library\n",
2828
"import os\n",
2929
"current_directory = os.getcwd()\n",
30-
"library_directory = current_directory.replace(\"monte_carlo\", \"libraries\")\n",
30+
"library_directory = current_directory.replace(\"monte-carlo\", \"libraries\")\n",
3131
"vts_path = os.path.join(library_directory, \"Vts.dll\")"
3232
]
3333
},
@@ -72,7 +72,6 @@
7272
"clr.AddReference(vts_path)\n",
7373
"import numpy as np\n",
7474
"import plotly.graph_objects as go\n",
75-
"import plotly.express as px\n",
7675
"from Vts import *\n",
7776
"from Vts.Common import *\n",
7877
"from Vts.Extensions import *\n",

monte-carlo/r-of-rho.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This is an example of python code using VTS to plot R(rho) using MCCL
2+
#
3+
# Import the Operating System so we can access the files for the VTS library
4+
import libraries
5+
from pythonnet import load
6+
load('coreclr')
7+
import clr
8+
import os
9+
file = './libraries/Vts.dll'
10+
print('Does this filepath exist?', os.path.isfile(file))
11+
clr.AddReference(os.path.abspath(file))
12+
13+
print('Import numpy')
14+
import numpy as np
15+
print('Import plotly.graph')
16+
import plotly.graph_objects as go
17+
print('Import Vts')
18+
from Vts import *
19+
from Vts.Common import *
20+
from Vts.Extensions import *
21+
from Vts.Modeling.Optimizers import *
22+
from Vts.Modeling.ForwardSolvers import *
23+
from Vts.SpectralMapping import *
24+
from Vts.Factories import *
25+
from Vts.MonteCarlo import *
26+
from Vts.MonteCarlo.Sources import *
27+
from Vts.MonteCarlo.Tissues import *
28+
from Vts.MonteCarlo.Detectors import *
29+
from Vts.MonteCarlo.Factories import *
30+
from Vts.MonteCarlo.PhotonData import *
31+
from Vts.MonteCarlo.PostProcessing import *
32+
print('Import System')
33+
from System import Array
34+
# Setup the values for the simulations and plot results
35+
# create a SimulationInput object to define the simulation
36+
detectorRange = DoubleRange(start=0, stop=40, number=201)
37+
detectorInput = ROfRhoDetectorInput()
38+
detectorInput.Rho = detectorRange
39+
detectorInput.Name = "ROfRho"
40+
detectors = Array.CreateInstance(IDetectorInput,1)
41+
detectors[0] = detectorInput
42+
43+
simulationInput = SimulationInput()
44+
simulationInput.N=1000
45+
simulationInput.DetectorInputs= detectors
46+
47+
# create the simulation
48+
simulation = MonteCarloSimulation(simulationInput)
49+
50+
# run the simulation
51+
simulationOutput = simulation.Run()
52+
53+
# plot the results using Plotly
54+
detectorResults = Array.CreateInstance(ROfRhoDetector,1)
55+
detectorResults[0] = simulationOutput.ResultsDictionary["ROfRho"]
56+
logReflectance = [r for r in detectorResults[0].Mean]
57+
detectorMidpoints = [mp for mp in detectorRange]
58+
59+
xLabel = "ρ [mm]"
60+
yLabel = "log(R(ρ)) [mm-2]"
61+
62+
chart = go.Figure()
63+
chart.add_trace(go.Scatter(x=detectorMidpoints, y=logReflectance, mode='markers'))
64+
chart.update_layout( title="log(R(ρ)) [mm-2]", xaxis_title=xLabel, yaxis_title=yLabel)
65+
chart.update_yaxes(type="log")
66+
chart.show(renderer="browser")

scripting/monte_carlo/demo_01_r_of_rho_simple.ipynb renamed to monte-carlo/r_of_rho.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"#Import the Operating System so we can access the files for the VTS library\n",
2626
"import os\n",
2727
"current_directory = os.getcwd()\n",
28-
"library_directory = current_directory.replace(\"monte_carlo\", \"libraries\")\n",
28+
"library_directory = current_directory.replace(\"monte-carlo\", \"libraries\")\n",
2929
"vts_path = os.path.join(library_directory, \"Vts.dll\")"
3030
]
3131
},
@@ -66,7 +66,6 @@
6666
"clr.AddReference(vts_path)\n",
6767
"import numpy as np\n",
6868
"import plotly.graph_objects as go\n",
69-
"import plotly.express as px\n",
7069
"from Vts import *\n",
7170
"from Vts.Common import *\n",
7271
"from Vts.Extensions import *\n",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"#Import the Operating System so we can get the file path for the Vts library\n",
3838
"import os\n",
3939
"current_directory = os.getcwd()\n",
40-
"library_directory = current_directory.replace(\"monte_carlo\", \"libraries\")\n",
40+
"library_directory = current_directory.replace(\"monte-carlo\", \"libraries\")\n",
4141
"vts_path = os.path.join(library_directory, \"Vts.dll\")\n",
4242
"clr.AddReference(vts_path)"
4343
]
@@ -260,7 +260,7 @@
260260
"source": [
261261
"Which should produce \n",
262262
"\n",
263-
"<img src='example.svg'>"
263+
"<img src='r_of_rho_impulse_beam.svg'>"
264264
]
265265
}
266266
],

0 commit comments

Comments
 (0)