Skip to content

Commit

Permalink
bump version and more type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Feb 24, 2021
1 parent 023524d commit 6e9eee0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions neutronics_material_maker/mutlimaterial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import warnings
from json import JSONEncoder
from typing import List, Optional
from typing import List, Optional, Union

import neutronics_material_maker as nmm
from neutronics_material_maker import (make_fispact_material,
Expand Down Expand Up @@ -80,16 +80,16 @@ class MultiMaterial:
def __init__(
self,
material_tag: Optional[str] = None,
materials: list = [],
materials: List[Union[nmm.Material, openmc.Material]] = [],
fracs: List[float] = [],
percent_type: str = "vo",
percent_type: Optional[str] = "vo",
packing_fraction: float = 1.0,
zaid_suffix: str = None,
material_id: int = None,
decimal_places: int = 8,
volume_in_cm3: float = None,
temperature_in_C: float = None,
temperature_in_K: float = None
zaid_suffix: Optional[str] = None,
material_id: Optional[int] = None,
decimal_places: Optional[int] = 8,
volume_in_cm3: Optional[float] = None,
temperature_in_C: Optional[float] = None,
temperature_in_K: Optional[float] = None
):
self.material_tag = material_tag
self.materials = materials
Expand Down
16 changes: 8 additions & 8 deletions neutronics_material_maker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
.fispact_material not avaiable")


def make_fispact_material(mat):
def make_fispact_material(mat) -> str:
"""
Returns a Fispact material card for the material. This contains the required
keywords (DENSITY and FUEL) and the number of atoms of each isotope in the
Expand Down Expand Up @@ -43,7 +43,7 @@ def make_fispact_material(mat):
return "\n".join(mat_card)


def make_serpent_material(mat):
def make_serpent_material(mat) -> str:
"""Returns the material in a string compatable with Serpent II"""

if mat.material_tag is None:
Expand Down Expand Up @@ -78,7 +78,7 @@ def make_serpent_material(mat):
return "\n".join(mat_card)


def make_mcnp_material(mat):
def make_mcnp_material(mat) -> str:
"""Returns the material in a string compatable with MCNP6"""

if mat.material_id is None:
Expand Down Expand Up @@ -127,22 +127,22 @@ def make_mcnp_material(mat):
return "\n".join(mat_card)


def isotope_to_zaid(isotope):
def isotope_to_zaid(isotope: str) -> str:
"""converts an isotope into a zaid e.g. Li6 -> 003006"""
z, a, m = openmc.data.zam(isotope)
zaid = str(z).zfill(3) + str(a).zfill(3)
return zaid


def zaid_to_isotope(zaid):
def zaid_to_isotope(zaid: str) -> str:
"""converts an isotope into a zaid e.g. 003006 -> Li6"""
a = str(zaid)[-3:]
z = str(zaid)[:-3]
symbol = openmc.data.ATOMIC_SYMBOL[int(z)]
return symbol + str(int(a))


def AddMaterialFromDir(directory, verbose=True):
def AddMaterialFromDir(directory: str, verbose: bool = True):
"""Add materials to the internal library from a directory of json files"""
for filename in Path(directory).rglob("*.json"):
with open(filename, "r") as f:
Expand All @@ -153,7 +153,7 @@ def AddMaterialFromDir(directory, verbose=True):
print(sorted(list(new_data.keys())), "\n")


def AddMaterialFromFile(filename, verbose=True):
def AddMaterialFromFile(filename, verbose=True) -> None:
"""Add materials to the internal library from a json file"""
with open(filename, "r") as f:
new_data = json.load(f)
Expand All @@ -163,7 +163,7 @@ def AddMaterialFromFile(filename, verbose=True):
print(sorted(list(material_dict.keys())))


def AvailableMaterials():
def AvailableMaterials() -> dict:
"""Returns a dictionary of available materials"""
return material_dict

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="neutronics_material_maker",
version="0.1.12",
version="0.1.13",
summary="Package for making material cards for neutronics codes",
author="neutronics_material_maker development team",
author_email="[email protected]",
Expand Down

0 comments on commit 6e9eee0

Please sign in to comment.