Skip to content

Commit 4baaa65

Browse files
author
Lisa Malenfant
committed
Initial Commit
0 parents  commit 4baaa65

File tree

5 files changed

+148
-0
lines changed

5 files changed

+148
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.ipynb_checkpoints/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Jupyter notebooks to call the VTS using Python

license.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## The MIT License (MIT)
2+
3+
#### Copyright (c) 2023 Virtual Photonics Technology Initiative
4+
5+
### Acknowledgement
6+
Use the following acknowledgement in publications or applications that make use of this open source software or underlying technology and research:
7+
8+
__"This work was made possible through open-source software resources offered by the Virtual Photonics Technology Initiative, at the Beckman Laser Institute, University of California, Irvine."__
9+
10+
_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:_
11+
12+
_The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software._
13+
14+
_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import os\n",
10+
"current_directory = os.getcwd()\n",
11+
"publish_local = current_directory.replace(\"monte_carlo\", \"libraries\\Vts.dll\")"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"pip install pythonnet plotly numpy"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"from pythonnet import set_runtime\n",
30+
"set_runtime(\"coreclr\")\n",
31+
"import clr\n",
32+
"clr.AddReference(publish_local) # Copy the VTS dlls into the libraries folders\n",
33+
"import numpy as np\n",
34+
"import plotly.graph_objects as go\n",
35+
"from Vts import *\n",
36+
"from Vts.Common import *\n",
37+
"from Vts.Extensions import *\n",
38+
"from Vts.Modeling.Optimizers import *\n",
39+
"from Vts.Modeling.ForwardSolvers import *\n",
40+
"from Vts.SpectralMapping import *\n",
41+
"from Vts.Factories import *\n",
42+
"from Vts.MonteCarlo import *\n",
43+
"from Vts.MonteCarlo.Sources import *\n",
44+
"from Vts.MonteCarlo.Tissues import *\n",
45+
"from Vts.MonteCarlo.Detectors import *\n",
46+
"from Vts.MonteCarlo.Factories import *\n",
47+
"from Vts.MonteCarlo.PhotonData import *\n",
48+
"from Vts.MonteCarlo.PostProcessing import *\n",
49+
"from System import Array"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"# create a SimulationInput object to define the simulation\n",
59+
"detectorRange = DoubleRange(start=0, stop=40, number=201)\n",
60+
"detectorInput = ROfRhoDetectorInput()\n",
61+
"detectorInput.Rho = detectorRange\n",
62+
"detectorInput.Name = \"ROfRho\"\n",
63+
"detectors = Array.CreateInstance(IDetectorInput,1)\n",
64+
"detectors[0] = detectorInput\n",
65+
"\n",
66+
"simulationInput = SimulationInput()\n",
67+
"simulationInput.N=1000\n",
68+
"simulationInput.DetectorInputs= detectors\n",
69+
"\n",
70+
"# create the simulation\n",
71+
"simulation = MonteCarloSimulation(simulationInput)\n",
72+
"\n",
73+
"# run the simulation\n",
74+
"simulationOutput = simulation.Run()\n",
75+
"\n",
76+
"# plot the results using Plotly\n",
77+
"detectorResults = Array.CreateInstance(ROfRhoDetector,1)\n",
78+
"detectorResults[0] = simulationOutput.ResultsDictionary[\"ROfRho\"]\n",
79+
"logReflectance = [np.log(r) for r in detectorResults[0].Mean]\n",
80+
"detectorMidpoints = [mp for mp in detectorRange.AsEnumerable()]\n",
81+
"\n",
82+
"xLabel = \"ρ [mm]\"\n",
83+
"yLabel = \"log(R(ρ)) [mm-2]\"\n",
84+
"\n",
85+
"chart = go.Figure()\n",
86+
"chart.add_trace(go.Scatter(x=detectorMidpoints, y=logReflectance, mode='lines+markers'))\n",
87+
"chart.update_layout( title=\"log(R(ρ)) [mm-2]\", xaxis_title=xLabel, yaxis_title=yLabel)\n",
88+
"chart.show()\n"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": null,
94+
"metadata": {},
95+
"outputs": [],
96+
"source": []
97+
}
98+
],
99+
"metadata": {
100+
"kernelspec": {
101+
"display_name": "Python 3 (ipykernel)",
102+
"language": "python",
103+
"name": "python3"
104+
},
105+
"language_info": {
106+
"codemirror_mode": {
107+
"name": "ipython",
108+
"version": 3
109+
},
110+
"file_extension": ".py",
111+
"mimetype": "text/x-python",
112+
"name": "python",
113+
"nbconvert_exporter": "python",
114+
"pygments_lexer": "ipython3",
115+
"version": "3.11.5"
116+
}
117+
},
118+
"nbformat": 4,
119+
"nbformat_minor": 2
120+
}

scripting/runtimeconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"runtimeOptions": {
3+
"tfm": "net6.0",
4+
"framework": {
5+
"name": "Microsoft.NETCore.App",
6+
"version": "6.0.0"
7+
},
8+
"configProperties": {
9+
"System.GC.Server": true
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)