# How do I create a spatially varying material?

| Date       | Category    |
|------------|-------------|
| 2023-12-05 19:33:11 | Mediums |


When a regular Tidy3D <a href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.Medium.html?__hstc=197414576.85a08fc595b47d0b94ebfa20ba44cd6d.1696006513341.1701802736288.1701804845497.22&amp;__hssc=197414576.1.1701804845497&amp;__hsfp=3209960735">Medium</a> or a dispersive medium such as <a href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.Lorentz.html?__hstc=197414576.85a08fc595b47d0b94ebfa20ba44cd6d.1696006513341.1701802736288.1701804845497.22&amp;__hssc=197414576.1.1701804845497&amp;__hsfp=3209960735">Lorentz</a> is assigned to a <a href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.Structure.html?__hstc=197414576.85a08fc595b47d0b94ebfa20ba44cd6d.1696006513341.1701802736288.1701804845497.22&amp;__hssc=197414576.1.1701804845497&amp;__hsfp=3209960735">Structure</a>, the refractive index is homogeneous within the geometry. In some cases, such as gradient-index optics component and inhomogeneous doped structure simulations, a spatially varying refractive index distribution is desirable. Fortunately, Tidy3D supports both <strong>non-dispersive</strong> and <strong>dispersive</strong> media that have a spatially varying refractive index, and thus can help you achieve this result very conveniently.

 

The available custom materials are <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomMedium.html">CustomMedium</a>, <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomPoleResidue.html">CustomPoleResidue</a>, <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomLorentz.html">CustomLorentz</a>, <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomSellmeier.html">CustomSellmeier</a>, <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomDrude.html">CustomDrude</a>, <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomDebye.html">CustomDebye</a>, and <a target="_blank" rel="noopener" href="https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary/tidy3d.CustomAnisotropicMedium.html">CustomAnisotropicMedium</a>. To create a custom medium, call one of the "Custom-" materials, e.g. "CustomMedium" for a spatially varying non-dispersive medium, and provide the related datasets. See <a href="https://www.flexcompute.com/tidy3d/examples/notebooks/CustomMediumTutorial/">this tutorial</a> for examples on creating spatially varying materials.
