Skip to content

Commit

Permalink
Final comment
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-flex committed Jan 24, 2025
1 parent 1813a80 commit ed78fc8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tests/test_components/test_heat_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,32 +1134,32 @@ def test_gaussian_doping_sigma_calculation():


def test_gaussian_doping_get_contrib():
"""Test get_contrib method in GaussianDoping."""
"""Test _get_contrib method in GaussianDoping."""
max_N = 1e18
min_N = 1e15
width = 0.1

box = td.GaussianDoping(ref_con=min_N, concentration=max_N, width=width, source="xmin")

coords = {"x": [0], "y": [0], "z": [0]}
contrib = box.get_contrib(coords)
contrib = box._get_contrib(coords)
assert np.isclose(float(contrib), max_N, rtol=1e-6)

coords = {"x": [0.5], "y": [0], "z": [0]}
contrib = box.get_contrib(coords)
contrib = box._get_contrib(coords)
assert np.isclose(float(contrib), min_N, rtol=1e-6)

coords = {"x": [0.5 - width / 2], "y": [0], "z": [0]}
contrib = box.get_contrib(coords)
contrib = box._get_contrib(coords)
expected_value = max_N * np.exp(-width * width / 4 / box.sigma / box.sigma / 2)
assert np.isclose(float(contrib), expected_value, rtol=1e-6)


def test_gaussian_doping_get_contrib_2d_coords():
"""Test get_contrib method in GaussianDoping with 2D coordinates."""
"""Test _get_contrib method in GaussianDoping with 2D coordinates."""
box = td.GaussianDoping(ref_con=1e15, concentration=1e18, width=0.1, source="xmin")
coords = {"x": [0], "y": [0], "z": [-0.5, 0, 0.5]}
contrib = box.get_contrib(coords)
contrib = box._get_contrib(coords)


def test_gaussian_doping_bounds_behavior():
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/components/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ def _pcolormesh_shape_doping_box(
struct_doping[n] = struct_doping[n] + contrib
if isinstance(doping_box, GaussianDoping):
coords_dict = {"xyz"[d]: coords_2D[d] for d in plane_axes_inds}
contrib = doping_box.get_contrib(coords_dict)
contrib = doping_box._get_contrib(coords_dict)
struct_doping[n] = struct_doping[n] + contrib

if plt_type == "doping":
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/components/tcad/doping.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def sigma(self):
"""The sigma parameter of the pseudo-gaussian"""
return np.sqrt(-self.width * self.width / 2 / np.log(self.ref_con / self.concentration))

def get_contrib(self, coords: dict, meshgrid: bool = True):
def _get_contrib(self, coords: dict, meshgrid: bool = True):
"""Returns the contribution to the doping a the locations specified in coords"""

# work out whether x,y, and z are present
Expand Down

0 comments on commit ed78fc8

Please sign in to comment.