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 max splits #243

Merged
merged 1 commit into from
Sep 27, 2023
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
11 changes: 6 additions & 5 deletions tasks/task_13_variance_reduction/2_shielded_room_single_ww.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,15 @@
"wwg = openmc.WeightWindowGenerator(\n",
" mesh=mesh, # this is the mesh that covers the geometry\n",
" energy_bounds=np.linspace(0.0, 2.5e6, 10), # 10 energy bins from 0 to max source energy\n",
" particle_type='neutron'\n",
" particle_type='neutron',\n",
")\n",
"\n",
"# The simulation with Weight Windows takes more time per particle because particles are splitting\n",
"# and take more time from birth to termination for the particle including all the split particles\n",
"# we are reducing the number of particles so this simulation takes a similar amount of time\n",
"# to the previous simulation that didn't use weight windows. So we can make a fair comparison\n",
"model.settings.particles = 4900\n",
"model.settings.max_splits = 1_000 # controls the maximum partile splits over the entire lifetime of the particle\n",
"model.settings.weight_window_generators = wwg"
]
},
Expand All @@ -444,9 +445,9 @@
"\n",
"t1 = time.time()\n",
"\n",
"print(f'total time without weight windows {int(t1-t0)}s')\n",
"print(f'total time with weight windows {int(t1-t0)}s')\n",
"\n",
"plot_mesh_tally(ww_statepoint_filename, 'no_ww.png')"
"plot_mesh_tally(ww_statepoint_filename, 'ww.png')"
]
},
{
Expand All @@ -467,7 +468,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "53fa1fce-f1b4-40b5-aa8f-fa58de32f65b",
"id": "09d8d704-75e5-4339-9ff0-da64ae79721c",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -489,7 +490,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"# all (100%) of source particles are 14MeV energy\n",
"energy = openmc.stats.Discrete([14e6], [1.0])\n",
"\n",
"source = openmc.Source(space=space, angle=angle, energy=energy)\n",
"source = openmc.IndependentSource(space=space, angle=angle, energy=energy)\n",
"source.particle = \"neutron\""
]
},
Expand All @@ -162,7 +162,7 @@
"metadata": {},
"outputs": [],
"source": [
"mesh = openmc.RegularMesh().from_domain(domain=my_geometry)\n",
"mesh = openmc.RegularMesh().from_domain(domain=my_geometry, dimension=[20,20,20])\n",
"\n",
"mesh_filter = openmc.MeshFilter(mesh)\n",
"\n",
Expand Down Expand Up @@ -199,6 +199,7 @@
"my_settings.source = source\n",
"my_settings.particles = 120\n",
"my_settings.batches = 10\n",
"my_settings.max_splits = 4000 # controls the total number of maximum splits a particle can do over the entire lifetime\n",
"\n",
"# no need to write the tallies.out file which saves space and time when large meshes are used\n",
"my_settings.output = {'tallies': False}"
Expand Down Expand Up @@ -329,7 +330,7 @@
" # wws.survival_ratio\n",
" # wws.max_lower_bound_ratio\n",
" # wws.weight_cutoff\n",
" # wws.max_splits\n",
" # wws.max_split # controls the total number of maximum splits a particle can do per mesh voxel\n",
"\n",
" # 5 iterations of weight window improvements\n",
" for i in range(5):\n",
Expand All @@ -356,20 +357,6 @@
" )"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "e293ce43",
"metadata": {},
"source": []
},
{
"attachments": {},
"cell_type": "markdown",
"id": "79ec2340",
"metadata": {},
"source": []
},
{
"attachments": {},
"cell_type": "markdown",
Expand Down Expand Up @@ -444,7 +431,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
"my_settings.source = source\n",
"my_settings.particles = 50000\n",
"my_settings.batches = 5\n",
"my_settings.max_splits = 100 # controls the total number of maximum splits a particle can do over the entire lifetime\n",
"\n",
"# the mesh tallies produce large tallies.out files so this output setting avoids writing the tallies.out and saves time\n",
"my_settings.output = {'tallies': False}"
]
Expand Down Expand Up @@ -326,7 +328,7 @@
" # wws.survival_ratio\n",
" # wws.max_lower_bound_ratio\n",
" # wws.weight_cutoff\n",
" # wws.max_splits\n",
" # wws.max_split\n",
" \n",
" # gets a live pointer to the spectra tally that we will plot with each batch\n",
" spectra_tally = openmc.lib.tallies[outer_surface_spectra_tally.id]\n",
Expand Down Expand Up @@ -399,7 +401,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Loading