mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Merge pull request #2464 from shimwell/moving_voxel_plot_code
moved voxel plot to api accessible function
This commit is contained in:
commit
6dde8af940
4 changed files with 162 additions and 63 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from pathlib import Path
|
||||
|
||||
import openmc
|
||||
import openmc.examples
|
||||
import pytest
|
||||
|
|
@ -37,6 +39,7 @@ def myplot():
|
|||
}
|
||||
return plot
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def myprojectionplot():
|
||||
plot = openmc.ProjectionPlot(name='myprojectionplot')
|
||||
|
|
@ -66,6 +69,35 @@ def myprojectionplot():
|
|||
return plot
|
||||
|
||||
|
||||
def test_voxel_plot(run_in_tmpdir):
|
||||
surf1 = openmc.Sphere(r=500, boundary_type='vacuum')
|
||||
cell1 = openmc.Cell(region=-surf1)
|
||||
geometry = openmc.Geometry([cell1])
|
||||
geometry.export_to_xml()
|
||||
materials = openmc.Materials()
|
||||
materials.export_to_xml()
|
||||
vox_plot = openmc.Plot()
|
||||
vox_plot.type = 'voxel'
|
||||
vox_plot.id = 12
|
||||
vox_plot.width = (1500., 1500., 1500.)
|
||||
vox_plot.pixels = (200, 200, 200)
|
||||
vox_plot.color_by = 'cell'
|
||||
vox_plot.to_vtk('test_voxel_plot.vti')
|
||||
|
||||
assert Path('plot_12.h5').is_file()
|
||||
assert Path('test_voxel_plot.vti').is_file()
|
||||
|
||||
vox_plot.filename = 'h5_voxel_plot'
|
||||
vox_plot.to_vtk('another_test_voxel_plot.vti')
|
||||
|
||||
assert Path('h5_voxel_plot.h5').is_file()
|
||||
assert Path('another_test_voxel_plot.vti').is_file()
|
||||
|
||||
slice_plot = openmc.Plot()
|
||||
with pytest.raises(ValueError):
|
||||
slice_plot.to_vtk('shimmy.vti')
|
||||
|
||||
|
||||
def test_attributes(myplot):
|
||||
assert myplot.name == 'myplot'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue