-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from fusion-energy/separate_tests_for_h5m_crea…
…tion_and_transport refactoring to decrease repetition
- Loading branch information
Showing
35 changed files
with
341 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,30 @@ | ||
|
||
class Circulartorus: | ||
def __init__(self, materials, major_radius=10, minor_radius=1): | ||
self.materials = materials | ||
from .utils import BaseCommonGeometryObject | ||
class Circulartorus(BaseCommonGeometryObject): | ||
def __init__(self, major_radius=10, minor_radius=1): | ||
self.major_radius = major_radius | ||
self.minor_radius = minor_radius | ||
|
||
def csg_model(self): | ||
def csg_model(self, materials): | ||
import openmc | ||
|
||
surface = openmc.ZTorus(a=self.major_radius, b=self.minor_radius, c=self.minor_radius, boundary_type="vacuum") | ||
|
||
surface = openmc.ZTorus( | ||
a=self.major_radius, | ||
b=self.minor_radius, | ||
c=self.minor_radius, | ||
boundary_type="vacuum" | ||
) | ||
region = -surface | ||
cell = openmc.Cell(region=region) | ||
cell.fill = self.materials[0] | ||
cell.fill = materials[0] | ||
geometry = openmc.Geometry([cell]) | ||
materials = openmc.Materials([self.materials[0]]) | ||
model = openmc.Model(geometry=geometry, materials=materials) | ||
my_materials = openmc.Materials(materials) | ||
model = openmc.Model(geometry=geometry, materials=my_materials) | ||
return model | ||
|
||
def cadquery_assembly(self): | ||
import cadquery as cq | ||
|
||
assembly = cq.Assembly(name="circulartorus") | ||
circulartorus = cq.Solid.makeTorus(self.major_radius, self.minor_radius) | ||
assembly.add(circulartorus) | ||
return assembly | ||
|
||
def export_stp_file(self, filename="circulartorus.step"): | ||
self.cadquery_assembly().save(filename, "STEP") | ||
|
||
def dagmc_model(self, filename="circulartorus.h5m", min_mesh_size=0.1, max_mesh_size=100.0): | ||
from cad_to_dagmc import CadToDagmc | ||
import openmc | ||
|
||
assembly = self.cadquery_assembly() | ||
ctd = CadToDagmc() | ||
material_tags = [self.materials[0].name] | ||
ctd.add_cadquery_object(assembly, material_tags=material_tags) | ||
ctd.export_dagmc_h5m_file( | ||
filename, | ||
min_mesh_size=min_mesh_size, | ||
max_mesh_size=max_mesh_size | ||
) | ||
universe = openmc.DAGMCUniverse(filename).bounded_universe() | ||
materials = openmc.Materials([self.materials[0]]) | ||
geometry = openmc.Geometry(universe) | ||
|
||
model = openmc.Model(geometry=geometry, materials=materials) | ||
return model | ||
|
||
def dagmc_model_with_cad_to_openmc(self, filename="circulartorus.h5m"): | ||
from CAD_to_OpenMC import assembly | ||
import openmc | ||
|
||
self.export_stp_file() | ||
|
||
a=assembly.Assembly(["circulartorus.step"]) | ||
a.verbose=1 | ||
assembly.mesher_config['threads']=1 | ||
a.run( | ||
backend='stl2', | ||
merge=True, | ||
h5m_filename=filename, | ||
sequential_tags=[self.materials[0].name], | ||
scale=1.0 | ||
) | ||
|
||
universe = openmc.DAGMCUniverse(filename, auto_geom_ids=True).bounded_universe() | ||
geometry = openmc.Geometry(universe) | ||
model = openmc.Model(geometry=geometry) | ||
return model | ||
return assembly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.