### Install SuperScreen from GitHub Source: https://superscreen.readthedocs.io/en/latest/_sources/installation.rst.txt Install SuperScreen directly from its GitHub repository. This is useful for getting the latest development version. ```bash pip install git+https://github.com/loganbvh/superscreen.git ``` -------------------------------- ### Install Superscreen in Google Colab Source: https://superscreen.readthedocs.io/en/latest/notebooks/logo.html Installs the Superscreen library from GitHub if the environment is Google Colab. This is a prerequisite for running the subsequent examples. ```python if "google.colab" in str(get_ipython()): %pip install --quiet git+https://github.com/loganbvh/superscreen.git ``` -------------------------------- ### Install SuperScreen from GitHub Source: https://superscreen.readthedocs.io/en/latest/notebooks/scanning-squid.html Installs the SuperScreen library from GitHub. This is typically used in environments like Google Colab. ```python # Automatically install superscreen from GitHub only if running in Google Colab if "google.colab" in str(get_ipython()): %pip install --quiet git+https://github.com/loganbvh/superscreen.git ``` -------------------------------- ### Install SuperScreen from PyPI Source: https://superscreen.readthedocs.io/en/latest/_sources/installation.rst.txt Use this command to install the latest stable version of SuperScreen from the Python Package Index. ```bash pip install superscreen ``` -------------------------------- ### Verify SuperScreen Installation Source: https://superscreen.readthedocs.io/en/latest/installation.html Run the SuperScreen test suite within a Python session to confirm the installation was successful. ```python import superscreen.testing as st st.run() ``` -------------------------------- ### Polygon Bounds (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the bounding box coordinates of a polygon. This example shows the output of the `bounds` attribute. ```python print(f"The bounds of the polygon are: {bounds}") ``` -------------------------------- ### Configuration Example Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Illustrates a configuration setting related to field sources. This might affect how data is fetched or stored. ```yaml field_sources: default_provider: "local" cache_enabled: true cache_ttl: 3600 ``` -------------------------------- ### Polygon Equals (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates the result of checking if polygons are equal. This example shows boolean outputs for the `equals` method. ```python print(f"Is polygon1 equal to polygon2? {polygon1.equals(polygon2)}") print(f"Is polygon1 equal to polygon3? {polygon1.equals(polygon3)}") ``` -------------------------------- ### Polygon Boundary (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the geometry type and coordinates of a polygon's boundary. This example demonstrates the `boundary` property. ```python print(f"Boundary type: {boundary.geom_type}") print(f"Boundary coordinates: {list(boundary.coords)}") ``` -------------------------------- ### Polygon Simplify (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the number of points in a simplified polygon compared to the original. This example demonstrates the `simplify` method. ```python print(f"Original polygon points: {len(complex_polygon.exterior.coords)}") print(f"Simplified polygon points: {len(simplified_polygon.exterior.coords)}") ``` -------------------------------- ### Install SuperScreen from GitHub (Colab) Source: https://superscreen.readthedocs.io/en/latest/notebooks/polygons.html Installs the SuperScreen library directly from its GitHub repository. This is useful when running in environments like Google Colab to ensure you have the latest version. ```python # Automatically install superscreen from GitHub only if running in Google Colab if "google.colab" in str(get_ipython()): %pip install --quiet git+https://github.com/loganbvh/superscreen.git ``` -------------------------------- ### Polygon Union (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Calculates and prints the area of the union of two polygons. This example demonstrates the `union` method. ```python print(f"Union area: {union.area}") ``` -------------------------------- ### Polygon from WKT (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the area of a polygon created from a WKT string. This example demonstrates creating a polygon using `Polygon(wkt_string)`. ```python print(f"Created polygon area: {polygon.area}") ``` -------------------------------- ### Polygon WKT Representation (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the Well-Known Text (WKT) representation of a polygon. This example shows the output of the `wkt` attribute. ```python print(f"WKT representation: {wkt_representation}") ``` -------------------------------- ### Polygon Area Calculation (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt A concrete example demonstrating the calculation of a polygon's area. This snippet is part of a larger demonstration. ```python print(polygon.area) ``` -------------------------------- ### Polygon Touches (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates the result of checking if a polygon touches a point. This example shows boolean outputs for the `touches` method. ```python print(f"Does polygon touch point (0, 1)? {polygon.touches(point_on_boundary)}") print(f"Does polygon touch point (1, 1)? {polygon.touches(point_inside)}") ``` -------------------------------- ### Polygon Disjoint (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates the result of checking if polygons are disjoint. This example shows boolean outputs for the `disjoint` method. ```python print(f"Are polygon1 and polygon2 disjoint? {polygon1.disjoint(polygon2)}") print(f"Are polygon1 and polygon3 disjoint? {polygon1.disjoint(polygon3)}") ``` -------------------------------- ### Polygon Area Calculation (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Another concrete example for calculating polygon area, likely from a different context or with different input. ```python print(polygon_with_hole.area) ``` -------------------------------- ### Run SuperScreen Tests from Command Line Source: https://superscreen.readthedocs.io/en/latest/_sources/installation.rst.txt An alternative method to verify your SuperScreen installation by executing the test suite directly from your terminal. ```bash python -m superscreen.testing ``` -------------------------------- ### Polygon Exterior Coordinates (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the coordinates of a polygon's exterior boundary. This example shows how to access the `exterior` property and its `coords`. ```python print(f"Exterior coordinates: {list(polygon_with_hole.exterior.coords)}") ``` -------------------------------- ### Solution.__init__ Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/solution.html Initializes a Solution object with simulation results and device parameters. ```APIDOC ## Solution.__init__ ### Description Initializes a Solution object, which serves as a container for calculated stream functions and fields, along with convenient data processing methods. ### Method `__init__(self, *, device: Device, film_solutions: Dict[str, FilmSolution], applied_field_func: Callable, field_units: str, current_units: str, circulating_currents: Optional[Dict[str, float]] = None, terminal_currents: Optional[Dict[str, float]] = None, vortices: Optional[List[Vortex]] = None, solver: str = "superscreen.solve")` ### Parameters * `device` (Device) - The ``Device`` that was solved. * `film_solutions` (Dict[str, FilmSolution]) - A dictionary mapping film names to their corresponding ``FilmSolution`` objects, containing raw simulation results. * `applied_field_func` (Callable) - The function defining the applied magnetic field. * `field_units` (str) - The units used for magnetic field quantities. * `current_units` (str) - The units used for current quantities. * `circulating_currents` (Optional[Dict[str, float]], optional) - A dictionary mapping hole names to their circulating currents. Defaults to None. * `terminal_currents` (Optional[Dict[str, float]], optional) - A dictionary mapping terminal names to their terminal currents. Defaults to None. * `vortices` (Optional[List[Vortex]], optional) - A list of ``Vortex`` objects located in the ``Device``. Defaults to None. * `solver` (str, optional) - The name of the solver method used to generate the solution. Defaults to "superscreen.solve". ``` -------------------------------- ### Create and Save Initial Solution Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/solver/solve.html Constructs the initial `Solution` object and saves it to an HDF5 file if `save_path` is provided. The device is saved in the root group, and the solution is linked. ```python solution = Solution(device=device, film_solutions=film_solutions, **solution_kwargs) if save_path is not None: with h5py.File(save_path, "x") as h5file: # Save device in the root group. Solutions from all iterations # will reference the device with an h5py.SoftLink. device.to_hdf5(h5file.create_group("device")) solution.to_hdf5(h5file.create_group(str(0)), device_path="/device") ``` -------------------------------- ### Install Superscreen Conditionally in Colab Source: https://superscreen.readthedocs.io/en/latest/notebooks/logo.html Installs the superscreen library from GitHub only when running in a Google Colab environment. Ensure you have internet connectivity for the installation. ```python from IPython import get_ipython if get_ipython() is not None: # Install superscreen from GitHub only if running in Google Colab !pip install git+https://github.com/superscreen/superscreen.git ``` -------------------------------- ### Polygon Area (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the calculated area of a polygon. This is a straightforward example of the `area` attribute. ```python print(f"The area of the polygon is: {area}") ``` -------------------------------- ### Basic Polygon Creation Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates how to create a basic polygon. Ensure necessary libraries are imported. ```python from shapely.geometry import Polygon # Create a polygon with exterior coordinates polygon = Polygon([(0, 0), (1, 1), (1, 0)]) print(polygon.area) ``` -------------------------------- ### Polygon Length (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the calculated perimeter length of a polygon. This is a straightforward example of the `length` attribute. ```python print(f"The length of the polygon boundary is: {length}") ``` -------------------------------- ### Solution Class Initialization Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/solution.html Initializes the Solution object, storing device information, film solutions, applied field function, units, and other simulation parameters. Makes a copy of the device. ```python self.device = device.copy(with_mesh=True, copy_mesh=False) self.film_solutions = film_solutions self.applied_field_func = applied_field_func self.circulating_currents = circulating_currents or {} self.terminal_currents = terminal_currents or {} self.vortices = vortices or [] # Make field_units and current_units "read-only" attributes. # The should never be changed after instantiation. self._field_units = field_units self._current_units = current_units self._solver = solver self._time_created = dt.datetime.now() self._version_info = version_dict() ``` -------------------------------- ### Polygon GeoJSON Representation (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the GeoJSON representation of a polygon. This example shows the output of the `geojson` attribute. ```python print(f"GeoJSON representation: {geojson_representation}") ``` -------------------------------- ### Polygon Relate (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the spatial relationship matrix between two polygons. This example demonstrates the `relate` method. ```python print(f"Spatial relationship between polygon1 and polygon2: {relation}") ``` -------------------------------- ### Create a Document with Field Sources, Field Source Types, and Default Values Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Demonstrates creating a Document that integrates field sources, field source types, and default values. This provides a highly structured and robust data representation. ```python from typing import Any, Dict, List, Optional, Tuple from langchain_core.documents import Document from langchain_core.fields import Field, FieldSource, FieldSourceType def create_document_with_field_sources_field_source_types_and_default_values(page_content: str, field_sources: List[FieldSource], field_source_types: List[FieldSourceType]) -> Document: """Create a Document with field sources, field source types, and default values.""" return Document(page_content=page_content, field_sources=field_sources, field_source_types=field_source_types) ``` -------------------------------- ### Create a Document with Field Sources and Metadata Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Shows how to create a Document that includes field sources and associated metadata. This allows for more detailed context about the data. ```python from typing import Any, Dict, List, Optional, Tuple from langchain_core.documents import Document from langchain_core.fields import Field, FieldSource, FieldSourceType def create_document_with_field_sources_and_metadata(page_content: str, field_sources: List[FieldSource], metadata: Dict[str, Any]) -> Document: """Create a Document with field sources and metadata.""" return Document(page_content=page_content, field_sources=field_sources, metadata=metadata) ``` -------------------------------- ### Polygon Difference (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Calculates and prints the area of the difference between two polygons. This example demonstrates the `difference` method. ```python print(f"Difference area: {difference.area}") ``` -------------------------------- ### Create a Field Source Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Demonstrates how to create a new field source. This is a foundational step for managing and utilizing field data. ```python from typing import Any, Dict, List, Optional, Tuple from langchain_core.documents import Document from langchain_core.fields import Field, FieldSource, FieldSourceType def create_field_source(name: str, fields: List[Field]) -> FieldSource: """Create a FieldSource.""" return FieldSource(name=name, fields=fields) ``` -------------------------------- ### Polygon Intersection (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Calculates and prints the area of the intersection between two polygons. This example demonstrates the `intersection` method. ```python print(f"Intersection area: {intersection.area}") ``` -------------------------------- ### Create a Document with Field Sources and Default Values Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Demonstrates creating a Document that incorporates field sources with default values. This allows for documents to have inherent default data. ```python from typing import Any, Dict, List, Optional, Tuple from langchain_core.documents import Document from langchain_core.fields import Field, FieldSource, FieldSourceType def create_document_with_field_sources_and_default_values(page_content: str, field_sources: List[FieldSource]) -> Document: """Create a Document with field sources and default values.""" return Document(page_content=page_content, field_sources=field_sources) ``` -------------------------------- ### Polygon Buffering (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Calculates the area of a buffered polygon. This example shows the result of applying a buffer operation. ```python print(f"Buffered polygon area: {buffered_polygon.area}") ``` -------------------------------- ### Initialize Device Object Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/device/device.html Instantiate a Device object with its name, layers, films, holes, terminals, and abstract regions. Ensure all provided polygons are valid and assigned to existing layers. ```python Device( name="my_device", layers=[ Layer(name="layer1", thickness=0.1*ureg("um")), Layer(name="layer2", thickness=0.1*ureg("um")), ], films={ "film1": Polygon(name="film1", layer="layer1", vertices=[(0,0), (10,0), (10,10), (0,10)]), "film2": Polygon(name="film2", layer="layer1", vertices=[(10,0), (20,0), (20,10), (10,10)]), }, holes={ "hole1": Polygon(name="hole1", layer="layer1", vertices=[(2,2), (8,2), (8,8), (2,8)]), }, terminals={ "film1": [Polygon(name="term1", layer="layer1", vertices=[(0,0), (2,0), (2,2), (0,2)])], }, abstract_regions=[ Polygon(name="region1", layer="layer2", vertices=[(0,0), (20,0), (20,10), (0,10)]), ], length_units="um", solve_dtype="float64", ) ``` -------------------------------- ### Simulate with Multiple Sources and One Drain Source: https://superscreen.readthedocs.io/en/latest/notebooks/terminal-currents.html Applies a set of terminal currents to the device model and solves for the resulting current distribution. This example demonstrates a configuration where three terminals act as sources and one acts as a drain, summing to a net current. ```python # Each terminal current can be a float, string, or pint.Quantity terminal_currents = { "source1": "1 uA", "source2": sc.ureg("2 uA"), "source3": 3, "drain": "-6 uA", } solution = solve_and_plot_model({"plus": terminal_currents}) ``` -------------------------------- ### Create a Field Source with Field Source Types Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Demonstrates initializing a FieldSource with a list of FieldSourceType objects. This links the data source definition to its categorization. ```python from typing import Any, Dict, List, Optional, Tuple from langchain_core.documents import Document from langchain_core.fields import Field, FieldSource, FieldSourceType def create_field_source_with_field_source_types(name: str, fields: List[Field], field_source_types: List[FieldSourceType]) -> FieldSource: """Create a FieldSource with field source types.""" return FieldSource(name=name, fields=fields, field_source_types=field_source_types) ``` -------------------------------- ### Device Initialization Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/device/device.html Initializes a Device object with its name, layers, films, and optional holes, terminals, and abstract regions. ```APIDOC ## Device ### Description An object representing a device composed of one or more layers of thin film superconductor. ### Parameters - **name** (str) - Required - Name of the device. - **layers** (Union[Sequence[Layer], Dict[str, Layer]]) - Required - Layers making up the device. - **films** (Union[Sequence[Polygon], Dict[str, Polygon]]) - Required - Polygons representing regions of superconductor. - **holes** (Optional[Union[Sequence[Polygon], Dict[str, Polygon]]]) - Optional - Holes representing holes in superconducting films. - **terminals** (Optional[Dict[str, List[Polygon]]]) - Optional - A dict of {film_name: terminals} representing transport terminals in the device. - **abstract_regions** (Optional[Union[Sequence[Polygon], Dict[str, Polygon]]]) - Optional - Polygons representing abstract regions in a device. - **length_units** (str) - Optional - Distance units for the coordinate system. Defaults to "um". - **solve_dtype** (Union[str, np.dtype]) - Optional - The float data type to use when solving the device. Defaults to "float32". ``` -------------------------------- ### Solution.version_info Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/solution.html Provides version information for dependencies. ```APIDOC ## Solution.version_info ### Description Returns a dictionary containing version information for the solution's dependencies. ### Property `version_info` (Dict[str, str]) ### Returns * `Dict[str, str]` - A dictionary of dependency versions. ``` -------------------------------- ### Polygon Overlaps (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates the result of checking if polygons overlap. This example shows boolean outputs for the `overlaps` method. ```python print(f"Does polygon1 overlap polygon2? {polygon1.overlaps(polygon2)}") print(f"Does polygon1 overlap polygon3? {polygon1.overlaps(polygon3)}") ``` -------------------------------- ### Polygon Convex Hull (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Calculates and prints the area of the convex hull of a polygon. This example demonstrates the `convex_hull` property. ```python print(f"Convex hull area: {convex_hull.area}") ``` -------------------------------- ### Import Libraries and Set Up Environment Source: https://superscreen.readthedocs.io/en/latest/notebooks/logo.html Imports necessary libraries including numpy, matplotlib, and superscreen. It also sets environment variables for numerical computation and configures matplotlib for inline plotting. ```python %config InlineBackend.figure_formats = {"retina", "png"} %matplotlib inline import os os.environ["OPENBLAS_NUM_THREADS"] = "1" import numpy as np from matplotlib.textpath import TextPath from matplotlib.font_manager import FontProperties import superscreen as sc SAVE = False ``` -------------------------------- ### Polygon Validity Check (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Checks if a polygon object is geometrically valid. This example demonstrates the usage of the `is_valid` attribute. ```python print(f"Is valid: {valid_polygon.is_valid}") ``` -------------------------------- ### Create a Document with Field Sources and Field Source Types Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Demonstrates creating a Document that includes both field sources and field source types. This provides a comprehensive way to structure and annotate data. ```python from typing import Any, Dict, List, Optional, Tuple from langchain_core.documents import Document from langchain_core.fields import Field, FieldSource, FieldSourceType def create_document_with_field_sources_and_types(page_content: str, field_sources: List[FieldSource], field_source_types: List[FieldSourceType]) -> Document: """Create a Document with field sources and field source types.""" return Document(page_content=page_content, field_sources=field_sources, field_source_types=field_source_types) ``` -------------------------------- ### Polygon Crosses (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates the result of checking if a polygon crosses lines. This example shows boolean outputs for the `crosses` method. ```python print(f"Does polygon cross line_crossing? {polygon.crosses(line_crossing)}") print(f"Does polygon cross line_within? {polygon.crosses(line_within)}") ``` -------------------------------- ### Polygon Intersects (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Demonstrates the result of checking if a polygon intersects with points. This example shows boolean outputs for the `intersects` method. ```python print(f"Does polygon intersect point (1, 1)? {polygon.intersects(point_inside)}") print(f"Does polygon intersect point (3, 3)? {polygon.intersects(point_outside)}") ``` -------------------------------- ### Polygon Centroid (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the coordinates of a polygon's centroid. This example shows how to access the centroid's x and y attributes. ```python print(f"Centroid coordinates: ({centroid.x}, {centroid.y})") ``` -------------------------------- ### Polygon Symmetric Difference (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Calculates and prints the area of the symmetric difference between two polygons. This example demonstrates the `symmetric_difference` method. ```python print(f"Symmetric difference area: {symmetric_difference.area}") ``` -------------------------------- ### Configure Matplotlib and Import Libraries Source: https://superscreen.readthedocs.io/en/latest/notebooks/terminal-currents.html Sets up matplotlib for inline plotting and configures environment variables for numerical computations. Imports necessary superscreen modules and utilities. ```python %config InlineBackend.figure_formats = {"retina", "png"} %matplotlib inline import os os.environ["OPENBLAS_NUM_THREADS"] = "1" import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = (5, 4) plt.rcParams["font.size"] = 10 import superscreen as sc from superscreen.geometry import box, circle, rotate ``` -------------------------------- ### Instantiate and Print ConstantField Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/field-sources.ipynb.txt Demonstrates how to create a ConstantField with a specified value and print its representation. This field is useful for simulating a uniform magnetic field. ```python field = sc.sources.ConstantField(5) print(field) ``` -------------------------------- ### Initialize a Layer with London Lambda and Thickness Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/device/layer.html Instantiate a Layer object by providing both the London penetration depth and the layer thickness. This is an alternative to providing the effective Lambda directly. ```python layer = Layer(name='superconducting_layer', london_lambda=0.2e-6, thickness=0.1e-6, z0=0.1e-6) ``` -------------------------------- ### Polygon Area with Holes (Example) Source: https://superscreen.readthedocs.io/en/latest/_sources/notebooks/polygons.ipynb.txt Prints the calculated area of a polygon with an interior hole. This example shows the `area` attribute for polygons with holes. ```python print(f"Area of polygon with hole: {polygon_with_hole.area}") ``` -------------------------------- ### Copy Device Configuration Source: https://superscreen.readthedocs.io/en/latest/_modules/superscreen/device/device.html Creates a copy of the Device instance. Allows control over whether to copy the mesh data (shallow or deep copy). ```python layers = [layer.copy() for layer in self.layers.values()] films = [film.copy() for film in self.films.values()] holes = [hole.copy() for hole in self.holes.values()] terminals = { film: [term.copy() for term in film_terms] for film, film_terms in self.terminals.items() } abstract_regions = [region.copy() for region in self.abstract_regions.values()] device = Device( self.name, layers=layers, films=films, holes=holes, terminals=terminals, abstract_regions=abstract_regions, length_units=self.length_units, ) if with_mesh and self.meshes is not None: meshes = self.meshes if copy_mesh: meshes = {name: mesh.copy() for name, mesh in meshes.items()} device.meshes = meshes return device ```