From 66c211ac4bc7f5b1775f1c1fd79e309a6d329f68 Mon Sep 17 00:00:00 2001 From: daquintero Date: Sun, 31 Mar 2024 23:01:33 +0200 Subject: [PATCH 1/2] FEAT: Refactor on the materials --- materials/electrical_resistivity/__init__.py | 0 materials/electrical_resistivity/index.py | 0 materials/thermal_conductivity/__init__.py | 0 materials/thermal_conductivity/index.py | 0 piel/__init__.py | 1 + piel/cli/environment/nix.py | 2 +- piel/file_conversion.py | 6 +- piel/file_system.py | 84 +++++++------- piel/integration/amaranth_openlane.py | 8 +- piel/integration/gdsfactory_openlane.py | 6 +- {materials => piel/materials}/README.md | 0 piel/materials/__init__.py | 2 + .../electrical_resistivity/README.md | 0 .../electrical_resistivity}/__init__.py | 0 .../electrical_resistivity/data}/copper.csv | 0 .../electrical_resistivity/data}/silver.csv | 0 {materials => piel/materials}/silicon.py | 0 .../materials}/thermal_conductivity/README.md | 0 .../thermal_conductivity/__init__.py | 4 + .../thermal_conductivity/aluminum.py | 28 +++++ piel/materials/thermal_conductivity/copper.py | 107 ++++++++++++++++++ .../data}/amorphous_silicon.csv | 0 .../data}/crystalline_silicon.csv | 0 .../data}/ofhc_copper_nist.xlsx | Bin .../ofhc_copper_thermal_conductivity.csv | 0 .../data}/vitrous_silica.csv | 0 .../thermal_conductivity/stainless_steel.py | 53 +++++++++ piel/materials/thermal_conductivity/teflon.py | 28 +++++ piel/models/physical/geometry.py | 24 +++- piel/models/physical/thermal.py | 23 +++- piel/project_structure.py | 18 +-- piel/tools/amaranth/export.py | 6 +- piel/tools/amaranth/verify.py | 4 +- piel/tools/cocotb/data.py | 10 +- piel/tools/hdl21/simulator.py | 10 +- piel/tools/openlane/utils.py | 20 ++-- piel/tools/openlane/v1.py | 4 +- piel/tools/openlane/v2.py | 14 +-- piel/types.py | 8 +- pyproject.toml | 9 ++ 40 files changed, 377 insertions(+), 102 deletions(-) delete mode 100644 materials/electrical_resistivity/__init__.py delete mode 100644 materials/electrical_resistivity/index.py delete mode 100644 materials/thermal_conductivity/__init__.py delete mode 100644 materials/thermal_conductivity/index.py rename {materials => piel/materials}/README.md (100%) create mode 100644 piel/materials/__init__.py rename {materials => piel/materials}/electrical_resistivity/README.md (100%) rename {materials => piel/materials/electrical_resistivity}/__init__.py (100%) rename {materials/electrical_resistivity => piel/materials/electrical_resistivity/data}/copper.csv (100%) rename {materials/electrical_resistivity => piel/materials/electrical_resistivity/data}/silver.csv (100%) rename {materials => piel/materials}/silicon.py (100%) rename {materials => piel/materials}/thermal_conductivity/README.md (100%) create mode 100644 piel/materials/thermal_conductivity/__init__.py create mode 100644 piel/materials/thermal_conductivity/aluminum.py create mode 100644 piel/materials/thermal_conductivity/copper.py rename {materials/thermal_conductivity => piel/materials/thermal_conductivity/data}/amorphous_silicon.csv (100%) rename {materials/thermal_conductivity => piel/materials/thermal_conductivity/data}/crystalline_silicon.csv (100%) rename {materials/thermal_conductivity => piel/materials/thermal_conductivity/data}/ofhc_copper_nist.xlsx (100%) rename {materials/thermal_conductivity => piel/materials/thermal_conductivity/data}/ofhc_copper_thermal_conductivity.csv (100%) rename {materials/thermal_conductivity => piel/materials/thermal_conductivity/data}/vitrous_silica.csv (100%) create mode 100644 piel/materials/thermal_conductivity/stainless_steel.py create mode 100644 piel/materials/thermal_conductivity/teflon.py diff --git a/materials/electrical_resistivity/__init__.py b/materials/electrical_resistivity/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/materials/electrical_resistivity/index.py b/materials/electrical_resistivity/index.py deleted file mode 100644 index e69de29b..00000000 diff --git a/materials/thermal_conductivity/__init__.py b/materials/thermal_conductivity/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/materials/thermal_conductivity/index.py b/materials/thermal_conductivity/index.py deleted file mode 100644 index e69de29b..00000000 diff --git a/piel/__init__.py b/piel/__init__.py index bb5fe770..b9b84f25 100644 --- a/piel/__init__.py +++ b/piel/__init__.py @@ -5,6 +5,7 @@ # Libraries from piel import models # NOQA: F401 from piel import visual # NOQA: F401 +from piel import materials # NOQA: F401 # Functions diff --git a/piel/cli/environment/nix.py b/piel/cli/environment/nix.py index e8447d9d..745ebf2f 100644 --- a/piel/cli/environment/nix.py +++ b/piel/cli/environment/nix.py @@ -74,7 +74,7 @@ def install_and_configure_nix(): def update_openlane_directory( - directory: piel.piel_path_types = default_openlane2_directory, + directory: piel.PathTypes = default_openlane2_directory, branch: str = "main", ): """ diff --git a/piel/file_conversion.py b/piel/file_conversion.py index 03f7781b..0557f605 100644 --- a/piel/file_conversion.py +++ b/piel/file_conversion.py @@ -1,6 +1,6 @@ import pandas as pd from .file_system import return_path -from .types import piel_path_types +from .types import PathTypes __all__ = [ "read_csv_to_pandas", @@ -8,7 +8,7 @@ ] -def read_csv_to_pandas(file_path: piel_path_types): +def read_csv_to_pandas(file_path: PathTypes): """ This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. """ @@ -17,7 +17,7 @@ def read_csv_to_pandas(file_path: piel_path_types): return simulation_data -def read_vcd_to_json(file_path: piel_path_types): +def read_vcd_to_json(file_path: PathTypes): from pyDigitalWaveTools.vcd.parser import VcdParser file_path = return_path(file_path) diff --git a/piel/file_system.py b/piel/file_system.py index f31b4618..46ba1f50 100644 --- a/piel/file_system.py +++ b/piel/file_system.py @@ -10,7 +10,7 @@ import subprocess import types from typing import Literal, Optional -from .types import piel_path_types +from .types import PathTypes __all__ = [ "check_path_exists", @@ -39,14 +39,14 @@ def check_path_exists( - path: piel_path_types, + path: PathTypes, raise_errors: bool = False, ) -> bool: """ Checks if a directory exists. Args: - path(piel_path_types): Input path. + path(PathTypes): Input path. Returns: directory_exists(bool): True if directory exists. @@ -63,14 +63,14 @@ def check_path_exists( def check_example_design( design_name: str = "simple_design", - designs_directory: piel_path_types | None = None, + designs_directory: PathTypes | None = None, ) -> bool: """ We copy the example simple_design from docs to the `/foss/designs` in the `iic-osic-tools` environment. Args: design_name(str): Name of the design to check. - designs_directory(piel_path_types): Directory that contains the DESIGNS environment flag. + designs_directory(PathTypes): Directory that contains the DESIGNS environment flag. # TODO Returns: @@ -86,15 +86,15 @@ def check_example_design( def copy_source_folder( - source_directory: piel_path_types, - target_directory: piel_path_types, + source_directory: PathTypes, + target_directory: PathTypes, ) -> None: """ Copies the files from a source_directory to a target_directory Args: - source_directory(piel_path_types): Source directory. - target_directory(piel_path_types): Target directory. + source_directory(PathTypes): Source directory. + target_directory(PathTypes): Target directory. Returns: None @@ -127,7 +127,7 @@ def copy_source_folder( def copy_example_design( project_source: Literal["piel", "openlane"] = "piel", example_name: str = "simple_design", - target_directory: piel_path_types = None, + target_directory: PathTypes = None, target_project_name: Optional[str] = None, ) -> None: """ @@ -136,7 +136,7 @@ def copy_example_design( Args: project_source(str): Source of the project. example_name(str): Name of the example design. - target_directory(piel_path_types): Target directory. + target_directory(PathTypes): Target directory. target_project_name(str): Name of the target project. Returns: @@ -184,13 +184,13 @@ def copy_example_design( def convert_list_to_path_list( - input_list: list[piel_path_types], + input_list: list[PathTypes], ) -> list[pathlib.Path]: """ Converts a list of strings or pathlib.Path to a list of pathlib.Path. Args: - input_list(list[piel_path_types]): Input list. + input_list(list[PathTypes]): Input list. Returns: output_list(list[pathlib.Path]): Output list. @@ -270,7 +270,7 @@ def delete_path(path: str | pathlib.Path) -> None: def delete_path_list_in_directory( - directory_path: piel_path_types, + directory_path: PathTypes, path_list: list, ignore_confirmation: bool = False, validate_individual: bool = False, @@ -287,7 +287,7 @@ def delete_path_list_in_directory( ``` Args: - directory_path(piel_path_types): Input path. + directory_path(PathTypes): Input path. path_list(list): List of files. ignore_confirmation(bool): Ignore confirmation. Default: False. validate_individual(bool): Validate individual files. Default: False. @@ -326,7 +326,7 @@ def delete_path_list_in_directory( def get_files_recursively_in_directory( - path: piel_path_types, + path: PathTypes, extension: str = "*", ): """ @@ -337,7 +337,7 @@ def get_files_recursively_in_directory( get_files_recursively_in_directory('path/to/directory', 'extension') Args: - path(piel_path_types): Input path. + path(PathTypes): Input path. extension(str): File extension. Returns: @@ -352,7 +352,7 @@ def get_files_recursively_in_directory( def get_id_map_directory_dictionary( - path_list: list[piel_path_types], target_prefix: str + path_list: list[PathTypes], target_prefix: str ): """ Returns a dictionary of ids to directories. @@ -362,7 +362,7 @@ def get_id_map_directory_dictionary( get_id_to_directory_dictionary(path_list, target_prefix) Args: - path_list(list[piel_path_types]): List of paths. + path_list(list[PathTypes]): List of paths. target_prefix(str): Target prefix. Returns: @@ -419,7 +419,7 @@ def get_top_level_script_directory() -> pathlib.Path: def list_prefix_match_directories( - output_directory: piel_path_types, + output_directory: PathTypes, target_prefix: str, ): """ @@ -430,7 +430,7 @@ def list_prefix_match_directories( list_prefix_match_directories('path/to/directory', 'prefix') Args: - output_directory(piel_path_types): Output directory. + output_directory(PathTypes): Output directory. target_prefix(str): Target prefix. Returns: @@ -447,7 +447,7 @@ def list_prefix_match_directories( return matching_directories -def permit_script_execution(script_path: piel_path_types) -> None: +def permit_script_execution(script_path: PathTypes) -> None: """ Permits the execution of a script. @@ -456,7 +456,7 @@ def permit_script_execution(script_path: piel_path_types) -> None: permit_script_execution('path/to/script') Args: - script_path(piel_path_types): Script path. + script_path(PathTypes): Script path. Returns: None @@ -465,7 +465,7 @@ def permit_script_execution(script_path: piel_path_types) -> None: script.chmod(script.stat().st_mode | stat.S_IEXEC) -def permit_directory_all(directory_path: piel_path_types) -> None: +def permit_directory_all(directory_path: PathTypes) -> None: """ Permits a directory to be read, written and executed. Use with care as it can be a source for security issues. @@ -474,7 +474,7 @@ def permit_directory_all(directory_path: piel_path_types) -> None: permit_directory_all('path/to/directory') Args: - directory_path(piel_path_types): Input path. + directory_path(PathTypes): Input path. Returns: None @@ -492,7 +492,7 @@ def permit_directory_all(directory_path: piel_path_types) -> None: ) -def read_json(path: piel_path_types) -> dict: +def read_json(path: PathTypes) -> dict: """ Reads a JSON file. @@ -501,7 +501,7 @@ def read_json(path: piel_path_types) -> dict: read_json('path/to/file.json') Args: - path(piel_path_types): Input path. + path(PathTypes): Input path. Returns: json_data(dict): JSON data. @@ -513,8 +513,8 @@ def read_json(path: piel_path_types) -> dict: def rename_file( - match_file_path: piel_path_types, - renamed_file_path: piel_path_types, + match_file_path: PathTypes, + renamed_file_path: PathTypes, ) -> None: """ Renames a file. @@ -524,8 +524,8 @@ def rename_file( rename_file('path/to/match_file', 'path/to/renamed_file') Args: - match_file_path(piel_path_types): Input path. - renamed_file_path(piel_path_types): Input path. + match_file_path(PathTypes): Input path. + renamed_file_path(PathTypes): Input path. Returns: None @@ -536,7 +536,7 @@ def rename_file( def rename_files_in_directory( - target_directory: piel_path_types, + target_directory: PathTypes, match_string: str, renamed_string: str, ) -> None: @@ -548,7 +548,7 @@ def rename_files_in_directory( rename_files_in_directory('path/to/directory', 'match_string', 'renamed_string') Args: - target_directory(piel_path_types): Input path. + target_directory(PathTypes): Input path. match_string(str): String to match. renamed_string(str): String to replace. @@ -564,7 +564,7 @@ def rename_files_in_directory( def replace_string_in_file( - file_path: piel_path_types, + file_path: PathTypes, match_string: str, replace_string: str, ): @@ -576,7 +576,7 @@ def replace_string_in_file( replace_string_in_file('path/to/file', 'match_string', 'replace_string') Args: - file_path(piel_path_types): Input path. + file_path(PathTypes): Input path. match_string(str): String to match. replace_string(str): String to replace. @@ -598,7 +598,7 @@ def replace_string_in_file( def replace_string_in_directory_files( - target_directory: piel_path_types, + target_directory: PathTypes, match_string: str, replace_string: str, ): @@ -610,7 +610,7 @@ def replace_string_in_directory_files( replace_string_in_directory_files('path/to/directory', 'match_string', 'replace_string') Args: - target_directory(piel_path_types): Input path. + target_directory(PathTypes): Input path. match_string(str): String to match. replace_string(str): String to replace. @@ -624,7 +624,7 @@ def replace_string_in_directory_files( def return_path( - input_path: piel_path_types, + input_path: PathTypes, as_piel_module: bool = False, ) -> pathlib.Path: """ @@ -697,12 +697,12 @@ def treat_as_module(input_path_i: pathlib.Path): return output_path -def run_script(script_path: piel_path_types) -> None: +def run_script(script_path: PathTypes) -> None: """ Runs a script on the filesystem `script_path`. Args: - script_path(piel_path_types): Script path. + script_path(PathTypes): Script path. Returns: None @@ -712,7 +712,7 @@ def run_script(script_path: piel_path_types) -> None: def write_file( - directory_path: piel_path_types, + directory_path: PathTypes, file_text: str, file_name: str, ) -> None: @@ -720,7 +720,7 @@ def write_file( Records a `script_name` in the `scripts` project directory. Args: - directory_path(piel_path_types): Design directory. + directory_path(PathTypes): Design directory. file_text(str): Script to write. file_name(str): Name of the script. diff --git a/piel/integration/amaranth_openlane.py b/piel/integration/amaranth_openlane.py index ee64b5e9..7613e683 100644 --- a/piel/integration/amaranth_openlane.py +++ b/piel/integration/amaranth_openlane.py @@ -16,7 +16,7 @@ test_basic_open_lane_configuration_v1, test_basic_open_lane_configuration_v2, ) -from ..types import piel_path_types +from ..types import PathTypes __all__ = ["layout_amaranth_truth_table_through_openlane"] @@ -25,7 +25,7 @@ def layout_openlane_from_truth_table( truth_table: dict, inputs: list[str], outputs: list[str], - parent_directory: piel_path_types, + parent_directory: PathTypes, target_directory_name: Optional[str] = None, openlane_version: Literal["v1", "v2"] = "v2", **kwargs @@ -48,7 +48,7 @@ def layout_amaranth_truth_table_through_openlane( amaranth_module: am.Module, inputs_name_list: list[str], outputs_name_list: list[str], - parent_directory: piel_path_types, + parent_directory: PathTypes, target_directory_name: Optional[str] = None, openlane_version: Literal["v1", "v2"] = "v2", **kwargs @@ -71,7 +71,7 @@ def layout_amaranth_truth_table_through_openlane( amaranth_module (amaranth.Module): Amaranth module class. inputs_name_list (list[str]): List of input names. outputs_name_list (list[str]): List of output names. - parent_directory (piel_path_types): Parent directory PATH. + parent_directory (PathTypes): Parent directory PATH. target_directory_name (Optional[str]): Target directory name. If none is provided, it will default to the name of the amaranth elaboratable class. openlane_version (Literal["v1", "v2"]): OpenLane version. Defaults to ``v1``. diff --git a/piel/integration/gdsfactory_openlane.py b/piel/integration/gdsfactory_openlane.py index fbc5bc73..542b480e 100644 --- a/piel/integration/gdsfactory_openlane.py +++ b/piel/integration/gdsfactory_openlane.py @@ -6,7 +6,7 @@ * GF180nm https://gdsfactory.github.io/gf180/ """ import gdsfactory as gf -from ..types import piel_path_types +from ..types import PathTypes from ..file_system import check_path_exists from piel.tools.openlane.migrate import get_design_from_openlane_migration from piel.tools.openlane import find_latest_design_run, get_gds_path_from_design_run @@ -16,7 +16,7 @@ def create_gdsfactory_component_from_openlane( design_name_v1: str | None = None, - design_directory: piel_path_types | None = None, + design_directory: PathTypes | None = None, run_name: str | None = None, v1: bool = True, ) -> gf.Component: @@ -27,7 +27,7 @@ def create_gdsfactory_component_from_openlane( Args: design_name_v1(str): Design name of the v1 design that can be found within `$OPENLANE_ROOT/""/designs`. - design_directory(piel_path_types): Design directory PATH. + design_directory(PathTypes): Design directory PATH. run_name(str): Name of the run to extract the GDS from. If None, it will look at the latest run. v1(bool): If True, it will import the design from the OpenLane v1 configuration. diff --git a/materials/README.md b/piel/materials/README.md similarity index 100% rename from materials/README.md rename to piel/materials/README.md diff --git a/piel/materials/__init__.py b/piel/materials/__init__.py new file mode 100644 index 00000000..b5ed743b --- /dev/null +++ b/piel/materials/__init__.py @@ -0,0 +1,2 @@ +from . import thermal_conductivity +from . import electrical_resistivity diff --git a/materials/electrical_resistivity/README.md b/piel/materials/electrical_resistivity/README.md similarity index 100% rename from materials/electrical_resistivity/README.md rename to piel/materials/electrical_resistivity/README.md diff --git a/materials/__init__.py b/piel/materials/electrical_resistivity/__init__.py similarity index 100% rename from materials/__init__.py rename to piel/materials/electrical_resistivity/__init__.py diff --git a/materials/electrical_resistivity/copper.csv b/piel/materials/electrical_resistivity/data/copper.csv similarity index 100% rename from materials/electrical_resistivity/copper.csv rename to piel/materials/electrical_resistivity/data/copper.csv diff --git a/materials/electrical_resistivity/silver.csv b/piel/materials/electrical_resistivity/data/silver.csv similarity index 100% rename from materials/electrical_resistivity/silver.csv rename to piel/materials/electrical_resistivity/data/silver.csv diff --git a/materials/silicon.py b/piel/materials/silicon.py similarity index 100% rename from materials/silicon.py rename to piel/materials/silicon.py diff --git a/materials/thermal_conductivity/README.md b/piel/materials/thermal_conductivity/README.md similarity index 100% rename from materials/thermal_conductivity/README.md rename to piel/materials/thermal_conductivity/README.md diff --git a/piel/materials/thermal_conductivity/__init__.py b/piel/materials/thermal_conductivity/__init__.py new file mode 100644 index 00000000..09535f77 --- /dev/null +++ b/piel/materials/thermal_conductivity/__init__.py @@ -0,0 +1,4 @@ +from .stainless_steel import stainless_steel +from .aluminum import aluminum +from .copper import copper +from .teflon import teflon diff --git a/piel/materials/thermal_conductivity/aluminum.py b/piel/materials/thermal_conductivity/aluminum.py new file mode 100644 index 00000000..8984c595 --- /dev/null +++ b/piel/materials/thermal_conductivity/aluminum.py @@ -0,0 +1,28 @@ +from typing import Literal +import jax.numpy as jnp +from piel.types import ArrayTypes + +supported_specifications = Literal["1100"] + +__all__ = ["aluminum"] + + +def aluminum( + temperature_range_K: ArrayTypes, + specification: supported_specifications = "1100" +) -> float: + if specification == "1100": + thermal_conductivity_fit = jnp.power(10, + 23.39172 + - 148.5733 * (jnp.log10(temperature_range_K)) + + 422.1917 * (jnp.log10(temperature_range_K) ** 2) + - 653.6664 * (jnp.log10(temperature_range_K) ** 3) + + 607.0402 * (jnp.log10(temperature_range_K) ** 4) + - 346.152 * (jnp.log10(temperature_range_K) ** 5) + + 118.4276 * (jnp.log10(temperature_range_K) ** 6) + - 22.2781 * (jnp.log10(temperature_range_K) ** 7) + + 1.770187 * (jnp.log10(temperature_range_K) ** 8)) + else: + raise ValueError("Invalid specification: " + specification) + + return thermal_conductivity_fit diff --git a/piel/materials/thermal_conductivity/copper.py b/piel/materials/thermal_conductivity/copper.py new file mode 100644 index 00000000..87c8b5ac --- /dev/null +++ b/piel/materials/thermal_conductivity/copper.py @@ -0,0 +1,107 @@ +import jax.numpy as jnp +import pandas as pd +from typing import Literal + +import piel +from piel.types import ArrayTypes, PathTypes + +# CURRENT TODO: finish migrating this, add material sub names, add proper export, put into __init__ + +__all__ = ["copper"] + +supported_specifications = Literal["rrr50", "rrr100", "rrr150", "rrr300", "rrr500"] + + +def copper( + temperature_range_K: ArrayTypes, + specification: supported_specifications, +) -> jnp.ndarray: + copper_thermal_conductivity_file = piel.return_path(__file__).parent / "data" / "ofhc_copper_thermal_conductivity.csv" + assert copper_thermal_conductivity_file.exists() + thermal_conductivity_material_dataset = pd.read_csv( + copper_thermal_conductivity_file + ) + + # Simplified coefficient extraction + coefficients = {} + for coeff in ["a", "b", "c", "d", "e", "f", "g", "h", "i"]: + coefficients[coeff] = thermal_conductivity_material_dataset.loc[ + thermal_conductivity_material_dataset["coefficient"] == coeff, specification].values[0] + + # Calculating thermal conductivity + numerator = (coefficients['a'] + + coefficients['c'] * temperature_range_K ** 0.5 + + coefficients['e'] * temperature_range_K + + coefficients['g'] * temperature_range_K ** 1.5 + + coefficients['i'] * temperature_range_K ** 2) + + denominator = (1 + + coefficients['b'] * temperature_range_K ** 0.5 + + coefficients['d'] * temperature_range_K + + coefficients['f'] * temperature_range_K ** 1.5 + + coefficients['h'] * temperature_range_K ** 2) + + thermal_conductivity_fit = numerator / denominator + + return thermal_conductivity_fit + +# if self.material_name == "copper": +# thermal_conductivity_material_dataset = pd.read_csv( +# file_path + "/../materials/data/raw/thermal_conductivity/ofhc_copper_thermal_conductivity.csv") +# a = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "a"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "a"][ +# self.material_sub_name].values) +# b = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "b"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "b"][ +# self.material_sub_name].values) +# c = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "c"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "c"][ +# self.material_sub_name].values) +# d = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "d"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "d"][ +# self.material_sub_name].values) +# e = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "e"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "e"][ +# self.material_sub_name].values) +# f = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "f"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "f"][ +# self.material_sub_name].values) +# g = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "g"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "g"][ +# self.material_sub_name].values) +# h = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "h"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "h"][ +# self.material_sub_name].values) +# i = nsy.C(s=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "i"][self.material_sub_name].values[0], +# n=thermal_conductivity_material_dataset[ +# thermal_conductivity_material_dataset["coefficient"] == "i"][ +# self.material_sub_name].values) +# self.__thermal_conductivity_fit__ = nsy.V(n=10) ** ((a + +# c * self.temperature_range_K ** 0.5 + +# e * self.temperature_range_K + +# g * self.temperature_range_K ** 1.5 + +# i * self.temperature_range_K ** 2) / +# (1 + +# b * self.temperature_range_K ** 0.5 + +# d * self.temperature_range_K + +# f * self.temperature_range_K ** 1.5 + +# h * self.temperature_range_K ** 2) +# +# return self.__thermal_conductivity_fit__.n diff --git a/materials/thermal_conductivity/amorphous_silicon.csv b/piel/materials/thermal_conductivity/data/amorphous_silicon.csv similarity index 100% rename from materials/thermal_conductivity/amorphous_silicon.csv rename to piel/materials/thermal_conductivity/data/amorphous_silicon.csv diff --git a/materials/thermal_conductivity/crystalline_silicon.csv b/piel/materials/thermal_conductivity/data/crystalline_silicon.csv similarity index 100% rename from materials/thermal_conductivity/crystalline_silicon.csv rename to piel/materials/thermal_conductivity/data/crystalline_silicon.csv diff --git a/materials/thermal_conductivity/ofhc_copper_nist.xlsx b/piel/materials/thermal_conductivity/data/ofhc_copper_nist.xlsx similarity index 100% rename from materials/thermal_conductivity/ofhc_copper_nist.xlsx rename to piel/materials/thermal_conductivity/data/ofhc_copper_nist.xlsx diff --git a/materials/thermal_conductivity/ofhc_copper_thermal_conductivity.csv b/piel/materials/thermal_conductivity/data/ofhc_copper_thermal_conductivity.csv similarity index 100% rename from materials/thermal_conductivity/ofhc_copper_thermal_conductivity.csv rename to piel/materials/thermal_conductivity/data/ofhc_copper_thermal_conductivity.csv diff --git a/materials/thermal_conductivity/vitrous_silica.csv b/piel/materials/thermal_conductivity/data/vitrous_silica.csv similarity index 100% rename from materials/thermal_conductivity/vitrous_silica.csv rename to piel/materials/thermal_conductivity/data/vitrous_silica.csv diff --git a/piel/materials/thermal_conductivity/stainless_steel.py b/piel/materials/thermal_conductivity/stainless_steel.py new file mode 100644 index 00000000..c344a2fd --- /dev/null +++ b/piel/materials/thermal_conductivity/stainless_steel.py @@ -0,0 +1,53 @@ +import jax.numpy as jnp +from typing import Literal + +__all__ = ["stainless_steel"] + +supported_specifications = Literal["304", "310", "316"] + + +def stainless_steel(temperature_range_K, material_sub_name): + if material_sub_name == "304": + # https://trc.nist.gov/cryogenics/materials/304Stainless/304Stainless_rev.htm + thermal_conductivity_fit = 10 ** ( + -1.4087 + + 1.3982 * jnp.log10(temperature_range_K) + + 0.2543 * (jnp.log10(temperature_range_K) ** 2) + - 0.6260 * (jnp.log10(temperature_range_K) ** 3) + + 0.2334 * (jnp.log10(temperature_range_K) ** 4) + + 0.4256 * (jnp.log10(temperature_range_K) ** 5) + - 0.4658 * (jnp.log10(temperature_range_K) ** 6) + + 0.1650 * (jnp.log10(temperature_range_K) ** 7) + - 0.0199 * (jnp.log10(temperature_range_K) ** 8) + ) + elif material_sub_name == "310": + # https://trc.nist.gov/cryogenics/materials/310%20Stainless/310Stainless_rev.htm + thermal_conductivity_fit = 10 ** ( + -0.81907 + - 2.1967 * jnp.log10(temperature_range_K) + + 9.1059 * (jnp.log10(temperature_range_K) ** 2) + - 13.078 * (jnp.log10(temperature_range_K) ** 3) + + 10.853 * (jnp.log10(temperature_range_K) ** 4) + - 5.1269 * (jnp.log10(temperature_range_K) ** 5) + + 1.2583 * (jnp.log10(temperature_range_K) ** 6) + - 0.12395 * (jnp.log10(temperature_range_K) ** 7) + ) + elif material_sub_name == "316": + # https://trc.nist.gov/cryogenics/materials/310%20Stainless/310Stainless_rev.htm + # Assuming the formula is similar to 304 since the same values are used in your example. + # If there's a different formula for 316, it should replace the coefficients here. + thermal_conductivity_fit = 10 ** ( + -1.4087 + + 1.3982 * jnp.log10(temperature_range_K) + + 0.2543 * (jnp.log10(temperature_range_K) ** 2) + - 0.6260 * (jnp.log10(temperature_range_K) ** 3) + + 0.2334 * (jnp.log10(temperature_range_K) ** 4) + + 0.4256 * (jnp.log10(temperature_range_K) ** 5) + - 0.4658 * (jnp.log10(temperature_range_K) ** 6) + + 0.1650 * (jnp.log10(temperature_range_K) ** 7) + - 0.0199 * (jnp.log10(temperature_range_K) ** 8) + ) + else: + raise ValueError("Invalid material sub name: " + material_sub_name) + + return thermal_conductivity_fit diff --git a/piel/materials/thermal_conductivity/teflon.py b/piel/materials/thermal_conductivity/teflon.py new file mode 100644 index 00000000..2600c44c --- /dev/null +++ b/piel/materials/thermal_conductivity/teflon.py @@ -0,0 +1,28 @@ +import jax.numpy as jnp + + +__all__ = ["teflon"] + +def teflon(temperature_range_K): + """ + Trade Names for FEP resins include DuPont Teflon™, Daikin Neoflon™, Dyneon Hostaflon™, NiFlon, Sinoflon. + Source: https://trc.nist.gov/cryogenics/materials/Teflon/Teflon_rev.htm + + Args: + temperature_range_K: + + Returns: + + """ + thermal_conductivity_fit = 10 ** ( + + 2.7380 + - 30.677 * jnp.log10(temperature_range_K) + + 89.430 * (jnp.log10(temperature_range_K) ** 2) + - 136.99 * (jnp.log10(temperature_range_K) ** 3) + + 124.69 * (jnp.log10(temperature_range_K) ** 4) + - 69.556 * (jnp.log10(temperature_range_K) ** 5) + + 23.320 * (jnp.log10(temperature_range_K) ** 6) + - 4.3135 * (jnp.log10(temperature_range_K) ** 7) + + 0.33829 * (jnp.log10(temperature_range_K) ** 8) + ) + return thermal_conductivity_fit diff --git a/piel/models/physical/geometry.py b/piel/models/physical/geometry.py index 1fda3cf1..8228dca3 100644 --- a/piel/models/physical/geometry.py +++ b/piel/models/physical/geometry.py @@ -1,13 +1,14 @@ import jax.numpy as jnp -__all__ = ["calculate_cross_sectional_area_m2"] +__all__ = ["awg_to_cross_sectional_area_m2", + "calculate_cross_sectional_area_m2", ] def calculate_cross_sectional_area_m2( diameter_m: float, ) -> float: """ - Calculates the cross sectional area of a circle in meters squared. + Calculates the cross-sectional area of a circle in meters squared. Args: diameter_m (float): Diameter of the circle in meters. @@ -15,4 +16,21 @@ def calculate_cross_sectional_area_m2( Returns: float: Cross sectional area in meters squared. """ - return jnp.pi * (diameter_m**2) / 4 + return jnp.pi * (diameter_m ** 2) / 4 + + +def awg_to_cross_sectional_area_m2( + awg: int, +) -> float: + """ + Converts an AWG value to the cross-sectional area in meters squared. + + Args: + awg (int): The AWG value to convert. + + Returns: + float: The cross-sectional area in meters squared. + """ + return jnp.pi * (0.127 * 92 ** ((36 - awg) / 39) ** 2) / 4 + +# old ((0.127) * (92 ** ((36 - self.core_diameter_awg) / 39))) * 1e-3 diff --git a/piel/models/physical/thermal.py b/piel/models/physical/thermal.py index 0d68ecf8..17999eb6 100644 --- a/piel/models/physical/thermal.py +++ b/piel/models/physical/thermal.py @@ -6,8 +6,29 @@ def heat_transfer_1d_W( - thermal_conductivity_fit, temperature_range_K, cross_sectional_area_m2, length_m + thermal_conductivity_fit, + temperature_range_K: list[float, float], + cross_sectional_area_m2: float, + length_m: float ) -> float: + """ + Calculate the heat transfer in watts for a 1D system. The thermal conductivity is assumed to be a function of + temperature. + + .. math:: + + q = A \int_{T_1}^{T_2} k(T) dT + + Args: + thermal_conductivity_fit: + temperature_range_K: + cross_sectional_area_m2: + length_m: + + Returns: + float: The heat transfer in watts for a 1D system. + + """ thermal_conductivity_integral_area = jnp.trapz( thermal_conductivity_fit, temperature_range_K ) diff --git a/piel/project_structure.py b/piel/project_structure.py index ade99242..45e2b2e7 100644 --- a/piel/project_structure.py +++ b/piel/project_structure.py @@ -5,7 +5,7 @@ import types from typing import Literal, Optional -from .types import piel_path_types +from .types import PathTypes from .file_system import ( return_path, read_json, @@ -24,7 +24,7 @@ def create_setup_py( - design_directory: piel_path_types, + design_directory: PathTypes, project_name: Optional[str] = None, from_config_json: bool = True, ) -> None: @@ -32,7 +32,7 @@ def create_setup_py( This function creates a setup.py file from the config.json file found in the design directory. Args: - design_directory(piel_path_types): Design directory PATH or module name. + design_directory(PathTypes): Design directory PATH or module name. Returns: None @@ -70,7 +70,7 @@ def create_setup_py( def create_empty_piel_project( - project_name: str, parent_directory: piel_path_types + project_name: str, parent_directory: PathTypes ) -> None: """ This function creates an empty piel-structure project in the target directory. Structuring your files in this way @@ -81,7 +81,7 @@ def create_empty_piel_project( Args: project_name(str): Name of the project. - parent_directory(piel_path_types): Parent directory of the project. + parent_directory(PathTypes): Parent directory of the project. Returns: None @@ -236,12 +236,12 @@ def get_module_folder_type_location( return folder_path -def pip_install_local_module(module_path: piel_path_types): +def pip_install_local_module(module_path: PathTypes): """ This function installs a local module in editable mode. Args: - module_path(piel_path_types): Path to the module to be installed. + module_path(PathTypes): Path to the module to be installed. Returns: None @@ -254,12 +254,12 @@ def pip_install_local_module(module_path: piel_path_types): print(f"Failed to install local module at '{module_path}'.") -def read_configuration(design_directory: piel_path_types) -> dict: +def read_configuration(design_directory: PathTypes) -> dict: """ This function reads the configuration file found in the design directory. Args: - design_directory(piel_path_types): Design directory PATH. + design_directory(PathTypes): Design directory PATH. Returns: config_dictionary(dict): Configuration dictionary. diff --git a/piel/tools/amaranth/export.py b/piel/tools/amaranth/export.py index 6e401a5c..aef3bed2 100644 --- a/piel/tools/amaranth/export.py +++ b/piel/tools/amaranth/export.py @@ -4,7 +4,7 @@ from ...project_structure import get_module_folder_type_location from ...file_system import return_path -from ...types import piel_path_types +from ...types import PathTypes __all__ = ["generate_verilog_from_amaranth"] @@ -13,7 +13,7 @@ def generate_verilog_from_amaranth( amaranth_module: am.Elaboratable, ports_list: list[str], target_file_name: str, - target_directory: piel_path_types, + target_directory: PathTypes, backend=verilog, ) -> None: """ @@ -26,7 +26,7 @@ def generate_verilog_from_amaranth( amaranth_module (amaranth.Elaboratable): Amaranth elaboratable class. ports_list (list[str]): List of input names. target_file_name (str): Target file name. - target_directory (piel_path_types): Target directory PATH. + target_directory (PathTypes): Target directory PATH. backend (amaranth.back.verilog): Backend to use. Defaults to ``verilog``. Returns: diff --git a/piel/tools/amaranth/verify.py b/piel/tools/amaranth/verify.py index 796bf704..17e08a31 100644 --- a/piel/tools/amaranth/verify.py +++ b/piel/tools/amaranth/verify.py @@ -5,7 +5,7 @@ from ...project_structure import get_module_folder_type_location from ...file_system import return_path -from ...types import piel_path_types +from ...types import PathTypes __all__ = ["verify_truth_table"] @@ -16,7 +16,7 @@ def verify_truth_table( inputs: list, outputs: list, vcd_file_name: str, - target_directory: piel_path_types, + target_directory: PathTypes, implementation_type: Literal[ "combinatorial", "sequential", "memory" ] = "combinatorial", diff --git a/piel/tools/cocotb/data.py b/piel/tools/cocotb/data.py index 982db0b0..2fc6f78c 100644 --- a/piel/tools/cocotb/data.py +++ b/piel/tools/cocotb/data.py @@ -3,7 +3,7 @@ """ import functools import pandas as pd -from piel.types import piel_path_types +from piel.types import PathTypes from piel.file_system import return_path, get_files_recursively_in_directory __all__ = [ @@ -19,14 +19,14 @@ def get_simulation_output_files_from_design( - design_directory: piel_path_types, + design_directory: PathTypes, extension: str = "csv", ): """ This function returns a list of all the simulation output files in the design directory. Args: - design_directory (piel_path_types): The path to the design directory. + design_directory (PathTypes): The path to the design directory. Returns: output_files (list): List of all the simulation output files in the design directory. @@ -38,12 +38,12 @@ def get_simulation_output_files_from_design( return output_files -def read_simulation_data(file_path: piel_path_types): +def read_simulation_data(file_path: PathTypes): """ This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. Args: - file_path (piel_path_types): The path to the simulation data file. + file_path (PathTypes): The path to the simulation data file. Returns: simulation_data (pd.DataFrame): The simulation data in a Pandas dataframe. diff --git a/piel/tools/hdl21/simulator.py b/piel/tools/hdl21/simulator.py index 3451f2e0..f28f9334 100644 --- a/piel/tools/hdl21/simulator.py +++ b/piel/tools/hdl21/simulator.py @@ -4,7 +4,7 @@ import pandas as pd from typing import Literal, Optional import vlsirtools.spice as vsp -from ...types import piel_path_types +from ...types import PathTypes from ...file_system import return_path __all__ = [ @@ -16,13 +16,13 @@ def configure_ngspice_simulation( - run_directory: piel_path_types = ".", + run_directory: PathTypes = ".", ): """ This function configures the NGSPICE simulation for the circuit and returns a simulation class. Args: - run_directory (piel_path_types): Directory where the simulation will be run + run_directory (PathTypes): Directory where the simulation will be run Returns: simulation_options: Configured NGSPICE simulation options @@ -91,13 +91,13 @@ class Simulation: def save_results_to_csv( - results: hs.SimResult, file_name: str, save_directory: piel_path_types = "." + results: hs.SimResult, file_name: str, save_directory: PathTypes = "." ): """ This function converts the simulation results to a pandas dataframe and saves it to a csv file. Args: - directory (piel_path_types): Directory where the simulation will be run + directory (PathTypes): Directory where the simulation will be run """ save_directory = return_path(save_directory) diff --git a/piel/tools/openlane/utils.py b/piel/tools/openlane/utils.py index d1d40d28..f3aa1c4f 100644 --- a/piel/tools/openlane/utils.py +++ b/piel/tools/openlane/utils.py @@ -1,6 +1,6 @@ from datetime import datetime import pathlib -from piel.types import piel_path_types +from piel.types import PathTypes from piel.file_system import return_path from typing import Literal @@ -27,7 +27,7 @@ def extract_datetime_from_path(run_path: pathlib.Path) -> str: def find_all_design_runs( - design_directory: piel_path_types, + design_directory: PathTypes, run_name: str | None = None, ) -> list[pathlib.Path]: """ @@ -36,7 +36,7 @@ def find_all_design_runs( If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run Args: - design_directory (piel_path_types): The path to the design directory + design_directory (PathTypes): The path to the design directory run_name (str, optional): The name of the run to return. Defaults to None. version (Literal["v1", "v2"], optional): The version of OpenLane to use. Defaults to None. @@ -73,7 +73,7 @@ def find_all_design_runs( def find_latest_design_run( - design_directory: piel_path_types, + design_directory: PathTypes, run_name: str | None = None, version: Literal["v1", "v2"] | None = None, ) -> (pathlib.Path, str): @@ -83,7 +83,7 @@ def find_latest_design_run( If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run. Args: - design_directory (piel_path_types): The path to the design directory + design_directory (PathTypes): The path to the design directory run_name (str, optional): The name of the run to return. Defaults to None. version (Literal["v1", "v2"], optional): The version of the run to return. Defaults to None. @@ -123,15 +123,15 @@ def find_latest_design_run( def get_gds_path_from_design_run( - design_directory: piel_path_types, - run_directory: piel_path_types | None = None, + design_directory: PathTypes, + run_directory: PathTypes | None = None, ) -> pathlib.Path: """ Returns the path to the final GDS generated by OpenLane. Args: - design_directory (piel_path_types): The path to the design directory - run_directory (piel_path_types, optional): The path to the run directory. Defaults to None. Otherwise gets the latest run. + design_directory (PathTypes): The path to the design directory + run_directory (PathTypes, optional): The path to the run directory. Defaults to None. Otherwise gets the latest run. Returns: pathlib.Path: The path to the final GDS @@ -168,7 +168,7 @@ def get_gds_path_from_design_run( def get_design_run_version( - run_directory: piel_path_types, + run_directory: PathTypes, ) -> Literal["v1", "v2"]: """ Returns the version of the design run. diff --git a/piel/tools/openlane/v1.py b/piel/tools/openlane/v1.py index 8f3702ff..70bece11 100644 --- a/piel/tools/openlane/v1.py +++ b/piel/tools/openlane/v1.py @@ -14,7 +14,7 @@ run_script, write_file, ) -from ...types import piel_path_types +from ...types import PathTypes __all__ = [ "check_config_json_exists_openlane_v1", @@ -314,7 +314,7 @@ def read_configuration_openlane_v1( def write_configuration_openlane_v1( configuration: dict, - design_directory: piel_path_types, + design_directory: PathTypes, ) -> None: """ Writes a `config.json` onto a `design_directory` diff --git a/piel/tools/openlane/v2.py b/piel/tools/openlane/v2.py index 2746bdd3..c84571a8 100644 --- a/piel/tools/openlane/v2.py +++ b/piel/tools/openlane/v2.py @@ -1,5 +1,5 @@ from openlane.flows import Flow -from piel.types import piel_path_types +from piel.types import PathTypes from piel.file_system import ( return_path, read_json, @@ -16,7 +16,7 @@ def get_all_designs_metrics_openlane_v2( - output_directory: piel_path_types, + output_directory: PathTypes, target_prefix: str, ): """ @@ -34,7 +34,7 @@ def get_all_designs_metrics_openlane_v2( ``` Args: - output_directory (piel_path_types): The path to the output directory. + output_directory (PathTypes): The path to the output directory. target_prefix (str): The prefix of the designs to get the metrics for. Returns: @@ -59,12 +59,12 @@ def get_all_designs_metrics_openlane_v2( return output_dictionary -def read_metrics_openlane_v2(design_directory: piel_path_types) -> dict: +def read_metrics_openlane_v2(design_directory: PathTypes) -> dict: """ Read design metrics from OpenLane v2 run files. Args: - design_directory(piel_path_types): Design directory PATH. + design_directory(PathTypes): Design directory PATH. Returns: dict: Metrics dictionary. @@ -80,7 +80,7 @@ def read_metrics_openlane_v2(design_directory: piel_path_types) -> dict: def run_openlane_flow( configuration: dict | None = None, - design_directory: piel_path_types = ".", + design_directory: PathTypes = ".", parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False, ): @@ -89,7 +89,7 @@ def run_openlane_flow( Args: configuration(dict): OpenLane configuration dictionary. If none is present it will default to the config.json file on the design_directory. - design_directory(piel_path_types): Design directory PATH. + design_directory(PathTypes): Design directory PATH. parallel_asynchronous_run(bool): Run the flow in parallel. only_generate_flow_setup(bool): Only generate the flow setup. diff --git a/piel/types.py b/piel/types.py index 28be4e56..87e24b5a 100644 --- a/piel/types.py +++ b/piel/types.py @@ -6,9 +6,13 @@ import os import pathlib import types +import numpy as np +import jax.numpy as jnp __all__ = [ - "piel_path_types", + "ArrayTypes", + "PathTypes", ] -piel_path_types = str | pathlib.Path | os.PathLike | types.ModuleType +PathTypes = str | pathlib.Path | os.PathLike | types.ModuleType +ArrayTypes = np.ndarray | jnp.ndarray diff --git a/pyproject.toml b/pyproject.toml index da607ea8..143fa426 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,6 +118,15 @@ develop = [ "watchdog" ] +[[tool.poetry.source]] +name = "pypi" +priority = "primary" + +[[tool.poetry.source]] +name = "jaxsource" +url = "https://storage.googleapis.com/jax-releases/jax_releases.html" +priority = "supplemental" + [tool.poetry.scripts] piel = "piel.cli:main" poetry = "poetry.console.application:main" From c3b524e672940e71b5d4ed22057403b8505c27fb Mon Sep 17 00:00:00 2001 From: daquintero Date: Sun, 31 Mar 2024 23:46:56 +0200 Subject: [PATCH 2/2] :art: Visual styles, IO modelling --- docs/autoapi/index.rst | 1 + docs/autoapi/piel/cli/index.rst | 2 +- docs/autoapi/piel/file_conversion/index.rst | 4 +- docs/autoapi/piel/file_system/index.rst | 80 +++--- docs/autoapi/piel/index.rst | 210 +++++++++----- .../integration/amaranth_openlane/index.rst | 4 +- .../integration/gdsfactory_openlane/index.rst | 4 +- docs/autoapi/piel/integration/index.rst | 34 ++- .../integration/type_conversion/index.rst | 30 +- .../electrical_resistivity/index.rst | 6 + docs/autoapi/piel/materials/index.rst | 25 ++ docs/autoapi/piel/materials/silicon/index.rst | 258 ++++++++++++++++++ .../thermal_conductivity/aluminum/index.rst | 35 +++ .../thermal_conductivity/copper/index.rst | 35 +++ .../materials/thermal_conductivity/index.rst | 108 ++++++++ .../stainless_steel/index.rst | 35 +++ .../thermal_conductivity/teflon/index.rst | 44 +++ .../thermal_conductivity/types/index.rst | 21 ++ .../thermal_conductivity/utils/index.rst | 29 ++ .../piel/models/frequency/defaults/index.rst | 2 +- docs/autoapi/piel/models/frequency/index.rst | 2 +- .../piel/models/frequency/photonic/index.rst | 8 +- .../photonic/straight_waveguide/index.rst | 8 +- .../piel/models/logic/electro_optic/index.rst | 32 +++ .../electro_optic/signal_mapping/index.rst | 23 +- .../logic/electro_optic/types/index.rst | 24 ++ .../physical/electrical/cable/index.rst | 98 +++++++ .../piel/models/physical/electrical/index.rst | 1 + .../physical/electrical/types/index.rst | 179 ++++++++++++ .../models/physical/electronic/hva/index.rst | 6 + .../piel/models/physical/electronic/index.rst | 3 + .../models/physical/electronic/lna/index.rst | 6 + .../physical/electronic/types/index.rst | 67 +++++ .../piel/models/physical/geometry/index.rst | 14 +- docs/autoapi/piel/models/physical/index.rst | 15 +- .../piel/models/physical/thermal/index.rst | 17 +- .../piel/models/physical/types/index.rst | 21 ++ .../transient/electronic/ideal_rc/index.rst | 38 +++ .../models/transient/electronic/index.rst | 42 +++ .../transient/electronic/types/index.rst | 13 + docs/autoapi/piel/project_structure/index.rst | 16 +- .../piel/tools/amaranth/export/index.rst | 4 +- docs/autoapi/piel/tools/amaranth/index.rst | 6 +- .../piel/tools/amaranth/verify/index.rst | 2 +- docs/autoapi/piel/tools/cocotb/data/index.rst | 8 +- docs/autoapi/piel/tools/cocotb/index.rst | 8 +- docs/autoapi/piel/tools/hdl21/index.rst | 4 +- .../piel/tools/hdl21/simulator/index.rst | 4 +- docs/autoapi/piel/tools/index.rst | 42 +-- docs/autoapi/piel/tools/openlane/index.rst | 30 +- .../piel/tools/openlane/utils/index.rst | 16 +- docs/autoapi/piel/tools/openlane/v1/index.rst | 2 +- docs/autoapi/piel/tools/openlane/v2/index.rst | 12 +- docs/autoapi/piel/types/index.rst | 61 +++++ .../straight_waveguidecheckpoint/index.rst | 43 +++ docs/examples.rst | 1 + .../08_basic_interconnection_modelling.py | 137 ++++++++++ piel/__init__.py | 3 +- .../thermal_conductivity/__init__.py | 13 + .../thermal_conductivity/aluminum.py | 16 +- piel/materials/thermal_conductivity/copper.py | 23 +- .../thermal_conductivity/stainless_steel.py | 26 +- piel/materials/thermal_conductivity/teflon.py | 12 +- piel/materials/thermal_conductivity/types.py | 11 + piel/materials/thermal_conductivity/utils.py | 53 ++++ piel/models/physical/electrical/cable.py | 238 ++++++++++++++++ piel/models/physical/electrical/types.py | 125 +++++++++ sys => piel/models/physical/electronic/hva.py | 0 piel/models/physical/electronic/lna.py | 2 + piel/models/physical/electronic/types.py | 37 +++ piel/models/physical/thermal.py | 24 +- piel/models/physical/types.py | 11 + piel/models/transient/electronic/__init__.py | 1 + piel/models/transient/electronic/ideal_rc.py | 59 ++++ piel/models/transient/electronic/types.py | 1 + piel/types.py | 22 ++ piel/visual/__init__.py | 1 + piel/visual/auto_plot_multiple.py | 45 ++- piel/visual/style.py | 16 ++ pyproject.toml | 1 + 80 files changed, 2476 insertions(+), 244 deletions(-) create mode 100644 docs/autoapi/piel/materials/electrical_resistivity/index.rst create mode 100644 docs/autoapi/piel/materials/index.rst create mode 100644 docs/autoapi/piel/materials/silicon/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/aluminum/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/copper/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/stainless_steel/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/teflon/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/types/index.rst create mode 100644 docs/autoapi/piel/materials/thermal_conductivity/utils/index.rst create mode 100644 docs/autoapi/piel/models/logic/electro_optic/types/index.rst create mode 100644 docs/autoapi/piel/models/physical/electrical/types/index.rst create mode 100644 docs/autoapi/piel/models/physical/electronic/hva/index.rst create mode 100644 docs/autoapi/piel/models/physical/electronic/lna/index.rst create mode 100644 docs/autoapi/piel/models/physical/electronic/types/index.rst create mode 100644 docs/autoapi/piel/models/physical/types/index.rst create mode 100644 docs/autoapi/piel/models/transient/electronic/ideal_rc/index.rst create mode 100644 docs/autoapi/piel/models/transient/electronic/types/index.rst create mode 100644 docs/autoapi/piel/types/index.rst create mode 100644 docs/autoapi/straight_waveguidecheckpoint/index.rst create mode 100644 docs/examples/08_basic_interconnection_modelling.py create mode 100644 piel/materials/thermal_conductivity/types.py create mode 100644 piel/materials/thermal_conductivity/utils.py create mode 100644 piel/models/physical/electrical/types.py rename sys => piel/models/physical/electronic/hva.py (100%) create mode 100644 piel/models/physical/electronic/lna.py create mode 100644 piel/models/physical/electronic/types.py create mode 100644 piel/models/physical/types.py create mode 100644 piel/models/transient/electronic/ideal_rc.py create mode 100644 piel/models/transient/electronic/types.py create mode 100644 piel/visual/style.py diff --git a/docs/autoapi/index.rst b/docs/autoapi/index.rst index 08cf0790..9e5d4f90 100644 --- a/docs/autoapi/index.rst +++ b/docs/autoapi/index.rst @@ -7,5 +7,6 @@ This page contains auto-generated API reference documentation [#f1]_. :titlesonly: /autoapi/piel/index + /autoapi/straight_waveguidecheckpoint/index .. [#f1] Created with `sphinx-autoapi `_ \ No newline at end of file diff --git a/docs/autoapi/piel/cli/index.rst b/docs/autoapi/piel/cli/index.rst index 92fdf6b7..8e8d391a 100644 --- a/docs/autoapi/piel/cli/index.rst +++ b/docs/autoapi/piel/cli/index.rst @@ -86,7 +86,7 @@ Attributes Gets the piel installation directory. -.. py:function:: return_path(input_path: piel.config.piel_path_types, as_piel_module: bool = False) -> pathlib.Path +.. py:function:: return_path(input_path: piel.types.PathTypes, as_piel_module: bool = False) -> pathlib.Path Returns a pathlib.Path to be able to perform operations accordingly internally. diff --git a/docs/autoapi/piel/file_conversion/index.rst b/docs/autoapi/piel/file_conversion/index.rst index f4ef5257..709daf33 100644 --- a/docs/autoapi/piel/file_conversion/index.rst +++ b/docs/autoapi/piel/file_conversion/index.rst @@ -18,11 +18,11 @@ Functions -.. py:function:: read_csv_to_pandas(file_path: piel.config.piel_path_types) +.. py:function:: read_csv_to_pandas(file_path: piel.types.PathTypes) This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. -.. py:function:: read_vcd_to_json(file_path: piel.config.piel_path_types) +.. py:function:: read_vcd_to_json(file_path: piel.types.PathTypes) diff --git a/docs/autoapi/piel/file_system/index.rst b/docs/autoapi/piel/file_system/index.rst index ecf9de3d..7631ddff 100644 --- a/docs/autoapi/piel/file_system/index.rst +++ b/docs/autoapi/piel/file_system/index.rst @@ -38,43 +38,43 @@ Functions -.. py:function:: check_path_exists(path: piel.config.piel_path_types, raise_errors: bool = False) -> bool +.. py:function:: check_path_exists(path: piel.types.PathTypes, raise_errors: bool = False) -> bool Checks if a directory exists. :param path: Input path. - :type path: piel_path_types + :type path: PathTypes :returns: True if directory exists. :rtype: directory_exists(bool) -.. py:function:: check_example_design(design_name: str = 'simple_design', designs_directory: piel.config.piel_path_types | None = None) -> bool +.. py:function:: check_example_design(design_name: str = 'simple_design', designs_directory: piel.types.PathTypes | None = None) -> bool We copy the example simple_design from docs to the `/foss/designs` in the `iic-osic-tools` environment. :param design_name: Name of the design to check. :type design_name: str :param designs_directory: Directory that contains the DESIGNS environment flag. - :type designs_directory: piel_path_types + :type designs_directory: PathTypes :param # TODO: :returns: None -.. py:function:: copy_source_folder(source_directory: piel.config.piel_path_types, target_directory: piel.config.piel_path_types) -> None +.. py:function:: copy_source_folder(source_directory: piel.types.PathTypes, target_directory: piel.types.PathTypes) -> None Copies the files from a source_directory to a target_directory :param source_directory: Source directory. - :type source_directory: piel_path_types + :type source_directory: PathTypes :param target_directory: Target directory. - :type target_directory: piel_path_types + :type target_directory: PathTypes :returns: None -.. py:function:: copy_example_design(project_source: Literal[piel, openlane] = 'piel', example_name: str = 'simple_design', target_directory: piel.config.piel_path_types = None, target_project_name: Optional[str] = None) -> None +.. py:function:: copy_example_design(project_source: Literal[piel, openlane] = 'piel', example_name: str = 'simple_design', target_directory: piel.types.PathTypes = None, target_project_name: Optional[str] = None) -> None We copy the example simple_design from docs to the `/foss/designs` in the `iic-osic-tools` environment. @@ -83,7 +83,7 @@ Functions :param example_name: Name of the example design. :type example_name: str :param target_directory: Target directory. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param target_project_name: Name of the target project. :type target_project_name: str @@ -120,7 +120,7 @@ Functions :returns: None -.. py:function:: delete_path_list_in_directory(directory_path: piel.config.piel_path_types, path_list: list, ignore_confirmation: bool = False, validate_individual: bool = False) -> None +.. py:function:: delete_path_list_in_directory(directory_path: piel.types.PathTypes, path_list: list, ignore_confirmation: bool = False, validate_individual: bool = False) -> None Deletes a list of files in a directory. @@ -133,7 +133,7 @@ Functions ``` :param directory_path: Input path. - :type directory_path: piel_path_types + :type directory_path: PathTypes :param path_list: List of files. :type path_list: list :param ignore_confirmation: Ignore confirmation. Default: False. @@ -144,7 +144,7 @@ Functions :returns: None -.. py:function:: get_files_recursively_in_directory(path: piel.config.piel_path_types, extension: str = '*') +.. py:function:: get_files_recursively_in_directory(path: piel.types.PathTypes, extension: str = '*') Returns a list of files in a directory. @@ -153,7 +153,7 @@ Functions get_files_recursively_in_directory('path/to/directory', 'extension') :param path: Input path. - :type path: piel_path_types + :type path: PathTypes :param extension: File extension. :type extension: str @@ -161,7 +161,7 @@ Functions :rtype: file_list(list) -.. py:function:: get_id_map_directory_dictionary(path_list: list[piel.config.piel_path_types], target_prefix: str) +.. py:function:: get_id_map_directory_dictionary(path_list: list[piel.types.PathTypes], target_prefix: str) Returns a dictionary of ids to directories. @@ -170,7 +170,7 @@ Functions get_id_to_directory_dictionary(path_list, target_prefix) :param path_list: List of paths. - :type path_list: list[piel_path_types] + :type path_list: list[PathTypes] :param target_prefix: Target prefix. :type target_prefix: str @@ -180,15 +180,15 @@ Functions .. py:function:: get_top_level_script_directory() -> pathlib.Path - Returns the top level script directory whenever this file is run. This is useful when we want to know the - location of the script that is being executed at the top level, maybe in order to create relative directories of - find relevant files. + Attempts to return the top-level script directory when this file is run, + compatible with various execution environments like Jupyter Lab, pytest, PDM, etc. + TODO run full verification. :returns: Top level script directory. :rtype: top_level_script_directory(pathlib.Path) -.. py:function:: list_prefix_match_directories(output_directory: piel.config.piel_path_types, target_prefix: str) +.. py:function:: list_prefix_match_directories(output_directory: piel.types.PathTypes, target_prefix: str) Returns a list of directories that match a prefix. @@ -197,7 +197,7 @@ Functions list_prefix_match_directories('path/to/directory', 'prefix') :param output_directory: Output directory. - :type output_directory: piel_path_types + :type output_directory: PathTypes :param target_prefix: Target prefix. :type target_prefix: str @@ -205,7 +205,7 @@ Functions :rtype: matching_dirs(list) -.. py:function:: permit_script_execution(script_path: piel.config.piel_path_types) -> None +.. py:function:: permit_script_execution(script_path: piel.types.PathTypes) -> None Permits the execution of a script. @@ -214,12 +214,12 @@ Functions permit_script_execution('path/to/script') :param script_path: Script path. - :type script_path: piel_path_types + :type script_path: PathTypes :returns: None -.. py:function:: permit_directory_all(directory_path: piel.config.piel_path_types) -> None +.. py:function:: permit_directory_all(directory_path: piel.types.PathTypes) -> None Permits a directory to be read, written and executed. Use with care as it can be a source for security issues. @@ -228,12 +228,12 @@ Functions permit_directory_all('path/to/directory') :param directory_path: Input path. - :type directory_path: piel_path_types + :type directory_path: PathTypes :returns: None -.. py:function:: read_json(path: piel.config.piel_path_types) -> dict +.. py:function:: read_json(path: piel.types.PathTypes) -> dict Reads a JSON file. @@ -242,13 +242,13 @@ Functions read_json('path/to/file.json') :param path: Input path. - :type path: piel_path_types + :type path: PathTypes :returns: JSON data. :rtype: json_data(dict) -.. py:function:: rename_file(match_file_path: piel.config.piel_path_types, renamed_file_path: piel.config.piel_path_types) -> None +.. py:function:: rename_file(match_file_path: piel.types.PathTypes, renamed_file_path: piel.types.PathTypes) -> None Renames a file. @@ -257,14 +257,14 @@ Functions rename_file('path/to/match_file', 'path/to/renamed_file') :param match_file_path: Input path. - :type match_file_path: piel_path_types + :type match_file_path: PathTypes :param renamed_file_path: Input path. - :type renamed_file_path: piel_path_types + :type renamed_file_path: PathTypes :returns: None -.. py:function:: rename_files_in_directory(target_directory: piel.config.piel_path_types, match_string: str, renamed_string: str) -> None +.. py:function:: rename_files_in_directory(target_directory: piel.types.PathTypes, match_string: str, renamed_string: str) -> None Renames all files in a directory. @@ -273,7 +273,7 @@ Functions rename_files_in_directory('path/to/directory', 'match_string', 'renamed_string') :param target_directory: Input path. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param match_string: String to match. :type match_string: str :param renamed_string: String to replace. @@ -282,7 +282,7 @@ Functions :returns: None -.. py:function:: replace_string_in_file(file_path: piel.config.piel_path_types, match_string: str, replace_string: str) +.. py:function:: replace_string_in_file(file_path: piel.types.PathTypes, match_string: str, replace_string: str) Replaces a string in a file. @@ -291,7 +291,7 @@ Functions replace_string_in_file('path/to/file', 'match_string', 'replace_string') :param file_path: Input path. - :type file_path: piel_path_types + :type file_path: PathTypes :param match_string: String to match. :type match_string: str :param replace_string: String to replace. @@ -300,7 +300,7 @@ Functions :returns: None -.. py:function:: replace_string_in_directory_files(target_directory: piel.config.piel_path_types, match_string: str, replace_string: str) +.. py:function:: replace_string_in_directory_files(target_directory: piel.types.PathTypes, match_string: str, replace_string: str) Replaces a string in all files in a directory. @@ -309,7 +309,7 @@ Functions replace_string_in_directory_files('path/to/directory', 'match_string', 'replace_string') :param target_directory: Input path. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param match_string: String to match. :type match_string: str :param replace_string: String to replace. @@ -318,7 +318,7 @@ Functions :returns: None -.. py:function:: return_path(input_path: piel.config.piel_path_types, as_piel_module: bool = False) -> pathlib.Path +.. py:function:: return_path(input_path: piel.types.PathTypes, as_piel_module: bool = False) -> pathlib.Path Returns a pathlib.Path to be able to perform operations accordingly internally. @@ -337,22 +337,22 @@ Functions :rtype: pathlib.Path -.. py:function:: run_script(script_path: piel.config.piel_path_types) -> None +.. py:function:: run_script(script_path: piel.types.PathTypes) -> None Runs a script on the filesystem `script_path`. :param script_path: Script path. - :type script_path: piel_path_types + :type script_path: PathTypes :returns: None -.. py:function:: write_file(directory_path: piel.config.piel_path_types, file_text: str, file_name: str) -> None +.. py:function:: write_file(directory_path: piel.types.PathTypes, file_text: str, file_name: str) -> None Records a `script_name` in the `scripts` project directory. :param directory_path: Design directory. - :type directory_path: piel_path_types + :type directory_path: PathTypes :param file_text: Script to write. :type file_text: str :param file_name: Name of the script. diff --git a/docs/autoapi/piel/index.rst b/docs/autoapi/piel/index.rst index 6cbf2c9e..cbb8dadc 100644 --- a/docs/autoapi/piel/index.rst +++ b/docs/autoapi/piel/index.rst @@ -17,6 +17,7 @@ Subpackages cli/index.rst integration/index.rst + materials/index.rst models/index.rst tools/index.rst visual/index.rst @@ -28,16 +29,24 @@ Submodules :titlesonly: :maxdepth: 1 - config/index.rst file_conversion/index.rst file_system/index.rst parametric/index.rst project_structure/index.rst + types/index.rst Package Contents ---------------- +Classes +~~~~~~~ + +.. autoapisummary:: + + piel.PielBaseModel + + Functions ~~~~~~~~~ @@ -78,6 +87,7 @@ Functions piel.fock_transition_probability_amplitude piel.convert_2d_array_to_string piel.convert_array_type + piel.absolute_to_threshold piel.single_parameter_sweep piel.multi_parameter_sweep piel.create_setup_py @@ -162,8 +172,11 @@ Attributes .. autoapisummary:: - piel.piel_path_types + piel.ArrayTypes + piel.PathTypes piel.array_types + piel.tuple_int_type + piel.package_array_types piel.delete_simulation_output_files piel.get_simulation_output_files piel.snet @@ -174,47 +187,69 @@ Attributes piel.__version__ -.. py:data:: piel_path_types +.. py:data:: ArrayTypes + + + +.. py:data:: PathTypes -.. py:function:: check_path_exists(path: piel.config.piel_path_types, raise_errors: bool = False) -> bool +.. py:class:: PielBaseModel + + + Bases: :py:obj:`pydantic.BaseModel` + + .. py:class:: Config + + + .. py:attribute:: arbitrary_types_allowed + :value: True + + + + + .. py:method:: supplied_parameters() + + + +.. py:function:: check_path_exists(path: piel.types.PathTypes, raise_errors: bool = False) -> bool Checks if a directory exists. :param path: Input path. - :type path: piel_path_types + :type path: PathTypes :returns: True if directory exists. :rtype: directory_exists(bool) -.. py:function:: check_example_design(design_name: str = 'simple_design', designs_directory: piel.config.piel_path_types | None = None) -> bool +.. py:function:: check_example_design(design_name: str = 'simple_design', designs_directory: piel.types.PathTypes | None = None) -> bool We copy the example simple_design from docs to the `/foss/designs` in the `iic-osic-tools` environment. :param design_name: Name of the design to check. :type design_name: str :param designs_directory: Directory that contains the DESIGNS environment flag. - :type designs_directory: piel_path_types + :type designs_directory: PathTypes :param # TODO: :returns: None -.. py:function:: copy_source_folder(source_directory: piel.config.piel_path_types, target_directory: piel.config.piel_path_types) -> None +.. py:function:: copy_source_folder(source_directory: piel.types.PathTypes, target_directory: piel.types.PathTypes) -> None Copies the files from a source_directory to a target_directory :param source_directory: Source directory. - :type source_directory: piel_path_types + :type source_directory: PathTypes :param target_directory: Target directory. - :type target_directory: piel_path_types + :type target_directory: PathTypes :returns: None -.. py:function:: copy_example_design(project_source: Literal[piel, openlane] = 'piel', example_name: str = 'simple_design', target_directory: piel.config.piel_path_types = None, target_project_name: Optional[str] = None) -> None +.. py:function:: copy_example_design(project_source: Literal[piel, openlane] = 'piel', example_name: str = 'simple_design', target_directory: piel.types.PathTypes = None, target_project_name: Optional[str] = None) -> None We copy the example simple_design from docs to the `/foss/designs` in the `iic-osic-tools` environment. @@ -223,7 +258,7 @@ Attributes :param example_name: Name of the example design. :type example_name: str :param target_directory: Target directory. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param target_project_name: Name of the target project. :type target_project_name: str @@ -260,7 +295,7 @@ Attributes :returns: None -.. py:function:: delete_path_list_in_directory(directory_path: piel.config.piel_path_types, path_list: list, ignore_confirmation: bool = False, validate_individual: bool = False) -> None +.. py:function:: delete_path_list_in_directory(directory_path: piel.types.PathTypes, path_list: list, ignore_confirmation: bool = False, validate_individual: bool = False) -> None Deletes a list of files in a directory. @@ -273,7 +308,7 @@ Attributes ``` :param directory_path: Input path. - :type directory_path: piel_path_types + :type directory_path: PathTypes :param path_list: List of files. :type path_list: list :param ignore_confirmation: Ignore confirmation. Default: False. @@ -284,7 +319,7 @@ Attributes :returns: None -.. py:function:: get_files_recursively_in_directory(path: piel.config.piel_path_types, extension: str = '*') +.. py:function:: get_files_recursively_in_directory(path: piel.types.PathTypes, extension: str = '*') Returns a list of files in a directory. @@ -293,7 +328,7 @@ Attributes get_files_recursively_in_directory('path/to/directory', 'extension') :param path: Input path. - :type path: piel_path_types + :type path: PathTypes :param extension: File extension. :type extension: str @@ -303,15 +338,15 @@ Attributes .. py:function:: get_top_level_script_directory() -> pathlib.Path - Returns the top level script directory whenever this file is run. This is useful when we want to know the - location of the script that is being executed at the top level, maybe in order to create relative directories of - find relevant files. + Attempts to return the top-level script directory when this file is run, + compatible with various execution environments like Jupyter Lab, pytest, PDM, etc. + TODO run full verification. :returns: Top level script directory. :rtype: top_level_script_directory(pathlib.Path) -.. py:function:: get_id_map_directory_dictionary(path_list: list[piel.config.piel_path_types], target_prefix: str) +.. py:function:: get_id_map_directory_dictionary(path_list: list[piel.types.PathTypes], target_prefix: str) Returns a dictionary of ids to directories. @@ -320,7 +355,7 @@ Attributes get_id_to_directory_dictionary(path_list, target_prefix) :param path_list: List of paths. - :type path_list: list[piel_path_types] + :type path_list: list[PathTypes] :param target_prefix: Target prefix. :type target_prefix: str @@ -328,7 +363,7 @@ Attributes :rtype: id_dict(dict) -.. py:function:: list_prefix_match_directories(output_directory: piel.config.piel_path_types, target_prefix: str) +.. py:function:: list_prefix_match_directories(output_directory: piel.types.PathTypes, target_prefix: str) Returns a list of directories that match a prefix. @@ -337,7 +372,7 @@ Attributes list_prefix_match_directories('path/to/directory', 'prefix') :param output_directory: Output directory. - :type output_directory: piel_path_types + :type output_directory: PathTypes :param target_prefix: Target prefix. :type target_prefix: str @@ -345,7 +380,7 @@ Attributes :rtype: matching_dirs(list) -.. py:function:: permit_directory_all(directory_path: piel.config.piel_path_types) -> None +.. py:function:: permit_directory_all(directory_path: piel.types.PathTypes) -> None Permits a directory to be read, written and executed. Use with care as it can be a source for security issues. @@ -354,12 +389,12 @@ Attributes permit_directory_all('path/to/directory') :param directory_path: Input path. - :type directory_path: piel_path_types + :type directory_path: PathTypes :returns: None -.. py:function:: permit_script_execution(script_path: piel.config.piel_path_types) -> None +.. py:function:: permit_script_execution(script_path: piel.types.PathTypes) -> None Permits the execution of a script. @@ -368,12 +403,12 @@ Attributes permit_script_execution('path/to/script') :param script_path: Script path. - :type script_path: piel_path_types + :type script_path: PathTypes :returns: None -.. py:function:: read_json(path: piel.config.piel_path_types) -> dict +.. py:function:: read_json(path: piel.types.PathTypes) -> dict Reads a JSON file. @@ -382,13 +417,13 @@ Attributes read_json('path/to/file.json') :param path: Input path. - :type path: piel_path_types + :type path: PathTypes :returns: JSON data. :rtype: json_data(dict) -.. py:function:: rename_file(match_file_path: piel.config.piel_path_types, renamed_file_path: piel.config.piel_path_types) -> None +.. py:function:: rename_file(match_file_path: piel.types.PathTypes, renamed_file_path: piel.types.PathTypes) -> None Renames a file. @@ -397,14 +432,14 @@ Attributes rename_file('path/to/match_file', 'path/to/renamed_file') :param match_file_path: Input path. - :type match_file_path: piel_path_types + :type match_file_path: PathTypes :param renamed_file_path: Input path. - :type renamed_file_path: piel_path_types + :type renamed_file_path: PathTypes :returns: None -.. py:function:: rename_files_in_directory(target_directory: piel.config.piel_path_types, match_string: str, renamed_string: str) -> None +.. py:function:: rename_files_in_directory(target_directory: piel.types.PathTypes, match_string: str, renamed_string: str) -> None Renames all files in a directory. @@ -413,7 +448,7 @@ Attributes rename_files_in_directory('path/to/directory', 'match_string', 'renamed_string') :param target_directory: Input path. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param match_string: String to match. :type match_string: str :param renamed_string: String to replace. @@ -422,7 +457,7 @@ Attributes :returns: None -.. py:function:: replace_string_in_file(file_path: piel.config.piel_path_types, match_string: str, replace_string: str) +.. py:function:: replace_string_in_file(file_path: piel.types.PathTypes, match_string: str, replace_string: str) Replaces a string in a file. @@ -431,7 +466,7 @@ Attributes replace_string_in_file('path/to/file', 'match_string', 'replace_string') :param file_path: Input path. - :type file_path: piel_path_types + :type file_path: PathTypes :param match_string: String to match. :type match_string: str :param replace_string: String to replace. @@ -440,7 +475,7 @@ Attributes :returns: None -.. py:function:: replace_string_in_directory_files(target_directory: piel.config.piel_path_types, match_string: str, replace_string: str) +.. py:function:: replace_string_in_directory_files(target_directory: piel.types.PathTypes, match_string: str, replace_string: str) Replaces a string in all files in a directory. @@ -449,7 +484,7 @@ Attributes replace_string_in_directory_files('path/to/directory', 'match_string', 'replace_string') :param target_directory: Input path. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param match_string: String to match. :type match_string: str :param replace_string: String to replace. @@ -458,7 +493,7 @@ Attributes :returns: None -.. py:function:: return_path(input_path: piel.config.piel_path_types, as_piel_module: bool = False) -> pathlib.Path +.. py:function:: return_path(input_path: piel.types.PathTypes, as_piel_module: bool = False) -> pathlib.Path Returns a pathlib.Path to be able to perform operations accordingly internally. @@ -477,22 +512,22 @@ Attributes :rtype: pathlib.Path -.. py:function:: run_script(script_path: piel.config.piel_path_types) -> None +.. py:function:: run_script(script_path: piel.types.PathTypes) -> None Runs a script on the filesystem `script_path`. :param script_path: Script path. - :type script_path: piel_path_types + :type script_path: PathTypes :returns: None -.. py:function:: write_file(directory_path: piel.config.piel_path_types, file_text: str, file_name: str) -> None +.. py:function:: write_file(directory_path: piel.types.PathTypes, file_text: str, file_name: str) -> None Records a `script_name` in the `scripts` project directory. :param directory_path: Design directory. - :type directory_path: piel_path_types + :type directory_path: PathTypes :param file_text: Script to write. :type file_text: str :param file_name: Name of the script. @@ -501,7 +536,7 @@ Attributes :returns: None -.. py:function:: create_gdsfactory_component_from_openlane(design_name_v1: str | None = None, design_directory: piel.config.piel_path_types | None = None, run_name: str | None = None, v1: bool = True) -> gdsfactory.Component +.. py:function:: create_gdsfactory_component_from_openlane(design_name_v1: str | None = None, design_directory: piel.types.PathTypes | None = None, run_name: str | None = None, v1: bool = True) -> gdsfactory.Component This function cretes a gdsfactory layout component that can be included in the network codesign of the device, or that can be used for interconnection codesign. @@ -510,7 +545,7 @@ Attributes :param design_name_v1: Design name of the v1 design that can be found within `$OPENLANE_ROOT/""/designs`. :type design_name_v1: str :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: Name of the run to extract the GDS from. If None, it will look at the latest run. :type run_name: str :param v1: If True, it will import the design from the OpenLane v1 configuration. @@ -721,6 +756,14 @@ Attributes +.. py:data:: tuple_int_type + + + +.. py:data:: package_array_types + + + .. py:function:: convert_2d_array_to_string(list_2D: list[list]) This function is particularly useful to convert digital data when it is represented as a 2D array into a set of strings. @@ -738,7 +781,24 @@ Attributes >>> "0001" -.. py:function:: convert_array_type(array: array_types, output_type: Literal[qutip, jax, numpy, list, tuple]) +.. py:function:: convert_array_type(array: array_types, output_type: package_array_types) + + +.. py:function:: absolute_to_threshold(array: array_types, threshold: float = 1e-06, dtype_output: int | float | bool = int, output_array_type: package_array_types = 'jax') -> package_array_types + + This function converts the computed optical transmission arrays to single bit digital signals. + The function takes the absolute value of the array and compares it to a threshold to determine the digital signal. + + :param array: The optical transmission array of any dimension. + :type array: array_types + :param dtype_output: The output type. Defaults to int. + :type dtype_output: int | float | bool, optional + :param threshold: The threshold to compare the array to. Defaults to 1e-6. + :type threshold: float, optional + :param output_array_type: The output type. Defaults to "jax". + :type output_array_type: array_types, optional + + Returns: .. py:function:: single_parameter_sweep(base_design_configuration: dict, parameter_name: str, parameter_sweep_values: list) @@ -789,17 +849,17 @@ Attributes :rtype: parameter_sweep_design_dictionary_array(list) -.. py:function:: create_setup_py(design_directory: piel.config.piel_path_types, project_name: Optional[str] = None, from_config_json: bool = True) -> None +.. py:function:: create_setup_py(design_directory: piel.types.PathTypes, project_name: Optional[str] = None, from_config_json: bool = True) -> None This function creates a setup.py file from the config.json file found in the design directory. :param design_directory: Design directory PATH or module name. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: None -.. py:function:: create_empty_piel_project(project_name: str, parent_directory: piel.config.piel_path_types) -> None +.. py:function:: create_empty_piel_project(project_name: str, parent_directory: piel.types.PathTypes) -> None This function creates an empty piel-structure project in the target directory. Structuring your files in this way enables the co-design and use of the tools supported by piel whilst maintaining the design flow ordered, @@ -810,7 +870,7 @@ Attributes :param project_name: Name of the project. :type project_name: str :param parent_directory: Parent directory of the project. - :type parent_directory: piel_path_types + :type parent_directory: PathTypes :returns: None @@ -822,22 +882,22 @@ Attributes TODO DOCS -.. py:function:: pip_install_local_module(module_path: piel.config.piel_path_types) +.. py:function:: pip_install_local_module(module_path: piel.types.PathTypes) This function installs a local module in editable mode. :param module_path: Path to the module to be installed. - :type module_path: piel_path_types + :type module_path: PathTypes :returns: None -.. py:function:: read_configuration(design_directory: piel.config.piel_path_types) -> dict +.. py:function:: read_configuration(design_directory: piel.types.PathTypes) -> dict This function reads the configuration file found in the design directory. :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: Configuration dictionary. :rtype: config_dictionary(dict) @@ -923,23 +983,23 @@ Attributes -.. py:function:: get_simulation_output_files_from_design(design_directory: piel.config.piel_path_types, extension: str = 'csv') +.. py:function:: get_simulation_output_files_from_design(design_directory: piel.types.PathTypes, extension: str = 'csv') This function returns a list of all the simulation output files in the design directory. :param design_directory: The path to the design directory. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: List of all the simulation output files in the design directory. :rtype: output_files (list) -.. py:function:: read_simulation_data(file_path: piel.config.piel_path_types) +.. py:function:: read_simulation_data(file_path: piel.types.PathTypes) This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. :param file_path: The path to the simulation data file. - :type file_path: piel_path_types + :type file_path: PathTypes :returns: The simulation data in a Pandas dataframe. :rtype: simulation_data (pd.DataFrame) @@ -1066,14 +1126,14 @@ Attributes Extracts the datetime from a given `run_path` and returns it as a string. -.. py:function:: find_all_design_runs(design_directory: piel.config.piel_path_types, run_name: str | None = None) -> list[pathlib.Path] +.. py:function:: find_all_design_runs(design_directory: piel.types.PathTypes, run_name: str | None = None) -> list[pathlib.Path] For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of OpenLane to use. Defaults to None. @@ -1085,14 +1145,14 @@ Attributes :rtype: list[pathlib.Path] -.. py:function:: find_latest_design_run(design_directory: piel.config.piel_path_types, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) +.. py:function:: find_latest_design_run(design_directory: piel.types.PathTypes, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of the run to return. Defaults to None. @@ -1104,20 +1164,20 @@ Attributes :rtype: (pathlib.Path, str) -.. py:function:: get_gds_path_from_design_run(design_directory: piel.config.piel_path_types, run_directory: piel.config.piel_path_types | None = None) -> pathlib.Path +.. py:function:: get_gds_path_from_design_run(design_directory: piel.types.PathTypes, run_directory: piel.types.PathTypes | None = None) -> pathlib.Path Returns the path to the final GDS generated by OpenLane. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_directory: The path to the run directory. Defaults to None. Otherwise gets the latest run. - :type run_directory: piel_path_types, optional + :type run_directory: PathTypes, optional :returns: The path to the final GDS :rtype: pathlib.Path -.. py:function:: get_design_run_version(run_directory: piel.config.piel_path_types) -> Literal[v1, v2] +.. py:function:: get_design_run_version(run_directory: piel.types.PathTypes) -> Literal[v1, v2] Returns the version of the design run. @@ -1247,7 +1307,7 @@ Attributes :rtype: configuration(dict) -.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.config.piel_path_types) -> None +.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.types.PathTypes) -> None Writes a `config.json` onto a `design_directory` @@ -1493,7 +1553,7 @@ Attributes :rtype: file_lines_raw (list) -.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.config.piel_path_types, target_prefix: str) +.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.types.PathTypes, target_prefix: str) Returns a dictionary of all the metrics for all the designs in the output directory. @@ -1509,7 +1569,7 @@ Attributes ``` :param output_directory: The path to the output directory. - :type output_directory: piel_path_types + :type output_directory: PathTypes :param target_prefix: The prefix of the designs to get the metrics for. :type target_prefix: str @@ -1517,25 +1577,25 @@ Attributes :rtype: dict -.. py:function:: read_metrics_openlane_v2(design_directory: piel.config.piel_path_types) -> dict +.. py:function:: read_metrics_openlane_v2(design_directory: piel.types.PathTypes) -> dict Read design metrics from OpenLane v2 run files. :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: Metrics dictionary. :rtype: dict -.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.config.piel_path_types = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) +.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.types.PathTypes = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) Runs the OpenLane v2 flow. :param configuration: OpenLane configuration dictionary. If none is present it will default to the config.json file on the design_directory. :type configuration: dict :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param parallel_asynchronous_run: Run the flow in parallel. :type parallel_asynchronous_run: bool :param only_generate_flow_setup: Only generate the flow setup. @@ -1545,12 +1605,12 @@ Attributes -.. py:function:: configure_ngspice_simulation(run_directory: piel.config.piel_path_types = '.') +.. py:function:: configure_ngspice_simulation(run_directory: piel.types.PathTypes = '.') This function configures the NGSPICE simulation for the circuit and returns a simulation class. :param run_directory: Directory where the simulation will be run - :type run_directory: piel_path_types + :type run_directory: PathTypes :returns: Configured NGSPICE simulation options :rtype: simulation_options diff --git a/docs/autoapi/piel/integration/amaranth_openlane/index.rst b/docs/autoapi/piel/integration/amaranth_openlane/index.rst index 80c05db5..45690506 100644 --- a/docs/autoapi/piel/integration/amaranth_openlane/index.rst +++ b/docs/autoapi/piel/integration/amaranth_openlane/index.rst @@ -22,7 +22,7 @@ Functions -.. py:function:: layout_amaranth_truth_table_through_openlane(amaranth_module: amaranth.Module, inputs_name_list: list[str], outputs_name_list: list[str], parent_directory: piel.config.piel_path_types, target_directory_name: Optional[str] = None, openlane_version: Literal[v1, v2] = 'v2', **kwargs) +.. py:function:: layout_amaranth_truth_table_through_openlane(amaranth_module: amaranth.Module, inputs_name_list: list[str], outputs_name_list: list[str], parent_directory: piel.types.PathTypes, target_directory_name: Optional[str] = None, openlane_version: Literal[v1, v2] = 'v2', **kwargs) This function implements an amaranth truth-table module through the openlane flow. There are several ways to implement a module. Fundamentally, this requires the verilog files to be generated from the openlane-module in a @@ -44,7 +44,7 @@ Functions :param outputs_name_list: List of output names. :type outputs_name_list: list[str] :param parent_directory: Parent directory PATH. - :type parent_directory: piel_path_types + :type parent_directory: PathTypes :param target_directory_name: Target directory name. If none is provided, it will default to the name of the amaranth elaboratable class. :type target_directory_name: Optional[str] :param openlane_version: OpenLane version. Defaults to ``v1``. diff --git a/docs/autoapi/piel/integration/gdsfactory_openlane/index.rst b/docs/autoapi/piel/integration/gdsfactory_openlane/index.rst index c8f74caa..be52ee9e 100644 --- a/docs/autoapi/piel/integration/gdsfactory_openlane/index.rst +++ b/docs/autoapi/piel/integration/gdsfactory_openlane/index.rst @@ -26,7 +26,7 @@ Functions -.. py:function:: create_gdsfactory_component_from_openlane(design_name_v1: str | None = None, design_directory: piel.config.piel_path_types | None = None, run_name: str | None = None, v1: bool = True) -> gdsfactory.Component +.. py:function:: create_gdsfactory_component_from_openlane(design_name_v1: str | None = None, design_directory: piel.types.PathTypes | None = None, run_name: str | None = None, v1: bool = True) -> gdsfactory.Component This function cretes a gdsfactory layout component that can be included in the network codesign of the device, or that can be used for interconnection codesign. @@ -35,7 +35,7 @@ Functions :param design_name_v1: Design name of the v1 design that can be found within `$OPENLANE_ROOT/""/designs`. :type design_name_v1: str :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: Name of the run to extract the GDS from. If None, it will look at the latest run. :type run_name: str :param v1: If True, it will import the design from the OpenLane v1 configuration. diff --git a/docs/autoapi/piel/integration/index.rst b/docs/autoapi/piel/integration/index.rst index 32496023..058af5e9 100644 --- a/docs/autoapi/piel/integration/index.rst +++ b/docs/autoapi/piel/integration/index.rst @@ -49,6 +49,7 @@ Functions piel.integration.fock_transition_probability_amplitude piel.integration.convert_2d_array_to_string piel.integration.convert_array_type + piel.integration.absolute_to_threshold @@ -58,9 +59,11 @@ Attributes .. autoapisummary:: piel.integration.array_types + piel.integration.tuple_int_type + piel.integration.package_array_types -.. py:function:: create_gdsfactory_component_from_openlane(design_name_v1: str | None = None, design_directory: piel.config.piel_path_types | None = None, run_name: str | None = None, v1: bool = True) -> gdsfactory.Component +.. py:function:: create_gdsfactory_component_from_openlane(design_name_v1: str | None = None, design_directory: piel.types.PathTypes | None = None, run_name: str | None = None, v1: bool = True) -> gdsfactory.Component This function cretes a gdsfactory layout component that can be included in the network codesign of the device, or that can be used for interconnection codesign. @@ -69,7 +72,7 @@ Attributes :param design_name_v1: Design name of the v1 design that can be found within `$OPENLANE_ROOT/""/designs`. :type design_name_v1: str :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: Name of the run to extract the GDS from. If None, it will look at the latest run. :type run_name: str :param v1: If True, it will import the design from the OpenLane v1 configuration. @@ -280,6 +283,14 @@ Attributes +.. py:data:: tuple_int_type + + + +.. py:data:: package_array_types + + + .. py:function:: convert_2d_array_to_string(list_2D: list[list]) This function is particularly useful to convert digital data when it is represented as a 2D array into a set of strings. @@ -297,6 +308,23 @@ Attributes >>> "0001" -.. py:function:: convert_array_type(array: array_types, output_type: Literal[qutip, jax, numpy, list, tuple]) +.. py:function:: convert_array_type(array: array_types, output_type: package_array_types) + + +.. py:function:: absolute_to_threshold(array: array_types, threshold: float = 1e-06, dtype_output: int | float | bool = int, output_array_type: package_array_types = 'jax') -> package_array_types + + This function converts the computed optical transmission arrays to single bit digital signals. + The function takes the absolute value of the array and compares it to a threshold to determine the digital signal. + + :param array: The optical transmission array of any dimension. + :type array: array_types + :param dtype_output: The output type. Defaults to int. + :type dtype_output: int | float | bool, optional + :param threshold: The threshold to compare the array to. Defaults to 1e-6. + :type threshold: float, optional + :param output_array_type: The output type. Defaults to "jax". + :type output_array_type: array_types, optional + + Returns: diff --git a/docs/autoapi/piel/integration/type_conversion/index.rst b/docs/autoapi/piel/integration/type_conversion/index.rst index fb10c546..41f48d4a 100644 --- a/docs/autoapi/piel/integration/type_conversion/index.rst +++ b/docs/autoapi/piel/integration/type_conversion/index.rst @@ -20,6 +20,7 @@ Functions piel.integration.type_conversion.convert_array_type piel.integration.type_conversion.convert_2d_array_to_string + piel.integration.type_conversion.absolute_to_threshold @@ -29,13 +30,23 @@ Attributes .. autoapisummary:: piel.integration.type_conversion.array_types + piel.integration.type_conversion.tuple_int_type + piel.integration.type_conversion.package_array_types .. py:data:: array_types -.. py:function:: convert_array_type(array: array_types, output_type: Literal[qutip, jax, numpy, list, tuple]) +.. py:data:: tuple_int_type + + + +.. py:data:: package_array_types + + + +.. py:function:: convert_array_type(array: array_types, output_type: package_array_types) .. py:function:: convert_2d_array_to_string(list_2D: list[list]) @@ -55,3 +66,20 @@ Attributes >>> "0001" +.. py:function:: absolute_to_threshold(array: array_types, threshold: float = 1e-06, dtype_output: int | float | bool = int, output_array_type: package_array_types = 'jax') -> package_array_types + + This function converts the computed optical transmission arrays to single bit digital signals. + The function takes the absolute value of the array and compares it to a threshold to determine the digital signal. + + :param array: The optical transmission array of any dimension. + :type array: array_types + :param dtype_output: The output type. Defaults to int. + :type dtype_output: int | float | bool, optional + :param threshold: The threshold to compare the array to. Defaults to 1e-6. + :type threshold: float, optional + :param output_array_type: The output type. Defaults to "jax". + :type output_array_type: array_types, optional + + Returns: + + diff --git a/docs/autoapi/piel/materials/electrical_resistivity/index.rst b/docs/autoapi/piel/materials/electrical_resistivity/index.rst new file mode 100644 index 00000000..42c71f88 --- /dev/null +++ b/docs/autoapi/piel/materials/electrical_resistivity/index.rst @@ -0,0 +1,6 @@ +:py:mod:`piel.materials.electrical_resistivity` +=============================================== + +.. py:module:: piel.materials.electrical_resistivity + + diff --git a/docs/autoapi/piel/materials/index.rst b/docs/autoapi/piel/materials/index.rst new file mode 100644 index 00000000..1d6cc6a7 --- /dev/null +++ b/docs/autoapi/piel/materials/index.rst @@ -0,0 +1,25 @@ +:py:mod:`piel.materials` +======================== + +.. py:module:: piel.materials + + +Subpackages +----------- +.. toctree:: + :titlesonly: + :maxdepth: 3 + + electrical_resistivity/index.rst + thermal_conductivity/index.rst + + +Submodules +---------- +.. toctree:: + :titlesonly: + :maxdepth: 1 + + silicon/index.rst + + diff --git a/docs/autoapi/piel/materials/silicon/index.rst b/docs/autoapi/piel/materials/silicon/index.rst new file mode 100644 index 00000000..0b563fa0 --- /dev/null +++ b/docs/autoapi/piel/materials/silicon/index.rst @@ -0,0 +1,258 @@ +:py:mod:`piel.materials.silicon` +================================ + +.. py:module:: piel.materials.silicon + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.silicon.k + piel.materials.silicon.epsilon_0 + piel.materials.silicon.h + piel.materials.silicon.T_a + piel.materials.silicon.epsilon_si + piel.materials.silicon.E_g_si_bardin + piel.materials.silicon.m_dh_green_h + piel.materials.silicon.m_l_askt_h + piel.materials.silicon.m_h_askt_h + piel.materials.silicon.m_so_askt_h + piel.materials.silicon.m_dh_askt_h + piel.materials.silicon.m_t_askt_e + piel.materials.silicon.m_ce_askt_e + piel.materials.silicon.m_de_askt_e + piel.materials.silicon.N_c + piel.materials.silicon.E_c + piel.materials.silicon.E_f + piel.materials.silicon.n_0 + piel.materials.silicon.N_v + piel.materials.silicon.p_0 + piel.materials.silicon.n_i + piel.materials.silicon.n_io + piel.materials.silicon.mu_0a_e + piel.materials.silicon.mu_0b_e + piel.materials.silicon.kappa_a_e + piel.materials.silicon.kappa_b_e + piel.materials.silicon.mu_0a_h + piel.materials.silicon.mu_0b_h + piel.materials.silicon.kappa_a_h + piel.materials.silicon.kappa_b_h + piel.materials.silicon.mu_ps_e + piel.materials.silicon.mu_ps_h + piel.materials.silicon.mu_min_e + piel.materials.silicon.N_ref_e + piel.materials.silicon.kappa_c_e + piel.materials.silicon.mu_min_h + piel.materials.silicon.N_ref_h + piel.materials.silicon.kappa_c_h + piel.materials.silicon.mu_psii_e + piel.materials.silicon.mu_psii_h + + + +.. py:function:: k() + + Return the Boltzmann constant in eV/K. + + +.. py:function:: epsilon_0() + + Return the permittivity of free space in F/m (Farads per meter). + + +.. py:function:: h() + + Return Planck's constant in J.s or eV.s. + + +.. py:function:: T_a() + + Return an array of ambient temperatures ranging from 0.1 to 300 K. + + +.. py:function:: epsilon_si() + + Return the permittivity of Silicon. + + +.. py:function:: E_g_si_bardin(T) + + Calculate the bandgap energy of silicon as a function of temperature. + + +.. py:function:: m_dh_green_h(T) + + Calculate the density of states effective mass for holes (Green) as a function of temperature. + + +.. py:function:: m_l_askt_h(T) + + Calculate the normalized light hole effective mass as a function of temperature. + + +.. py:function:: m_h_askt_h(T) + + Calculate the normalized heavy hole effective mass as a function of temperature. + + +.. py:function:: m_so_askt_h(T) + + Calculate the normalized split-off hole effective mass as a function of temperature. + + +.. py:function:: m_dh_askt_h(T) + + Calculate the density of states effective mass for holes as a function of temperature. + + +.. py:function:: m_t_askt_e(T) + + Calculate the transversal effective mass for electrons as a function of temperature. + + +.. py:function:: m_ce_askt_e(T) + + Calculate the effective conduction mass for electrons as a function of temperature. + + +.. py:function:: m_de_askt_e(T) + + Calculate the electron density-of-states effective mass as a function of temperature. + + +.. py:function:: N_c(T) + + Calculate the effective density of states in the conduction band as a function of temperature. + + +.. py:function:: E_c(T) + + Calculate the conduction band energy as a function of temperature. + + +.. py:function:: E_f(T) + + Calculate the Fermi level energy as a function of temperature. + + +.. py:function:: n_0(T) + + Calculate the electron concentration at equilibrium as a function of temperature. + + +.. py:function:: N_v(T) + + Calculate the effective density of states in the valence band as a function of temperature. + + +.. py:function:: p_0(T) + + Calculate the hole concentration at equilibrium as a function of temperature. + + +.. py:function:: n_i(T) + + Calculate the intrinsic carrier concentration as a function of temperature. + + +.. py:function:: n_io(T) + + Calculate the intrinsic carrier concentration for a given temperature using an alternative method. + + +.. py:function:: mu_0a_e() + + Return the parameter mu_0a for electron mobility. + + +.. py:function:: mu_0b_e() + + Return the parameter mu_0b for electron mobility. + + +.. py:function:: kappa_a_e() + + Return the exponent kappa_a for electron mobility. + + +.. py:function:: kappa_b_e() + + Return the exponent kappa_b for electron mobility. + + +.. py:function:: mu_0a_h() + + Return the parameter mu_0a for hole mobility. + + +.. py:function:: mu_0b_h() + + Return the parameter mu_0b for hole mobility. + + +.. py:function:: kappa_a_h() + + Return the exponent kappa_a for hole mobility. + + +.. py:function:: kappa_b_h() + + Return the exponent kappa_b for hole mobility. + + +.. py:function:: mu_ps_e(T) + + Calculate the electron mobility due to phonon scattering as a function of temperature. + + +.. py:function:: mu_ps_h(T) + + Calculate the hole mobility due to phonon scattering as a function of temperature. + + +.. py:function:: mu_min_e(T) + + Calculate the minimum electron mobility as a function of temperature. + + +.. py:function:: N_ref_e(T) + + Return the reference concentration N_ref for electrons as a function of temperature. + + +.. py:function:: kappa_c_e(T) + + Return the exponent kappa_c for electron mobility as a function of temperature. + + +.. py:function:: mu_min_h(T) + + Calculate the minimum hole mobility as a function of temperature. + + +.. py:function:: N_ref_h(T) + + Return the reference concentration N_ref for holes as a function of temperature. + + +.. py:function:: kappa_c_h(T) + + Return the exponent kappa_c for hole mobility as a function of temperature. + + +.. py:function:: mu_psii_e(T, N_I_e) + + Calculate the phonon scattering and ionized impurity electron scattering mobility. + + +.. py:function:: mu_psii_h(T, N_I_h) + + Calculate the phonon scattering and ionized impurity hole scattering mobility. + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/aluminum/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/aluminum/index.rst new file mode 100644 index 00000000..e63b1c17 --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/aluminum/index.rst @@ -0,0 +1,35 @@ +:py:mod:`piel.materials.thermal_conductivity.aluminum` +====================================================== + +.. py:module:: piel.materials.thermal_conductivity.aluminum + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.aluminum.aluminum + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.aluminum.material_references + + +.. py:data:: material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + + + +.. py:function:: aluminum(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material_reference: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) -> float + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/copper/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/copper/index.rst new file mode 100644 index 00000000..131f982a --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/copper/index.rst @@ -0,0 +1,35 @@ +:py:mod:`piel.materials.thermal_conductivity.copper` +==================================================== + +.. py:module:: piel.materials.thermal_conductivity.copper + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.copper.copper + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.copper.material_references + + +.. py:data:: material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + + + +.. py:function:: copper(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material_reference: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) -> piel.types.ArrayTypes + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/index.rst new file mode 100644 index 00000000..b0dfdf07 --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/index.rst @@ -0,0 +1,108 @@ +:py:mod:`piel.materials.thermal_conductivity` +============================================= + +.. py:module:: piel.materials.thermal_conductivity + + +Submodules +---------- +.. toctree:: + :titlesonly: + :maxdepth: 1 + + aluminum/index.rst + copper/index.rst + stainless_steel/index.rst + teflon/index.rst + types/index.rst + utils/index.rst + + +Package Contents +---------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.stainless_steel + piel.materials.thermal_conductivity.aluminum + piel.materials.thermal_conductivity.copper + piel.materials.thermal_conductivity.teflon + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.MaterialReferenceType + piel.materials.thermal_conductivity.MaterialReferencesTypes + piel.materials.thermal_conductivity.SpecificationType + piel.materials.thermal_conductivity.stainless_steel_material_references + piel.materials.thermal_conductivity.aluminum_material_references + piel.materials.thermal_conductivity.copper_material_references + piel.materials.thermal_conductivity.teflon_material_references + piel.materials.thermal_conductivity.material_references + + +.. py:function:: stainless_steel(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material_reference: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) + + +.. py:function:: aluminum(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material_reference: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) -> float + + +.. py:function:: copper(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material_reference: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) -> piel.types.ArrayTypes + + +.. py:function:: teflon(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, *args, **kwargs) + + Trade Names for FEP resins include DuPont Teflon™, Daikin Neoflon™, Dyneon Hostaflon™, NiFlon, Sinoflon. + Source: https://trc.nist.gov/cryogenics/materials/Teflon/Teflon_rev.htm + + :param temperature_range_K: + + Returns: + + + +.. py:data:: MaterialReferenceType + + + +.. py:data:: MaterialReferencesTypes + + + +.. py:data:: SpecificationType + + + +.. py:data:: stainless_steel_material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + + + +.. py:data:: aluminum_material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + + + +.. py:data:: copper_material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + + + +.. py:data:: teflon_material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + :value: [('teflon', None)] + + + +.. py:data:: material_references + + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/stainless_steel/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/stainless_steel/index.rst new file mode 100644 index 00000000..62d9e406 --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/stainless_steel/index.rst @@ -0,0 +1,35 @@ +:py:mod:`piel.materials.thermal_conductivity.stainless_steel` +============================================================= + +.. py:module:: piel.materials.thermal_conductivity.stainless_steel + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.stainless_steel.stainless_steel + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.stainless_steel.material_references + + +.. py:data:: material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + + + +.. py:function:: stainless_steel(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material_reference: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/teflon/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/teflon/index.rst new file mode 100644 index 00000000..a682d1e9 --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/teflon/index.rst @@ -0,0 +1,44 @@ +:py:mod:`piel.materials.thermal_conductivity.teflon` +==================================================== + +.. py:module:: piel.materials.thermal_conductivity.teflon + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.teflon.teflon + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.teflon.material_references + + +.. py:data:: material_references + :type: piel.materials.thermal_conductivity.types.MaterialReferencesTypes + :value: [('teflon', None)] + + + +.. py:function:: teflon(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, *args, **kwargs) + + Trade Names for FEP resins include DuPont Teflon™, Daikin Neoflon™, Dyneon Hostaflon™, NiFlon, Sinoflon. + Source: https://trc.nist.gov/cryogenics/materials/Teflon/Teflon_rev.htm + + :param temperature_range_K: + + Returns: + + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/types/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/types/index.rst new file mode 100644 index 00000000..6bbc07e1 --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/types/index.rst @@ -0,0 +1,21 @@ +:py:mod:`piel.materials.thermal_conductivity.types` +=================================================== + +.. py:module:: piel.materials.thermal_conductivity.types + + +Module Contents +--------------- + +.. py:data:: SpecificationType + + + +.. py:data:: MaterialReferenceType + + + +.. py:data:: MaterialReferencesTypes + + + diff --git a/docs/autoapi/piel/materials/thermal_conductivity/utils/index.rst b/docs/autoapi/piel/materials/thermal_conductivity/utils/index.rst new file mode 100644 index 00000000..2a2113b0 --- /dev/null +++ b/docs/autoapi/piel/materials/thermal_conductivity/utils/index.rst @@ -0,0 +1,29 @@ +:py:mod:`piel.materials.thermal_conductivity.utils` +=================================================== + +.. py:module:: piel.materials.thermal_conductivity.utils + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.materials.thermal_conductivity.utils.get_thermal_conductivity_fit + + + +.. py:function:: get_thermal_conductivity_fit(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, material: piel.materials.thermal_conductivity.types.MaterialReferenceType, *args, **kwargs) -> piel.types.ArrayTypes + + Get the thermal conductivity fit for a given material. + + :param temperature_range_K: + :param material: + + Returns: + + diff --git a/docs/autoapi/piel/models/frequency/defaults/index.rst b/docs/autoapi/piel/models/frequency/defaults/index.rst index 0051e916..eac821b2 100644 --- a/docs/autoapi/piel/models/frequency/defaults/index.rst +++ b/docs/autoapi/piel/models/frequency/defaults/index.rst @@ -17,7 +17,7 @@ Functions -.. py:function:: get_default_models(custom_defaults: dict | None = None, type: Literal[classical, quantum] = 'classical') -> dict +.. py:function:: get_default_models(custom_defaults: dict | None = None, type: Literal[classical, quantum, optical_logic_verification] = 'classical') -> dict Returns the default models dictionary. diff --git a/docs/autoapi/piel/models/frequency/index.rst b/docs/autoapi/piel/models/frequency/index.rst index 41c779bf..a1bae675 100644 --- a/docs/autoapi/piel/models/frequency/index.rst +++ b/docs/autoapi/piel/models/frequency/index.rst @@ -65,7 +65,7 @@ Functions :rtype: dict -.. py:function:: get_default_models(custom_defaults: dict | None = None, type: Literal[classical, quantum] = 'classical') -> dict +.. py:function:: get_default_models(custom_defaults: dict | None = None, type: Literal[classical, quantum, optical_logic_verification] = 'classical') -> dict Returns the default models dictionary. diff --git a/docs/autoapi/piel/models/frequency/photonic/index.rst b/docs/autoapi/piel/models/frequency/photonic/index.rst index dad7c2cf..fa8e3539 100644 --- a/docs/autoapi/piel/models/frequency/photonic/index.rst +++ b/docs/autoapi/piel/models/frequency/photonic/index.rst @@ -36,10 +36,11 @@ Functions piel.models.frequency.photonic.grating_coupler_simple piel.models.frequency.photonic.mmi1x2_50_50 piel.models.frequency.photonic.mmi2x2_50_50 - piel.models.frequency.photonic.ideal_active_waveguide + piel.models.frequency.photonic.active_waveguide piel.models.frequency.photonic.waveguide piel.models.frequency.photonic.simple_straight piel.models.frequency.photonic.lossless_straight + piel.models.frequency.photonic.ideal_lossless_active_waveguide @@ -61,7 +62,7 @@ Functions .. py:function:: mmi2x2_50_50() -.. py:function:: ideal_active_waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0, active_phase_rad=0.0) +.. py:function:: active_waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0, active_phase_rad=0.0) .. py:function:: waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0) @@ -73,3 +74,6 @@ Functions .. py:function:: lossless_straight() +.. py:function:: ideal_lossless_active_waveguide(active_phase_rad=0.0) + + diff --git a/docs/autoapi/piel/models/frequency/photonic/straight_waveguide/index.rst b/docs/autoapi/piel/models/frequency/photonic/straight_waveguide/index.rst index 21cee4de..a611b4ee 100644 --- a/docs/autoapi/piel/models/frequency/photonic/straight_waveguide/index.rst +++ b/docs/autoapi/piel/models/frequency/photonic/straight_waveguide/index.rst @@ -19,16 +19,17 @@ Functions .. autoapisummary:: piel.models.frequency.photonic.straight_waveguide.waveguide - piel.models.frequency.photonic.straight_waveguide.ideal_active_waveguide + piel.models.frequency.photonic.straight_waveguide.active_waveguide piel.models.frequency.photonic.straight_waveguide.simple_straight piel.models.frequency.photonic.straight_waveguide.lossless_straight + piel.models.frequency.photonic.straight_waveguide.ideal_lossless_active_waveguide .. py:function:: waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0) -.. py:function:: ideal_active_waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0, active_phase_rad=0.0) +.. py:function:: active_waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0, active_phase_rad=0.0) .. py:function:: simple_straight(length=10.0, width=0.5) @@ -37,3 +38,6 @@ Functions .. py:function:: lossless_straight() +.. py:function:: ideal_lossless_active_waveguide(active_phase_rad=0.0) + + diff --git a/docs/autoapi/piel/models/logic/electro_optic/index.rst b/docs/autoapi/piel/models/logic/electro_optic/index.rst index a474fcf2..2c3a15dd 100644 --- a/docs/autoapi/piel/models/logic/electro_optic/index.rst +++ b/docs/autoapi/piel/models/logic/electro_optic/index.rst @@ -11,6 +11,7 @@ Submodules :maxdepth: 1 signal_mapping/index.rst + types/index.rst Package Contents @@ -25,11 +26,20 @@ Functions piel.models.logic.electro_optic.bits_array_from_bits_amount piel.models.logic.electro_optic.convert_phase_array_to_bit_array piel.models.logic.electro_optic.find_nearest_bit_for_phase + piel.models.logic.electro_optic.format_electro_optic_fock_transition piel.models.logic.electro_optic.linear_bit_phase_map piel.models.logic.electro_optic.return_phase_array_from_data_series +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.models.logic.electro_optic.electro_optic_fock_state_type + + .. py:function:: bits_array_from_bits_amount(bits_amount: int, bit_format: Literal[int, str] = 'int') -> numpy.ndarray Returns an array of bits from a given amount of bits. @@ -81,6 +91,24 @@ Functions :rtype: bitstring(str) +.. py:function:: format_electro_optic_fock_transition(switch_state_array: piel.integration.type_conversion.array_types, input_fock_state_array: piel.integration.type_conversion.array_types, raw_output_state: piel.integration.type_conversion.array_types) -> piel.models.logic.electro_optic.types.electro_optic_fock_state_type + + Formats the electro-optic state into a standard electro_optic_fock_state_type format. This is useful for the + electro-optic model to ensure that the output state is in the correct format. The output state is a dictionary + that contains the phase, input fock state, and output fock state. The idea is that this will allow us to + standardise and compare the output states of the electro-optic model across multiple formats. + + :param switch_state_array: Array of switch states. + :type switch_state_array: array_types + :param input_fock_state_array: Array of valid input fock states. + :type input_fock_state_array: array_types + :param raw_output_state: Array of raw output state. + :type raw_output_state: array_types + + :returns: Electro-optic state. + :rtype: electro_optic_state(electro_optic_fock_state_type) + + .. py:function:: linear_bit_phase_map(bits_amount: int, final_phase_rad: float, initial_phase_rad: float = 0, return_dataframe: bool = True, quantization_error: float = 1e-06, bit_format: Literal[int, str] = 'int') -> dict | pandas.DataFrame Returns a linear direct mapping of bits to phase. @@ -110,3 +138,7 @@ Functions :rtype: phase_array(list) +.. py:data:: electro_optic_fock_state_type + + + diff --git a/docs/autoapi/piel/models/logic/electro_optic/signal_mapping/index.rst b/docs/autoapi/piel/models/logic/electro_optic/signal_mapping/index.rst index 05f149d8..ea8622e4 100644 --- a/docs/autoapi/piel/models/logic/electro_optic/signal_mapping/index.rst +++ b/docs/autoapi/piel/models/logic/electro_optic/signal_mapping/index.rst @@ -5,6 +5,7 @@ .. autoapi-nested-parse:: + TODO implement this function. In this function we implement different methods of mapping electronic signals to phase. One particular implementation of phase mapping would be: @@ -21,7 +22,8 @@ We can define the two corresponding angles that this would be. - A more complex implementation of phase mapping can be similar to a DAC mapping: a bitstring within a converter bit-size can map directly to a particular phase space within a particular mapping. + A more complex implementation of phase mapping can be similar to a DAC mapping: a bitstring within a converter + bit-size can map directly to a particular phase space within a particular mapping. @@ -39,6 +41,7 @@ Functions piel.models.logic.electro_optic.signal_mapping.find_nearest_bit_for_phase piel.models.logic.electro_optic.signal_mapping.linear_bit_phase_map piel.models.logic.electro_optic.signal_mapping.return_phase_array_from_data_series + piel.models.logic.electro_optic.signal_mapping.format_electro_optic_fock_transition @@ -122,3 +125,21 @@ Functions :rtype: phase_array(list) +.. py:function:: format_electro_optic_fock_transition(switch_state_array: piel.integration.type_conversion.array_types, input_fock_state_array: piel.integration.type_conversion.array_types, raw_output_state: piel.integration.type_conversion.array_types) -> piel.models.logic.electro_optic.types.electro_optic_fock_state_type + + Formats the electro-optic state into a standard electro_optic_fock_state_type format. This is useful for the + electro-optic model to ensure that the output state is in the correct format. The output state is a dictionary + that contains the phase, input fock state, and output fock state. The idea is that this will allow us to + standardise and compare the output states of the electro-optic model across multiple formats. + + :param switch_state_array: Array of switch states. + :type switch_state_array: array_types + :param input_fock_state_array: Array of valid input fock states. + :type input_fock_state_array: array_types + :param raw_output_state: Array of raw output state. + :type raw_output_state: array_types + + :returns: Electro-optic state. + :rtype: electro_optic_state(electro_optic_fock_state_type) + + diff --git a/docs/autoapi/piel/models/logic/electro_optic/types/index.rst b/docs/autoapi/piel/models/logic/electro_optic/types/index.rst new file mode 100644 index 00000000..34939ba4 --- /dev/null +++ b/docs/autoapi/piel/models/logic/electro_optic/types/index.rst @@ -0,0 +1,24 @@ +:py:mod:`piel.models.logic.electro_optic.types` +=============================================== + +.. py:module:: piel.models.logic.electro_optic.types + +.. autoapi-nested-parse:: + + This is the standard format of a corresponding output state for a given input state in the electro-optic model: + + output_state_0 = { + "phase": (switch_states[0],), + "input_fock_state": piel.convert_array_type(valid_input_fock_states[0], "tuple"), + "output_fock_state": piel.absolute_to_threshold(raw_output_state_0, output_array_type="tuple"), + } + + + +Module Contents +--------------- + +.. py:data:: electro_optic_fock_state_type + + + diff --git a/docs/autoapi/piel/models/physical/electrical/cable/index.rst b/docs/autoapi/piel/models/physical/electrical/cable/index.rst index 2cfeda4a..37d246e0 100644 --- a/docs/autoapi/piel/models/physical/electrical/cable/index.rst +++ b/docs/autoapi/piel/models/physical/electrical/cable/index.rst @@ -4,3 +4,101 @@ .. py:module:: piel.models.physical.electrical.cable +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.models.physical.electrical.cable.calculate_coaxial_cable_geometry + piel.models.physical.electrical.cable.define_coaxial_cable_materials + piel.models.physical.electrical.cable.calculate_coaxial_cable_heat_transfer + piel.models.physical.electrical.cable.calculate_dc_cable_geometry + piel.models.physical.electrical.cable.define_dc_cable_materials + piel.models.physical.electrical.cable.calculate_dc_cable_heat_transfer + + + +.. py:function:: calculate_coaxial_cable_geometry(length_m: float = 1, sheath_top_diameter_m: float = 0.001651, sheath_bottom_diameter_m: float = 0.001468, core_diameter_dimension: Literal[awg, metric] = 'metric', core_diameter_awg: piel.models.physical.electrical.types.Optional[float] = None, core_diameter_m: float = 0.002, **kwargs) -> piel.models.physical.electrical.types.CoaxialCableGeometryType + + Calculate the geometry of a coaxial cable. Defaults are based on the parameters of a TODO + + :param length_m: Length of the cable in meters. + :param sheath_top_diameter_m: Diameter of the top of the sheath in meters. + :param sheath_bottom_diameter_m: Diameter of the bottom of the sheath in meters. + :param core_diameter_dimension: Dimension of the core diameter. + :param core_diameter_awg: Core diameter in AWG. + :param core_diameter_m: Core diameter in meters. + :param \*\*kwargs: + + :returns: The geometry of the coaxial cable. + :rtype: CoaxialCableGeometryType + + +.. py:function:: define_coaxial_cable_materials(core_material: piel.models.physical.electrical.types.MaterialReferenceType, sheath_material: piel.models.physical.electrical.types.MaterialReferenceType, dielectric_material: piel.models.physical.electrical.types.MaterialReferenceType) -> piel.models.physical.electrical.types.CoaxialCableMaterialSpecificationType + + Define the materials of a coaxial cable. + + :param core_material: The material of the core. + :param sheath_material: The material of the sheath. + :param dielectric_material: The material of the dielectric. + + :returns: The material specification of the coaxial cable. + :rtype: CoaxialCableMaterialSpecificationType + + +.. py:function:: calculate_coaxial_cable_heat_transfer(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, geometry_class: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.CoaxialCableGeometryType], material_class: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.CoaxialCableMaterialSpecificationType], core_material: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.MaterialReferenceType] = None, sheath_material: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.MaterialReferenceType] = None, dielectric_material: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.MaterialReferenceType] = None) -> piel.models.physical.electrical.types.CoaxialCableHeatTransferType + + Calculate the heat transfer of a coaxial cable. + + :param temperature_range_K: The temperature range in Kelvin. + :param geometry_class: The geometry of the cable. + :param material_class: The material of the cable. + :param core_material: The material of the core. + :param sheath_material: The material of the sheath. + :param dielectric_material: The material of the dielectric. + + :returns: The heat transfer of the cable. + :rtype: CoaxialCableHeatTransferType + + +.. py:function:: calculate_dc_cable_geometry(length_m: float = 1, core_diameter_dimension: Literal[awg, metric] = 'metric', core_diameter_awg: piel.models.physical.electrical.types.Optional[float] = None, core_diameter_m: float = 0.002, *args, **kwargs) -> piel.models.physical.electrical.types.DCCableGeometryType + + Calculate the geometry of a DC cable. Defaults are based on the parameters of a TODO + + :param length_m: Length of the cable in meters. + :param core_diameter_dimension: Dimension of the core diameter. + :param core_diameter_awg: Core diameter in AWG. + :param core_diameter_m: Core diameter in meters. + :param \*\*kwargs: + + :returns: The geometry of the coaxial cable. + :rtype: CoaxialCableGeometryType + + +.. py:function:: define_dc_cable_materials(core_material: piel.models.physical.electrical.types.MaterialReferenceType) -> piel.models.physical.electrical.types.DCCableMaterialSpecificationType + + Define the materials of a coaxial cable. + + :param core_material: The material of the core. + + :returns: The material specification of the dc cable. + :rtype: DCCableMaterialSpecificationType + + +.. py:function:: calculate_dc_cable_heat_transfer(temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, geometry_class: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.DCCableGeometryType], material_class: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.DCCableMaterialSpecificationType], core_material: piel.models.physical.electrical.types.Optional[piel.models.physical.electrical.types.MaterialReferenceType] = None) -> piel.models.physical.electrical.types.DCCableHeatTransferType + + Calculate the heat transfer of a coaxial cable. + + :param temperature_range_K: The temperature range in Kelvin. + :param geometry_class: The geometry of the cable. + :param material_class: The material of the cable. + :param core_material: The material of the core. + + :returns: The heat transfer of the cable. + :rtype: DCCableHeatTransferType + + diff --git a/docs/autoapi/piel/models/physical/electrical/index.rst b/docs/autoapi/piel/models/physical/electrical/index.rst index 9976cba6..83ead321 100644 --- a/docs/autoapi/piel/models/physical/electrical/index.rst +++ b/docs/autoapi/piel/models/physical/electrical/index.rst @@ -11,5 +11,6 @@ Submodules :maxdepth: 1 cable/index.rst + types/index.rst diff --git a/docs/autoapi/piel/models/physical/electrical/types/index.rst b/docs/autoapi/piel/models/physical/electrical/types/index.rst new file mode 100644 index 00000000..15dae831 --- /dev/null +++ b/docs/autoapi/piel/models/physical/electrical/types/index.rst @@ -0,0 +1,179 @@ +:py:mod:`piel.models.physical.electrical.types` +=============================================== + +.. py:module:: piel.models.physical.electrical.types + + +Module Contents +--------------- + +Classes +~~~~~~~ + +.. autoapisummary:: + + piel.models.physical.electrical.types.CoaxialCableGeometryType + piel.models.physical.electrical.types.CoaxialCableHeatTransferType + piel.models.physical.electrical.types.CoaxialCableMaterialSpecificationType + piel.models.physical.electrical.types.DCCableGeometryType + piel.models.physical.electrical.types.DCCableHeatTransferType + piel.models.physical.electrical.types.DCCableMaterialSpecificationType + + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.models.physical.electrical.types.CableHeatTransferTypes + piel.models.physical.electrical.types.CableGeometryTypes + piel.models.physical.electrical.types.CableMaterialSpecificationTypes + + +.. py:class:: CoaxialCableGeometryType + + + Bases: :py:obj:`piel.types.QuantityType` + + The base class for all cable types. + + .. py:attribute:: core_cross_sectional_area_m2 + :type: Optional[float] + + The cross-sectional area of the core in meters squared. + + .. py:attribute:: length_m + :type: float + + The length of the cable in meters. + + .. py:attribute:: sheath_cross_sectional_area_m2 + :type: Optional[float] + + The cross-sectional area of the sheath in meters squared. + + .. py:attribute:: total_cross_sectional_area_m2 + :type: Optional[float] + + The total cross-sectional area of the cable in meters squared. + + +.. py:class:: CoaxialCableHeatTransferType + + + Bases: :py:obj:`piel.types.QuantityType` + + All units are in watts. + + .. py:attribute:: core + :type: Optional[float] + + The computed heat transfer in watts for the core of the cable. + + .. py:attribute:: sheath + :type: Optional[float] + + The computed heat transfer in watts for the sheath of the cable. + + .. py:attribute:: dielectric + :type: Optional[float] + + The computed heat transfer in watts for the dielectric of the cable. + + .. py:attribute:: total + :type: float + + The total computed heat transfer in watts for the cable. + + +.. py:class:: CoaxialCableMaterialSpecificationType + + + Bases: :py:obj:`piel.types.QuantityType` + + The base class for all cable types. + + .. py:attribute:: core + :type: Optional[piel.materials.thermal_conductivity.types.MaterialReferenceType] + + The material of the core. + + .. py:attribute:: sheath + :type: Optional[piel.materials.thermal_conductivity.types.MaterialReferenceType] + + The material of the sheath. + + .. py:attribute:: dielectric + :type: Optional[piel.materials.thermal_conductivity.types.MaterialReferenceType] + + The material of the dielectric. + + +.. py:class:: DCCableGeometryType + + + Bases: :py:obj:`piel.types.QuantityType` + + The base class for all cable types. + + .. py:attribute:: core_cross_sectional_area_m2 + :type: float + + The cross-sectional area of the core in meters squared. + + .. py:attribute:: length_m + :type: float + + The length of the cable in meters. + + .. py:attribute:: total_cross_sectional_area_m2 + :type: float + + The total cross-sectional area of the cable in meters squared. + + +.. py:class:: DCCableHeatTransferType + + + Bases: :py:obj:`piel.types.QuantityType` + + All units are in watts. + + .. py:attribute:: core + :type: Optional[float] + + The computed heat transfer in watts for the core of the cable. + + .. py:attribute:: total + :type: float + + The total computed heat transfer in watts for the cable. + + +.. py:class:: DCCableMaterialSpecificationType + + + Bases: :py:obj:`piel.types.QuantityType` + + The base class for all cable types. + + .. py:attribute:: core + :type: Optional[piel.materials.thermal_conductivity.types.MaterialReferenceType] + + The material of the core. + + +.. py:data:: CableHeatTransferTypes + + + +.. py:data:: CableGeometryTypes + + + +.. py:data:: CableMaterialSpecificationTypes + + + diff --git a/docs/autoapi/piel/models/physical/electronic/hva/index.rst b/docs/autoapi/piel/models/physical/electronic/hva/index.rst new file mode 100644 index 00000000..3f4a725e --- /dev/null +++ b/docs/autoapi/piel/models/physical/electronic/hva/index.rst @@ -0,0 +1,6 @@ +:py:mod:`piel.models.physical.electronic.hva` +============================================= + +.. py:module:: piel.models.physical.electronic.hva + + diff --git a/docs/autoapi/piel/models/physical/electronic/index.rst b/docs/autoapi/piel/models/physical/electronic/index.rst index e1899424..a7522e9b 100644 --- a/docs/autoapi/piel/models/physical/electronic/index.rst +++ b/docs/autoapi/piel/models/physical/electronic/index.rst @@ -12,9 +12,12 @@ Submodules capacitor/index.rst defaults/index.rst + hva/index.rst + lna/index.rst resistor/index.rst straight/index.rst taper/index.rst + types/index.rst via_stack/index.rst diff --git a/docs/autoapi/piel/models/physical/electronic/lna/index.rst b/docs/autoapi/piel/models/physical/electronic/lna/index.rst new file mode 100644 index 00000000..a07bcbf0 --- /dev/null +++ b/docs/autoapi/piel/models/physical/electronic/lna/index.rst @@ -0,0 +1,6 @@ +:py:mod:`piel.models.physical.electronic.lna` +============================================= + +.. py:module:: piel.models.physical.electronic.lna + + diff --git a/docs/autoapi/piel/models/physical/electronic/types/index.rst b/docs/autoapi/piel/models/physical/electronic/types/index.rst new file mode 100644 index 00000000..7d594b1f --- /dev/null +++ b/docs/autoapi/piel/models/physical/electronic/types/index.rst @@ -0,0 +1,67 @@ +:py:mod:`piel.models.physical.electronic.types` +=============================================== + +.. py:module:: piel.models.physical.electronic.types + + +Module Contents +--------------- + +Classes +~~~~~~~ + +.. autoapisummary:: + + piel.models.physical.electronic.types.LNAMetricsType + + + + +.. py:class:: LNAMetricsType + + + Bases: :py:obj:`piel.types.PielBaseModel` + + Low-noise amplifier metrics. + + .. py:attribute:: footprint_mm2 + :type: Optional[float] + + + + .. py:attribute:: bandwidth_Hz + :type: Optional[MinimumMaximumType] + + + + .. py:attribute:: noise_figure + :type: Optional[MinimumMaximumType] + + + + .. py:attribute:: power_consumption_mW + :type: Optional[MinimumMaximumType] + + + + .. py:attribute:: power_gain_dB + :type: Optional[MinimumMaximumType] + + + + .. py:attribute:: supply_voltage_V + :type: Optional[float] + + + + .. py:attribute:: technology_nm + :type: Optional[float] + + + + .. py:attribute:: technology_material + :type: Optional[str] + + + + diff --git a/docs/autoapi/piel/models/physical/geometry/index.rst b/docs/autoapi/piel/models/physical/geometry/index.rst index aca18d5e..bc4c78fc 100644 --- a/docs/autoapi/piel/models/physical/geometry/index.rst +++ b/docs/autoapi/piel/models/physical/geometry/index.rst @@ -14,12 +14,13 @@ Functions .. autoapisummary:: piel.models.physical.geometry.calculate_cross_sectional_area_m2 + piel.models.physical.geometry.awg_to_cross_sectional_area_m2 .. py:function:: calculate_cross_sectional_area_m2(diameter_m: float) -> float - Calculates the cross sectional area of a circle in meters squared. + Calculates the cross-sectional area of a circle in meters squared. :param diameter_m: Diameter of the circle in meters. :type diameter_m: float @@ -28,3 +29,14 @@ Functions :rtype: float +.. py:function:: awg_to_cross_sectional_area_m2(awg: int) -> float + + Converts an AWG value to the cross-sectional area in meters squared. + + :param awg: The AWG value to convert. + :type awg: int + + :returns: The cross-sectional area in meters squared. + :rtype: float + + diff --git a/docs/autoapi/piel/models/physical/index.rst b/docs/autoapi/piel/models/physical/index.rst index 3cdd0d2f..27f1e2c5 100644 --- a/docs/autoapi/piel/models/physical/index.rst +++ b/docs/autoapi/piel/models/physical/index.rst @@ -25,6 +25,7 @@ Submodules geometry/index.rst thermal/index.rst + types/index.rst units/index.rst @@ -37,14 +38,26 @@ Functions .. autoapisummary:: + piel.models.physical.awg_to_cross_sectional_area_m2 piel.models.physical.calculate_cross_sectional_area_m2 piel.models.physical.convert_awg_to_m2 +.. py:function:: awg_to_cross_sectional_area_m2(awg: int) -> float + + Converts an AWG value to the cross-sectional area in meters squared. + + :param awg: The AWG value to convert. + :type awg: int + + :returns: The cross-sectional area in meters squared. + :rtype: float + + .. py:function:: calculate_cross_sectional_area_m2(diameter_m: float) -> float - Calculates the cross sectional area of a circle in meters squared. + Calculates the cross-sectional area of a circle in meters squared. :param diameter_m: Diameter of the circle in meters. :type diameter_m: float diff --git a/docs/autoapi/piel/models/physical/thermal/index.rst b/docs/autoapi/piel/models/physical/thermal/index.rst index 1e1f40c8..e6daae11 100644 --- a/docs/autoapi/piel/models/physical/thermal/index.rst +++ b/docs/autoapi/piel/models/physical/thermal/index.rst @@ -17,6 +17,21 @@ Functions -.. py:function:: heat_transfer_1d_W(thermal_conductivity_fit, temperature_range_K, cross_sectional_area_m2, length_m) -> float +.. py:function:: heat_transfer_1d_W(thermal_conductivity_fit, temperature_range_K: piel.models.physical.types.TemperatureRangeTypes, cross_sectional_area_m2: float, length_m: float, *args, **kwargs) -> float + + Calculate the heat transfer in watts for a 1D system. The thermal conductivity is assumed to be a function of + temperature. + + .. math:: + + q = A \int_{T_1}^{T_2} k(T) dT + + :param thermal_conductivity_fit: + :param temperature_range_K: + :param cross_sectional_area_m2: + :param length_m: + + :returns: The heat transfer in watts for a 1D system. + :rtype: float diff --git a/docs/autoapi/piel/models/physical/types/index.rst b/docs/autoapi/piel/models/physical/types/index.rst new file mode 100644 index 00000000..d2a6ba64 --- /dev/null +++ b/docs/autoapi/piel/models/physical/types/index.rst @@ -0,0 +1,21 @@ +:py:mod:`piel.models.physical.types` +==================================== + +.. py:module:: piel.models.physical.types + + +Module Contents +--------------- + +.. py:data:: TemperatureRangeLimitType + + + +.. py:data:: TemperatureRangeArrayType + + + +.. py:data:: TemperatureRangeTypes + + + diff --git a/docs/autoapi/piel/models/transient/electronic/ideal_rc/index.rst b/docs/autoapi/piel/models/transient/electronic/ideal_rc/index.rst new file mode 100644 index 00000000..2a19d800 --- /dev/null +++ b/docs/autoapi/piel/models/transient/electronic/ideal_rc/index.rst @@ -0,0 +1,38 @@ +:py:mod:`piel.models.transient.electronic.ideal_rc` +=================================================== + +.. py:module:: piel.models.transient.electronic.ideal_rc + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.models.transient.electronic.ideal_rc.calculate_multistage_rc_performance + + + +.. py:function:: calculate_multistage_rc_performance(multistage_configuration: Optional[piel.models.transient.electronic.types.RCMultiStageConfigurationType] = None, switching_frequency_Hz: Optional[float] = 100000.0) + + Calculates the total energy and power consumption for charging and discharging + in a multistage RC configuration, as well as the transition energy and power consumption. + + :param multistage_configuration: A list of dictionaries containing the voltage and capacitance for each stage. + :type multistage_configuration: Optional[RCMultiStageConfigurationType] + :param switching_frequency_Hz: The switching frequency of the RC stages. + :type switching_frequency_Hz: Optional[float] + + :returns: + + - Total charge and discharge energy. + - Total charge and discharge power consumption. + - Transition energy. + - Transition power consumption. + :rtype: A tuple containing + + diff --git a/docs/autoapi/piel/models/transient/electronic/index.rst b/docs/autoapi/piel/models/transient/electronic/index.rst index 44e904aa..a8c2381b 100644 --- a/docs/autoapi/piel/models/transient/electronic/index.rst +++ b/docs/autoapi/piel/models/transient/electronic/index.rst @@ -4,3 +4,45 @@ .. py:module:: piel.models.transient.electronic +Submodules +---------- +.. toctree:: + :titlesonly: + :maxdepth: 1 + + ideal_rc/index.rst + types/index.rst + + +Package Contents +---------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + piel.models.transient.electronic.calculate_multistage_rc_performance + + + +.. py:function:: calculate_multistage_rc_performance(multistage_configuration: Optional[piel.models.transient.electronic.types.RCMultiStageConfigurationType] = None, switching_frequency_Hz: Optional[float] = 100000.0) + + Calculates the total energy and power consumption for charging and discharging + in a multistage RC configuration, as well as the transition energy and power consumption. + + :param multistage_configuration: A list of dictionaries containing the voltage and capacitance for each stage. + :type multistage_configuration: Optional[RCMultiStageConfigurationType] + :param switching_frequency_Hz: The switching frequency of the RC stages. + :type switching_frequency_Hz: Optional[float] + + :returns: + + - Total charge and discharge energy. + - Total charge and discharge power consumption. + - Transition energy. + - Transition power consumption. + :rtype: A tuple containing + + diff --git a/docs/autoapi/piel/models/transient/electronic/types/index.rst b/docs/autoapi/piel/models/transient/electronic/types/index.rst new file mode 100644 index 00000000..abbde61f --- /dev/null +++ b/docs/autoapi/piel/models/transient/electronic/types/index.rst @@ -0,0 +1,13 @@ +:py:mod:`piel.models.transient.electronic.types` +================================================ + +.. py:module:: piel.models.transient.electronic.types + + +Module Contents +--------------- + +.. py:data:: RCMultiStageConfigurationType + + + diff --git a/docs/autoapi/piel/project_structure/index.rst b/docs/autoapi/piel/project_structure/index.rst index 33335bc6..8b1ded28 100644 --- a/docs/autoapi/piel/project_structure/index.rst +++ b/docs/autoapi/piel/project_structure/index.rst @@ -26,17 +26,17 @@ Functions -.. py:function:: create_setup_py(design_directory: piel.config.piel_path_types, project_name: Optional[str] = None, from_config_json: bool = True) -> None +.. py:function:: create_setup_py(design_directory: piel.types.PathTypes, project_name: Optional[str] = None, from_config_json: bool = True) -> None This function creates a setup.py file from the config.json file found in the design directory. :param design_directory: Design directory PATH or module name. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: None -.. py:function:: create_empty_piel_project(project_name: str, parent_directory: piel.config.piel_path_types) -> None +.. py:function:: create_empty_piel_project(project_name: str, parent_directory: piel.types.PathTypes) -> None This function creates an empty piel-structure project in the target directory. Structuring your files in this way enables the co-design and use of the tools supported by piel whilst maintaining the design flow ordered, @@ -47,7 +47,7 @@ Functions :param project_name: Name of the project. :type project_name: str :param parent_directory: Parent directory of the project. - :type parent_directory: piel_path_types + :type parent_directory: PathTypes :returns: None @@ -59,22 +59,22 @@ Functions TODO DOCS -.. py:function:: pip_install_local_module(module_path: piel.config.piel_path_types) +.. py:function:: pip_install_local_module(module_path: piel.types.PathTypes) This function installs a local module in editable mode. :param module_path: Path to the module to be installed. - :type module_path: piel_path_types + :type module_path: PathTypes :returns: None -.. py:function:: read_configuration(design_directory: piel.config.piel_path_types) -> dict +.. py:function:: read_configuration(design_directory: piel.types.PathTypes) -> dict This function reads the configuration file found in the design directory. :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: Configuration dictionary. :rtype: config_dictionary(dict) diff --git a/docs/autoapi/piel/tools/amaranth/export/index.rst b/docs/autoapi/piel/tools/amaranth/export/index.rst index b10d428f..4350a81f 100644 --- a/docs/autoapi/piel/tools/amaranth/export/index.rst +++ b/docs/autoapi/piel/tools/amaranth/export/index.rst @@ -17,7 +17,7 @@ Functions -.. py:function:: generate_verilog_from_amaranth(amaranth_module: amaranth.Elaboratable, ports_list: list[str], target_file_name: str, target_directory: piel.config.piel_path_types, backend=verilog) -> None +.. py:function:: generate_verilog_from_amaranth(amaranth_module: amaranth.Elaboratable, ports_list: list[str], target_file_name: str, target_directory: piel.types.PathTypes, backend=verilog) -> None This function exports an amaranth module to either a defined path, or a project structure in the form of an imported multi-design module. @@ -31,7 +31,7 @@ Functions :param target_file_name: Target file name. :type target_file_name: str :param target_directory: Target directory PATH. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param backend: Backend to use. Defaults to ``verilog``. :type backend: amaranth.back.verilog diff --git a/docs/autoapi/piel/tools/amaranth/index.rst b/docs/autoapi/piel/tools/amaranth/index.rst index d0c6df75..5cdad9f0 100644 --- a/docs/autoapi/piel/tools/amaranth/index.rst +++ b/docs/autoapi/piel/tools/amaranth/index.rst @@ -54,7 +54,7 @@ Functions :returns: Generated amaranth module. -.. py:function:: generate_verilog_from_amaranth(amaranth_module: amaranth.Elaboratable, ports_list: list[str], target_file_name: str, target_directory: piel.config.piel_path_types, backend=verilog) -> None +.. py:function:: generate_verilog_from_amaranth(amaranth_module: amaranth.Elaboratable, ports_list: list[str], target_file_name: str, target_directory: piel.types.PathTypes, backend=verilog) -> None This function exports an amaranth module to either a defined path, or a project structure in the form of an imported multi-design module. @@ -68,14 +68,14 @@ Functions :param target_file_name: Target file name. :type target_file_name: str :param target_directory: Target directory PATH. - :type target_directory: piel_path_types + :type target_directory: PathTypes :param backend: Backend to use. Defaults to ``verilog``. :type backend: amaranth.back.verilog :returns: None -.. py:function:: verify_truth_table(truth_table_amaranth_module: amaranth.Elaboratable, truth_table_dictionary: dict, inputs: list, outputs: list, vcd_file_name: str, target_directory: piel.config.piel_path_types, implementation_type: Literal[combinatorial, sequential, memory] = 'combinatorial') +.. py:function:: verify_truth_table(truth_table_amaranth_module: amaranth.Elaboratable, truth_table_dictionary: dict, inputs: list, outputs: list, vcd_file_name: str, target_directory: piel.types.PathTypes, implementation_type: Literal[combinatorial, sequential, memory] = 'combinatorial') We will implement a function that tests the module to verify that the outputs generates match the truth table provided. diff --git a/docs/autoapi/piel/tools/amaranth/verify/index.rst b/docs/autoapi/piel/tools/amaranth/verify/index.rst index 67366838..5cfcbea6 100644 --- a/docs/autoapi/piel/tools/amaranth/verify/index.rst +++ b/docs/autoapi/piel/tools/amaranth/verify/index.rst @@ -17,7 +17,7 @@ Functions -.. py:function:: verify_truth_table(truth_table_amaranth_module: amaranth.Elaboratable, truth_table_dictionary: dict, inputs: list, outputs: list, vcd_file_name: str, target_directory: piel.config.piel_path_types, implementation_type: Literal[combinatorial, sequential, memory] = 'combinatorial') +.. py:function:: verify_truth_table(truth_table_amaranth_module: amaranth.Elaboratable, truth_table_dictionary: dict, inputs: list, outputs: list, vcd_file_name: str, target_directory: piel.types.PathTypes, implementation_type: Literal[combinatorial, sequential, memory] = 'combinatorial') We will implement a function that tests the module to verify that the outputs generates match the truth table provided. diff --git a/docs/autoapi/piel/tools/cocotb/data/index.rst b/docs/autoapi/piel/tools/cocotb/data/index.rst index e7569d72..55028904 100644 --- a/docs/autoapi/piel/tools/cocotb/data/index.rst +++ b/docs/autoapi/piel/tools/cocotb/data/index.rst @@ -36,23 +36,23 @@ Attributes -.. py:function:: get_simulation_output_files_from_design(design_directory: piel.config.piel_path_types, extension: str = 'csv') +.. py:function:: get_simulation_output_files_from_design(design_directory: piel.types.PathTypes, extension: str = 'csv') This function returns a list of all the simulation output files in the design directory. :param design_directory: The path to the design directory. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: List of all the simulation output files in the design directory. :rtype: output_files (list) -.. py:function:: read_simulation_data(file_path: piel.config.piel_path_types) +.. py:function:: read_simulation_data(file_path: piel.types.PathTypes) This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. :param file_path: The path to the simulation data file. - :type file_path: piel_path_types + :type file_path: PathTypes :returns: The simulation data in a Pandas dataframe. :rtype: simulation_data (pd.DataFrame) diff --git a/docs/autoapi/piel/tools/cocotb/index.rst b/docs/autoapi/piel/tools/cocotb/index.rst index 9505bbf2..dea6580b 100644 --- a/docs/autoapi/piel/tools/cocotb/index.rst +++ b/docs/autoapi/piel/tools/cocotb/index.rst @@ -121,23 +121,23 @@ Attributes -.. py:function:: get_simulation_output_files_from_design(design_directory: piel.config.piel_path_types, extension: str = 'csv') +.. py:function:: get_simulation_output_files_from_design(design_directory: piel.types.PathTypes, extension: str = 'csv') This function returns a list of all the simulation output files in the design directory. :param design_directory: The path to the design directory. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: List of all the simulation output files in the design directory. :rtype: output_files (list) -.. py:function:: read_simulation_data(file_path: piel.config.piel_path_types) +.. py:function:: read_simulation_data(file_path: piel.types.PathTypes) This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. :param file_path: The path to the simulation data file. - :type file_path: piel_path_types + :type file_path: PathTypes :returns: The simulation data in a Pandas dataframe. :rtype: simulation_data (pd.DataFrame) diff --git a/docs/autoapi/piel/tools/hdl21/index.rst b/docs/autoapi/piel/tools/hdl21/index.rst index d2abc80a..9bee0c56 100644 --- a/docs/autoapi/piel/tools/hdl21/index.rst +++ b/docs/autoapi/piel/tools/hdl21/index.rst @@ -32,12 +32,12 @@ Functions -.. py:function:: configure_ngspice_simulation(run_directory: piel.config.piel_path_types = '.') +.. py:function:: configure_ngspice_simulation(run_directory: piel.types.PathTypes = '.') This function configures the NGSPICE simulation for the circuit and returns a simulation class. :param run_directory: Directory where the simulation will be run - :type run_directory: piel_path_types + :type run_directory: PathTypes :returns: Configured NGSPICE simulation options :rtype: simulation_options diff --git a/docs/autoapi/piel/tools/hdl21/simulator/index.rst b/docs/autoapi/piel/tools/hdl21/simulator/index.rst index a840b47d..f6bba716 100644 --- a/docs/autoapi/piel/tools/hdl21/simulator/index.rst +++ b/docs/autoapi/piel/tools/hdl21/simulator/index.rst @@ -20,12 +20,12 @@ Functions -.. py:function:: configure_ngspice_simulation(run_directory: piel.config.piel_path_types = '.') +.. py:function:: configure_ngspice_simulation(run_directory: piel.types.PathTypes = '.') This function configures the NGSPICE simulation for the circuit and returns a simulation class. :param run_directory: Directory where the simulation will be run - :type run_directory: piel_path_types + :type run_directory: PathTypes :returns: Configured NGSPICE simulation options :rtype: simulation_options diff --git a/docs/autoapi/piel/tools/index.rst b/docs/autoapi/piel/tools/index.rst index cdc9551c..06b46508 100644 --- a/docs/autoapi/piel/tools/index.rst +++ b/docs/autoapi/piel/tools/index.rst @@ -193,23 +193,23 @@ Attributes -.. py:function:: get_simulation_output_files_from_design(design_directory: piel.config.piel_path_types, extension: str = 'csv') +.. py:function:: get_simulation_output_files_from_design(design_directory: piel.types.PathTypes, extension: str = 'csv') This function returns a list of all the simulation output files in the design directory. :param design_directory: The path to the design directory. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: List of all the simulation output files in the design directory. :rtype: output_files (list) -.. py:function:: read_simulation_data(file_path: piel.config.piel_path_types) +.. py:function:: read_simulation_data(file_path: piel.types.PathTypes) This function returns a Pandas dataframe that contains all the simulation data outputted from the simulation run. :param file_path: The path to the simulation data file. - :type file_path: piel_path_types + :type file_path: PathTypes :returns: The simulation data in a Pandas dataframe. :rtype: simulation_data (pd.DataFrame) @@ -336,14 +336,14 @@ Attributes Extracts the datetime from a given `run_path` and returns it as a string. -.. py:function:: find_all_design_runs(design_directory: piel.config.piel_path_types, run_name: str | None = None) -> list[pathlib.Path] +.. py:function:: find_all_design_runs(design_directory: piel.types.PathTypes, run_name: str | None = None) -> list[pathlib.Path] For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of OpenLane to use. Defaults to None. @@ -355,14 +355,14 @@ Attributes :rtype: list[pathlib.Path] -.. py:function:: find_latest_design_run(design_directory: piel.config.piel_path_types, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) +.. py:function:: find_latest_design_run(design_directory: piel.types.PathTypes, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of the run to return. Defaults to None. @@ -374,20 +374,20 @@ Attributes :rtype: (pathlib.Path, str) -.. py:function:: get_gds_path_from_design_run(design_directory: piel.config.piel_path_types, run_directory: piel.config.piel_path_types | None = None) -> pathlib.Path +.. py:function:: get_gds_path_from_design_run(design_directory: piel.types.PathTypes, run_directory: piel.types.PathTypes | None = None) -> pathlib.Path Returns the path to the final GDS generated by OpenLane. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_directory: The path to the run directory. Defaults to None. Otherwise gets the latest run. - :type run_directory: piel_path_types, optional + :type run_directory: PathTypes, optional :returns: The path to the final GDS :rtype: pathlib.Path -.. py:function:: get_design_run_version(run_directory: piel.config.piel_path_types) -> Literal[v1, v2] +.. py:function:: get_design_run_version(run_directory: piel.types.PathTypes) -> Literal[v1, v2] Returns the version of the design run. @@ -517,7 +517,7 @@ Attributes :rtype: configuration(dict) -.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.config.piel_path_types) -> None +.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.types.PathTypes) -> None Writes a `config.json` onto a `design_directory` @@ -763,7 +763,7 @@ Attributes :rtype: file_lines_raw (list) -.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.config.piel_path_types, target_prefix: str) +.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.types.PathTypes, target_prefix: str) Returns a dictionary of all the metrics for all the designs in the output directory. @@ -779,7 +779,7 @@ Attributes ``` :param output_directory: The path to the output directory. - :type output_directory: piel_path_types + :type output_directory: PathTypes :param target_prefix: The prefix of the designs to get the metrics for. :type target_prefix: str @@ -787,25 +787,25 @@ Attributes :rtype: dict -.. py:function:: read_metrics_openlane_v2(design_directory: piel.config.piel_path_types) -> dict +.. py:function:: read_metrics_openlane_v2(design_directory: piel.types.PathTypes) -> dict Read design metrics from OpenLane v2 run files. :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: Metrics dictionary. :rtype: dict -.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.config.piel_path_types = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) +.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.types.PathTypes = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) Runs the OpenLane v2 flow. :param configuration: OpenLane configuration dictionary. If none is present it will default to the config.json file on the design_directory. :type configuration: dict :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param parallel_asynchronous_run: Run the flow in parallel. :type parallel_asynchronous_run: bool :param only_generate_flow_setup: Only generate the flow setup. @@ -815,12 +815,12 @@ Attributes -.. py:function:: configure_ngspice_simulation(run_directory: piel.config.piel_path_types = '.') +.. py:function:: configure_ngspice_simulation(run_directory: piel.types.PathTypes = '.') This function configures the NGSPICE simulation for the circuit and returns a simulation class. :param run_directory: Directory where the simulation will be run - :type run_directory: piel_path_types + :type run_directory: PathTypes :returns: Configured NGSPICE simulation options :rtype: simulation_options diff --git a/docs/autoapi/piel/tools/openlane/index.rst b/docs/autoapi/piel/tools/openlane/index.rst index 175e3bbc..cb226b95 100644 --- a/docs/autoapi/piel/tools/openlane/index.rst +++ b/docs/autoapi/piel/tools/openlane/index.rst @@ -100,14 +100,14 @@ Functions Extracts the datetime from a given `run_path` and returns it as a string. -.. py:function:: find_all_design_runs(design_directory: piel.config.piel_path_types, run_name: str | None = None) -> list[pathlib.Path] +.. py:function:: find_all_design_runs(design_directory: piel.types.PathTypes, run_name: str | None = None) -> list[pathlib.Path] For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of OpenLane to use. Defaults to None. @@ -119,14 +119,14 @@ Functions :rtype: list[pathlib.Path] -.. py:function:: find_latest_design_run(design_directory: piel.config.piel_path_types, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) +.. py:function:: find_latest_design_run(design_directory: piel.types.PathTypes, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of the run to return. Defaults to None. @@ -138,20 +138,20 @@ Functions :rtype: (pathlib.Path, str) -.. py:function:: get_gds_path_from_design_run(design_directory: piel.config.piel_path_types, run_directory: piel.config.piel_path_types | None = None) -> pathlib.Path +.. py:function:: get_gds_path_from_design_run(design_directory: piel.types.PathTypes, run_directory: piel.types.PathTypes | None = None) -> pathlib.Path Returns the path to the final GDS generated by OpenLane. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_directory: The path to the run directory. Defaults to None. Otherwise gets the latest run. - :type run_directory: piel_path_types, optional + :type run_directory: PathTypes, optional :returns: The path to the final GDS :rtype: pathlib.Path -.. py:function:: get_design_run_version(run_directory: piel.config.piel_path_types) -> Literal[v1, v2] +.. py:function:: get_design_run_version(run_directory: piel.types.PathTypes) -> Literal[v1, v2] Returns the version of the design run. @@ -281,7 +281,7 @@ Functions :rtype: configuration(dict) -.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.config.piel_path_types) -> None +.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.types.PathTypes) -> None Writes a `config.json` onto a `design_directory` @@ -527,7 +527,7 @@ Functions :rtype: file_lines_raw (list) -.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.config.piel_path_types, target_prefix: str) +.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.types.PathTypes, target_prefix: str) Returns a dictionary of all the metrics for all the designs in the output directory. @@ -543,7 +543,7 @@ Functions ``` :param output_directory: The path to the output directory. - :type output_directory: piel_path_types + :type output_directory: PathTypes :param target_prefix: The prefix of the designs to get the metrics for. :type target_prefix: str @@ -551,25 +551,25 @@ Functions :rtype: dict -.. py:function:: read_metrics_openlane_v2(design_directory: piel.config.piel_path_types) -> dict +.. py:function:: read_metrics_openlane_v2(design_directory: piel.types.PathTypes) -> dict Read design metrics from OpenLane v2 run files. :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: Metrics dictionary. :rtype: dict -.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.config.piel_path_types = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) +.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.types.PathTypes = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) Runs the OpenLane v2 flow. :param configuration: OpenLane configuration dictionary. If none is present it will default to the config.json file on the design_directory. :type configuration: dict :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param parallel_asynchronous_run: Run the flow in parallel. :type parallel_asynchronous_run: bool :param only_generate_flow_setup: Only generate the flow setup. diff --git a/docs/autoapi/piel/tools/openlane/utils/index.rst b/docs/autoapi/piel/tools/openlane/utils/index.rst index d5093943..577b5171 100644 --- a/docs/autoapi/piel/tools/openlane/utils/index.rst +++ b/docs/autoapi/piel/tools/openlane/utils/index.rst @@ -27,14 +27,14 @@ Functions Extracts the datetime from a given `run_path` and returns it as a string. -.. py:function:: find_all_design_runs(design_directory: piel.config.piel_path_types, run_name: str | None = None) -> list[pathlib.Path] +.. py:function:: find_all_design_runs(design_directory: piel.types.PathTypes, run_name: str | None = None) -> list[pathlib.Path] For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of OpenLane to use. Defaults to None. @@ -46,14 +46,14 @@ Functions :rtype: list[pathlib.Path] -.. py:function:: find_latest_design_run(design_directory: piel.config.piel_path_types, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) +.. py:function:: find_latest_design_run(design_directory: piel.types.PathTypes, run_name: str | None = None, version: Literal[v1, v2] | None = None) -> (pathlib.Path, str) For a given `design_directory`, the `openlane` output can be found in the `runs` subdirectory. This function sorts the runs according to the default notations between both `openlane` and `openlane2` run formats. If a `run_name` is specified, then the function will return the exact run if it exists. Otherwise, it will return the latest run. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_name: The name of the run to return. Defaults to None. :type run_name: str, optional :param version: The version of the run to return. Defaults to None. @@ -65,20 +65,20 @@ Functions :rtype: (pathlib.Path, str) -.. py:function:: get_gds_path_from_design_run(design_directory: piel.config.piel_path_types, run_directory: piel.config.piel_path_types | None = None) -> pathlib.Path +.. py:function:: get_gds_path_from_design_run(design_directory: piel.types.PathTypes, run_directory: piel.types.PathTypes | None = None) -> pathlib.Path Returns the path to the final GDS generated by OpenLane. :param design_directory: The path to the design directory - :type design_directory: piel_path_types + :type design_directory: PathTypes :param run_directory: The path to the run directory. Defaults to None. Otherwise gets the latest run. - :type run_directory: piel_path_types, optional + :type run_directory: PathTypes, optional :returns: The path to the final GDS :rtype: pathlib.Path -.. py:function:: get_design_run_version(run_directory: piel.config.piel_path_types) -> Literal[v1, v2] +.. py:function:: get_design_run_version(run_directory: piel.types.PathTypes) -> Literal[v1, v2] Returns the version of the design run. diff --git a/docs/autoapi/piel/tools/openlane/v1/index.rst b/docs/autoapi/piel/tools/openlane/v1/index.rst index bbd6faa4..606213e2 100644 --- a/docs/autoapi/piel/tools/openlane/v1/index.rst +++ b/docs/autoapi/piel/tools/openlane/v1/index.rst @@ -145,7 +145,7 @@ Functions :rtype: configuration(dict) -.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.config.piel_path_types) -> None +.. py:function:: write_configuration_openlane_v1(configuration: dict, design_directory: piel.types.PathTypes) -> None Writes a `config.json` onto a `design_directory` diff --git a/docs/autoapi/piel/tools/openlane/v2/index.rst b/docs/autoapi/piel/tools/openlane/v2/index.rst index ecc5bcff..73e4c335 100644 --- a/docs/autoapi/piel/tools/openlane/v2/index.rst +++ b/docs/autoapi/piel/tools/openlane/v2/index.rst @@ -19,7 +19,7 @@ Functions -.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.config.piel_path_types, target_prefix: str) +.. py:function:: get_all_designs_metrics_openlane_v2(output_directory: piel.types.PathTypes, target_prefix: str) Returns a dictionary of all the metrics for all the designs in the output directory. @@ -35,7 +35,7 @@ Functions ``` :param output_directory: The path to the output directory. - :type output_directory: piel_path_types + :type output_directory: PathTypes :param target_prefix: The prefix of the designs to get the metrics for. :type target_prefix: str @@ -43,25 +43,25 @@ Functions :rtype: dict -.. py:function:: read_metrics_openlane_v2(design_directory: piel.config.piel_path_types) -> dict +.. py:function:: read_metrics_openlane_v2(design_directory: piel.types.PathTypes) -> dict Read design metrics from OpenLane v2 run files. :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :returns: Metrics dictionary. :rtype: dict -.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.config.piel_path_types = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) +.. py:function:: run_openlane_flow(configuration: dict | None = None, design_directory: piel.types.PathTypes = '.', parallel_asynchronous_run: bool = False, only_generate_flow_setup: bool = False) Runs the OpenLane v2 flow. :param configuration: OpenLane configuration dictionary. If none is present it will default to the config.json file on the design_directory. :type configuration: dict :param design_directory: Design directory PATH. - :type design_directory: piel_path_types + :type design_directory: PathTypes :param parallel_asynchronous_run: Run the flow in parallel. :type parallel_asynchronous_run: bool :param only_generate_flow_setup: Only generate the flow setup. diff --git a/docs/autoapi/piel/types/index.rst b/docs/autoapi/piel/types/index.rst new file mode 100644 index 00000000..2de04d0d --- /dev/null +++ b/docs/autoapi/piel/types/index.rst @@ -0,0 +1,61 @@ +:py:mod:`piel.types` +==================== + +.. py:module:: piel.types + +.. autoapi-nested-parse:: + + We create a set of parameters that can be used throughout the project for optimisation. + + The numerical solver is jax and is imported throughout the module. + + + +Module Contents +--------------- + +Classes +~~~~~~~ + +.. autoapisummary:: + + piel.types.PielBaseModel + + + + +Attributes +~~~~~~~~~~ + +.. autoapisummary:: + + piel.types.PathTypes + piel.types.ArrayTypes + + +.. py:data:: PathTypes + + + +.. py:data:: ArrayTypes + + + +.. py:class:: PielBaseModel + + + Bases: :py:obj:`pydantic.BaseModel` + + .. py:class:: Config + + + .. py:attribute:: arbitrary_types_allowed + :value: True + + + + + .. py:method:: supplied_parameters() + + + diff --git a/docs/autoapi/straight_waveguidecheckpoint/index.rst b/docs/autoapi/straight_waveguidecheckpoint/index.rst new file mode 100644 index 00000000..549f8f81 --- /dev/null +++ b/docs/autoapi/straight_waveguidecheckpoint/index.rst @@ -0,0 +1,43 @@ +:py:mod:`straight_waveguide-checkpoint` +======================================= + +.. py:module:: straight_waveguide-checkpoint + +.. autoapi-nested-parse:: + + Translated from https://github.com/flaport/sax or https://github.com/flaport/photontorch/tree/master + + + +Module Contents +--------------- + + +Functions +~~~~~~~~~ + +.. autoapisummary:: + + straight_waveguide-checkpoint.waveguide + straight_waveguide-checkpoint.ideal_active_waveguide + straight_waveguide-checkpoint.simple_straight + straight_waveguide-checkpoint.lossless_straight + straight_waveguide-checkpoint.active_lossless_straight + + + +.. py:function:: waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0) + + +.. py:function:: ideal_active_waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0, active_phase_rad=0.0) + + +.. py:function:: simple_straight(length=10.0, width=0.5) + + +.. py:function:: lossless_straight() + + +.. py:function:: active_lossless_straight(active_phase_rad=0.0) + + diff --git a/docs/examples.rst b/docs/examples.rst index 84fdbe42..34440785 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -17,3 +17,4 @@ Examples examples/05_quantum_integration_basics examples/06_component_codesign_basics examples/07_mixed_signal_photonic_cosimulation + examples/08_basic_interconnection_modelling diff --git a/docs/examples/08_basic_interconnection_modelling.py b/docs/examples/08_basic_interconnection_modelling.py new file mode 100644 index 00000000..e29048d4 --- /dev/null +++ b/docs/examples/08_basic_interconnection_modelling.py @@ -0,0 +1,137 @@ +# # Basic Interconnection Modelling +# +# It is very difficult to design an electronic-photonic system without actually *connecting* them together. As it turns out, interconnection modelling is crucial in understanding the scaling of these systems. +# +# We might want to model: +# +# - Interconnection effects of electro-optic switches with their transmission line, or transmission lines towards RF analog modulation +# - Path-length matched digital transmission lines to an amplifier +# - The transmission line from a detector diode to the low-noise amplifier before an analogue-to-digital converter. +# - Electronic to photonic chip bonding. +# +# An important aspect to note is that the computational architecture is designed to have the minimal amouunt of operations being computed for a given type of modelling, and this means the modelling speed is as fast as can be for a given operation within a python implementation, pending further toolset implementations. +# +# As such, understanding interconnection effects turns out to be pretty important in these type of systems. + +import numpy as np +import piel +from piel.models.physical.electrical.cable import calculate_coaxial_cable_geometry, calculate_coaxial_cable_heat_transfer, calculate_dc_cable_geometry +from piel.models.physical.electrical.types import CoaxialCableGeometryType, CoaxialCableMaterialSpecificationType + +# ## Starting from the Basics + +# ### Modelling a DC Wire +# +# Let's take the most basic example to physically verify that the numerical functional implementation gives accurate results in terms of calculating the corresponding heat transfer. We will also do some analytical comparisons: + +basic_dc_cable = calculate_dc_cable_geometry( + length_m = 1, + core_diameter_m = 1e-3, +) +basic_dc_cable + +# ### Modelling a Coaxial Cable +# +# #### Thermal Heat Transfer +# +# Note that we have strongly-typed classes in order to manage the data containers across multiple functions. This enables flexibly extending the corresponding implementations. + +basic_coaxial_cable = calculate_coaxial_cable_geometry( + length_m = 1, + sheath_top_diameter_m = 1.651e-3, + sheath_bottom_diameter_m = 1.468e-3, + core_diameter_m = 2e-3, +) +basic_coaxial_cable + +# ``` +# CoaxialCableGeometryType(core_cross_sectional_area_m2=3.141592653589793e-06, length_m=1.0, sheath_cross_sectional_area_m2=4.482872075095052e-07, total_cross_sectional_area_m2=3.5898798610992983e-06) +# ``` + +# You can also run the help function to learn more of the corresponding class, on top of the existing documentation. + +# + +# help(CoaxialCableGeometryType) +# - + +# Now, let's apply each section with materials. First, let's work out what are all the current supported materials specifications (feel free to contribute!). Note that this is always specific to the corresponding property. + +from piel.materials.thermal_conductivity import material_references as thermal_conductivity_material_references + +thermal_conductivity_material_references + +# ``` +# [('stainless_steel', '304'), +# ('stainless_steel', '310'), +# ('stainless_steel', '316'), +# ('aluminum', '1100'), +# ('copper', 'rrr50'), +# ('copper', 'rrr100'), +# ('copper', 'rrr150'), +# ('copper', 'rrr300'), +# ('copper', 'rrr500'), +# ('teflon', None)] +# ``` + +# It is pretty straightforward to define a corresponding coaxial-cable material specification accordingly with the static `CoaxialCableMaterialSpecificationType` container: + +basic_coaxial_cable_materials = CoaxialCableMaterialSpecificationType( + core=('copper', 'rrr50'), + sheath=('copper', 'rrr50'), + dielectric=('teflon', None) +) +basic_coaxial_cable_materials + +# ``` +# CoaxialCableMaterialSpecificationType(core=('copper', 'rrr50'), sheath=('copper', 'rrr50'), dielectric=('teflon', None)) +# ``` + +# Now, let's assume we have a coaxial cable that goes from room temperature to cryogenic temperatures. Say, a cable inside a cryostat that goes from 273K to 70K. Let's work out how much thermal heat transfer occurs in between these stages in Watts. + +temperature_range_limits_K = tuple([70, 273]) + +basic_coaxial_cable_heat_transfer = calculate_coaxial_cable_heat_transfer( + temperature_range_K=temperature_range_limits_K, + geometry_class=basic_coaxial_cable, + material_class=basic_coaxial_cable_materials, +) +basic_coaxial_cable_heat_transfer + +# ``` +# CoaxialCableHeatTransferType(core=0.0019091610845816964, sheath=0.0019091610845816964, dielectric=0.00018867678408072714, total=0.00400699895324412) +# ``` + +# ### Larger System Modelling + +# Modelling the heat transfer of multiple coaxial cables in parallel in a system involves basic python operations:s + +parallel_cables_amount = 4 +4 * basic_coaxial_cable_heat_transfer.total + +# ``` +# 0.01602799581297648 +# ``` + +# Modelling the heat transfer of 4 cables in series, just involves making the cable in series: + +# + +basic_coaxial_cable_4_in_series = calculate_coaxial_cable_geometry( + length_m = 1 * 4, + sheath_top_diameter_m = 1.651e-3, + sheath_bottom_diameter_m = 1.468e-3, + core_diameter_m = 2e-3, +) + +basic_coaxial_cable_heat_transfer_4_in_series = calculate_coaxial_cable_heat_transfer( + temperature_range_K=temperature_range_limits_K, + geometry_class=basic_coaxial_cable_4_in_series, + material_class=basic_coaxial_cable_materials, +) +basic_coaxial_cable_heat_transfer_4_in_series +# - + +# ``` +# CoaxialCableHeatTransferType(core=0.0004772902711454241, sheath=0.0004772902711454241, dielectric=4.7169196020181784e-05, total=0.00100174973831103) +# ``` + + diff --git a/piel/__init__.py b/piel/__init__.py index b9b84f25..fc6a0964 100644 --- a/piel/__init__.py +++ b/piel/__init__.py @@ -5,7 +5,7 @@ # Libraries from piel import models # NOQA: F401 from piel import visual # NOQA: F401 -from piel import materials # NOQA: F401 +from piel import materials # NOQA: F401 # Functions @@ -16,7 +16,6 @@ from .project_structure import * from .tools import * - os.environ["PIEL_PACKAGE_DIRECTORY"] = str( pathlib.Path(__file__).parent.parent.resolve() ) diff --git a/piel/materials/thermal_conductivity/__init__.py b/piel/materials/thermal_conductivity/__init__.py index 09535f77..42cdea15 100644 --- a/piel/materials/thermal_conductivity/__init__.py +++ b/piel/materials/thermal_conductivity/__init__.py @@ -2,3 +2,16 @@ from .aluminum import aluminum from .copper import copper from .teflon import teflon +from .types import * + +from .stainless_steel import material_references as stainless_steel_material_references +from .aluminum import material_references as aluminum_material_references +from .copper import material_references as copper_material_references +from .teflon import material_references as teflon_material_references + +material_references = ( + stainless_steel_material_references + + aluminum_material_references + + copper_material_references + + teflon_material_references +) diff --git a/piel/materials/thermal_conductivity/aluminum.py b/piel/materials/thermal_conductivity/aluminum.py index 8984c595..4ce2ac0d 100644 --- a/piel/materials/thermal_conductivity/aluminum.py +++ b/piel/materials/thermal_conductivity/aluminum.py @@ -1,16 +1,24 @@ from typing import Literal import jax.numpy as jnp from piel.types import ArrayTypes +from .types import MaterialReferenceType, MaterialReferencesTypes +from ...models.physical.types import TemperatureRangeTypes -supported_specifications = Literal["1100"] +__all__ = ["aluminum", "material_references"] -__all__ = ["aluminum"] +supported_specifications = ["1100",] +material_references: MaterialReferencesTypes = [ + ("aluminum", specification_i) for specification_i in supported_specifications +] def aluminum( - temperature_range_K: ArrayTypes, - specification: supported_specifications = "1100" + temperature_range_K: TemperatureRangeTypes, + material_reference: MaterialReferenceType, + *args, + **kwargs ) -> float: + specification = material_reference[1] if specification == "1100": thermal_conductivity_fit = jnp.power(10, 23.39172 diff --git a/piel/materials/thermal_conductivity/copper.py b/piel/materials/thermal_conductivity/copper.py index 87c8b5ac..12b52707 100644 --- a/piel/materials/thermal_conductivity/copper.py +++ b/piel/materials/thermal_conductivity/copper.py @@ -3,20 +3,29 @@ from typing import Literal import piel -from piel.types import ArrayTypes, PathTypes +from ...types import ArrayTypes +from .types import MaterialReferencesTypes, MaterialReferenceType +from ...models.physical.types import TemperatureRangeTypes # CURRENT TODO: finish migrating this, add material sub names, add proper export, put into __init__ -__all__ = ["copper"] +__all__ = ["copper", "material_references"] -supported_specifications = Literal["rrr50", "rrr100", "rrr150", "rrr300", "rrr500"] +supported_specifications = ["rrr50", "rrr100", "rrr150", "rrr300", "rrr500"] +material_references: MaterialReferencesTypes = [ + ("copper", specification_i) for specification_i in supported_specifications +] def copper( - temperature_range_K: ArrayTypes, - specification: supported_specifications, -) -> jnp.ndarray: - copper_thermal_conductivity_file = piel.return_path(__file__).parent / "data" / "ofhc_copper_thermal_conductivity.csv" + temperature_range_K: TemperatureRangeTypes, + material_reference: MaterialReferenceType, + *args, + **kwargs +) -> ArrayTypes: + specification = material_reference[1] + copper_thermal_conductivity_file = piel.return_path( + __file__).parent / "data" / "ofhc_copper_thermal_conductivity.csv" assert copper_thermal_conductivity_file.exists() thermal_conductivity_material_dataset = pd.read_csv( copper_thermal_conductivity_file diff --git a/piel/materials/thermal_conductivity/stainless_steel.py b/piel/materials/thermal_conductivity/stainless_steel.py index c344a2fd..85d816a1 100644 --- a/piel/materials/thermal_conductivity/stainless_steel.py +++ b/piel/materials/thermal_conductivity/stainless_steel.py @@ -1,12 +1,32 @@ import jax.numpy as jnp from typing import Literal +from .types import MaterialReferencesTypes, MaterialReferenceType +from ...models.physical.types import TemperatureRangeTypes -__all__ = ["stainless_steel"] +__all__ = ["stainless_steel", "material_references"] -supported_specifications = Literal["304", "310", "316"] +supported_specifications = ["304", "310", "316"] +material_references: MaterialReferencesTypes = [ + ("stainless_steel", specification_i) for specification_i in supported_specifications +] -def stainless_steel(temperature_range_K, material_sub_name): +def stainless_steel( + temperature_range_K: TemperatureRangeTypes, + material_reference: MaterialReferenceType, + *args, + **kwargs +): + try: + specification = material_reference[1] + material_sub_name = specification[1] + except IndexError: + raise ValueError("Invalid specification for stainless steel: " + + specification + + ". Valid options are: " + + str(supported_specifications) + ) + if material_sub_name == "304": # https://trc.nist.gov/cryogenics/materials/304Stainless/304Stainless_rev.htm thermal_conductivity_fit = 10 ** ( diff --git a/piel/materials/thermal_conductivity/teflon.py b/piel/materials/thermal_conductivity/teflon.py index 2600c44c..26fddc1e 100644 --- a/piel/materials/thermal_conductivity/teflon.py +++ b/piel/materials/thermal_conductivity/teflon.py @@ -1,9 +1,17 @@ import jax.numpy as jnp +from .types import MaterialReferenceType, MaterialReferencesTypes +from ...models.physical.types import TemperatureRangeTypes +__all__ = ["teflon", "material_references"] -__all__ = ["teflon"] +material_references: MaterialReferencesTypes = [("teflon", None), ] -def teflon(temperature_range_K): + +def teflon( + temperature_range_K: TemperatureRangeTypes, + *args, + **kwargs +): """ Trade Names for FEP resins include DuPont Teflon™, Daikin Neoflon™, Dyneon Hostaflon™, NiFlon, Sinoflon. Source: https://trc.nist.gov/cryogenics/materials/Teflon/Teflon_rev.htm diff --git a/piel/materials/thermal_conductivity/types.py b/piel/materials/thermal_conductivity/types.py new file mode 100644 index 00000000..daacb5db --- /dev/null +++ b/piel/materials/thermal_conductivity/types.py @@ -0,0 +1,11 @@ +from typing import Literal, Optional + +__all__ = [ + "MaterialReferenceType", + "MaterialReferencesTypes", + "SpecificationType", +] + +SpecificationType = Literal +MaterialReferenceType = tuple[str, Optional[str]] +MaterialReferencesTypes = list[MaterialReferenceType] diff --git a/piel/materials/thermal_conductivity/utils.py b/piel/materials/thermal_conductivity/utils.py new file mode 100644 index 00000000..b82f9134 --- /dev/null +++ b/piel/materials/thermal_conductivity/utils.py @@ -0,0 +1,53 @@ +import numpy as np +from piel.types import ArrayTypes +from piel.models.physical.types import TemperatureRangeTypes +from piel.materials.thermal_conductivity.types import MaterialReferenceType +from piel.models.physical.types import TemperatureRangeLimitType +from piel.materials import thermal_conductivity + +__all__ = ["get_thermal_conductivity_fit"] + + +def get_thermal_conductivity_fit( + temperature_range_K: TemperatureRangeTypes, + material: MaterialReferenceType, + *args, + **kwargs +) -> ArrayTypes: + """ + Get the thermal conductivity fit for a given material. + + Args: + temperature_range_K: + material: + + Returns: + """ + material_name = material[0] + + if type(temperature_range_K) is tuple: + # TODO how to compare this with the TemperatureRangeLimitType? + temperature_range_K = np.linspace( + temperature_range_K[0], temperature_range_K[1], num=1000, + *args, + **kwargs + ) + elif isinstance(temperature_range_K, ArrayTypes): + pass + else: + raise ValueError("Invalid temperature_range_K type. Must be a TemperatureRangeType.") + + if material_name == "copper": + return thermal_conductivity.copper(temperature_range_K=temperature_range_K, + material_reference=material) + if material_name == "stainless_steel": + return thermal_conductivity.stainless_steel(temperature_range_K=temperature_range_K, + material_reference=material) + if material_name == "aluminum": + return thermal_conductivity.aluminum(temperature_range_K=temperature_range_K, + material_reference=material) + if material_name == "teflon": + return thermal_conductivity.teflon(temperature_range_K=temperature_range_K, + material_reference=material) + else: + raise ValueError(f"Material {material_name} not supported.") diff --git a/piel/models/physical/electrical/cable.py b/piel/models/physical/electrical/cable.py index e69de29b..50fdb325 100644 --- a/piel/models/physical/electrical/cable.py +++ b/piel/models/physical/electrical/cable.py @@ -0,0 +1,238 @@ +from typing import Optional, Literal + +from ..geometry import calculate_cross_sectional_area_m2, awg_to_cross_sectional_area_m2 +from ..thermal import heat_transfer_1d_W +from ....materials.thermal_conductivity.types import MaterialReferenceType +from piel.materials.thermal_conductivity.utils import get_thermal_conductivity_fit +from .types import * +from ..types import TemperatureRangeTypes + + +def calculate_coaxial_cable_geometry( + length_m: float = 1, + sheath_top_diameter_m: float = 1.651e-3, + sheath_bottom_diameter_m: float = 1.468e-3, + core_diameter_dimension: Literal["awg", "metric"] = "metric", + core_diameter_awg: Optional[float] = None, + core_diameter_m: float = 2e-3, + **kwargs +) -> CoaxialCableGeometryType: + """ + Calculate the geometry of a coaxial cable. Defaults are based on the parameters of a TODO + + Args: + length_m: Length of the cable in meters. + sheath_top_diameter_m: Diameter of the top of the sheath in meters. + sheath_bottom_diameter_m: Diameter of the bottom of the sheath in meters. + core_diameter_dimension: Dimension of the core diameter. + core_diameter_awg: Core diameter in AWG. + core_diameter_m: Core diameter in meters. + **kwargs: + + Returns: + CoaxialCableGeometryType: The geometry of the coaxial cable. + """ + + if core_diameter_dimension == "awg": + core_diameter_m = awg_to_cross_sectional_area_m2(core_diameter_awg) + + core_cross_sectional_area_m2 = calculate_cross_sectional_area_m2(diameter_m=core_diameter_m) + sheath_cross_sectional_area_m2 = calculate_cross_sectional_area_m2( + diameter_m=sheath_top_diameter_m) - calculate_cross_sectional_area_m2(diameter_m=sheath_bottom_diameter_m) + total_cross_sectional_area_m2 = core_cross_sectional_area_m2 + sheath_cross_sectional_area_m2 # TODO dielectric + + return CoaxialCableGeometryType( + length_m=length_m, + core_cross_sectional_area_m2=core_cross_sectional_area_m2, + sheath_cross_sectional_area_m2=sheath_cross_sectional_area_m2, + total_cross_sectional_area_m2=total_cross_sectional_area_m2, + **kwargs + ) + + +def define_coaxial_cable_materials( + core_material: MaterialReferenceType, + sheath_material: MaterialReferenceType, + dielectric_material: MaterialReferenceType, +) -> CoaxialCableMaterialSpecificationType: + """ + Define the materials of a coaxial cable. + + Args: + core_material: The material of the core. + sheath_material: The material of the sheath. + dielectric_material: The material of the dielectric. + + Returns: + CoaxialCableMaterialSpecificationType: The material specification of the coaxial cable. + """ + return CoaxialCableMaterialSpecificationType( + core=core_material, + sheath=sheath_material, + dielectric=dielectric_material + ) + + +def calculate_coaxial_cable_heat_transfer( + temperature_range_K: TemperatureRangeTypes, + geometry_class: Optional[CoaxialCableGeometryType], + material_class: Optional[CoaxialCableMaterialSpecificationType], + core_material: Optional[MaterialReferenceType] = None, + sheath_material: Optional[MaterialReferenceType] = None, + dielectric_material: Optional[MaterialReferenceType] = None, +) -> CoaxialCableHeatTransferType: + """ + Calculate the heat transfer of a coaxial cable. + + Args: + temperature_range_K: The temperature range in Kelvin. + geometry_class: The geometry of the cable. + material_class: The material of the cable. + core_material: The material of the core. + sheath_material: The material of the sheath. + dielectric_material: The material of the dielectric. + + Returns: + CoaxialCableHeatTransferType: The heat transfer of the cable. + """ + if material_class is not None: + provided_materials = material_class.supplied_parameters() + elif material_class is None: + material_class = CoaxialCableMaterialSpecificationType( + core=core_material, + sheath=sheath_material, + dielectric=dielectric_material + ) + provided_materials = material_class.supplied_parameters() + else: + raise ValueError("No material class or material parameters provided.") + + heat_transfer_parameters = dict() + total_heat_transfer_W = 0 + for material_i in provided_materials: + thermal_conductivity_fit_i = get_thermal_conductivity_fit( + temperature_range_K=temperature_range_K, + material=getattr(material_class, material_i) + ) + # CURRENT TODO compute the thermal conductivity fit accordingly. Implement a material reference to thermal conductivtiy data mapping. + + heat_transfer_i = heat_transfer_1d_W( + thermal_conductivity_fit=thermal_conductivity_fit_i, + temperature_range_K=temperature_range_K, + cross_sectional_area_m2=geometry_class.total_cross_sectional_area_m2, + length_m=geometry_class.length_m + ) + heat_transfer_parameters[material_i] = heat_transfer_i + total_heat_transfer_W += heat_transfer_i + heat_transfer_parameters["total"] = total_heat_transfer_W + + return CoaxialCableHeatTransferType( + **heat_transfer_parameters, + ) + + +def calculate_dc_cable_geometry( + length_m: float = 1, + core_diameter_dimension: Literal["awg", "metric"] = "metric", + core_diameter_awg: Optional[float] = None, + core_diameter_m: float = 2e-3, + *args, + **kwargs +) -> DCCableGeometryType: + """ + Calculate the geometry of a DC cable. Defaults are based on the parameters of a TODO + + Args: + length_m: Length of the cable in meters. + core_diameter_dimension: Dimension of the core diameter. + core_diameter_awg: Core diameter in AWG. + core_diameter_m: Core diameter in meters. + **kwargs: + + Returns: + CoaxialCableGeometryType: The geometry of the coaxial cable. + """ + + if core_diameter_dimension == "awg": + core_diameter_m = awg_to_cross_sectional_area_m2(core_diameter_awg) + + core_cross_sectional_area_m2 = calculate_cross_sectional_area_m2(diameter_m=core_diameter_m) + total_cross_sectional_area_m2 = core_cross_sectional_area_m2 + + return DCCableGeometryType( + length_m=length_m, + core_cross_sectional_area_m2=core_cross_sectional_area_m2, + total_cross_sectional_area_m2=total_cross_sectional_area_m2, + *args, + **kwargs, + ) + + +def define_dc_cable_materials( + core_material: MaterialReferenceType, +) -> DCCableMaterialSpecificationType: + """ + Define the materials of a coaxial cable. + + Args: + core_material: The material of the core. + + Returns: + DCCableMaterialSpecificationType: The material specification of the dc cable. + """ + return DCCableMaterialSpecificationType( + core=core_material, + ) + + +def calculate_dc_cable_heat_transfer( + temperature_range_K: TemperatureRangeTypes, + geometry_class: Optional[DCCableGeometryType], + material_class: Optional[DCCableMaterialSpecificationType], + core_material: Optional[MaterialReferenceType] = None, +) -> DCCableHeatTransferType: + """ + Calculate the heat transfer of a coaxial cable. + + Args: + temperature_range_K: The temperature range in Kelvin. + geometry_class: The geometry of the cable. + material_class: The material of the cable. + core_material: The material of the core. + + Returns: + DCCableHeatTransferType: The heat transfer of the cable. + """ + + if material_class is not None: + provided_materials = material_class.supplied_parameters() + elif material_class is None: + material_class = DCCableMaterialSpecificationType( + core=core_material, + ) + provided_materials = material_class.supplied_parameters() + else: + raise ValueError("No material class or material parameters provided.") + + heat_transfer_parameters = dict() + total_heat_transfer_W = 0 + for material_i in provided_materials: + thermal_conductivity_fit_i = get_thermal_conductivity_fit( + temperature_range_K=temperature_range_K, + material=getattr(material_class, material_i) + ) + # CURRENT TODO compute the thermal conductivity fit accordingly. Implement a material reference to thermal conductivtiy data mapping. + + heat_transfer_i = heat_transfer_1d_W( + thermal_conductivity_fit=thermal_conductivity_fit_i, + temperature_range_K=temperature_range_K, + cross_sectional_area_m2=geometry_class.total_cross_sectional_area_m2, + length_m=geometry_class.length_m + ) + heat_transfer_parameters[material_i] = heat_transfer_i + total_heat_transfer_W += heat_transfer_i + heat_transfer_parameters["total"] = total_heat_transfer_W + + return DCCableHeatTransferType( + **heat_transfer_parameters, + ) diff --git a/piel/models/physical/electrical/types.py b/piel/models/physical/electrical/types.py new file mode 100644 index 00000000..7161272f --- /dev/null +++ b/piel/models/physical/electrical/types.py @@ -0,0 +1,125 @@ +from typing import Optional, Union +from ....materials.thermal_conductivity.types import MaterialReferenceType +from ....types import QuantityType + +__all__ = [ + "CoaxialCableGeometryType", + "CoaxialCableHeatTransferType", + "CoaxialCableMaterialSpecificationType", + "DCCableGeometryType", + "DCCableHeatTransferType", + "DCCableMaterialSpecificationType", + "CableHeatTransferTypes", + "CableGeometryTypes", + "CableMaterialSpecificationTypes", +] + + +class CoaxialCableGeometryType(QuantityType): + core_cross_sectional_area_m2: Optional[float] + """ + The cross-sectional area of the core in meters squared. + """ + + length_m: float + """ + The length of the cable in meters. + """ + + sheath_cross_sectional_area_m2: Optional[float] + """ + The cross-sectional area of the sheath in meters squared. + """ + + total_cross_sectional_area_m2: Optional[float] + """ + The total cross-sectional area of the cable in meters squared. + """ + + +class CoaxialCableHeatTransferType(QuantityType): + """ + All units are in watts. + """ + + core: Optional[float] + """ + The computed heat transfer in watts for the core of the cable. + """ + + sheath: Optional[float] + """ + The computed heat transfer in watts for the sheath of the cable. + """ + + dielectric: Optional[float] + """ + The computed heat transfer in watts for the dielectric of the cable. + """ + + total: float + """ + The total computed heat transfer in watts for the cable. + """ + + +class CoaxialCableMaterialSpecificationType(QuantityType): + core: Optional[MaterialReferenceType] + """ + The material of the core. + """ + + sheath: Optional[MaterialReferenceType] + """ + The material of the sheath. + """ + + dielectric: Optional[MaterialReferenceType] + """ + The material of the dielectric. + """ + + +class DCCableGeometryType(QuantityType): + core_cross_sectional_area_m2: float + """ + The cross-sectional area of the core in meters squared. + """ + + length_m: float + """ + The length of the cable in meters. + """ + + total_cross_sectional_area_m2: float + """ + The total cross-sectional area of the cable in meters squared. + """ + + +class DCCableHeatTransferType(QuantityType): + """ + All units are in watts. + """ + + core: Optional[float] + """ + The computed heat transfer in watts for the core of the cable. + """ + + total: float + """ + The total computed heat transfer in watts for the cable. + """ + + +class DCCableMaterialSpecificationType(QuantityType): + core: Optional[MaterialReferenceType] + """ + The material of the core. + """ + + +CableHeatTransferTypes = Union[CoaxialCableHeatTransferType, DCCableHeatTransferType] +CableGeometryTypes = Union[CoaxialCableGeometryType, DCCableGeometryType] +CableMaterialSpecificationTypes = Union[CoaxialCableMaterialSpecificationType, DCCableMaterialSpecificationType] diff --git a/sys b/piel/models/physical/electronic/hva.py similarity index 100% rename from sys rename to piel/models/physical/electronic/hva.py diff --git a/piel/models/physical/electronic/lna.py b/piel/models/physical/electronic/lna.py new file mode 100644 index 00000000..5c640557 --- /dev/null +++ b/piel/models/physical/electronic/lna.py @@ -0,0 +1,2 @@ +from .types import LNAMetricsType + diff --git a/piel/models/physical/electronic/types.py b/piel/models/physical/electronic/types.py new file mode 100644 index 00000000..6995aae1 --- /dev/null +++ b/piel/models/physical/electronic/types.py @@ -0,0 +1,37 @@ +from piel.types import PielBaseModel +from typing import Optional + +__all__ = [ + "LNAMetricsType", +] + +MinimumMaximumType = tuple([Optional[float], Optional[float]]) + + +class LNAMetricsType(PielBaseModel): + """ + Low-noise amplifier metrics. + """ + footprint_mm2: Optional[float] + bandwidth_Hz: Optional[MinimumMaximumType] + noise_figure: Optional[MinimumMaximumType] + power_consumption_mW: Optional[MinimumMaximumType] + power_gain_dB: Optional[MinimumMaximumType] + supply_voltage_V: Optional[float] + technology_nm: Optional[float] + technology_material: Optional[str] + + +class HVAMetricsType(PielBaseModel): + """ + High-voltage amplifier metrics. + """ + footprint_mm2: Optional[float] + bandwidth_Hz: Optional[MinimumMaximumType] + power_added_efficiency: Optional[MinimumMaximumType] + power_consumption_mW: Optional[MinimumMaximumType] + power_gain_dB: Optional[MinimumMaximumType] + saturated_power_output_dBm: Optional[float] + supply_voltage_V: Optional[float] + technology_nm: Optional[float] + technology_material: Optional[str] diff --git a/piel/models/physical/thermal.py b/piel/models/physical/thermal.py index 17999eb6..58d2272b 100644 --- a/piel/models/physical/thermal.py +++ b/piel/models/physical/thermal.py @@ -1,4 +1,6 @@ -import jax.numpy as jnp +import numpy as np +from .types import TemperatureRangeTypes, TemperatureRangeLimitType +from piel.types import ArrayTypes __all__ = [ "heat_transfer_1d_W", @@ -7,9 +9,11 @@ def heat_transfer_1d_W( thermal_conductivity_fit, - temperature_range_K: list[float, float], + temperature_range_K: TemperatureRangeTypes, cross_sectional_area_m2: float, - length_m: float + length_m: float, + *args, + **kwargs ) -> float: """ Calculate the heat transfer in watts for a 1D system. The thermal conductivity is assumed to be a function of @@ -29,7 +33,19 @@ def heat_transfer_1d_W( float: The heat transfer in watts for a 1D system. """ - thermal_conductivity_integral_area = jnp.trapz( + if type(temperature_range_K) is tuple: + # TODO how to compare this with the TemperatureRangeLimitType? + temperature_range_K = np.linspace( + temperature_range_K[0], temperature_range_K[1], num=1000, + *args, + **kwargs + ) + elif isinstance(temperature_range_K, ArrayTypes): + pass + else: + raise ValueError("Invalid temperature_range_K type. Must be a TemperatureRangeType.") + + thermal_conductivity_integral_area = np.trapz( thermal_conductivity_fit, temperature_range_K ) return cross_sectional_area_m2 * thermal_conductivity_integral_area / length_m diff --git a/piel/models/physical/types.py b/piel/models/physical/types.py new file mode 100644 index 00000000..2310418a --- /dev/null +++ b/piel/models/physical/types.py @@ -0,0 +1,11 @@ +from ...types import ArrayTypes + +__all__ = [ + "TemperatureRangeLimitType", + "TemperatureRangeArrayType", + "TemperatureRangeTypes", +] + +TemperatureRangeLimitType = tuple[float, float] +TemperatureRangeArrayType = ArrayTypes +TemperatureRangeTypes = TemperatureRangeLimitType | TemperatureRangeArrayType diff --git a/piel/models/transient/electronic/__init__.py b/piel/models/transient/electronic/__init__.py index e69de29b..a63842ee 100644 --- a/piel/models/transient/electronic/__init__.py +++ b/piel/models/transient/electronic/__init__.py @@ -0,0 +1 @@ +from .ideal_rc import * diff --git a/piel/models/transient/electronic/ideal_rc.py b/piel/models/transient/electronic/ideal_rc.py new file mode 100644 index 00000000..143ec7db --- /dev/null +++ b/piel/models/transient/electronic/ideal_rc.py @@ -0,0 +1,59 @@ +import jax.numpy as jnp +from typing import Optional +from .types import RCMultiStageConfigurationType + +__all__ = ["calculate_multistage_rc_performance"] + + +def calculate_multistage_rc_performance( + multistage_configuration: Optional[RCMultiStageConfigurationType] = None, + switching_frequency_Hz: Optional[float] = 1e5, +): + """ + Calculates the total energy and power consumption for charging and discharging + in a multistage RC configuration, as well as the transition energy and power consumption. + + Parameters: + multistage_configuration(Optional[RCMultiStageConfigurationType]): A list of dictionaries containing the voltage and capacitance for each stage. + switching_frequency_Hz(Optional[float]): The switching frequency of the RC stages. + + Returns: + A tuple containing: + - Total charge and discharge energy. + - Total charge and discharge power consumption. + - Transition energy. + - Transition power consumption. + """ + if multistage_configuration is None: + power_level_configuration = (1.8, 3.3, 10) + multistage_configuration = list[ + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[0], "capacitance": 1e-12}, + {"voltage": power_level_configuration[1], "capacitance": 3e-12}, + {"voltage": power_level_configuration[1], "capacitance": 3e-12}, + {"voltage": power_level_configuration[2], "capacitance": 10e-12}, + ] + + # Create JAX arrays from the multistage_configuration + voltage_array = jnp.array([stage["voltage"] for stage in multistage_configuration]) + capacitance_array = jnp.array([stage["capacitance"] for stage in multistage_configuration]) + + # Calculate total charge discharge energy + total_charge_discharge_energy = jnp.sum(voltage_array ** 2 * capacitance_array) + total_charge_discharge_power_consumption = total_charge_discharge_energy * switching_frequency_Hz + transition_energy = total_charge_discharge_power_consumption / 2 + transition_power_consumption = total_charge_discharge_power_consumption / 2 + + return ( + total_charge_discharge_energy, + total_charge_discharge_power_consumption, + transition_energy, + transition_power_consumption, + ) diff --git a/piel/models/transient/electronic/types.py b/piel/models/transient/electronic/types.py new file mode 100644 index 00000000..465f36cd --- /dev/null +++ b/piel/models/transient/electronic/types.py @@ -0,0 +1 @@ +RCMultiStageConfigurationType = list[dict[str, float]] diff --git a/piel/types.py b/piel/types.py index 87e24b5a..3548282b 100644 --- a/piel/types.py +++ b/piel/types.py @@ -5,6 +5,7 @@ """ import os import pathlib +import pydantic import types import numpy as np import jax.numpy as jnp @@ -12,7 +13,28 @@ __all__ = [ "ArrayTypes", "PathTypes", + "PielBaseModel", ] PathTypes = str | pathlib.Path | os.PathLike | types.ModuleType ArrayTypes = np.ndarray | jnp.ndarray + + +class PielBaseModel(pydantic.BaseModel): + class Config: + arbitrary_types_allowed = True + + def supplied_parameters(self): + # This method returns a list of parameter names that have been supplied (i.e., are not None) + return [param for param, value in self.__dict__.items() if value is not None] + + +class QuantityType(PielBaseModel): + """ + The base class for all cable types. + """ + + units: str + """ + The units of the type. + """ diff --git a/piel/visual/__init__.py b/piel/visual/__init__.py index 8e205040..4f20d5ec 100644 --- a/piel/visual/__init__.py +++ b/piel/visual/__init__.py @@ -1,2 +1,3 @@ from .auto_plot_multiple import * from .data_conversion import * +from .style import * diff --git a/piel/visual/auto_plot_multiple.py b/piel/visual/auto_plot_multiple.py index 669d95d1..b6dfe79a 100644 --- a/piel/visual/auto_plot_multiple.py +++ b/piel/visual/auto_plot_multiple.py @@ -4,7 +4,7 @@ import pandas as pd import pathlib -matplotlib.style.use(pathlib.Path(__file__).parent / pathlib.Path("piel_fast.rcParams")) + __all__ = [ "plot_simple", @@ -12,23 +12,50 @@ ] -def plot_simple(x_data: np.array, y_data: np.array, ylabel: str, xlabel: str): +def plot_simple( + x_data: np.array, + y_data: np.array, + label: str | None = None, + ylabel: str | None = None, + xlabel: str | None = None, + fig: plt.Figure | None = None, + ax: plt.Axes | None = None, + *args, + **kwargs +): """ - Plot a simple line graph. + Plot a simple line graph. The desire of this function is just to abstract the most basic data representation whilst + keeping the flexibility of the matplotlib library. The goal would be as well that more complex data plots can be + constructed from a set of these methods. Args: x_data (np.array): X axis data. y_data (np.array): Y axis data. - ylabel (str): Y axis label. - xlabel (str): X axis label. + label (str, optional): Label for the plot. Defaults to None. + ylabel (str, optional): Y axis label. Defaults to None. + xlabel (str, optional): X axis label. Defaults to None. + fig (plt.Figure, optional): Matplotlib figure. Defaults to None. + ax (plt.Axes, optional): Matplotlib axes. Defaults to None. Returns: plt: Matplotlib plot. """ - plt.plot(x_data, y_data) - plt.ylabel(ylabel) - plt.xlabel(xlabel) - return plt + if (ax is None) and (fig is None): + fig, ax = plt.subplots() + + ax.plot(x_data, y_data, label=label, *args, **kwargs) + + if ylabel is not None: + ax.set_ylabel(ylabel) + + if xlabel is not None: + ax.set_xlabel(xlabel) + + if label is not None: + # This function appends to the existing plt legend + ax.legend() + + return fig, ax def plot_simple_multi_row( diff --git a/piel/visual/style.py b/piel/visual/style.py new file mode 100644 index 00000000..22b16134 --- /dev/null +++ b/piel/visual/style.py @@ -0,0 +1,16 @@ +import matplotlib as mpl +import pathlib + +__all__ = [ + "activate_piel_styles", +] + + +def activate_piel_styles(): + """ + Activates the piel fast rc params. + + Returns: + None + """ + mpl.style.use(pathlib.Path(__file__).parent / pathlib.Path("piel_fast.rcParams")) diff --git a/pyproject.toml b/pyproject.toml index 143fa426..ad7faafc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ packages = [ [tool.poetry.dependencies] python = ">=3.10,<3.12" +pydantic = "^1" amaranth = "0.4.0" amaranth-yosys = "0.35.0.0.post81" cython = "0.29.21"