From 7b5daa05bf6da797f7eb03270a34e741605bb967 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 11 Aug 2021 17:55:23 +0100 Subject: [PATCH 01/18] using cubit python api --- paramak/make_faceteted_neutronics_model.py | 308 --------------------- paramak/reactor.py | 25 +- paramak/shape.py | 38 ++- paramak/utils.py | 120 -------- 4 files changed, 47 insertions(+), 444 deletions(-) delete mode 100644 paramak/make_faceteted_neutronics_model.py diff --git a/paramak/make_faceteted_neutronics_model.py b/paramak/make_faceteted_neutronics_model.py deleted file mode 100644 index c745b11bc..000000000 --- a/paramak/make_faceteted_neutronics_model.py +++ /dev/null @@ -1,308 +0,0 @@ -#!/usr/env/python3 -import json -import os - -# This script automatically produces DAGMC compatable geometry. A manifest -# file is required that specfies a the stp filenames and the materials names to -# assign. The name of the manifest file is manifest.json by default but can be -# specified using aprepro arguments. Other optional aprepro arguments are -# faceting_tolerance and merge_tolerance which default to 1e-1 and 1e-4 by -# default - -# To using this script with Cubit it can be run in batch mode -# c -batch -nographics make_faceteted_neutronics_model.py - -# With the Cubit GUI -# coreform_cubit make_faceteted_neutronics_model.py - -# With additional arguments to overwrite the defaults -# coreform_cubit -batch -nographics make_faceteted_neutronics_model.py "faceting_tolerance='1e-4'" "merge_tolerance='1e-4'" - -# An example manifest file would contain a list of dictionaries with entries -# having stp_filename and material_tag keywords. Here is an example manifest -# file with just two entries. - -# coreform_cubit -batch -nographics make_faceteted_neutronics_model.py - -# [ -# { -# "material_tag": "copper", -# "stp_filename": "inboard_tf_coils.stp" -# }, -# { -# "material_tag": "tungsten_carbide", -# "stp_filename": "center_column_shield.stp" -# } -# ] - -# The specific name of dictionary key to use for material group names defaults -# to material_tag but can be specified by the user, in this example another -# dictionary key is used (called material_id) which could contain integers and -# therefore make the manifest.json file can contain strings for use with OpenMC -# and integer values to make Cubit group names are compatable with MCNP and -# Shift. - -# coreform_cubit -batch -nographics make_faceteted_neutronics_model.py "material_key_name='material_id'" - -# [ -# { -# "material_id": "1", -# "material_tag": "copper", -# "stp_filename": "inboard_tf_coils.stp" -# }, -# { -# "material_id": "2", -# "material_tag": "tungsten_carbide", -# "stp_filename": "center_column_shield.stp" -# } -# ] - -# You can also change the default dictionary key used for the geometry file. -# By default the code looks for "stp_filename" however the dictionary key can -# be changed using the geometry_key_name argument. For example you could have -# a key name for sat files. - -# coreform_cubit -batch -nographics make_faceteted_neutronics_model.py "geometry_key_name='sat_filename'" - -# entries can also contain a "surface_reflectivity" key to indicate reflecting -# surfaces. This will then be used to automatically tag the surfaces. - -# { -# "material_tag": "m3", -# "stp_filename": "large_cake_slice.stp", -# "surface_reflectivity": true -# } - -# The tag name to use as the reflective boundary identifier can also be -# specified using the surface_reflectivity_name argument. Defaults to -# "reflective" Shift uses "spec.reflect" and MCNP code uses "boundary:Reflecting" - -def find_number_of_volumes_in_each_step_file(input_locations, basefolder): - body_ids = "" - volumes_in_each_step_file = [] - # all_groups=cubit.parse_cubit_list("group","all") - # starting_group_id = len(all_groups) - for entry in input_locations: - # starting_group_id = starting_group_id +1 - current_vols = cubit.parse_cubit_list("volume", "all") - print(os.path.join(basefolder, entry[geometry_key_name])) - if entry[geometry_key_name].endswith(".sat"): - import_type = "acis" - if entry[geometry_key_name].endswith( - ".stp") or entry[geometry_key_name].endswith(".step"): - import_type = "step" - short_file_name = os.path.split(entry[geometry_key_name])[-1] - # print('short_file_name',short_file_name) - # cubit.cmd('import '+import_type+' "' + entry['stp_filename'] + '" separate_bodies no_surfaces no_curves no_vertices group "'+str(short_file_name)+'"') - cubit.cmd( - "import " - + import_type - + ' "' - + os.path.join(basefolder, entry[geometry_key_name]) - + '" separate_bodies no_surfaces no_curves no_vertices ' - ) - all_vols = cubit.parse_cubit_list("volume", "all") - new_vols = set(current_vols).symmetric_difference(set(all_vols)) - new_vols = map(str, new_vols) - print("new_vols", new_vols, type(new_vols)) - current_bodies = cubit.parse_cubit_list("body", "all") - print("current_bodies", current_bodies) - # volumes_in_group = cubit.cmd('volume in group '+str(starting_group_id)) - # print('volumes_in_group',volumes_in_group,type(volumes_in_group)) - if len(new_vols) > 1: - cubit.cmd( - "unite vol " + - " ".join(new_vols) + - " with vol " + - " ".join(new_vols)) - all_vols = cubit.parse_cubit_list("volume", "all") - new_vols_after_unite = set( - current_vols).symmetric_difference(set(all_vols)) - new_vols_after_unite = map(str, new_vols_after_unite) - # cubit.cmd('group '+str(starting_group_id)+' copy rotate 45 about z repeat 7') - entry["volumes"] = new_vols_after_unite - cubit.cmd( - 'group "' + - short_file_name + - '" add volume ' + - " ".join( - entry["volumes"])) - # cubit.cmd('volume in group '+str(starting_group_id)+' copy rotate 45 about z repeat 7') - if 'surface_reflectivity' in entry.keys(): - entry['surface_reflectivity'] = find_all_surfaces_of_reflecting_wedge(new_vols_after_unite) - print("entry['surface_reflectivity']", entry['surface_reflectivity']) - cubit.cmd("separate body all") - return input_locations - - -def find_all_surfaces_of_reflecting_wedge(new_vols): - surfaces_in_volume = cubit.parse_cubit_list("surface", " in volume "+' '.join(new_vols)) - surface_info_dict = {} - for surface_id in surfaces_in_volume: - surface = cubit.surface(surface_id) - #area = surface.area() - vertex_in_surface = cubit.parse_cubit_list("vertex", " in surface " + str(surface_id)) - if surface.is_planar() == True and len(vertex_in_surface) == 4: - surface_info_dict[surface_id] = {'reflector': True} - else: - surface_info_dict[surface_id] = {'reflector': False} - print('surface_info_dict', surface_info_dict) - return surface_info_dict - - -def byteify(input): - if isinstance(input, dict): - return {byteify(key): byteify(value) - for key, value in input.iteritems()} - elif isinstance(input, list): - return [byteify(element) for element in input] - elif isinstance(input, unicode): - return input.encode("utf-8") - else: - return input - - -def find_reflecting_surfaces_of_reflecting_wedge(geometry_details, surface_reflectivity_name): - print('running find_reflecting_surfaces_of_reflecting_wedge') - wedge_volume = None - for entry in geometry_details: - print(entry) - print(entry.keys()) - if 'surface_reflectivity' in entry.keys(): - print('found surface_reflectivity') - surface_info_dict = entry['surface_reflectivity'] - wedge_volume = ' '.join(entry['volumes']) - print('wedge_volume', wedge_volume) - surfaces_in_wedge_volume = cubit.parse_cubit_list("surface", " in volume "+str(wedge_volume)) - print('surfaces_in_wedge_volume', surfaces_in_wedge_volume) - for surface_id in surface_info_dict.keys(): - if surface_info_dict[surface_id]['reflector'] == True: - print(surface_id, 'surface originally reflecting but does it still exist') - if surface_id not in surfaces_in_wedge_volume: - del surface_info_dict[surface_id] - for surface_id in surfaces_in_wedge_volume: - if surface_id not in surface_info_dict.keys(): - surface_info_dict[surface_id] = {'reflector': True} - cubit.cmd('group "' + surface_reflectivity_name + '" add surf ' + str(surface_id)) - cubit.cmd('surface ' + str(surface_id)+' visibility on') - entry['surface_reflectivity'] = surface_info_dict - return geometry_details, wedge_volume - return geometry_details, wedge_volume - - -def tag_geometry_with_mats(geometry_details): - for entry in geometry_details: - if material_key_name in entry.keys(): - cubit.cmd( - 'group "mat:' - + str(entry[material_key_name]) - + '" add volume ' - + " ".join(entry["volumes"]) - ) - else: - print('material_key_name', material_key_name, 'not found for', entry) - - -def imprint_and_merge_geometry(): - cubit.cmd("imprint body all") - print('using merge_tolerance of ', merge_tolerance) - cubit.cmd("merge tolerance " + merge_tolerance) # optional as there is a default - cubit.cmd("merge vol all group_results") - cubit.cmd("graphics tol angle 3") - - -def scale_geometry(geometry_details): - for entry in geometry_details: - if 'scale' in entry.keys(): - cubit.cmd('volume ' + ' '.join(entry['volumes']) + ' scale ' + str(entry['scale'])) - - -def save_output_files(h5m_filename, trelis_filename, cubit_filename, geometry_details_filename): - """This saves the output files""" - cubit.cmd("set attribute on") - # use a faceting_tolerance 1.0e-4 or smaller for accurate simulations - print('using faceting_tolerance of ', faceting_tolerance) - cubit.cmd('export dagmc "'+h5m_filename+'" faceting_tolerance '+ faceting_tolerance) - # os.system('mbconvert -1 '+h5m_filename+' dagmc_not_watertight_edges.h5m') - if cubit_filename is not None: - cubit.cmd('save as "'+cubit_filename+'" overwrite') - if trelis_filename is not None: - cubit.cmd('save as "'+trelis_filename+'" overwrite') - if geometry_details_filename is not None: - with open(geometry_details_filename, "w") as outfile: - json.dump(geometry_details, outfile, indent=4) - -aprepro_vars = cubit.get_aprepro_vars() - -print("Found the following aprepro variables:") -print(aprepro_vars) -for var_name in aprepro_vars: - val = cubit.get_aprepro_value_as_string(var_name) - print("{0} = {1}".format(var_name, val)) - -if "faceting_tolerance" in aprepro_vars: - faceting_tolerance = str(cubit.get_aprepro_value_as_string("faceting_tolerance")) -else: - faceting_tolerance = str(1.0e-1) - -if "merge_tolerance" in aprepro_vars: - merge_tolerance = str(cubit.get_aprepro_value_as_string("merge_tolerance")) -else: - merge_tolerance = str(1e-4) - -if "material_key_name" in aprepro_vars: - material_key_name = str(cubit.get_aprepro_value_as_string("material_key_name")) -else: - material_key_name = "material_tag" - -if "geometry_key_name" in aprepro_vars: - geometry_key_name = str(cubit.get_aprepro_value_as_string("geometry_key_name")) -else: - geometry_key_name = "stp_filename" - -if "h5m_filename" in aprepro_vars: - h5m_filename = str(cubit.get_aprepro_value_as_string("h5m_filename")) -else: - h5m_filename = "dagmc_not_watertight.h5m" - -if "manifest_filename" in aprepro_vars: - manifest_filename = str(cubit.get_aprepro_value_as_string("manifest_filename")) -else: - manifest_filename = "manifest.json" - -if "trelis_filename" in aprepro_vars: - trelis_filename = str(cubit.get_aprepro_value_as_string("trelis_filename")) -else: - trelis_filename = None - -if "cubit_filename" in aprepro_vars: - cubit_filename = str(cubit.get_aprepro_value_as_string("cubit_filename")) -else: - cubit_filename = None - -if "geometry_details_filename" in aprepro_vars: - geometry_details_filename = str(cubit.get_aprepro_value_as_string("geometry_details_filename")) -else: - geometry_details_filename = None - -if "surface_reflectivity_name" in aprepro_vars: - surface_reflectivity_name = str(cubit.get_aprepro_value_as_string("surface_reflectivity_name")) -else: - surface_reflectivity_name = 'reflective' - - -with open(manifest_filename) as f: - geometry_details = byteify(json.load(f)) - -geometry_details = find_number_of_volumes_in_each_step_file( \ - geometry_details, os.path.abspath(".")) - -scale_geometry(geometry_details) - -tag_geometry_with_mats(geometry_details) - -imprint_and_merge_geometry() - -find_reflecting_surfaces_of_reflecting_wedge(geometry_details, surface_reflectivity_name) - -save_output_files(h5m_filename, trelis_filename, cubit_filename, geometry_details_filename) diff --git a/paramak/reactor.py b/paramak/reactor.py index 8b41124de..f4ae6acc9 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -6,6 +6,7 @@ from collections.abc import Iterable from pathlib import Path from typing import List, Optional, Tuple, Union +import cad_to_h5m import cadquery as cq import matplotlib.pyplot as plt @@ -832,12 +833,18 @@ def export_h5m_with_cubit( merge_tolerance: Optional[float] = None, faceting_tolerance: Optional[float] = None, include_plasma: Optional[bool] = False, + cubit_path: Optional[str] = '/opt/Coreform-Cubit-2021.5/bin/' ) -> str: """Produces a dagmc.h5m neutronics file compatable with DAGMC simulations using Coreform cubit. Arguments: filename: filename of h5m outputfile. + cubit_path: the path to Cubit bin folder, this is apped to the + python path so that Cubit can be imported. Defaults to the path + for a Linux installed Cubit 2021.5 but can be changed to suit. + The default path for a Linux install of Cubit 2021.4 would be + '/opt/Coreform-Cubit-2021.5/bin/' merge_tolerance: the allowable distance between edges and surfaces before merging these CAD objects into a single CAD object. See https://svalinn.github.io/DAGMC/usersguide/cubit_basics.html @@ -883,14 +890,20 @@ def export_h5m_with_cubit( 'filename') raise ValueError(msg) - not_watertight_file = paramak.utils.cubit_command_to_create_dagmc_h5m( - faceting_tolerance=faceting_tolerance, merge_tolerance=merge_tolerance) + files_with_tags = self.neutronics_description() - water_tight_h5m_filename = paramak.utils.make_watertight( - input_filename=not_watertight_file[0], - output_filename=filename - ) + for entry in files_with_tags: + # surface_reflectivity feature is unstable + entry.pop("surface_reflectivity", None) + entry['filename'] = entry['stp_filename'] + water_tight_h5m_filename = cad_to_h5m.cad_to_h5m( + files_with_tags=files_with_tags, + h5m_filename=filename, + cubit_path=cubit_path, + faceting_tolerance = faceting_tolerance, + merge_tolerance = merge_tolerance, + ) self.h5m_filename = water_tight_h5m_filename return water_tight_h5m_filename diff --git a/paramak/shape.py b/paramak/shape.py index ef8cf5de8..b2c537b31 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -5,6 +5,7 @@ from collections.abc import Iterable from pathlib import Path from typing import List, Optional, Tuple, Union +import cad_to_h5m from cadquery import exporters, Workplane, Compound, Assembly, Color from cadquery.occ_impl import shapes @@ -1572,13 +1573,21 @@ def export_h5m( def export_h5m_with_cubit( self, + filename: Optional[str] = 'dagmc.h5m', merge_tolerance: Optional[float] = None, faceting_tolerance: Optional[float] = None, + cubit_path: Optional[str] = '/opt/Coreform-Cubit-2021.5/bin/' ): """Produces a dagmc.h5m neutronics file compatable with DAGMC simulations using Coreform cubit. Arguments: + filename: filename of h5m outputfile. + cubit_path: the path to Cubit bin folder, this is apped to the + python path so that Cubit can be imported. Defaults to the path + for a Linux installed Cubit 2021.5 but can be changed to suit. + The default path for a Linux install of Cubit 2021.4 would be + '/opt/Coreform-Cubit-2021.5/bin/' merge_tolerance: the allowable distance between edges and surfaces before merging these CAD objects into a single CAD object. See https://svalinn.github.io/DAGMC/usersguide/cubit_basics.html @@ -1600,25 +1609,27 @@ def export_h5m_with_cubit( faceting_tolerance = self.faceting_tolerance self.export_stp() - self.export_neutronics_description() + files_with_tags = self.neutronics_description() - not_watertight_file = paramak.utils.cubit_command_to_create_dagmc_h5m( - faceting_tolerance=faceting_tolerance, merge_tolerance=merge_tolerance) + files_with_tags['filename'] = files_with_tags['stp_filename'] - water_tight_h5m = paramak.utils.make_watertight( - input_filename=not_watertight_file, - output_filename="dagmc.h5m" + water_tight_h5m_filename = cad_to_h5m.cad_to_h5m( + files_with_tags=[files_with_tags], + h5m_filename=filename, + cubit_path=cubit_path, + faceting_tolerance = faceting_tolerance, + merge_tolerance = merge_tolerance, ) - self.h5m_filename = water_tight_h5m + self.h5m_filename = water_tight_h5m_filename - return water_tight_h5m + return water_tight_h5m_filename def export_h5m_with_pymoab( self, filename: Optional[str] = 'dagmc.h5m', include_graveyard: Optional[bool] = True, - faceting_tolerance: Optional[float] = 0.001, + faceting_tolerance: Optional[float] = None, ) -> str: """Converts stl files into DAGMC compatible h5m file using PyMOAB. The DAGMC file produced has not been imprinted and merged unlike the other @@ -1632,12 +1643,19 @@ def export_h5m_with_pymoab( not. If True the the Reactor.make_graveyard will be called using Reactor.graveyard_size and Reactor.graveyard_offset attribute values. - faceting_tolerance: the precision of the faceting. + faceting_tolerance: the allowable distance between facetets + before merging these CAD objects into a single CAD object See + https://svalinn.github.io/DAGMC/usersguide/cubit_basics.html + for more details. Defaults to None which uses the + Shape.faceting_tolerance attribute. Returns: The filename of the DAGMC file created """ + if faceting_tolerance is None: + faceting_tolerance = self.faceting_tolerance + path_filename = Path(filename) if path_filename.suffix != ".h5m": diff --git a/paramak/utils.py b/paramak/utils.py index 1b1445b68..6210dd958 100644 --- a/paramak/utils.py +++ b/paramak/utils.py @@ -1,7 +1,6 @@ import math import os -import shutil import subprocess from collections.abc import Iterable from hashlib import blake2b @@ -20,125 +19,6 @@ import paramak -def cubit_command_to_create_dagmc_h5m( - faceting_tolerance: float, - merge_tolerance: float, - material_key_name: Optional[str] = 'material_tag', - geometry_key_name: Optional[str] = 'stp_filename', - batch: Optional[bool] = True, - h5m_filename: str = 'dagmc_not_watertight.h5m', - manifest_filename: str = 'manifest.json', - cubit_filename: str = 'dagmc.cub', - trelis_filename: str = 'dagmc.trelis', - geometry_details_filename: str = 'geometry_details.json', - surface_reflectivity_name: str = 'reflective', -) -> List[str]: - """Runs the Trelis executable command with the - make_faceteted_neutronics_model.py script which produces a non water tight - DAGMC h5m file. - - Arguments: - faceting_tolerance: the tolerance to use when faceting surfaces. - merge_tolerance: the tolerance to use when merging surfaces. - material_key_name: the dictionary key containing the str or int to use - as the material identifier. - geometry_key_name: the dictionary key containing the str to uses as the - CAD file identifier. - batch: Run the Cubit command in batch model with no GUI (True) or with - the GUI enabled (False). - h5m_filename: the filename of the DAGMC h5m file produced. This is not - water tight at this stage. - manifest_filename: The filename of the json file containing a list of - material_keys and geometry_keys. - cubit_filename: The output filename of the file. If None then no cubit - file will be exported. - trelis_filename: The output filename of the file. If None then no - trelis file will be exported. - geometry_details_filename: The output filename of the JSON file - containing details of the DAGMC geometry. This includes the - resulting volume numbers of the input CAD files, which can be - useful for specifying tallies. If None then no JSON fie will be - exported. - surface_reflectivity_name: The tag to assign to the reflective boundary - in the resulting DAGMC geometry Shift requires "spec.reflect" and - MCNP requires "boundary:Reflecting". - - Returns: - The filename of the h5m file created - """ - output_filenames = [ - h5m_filename, - trelis_filename, - cubit_filename, - geometry_details_filename] - filenames_extensions = ['.h5m', '.trelis', '.cub', '.json'] - - path_output_filenames = [] - - for output_file, extension in zip(output_filenames, filenames_extensions): - - if output_file is not None: - path_filename = Path(output_file) - - if path_filename.suffix != extension: - path_filename = path_filename.with_suffix(extension) - - path_filename.parents[0].mkdir(parents=True, exist_ok=True) - - path_output_filenames.append(str(path_filename)) - - shutil.copy( - src=Path(__file__).parent.absolute() / - 'make_faceteted_neutronics_model.py', - dst=Path().absolute() - ) - - if not Path("make_faceteted_neutronics_model.py").is_file(): - raise FileNotFoundError( - "The make_faceteted_neutronics_model.py was not found in the \ - directory") - - os.system('rm dagmc_not_watertight.h5m') - - if batch: - cubit_cmd = 'LD_LIBRARY_PATH="" HDF5_DISABLE_VERSION_CHECK=1 coreform_cubit -batch -nographics' - else: - cubit_cmd = 'LD_LIBRARY_PATH="" HDF5_DISABLE_VERSION_CHECK=1 coreform_cubit' - - os.system( - cubit_cmd + - " make_faceteted_neutronics_model.py \"faceting_tolerance='" + - str(faceting_tolerance) + - "'\" \"merge_tolerance='" + - str(merge_tolerance) + - "'\" \"material_key_name='" + - str(material_key_name) + - "'\" \"geometry_key_name='" + - str(geometry_key_name) + - "'\" \"h5m_filename='" + - str(h5m_filename) + - "'\" \"manifest_filename='" + - str(manifest_filename) + - "'\" \"cubit_filename='" + - str(cubit_filename) + - "'\" \"trelis_filename='" + - str(trelis_filename) + - "'\" \"geometry_details_filename='" + - str(geometry_details_filename) + - "'\" \"surface_reflectivity_name='" + - str(surface_reflectivity_name) + - "'\"") - - os.system('rm make_faceteted_neutronics_model.py') - - if not Path(h5m_filename).is_file(): - raise FileNotFoundError( - "The h5m file " + h5m_filename + " was not found \ - in the directory, the Trelis stage has failed") - - return path_output_filenames - - def make_watertight( input_filename: str = "dagmc_not_watertight.h5m", output_filename: str = "dagmc.h5m", From 3a6b3dc2af76334f43d1fa1c8e17530298dd0af5 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 11 Aug 2021 17:57:16 +0100 Subject: [PATCH 02/18] added new cad_h5m as dependancy --- environment.yml | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/environment.yml b/environment.yml index 5c2f65fcd..e6e326bcb 100644 --- a/environment.yml +++ b/environment.yml @@ -21,3 +21,4 @@ dependencies: - sphinxcadquery - defusedxml - jupyter-cadquery + - cad_to_h5m diff --git a/setup.py b/setup.py index ec6d7387f..13f66afad 100644 --- a/setup.py +++ b/setup.py @@ -40,4 +40,5 @@ "plasmaboundaries>=0.1.8", "remove_dagmc_tags>=0.0.5", "jupyter-cadquery>=2.2.0", + "cad_to_h5m>=0.0.1" ]) From 08b355749929a87c04e41b8eea8596c94056fbe0 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 11 Aug 2021 18:07:29 +0100 Subject: [PATCH 03/18] added tests for h5m export --- tests/test_reactor.py | 33 +++++++++++++++++++++++++++++++++ tests/test_shape.py | 16 ++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/test_reactor.py b/tests/test_reactor.py index 0f8a8a46d..7d55e7656 100644 --- a/tests/test_reactor.py +++ b/tests/test_reactor.py @@ -1295,6 +1295,39 @@ def check_correct_error_is_rasied(): self.assertRaises(ValueError, check_correct_error_is_rasied) + def test_cubit_h5m_export(self): + """exports a h5m file using cubit and checks that it has been created""" + + os.system("rm test_dagmc.h5m") + + my_reactor = paramak.BallReactor( + inner_bore_radial_thickness=10, + inboard_tf_leg_radial_thickness=30, + center_column_shield_radial_thickness=60, + divertor_radial_thickness=150, + inner_plasma_gap_radial_thickness=30, + plasma_radial_thickness=300, + outer_plasma_gap_radial_thickness=30, + firstwall_radial_thickness=30, + blanket_radial_thickness=50, + blanket_rear_wall_radial_thickness=30, + elongation=2, + triangularity=0.55, + number_of_tf_coils=16, + rotation_angle=90, + pf_coil_case_thicknesses=[10, 10, 10, 10], + pf_coil_radial_thicknesses=[20, 50, 50, 20], + pf_coil_vertical_thicknesses=[20, 50, 50, 20], + pf_coil_radial_position=[500, 575, 575, 500], + pf_coil_vertical_position=[300, 100, -100, -300], + rear_blanket_to_tf_gap=50, + outboard_tf_coil_radial_thickness=100, + outboard_tf_coil_poloidal_thickness=50 + ) + my_reactor.export_h5m_with_cubit(filename='test_dagmc.h5m') + + assert Path('test_dagmc.h5m').is_file() + if __name__ == "__main__": unittest.main() diff --git a/tests/test_shape.py b/tests/test_shape.py index 716ef1d2a..17c841264 100644 --- a/tests/test_shape.py +++ b/tests/test_shape.py @@ -893,6 +893,22 @@ def test_reuse_points(self): (200, 100), ] + def test_cubit_h5m_export(self): + """exports a h5m file using cubit and checks that it has been created""" + + os.system("rm test_dagmc.h5m") + + my_shape = paramak.Plasma( + major_radius=620, + minor_radius=210, + triangularity=0.33, + elongation=1.85, + rotation_angle=90, + ) + + my_shape.export_h5m_with_cubit(filename='test_dagmc.h5m') + + assert Path('test_dagmc.h5m').is_file() if __name__ == "__main__": unittest.main() From de50f780def2f255be0ceeb15a838a4bbadac80f Mon Sep 17 00:00:00 2001 From: autopep8 Date: Wed, 11 Aug 2021 19:02:42 +0000 Subject: [PATCH 04/18] Automated autopep8 fixes --- paramak/reactor.py | 6 +++--- paramak/shape.py | 6 +++--- setup.py | 3 +-- tests/test_shape.py | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/paramak/reactor.py b/paramak/reactor.py index f4ae6acc9..0a3829f78 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -843,7 +843,7 @@ def export_h5m_with_cubit( cubit_path: the path to Cubit bin folder, this is apped to the python path so that Cubit can be imported. Defaults to the path for a Linux installed Cubit 2021.5 but can be changed to suit. - The default path for a Linux install of Cubit 2021.4 would be + The default path for a Linux install of Cubit 2021.4 would be '/opt/Coreform-Cubit-2021.5/bin/' merge_tolerance: the allowable distance between edges and surfaces before merging these CAD objects into a single CAD object. See @@ -901,8 +901,8 @@ def export_h5m_with_cubit( files_with_tags=files_with_tags, h5m_filename=filename, cubit_path=cubit_path, - faceting_tolerance = faceting_tolerance, - merge_tolerance = merge_tolerance, + faceting_tolerance=faceting_tolerance, + merge_tolerance=merge_tolerance, ) self.h5m_filename = water_tight_h5m_filename diff --git a/paramak/shape.py b/paramak/shape.py index b2c537b31..41feeeb91 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -1586,7 +1586,7 @@ def export_h5m_with_cubit( cubit_path: the path to Cubit bin folder, this is apped to the python path so that Cubit can be imported. Defaults to the path for a Linux installed Cubit 2021.5 but can be changed to suit. - The default path for a Linux install of Cubit 2021.4 would be + The default path for a Linux install of Cubit 2021.4 would be '/opt/Coreform-Cubit-2021.5/bin/' merge_tolerance: the allowable distance between edges and surfaces before merging these CAD objects into a single CAD object. See @@ -1617,8 +1617,8 @@ def export_h5m_with_cubit( files_with_tags=[files_with_tags], h5m_filename=filename, cubit_path=cubit_path, - faceting_tolerance = faceting_tolerance, - merge_tolerance = merge_tolerance, + faceting_tolerance=faceting_tolerance, + merge_tolerance=merge_tolerance, ) self.h5m_filename = water_tight_h5m_filename diff --git a/setup.py b/setup.py index 13f66afad..d694e5ff4 100644 --- a/setup.py +++ b/setup.py @@ -40,5 +40,4 @@ "plasmaboundaries>=0.1.8", "remove_dagmc_tags>=0.0.5", "jupyter-cadquery>=2.2.0", - "cad_to_h5m>=0.0.1" - ]) + "cad_to_h5m>=0.0.1"]) diff --git a/tests/test_shape.py b/tests/test_shape.py index 17c841264..e65ef2514 100644 --- a/tests/test_shape.py +++ b/tests/test_shape.py @@ -910,5 +910,6 @@ def test_cubit_h5m_export(self): assert Path('test_dagmc.h5m').is_file() + if __name__ == "__main__": unittest.main() From 84f55bc89e51fd51b05302d6c9a7796e1d4fd00a Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 12 Aug 2021 00:23:37 +0100 Subject: [PATCH 05/18] added Cubit to Dockerfile used for testing --- Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Dockerfile b/Dockerfile index a502459d3..37f23a7b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,6 +55,29 @@ RUN echo installing CadQuery version $cq_version && \ pip install jupyter-cadquery==2.2.0 && \ conda clean -afy +# Download Cubit +RUN wget -O coreform-cubit-2021.5.deb https://f002.backblazeb2.com/file/cubit-downloads/Coreform-Cubit/Releases/Linux/Coreform-Cubit-2021.5%2B15962_5043ef39-Lin64.deb + +# install Cubit dependencies +RUN apt-get install -y libx11-6 +RUN apt-get install -y libxt6 +RUN apt-get install -y libgl1 +RUN apt-get install -y libglu1-mesa +RUN apt-get install -y libgl1-mesa-glx +RUN apt-get install -y libxcb-icccm4 +RUN apt-get install -y libxcb-image0 +RUN apt-get install -y libxcb-keysyms1 +RUN apt-get install -y libxcb-render-util0 +RUN apt-get install -y libxkbcommon-x11-0 +RUN apt-get install -y libxcb-randr0 +RUN apt-get install -y libxcb-xinerama0 + +# Install cubit +RUN dpkg -i coreform-cubit-2021.5.deb + +# Download Svalinn plugin +RUN wget https://github.com/svalinn/Cubit-plugin/releases/download/v0.0.2/svalinn-plugin_debian-10.10_cubit_2021.5.tgz +RUN tar -xzvf svalinn-plugin_debian-10.10_cubit_2021.5.tgz -C /opt/Coreform-Cubit-2021.5 # dagmc is needed as it includes the make_watertight command and moab # conda install -c conda-forge -c moab # now included with dagmc From 00963c8e6c19697e8e1f56ca72a0036e0d777405 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 13 Aug 2021 15:21:18 +0100 Subject: [PATCH 06/18] moved h5m tests from paramak --- tests/test_h5m_export.py | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/test_h5m_export.py diff --git a/tests/test_h5m_export.py b/tests/test_h5m_export.py new file mode 100644 index 000000000..9810ea7c0 --- /dev/null +++ b/tests/test_h5m_export.py @@ -0,0 +1,88 @@ + +import os +import unittest +from pathlib import Path + +import paramak + + +class TestReactorNeutronics(unittest.TestCase): + + def test_export_h5m(self): + """Creates a Reactor object consisting of two shapes and checks a h5m + file of the reactor can be exported using the export_h5m method.""" + + os.system('rm small_dagmc.h5m') + os.system('rm small_dagmc_without_graveyard.h5m') + os.system('rm small_dagmc_with_graveyard.h5m') + os.system('rm large_dagmc.h5m') + test_shape = paramak.RotateStraightShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat1') + test_shape2 = paramak.RotateSplineShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat2') + test_shape.rotation_angle = 360 + test_reactor = paramak.Reactor([test_shape, test_shape2]) + test_reactor.export_h5m( + filename='small_dagmc.h5m', + faceting_tolerance=0.01 + ) + test_reactor.export_h5m( + filename='small_dagmc_without_graveyard.h5m', + faceting_tolerance=0.01, + include_graveyard=False + ) + test_reactor.export_h5m( + filename='small_dagmc_with_graveyard.h5m', + faceting_tolerance=0.01, + include_graveyard=True + ) + test_reactor.export_h5m( + filename='large_dagmc.h5m', + faceting_tolerance=0.001 + ) + + assert Path("small_dagmc.h5m").exists() is True + assert Path("small_dagmc_with_graveyard.h5m").exists() is True + assert Path("large_dagmc.h5m").exists() is True + assert Path("large_dagmc.h5m").stat().st_size > Path( + "small_dagmc.h5m").stat().st_size + assert Path("small_dagmc_without_graveyard.h5m").stat( + ).st_size < Path("small_dagmc.h5m").stat().st_size + + def test_export_h5m_without_extension(self): + """Tests that the code appends .h5m to the end of the filename""" + + os.system('rm out.h5m') + test_shape = paramak.RotateStraightShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat1') + test_shape2 = paramak.RotateSplineShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat2') + test_shape.rotation_angle = 360 + test_reactor = paramak.Reactor([test_shape, test_shape2]) + test_reactor.export_h5m(filename='out', faceting_tolerance=0.01) + assert Path("out.h5m").exists() is True + os.system('rm out.h5m') + + def test_make_graveyard_accepts_offset_from_graveyard(self): + """Creates a graveyard for a reactor and sets the graveyard_offset. + Checks that the Reactor.graveyard_offset property is set""" + + test_shape = paramak.RotateStraightShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat1') + test_shape2 = paramak.RotateSplineShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat2') + test_shape.rotation_angle = 360 + test_reactor = paramak.Reactor([test_shape, test_shape2]) + test_reactor.graveyard_offset == 101 + graveyard = test_reactor.make_graveyard() + assert graveyard.volume > 0 + + +if __name__ == "__main__": + unittest.main() From 0b2fa8b0d81ef2328496710559dd1d76a0441201 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 13 Aug 2021 15:37:19 +0100 Subject: [PATCH 07/18] moved graveyard test --- tests/test_h5m_export.py | 18 ------------------ tests/test_reactor.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/test_h5m_export.py b/tests/test_h5m_export.py index 9810ea7c0..0595e1da2 100644 --- a/tests/test_h5m_export.py +++ b/tests/test_h5m_export.py @@ -5,7 +5,6 @@ import paramak - class TestReactorNeutronics(unittest.TestCase): def test_export_h5m(self): @@ -67,22 +66,5 @@ def test_export_h5m_without_extension(self): assert Path("out.h5m").exists() is True os.system('rm out.h5m') - def test_make_graveyard_accepts_offset_from_graveyard(self): - """Creates a graveyard for a reactor and sets the graveyard_offset. - Checks that the Reactor.graveyard_offset property is set""" - - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], - material_tag='mat1') - test_shape2 = paramak.RotateSplineShape( - points=[(0, 0), (0, 20), (20, 20)], - material_tag='mat2') - test_shape.rotation_angle = 360 - test_reactor = paramak.Reactor([test_shape, test_shape2]) - test_reactor.graveyard_offset == 101 - graveyard = test_reactor.make_graveyard() - assert graveyard.volume > 0 - - if __name__ == "__main__": unittest.main() diff --git a/tests/test_reactor.py b/tests/test_reactor.py index 7d55e7656..82ffcb42f 100644 --- a/tests/test_reactor.py +++ b/tests/test_reactor.py @@ -518,6 +518,22 @@ def test_stl_filename_None(): ValueError, test_stl_filename_None) + def test_make_graveyard_accepts_offset_from_graveyard(self): + """Creates a graveyard for a reactor and sets the graveyard_offset. + Checks that the Reactor.graveyard_offset property is set""" + + test_shape = paramak.RotateStraightShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat1') + test_shape2 = paramak.RotateSplineShape( + points=[(0, 0), (0, 20), (20, 20)], + material_tag='mat2') + test_shape.rotation_angle = 360 + test_reactor = paramak.Reactor([test_shape, test_shape2]) + test_reactor.graveyard_offset == 101 + graveyard = test_reactor.make_graveyard() + assert graveyard.volume > 0 + def test_reactor_creation_with_default_properties(self): """creates a Reactor object and checks that it has no default properties""" From 52d0c1ebf2f8635cd6ef597c7c4b73aed54f81cd Mon Sep 17 00:00:00 2001 From: autopep8 Date: Fri, 13 Aug 2021 14:38:10 +0000 Subject: [PATCH 08/18] Automated autopep8 fixes --- tests/test_h5m_export.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_h5m_export.py b/tests/test_h5m_export.py index 0595e1da2..faf3288cb 100644 --- a/tests/test_h5m_export.py +++ b/tests/test_h5m_export.py @@ -5,6 +5,7 @@ import paramak + class TestReactorNeutronics(unittest.TestCase): def test_export_h5m(self): @@ -66,5 +67,6 @@ def test_export_h5m_without_extension(self): assert Path("out.h5m").exists() is True os.system('rm out.h5m') + if __name__ == "__main__": unittest.main() From 635ac390cedca431d69f2e57ec940920ae5a7039 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 16 Aug 2021 11:49:38 +0100 Subject: [PATCH 09/18] using tempory release of cubit plugin --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 37f23a7b2..c737ad571 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,10 @@ RUN apt-get install -y libxcb-xinerama0 RUN dpkg -i coreform-cubit-2021.5.deb # Download Svalinn plugin -RUN wget https://github.com/svalinn/Cubit-plugin/releases/download/v0.0.2/svalinn-plugin_debian-10.10_cubit_2021.5.tgz + +# this will be downloaded from the main release when avaialbe +RUN wget https://github.com/Shimwell/Cubit-plugin/releases/download/v0.6.0/svalinn-plugin_debian-10.10_cubit_2021.5.tgz +# RUN wget https://github.com/svalinn/Cubit-plugin/releases/download/v0.0.2/svalinn-plugin_debian-10.10_cubit_2021.5.tgz RUN tar -xzvf svalinn-plugin_debian-10.10_cubit_2021.5.tgz -C /opt/Coreform-Cubit-2021.5 # dagmc is needed as it includes the make_watertight command and moab From e8062cd19e69c348f929a30841089f6bcfd83793 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 16 Aug 2021 11:55:38 +0100 Subject: [PATCH 10/18] added release info change acceptance --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index c737ad571..ed5a3de30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,7 @@ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 \ CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx \ DEBIAN_FRONTEND=noninteractive +RUN apt-get --allow-releaseinfo-change update RUN apt-get update -y && \ apt-get upgrade -y From cf1ba201368aa3c42f0fcb500c4c8d7417d594b9 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 16 Aug 2021 12:42:01 +0100 Subject: [PATCH 11/18] correct tests names with lowercase --- run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 65ec89835..7395250a0 100644 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,8 +1,8 @@ #!/bin/bash pytest tests/test_utils.py -v --cov=paramak --cov-append --cov-report term --cov-report xml -pytest tests/test_Shape.py -v --cov=paramak --cov-append --cov-report term --cov-report xml -pytest tests/test_Reactor.py -v --cov=paramak --cov-append --cov-report term --cov-report xml +pytest tests/test_shape.py -v --cov=paramak --cov-append --cov-report term --cov-report xml +pytest tests/test_reactor.py -v --cov=paramak --cov-append --cov-report term --cov-report xml pytest tests/test_parametric_shapes/ -v --cov=paramak --cov-append --cov-report term --cov-report xml pytest tests/test_parametric_components/ -v --cov=paramak --cov-append --cov-report term --cov-report xml pytest tests/test_parametric_reactors/ -v --cov=paramak --cov-append --cov-report term --cov-report xml From d9212b0ec3029039ad828ffce8e9e357639979eb Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 17 Aug 2021 11:07:58 +0100 Subject: [PATCH 12/18] improved error message for duplicate stl files in reactor --- paramak/reactor.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/paramak/reactor.py b/paramak/reactor.py index 0a3829f78..6713d97ff 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -7,7 +7,7 @@ from pathlib import Path from typing import List, Optional, Tuple, Union import cad_to_h5m - +from collections import Counter import cadquery as cq import matplotlib.pyplot as plt from cadquery import exporters @@ -625,11 +625,10 @@ def export_stl( """ if len(self.stl_filenames) != len(set(self.stl_filenames)): - raise ValueError( - "Set Reactor already contains a shape or component \ - with this stl_filename", - self.stl_filenames, - ) + duplicates = [k for k,v in Counter(self.stl_filenames).items() if v>1] + msg = ("The reactor contains multiple shapes with the same", + f"stl_filename. The duplications are: {duplicates}.", ) + raise ValueError(msg) filenames = [] for entry in self.shapes_and_components: From d16d8b6a5c749514c5916b6abd884ce614ad6318 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 21 Aug 2021 15:11:35 +0100 Subject: [PATCH 13/18] added better error message for missing mat tag --- paramak/reactor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paramak/reactor.py b/paramak/reactor.py index 6713d97ff..f3a95e8c5 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -390,10 +390,10 @@ def neutronics_description( ) if entry.material_tag is None: - raise ValueError( - "set Shape.material_tag for all the \ - Reactor entries before using this method" - ) + msg = (f"Shape with name {entry.name} has no material_tag. Set " + "shape.material_tag for all the shapes in " + "Reactor.shapes_and_components") + raise ValueError(msg) neutronics_description.append(entry.neutronics_description()) From f4eaa3f9be9dbb58cd73dbeafe917cf95a970543 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 21 Aug 2021 16:41:08 +0100 Subject: [PATCH 14/18] added material tag length check --- paramak/reactor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paramak/reactor.py b/paramak/reactor.py index f3a95e8c5..d9a1da030 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -963,6 +963,13 @@ def export_h5m_with_pymoab( entry.export_stl( entry.stl_filename, tolerance=faceting_tolerance) + + if len(entry.material_tag) > 27: + msg = ("Shape.material_tag > 28 characters. Material tags" + "must be less than 28 characters use in DAGMC " + f"{entry.material_tag} is too long.") + raise ValueError(msg) + moab_core = add_stl_to_moab_core( moab_core, surface_id, From feea7fed7dcf9f4ad21e4a7358257cc96514bf10 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 23 Aug 2021 13:32:44 +0000 Subject: [PATCH 15/18] Automated autopep8 fixes --- paramak/reactor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/paramak/reactor.py b/paramak/reactor.py index f3a95e8c5..45e535f26 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -390,9 +390,10 @@ def neutronics_description( ) if entry.material_tag is None: - msg = (f"Shape with name {entry.name} has no material_tag. Set " - "shape.material_tag for all the shapes in " - "Reactor.shapes_and_components") + msg = ( + f"Shape with name {entry.name} has no material_tag. Set " + "shape.material_tag for all the shapes in " + "Reactor.shapes_and_components") raise ValueError(msg) neutronics_description.append(entry.neutronics_description()) @@ -625,7 +626,9 @@ def export_stl( """ if len(self.stl_filenames) != len(set(self.stl_filenames)): - duplicates = [k for k,v in Counter(self.stl_filenames).items() if v>1] + duplicates = [ + k for k, v in Counter( + self.stl_filenames).items() if v > 1] msg = ("The reactor contains multiple shapes with the same", f"stl_filename. The duplications are: {duplicates}.", ) raise ValueError(msg) From b06aaa246b52b485c2cd76d94c7bdd631ccebc95 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 21 Aug 2021 16:52:53 +0100 Subject: [PATCH 16/18] added material check length check to pymoab h5m export --- paramak/reactor.py | 10 +++++----- paramak/shape.py | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/paramak/reactor.py b/paramak/reactor.py index 8f386cc4e..a378fafa6 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -963,16 +963,16 @@ def export_h5m_with_pymoab( paramak.PlasmaBoundaries)) is True or entry.name == 'plasma'): continue - entry.export_stl( - entry.stl_filename, - tolerance=faceting_tolerance) - if len(entry.material_tag) > 27: - msg = ("Shape.material_tag > 28 characters. Material tags" + msg = ("Shape.material_tag > 28 characters. Material tags " "must be less than 28 characters use in DAGMC " f"{entry.material_tag} is too long.") raise ValueError(msg) + entry.export_stl( + entry.stl_filename, + tolerance=faceting_tolerance) + moab_core = add_stl_to_moab_core( moab_core, surface_id, diff --git a/paramak/shape.py b/paramak/shape.py index 41feeeb91..0a489c8ed 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -1661,6 +1661,12 @@ def export_h5m_with_pymoab( if path_filename.suffix != ".h5m": path_filename = path_filename.with_suffix(".h5m") + if len(self.material_tag) > 27: + msg = ("Shape.material_tag > 28 characters. Material tags " + "must be less than 28 characters use in DAGMC " + f"{self.material_tag} is too long.") + raise ValueError(msg) + path_filename.parents[0].mkdir(parents=True, exist_ok=True) self.export_stl(self.stl_filename, tolerance=faceting_tolerance) From 6458aa434048197e02680a0ef97815b8939da37b Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 23 Aug 2021 15:13:58 +0000 Subject: [PATCH 17/18] Automated autopep8 fixes --- paramak/shape.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paramak/shape.py b/paramak/shape.py index 0a489c8ed..79c040288 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -1663,8 +1663,8 @@ def export_h5m_with_pymoab( if len(self.material_tag) > 27: msg = ("Shape.material_tag > 28 characters. Material tags " - "must be less than 28 characters use in DAGMC " - f"{self.material_tag} is too long.") + "must be less than 28 characters use in DAGMC " + f"{self.material_tag} is too long.") raise ValueError(msg) path_filename.parents[0].mkdir(parents=True, exist_ok=True) From 06323a68902d43eb0ca48b96fde679662c1eaa60 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 21 Aug 2021 18:42:44 +0100 Subject: [PATCH 18/18] fixed install license issue for cubit --- Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ed5a3de30..2144b5fbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,13 +76,17 @@ RUN apt-get install -y libxcb-xinerama0 # Install cubit RUN dpkg -i coreform-cubit-2021.5.deb -# Download Svalinn plugin - -# this will be downloaded from the main release when avaialbe -RUN wget https://github.com/Shimwell/Cubit-plugin/releases/download/v0.6.0/svalinn-plugin_debian-10.10_cubit_2021.5.tgz -# RUN wget https://github.com/svalinn/Cubit-plugin/releases/download/v0.0.2/svalinn-plugin_debian-10.10_cubit_2021.5.tgz +# installs svalinn plugin for cubit +RUN wget https://github.com/svalinn/Cubit-plugin/releases/download/0.2.1/svalinn-plugin_debian-10.10_cubit_2021.5.tgz RUN tar -xzvf svalinn-plugin_debian-10.10_cubit_2021.5.tgz -C /opt/Coreform-Cubit-2021.5 +# writes a non commercial license file +RUN mkdir -p /root/.config/Coreform/licenses +RUN printf 'Fri May 28 2021' >> /root/.config/Coreform/licenses/cubit-learn.lic + +# helps to identify Cubit related errrors +ENV CUBIT_VERBOSE=5 + # dagmc is needed as it includes the make_watertight command and moab # conda install -c conda-forge -c moab # now included with dagmc RUN conda install -c conda-forge dagmc && \