### Install neutronics-material-maker with Optional Density Features Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/install.rst Installs the neutronics-material-maker package along with additional dependencies (e.g., CoolProp) required for calculating coolant densities. This is an optional installation for extended functionality. ```bash pip install "neutronics_material_maker[density]" ``` -------------------------------- ### Install neutronics-material-maker via Conda (Recommended) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/install.rst Installs the neutronics-material-maker package using Conda from the conda-forge channel. This is the recommended and most straightforward installation method. ```bash conda install -c conda-forge neutronics_material_maker ``` -------------------------------- ### Create Material from Elements (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material.rst This example demonstrates how to instantiate a `neutronics_material_maker.Material` object by specifying a dictionary of elements and their atomic percentages. It sets the material's name, density, density unit, and percentage type. ```python import neutronics_material_maker as nmm my_mat = nmm.Material( name="li_with_si", density=3.0, density_unit="g/cm3", percent_type="ao", elements={ "Li": 4, "Si": 2 } ) ``` -------------------------------- ### Create Material from Isotopes (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material.rst This example shows how to create a `neutronics_material_maker.Material` object using a dictionary of isotopes and their atomic percentages. It defines the material's name, density, density unit, and percentage type. ```python import neutronics_material_maker as nmm my_mat = nmm.Material( name="enriched_li", density= 3.0, density_unit="g/cm3", percent_type="ao", isotopes={ "Li6": 0.9, "Li7": 0.1 } ) ``` -------------------------------- ### Create Material from Dictionary Expansion (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material.rst This example demonstrates how to construct a `neutronics_material_maker.Material` object by unpacking a Python dictionary directly into the constructor using the `**` operator. This allows for flexible material definition from pre-defined configurations. ```python import neutronics_material_maker as nmm my_dict = { "name": "li_with_si", "elements": { "Li": 4, "Si": 2 }, "density": 3.1, "density_unit": "g/cm3", "percent_type": "ao", } my_mat = nmm.Material(**my_dict) ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/install.rst Activates a previously created Conda environment, making its installed packages and Python version available for use in the current shell session. ```bash conda activate new_env ``` -------------------------------- ### Install neutronics-material-maker via Pip (for Conda + Pip method) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/install.rst Installs the neutronics-material-maker package using pip. This step typically follows the OpenMC Conda installation when using the Conda + Pip method. ```bash pip install neutronics-material-maker ``` -------------------------------- ### Access Shift Material Card with Temperature and ID (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Shows how to get the Shift material card, which necessitates providing both `temperature` and `material_id` when creating the material object. These parameters are used by Shift for its simulations. ```python my_mat = nmm.Material.from_library(name='eurofer', temperature=293, material_id=1) my_mat.shift_material ``` -------------------------------- ### Create Material from Isotopes (ZAID) (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material.rst This example illustrates how to define a `neutronics_material_maker.Material` object using isotopes specified by their ZAID (Z*1000 + A) values. It includes the material's name, density, density unit, and percentage type. ```python import neutronics_material_maker as nmm my_mat = nmm.Material( name="enriched_li", density=3.0, density_unit="g/cm3", percent_type="ao", isotopes={ "3006": 0.9, "3007": 0.1 } ) ``` -------------------------------- ### Create New Conda Environment Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/install.rst Creates a new isolated Python environment using Conda with a specified Python version (e.g., 3.8) to manage project dependencies without conflicts. ```bash conda create --name new_env python=3.8 ``` -------------------------------- ### Install OpenMC via Conda (for Conda + Pip method) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/install.rst Installs the OpenMC package using Conda from the conda-forge channel. This is a prerequisite step when opting for the Conda + Pip installation approach for neutronics-material-maker. ```bash conda install -c conda-forge openmc ``` -------------------------------- ### Mixing Two Materials with Material.from_mixture in Python Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_mixture.rst This Python example demonstrates how to create a new material by mixing two existing materials (`eurofer` and `tungsten`) using `neutronics_material_maker.Material.from_mixture`. It specifies volume fractions for each component, and the density of the new material is automatically calculated based on the mixture. ```python import neutronics_material_maker as nmm mat1 = nmm.Material.from_library(name='eurofer') mat2 = nmm.Material.from_library(name='tungsten') mat3 = nmm.Material.from_mixture( name='mixed_eurofer_and_tungsten', materials=[mat1, mat2], fracs=[0.4, 0.6], percent_type='vo' ) ``` -------------------------------- ### Access Fispact Material Card with Volume (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Illustrates how to obtain the Fispact material card, requiring a `volume_in_cm3` parameter during material object creation. This volume is necessary for Fispact's depletion calculations. ```python my_mat = nmm.Material.from_library(name='eurofer', volume_in_cm3=10) my_mat.fispact_material ``` -------------------------------- ### Retrieve Available Materials from Library (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Demonstrates how to list all materials accessible within the `neutronics_material_maker` library using the `AvailableMaterials()` function. This provides a dictionary of material names that can be used with `from_library()`. ```python import neutronics_material_maker as nmm all_materials = nmm.AvailableMaterials() print(all_materials.keys()) ``` -------------------------------- ### Create Basic Material Object from Library (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Illustrates the fundamental usage of `nmm.Material.from_library()` to instantiate a material object, such as 'eurofer', from the internal material collection. This creates a base material object ready for further processing. ```python import neutronics_material_maker as nmm my_mat = nmm.Material.from_library(name='eurofer') ``` -------------------------------- ### Import Custom Materials from JSON File (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst This Python example demonstrates how to import custom material definitions from a local JSON file (e.g., 'mat_lib.json') into the neutronics_material_maker library using the `nmm.AddMaterialFromFile()` function. After import, materials can be instantiated from the library using `nmm.Material.from_library()`. ```python import neutronics_material_maker as nmm nmm.AddMaterialFromFile('mat_lib.json') my_new_material = nmm.Material.from_library(name='my_secret_material') ``` -------------------------------- ### Install Neutronics Material Maker via Pip Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This snippet shows how to install the `neutronics_material_maker` package using pip. Note that OpenMC is not included with this method and must be installed separately. This is a simpler installation for users who manage OpenMC independently. ```bash pip install neutronics_material_maker ``` -------------------------------- ### Install Neutronics Material Maker with CoolProp for Density Calculations Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This snippet illustrates how to install `neutronics_material_maker` using pip, including optional dependencies like CoolProp, which are required for calculating the density of coolants. This enables advanced density adjustment features. ```bash pip install "neutronics_material_maker[density]" ``` -------------------------------- ### Example JSON Structure for Custom Material Definition Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst This JSON snippet illustrates the required format for defining a custom material that can be imported into the neutronics_material_maker library. It includes properties like density, density unit, percent type (e.g., 'ao' for atom percent), and a dictionary of elements with their respective percentages. ```json { "my_secret_material": { "density": 1.0, "percent_type":"ao", "density_unit": "g/cm3", "elements": { "H": 0.2, "C": 0.8 } } } ``` -------------------------------- ### Create Enriched Material with Specific Target (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Demonstrates how to specify a different enrichment target, such as 'Li7', when creating an enriched material. This allows for fine-grained control over the isotopic composition beyond the default enrichment target. ```python import neutronics_material_maker as nmm my_mat2 = nmm.Material.from_library('Li4SiO4', enrichment_target='Li7', enrichment=40) my_mat2.openmc_material ``` -------------------------------- ### Install Neutronics Material Maker via Conda Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This snippet demonstrates how to create a new Conda environment and install the `neutronics_material_maker` package along with its dependencies, including OpenMC, from the `conda-forge` channel. It ensures a self-contained environment for the library. ```bash conda create --name new_env python=3.8 conda activate new_env conda install neutronics_material_maker -c conda-forge ``` -------------------------------- ### Access OpenMC and Serpent Material Cards (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Shows how to retrieve the OpenMC and Serpent material card representations from a previously created material object. These properties provide the material definition in a format suitable for the respective neutronics codes. ```python my_mat.openmc_material my_mat.serpent_material ``` -------------------------------- ### Exporting a Mixed Material to JSON in Python Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_mixture.rst This Python example shows how to serialize and export a newly created mixed material object (`mat3`) to a JSON file. The built-in `json` module is used to dump the material object with pretty-printing (indentation) for readability, allowing it to be retrieved later. ```python import json with open('my_mixed_material.json', 'w') as outfile: json.dump(mat3, outfile, indent=4) ``` -------------------------------- ### Create Temperature and Pressure Dependent Material (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Demonstrates creating a material like H2O where density is adjusted based on provided temperature (in Kelvin) and pressure. The resulting OpenMC material card reflects these properties, with the library handling density calculations. ```python import neutronics_material_maker as nmm my_mat1 = nmm.Material.from_library('H2O', temperature=300, pressure=15e6) my_mat1.openmc_material ``` ```python import neutronics_material_maker as nmm my_mat1 = nmm.Material.from_library('H2O', temperature=573.15, pressure=15e6) my_mat1.openmc_material ``` -------------------------------- ### Access MCNP Material Card with ID (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Demonstrates accessing the MCNP material card, which requires providing a `material_id` during the material object instantiation. This ID is crucial for MCNP input files. ```python my_mat = nmm.Material.from_library(name='eurofer', material_id=1) my_mat.mcnp_material ``` -------------------------------- ### Export Materials to JSON or Other Formats (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst This Python snippet shows how to export one or more `neutronics_material_maker` Material objects to a file. The `nmm.SaveMaterialsToFile()` function allows specifying the output filename, a list of materials, and the desired format, which can be 'json', 'mcnp', 'serpent', 'shift', or 'fispact'. ```python import neutronics_material_maker as nmm my_mat1 = nmm.Material.from_library(name='eurofer', material_id=1) my_mat2 = nmm.Material.from_library(name='Li4SiO4', material_id=1) nmm.SaveMaterialsToFile( filename='my_materials.json', materials=[my_mat1, my_mat2], format='json', ) ``` -------------------------------- ### Create Enriched Material (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Illustrates creating an enriched material, such as 'Li4SiO4', where the density is adjusted based on the specified enrichment percentage (e.g., 60% Li6). The OpenMC material card reflects this enrichment, which is common for breeder blanket applications. ```python import neutronics_material_maker as nmm my_mat2 = nmm.Material.from_library('Li4SiO4', enrichment=60) my_mat2.openmc_material ``` -------------------------------- ### Add Custom Lines to MCNP Material Card (Python) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst Shows how to append additional lines to a generated MCNP material card using the `additional_end_lines` argument. This is useful for adding comments, specific treatment instructions like S(α,β), or other custom text at the end of the material card string. ```python import neutronics_material_maker as nmm my_mat2 = nmm.Material.from_library( name='H2O', material_id=24, temperature=573.15, pressure=15e6, additional_end_lines={'mcnp': ['mt24 lwtr.01']} ) print(my_mat2.mcnp_material) ``` -------------------------------- ### Define Material Card with Additional Line (MCNP-like) Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/example_material_from_library.rst This snippet demonstrates how to define a material card, likely for MCNP or similar neutronics codes, including isotopic compositions and an additional line 'mt24 lwtr.01' at the end. This additional line can be used for specific code inputs or custom material identifiers. ```bash c H2O density 7.25553605e-01 g/cm3 M24 001001 6.66562840e-01 001002 1.03826667e-04 008016 3.32540200e-01 008017 1.26333333e-04 008018 6.66800000e-04 mt24 lwtr.01 ``` -------------------------------- ### Load a Material from the Neutronics Material Maker Library Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This Python snippet demonstrates how to load a predefined material, such as 'eurofer', directly from the internal collection of the `neutronics_material_maker` library using `nmm.Material.from_library()`. This simplifies material creation by leveraging existing, well-defined material data. ```python import neutronics_material_maker as nmm my_mat = nmm.Material.from_library('eurofer') my_mat.openmc_material ``` -------------------------------- ### Material Class API Reference Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/docs/source/material.rst This entry describes the API documentation for the `Material` class, which is automatically generated from its source code using Sphinx's `automodule` directive. It includes all public members (methods and attributes) and shows the class's inheritance hierarchy. ```APIDOC Class: Material Module: neutronics_material_maker.material.Material Description: Represents a material for neutronics simulations. Directives: - :members: (All public members are documented) - :show-inheritance: (Class inheritance hierarchy is displayed) ``` -------------------------------- ### Mix Materials using Material.from_mixture in neutronics_material_maker Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md Shows how to combine multiple materials using the `from_mixture` method, accepting a list of `neutronics_material_maker.Materials` or `openmc.Material` objects along with their material fractions (e.g., volume fractions). ```python import neutronics_material_maker as nmm my_mat1 = nmm.Material.from_library(name='Li4SiO4', packing_fraction=0.64) my_mat2 = nmm.Material.from_library(name='Be12Ti') my_mat3 = nmm.Material.from_mixture(materials=[my_mat1, my_mat2], fracs=[0.4, 0.6], percent_type='vo') my_mat3.openmc_material ``` -------------------------------- ### Create Enriched Material with neutronics_material_maker Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md Demonstrates how to create a material with enriched lithium-6 content using `neutronics_material_maker.Material.from_library`, accounting for density changes due to enrichment. ```python import neutronics_material_maker as nmm my_mat2 = nmm.Material.from_library(name='Li4SiO4', enrichment=60) my_mat2.openmc_material ``` -------------------------------- ### List Available Materials in Neutronics Material Maker Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This Python snippet demonstrates how to access and print the keys of all materials available in the internal collection of the `neutronics_material_maker` library. It uses the `AvailableMaterials()` command to retrieve the dictionary of predefined materials. ```python import neutronics_material_maker as nmm all_materials = nmm.AvailableMaterials() print(all_materials.keys()) ``` -------------------------------- ### Import Custom Material Libraries into neutronics_material_maker Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md Illustrates how to import custom material definitions from a JSON file or a directory of JSON files using `AddMaterialFromFile()` or `AddMaterialFromDir()` to extend the available material library. ```python import neutronics_material_maker as nmm nmm.AddMaterialFromFile('mat_lib.json') nmm.AvailableMaterials() # this will print the new larger list of materials ``` -------------------------------- ### Define a Custom Material with Neutronics Material Maker Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This Python snippet shows how to create a custom material using the `nmm.Material()` constructor. It allows specifying the material's name, isotopic composition, density, percentage type, and density unit. The resulting material object can then be converted to an OpenMC material. ```python import neutronics_material_maker as nmm my_mat = nmm.Material( name='my_custom_material', isotopes={'Li6':0.5, 'Li7':0.5}, density=2.01, percent_type='ao', density_unit='g/cm3' ) my_mat.openmc_material ``` -------------------------------- ### Export neutronics_material_maker Materials to Various Neutronics Codes Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md Demonstrates how to export a material object created with `neutronics_material_maker` to different neutronics simulation codes like OpenMC, MCNP, Serpent, and Fispact, highlighting required properties for each export. ```python import neutronics_material_maker as nmm my_mat = nmm.Materialfrom_library('tungsten') # openmc my_mat.openmc_material # mcnp - required a material_id to be set my_mat.material_id = 1 my_mat.mcnp_material # serpent my_mat.serpent_material # fispact - requires volume to be specified my_mat.volume_in_cm3 = 1 / my_mat.density my_mat.fispact_material ``` -------------------------------- ### Create a Temperature and Pressure Dependent Material Source: https://github.com/fusion-energy/neutronics_material_maker/blob/main/README.md This Python snippet illustrates how to create a material whose density is adjusted based on specified temperature and pressure, using `nmm.Material.from_library()`. This feature is crucial for materials like H2O where density varies significantly with thermodynamic conditions, leveraging internal formulas or CoolProp. ```python import neutronics_material_maker as nmm my_mat1 = nmm.Material.from_library(name='H2O', temperature=600, pressure=15e6) my_mat1.openmc_material ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.