Download this example

Download this example as a Jupyter Notebook or as a Python script.


Import Materials#

This example shows how to import materials.

Perform imports and define constants#

Perform required imports.

[1]:
import json
import toml
from pathlib import Path
import tempfile

from IPython.display import display
from ansys.aedt.core.examples.downloads import download_file
import pandas as pd
from pyedb import Edb

Define constants

[2]:
AEDT_VERSION = "2025.2"

Preparation#

[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
file_edb = Path(temp_folder.name) / "test.aedb"
edbapp = Edb(file_edb, edbversion=AEDT_VERSION)
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\misc\decorators.py:33: UserWarning: Argument `edbversion` is deprecated for method `Edb`; use `version` instead.
  warnings.warn(
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\generic\design_types.py:327: UserWarning: Your ANSYS AEDT version is eligible to gRPC version.You might consider switching to that version for better user experience.For more information please check this link: https://edb.docs.pyansys.com/version/dev/grpc_api/index.html
  warnings.warn(GRPC_GENERAL_WARNING, UserWarning)
PyEDB INFO: Star initializing Edb 03:52:23.191627
PyEDB INFO: Edb version 2025.2
PyEDB INFO: Logger is initialized. Log file is saved to C:\Users\ansys\AppData\Local\Temp\pyedb_ansys.log.
PyEDB INFO: legacy v0.56.0
PyEDB INFO: Python version 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PyEDB INFO: create_edb completed in 7.0040 seconds.
PyEDB INFO: EDB C:\Users\ansys\AppData\Local\Temp\tmputfb_6cf.ansys\test.aedb created correctly.
PyEDB INFO: EDB initialization completed in 7.0834 seconds.

Create configure file#

Add distributed ports#

Keywords

  • name. Name of the material.

  • permittivity.

  • conductivity.

  • dielectric_loss_tangent.

  • magnetic_loss_tangent.

  • mass_density.

  • permeability.

  • poisson_ratio.

  • specific_heat.

  • thermal_conductivity.

  • thermal_modifier.

    • property_name.

    • basic_quadratic_c1. The C1 value in the quadratic model.

    • basic_quadratic_c2. The C2 value in the quadratic model.

    • basic_quadratic_temperature_reference. The TempRef value in the quadratic model.

    • advanced_quadratic_lower_limit. The lower temperature limit where the quadratic model is valid.

    • advanced_quadratic_upper_limit. The upper temperature limit where the quadratic model is valid.

    • advanced_quadratic_auto_calculate. The flag indicating whether or not the LowerConstantThermalModifierVal and UpperConstantThermalModifierVal values should be auto calculated.

    • advanced_quadratic_lower_constant. The constant thermal modifier value for temperatures lower than LowerConstantThermalModifierVal

    • advanced_quadratic_upper_constant. The constant thermal modifier value for temperatures greater than UpperConstantThermalModifierVal.

[4]:
materials = [
    {
        "name": "copper",
        "conductivity": 570000000,
        "thermal_modifier": [
            {
                "property_name": "conductivity",
                "basic_quadratic_c1": 0,
                "basic_quadratic_c2": 0,
                "basic_quadratic_temperature_reference": 22,
                "advanced_quadratic_lower_limit": -273.15,
                "advanced_quadratic_upper_limit": 1000,
                "advanced_quadratic_auto_calculate": True,
                "advanced_quadratic_lower_constant": 1,
                "advanced_quadratic_upper_constant": 1,
            },
        ],
    },
]
cfg = {"stackup": {"materials": materials}}
file_json = Path(temp_folder.name) / "edb_configuration.json"
with open(file_json, "w") as f:
    json.dump(cfg, f, indent=4, ensure_ascii=False)

Equivalent toml file looks like below

[5]:
toml_string = toml.dumps(cfg)
print(toml_string)
[stackup]
[[stackup.materials]]
name = "copper"
conductivity = 570000000
[[stackup.materials.thermal_modifier]]
property_name = "conductivity"
basic_quadratic_c1 = 0
basic_quadratic_c2 = 0
basic_quadratic_temperature_reference = 22
advanced_quadratic_lower_limit = -273.15
advanced_quadratic_upper_limit = 1000
advanced_quadratic_auto_calculate = true
advanced_quadratic_lower_constant = 1
advanced_quadratic_upper_constant = 1



Import configuration into example layout#

[6]:
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
PyEDB INFO: Updating boundaries finished. Time lapse 0:00:00
PyEDB INFO: Updating nets finished. Time lapse 0:00:00
PyEDB INFO: Updating components finished. Time lapse 0:00:00
PyEDB INFO: Creating pin groups finished. Time lapse 0:00:00
PyEDB INFO: Placing sources finished. Time lapse 0:00:00
PyEDB INFO: Creating setups finished. Time lapse 0:00:00
PyEDB INFO: Applying materials finished. Time lapse 0:00:00.015846
PyEDB INFO: Updating stackup finished. Time lapse 0:00:00
PyEDB INFO: Applying padstacks finished. Time lapse 0:00:00
PyEDB INFO: Applying S-parameters finished. Time lapse 0:00:00
PyEDB INFO: Applying package definitions finished. Time lapse 0:00:00
PyEDB INFO: Applying modeler finished. Time lapse 0:00:00
PyEDB INFO: Placing ports finished. Time lapse 0:00:00
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Applying operations finished. Time lapse 0:00:00
[6]:
True

Save and close Edb#

The temporary folder will be deleted once the execution of this script is finished. Replace edbapp.save() with edbapp.save_as(“C:/example.aedb”) to keep the example project.

[7]:
edbapp.save()
edbapp.close()
PyEDB INFO: Save Edb file completed in 0.0000 seconds.
PyEDB INFO: Close Edb file completed in 0.0000 seconds.
[7]:
True

Download this example

Download this example as a Jupyter Notebook or as a Python script.