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 tempfile
import time
from pathlib import Path

import toml
from pyedb import Edb

Define constants

[2]:
AEDT_VERSION = "2026.1"

Preparation#

[3]:
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
file_edb = Path(temp_folder.name) / "test.aedb"
edbapp = Edb(edbpath=str(file_edb), version=AEDT_VERSION)
C:\actions-runner\_work\pyaedt-examples\pyaedt-examples\.venv\lib\site-packages\pyedb\generic\design_types.py:375: UserWarning: You are using PyEDB with grpc, which is currently in beta. Some feature might be missing or not working as expected. Please report any issue you find to the PyEDB team.
  warnings.warn(GRPC_BETA_WARNING, UserWarning)
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Using PyEDB with gRPC as Beta until ANSYS 2027R1 official release.
PyEDB INFO: Logger is initialized in EDB.
PyEDB INFO: legacy v0.75.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: Grpc session started
PyEDB INFO: Grpc session started: pid=7080
PyEDB INFO: RPC session acquired (open databases: 1)
PyEDB INFO: Refreshing the Components dictionary.
PyEDB INFO: EDB C:\Users\ansys\AppData\Local\Temp\tmp2lmw9k9h.ansys\test.aedb created correctly.
PyEDB INFO: EDB initialized.

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 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: Applying materials finished. Time lapse 0:00:00
PyEDB INFO: Applying padstack definitions and instances completed in 0.0160 seconds.
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 terminals completed in 0.0000 seconds.
PyEDB INFO: Placing probes finished. Time lapse 0:00:00
PyEDB INFO: Applying operations completed in 0.0000 seconds.
PyEDB INFO: Applying setups completed in 0.0000 seconds.
[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: RPC session released (open databases: 0)
[7]:
True
[8]:
# Wait 3 seconds before cleaning the temporary directory.
time.sleep(3)

Clean up#

All project files are saved in the folder temp_folder.name. If you’ve run this example as a Jupyter notebook, you can retrieve those project files. The following cell removes all temporary files, including the project folder.

[9]:
temp_folder.cleanup()

Download this example

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